Skip to content

Support checked Block callbacks with uniform captures - #1625

Draft
tpn wants to merge 106 commits into
NVIDIA:mainfrom
tpn:codex/coop-interop-callables-stable199
Draft

tpn wants to merge 106 commits into
NVIDIA:mainfrom
tpn:codex/coop-interop-callables-stable199

Conversation

@tpn

@tpn tpn commented Oct 23, 2026 •

Copy link
Copy Markdown

Checked Block payload collectives can call Rust function items, stateless closures or closures holding one immutable uniform i32 value. The compiler authenticates and retains the thunk and environment while preserving participation, input-validity and scratch checks. It checks the actual capture value, rejects lane-dependent or unsupported captures, and conservatively invalidates borrowed slots after exposure.

The retained commits separate stateless callbacks from uniform capture support. This incorporates the former #1626 scope. The paired Block/Raking Reduce API is published in draft NVIDIA/cccl#12248; the stateless Merge Sort Keys comparator remains a distinct API change in NVIDIA/cccl#12250.

Recorded host/strict checks and focused admission controls pass. Stateless and captured Reduce ordinary Git Normal binaries each pass eight GPU commands, including six sanitizer runs. Fresh HTTPS builds and scoped executable/ABI/resource/launch comparisons pass; capture Full remains compile-qualified, and these receipts do not claim capture HTTPS GPU execution. The accepted source is unchanged by consolidation; current-head CI is checked separately.

Builds on #1589 and the existing low-level callback owner #1575. Review the combined 17-file change (+852/−75). GitHub’s main-based Files tab includes prerequisites; a narrow stacked base requires a maintainer-created upstream branch or prerequisite landing. This PR remains draft.

fxeqxmulfx and others added 30 commits October 12, 2026 02:14
With `lto = "fat"` or `lto = "thin"`, the build of a binary that uses a
library with kernels stopped with an error: "failed to get bitcode from
object file for LTO (Can't find section .llvmbc)". rustc keeps a list of
the Rust objects in each rlib. This list contains the objects of all
modules. With LTO, rustc reads bitcode from these objects and removes
them from the link. The artifact objects have no bitcode.

If a session writes an rlib, the backend now gives each artifact object
to rustc as the DWARF object of its module. This object is in the rlib,
but it is not in the list. LTO does not read this object, and the linker
gets it from the rlib.

The system linker does not get the DWARF objects. If the session also
writes a binary or a dynamic library, the backend gives the artifact
objects to this linker as link arguments. With
`-Zlink-native-libraries=no`, rustc does not give link arguments to the
linker. Then the artifact objects of this session are Rust objects, as
before.

The book said that `join_codegen()` and `link()` only call the LLVM
backend. Now it tells what they add to the outputs.

CI builds `cuda_module_in_lib` with fat LTO. The library is an rlib, and
then an rlib and a cdylib. After each build, CI makes sure that the
binary has the PTX bundles of the library and of the binary. It also
makes sure that the cdylib has the PTX bundle of the library.

Fixes NVIDIA#1495

Signed-off-by: Mikhail Borisov <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Use Cargo target names for standalone emit-ltoir artifacts. Bind the
compiler and reader to the same intermediate directory when invoked
from a Cargo workspace member.

Signed-off-by: Trent Nelson <[email protected]>
Accept ordered external LTO files when materializing embedded cubins.
Include their content in the codegen fingerprint and verify owned bytes
before linking through the existing finalizer. Preserve inputs that
overlap generated output paths and diagnose unresolved device symbols.

Add a standalone CUDA FFI example and a native regression script.

Signed-off-by: Trent Nelson <[email protected]>
Reuse existing example dependency pins and classify external LTO as
an FFI fixture. Run its linking regression in native sweeps and verify
relocatable debug output in the existing full-debug route.

Signed-off-by: Trent Nelson <[email protected]>
Preserve exact geometry and fixed dynamic shared-memory requirements
through artifact loading so preparation can select and validate the
compiled allocation. Keep artifact writers and readers on one in-tree
implementation while preserving legacy bundles without launch facts.

Signed-off-by: Trent Nelson <[email protected]>
Combine the reviewed compiler prerequisites for native library calls.
Keep the external LTO fixture on the shared in-tree artifact implementation.

Signed-off-by: Trent Nelson <[email protected]>
Use the reviewed Cargo target and output-directory correction in the
combined compiler prerequisite tree.

Signed-off-by: Trent Nelson <[email protected]>
Resolve concrete registration functions and scalar argument types during
device compilation, then invoke the native provider and link its owned
LTO output through the ordinary artifact finalizer.

Signed-off-by: Trent Nelson <[email protected]>
Carry the convergence marker through private dependency metadata and
emit it on each marked LLVM declaration before native optimization.
Deduplicate repeated extern symbols while rejecting incompatible
signatures and convergence requirements.

Signed-off-by: Trent Nelson <[email protected]>
Signed-off-by: Trent Nelson <[email protected]>

# Conflicts:
#	cuda-oxide/crates/rustc-codegen-cuda/src/library.rs
Keep original MIR and static identities while emitting checked helper

bodies for each root. Route typed calls and native plans through those

bodies so shared helpers can use distinct block shapes.

Signed-off-by: Trent Nelson <[email protected]>
Treat each block as one cluster when a known earlier target is selected.
Bind a device hint only after this fallback is used, so later feature
selection cannot silently change its semantics. Keep raw intrinsic and
cluster operation target requirements intact.

Signed-off-by: Trent Nelson <[email protected]>
tpn added 25 commits October 22, 2026 23:48
Recognize genuine core integer methods at the import boundary and
retain their scalar effects on the original direct calls. Other
helper calls keep their conservative borrow handling.

Signed-off-by: Trent Nelson <[email protected]>
Check signed and unsigned imports and preserve ordinary call effects
when no direct target is selected. Clarify the source metadata comment.

Signed-off-by: Trent Nelson <[email protected]>
Supply the warp width in the existing importer retention fixture.

Signed-off-by: Trent Nelson <[email protected]>
Authenticate stateless callable environments and reuse the existing
callback, payload and storage passes for checked Block operations.
Carry the selected thunk and borrowed environment through native
provider linking and the six-argument payload ABI.

Signed-off-by: Trent Nelson <[email protected]>
Carry genuine closure field types into rustc-free callback checks and
prove the actual shared i32 environment is block-uniform. Activate slot
exposure when the exposing operation is reached, preserving existing
alias invalidation through calls, stores and control-flow joins.

Signed-off-by: Trent Nelson <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Oct 23, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@tpn tpn changed the title Support stateless callbacks in checked block payload calls Support checked Block callbacks with uniform captures Oct 24, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants