Repository navigation
Warn when launch-bounded kernels spill registers - #757
Merged
nihalpasham merged 12 commits intoAug 10, 2026
Merged
Conversation
uurl
force-pushed
the
feat/launch-bounds-spill-warning-708
branch
from
August 9, 2026 10:41
198afdc to
8f3bfaf
Compare
Signed-off-by: Raul Estrada <[email protected]>
uurl
force-pushed
the
feat/launch-bounds-spill-warning-708
branch
from
August 9, 2026 10:53
8f3bfaf to
e498f9b
Compare
…OPTION Expose NvJitLinkError::is_unrecognized_option() so callers passing optional, non-semantic options can detect an older nvJitLink that predates them and retry without them. The result code is checked live against the installed toolkit by a new ignored test that feeds nvJitLinkCreate a bogus option. Signed-off-by: Nihal Pasham <[email protected]>
…inated kernel names Capture the 'N bytes stack frame' figure that sits on the same ptxas 'Function properties' line as the spill counters: local-memory frame size is distinct from spill traffic and issue NVIDIA#707's census needs it. Also unwrap kernel names in log shapes that terminate the line with a colon after a quoted name ("Function properties for '_Z3fooPi':"), which previously left a stray ': suffix on the parsed name. Signed-off-by: Nihal Pasham <[email protected]>
…nized diagnostic options Early 12.x nvJitLink versions reject options they do not know with NVJITLINK_ERROR_UNRECOGNIZED_OPTION, which would fail the whole link just because the caller asked for a best-effort report. When the with-report link fails that way, retry once without the diagnostic flags and return the linked image with an empty report. The retry runs inside the same revalidated-tool-identity window as the first attempt, and the plain link path is unaffected. Signed-off-by: Nihal Pasham <[email protected]>
…ecting a resource report Observed live on CUDA 13.3: a warm nvJitLink link serves the cubin from its own JIT cache, skips ptxas entirely, and replays no info log, so link_ltoir_with_report silently returned an empty resource report on every repeat link. Add -no-cache to the cubin diagnostic option set so the report always observes a real compile. The produced image bytes are identical, and the flag stays out of artifact digests with the other reporting options. Signed-off-by: Nihal Pasham <[email protected]>
…t format Add an ignored live test in the crate's live_tests style: build legacy-dialect NVVM IR for a kernel that must spill (64 mutually entangled live floats under a maxnreg=32 cap), compile it to LTOIR, link with link_ltoir_with_report, and assert the info log is present and parses to plausible register, stack-frame, and spill figures. The generated IR anchors the kernel with @llvm.used exactly as cuda-oxide's NVVM exporter does; without it nvJitLink dead-strips the kernel and the log carries no resource lines. On this host (CUDA 13.3, sm_86 target) the log reads: ptxas info : Compiling entry function 'spill_kernel' for 'sm_86' ptxas info : Function properties for spill_kernel ptxas . 360 bytes stack frame, 476 bytes spill stores, 584 bytes spill loads ptxas info : Used 32 registers, ... and parses to registers=32, stack_frame=360, spills=476/584. Signed-off-by: Nihal Pasham <[email protected]>
Signed-off-by: Raul Estrada <[email protected]>
device_codegen.rs references mir_importer::KernelLaunchBounds, but the explicit pipeline re-export list omitted it, so the rustc-codegen-cuda crate (outside the root workspace) failed to build.
… warning The launch-bounds spill warning is a raw span diagnostic, not a lint, so #[allow] cannot suppress it. Builds that measured a spill and accepted it need an escape hatch; presence-based parsing matches the existing CUDA_OXIDE_NO_OPT convention.
…s only in .note.nv.tkinfo Verified on CUDA 13.3 / sm_120: linking the same LTOIR with and without the diagnostic options yields cubins whose sections are byte-identical except .note.nv.tkinfo, where ptxas records its own option line (-v). The runtime fallback in cuda-host therefore produces code-identical, not byte-identical, images.
nihalpasham
force-pushed
the
feat/launch-bounds-spill-warning-708
branch
from
August 10, 2026 04:00
e498f9b to
eae5c66
Compare
Collaborator
|
Gist: ptxas's I force-pushed a restack onto the updated #756 plus three commits:
Verified on an RTX 5090 with CUDA 13.3:
Merging after #756. Partially addresses #708 within the disclosed |
# Conflicts: # crates/cuda-artifact-finalizer/src/link.rs
nihalpasham
approved these changes
Aug 10, 2026
nihalpasham
added a commit
that referenced
this pull request
Aug 11, 2026
…atch (#798) * docs(book): document the launch-bounds spill warning and its escape hatch #757 taught the backend to warn when a `#[launch_bounds]` kernel spills registers. The warning is user-facing and nothing in the book mentions it, so the first time anyone meets it is in their own build output. Two things make that worse than an ordinary documentation gap: * The build still succeeds. A bound that ptxas can only satisfy by spilling to local memory is a silent trade -- occupancy bought, then paid for again on every access to a spilled value -- and the warning is the only signal. * `#[allow(...)]` does not silence it. These are raw span diagnostics rather than lints, so the attribute a Rust user reaches for first does nothing, and the only escape hatch is `CUDA_OXIDE_NO_SPILL_WARN=1`, which appears in no documentation at all. So the `#[launch_bounds]` section now carries the diagnostic's actual shape, what it means, the usual responses, and the environment variable -- framed for builds that measured the spill and accepted it, which is the intent recorded on `emit_launch_bounds_spill_warnings`. It also says plainly that spilling is not automatically wrong, since a kernel can be faster spilling a little at high occupancy than not spilling at low. Every message string is quoted from `crates/rustc-codegen-cuda/src/lib.rs` rather than paraphrased; the byte and register figures are illustrative and labelled as such. Verified with `sphinx-build -W --keep-going`. Note for triage: issue #708 asked for this warning and is still open even though #757 merged it, so it looks like another squash-merge where the `Closes` did not fire. Signed-off-by: Vyncint Ng <[email protected]> * docs(book): note the spill warning requires cubin materialization The warning is emitted from write_device_artifact_object only when a materialized cubin exists; plain PTX builds never run ptxas, so there is no resource report to inspect. Say so, and show --materialize-cubin in the escape-hatch example command. --------- Signed-off-by: Vyncint Ng <[email protected]> Co-authored-by: nihalpasham <[email protected]>
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.
Depends on #756.
Please review/merge #756 first.
Refs #708.
Summary
Adds a rustc warning when a kernel compiled with
#[launch_bounds]reports register spills during native cubin materialization.This builds on the resource-reporting infrastructure introduced in #756 and addresses the warning path described in #708.
Changes
ptxasresource usage during cubin materialization;min_blocks_per_smwas specified.Example diagnostic:
The warning intentionally does not claim that
#[launch_bounds]caused the spill. It reports only the facts available from compilation: the kernel has launch bounds andptxasreported register spilling.Scope
The diagnostic is emitted when native cubin materialization runs, because that is the stage where
ptxasresource information becomes available.Normal PTX-only compilation does not run
ptxas, so it cannot provide exact spill information.Testing
Validated with: