Case file — PR #652 heliopause: prune unreferenced kernels from exported CUDA ELF64 cubins
Author @lukealonso (COLLABORATOR, Discord: lukealonso). Head 9ea2491, base main (branched at 571a447), open, ready for review, no labels, no reviews, no comments, CI on head "pending". Size: +937 / −5 in 2 files (heliopause/src/export/cubin.rs +927/−1, heliopause/src/export/capture.rs +10/−4).
Key findings (what the description does not tell a reader)
- Two silent, all-or-nothing fallbacks decide whether pruning happens at all, and neither is mentioned.
try_prune_unused_kernelsreturnsOk(None)(→ debug-stripped passthrough, no log, no error) if any captured symbol name has no matching.text.<name>section (cubin.rs:452-457), and skips pruning entirely unless there are strictly more.text.*sections than kept functions (cubin.rs:434-436). One mangled/sanitised-name mismatch therefore disables pruning for a whole module silently. This is plausibly why the description reports only 35 of 123 modules pruned — the description lists fallbacks only for stripped section names, missing program headers,SHN_XINDEXand non-zero vaddrs (cubin.rs:381-407), not these two. - No CI lane runs the tests this PR relies on. No workflow invokes
cargo test --manifest-path heliopause/Cargo.toml(not opened); the only CI touching cubins ispython-cpu.yml(CUDA_VISIBLE_DEVICES="", line 32), which exercisestests/preparation/test_cubin.pythrough the pyo3 extension.strip_and_pruneis not exposed to Python (recorder.rs:1010-1016registers only three cubin fns), and that test file was not modified. So the "223 non-CUDA tests passed" and the 2 new unit tests (cubin.rs:1223,cubin.rs:1273; 5 total in the module withcubin.rs:977/995/1015) are manual-only evidence. - Evidence is on hardware outside the charter's target matrix. The charter's goal is SM103/SM120/SM121 serving (charter line 21); all live validation is SM87/AGX Orin, and the Limitations say SM103/120/121 and multi-rank TP were not run. The CUTLASS-heavy modules the change targets are exactly the SM120/121 ones left unverified.
- Documentation now contradicts the code and was not updated.
docs/core-format-design.md:380-381states "The exporter preserves kernel and global symbol names in cubins"; pruning drops dead symbols' names from.strtaband clears their section index.docs/runtime-core-design.md:76still describes heliopause cubin handling as "debug stripping" only. No docs file is in the diff. - Correctness of the rewritten ELF is only structurally self-checked.
strip_and_prunere-parses its output (cubin.rs:363-367); nothing loads the pruned image through the driver at export time. An ELF that parses but is semantically invalid fails at serving load (helios/src/runtime_core/mod.rs:795-798), on the serving machine. - All numeric claims (cubin 166.51→19.46 MiB, kernels.safetensors 9.93→1.5 MiB, Prepare kernels 0.5s→0.1s, pre-cache 6.73→6.45 GiB, KV 15,488→32,768 tokens) are unattached to any artifact, log, script or baseline in the repo, and no automated lane could reproduce them (all cubin tests use hand-built synthetic ELF fixtures,
cubin.rs:910,cubin.rs:1032).
The change
cubin.rs gains strip_and_prune(image, &keep_functions) (cubin.rs:355-370): it calls the existing strip_debug, returns early when the keep set is empty (standalone modules), otherwise attempts try_prune_unused_kernels (cubin.rs:372-903) and falls back to the stripped image on None.
try_prune_unused_kernels (verified in code):
- Layout gate (
cubin.rs:381-407):EM_CUDA,phnum != 0,phentsize == 56,< 0xff00sections, program headers in bounds, every PT_LOAD with flags ∈ {5,6} and only PT_PHDR/PT_LOAD,p_vaddr == p_paddr == 0; then every section must haveaddr == 0and a non-empty name, and exactly oneSHT_SYMTABwithstride == 24and a valid linked strtab (cubin.rs:412-449). Any deviation → passthrough. - Reachability: seeds from captured names via a
.text.<fn>map (cubin.rs:451-457); adds.text.*section indices named by relocations in non-debugSHT_REL/SHT_RELA(cubin.rs:492-519); adds.nv.callgraphedges, treatinga == 0andb >= 0xfffffff0as sentinels (cubin.rs:521-537); followsEIATTR_EXTERNS(0x0f) from each kept function's.nv.info.<fn>(sh_info → text section) to a fixed point (cubin.rs:539-...). - Symbol table kept at original length: every 24-byte slot survives so indices stay valid; dead slots lose name/shndx/value and keep only the binding nibble (
entry[4] = sym.info & 0xf0). Consequence not stated in the description:.symtabbytes are not reclaimed — only.strtabnames and dropped section payloads are. - Companion cascade: sections whose sh_info points at a dropped section are dropped, via
sh_info_is_sectionwhich treats sh_info as a section index forSHT_REL/SHT_RELA,SHF_INFO_LINK,.nv.info.*,.nv.shared.*,.nv.local.*, and.nv.constant<digits>.<fn>(name must contain a dot after the prefix). - Filters for global
.nv.inforecords (attrs 0x11/0x12/0x2f) and.nv.callgraphdead endpoints; parse anomalies in either abort to passthrough. - Full re-emission: sections partitioned into non-ALLOC / RX / RW, new
.shstrtab/.strtab/symtab, section headers (sh_link/sh_info remapped,cubin.rs:841-856), then program headers appended at the end and the ELF header patched (cubin.rs:871-903).p_alignis hardcoded to 8 for every emitted header (cubin.rs:883), not copied from the input, andp_vaddr/p_paddrare left zero.
capture.rs builds a per-module BTreeSet<&str> of symbol names from output.index.ranks[0].functions filtered by f.module == name (capture.rs:3282-3287), calls strip_and_prune (capture.rs:3288), stages the pruned bytes and advances the phase byte counter with them (capture.rs:3289-3291), and — the behaviour change the description does state — calls cubin::global_symbols(&exported) rather than &image, in both the standalone-module guard (capture.rs:3293-3298) and the cuModuleGetGlobal_v2 loop (capture.rs:3315). Side effect: a module whose globals were pruned away can no longer trip the "standalone module declares globals without a captured kernel" error.
Nothing in the diff touches the wire format, protobuf, Helios runtime, Cargo manifests or docs.
The why
No issue is linked or closed; the motivation is prose only. The mechanism is real in the code: every module.file cubin is loaded whole via driver.module_load (helios/src/runtime_core/mod.rs:790-799). Ambient repo evidence of the pressure: ignition/preparation/memory_inventory.py:310-311 prints cubin bytes as "not resident VRAM"; #394 measures 32 SM120 cubins at 3,422,080 bytes; #479 reported 9,488 kernels / 436.17 MiB cubin for 314 graphs. The nearest open issue on the same symptom class is #630 (GB10 unified memory: KV budget responds to page-cache-polluted MemFree) — not referenced, not fixed here. Searching the local copy found no prior issue or PR asking for kernel pruning specifically: this is author-initiated.
Related work
- #394 (open, voipmonitor) "Assemble temporary core payloads in the rank export workspace" — same export/cubin staging pipeline, different lever (NFS fsync avoidance); no file overlap, both change what the exported cubin bytes/flow are; would need reconciling.
- #585 (closed, FujitsuPolycom) "Accelerate native graph capture, weight capture, and core publication" — review flagged
strip_debug'simage.to_vec()on Rayon's pool. This PR adds more per-module CPU work on the same path (stripped clone plus a full ELF rebuild); it makes no export-time cost claim (its timing claim is load-time "Prepare kernels"). - #646 / #647 (merged 2026-11-30, same author) both touch
capture.rs; this PR builds on the capture.rs they landed (branched at571a447; no default-branch commit since touches either changed file, so no textual conflict today). - #504/#525/#526/#527 (yatesdr, KV codec) are why a standalone module exists:
ignition/preparation/runtime_core.py:402-415registersGPU_CODEC_MODULE_NAMEpath-only with no captured functions — exactly the empty-keep-set passthrough branch (capture.rs:3282-3288,cubin.rs:357-361). A regression there breaks GPU KV codecs. - #642 (open, jcartu) skips unreferenced Inductor epilogue candidates — same goal one layer up (Python), unrelated files.
- #586, #587, #618, #620, #431, #297 are adjacent export-pipeline work; no file-level overlap and none is superseded.
- No competing or superseding change:
items_touching(heliopause/src/export/cubin.rs)returns nothing else in 180 days, and only this PR addsstrip_and_prune.
Recent activity
heliopause/src in the last 60 days is dominated by the author (#646, #647, #620, #618) plus #586 (PCCessna), #587 (FujitsuPolycom) and a silent-export-corruption fix. This PR continues that stream rather than reversing it: it keeps the capture_rank module loop (path-only modules from request.modules at capture.rs:2973-2977, per-function image discovery at capture.rs:3028-3032) and swaps only the cubin transform and the image used to enumerate globals.
People
The author is the de facto owner of this area: 62 commits in heliopause/src in 180 days (vs Martin Vit 11, Jason Cook 5), the only person who had ever touched cubin.rs before this PR (14a6a273, 3edd2c3a, 28f0833b licensing), 33 merged PRs in 180 days and — until this PR — 0 open. There is therefore no other reviewer with prior art on this file; nearest reviewers of the export path are voipmonitor (#394, #585 review), FujitsuPolycom (#585/#586/#587), PCCessna (#586). The adjacent author most affected is yatesdr (codec cubins).
Community
Zero engagement: Discussion (0), no reviews, no reactions, no labels — unlike the author's other PRs (e.g. #646 carries area:caching, area:memory, bug, performance, triage:review), and with no Autobot case-file comment yet even though every other PR in the local copy received one. related_items(652) cannot resolve because the PR is not in the local copy; cross-references above come from search_items/items_touching. Interest so far exists only in the description.
Project fit
Aligns: the charter's merge bar includes "a measured performance/memory issue"; the description follows the four-part format (why / what changed / claimed result / evidence) with commands and a Limitations paragraph; no new flags, no per-model branches, no runtime/API change ("no per-model special cases or flags", "keep the runtime small"); readers of old cores are unchanged, so #412-style artifact compatibility holds.
Does not align / open: the hardware matrix (SM103/120/121) is precisely what was not run (charter line 21); evidence snapshots are not reproducible from the repo (charter "bring real evidence … benchmarks showing an actual speedup … on a served workload" is partly met — load-time numbers on a served workload exist, but no command line, script or log); docs drift as in Key finding 4; the charter's line 44 ("GPU kernel code: report concrete defects only") makes the ELF-rewriting portion of this diff review-shaped, and review should look at the p_align == 8 hardcode (cubin.rs:883), the unremapped sh_info of sections sh_info_is_section does not recognise (e.g. a bare .nv.constant0 or .nv.global.init), and the absence of any post-rewrite assertion that every kept .text survived the cascade.
Claims and evidence
Verified in code: the reachability sources, the symtab index preservation, the sh_info cascade and remap, the global .nv.info/callgraph filters, the passthrough branches, the global_symbols(&exported) change. Not asserted by any test: .symtab's own sh_info after pruning, driver acceptance of a pruned image, the non-SHF_INFO_LINK .nv.constant* naming edge, and modules with a partially matching keep set (the fallback that would silently disable pruning). Test count is consistent: 5 export::cubin tests total, 2 new (one covering two fixture variants). All performance and memory figures are unsupported in-repo, as is "35 multi-kernel modules pruned" out of 123.
Reach
An unconditional change to the export path — no flag, no per-module opt-out, and the only signal is the aggregate byte count in the "Capture compiled modules and globals" phase (capture.rs:3384-3387). Artifacts get smaller, so re-exports produce different payload bytes; signing/publishing, ExecutableResource framing and the runtime reader are untouched. No configuration, CLI, dependency or Cargo change. Benefits are visible only on memory-constrained devices; failure modes move from export time to serving load time. Any request.modules path-only module and the KV-codec standalone module flow through the empty-keep-set branch.
Process
Hours old at capture (opened and last updated 2026-12-01 06:15), open/ready for review, unlabelled, unreviewed, CI pending. The two new tests are not wired into any CI workflow. No stale-work risk yet.
Open questions
Whether the missing prune on 88 of 123 modules is intended passthrough or the unmatched-name fallback (cubin.rs:452-457 / cubin.rs:434-436); whether p_align = 8 and zero vaddr/paddr reproduce NVIDIA's own layout for SM120/121 CUTLASS cubins (never run); whether a driver-level validation pass at export time is feasible; and whether docs/core-format-design.md:380-381 and docs/runtime-core-design.md:76 should be updated as part of this PR.