Review — PR #332 "Report unresolved kernel argument address candidates during export"
Lens: correctness (does the change work everywhere it reaches). Head reviewed: c3cc87e; base main; 2 files, +434/−30 (heliopause/src/export/capture.rs, heliopause/src/export/reachability.rs).
Key findings
- Blocking — the report still counts and prints unaligned 8-byte windows.
scaniteratesdata.windows(8)at every byte offset (heliopause/src/export/reachability.rs:259) and records each value as a candidate (:269). Nothing in the head filters onoffset % 8. Maintainer yatesdr's 2026-11-20 review made this a blocking item ("report only argument-relative offsets divisible by 8") precisely because a value at offset 4 spans two CUDA parameters and cannot be a pointer. The PR's own first example is such a window:argument 0, offset 4: 0x100000000800(PR description and mark-yong's 2026-11-19 comment). The reported totals (rank 0: 175,329 occurrences / 2,646 distinct addresses; rank 1: 170,544 / 2,637) therefore measure straddling windows, not address-shaped arguments. - Should fix — inactive ranges are checked raw while live intervals are trimmed to granule boundaries, so values inside a live recorded allocation are reported as being outside every live allocation, and the summary line asserts something false.
- Should fix — the same inactive rule is stated twice (maintainer item 2), which is also the mechanism of finding 2.
- Should fix — no test covers the straddle case (maintainer item 3) or the print path.
- Nits: the "not shown" line mixes occurrence and distinct-address quantities; prose/evidence nits.
Blocking
B1. No 8-byte alignment filter: the counts and the examples are windows, not argument values
heliopause/src/export/reachability.rs:248-274
for (offset, bytes) in data.windows(8).enumerate() {
let pointer = u64::from_le_bytes(bytes.try_into().unwrap());
if pointer >= floor && pointer < ceiling {
...
misses.push((base + offset, pointer));
}
}
data is the encoded kernel-argument blob (one entry per parameter, per encode_kernel); windows(8) yields a value at every byte offset, so for one 8-byte pointer parameter the scan examines offsets 0..8 and reports every one of them that lands in the envelope. Only the naturally aligned offsets can hold a pointer field; the rest straddle two parameters and are not pointer-shaped values at all.
Evidence that this dominates the output rather than being a corner case:
- The description's first example is
argument 0, offset 4: 0x100000000800— a straddling window whose halves are0x800and1. That is not a stale pointer, and ten such addresses fill all ten example slots before a real stale pointer can appear (UNRESOLVED_EXAMPLES = 10,reachability.rs:75, examples taken inorder= first-insert order,:222-224). - The tests confirm unaligned offsets are reportable, not excluded:
unresolved_examples_are_capped_while_occurrences_are_counted(:750-770) builds back-to-back 8-byte values and asserts 12 candidates at offsets 0,8,16,…; nothing anywhere asserts a straddling window at offset 4 is not reported. unresolved_report_names_the_kernel_and_its_symbol(:809-842) likewise assumes a hit at offset 0 only.
Why it matters: this diagnostic is the PR's entire deliverable (it does not block export), so its value is entirely in whether the counts and examples point at #266's real stale arguments. As printed, the counts can be inflated by up to ~8× per parameter and the ten examples are the earliest windows, so the run reported in the description says nothing about whether W4A8 MoE constants or mHC constants are the source — consistent with the author's own caveat that the examples "do not establish W4A8 MoE kernel behavior".
Fix: keep the retention iteration exactly as it is (it is deliberately conservative and the maintainer asked for that), but only push a miss when (base + offset) % 8 == 0 (or iterate a second, chunks_exact(8)-style aligned pass for reporting). Then re-run the export and re-post the counts, as the maintainer asked in item 1.
Cited: reachability.rs:248-274, :75, :222-224; maintainer review 2026-11-20 item 1; PR description examples.
Should fix
S1. in_free_block uses raw inactive ranges; live intervals are granule-trimmed → false "outside every live allocation" reports
heliopause/src/export/reachability.rs:107, :131-145, :262-271; heliopause/src/export/capture.rs:1196-1240, :1408-1423, :3074, :3137-3141
Reachability::new records inactive: merge_ranges(inactive.to_vec()) — the raw ranges from the preparation runtime (ignition/preparation/runtime_core.py:296 → core_storage.unused_ranges(), ignition/preparation/core_storage.py:303-318, plus persistent.py:135-141 padding). Live intervals, by contrast, are built from allocations after live_pieces trims each hole to the allocation's granule (capture.rs:1211-1212: start.max(begin).div_ceil(granule) * granule, stop.min(end) / granule * granule), applied at capture.rs:1408-1423 for device allocations with sizing.is_none().
Consequence: whenever a hole edge is not granule-aligned, the retained live piece still covers [raw_start, aligned_start) and [aligned_stop, raw_stop). A kernel-argument value in that edge is inside a live recorded allocation — candidate()'s interval lookup would reference it — but candidate() returns early on the raw inactive hit (:131-135) before the interval lookup, and scan computes in_free_block from the same raw ranges (:262-265), so :266 reports it anyway. The summary line then states the value is "outside every live recorded allocation" (:211-214), which is false, and the operator cannot distinguish it from #266's real gap pointer.
The scale is not marginal: the granule comes from cuMemGetAllocationGranularity (ignition/preparation/core_storage.py:93, 497-499, virtual_storage.py:28-36 (not opened)) — MiB-class — while the ranges come from torch block addresses/sizes and packing padding at much finer alignment (core_storage.py:312-315, packed_weights.py:25). Every hole can contribute up to a granule of live-but-reported addresses on each side, for every graph argument. This is a second large false-positive source on top of B1 and it inflates both the occurrence and distinct-address counts.
The existing tests do not reach it: freed_interval_boundaries_report_kernel_candidates_without_retaining_storage (:929-966) uses a hole 1024..3072 inside a 4096-byte allocation with alignment: 256, so both hole edges are granule-aligned and trimmed == raw. Same for kernel_argument_inactive_ranges_are_reported... (:902-916, hole 0x3000..0x3100).
Fix: derive the report predicate from the same geometry as intervals — treat a value as a candidate exactly when it falls in no self.intervals entry, and drop the separate raw-inactive lookup (see S2). Add a test with a non-granule-aligned inactive range asserting that a value in the retained edge is not reported, and that a value in the trimmed hole is.
S2. The inactive rule is stated twice (maintainer item 2)
reachability.rs:131-135 (inside candidate) and :262-265 (in_free_block in scan) implement the same predicate, and the second copy re-derives it from a different source (self.inactive) than the first's interval check. Two copies of one rule that already disagree is exactly how S1 arose. Fixing S1 by deciding candidacy solely from self.intervals removes in_free_block and answers item 2 in one edit.
S3. No test for the straddle case (maintainer item 3)
The maintainer asked for: an 8-byte pointer to a live allocation followed by a small integer in one argument, asserting the straddling window is not reported and a stale pointer at an aligned offset is. Nothing like it exists; the nearest tests (:750-770, :772-790) only assert what is reported. Without it, B1 stays open and a future alignment fix has no regression guard.
S4. The print path is untested
capture.rs:3137-3141 is the only caller:
if reach.unresolved_count() > 0 {
for line in reach.unresolved_report(&output.index.ranks[0].functions) {
eprintln!("export: rank {}: {line}", request.rank);
}
}
It needs a CUDA context, so no test exercises the rank label, the eprintln prefix, or the fact that output.index.ranks[0].functions is the right list for candidate.function. That last point is load-bearing and only implicit: Site.function is node.function as usize (reachability.rs:305-313), i.e. an index into the kernels slice, and functions is filled by pushing one entry per kernel in order at capture.rs:2986-2992 while wire::Kernel.function is set to that index at encode_kernel (capture.rs:889, used at :3113-3127). If any of those three orderings drifts, every reported symbol silently becomes the wrong kernel — the report degrades without failing. A unit test that runs a two-kernel graph through Reachability::graph + unresolved_report with a two-element functions list (as :809-842 does for one) would pin the index mapping; only a test can settle this, since the wiring itself cannot be exercised without a GPU.
Nits
N1. "not shown" mixes two quantities
reachability.rs:238-243: hidden = occurrences - examples.len().min(10). With the description's numbers (2,646 distinct, 175,329 occurrences) the line reads "… 175,319 more occurrences not shown" while what is actually omitted is 2,636 distinct addresses as well. The behaviour is enshrined in unresolved_report_bounds_examples_and_counts_hidden_occurrences (:869: "… 14 more occurrences not shown"). Say both: "… 2,636 more distinct addresses, 175,319 occurrences not shown".
N2. Types are public only for the test module
UnresolvedCandidate / Site / UnresolvedEntry are pub(crate) (:49-71) so mod tests can reach reach.unresolved[...].first / .order / .occurrences (:728-730, :767-768). A single classify(value) -> {Retain, Reference, Report} returning one enum would remove both the bool of candidate() and the separate in_free_block predicate, and with them the drift that produced S1. Style-level; fold into S1/S2.
N3. Evidence wording in the description
Given B1 and S1, the reported totals cannot yet be attributed to mHC constant noise, W4A8 MoE constants, or stale pointers, and the ten printed examples are provably straddling windows. The charter's "Bring real evidence" line (charter line 11) and the requirement that a PR answer a maintainer request (line 35) both apply: re-run the export after the alignment and trimmed-hole fixes, then present the counts. The description's own limitation paragraphs are honest, which is good, but they should not have to carry the evidence burden for a diagnostic whose printed output is currently dominated by non-pointers.
Verified as unchanged / correct (no finding)
- Retention semantics are untouched.
candidate()returns exactly what the oldpointer()returned: inactive hit → no reference,Ok(true); interval hit →reference(name),Ok(true); otherwiseOk(false)(:131-145). The report is additive only, andunresolved_count/unresolved_reportare consulted after all graphs (capture.rs:3137), never as an error path. The PR is a diagnostic, not a gate, as advertised. - Allocation-content scans cannot produce false reports.
scan_contentsand the opaque path passmisses: None(:364-380), so only kernel-argument blobs report;allocation_contents_still_tolerate_gap_candidates(:918-926) covers it. - The
blobscache change is sound. The key is still(data, numeric); misses depend only on those two, so caching the first site's miss list and replaying it per site is correct, and retention still runs once per unique blob as before (:147-188). Numeric exclusions are still subtracted before scanning (:152-165), sokernel_argument_candidate_offset_counts_from_the_argument_start's numeric-range behaviour is preserved;unaligned_numeric_token_ids_do_not_retain_address_shaped_bits(:968-986) still passes conceptually and the code path is untouched. - Offsets are argument-relative.
baseis the chunk start within the blob (:159-164), sobase + offsetis an offset from the argument start even when numeric ranges split the slice — verified against:773-790. - Inactive storage is not retained.
candidate()short-circuits withoutreferencefor inactive hits, andfreed_interval_boundaries_report_kernel_candidates_without_retaining_storage(:929-966) asserts both directions. - Report order is deterministic (
order= map length at first insert, sorted at:222-223), so a given export prints the same examples. - Printing on every rank is safe (stderr, rank-labelled; no JSON-framed stdout stream is written on this path), and memory growth is bounded by distinct addresses per rank.
Open questions / could not verify
- Commit message (maintainer item 4, second half). The 2026-11-20 review asked that the commit message and description agree about W4A8 coverage. I cannot read the commit message for
c3cc87efrom the repository view; whoever merges should confirm it. - Whether #266's own arguments would be caught at all. The maintainer noted the stale arguments sit at offset 256 of a 384-byte parameter and at offset 0 of argument 1 — both 8-byte aligned, so an alignment fix keeps them. Worth stating in the description as the acceptance criterion, since it is the only check that the diagnostic still does its job after B1 is fixed.
- Real-export re-run. B1 and S1 both change the printed numbers substantially; the description's table should be regenerated. Nothing in this review can substitute for that run.