Explore scratchpad · NVIDIA/hyperflare-inference #652

Raw Markdown for agents: https://autobot.eidonix.com/p/60a47d08-3910-46f8-ae4b-31553137b66c.md

#1 [high] Change: size, files and what the diff actually does

PR #652 "heliopause: prune unreferenced kernels from exported CUDA ELF64 cubins", head 9ea2491, base main (branched at 571a447), open/ready for review, no labels, no reviews, no comments (pr_comments returned empty).

Files (pr_files): heliopause/src/export/capture.rs (+10 -4), heliopause/src/export/cubin.rs (+927 -1).

cubin.rs changes:

capture.rs change (capture.rs:3282-3291, 3294, 3315): builds per-module keep_functions from output.index.ranks[0].functions filtered by f.module == name, calls cubin::strip_and_prune(&image, &keep_functions), and now calls cubin::global_symbols(&exported) (was &image) for both the standalone-module guard and the per-symbol cuModuleGetGlobal_v2 loop — i.e. globals are enumerated from the pruned image, matching the description.

History of cubin.rs: only three earlier commits, all by Luke Alonso (9ea2491 this PR, 28f0833b licensing 2026-10-30, 3edd2c3a, 14a6a273 2026-10-22). items_touching(heliopause/src/export/cubin.rs) = no other open/merged PR in 180 days touches it.

#2 [high] Change: undeclared/undocumented behaviours found in the code

Things the code does that the PR description does not say (all heliopause/src/export/cubin.rs unless noted):

  1. Pruning is all-or-nothing per module on any captured symbol name that has no .text.<name> section: for &fn_name in keep_functions { let Some(&si) = text_by_fn.get(fn_name) else { return Ok(None) } } (cubin.rs ~line 500 area, inside try_prune_unused_kernels). So one unmatched cuFuncGetName symbol (e.g. mangled vs section-sanitised name) makes the whole module fall back to debug-stripped passthrough with no error and no log. This, plus the text_by_fn.len() <= keep_functions.len() shortcut, plausibly explains "35 multi-kernel modules pruned" out of 123 modules in the description's SM87 export. The description lists fallbacks only for stripped names / missing phdrs / SHN_XINDEX / non-zero vaddrs.
  2. Pruning only happens when strictly more .text.* sections exist than kept functions (if text_by_fn.len() <= keep_functions.len() { return Ok(None) }).
  3. Program header p_align is hardcoded to 8 for every emitted PT_PHDR/PT_LOAD (push_ph writes 8 at ph+48) rather than copied from the input; p_vaddr/p_paddr are left 0 and p_paddr is never written (stays 0), matching the input invariant it verified.
  4. The symbol table keeps its original size: dead entries stay as 24-byte slots with binding bits only (entry[4] = sym.info & 0xf0), so .symtab bytes are not reclaimed — only .strtab names and dead .text/companion payloads are. Description says this ("preserving .symtab entry indices while zeroing dead symbol slots") but it means .symtab is not a size win.
  5. Dead-symbol detection is sym.shndx != 0 && shndx < SHN_LORESERVE && !keep_sec[shndx]; symbols in dropped sections lose their name (strtab offset 0) and section index. Global/absolute symbols (shndx 0 or >= SHN_LORESERVE) are always preserved with names.
  6. .nv.info.<fn> EIATTR_EXTERNS parsing (attr 0x0f) is per kept text section via the .nv.info.<fn> section's sh_info mapping; if a .nv.info.<fn> section is missing the externs are just not followed.
  7. strip_and_prune re-parses the pruned bytes (Elf::parse(&pruned)?) as a sanity check, but nothing checks that the pruned image still contains every kept .text after the cascade, and nothing validates the result against the CUDA driver at export time — the first cuModuleLoadData of the pruned image happens at serving time (helios/src/runtime_core/mod.rs:796).
  8. is_debug_section and the strip_debug debug-name test are now two copies of the same predicate (cubin.rs:189-193 and cubin.rs:254-259).

#3 [high] Process: heliopause tests are not covered by CI workflows

CI: pull_request triggers exist in .github/workflows/native-serving.yml:6, python-cpu.yml:6 (and helios-lifecycle/release to check). BUT no workflow runs cargo test --manifest-path heliopause/Cargo.toml:

Orientation packet says "CI on the head commit: pending"; local copy has no CI results for 9ea2491.

#5 [high] Related work: #394 staging, #585 strip_debug perf, #504 kv_codec, #642

Related work, same/adjacent code:

#7 [high] Project fit: charter alignment, hardware-matrix gap, doc drift

Project fit (charter, docs, process) — facts, both ways: ALIGNS:

DOES NOT / OPEN TENSIONS:

#8 [high] Claims and evidence: what backs each claim and what does not

Claims vs evidence (cubin-flavoured technical claims, presented as facts/observations, not verdicts):

CLAIM: "Preserving .symtab entry indices while zeroing dead symbol slots keeps all per-function .nv.info., .text. sh_info, and relocation symbol references valid". Implementation keeps every symtab slot (24 bytes each, cubin.rs new_symtab loop) so index references stay valid; dead slots keep only the binding nibble (entry[4] = sym.info & 0xf0) and get st_shndx=0, all-zero value/size/name. Note: setting st_shndx=0 (SHN_UNDEF) rather than leaving the old section index is the mechanism that keeps symtab.sh_info valid? — actually sh_info of .symtab is the index of the first non-local symbol, and the code preserves st_info binding bits explicitly "so symtab.sh_info stays valid". No test asserts symtab.sh_info after pruning: the two new tests (cubin.rs:1223-1281) check dead-section removal, callee retention, companion sh_info remap, global symbol preservation, and passthrough, but never assert elf.sections[symtab].info or that cuModuleLoadData accepts the result.

CLAIM: "computes transitive kernel reachability from the captured symbols plus non-debug SHT_REL/SHT_RELA targets, .nv.callgraph edges, and per-function .nv.info. EIATTR_EXTERNS (0x0f)". Verified in code at cubin.rs:451-457 (seeds), 492-519 (relocations), 521-540 (callgraph), 541-... (externs loop, fixed-point loop { … if !added { break } }). Reachability is over section indices derived from symbol shndx, so a callee reachable only through a symbol whose shndx is SHN_UNDEF or absolute (>0xff00) is not followed.

CLAIM: "removes … companion sections whose sh_info references a dropped section—including per-kernel .nv.constant*, .nv.shared., .nv.local. emitted without SHF_INFO_LINK (as in CUTLASS cubins)". Code: sh_info_is_section (cubin.rs:262-...) + the cascade loop that repeatedly drops sections whose sh_info target is dropped. Concrete risk noted by reading, not tested: .nv.constant* is classified as section-index-bearing only when the name has a dot after .nv.constant (name.strip_prefix(b".nv.constant") then rest.contains(&b'.')); a per-kernel bank named .nv.constant0 with no function suffix, or .nv.global.init, is treated as sh_info-not-a-section and therefore never dropped/remapped — it survives with a stale sh_info, which the later sh_info remap also leaves untouched (sh_info_is_section false ⇒ s.info copied as-is). That is the shape of thing that would make a driver reject the module; nothing in the PR tests it.

CLAIM: filters "dead-symbol entries from global .nv.info (0x11/0x12/0x2f) and .nv.callgraph". Code: filter_global_nvinfo / filter_callgraph; both return None (⇒ whole-module passthrough) on any parse anomaly. filter_callgraph's guard b < 0xffff_fff0 treats high u32 values as sentinels, and drops edges where either endpoint is dead.

CLAIM: standalone & non-standard layouts "pass through debug-stripped without structural pruning" — implemented and tested (cubin.rs:1273-1281 uses the existing cubin() fixture which has phnum=0), but the gate list in the description is incomplete vs code: it also requires phentsize == 56, p_flags ∈ {5,6} for PT_LOAD, no duplicate SHT_SYMTAB, symtab.stride == 24, .text.* names that are valid UTF-8, and — crucially — every kept function name to match a .text.<fn> section (see the "undeclared behaviours" note).

NUMBERS (unverified in-repo): 166.51 MiB → 19.46 MiB uncompressed cubin; 9.93 MiB → 1.5 MiB kernels.safetensors; 251 functions / 123 modules / 35 modules pruned; Prepare kernels 0.5s → 0.1s; pre-cache 6.73 GiB → 6.45 GiB (−287 MiB); KV 15,488 → 32,768 tokens, snapshot slots 3 → 7. No artifacts, logs, profile output, or script accompany them; nothing in the repo records the baseline. tests/preparation/test_cubin.py (6 tests) was not modified by this PR (pr_files) and only exercises strip_debug/global_symbols, not pruning.

TEST CLAIMS: "223 non-CUDA tests passed" is a full-suite count for the heliopause crate; the added tests are 2 #[test] functions (cubin.rs:1223, 1273) — the description says "5 export::cubin unit tests", which is the total in the module (3 pre-existing at cubin.rs:977/995/1015 + 2 new), consistent. But pruning_removes_dead_kernels_and_keeps_callees_and_globals loops over two fixture variants (callgraph vs EIATTR_EXTERNS) inside one test, so 2 new test functions cover 3 scenarios.

#9 [high] Reach: who and what it affects

Reach / impact:

#4 [medium] The why: no issue is linked, motivation is prose + ambient evidence

The "why" — problem statement and where it comes from:

#6 [medium] People: author is area owner and sole prior cubin.rs author

People:

#10 [medium] Process and recent activity: fresh, unreviewed, no CI recorded, builds on #646/#647

Process / activity: PR #652 by lukealonso, opened 2026-12-01 06:15 and last updated 06:15 (same minute) — hours old at capture, no stale-work risk yet. State "open, ready for review" per orientation packet. Labels: none (contrast #646 with area:caching/area:memory/bug/performance/triage:review). Reviews: none. Comments: none — read_item 652 "Discussion (0)" and no flare-autobot case-file comment, which every other PR in the local copy received (e.g. #394 at 2026-11-25). CI on head 9ea2491: pending per orientation packet; no CI results locally. Base main, branched at 571a447; no default-branch commits since then touch either changed file (orientation packet), though #646 and #647 (merged 2026-11-30, same author) do touch capture.rs, so the rebase is textual-clean but semantically adjacent.

Branch history on cubin.rs: only 9ea2491 (this), 28f0833b (licensing), 3edd2c3a, 14a6a273 — all lukealonso.

Recent activity in heliopause/src (orientation packet, last 60 days): bf7562ae #646 and f2ca2c41 #647 (both lukealonso, 2026-11-30) touch capture.rs; c146d7be #620 (copy drafts), e0290571 #586 (PCCessna, Engram planes), e80b1f2f #618 (single-pass export), f1bd4210 #587 (FujitsuPolycom, skip digest/fsync on disposable spans), a39f6777 (silent export corruption). This PR builds on that stream rather than reversing it: it keeps capture_rank's module loop shape (staging writes, module_globals download, reach.opaque_contents) and only swaps the cubin transform and the image used to enumerate globals. It does not conflict with #587's disposable-span work (the pruned bytes are what get staged) but it does add per-module CPU work to the same span, and it supersedes nothing. Recent activity angle: nothing in the diff reverses earlier work; the one thing it changes in behaviour is that global_symbols is now read from the exported image (capture.rs:3294, 3315) instead of the raw one — the description states this, and it is the reason a module whose globals were pruned out can no longer trip the "standalone module declares globals without a captured kernel" error (capture.rs:3293-3298).

#11 [medium] Community: no engagement at all; no CI lane reproduces the evidence

Community angle: nothing to report beyond absence. Zero comments, zero reviews, zero reactions on #652 (read_item 652 "Discussion (0)"; pr_comments empty). No linked issue, no linked PR, no Discord discussion captured besides the PR's own "Discord: lukealonso" line. Related_items() cannot resolve #652 (not in the local copy), so cross-references come from search_items/items_touching instead. Interest so far: none outside the author — the PR was opened and not yet touched by the Autobot intake either (no case-file comment), so a reviewer arriving later would be the first reader.

Environment/verification note for the report: the PR's live evidence hardware (SM87 Jetson Orin Nano 8 GB, AGX Orin with --memory-limit 6900m) is not in the charter's supported matrix (SM103/SM120/SM121) and CI here has no GPU: python-cpu.yml sets CUDA_VISIBLE_DEVICES="" (.github/workflows/python-cpu.yml:32), and helios tests in native-serving.yml are CPU-side. So no automated lane in this repo can reproduce either the pruning correctness on real cubins or the memory/KV numbers; all cubin tests use hand-built synthetic ELF fixtures (cubin.rs:910 cubin(), cubin.rs:1032 multi_kernel_cubin()).