Repository navigation
Description
A kernel that takes a pointer to a shared-memory type emits an entry parameter in the .shared state space. ptxas assembles the module, and the driver then refuses to load it, so every kernel in that module becomes unreachable.
DriverError(200, "device kernel image is invalid")
generated_intrinsics_blackwell contains such a kernel, so the module that example builds cannot be loaded on the architecture it pins.
Reproducer
#[cuda_module]
mod kernels {
use super::*;
#[kernel]
pub fn plain(mut out: DisjointSlice<u32>) {
if let Some(s) = out.get_mut(thread::index_1d()) { *s = 7; }
}
/// Empty body. The only unusual thing is the parameter type.
#[kernel]
pub unsafe fn takes_barrier(_barrier: *mut Barrier) {}
}With takes_barrier present, kernels::load fails with error 200. Remove it and the same module loads and plain writes 7. The body is empty, so nothing the kernel does is involved.
The emitted entry
.visible .entry takes_barrier(
.param .u64 .ptr .shared .align 1 takes_barrier_param_0
)
.ptr .shared on an entry parameter is the problem. A kernel receives its parameters in .param space and cannot be handed a shared-memory address by the host, since shared memory is allocated per block at launch. The attribute is meaningful on a .func parameter, not on a .entry one.
Barrier lives in shared memory, so *mut Barrier carries addrspace(3), and that address space reaches the entry signature rather than being rejected or widened to generic.
ptxas does not object. Assembling the example's own PTX by hand succeeds:
$ ptxas -arch=sm_120a generated_intrinsics_blackwell.ptx -o /tmp/bw.cubin
ptxas ... warning : Advisory: '.multicast::cluster' modifier ... on .target 'sm_120a'
$ echo $?
0
So the fault surfaces only when a module is loaded, which is why nothing catches it today.
Why the example hides it
generated_intrinsics_blackwell sits in BLACKWELL_COMPILE_EXAMPLES, documented in scripts/smoketest.sh as "compile-only coverage pinned to exact sm_120a. These kernels are never launched." Its main is:
fn main() {
println!("PASS: generated Blackwell sparse MMA compile coverage");
}The smoketest records a pass, and no GPU in CI would change that, since the example never asks the driver for the module.
Isolating it inside that example gives the same answer as the reproducer above. Commenting out compile_tma_compatibility and nothing else makes the module load, after which the conversion kernels run and produce correct values on hardware:
e4m3x2(1.0, 2.0) = 0x4038
e5m2x2(1.0, 2.0) = 0x403c
Those match the formats by hand: 1.0 is 0x38 in e4m3 and 0x3C in e5m2, 2.0 is 0x40 in both, and the first argument occupies the low byte as cvt_rn_satfinite_e4m3x2_f32 documents. Removing the TMA calls one family at a time does not help, and emptying the body does not help either. The sparse MMA kernels load and run on their own.
Expected
A kernel parameter that would carry a non-generic address space is refused at compile time, in the manner of the other invalid-input diagnostics, rather than assembled into a module the driver cannot load. Widening the pointer to generic would also work if passing such an address is meant to be allowed, though for shared memory there is nothing sensible the host could pass.
Environment
RTX 5060 Laptop GPU, compute capability 12.0, CUDA 13.3, driver 610.43.03, target sm_120a.
Activity