Skip to content

fix(cuda-oxide): gate the tcgen05 example on its module's target - #1629

Open
0z5a wants to merge 1 commit into
NVIDIA:mainfrom
0z5a:fix/tcgen05-example-module-target
Open

0z5a wants to merge 1 commit into
NVIDIA:mainfrom
0z5a:fix/tcgen05-example-module-target

Conversation

@0z5a

@0z5a 0z5a commented Oct 24, 2026

Copy link
Copy Markdown

Summary

Closes #1628.

The tcgen05 example's compile-only coverage kernels include tcgen05.mma ... kind::i8, which sm_103a does not provide. On a cc 10.3 GPU, the backend therefore builds an sm_100a module even with the detected sm_103a hint. The runtime gate accepted cc 10.3, the driver could not JIT the PTX (CUDA_ERROR_INVALID_PTX, 218), and the example failed.

The example now also checks the module's own .target before loading:

  • an arch-specific target (a) needs that exact compute capability;
  • a family target (f) needs the same major and at least its minor;
  • a plain target needs at least its capability.

Otherwise the example takes the existing PTX-only path, which assembles the module with ptxas. The gate on the GPU generation (can_execute_tcgen05_ptx) is unchanged.

Changes

  • cuda-oxide/crates/rustc-codegen-cuda/examples/tcgen05/src/main.rs: before loading the embedded module, compare its .target with the GPU's compute capability, and take the PTX-only path when the module cannot run there.

Testing

scripts/smoketest.sh -o 'tcgen05|gemm_sol':

Example Before After
gemm_sol PASS (executed) PASS (executed)
gemm_sol_final PASS (executed) PASS (executed)
tcgen05 FAIL (exit=1: CUDA_ERROR_INVALID_PTX) PASS (PTX compiled; ptxas sm_100a ok)
tcgen05_matmul PASS (executed) PASS (executed)

scripts/smoketest.sh -o '^redux_f32$|generated_intrinsics_blackwell': 2/2 PASS.

GPU: B300 (cc 10.3, x86_64) | driver 610.57.04 | CUDA 13.3 | rustc 1.99.1 | cuda-rust fc747196

Not run on B200 (cc 10.0). There the module target matches the GPU, so the example executes as before.

  • just -f cuda-oxide/Justfile check passes -- not run for this change; the change is confined to the example, which is its own workspace
  • cuda-oxide/scripts/smoketest.sh -o 'tcgen05|gemm_sol' (above)
  • New example added (if applicable) -- not applicable

Checklist

  • All commits signed off (git commit -s)
  • SPDX headers on new source files -- no new files

The example's compile-only coverage kernels include `tcgen05.mma ... kind::i8`,
which sm_103a does not provide, so on a cc 10.3 GPU the backend falls back to an
sm_100a module even when the detected sm_103a is passed as the device hint.
The runtime gate accepted cc 10.3, the driver could not JIT the sm_100a PTX
(CUDA_ERROR_INVALID_PTX, 218) and the example failed.

Also require the module's own `.target` to run on the GPU before loading it:
an arch-specific target needs that exact compute capability, a family target
the same major and at least its minor. Otherwise the example takes the
existing PTX-only path, which assembles the module with ptxas.

Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
@0z5a
0z5a requested a review from nihalpasham as a code owner October 24, 2026 15:54
@copy-pr-bot

copy-pr-bot Bot commented Oct 24, 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.

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.

tcgen05 example fails on B300 (cc 10.3): its module falls back to sm_100a

1 participant