Review of PR #332 — Report unresolved kernel argument address candidates during export
Lens: subtraction only. Reviewed at head 1ac7073d, base main c9935887. Diff: +599 / −37 across 4 files (heliopause/src/export/reachability.rs +579/−34, heliopause/src/export/capture.rs +6/−1, docs/runtime-core-design.md +8/−2, docs/TODO.txt +6). Roughly 374 of the added lines are tests (main's test module starts at reachability.rs:323–324 and was ~384 lines; head's runs 495–1252, ~758 lines), ~194 are production lines in reachability.rs, 14 are docs.
Key findings
- Should not be merged at this size. 599 added lines buy a non-blocking stderr diagnostic, and the PR's own measurement (mark-yong, 2026-11-28 19:09) still reports no stale pointer: 22,618 occurrences / 762 distinct addresses on rank 0 and 19,417 / 832 on rank 1, with every printed example a CUTLASS template constant (
0xfff00000fff,0x3fff000003ff,0x200000000020,0x100000001000) from mHC/dense-GEMM kernels — none from a W4A8 MoE kernel, none a live-owner miss. The required four-GPU measurement is filed as future work indocs/TODO.txt:350-354, so the change merges with its own validation open (charter line 11: "Bring real evidence … Bug fixes need to address the root cause"). - A version that answers every maintainer ask is ~155 production + ~90 test lines, i.e. ~350–450 of the 599 added lines can go without losing a requested behaviour (counts, ten aligned examples, hidden total, one rule, tests, docs).
- ~200 lines are removable with no behaviour lost at all: ~75 production (duplicate site structs, the miss list cloned twice per key, a single-use counter accessor, a pluralizer) and ~120 test lines (eight tests whose claim a sibling test already asserts).
- Nothing outside the two changed files is left dead: I swept
Reachability::pointer's callers, theblobsfield, the newgraph(name, …)parameter,merge_ranges/subtract_rangesusers, and the docs.
1. Blocking — ~350–450 lines: the change is far larger than its purpose (reachability.rs whole, capture.rs:3219-3223, docs)
docs/TODO.txt:350-354 records that the diagnostic has still not been measured on the hardware that motivates it: "Measure the unresolved kernel-argument diagnostic on a four-GPU DeepSeek V4.1 export (issue #266) and an eight-GPU W4A8 MoE export … Close when both exports have run … and the counts establish whether per-kernel example grouping is needed." The PR body says the same thing ("does not reproduce #266's four-GPU DeepSeek V4.1 failure"). Meanwhile #266's root cause is already fixed and independently verified by merged #331 ("Isolate cuBLAS warmup workspaces from CUDA graph capture"): FujitsuPolycom, 2026-11-19, four GB10s TP4, "all 120 cuBLAS split-K workspace arguments identified in #266 resolved to the same recorded allocation on each rank", 7,014/7,900-token prompts served, no new Xid.
So the honest scope is the maintainer's asks and nothing more (yatesdr, 2026-11-18 items 1–7; 2026-11-19 15:56 item 4; 2026-11-20 04:34 items 1–4): occurrence and distinct-address counts per rank, up to ten 8-byte-aligned examples carrying graph / node / symbol / module / argument / offset, the omitted total, one rule for live/inactive/gap, a test per distinct fact, and a doc sentence. That is ~155 production + ~90 test lines plus the 8 doc lines already present. The extra ~350 lines are: a second site struct and an order field with a re-sort of a HashMap (reachability.rs:45-76, 196, 208, 247-248), a per-key miss-list cache (172-213), an Option<&mut Vec> sink threaded through scan (283-288, callers 185-189, 402-406, 410), unresolved_unique_addresses (222-224), a four-line prose summary plus with_count (236-246, 487-493), and ~374 lines of tests where ~90 suffice.
Nothing else in the diff is behaviour change: the pointer → candidate rename (153-170), the alignment filter (294-303) and using name/node_index/position for the site (308-345) are each a few lines.
2. Should fix — ~120 lines: eight of the twelve new tests re-prove a sibling test (reachability.rs:804-1133)
Ranked by saving, with the sibling that already asserts the same fact:
unresolved_report_hidden_line_sums_omitted_address_occurrences(944-987, 44 lines). Its only claim is that the omitted line sums hidden occurrences rather than counting hidden addresses;unresolved_report_bounds_examples_and_counts_hidden_occurrences(876-905) already asserts" … 2 more distinct addresses (4 occurrences) not shown"where 4 ≠ 2, so an implementation printing the address count fails there. Same shape, different numbers. −44.unresolved_report_omits_hidden_line_when_all_distinct_addresses_are_shown(907-942, 36 lines). The one-address half (907-926) restatesunresolved_report_names_the_kernel_and_its_symbol(841-874) and the empty case (989-993); only the exactly-ten boundary is new and needs ~6 lines. −30.kernel_argument_boundaries_and_external_values_follow_the_recorded_contract(995-1017, 23 lines). The live/gap boundaries are the same valuesfreed_interval_boundaries_report_kernel_candidates_without_retaining_storage(1071-1133) walks; the out-of-envelope rows exercisepointer >= floor && pointer < ceiling, unchanged from main (main'sreachability.rs:152-155). −20.shared_argument_bytes_record_one_example_per_address(824-839, 16 lines). Dedup-by-address and first-site retention are asserted by876-905, which reports 12 distinct addresses across graph-a/graph-b withlines[1].contains("graph \"graph-a\" …"). −16.kernel_argument_inactive_ranges_are_reported_but_numeric_ranges_stay_lenient(1019-1033, 15 lines). The inactive half is the third argument of1071-1133; the numeric half is main'snumeric_argument_holes_are_conservative(mainreachability.rs:600-607). −15.kernel_argument_candidate_offset_counts_from_the_argument_start(804-822, 19 lines). Offset-from-argument-start is new but needs ~8 lines; its numeric-hole half repeats the same main test. −10.allocation_contents_still_tolerate_gap_candidates(1035-1043, 9 lines). One distinct fact ("contents() never reports") in 3 lines. −6.unresolved_report_is_empty_without_candidates(989-993, 5 lines). With the guard atcapture.rs:3219deleted (see §3) nothing calls the report on an empty map; the assertion isVec::is_empty()on no work. −5.
Total 146; a conservative claim is −120. Reviewer yatesdr already flagged this pattern once: "repeated_argument_bytes_report_every_call_site repeats what unresolved_examples_are_capped_while_occurrences_are_counted already proves, except the graph name" (2026-11-18, item 6).
3. Should fix — ~75 lines: five production simplifications (reachability.rs:45-76, 172-281, 487-493; capture.rs:3219-3223)
(a) −19: one site struct instead of two plus three doc blocks (reachability.rs:45-76). UnresolvedCandidate and Site carry the same four fields; the difference is String vs &str.
/// A kernel argument value that resolves to no live recorded allocation, in a gap
/// between allocations or an inactive block. It may be a stale pointer or a numeric
/// constant, so export reports it without failing.
#[derive(Clone)]
struct Site<'a> { graph: &'a str, node: usize, function: usize, argument: usize }
struct Unresolved {
graph: String, node: usize, function: usize, argument: usize, offset: usize,
order: usize, occurrences: usize,
}
/// Distinct addresses shown per rank.
const UNRESOLVED_EXAMPLES: usize = 10;
(b) −18: the miss list is cloned twice per key (reachability.rs:172-213). misses.clone() at 175 and again at 191; the cached Vec is then moved into the loop at 195. Moving the temporary into the map and reading it back by disjoint field borrow removes both clones (no misses.clone(), no match):
fn blob(&mut self, data: &[u8], numeric: &[(usize, usize)], site: &Site) -> ExportResult<()> {
let key = (data.to_vec(), numeric.to_vec());
if !self.blobs.contains_key(&key) {
let excluded = merge_ranges(numeric.iter().map(|&(s, e)| (s as u64, e as u64)).collect());
let mut misses = Vec::new();
for (start, end) in subtract_ranges(0, data.len() as u64, &excluded) {
self.scan(&data[start as usize..end as usize], start as usize, Some(&mut misses))?;
}
self.blobs.insert(key.clone(), misses);
}
for &(offset, address) in &self.blobs[&key] {
let order = self.unresolved.len();
self.unresolved.entry(address).and_modify(|e| e.occurrences += 1).or_insert(Unresolved {
graph: site.graph.to_owned(), node: site.node, function: site.function,
argument: site.argument, offset, order, occurrences: 1,
});
}
Ok(())
}
(c) −35: four-line prose summary plus the pluralizer (reachability.rs:236-246, 253-262, 270-278, 487-493). with_count is new machinery with no other user (search_code 'fn plural' → no matches) and each call site needs two format arguments plus a wrapped string. "occurrence(s)"/"address(es)" on stderr is exact enough and makes unresolved_report ~26 lines instead of 56 + 7:
let mut lines = vec![format!(
"kernel argument scan: {occurrences} occurrence(s), {} address(es) outside every live allocation",
examples.len())];
...
" graph {:?} node {} kernel {} ({}), argument {}, offset {}: {address:#x} ({} occurrence(s))"
...
" … {} more address(es) ({} occurrence(s)) not shown"
(d) −3: unresolved_unique_addresses (reachability.rs:222-224) is self.unresolved.len(), used only at 242 and in four asserts where .len() reads the same.
(e) −3: the print guard duplicates the report's own empty check (capture.rs:3219-3223). unresolved_report already returns an empty Vec when occurrences == 0 (reachability.rs:232-235), so:
for line in reach.unresolved_report(&output.index.ranks[0].functions) {
eprintln!("export: rank {}: {line}", request.rank);
}
Kept deliberately: the order field and its sort at 247-248 (dropping it would change which ten examples print), and the Option<&mut Vec> sink at 283-288 (removing it makes callers longer than it saves — a wash, not a subtraction).
4. Nit — 3 lines: the reporting rule is documented twice (docs/runtime-core-design.md:154-157 and :339-341)
Both paragraphs say the same thing: aligned argument values in gaps/inactive ranges are reported per rank on stderr without retaining inactive storage. One sentence in each is the most the two contexts need; the second is the one the reviewer asked for, so trim the first.
What I checked and dropped
- Inactive-range rule stated twice — fixed at head:
candidate(reachability.rs:153-170) is now the single live/inactive/gap rule andscanno longer re-partitions. Do not re-raise. - Alignment filter (
reachability.rs:294-303) — new behaviour the maintainer required (yatesdr, 2026-11-20 item 1); not a subtraction. kernel_symbols/CUfunctionhandle map — already gone; symbols come from the recorded function index (reachability.rs:252-258,capture.rs:3202-3209). No dead path.Option<&mut Vec>sink — three lines inscan, three at each of three call sites; inlining the collection would grow them.- Nothing left behind elsewhere:
Reachability::pointerhas no other caller,blobsis private,graph(name, …)'s only production caller iscapture.rs:3102, andmerge_ranges/subtract_rangesusers inweight_reuse.rs(not opened) are unaffected. The diff needs no follow-up deletions.
Open questions
- Which ten examples to print is unverified: with
orderretained, output is by first encounter; if a reviewer prefers sorting by address, theorderfield disappears (−4 more) but the printed examples change. - No one has shown that any aligned candidate in the Vision-Exp export is a stale pointer; until the TODO measurement runs, the diagnostic's output cannot be distinguished from constants, which is the substance of the blocking finding.
Verdict: should not be merged The change: +599 / −37 lines, 4 files Could remove: about 200 lines with no behaviour lost, in 15 places; about 350–450 lines if cut to what the maintainer asked for Biggest subtractions:
heliopause/src/export/reachability.rs:944-987:unresolved_report_hidden_line_sums_omitted_address_occurrencesduplicates the 4≠2 assertion in:876-905: nothing: about 44 linesheliopause/src/export/reachability.rs:907-942: hidden-line-omitted test restates:841-874and:989-993; keep only the exactly-ten boundary: about 30 linesheliopause/src/export/reachability.rs:236-278,487-493: four-line prose summary andwith_countpluralizer: one-line "occurrence(s)"/"address(es)": about 35 linesheliopause/src/export/reachability.rs:45-76: duplicateUnresolvedCandidate/Sitestructs and three doc blocks: oneSite<'a>plus oneUnresolved: about 19 linesheliopause/src/export/reachability.rs:172-213:misses.clone()twice per key and thematch: move the temporary into the cache and borrow it back: about 18 lines Left behind: None. (Verified: no otherpointercaller, privateblobs,graph(name, …)only from capture.rs:3102,merge_ranges/subtract_rangesusers unaffected.) Link: https://github.com/NVIDIA/hyperflare-inference/pull/332