Repository navigation
heliopause/cubin: prune empty trailing CUDA 13.2 callgraph sections - #70
Draft
FujitsuPolycom wants to merge 1 commit into
Draft
FujitsuPolycom wants to merge 1 commit into
FujitsuPolycom wants to merge 1 commit into
Conversation
CUDA 13.2 (ptxas V13.2.86) appends three empty trailing subsection
headers ((0, 0xffff_fffe) CG_PROTO, (0, 0xffff_fffd) CG_ICALL, and
(0, 0xffff_fffc), an undocumented third empty header) with zero payload
entries to .nv.callgraph in multi-kernel cubins. heliopause/src/export/cubin.rs
previously returned None on any sentinel other than (0, 0xffff_ffff),
disabling dead-kernel pruning on CUDA 13.2 multi-kernel cubins.
- heliopause/src/export/cubin.rs:
- Before: compute_reachable_text and filter_callgraph duplicated
.nv.callgraph pair loops and bailed out on any non-(0, 0xffff_ffff)
sentinel.
- After: introduces a single parse_callgraph(raw) -> Option<Vec<(u32, u32)>>
shared by both passes (removing duplicated loops and helper functions
for a net reduction in production LOC). Empty trailing (0, 0xffff_fffe),
(0, 0xffff_fffd), and (0, 0xffff_fffc) headers are accepted and
preserved verbatim; any payload pair after a trailing header, any
direct sentinel after a trailing header, or any unknown sentinel still
returns None and falls back to strip_debug.
- Tests: updates pruning_falls_back_on_callgraph_proto_icall_and_prototype_sections
using in-bounds symbol indices (1, 2) after trailing sentinels so
parse_callgraph's in_trailing guard is directly exercised, and adds
pruning_allows_empty_trailing_cuda132_callgraph_subsections covering
single and 3-header empty trailing sequences.
- Compatibility: zero change for CUDA 12.x cubins or existing signed cores.
Result:
- Restores dead-kernel pruning on real CUDA 13.2 (ptxas V13.2.86)
multi-kernel cubins while failing closed on non-empty trailing sections.
Evidence:
- Verified on clean git archive via cargo test --locked --release
--manifest-path heliopause/Cargo.toml --lib,
CUDA_VISIBLE_DEVICES="" pytest tests/preparation/test_cubin.py
tests/preparation/test_core_boundary.py, and end-to-end pruning of real
ptxas V13.2.86 multi-kernel cubins (sm_87 and sm_120) through the
compiled flare_heliopause extension.
- Limitations: non-empty CG_PROTO/CG_ICALL/0xffff_fffc subsections still
fall back to strip_debug; full-model CUDA 13.2 export and flare run
verification with this Rust binary remains unrun.
Discord: Dooner
Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
Signed-off-by: Dooner <dooner@users.noreply.github.com>
FujitsuPolycom
force-pushed
the
jetson/pr-e-cuda132-callgraph-cubin
branch
from
December 4, 2026 21:57
d0a70b7 to
c518dd2
Compare
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.
Why
CUDA 13.2 (
ptxas V13.2.86) appends three empty trailing subsection headers—(0, 0xffff_fffe)(CG_PROTO),(0, 0xffff_fffd)(CG_ICALL), and(0, 0xffff_fffc)(an undocumented third empty header observed inptxas V13.2.86output)—with zero payload entries to.nv.callgraphin multi-kernel cubins.heliopause/src/export/cubin.rspreviously accepted only(0, 0xffff_ffff)and returnedNoneon every other sentinel, falling back tostrip_debugand disabling dead-kernel pruning on CUDA 13.2 multi-kernel cubins.Empty trailing subsection headers contain zero
.strtabbyte offsets and zero symbol indices, so preserving them verbatim cannot corrupt string offsets or drop indirect call targets. Allowing them only as an empty trailing run—while continuing to fall back tostrip_debugwhenever any payload pair follows a trailing header, any(0, 0xffff_ffff)appears after a trailing header, or any unknown sentinel appears—restores CUDA 13.2 dead-kernel pruning safely.What changed
Before this change,
heliopause/src/export/cubin.rsduplicated.nv.callgraphpair parsing incompute_reachable_textandfilter_callgraphand returnedNoneon every non-direct sentinel, including empty trailing headers.heliopause/src/export/cubin.rs:filter_callgraphand the.nv.callgraphedge loop incompute_reachable_textbailed out immediately whenevera == 0 && b != 0xffff_ffff.is_direct_callgraph_sentinelwith a single sharedparse_callgraph(raw: &[u8]) -> Option<Vec<(u32, u32)>>(net-2production LOC). Direct-call edges (a >= 1,b < 0xffff_fff0) and(0, 0xffff_ffff)are accepted before any trailing header;(0, 0xffff_fffe),(0, 0xffff_fffd), and(0, 0xffff_fffc)switch the parser into an empty-trailing-headers state where only further empty trailing headers are accepted and preserved verbatim. Any payload pair following a trailing header, any(0, 0xffff_ffff)after a trailing header, or any unrecognized sentinel returnsNoneand falls back tostrip_debug. Updates the adjacent comment incompute_reachable_textto match.heliopause/src/export/cubin.rs):FixtureOptionsfromextra_callgraph_pair: Option<(u32, u32)>toextra_callgraph_pairs: Vec<(u32, u32)>.pruning_falls_back_on_callgraph_proto_icall_and_prototype_sectionsusing in-bounds symbol indices(1, 2)after each trailing header (0xffff_fffe,0xffff_fffd,0xffff_fffc) soparse_callgraph'sin_trailingguard is exercised directly rather than masked bycompute_reachable_text'ssyms.len()check, alongside unknown sentinel(0, 0xffff_fffb)and out-of-order(0, 0xffff_fffe), (0, 0xffff_ffff).pruning_allows_empty_trailing_cuda132_callgraph_subsectionscovering both single-header[(0, 0xffff_fffe)]and 3-header[(0, 0xffff_fffe), (0, 0xffff_fffd), (0, 0xffff_fffc)]empty trailing sequences, verifying.text.dead_kernelremoval,validate_pruned_cubin, retention of.text.live_kerneland.text.helper_fn, and exact.nv.callgraphoutput.Claimed benefit and result
ptxas V13.2.86) multi-kernel cubin (c518dd28b4caffe636cb3d2fbdd29a0c6e0f9c1avs. base7bbc6707792aa1cb8633794ee189b7592091cc45):ptxas V13.2.86,live_kernel+helper_fn+dead_kernel)7bbc6707strip_and_prunec518dd28strip_and_prune.text.dead_kernelafter prunesm_87(non-Mercury ELF cubin,5,480 Bstripped)5,480 B(fallback)3,112 B(-43.2%)validate_pruned_cubin)sm_120/sm_121(Mercury.nv.merc.*cubin,8,408 Bstripped)8,408 B(fallback)8,408 B(unchanged.nv.merc.*fallback)cuModuleLoadDatamemory overhead caused by falling back tostrip_debug.Supporting evidence and limitations
Tested on clean
git archive c518dd28b4caffe636cb3d2fbdd29a0c6e0f9c1aatopNVIDIA/hyperflare-inferencemain(7bbc6707792aa1cb8633794ee189b7592091cc45):c518dd28b4caffe636cb3d2fbdd29a0c6e0f9c1a):cargo test --locked --release --manifest-path heliopause/Cargo.toml --lib:235 passed; 0 failed; 6 ignored(all 11export::cubin::tests::*passed).cargo build --locked --release --manifest-path heliopause/Cargo.toml --features extension-module+CUDA_VISIBLE_DEVICES="" pytest tests/preparation/test_cubin.py tests/preparation/test_core_boundary.py -v:10 passed(6/6test_cubin.py,4/4test_core_boundary.py).(false, 1.., ..0xffff_fff0)to(_, 1.., ..0xffff_fff0)inparse_callgraphimmediately failedpruning_falls_back_on_callgraph_proto_icall_and_prototype_sections(0 passed; 1 failed).ptxas V13.2.86cubin check: Assembled a multi-kernel PTX (live_kernelcallinghelper_fnplus unreachabledead_kernel) withptxas V13.2.86, verified viareadelf -x .nv.callgraphthat it emitted(0, 0xffff_ffff), (0, 0xffff_fffe), (0, 0xffff_fffd), (0, 0xffff_fffc), and comparedstrip_and_prune+validate_pruned_cubinbetween base7bbc6707(5,480 B,.text.dead_kernelretained) and candidatec518dd28(3,112 B,.text.dead_kernelremoved onsm_87).heliopause.CG_PROTO,CG_ICALL, and0xffff_fffcsubsections (containing.strtab-offset payload pairs) continue to fall back safely tostrip_debug..nv.merc.*onsm_120/sm_121) continue to fall back tostrip_debugunder the pre-existing Mercury guard.ignition export,cuModuleLoadDatamemory measurement, andflare runserving with this Rust binary have not yet been executed onc518dd28b4caffe636cb3d2fbdd29a0c6e0f9c1a.Discord: Dooner