Repository navigation
Reuse a runtime-descriptor LTO driver for AST JIT evaluation #24407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
vyasr
wants to merge
9
commits into
NVIDIA:main
Choose a base branch
from
vyasr:codex/ast-runtime-lto
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+606
−77
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d089788
Reuse a runtime-descriptor LTO driver for multi-output AST JIT
vyasr 3487e31
Fix AST LTO test type deduction and cache array lint
vyasr c1dcf42
Preserve AST LTO scratch allocation policy and expand error coverage
vyasr 21294ca
Trim redundant AST LTO regression tests
vyasr 5cee814
Simplify AST runtime LTO linkage and error handling
vyasr 133cf2a
Extend AST runtime LTO to single outputs and retained programs
vyasr 1beef23
Simplify AST LTO cache layering and runtime driver handling
vyasr 6ce2666
Keep AST driver lightweight and clarify fragment retention
vyasr cccb586
Trim redundant AST runtime LTO regression coverage
vyasr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <cuda/std/cstdint> | ||
|
|
||
| namespace cudf::jit::ast_runtime { | ||
|
|
||
| // Keep this internal ABI independent of column types and schema width so one row-loop fragment | ||
| // can serve every supported fixed-width AST expression. | ||
| struct input_descriptor { | ||
| void const* data; | ||
| cuda::std::uint32_t const* null_mask; | ||
| cuda::std::int32_t offset; | ||
| bool scalar; | ||
| }; | ||
|
|
||
| struct output_descriptor { | ||
| void* data; | ||
| cuda::std::uint32_t* null_mask; | ||
| }; | ||
|
|
||
| } // namespace cudf::jit::ast_runtime | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include <cudf/errc.hpp> | ||
|
|
||
| #include <transform/jit/ast_runtime_descriptor.hpp> | ||
|
|
||
| namespace cudf::jit::ast_runtime { | ||
|
|
||
| extern "C" __device__ cudf::errc transform_row(cuda::std::int32_t row, | ||
| cuda::std::uint32_t active_mask, | ||
| input_descriptor const* inputs, | ||
| output_descriptor const* outputs); | ||
|
|
||
| } // namespace cudf::jit::ast_runtime | ||
|
|
||
| extern "C" __global__ void cudf_kernel_entry( | ||
| cuda::std::int32_t row_size, | ||
| cuda::std::uint32_t const* stencil, | ||
| void*, | ||
| cudf::jit::ast_runtime::input_descriptor const* inputs, | ||
| cudf::jit::ast_runtime::output_descriptor const* outputs, | ||
| cuda::std::int32_t* max_error) | ||
| { | ||
| auto const start = static_cast<cuda::std::int64_t>(blockIdx.x) * blockDim.x + threadIdx.x; | ||
| auto const stride = static_cast<cuda::std::int64_t>(gridDim.x) * blockDim.x; | ||
| // The final warp must reach the active-lane ballot together, even when its last rows are absent. | ||
| auto const padded_rows = (static_cast<cuda::std::int64_t>(row_size) + 31) / 32 * 32; | ||
| auto thread_error = cudf::errc::SUCCESS; | ||
| for (auto row = start; row < padded_rows; row += stride) { | ||
| auto const active = | ||
| row < row_size && (stencil == nullptr || (stencil[row / 32] & (1u << (row % 32)))); | ||
| auto const active_mask = __ballot_sync(0xffffffffu, active); | ||
| if (!active) { continue; } | ||
| auto const error = cudf::jit::ast_runtime::transform_row( | ||
| static_cast<cuda::std::int32_t>(row), active_mask, inputs, outputs); | ||
| if (static_cast<int>(error) > static_cast<int>(thread_error)) { thread_error = error; } | ||
| } | ||
| if (thread_error != cudf::errc::SUCCESS) { atomicMax(max_error, static_cast<int>(thread_error)); } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include <cudf/detail/row_ir/opcode.hpp> | ||
| #include <cudf/errc.hpp> | ||
| #include <cudf/utilities/bit.hpp> | ||
|
|
||
| #include <cuda/std/optional> | ||
|
|
||
| #include <jit/sync.cuh> | ||
| #include <transform/jit/ast_runtime_descriptor.hpp> | ||
|
|
||
| // Keep generated operations outside the reusable precompiled-header prefix. | ||
| // https://docs.nvidia.com/cuda/archive/12.9.0/nvrtc/index.html#determining-the-header-stop-point | ||
| #pragma nv_hdrstop | ||
|
|
||
| namespace cudf::jit::ast_runtime { | ||
|
|
||
| template <typename T, bool Nullable> | ||
| __device__ auto load(input_descriptor const& column, cuda::std::int32_t row) | ||
| { | ||
| auto const index = column.offset + (column.scalar ? 0 : row); | ||
| if constexpr (Nullable) { | ||
| if (!cudf::bit_value_or(column.null_mask, index, true)) { return cuda::std::optional<T>{}; } | ||
| return cuda::std::optional<T>{static_cast<T const*>(column.data)[index]}; | ||
| } else { | ||
| return static_cast<T const*>(column.data)[index]; | ||
| } | ||
| } | ||
|
|
||
| template <typename T> | ||
| __device__ void store(output_descriptor const& column, | ||
| cuda::std::int32_t row, | ||
| cuda::std::uint32_t, | ||
| T value) | ||
| { | ||
| static_cast<T*>(column.data)[row] = value; | ||
| } | ||
|
|
||
| template <typename T> | ||
| __device__ void store(output_descriptor const& column, | ||
| cuda::std::int32_t row, | ||
| cuda::std::uint32_t active_mask, | ||
| cuda::std::optional<T> value) | ||
| { | ||
| // Null positions have no defined value, but maskless outputs still need initialized data. | ||
| if (value.has_value() || column.null_mask == nullptr) { | ||
| static_cast<T*>(column.data)[row] = value.value_or(T{}); | ||
| } | ||
| // All active lanes must participate, including lanes whose value store was skipped. | ||
| cudf::jit::warp_compact_validity(active_mask, column.null_mask, row, value.has_value()); | ||
| } | ||
|
|
||
| #include <cudf/detail/operation_udf.cuh> | ||
|
|
||
| } // namespace cudf::jit::ast_runtime | ||
|
|
||
| // Registering a global entry makes retention of this otherwise device-only fragment explicit | ||
| // across NVRTC versions before the driver is linked. This anchor is never launched. | ||
| extern "C" __global__ void cudf_ast_runtime_entry() | ||
| { | ||
| auto const operation = &cudf::jit::ast_runtime::transform_row; | ||
| asm volatile("" : : "l"(operation)); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is essentially a
column_device_view+is_scalar.We can request that users use a record type equivalent to a
column_device_viewrather than creating an entirely separate struct.