Repository navigation
feat(examples): capture SIMT kernel launches into a CudaGraph - #1731
Merged
Merged
Conversation
cuda-oxide's async launches have been cuda_async AsyncKernelLaunches since NVIDIA#1461, and those implement GraphNode, so SIMT kernels can be recorded into the shared CudaGraph. No cuda-oxide example showed it; the only graph examples were cutile-rs's. `cuda_graph` builds a step of 16 small launches (eight layers of `axpy` then `scale`), runs it eagerly through the ordinary module API, and records the same launches once with `CudaGraph::scope` and replays them. Both paths run the same kernels in the same order, so the example requires their results to match bit for bit and checks both against a CPU reference. It prints the time per step of each path. On an A10G the step takes 47-55 us eagerly and 24.3 us as a graph replay, with no element differing and a relative error of 2.1e-7 against the CPU. compute-sanitizer reports no errors. Signed-off-by: Vyncint Ng <[email protected]>
Open
Collaborator
|
/ok to test 207f3ac |
Collaborator
|
Thanks, this is a clean, self-contained example of capturing At |
nihalpasham
approved these changes
Nov 9, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What This PR Does
Adds
examples/cuda_graphdemonstrating how to capture and replay SIMT kernel launches generated by#[cuda_module]usingcuda_async::cuda_graph::CudaGraph:cuda_graphExample (crates/rustc-codegen-cuda/examples/cuda_graph)cuda-oxide/README.md)1. Capturing
#[cuda_module]Async Launchers intoCudaGraphEach step executes 16 small kernel launches (8 layers of
axpyfollowed byscale) and compares eager stream submission against a capturedCudaGraphreplay and a host CPU reference:0mismatched elements) and checks max relative error (< 1e-4) against the CPU reference.Verification
RTX 5090,sm_120a):cargo oxide run cuda_graphpasses (23.4 us/stepeager vs16.4 us/stepgraph replay;compute-sanitizer --tool memcheck:0 errors).cargo clippy --manifest-path crates/rustc-codegen-cuda/examples/cuda_graph/Cargo.toml --all-targets -- -D warnings: PASSsync-example-locks.sh --check,check-spdx-headers.sh,check-example-smoketest-contract.sh: all PASSRefs #107