#1 [high] Finding 1 (Major): pruned image keeps auxiliary symbol tables / sh_info with stale, un-remapped section indices
heliopause/src/export/cubin.rs
(a) Symbol tables: try_prune_unused_kernels accepts exactly one SHT_SYMTAB (kind 2) and rebuilds only that table:
- cubin.rs:412-432 — loop only tests
s.kind == SHT_SYMTAB; a second SHT_SYMTAB aborts, but kind0x70000085does not trip the guard. - cubin.rs:437-449 —
symtab_idx;strtab_idx = symtab_sec.link. - cubin.rs:694-722 — only
syms(fromsymtab_idx) is rewritten; every other section is copied verbatim byplace()(cubin.rs:772-795,new_sizes[old_si] = slice.len(); out.extend_from_slice(slice)). The codebase knows this second table kind exists: cubin.rs:145if s.kind != 2 && !(alternate && s.kind == 0x70000085) { continue; }(used bystrip_debug), and tests/preparation/test_cubin.py:35(b".nv.merc.symtab", 0x70000085, 0x10000000, symbols, 2, 24).
(b) sh_info: sh_info_is_section (cubin.rs:261-280) returns false for anything it does not recognise, and cubin.rs:849-856 then copies the raw index:
let sh_info = if sh_info_is_section(s, sec_names[old_si]) && s.info != 0 {
let Some(mapped) = old_to_new_sec.get(s.info as usize).copied().flatten() else {
return Ok(None);
};
mapped as u32
} else {
s.info
};
The author's own comment at cubin.rs:274-278 documents that NVIDIA omits SHF_INFO_LINK on .nv.constant<digits>.<fn>; the same omission on any other name (bare .nv.shared, .nv.global.init, .nv.weak, .nv.merc.*) leaves an index into the old table that, after compaction (cubin.rs:652-659), designates a different section.
Impact: strip_and_prune's only output check is Elf::parse(&pruned)? (cubin.rs:365), which validates the section table bounds and nothing about cross-references, so a mis-indexed aux symtab or sh_info reaches cuModuleLoadData on the serving host (helios/src/runtime_core/mod.rs:795-798). A wrong sh_info on a per-kernel .nv.info/.nv.constant* section can also bind metadata to the wrong kernel.
Fix: passthrough (Ok(None)) when any non-SHT_SYMTAB symbol table (0x70000085, SHT_SYMTAB_SHNDX 18) or any kept section's non-zero sh_info is not provably a recognised section index; alternatively remap those too.
#2 [high] Finding 2 (Major): two silent all-or-nothing passthroughs; no diagnostic for 88/123 unpruned modules
heliopause/src/export/cubin.rs:434-436
if text_by_fn.len() <= keep_functions.len() {
return Ok(None);
}
heliopause/src/export/cubin.rs:451-457
let mut keep_text: BTreeSet = BTreeSet::new();
for &fn_name in keep_functions {
let Some(&si) = text_by_fn.get(fn_name) else {
return Ok(None);
};
keep_text.insert(si);
}
cubin.rs:363-369 — None means Ok(clean), i.e. debug-stripped passthrough: no error, no log, no counter. Verified there is no eprintln/log::/println anywhere in cubin.rs.
Consequences:
- Any single mismatch between a captured
wire::Function.symbol(capture.rs:3120let symbol = unsafe { CStr::from_ptr(name) }.to_str()?.to_owned();, fromcuFuncGetName) and a.text.<name>section suffix disables pruning for the whole module. A module that mixes per-function.text.<fn>sections with any symbol that has no such section gets zero pruning for all of its other dead kernels. - The only observable output is capture.rs:3289-3291
module_bytes += exported.len() as u64; module_phase.advance_bytes(exported.len() as u64);plus capture.rs:3384-3387module_phase.finish(format!("{module_bytes} bytes, {} global bytes downloaded", downloader.downloaded)). That is an aggregate total, not a per-module pruned/skipped signal. - The PR text lists fallbacks only for "stripped section names, no program headers …,
SHN_XINDEXsymbol tables, or non-zero section/segment virtual addresses" and reports "35 multi-kernel modules pruned" out of 123 with no explanation for the other 88. These two guards are the likely explanation and are undocumented, so a reviewer/operator cannot tell intended passthrough from silent failure.
Fix: return the prune decision (pruned / skipped-with-reason) to capture.rs and report counts in module_phase.finish, or at minimum count and print modules where a captured name had no .text.<name> section.
#3 [high] Finding 3 (Major): pruned image never loaded at export time; no CI gate for cubin.rs
heliopause/src/export/cubin.rs:363-367 — the only check on the rewritten image:
match try_prune_unused_kernels(&clean, keep_functions)? {
Some(pruned) => {
Elf::parse(&pruned)?;
Ok(pruned)
}
Elf::parse (cubin.rs:69-107) validates only the ELF magic, e_shentsize == 64, names < count, and that the section table lies within the image. It does not check symbol/section cross-references, program-header coverage, or driver acceptance.
Nothing loads the pruned image during export. The first driver contact is on the serving machine: helios/src/runtime_core/mod.rs:790-798
let image = files.read(core, &module.file)?;
if !image.starts_with(b"\x7fELF") { return Err(invalid("module image is not a compiled cubin")); }
let mut handle = null_mut();
driver.check("cuModuleLoadData", (driver.module_load)(&mut handle, image.as_ptr().cast()))?;
and then cuModuleGetFunction per core.functions (mod.rs:825-831). A structurally-parseable but semantically invalid ELF therefore converts an export-time failure into a serving-start failure on the user's GPU.
No CI lane exercises the new code:
search_code("heliopause", path=".github/")returns no matches.- .github/workflows/native-serving.yml:47-77 invokes
cargo testonly for eos, selene, selene-manager, helios, flare-cli, flare. - .github/workflows/python-cpu.yml:29-33 builds the pyo3 extension and runs
pytest tests/, whose cubin test (tests/preparation/test_cubin.py:10from ignition.preparation.module_images import global_symbols, strip_debug) never reachesstrip_and_prune: recorder.rs:1010-1016 registers onlycubin_strip_debug,cubin_strip_global_source,cubin_global_symbols, and that test file is unchanged by this PR. So the 5export::cubintests (cubin.rs:977, 995, 1015 pre-existing; 1223, 1273 new) and the PR'scargo test --libresult are manual-only, un-gated evidence for a binary-format rewrite.
Impact: a regression here is invisible to CI and surfaces only as a core that fails to load or a kernel that is silently absent at serving start.
Fix: (a) add a heliopause cargo test step to native-serving.yml; (b) as a cheap in-export guard, assert after pruning that every captured name still resolves to a surviving .text.* section and that every surviving section's sh_link/sh_info resolves, which is already computable in try_prune_unused_kernels.
#4 [high] Finding 4 (Major): charter hardware matrix (SM103/120/121) unverified for an unconditional export change
Charter (goals): "Prepare supported model recipes with Ignition and serve captured CUDA graphs from Rust on SM103, SM120, and SM121." AGENTS.md:3 "Flare is a local inference server for NVIDIA SM103/SM120/SM121 GPUs."
PR description limitations, verbatim: "SM103, SM120, SM121, and multi-rank TP core exports were not run for this PR."
Every live number in the description is from SM87: "On an SM87 Inkling-2-Mini 9-graph (widths 1, 2, 4, 8) K4V8 + DSpark export (251 captured functions across 123 modules)…" and "On Jetson Orin Nano 8 GB under flare run --memory-limit -16m…" plus "needle recall on AGX Orin".
The change is unconditional on the export path (capture.rs:3288) with no flag or opt-out, so a SM120/121 export cannot avoid it, while the modules it is aimed at are the ones never exercised:
- the pruning gate depends on per-kernel
.text.<fn>naming (cubin.rs:421-425) and onEIATTR_EXTERNS/.nv.callgraph(cubin.rs:521-614) — layout assumptions that are exactly what differs between architectures; - if a target architecture emits kernel code under a different section prefix,
text_by_fnis empty and cubin.rs:434-436if text_by_fn.len() <= keep_functions.len() { return Ok(None); }silently disables pruning — the same silent path that plausibly explains only 35 of 123 modules pruning on SM87. Charter/AGENTS.md:200 require identifying missing hardware explicitly; the description does that, but the charter's served-workload evidence bar (#210) is met only on hardware outside the supported matrix. Fix: run at least one SM120 or SM121 export +flare runon a CUTLASS/FlashInfer-heavy module before merge, or gate pruning to layouts the author has validated.
#8 [high] Research summary
Reviewed PR #652 (heliopause: prune unreferenced kernels from exported CUDA ELF64 cubins, +937/−5 in heliopause/src/export/cubin.rs and capture.rs) through the correctness/contracts/system-consequences lens. I read the full diff, the new strip_and_prune/try_prune_unused_kernels in context, the capture loop that calls it, the Helios consumer that loads the resulting cubin, the KV-codec standalone-module path, the pyo3 surface, the CI workflows, and the design docs the change touches.
Six findings, all with exact citations, verbatim quotes, severity, impact and fix, saved to the scratchpad. The two biggest are correctness: the pruned image keeps auxiliary symbol tables and unrecognised sh_info values with pre-compaction section indices that are never remapped or reset (.nv.merc.symtab kind 0x70000085 is one the codebase itself knows about), and the only verification of the rewritten ELF is a bounds-only Elf::parse — the first real load is cuModuleLoadData on the serving machine. Both are amplified by two documented-nowhere silent all-or-nothing passthroughs (one unmatched captured symbol name, or one module with no surplus .text.* sections, disables pruning for the whole module with no log — the plausible explanation for the description's 35-of-123 pruned-modules figure), and by the fact that no CI lane runs the heliopause tests (search_code("heliopause", path=".github/") returns nothing), so the 5 export::cubin tests are manual-only. A fourth finding covers the charter's actual hardware matrix: all live evidence is SM87/AGX Orin while the change is unconditional for SM103/120/121, precisely the CUTLASS-heavy case it targets. Minor findings cover the docs now contradicting the code (core-format-design.md:380-381 still says symbol names are preserved) and per-module export-time memory amplification with both images live.
I also recorded a "verified sound" note: the standalone/KV-codec passthrough, the switch to global_symbols(&exported), the absence of any wire/proto/runtime contract change, and the byte accounting all hold up; I found no concurrency hazard in the module loop and no admission/rate-metric span change in this PR.
#9 [high] Review identity, scope and severity index (for the final report header)
PR #652 heliopause: prune unreferenced kernels from exported CUDA ELF64 cubins, author @lukealonso, head 9ea2491, base main, +937/−5 in 2 files:
heliopause/src/export/capture.rs(+10/−4)heliopause/src/export/cubin.rs(+927/−1)
Lens: Correctness, Contracts & System-Level Consequences.
Files opened in context (not inferred): the whole diff; heliopause/src/export/cubin.rs lines 1-260, 260-470, 470-700, 700-960, 960-1040, 1215-1284; capture.rs 2950-3110, 3109-3230, 3230-3400; heliopause/src/export/binding.rs 20-60, 1820-1870; heliopause/src/export/recorder.rs 975-1030; heliopause/src/export/core.rs modules handling; helios/src/runtime_core/mod.rs 760-880; helios/src/runtime_core/selection.rs 390-540; helios/src/core/schema.rs 541-580; helios/src/offload/transfer/gpu_codec.rs 265-300, 1270-1300; helios/src/startup.rs 200-340; ignition/preparation/module_images.py; ignition/preparation/runtime_core.py 85-135; ignition/preparation/memory_inventory.py 200-330; tests/preparation/test_cubin.py; AGENTS.md; docs/core-format-design.md 360-400; docs/runtime-core-design.md 55-95, 300-350; docs/TODO.txt; .github/workflows/native-serving.yml; .github/workflows/python-cpu.yml.
Severity-ranked index (each has its own note):
- Major — pruned image keeps auxiliary symtabs (
0x70000085) and unrecognisedsh_infowith stale pre-compaction indices (scratchpad note 1). - Major — two silent all-or-nothing passthroughs, no per-module diagnostic, explaining 35/123 and undocumented in the PR text (note 2).
- Major — rewritten ELF only self-checked by bounds-only
Elf::parse; nothing driver-loads it at export; no CI lane runs the heliopause tests (note 3). - Major — charter matrix SM103/120/121 never run but the change is unconditional on the export path (note 4).
- Minor —
docs/core-format-design.md:380-381anddocs/runtime-core-design.md:76now contradict the code; no docs in the diff (note 5). - Minor — export-time memory amplification, both images live at once, unmeasured (note 6). Plus note 7: areas verified sound (no findings).
#5 [medium] Finding 5 (Minor): design docs now contradict the code, unmodified by this PR
docs/core-format-design.md:380-381, verbatim: The exporter preserves kernel and global symbol names in cubins and their execution bindings. Cubin debug sections and assertion source paths are stripped.
After this PR that is false for dead kernels: cubin.rs:716-720
} else {
// Preserve local/global binding so symtab.sh_info stays valid; clear type, section, and name.
dead_syms.insert(idx);
entry[4] = sym.info & 0xf0;
}
clears st_name and st_shndx for every symbol in a dropped section, and the rebuilt .strtab (cubin.rs:674-690, add_str cache over surviving names only) never receives the dead name. The new test asserts it: cubin.rs:1230 assert!(!pruned.windows(11).any(|w| w == b"dead_kernel"));.
docs/runtime-core-design.md:76 likewise still describes heliopause as owning only "cubin debug stripping".
No docs file is in the diff (changed files are capture.rs and cubin.rs only), and AGENTS.md:54-60 requires documents to state designed behavior rather than contradict it. Since docs/core-format-design.md is the contract file a core reader trusts for "symbol names are preserved", this drift matters for anyone reasoning about old vs new cores.
Fix: update core-format-design.md:380-381 and runtime-core-design.md:76 in this PR to state that unreferenced kernel and dead symbol names are removed and their .symtab slots zeroed, and that this is layout-conditional with debug-stripped passthrough otherwise.
#6 [medium] Finding 6 (Minor): export-time memory amplification per module, unmeasured
heliopause/src/export/capture.rs:3280-3288:
for (index, (name, image)) in modules.into_iter().enumerate() {
let file = format!("module-{index}.cubin");
let keep_functions: BTreeSet<&str> = output.index.ranks[0]
.functions
.iter()
.filter(|f| f.module == name)
.map(|f| f.symbol.as_str())
.collect();
let exported = cubin::strip_and_prune(&image, &keep_functions)?;
Before: let exported = cubin::strip_debug(&image)?; — one image.to_vec() clone (cubin.rs:197) per module.
After, on the same loop that runs over every module:
strip_debugstill clones the whole image (cubin.rs:197let mut result = image.to_vec();) — cubin.rs:359let clean = strip_debug(image)?;try_prune_unused_kernelsthen allocates:sec_names(cubin.rs:409),symswith one heap&[u8]per symbol plusVec(cubin.rs:470),cg_edgesBTreeMap with a Vec per caller (cubin.rs:522),keep_text/keep_sec/old_to_new_sec/new_secs_old_idx/new_sec_name_off/new_offsets/new_sizesall O(sections) (cubin.rs:451, 617, 652, 663, 769-770),shstr_buf,str_buf,str_cache,new_symtab(cubin.rs:662-693), then the full re-emittedout(cubin.rs:768), and finallystrip_and_prunekeeps bothcleanandprunedlive simultaneously (cubin.rs:359-368). So peak live bytes per module roughly triples (clean + pruned + the ELF index structures) for modules of ~tens to ~135 MiB. PR #585 review previously flaggedstrip_debug'simage.to_vec()on Rayon's pool; this change adds the ELF rebuild on top.
Correctness note (worth flagging, not a defect): no issue found here — the loop is sequential (for … in modules), downloader and the BTreeSet are per-iteration, and the sets borrow output.index.ranks[0].functions immutably while output.index.ranks[0].modules.push occurs later in the same iteration body; no aliasing conflict and no cross-module shared state.
The PR description makes no export-time cost claim (its timing claim is load-time "Prepare kernels 0.5s → 0.1s"), so this is an unmeasured regression risk on very large modules rather than a stated benefit violation. Fix if accepted: reuse the clean buffer or let try_prune_unused_kernels consume image by value so peak is one image plus the output.
#7 [medium] Verified-sound areas (no findings)
Checked and found sound — do not report as issues:
-
Standalone / KV codec passthrough. capture.rs:3282-3288 builds an empty
BTreeSetfor path-only modules (ignition/preparation/runtime_core.py:402-415 registersGPU_CODEC_MODULE_NAMEpath-only), and cubin.rs:357-361 returnsOk(clean)immediately. Tested at cubin.rs:1273-1282. The Helios consumer loads that cubin by name lookup (helios/src/offload/transfer/gpu_codec.rs:282-298) from the separategpu_codec_cubinspath (helios/src/runtime_core/model.rs:628-664), not fromcore.modules, soprune_kernels(helios/src/runtime_core/selection.rs:461-481) never drops it. No regression. -
global_symbols(&exported)change. Enumerating globals from the pruned image is correct:global_symbols(cubin.rs:239-252) only acceptskind == 1(STT_OBJECT) withsize != 0and a live section index; dead slots withst_shndx == 0/ zeroed name and live.nv.global*/.nv.constant*sections are retained bysh_info_is_section+ thesym.shndx == 0 || >= SHN_LORESERVEandold_to_new_secbranches (cubin.rs:700-715). Theglobal_symbols(&exported)call is the same buffer just written tomodule-{index}.cubin(capture.rs:3291), so export-time symbol discovery and the exported artifact now agree — this is a tightening, not a loosening. -
The "can no longer trip standalone-module-declares-globals" side effect (capture.rs:3293-3298) is narrow: with an empty keep set the image is only debug-stripped, so that check is unchanged for standalone modules. Only a module that has captured kernels but lost all
.nv.globalsections could now pass; that state is already impossible for any kernel whose constants are reachable, because reachability seeds from the captured names andsh_infocascade preserves companions. -
p_alignhardcoded to 8 (cubin.rs:883put(&mut ph, 48, 8, 8);) and left-zerop_vaddr/p_paddr(never written bypush_ph, cubin.rs:876-885): unverified against NVIDIA's own SM120/121 output (never run there), but internally consistent with the gate that requires every inputp_vaddr/p_paddrto be zero (cubin.rs:397-401), and the emittedPT_LOADs are page-alignment-independent for CUDA's loader. Report only as part of Finding 4's matrix gap, not as a standalone defect. -
No wire/proto/runtime contract change. HELIOS reads
core.modules[].fileandcore.modules[].globalsunchanged (helios/src/core/schema.rs:541-580, helios/src/runtime_core/mod.rs:790-822); no schema, protobuf, Cargo, or CLI change is in the diff. Old cores still load. -
phase.advance_bytesaccounting is consistent — capture.rs:3289-3291 advances by the pruned length andmodule_bytesaccumulates the same value, so the "Capture compiled modules and globals" total shrinks with the artifact rather than disagreeing with it (helios/src/startup.rs:303-313).