Review — PR #332 "Report unresolved kernel argument address candidates during export"
Lens: correctness. Head 1ac7073d, base main; 4 files, +599/−37 (heliopause/src/export/capture.rs, heliopause/src/export/reachability.rs, docs/TODO.txt, docs/runtime-core-design.md). Refs #266.
Key findings
No blocking issues at 1ac7073d. All three blockers from my 2026-11-25 review of c3cc87e are fixed: the 8-byte alignment filter landed on the reporting push only, the duplicate in_free_block rule is gone, and the maintainer's straddling-window regression test exists.
Two should-fix items remain, both about the diagnostic's evidence value rather than about export correctness (the scan never retains storage or fails an export, so nothing here can corrupt an artifact):
- The report and the exporter disagree about what "inactive" means, and the mismatch cuts both ways: it over-counts in retained hole edges and, more importantly, silently misses stale values in freed sub-granule blocks — precisely the #266 shape.
- The argument-relative alignment rule is untested across numeric spans, so the one guard that keeps the counts interpretable (and that the counts now depend on — totals fell 175,329→22,618 after it landed) could regress to
base = 0without a failing test.
Three nits follow. Everything below is verified against the code at this head.
Should fix
1. heliopause/src/export/reachability.rs:156-170 and :298 — the report uses raw inactive ranges while the exported intervals are granule-trimmed, so sub-granule freed blocks go unreported
candidate() checks self.inactive first and returns Ok(false) before the interval lookup:
fn candidate(&mut self, value: u64) -> ExportResult<bool> {
let inactive = self.inactive.partition_point(|&(start, _)| start <= value);
if inactive > 0 && value < self.inactive[inactive - 1].1 {
return Ok(false);
}
let index = self.intervals.partition_point(|&(start, _, _)| start <= value);
...
Reachability::new is still handed raw, merged request.inactive (capture.rs:3164), and inactive is stored merged but untrimmed (reachability.rs:108). The exported live intervals, by contrast, come from live_pieces, which trims every hole inward to granule boundaries (capture.rs:1259-1303, applied at 1471-1485 for memory == "device", sizing.is_none(), non-peer, no snapshot spans: start = start.max(begin).div_ceil(granule) * granule, stop = stop.min(end) / granule * granule).
Raw hole edges are not granule-aligned in practice: core_storage.unused_ranges() (ignition/preparation/core_storage.py:308-323) returns allocator-block slack such as (block.address + live, block.address + block.size) — 512-byte-class torch alignment — and PersistentTensorArena.unused_ranges() returns tensors' alignment padding (ignition/preparation/persistent.py:135-141), while the granule is cuMemGetAllocationGranularity (core_storage.py:502-504), MiB-class. So raw ≠ trimmed for essentially every hole.
Two consequences, in opposite directions:
- Values in a retained edge are still counted. The trimmed piece covers
[raw_start, aligned_start)and[aligned_stop, raw_stop). A candidate there resolves to a live exported allocation, yetcandidate()returns early on the raw inactive hit before the interval lookup, so it is reported as resolving to no active allocation. The summary wording was improved this round ("resolve to no active recorded allocation (gap or inactive range)",reachability.rs:236-246), so the literal false claim is gone — but those values still inflate the occurrence and distinct-address totals the PR asks the reader to interpret, and they are the totals the author quotes in the description. - Values inside a genuinely freed sub-granule block are not reported at all. The author's reason for keeping raw
request.inactive(comment of 2026-11-28 19:09, item 5) is that trimming inward would let a pointer into a freed sub-granule block retain the segment. That is true but only half the trade:live_piecesalready retains that block as part of the enclosing piece, so the segment is retained either way, and the value silently drops out of the diagnostic — the!self.candidate(pointer)?guard atreachability.rs:298is false, so nothing is pushed. A stale workspace freed at sub-granule granularity inside an otherwise live segment is exactly the #266 shape (a cuBLAS split-K workspace), and it is invisible in the report.
No test can catch the second half: freed_interval_boundaries_report_kernel_candidates_without_retaining_storage (reachability.rs:1072-1133) uses hole edges 1024 and 3072, both granule-aligned, so raw and trimmed geometries coincide there.
Why it matters: the deliverable is the counts and the ten examples (charter line 11, "Bring real evidence"; line 35, "What gets merged"). With one geometry driving retention and another driving reporting, neither the totals nor the silence can be attributed to a cause.
Fix: derive the report predicate from the exported geometry and keep conservative retention separate. Concretely, keep candidate() as is (it is byte-equivalent to main's pointer(), main reachability.rs:118-131, so retention behaviour is preserved) but compute candidacy for reporting from self.intervals alone — report when the value falls in no interval — and pass a second, granule-trimmed inactive list from capture_rank for that purpose (or pass the granule and trim inside candidate()'s report branch). Add a test with a hole whose raw edge is not a multiple of the allocation alignment, asserting (a) a value in the retained unaligned edge is not reported and (b) a value in a freed sub-granule block inside a retained piece is reported.
2. heliopause/src/export/reachability.rs:300 — argument-relative alignment (base + offset) is untested across numeric spans
The filter is (base + offset).is_multiple_of(8). base is the chunk's byte offset within the argument blob, and blob() restarts the scan at each numeric-exclusion span with start as usize (reachability.rs:184-190), so the predicate is argument-relative — the right frame, since blob.data is one parameter's bytes (encode_kernel, capture.rs:836-850) and a pointer field sits at a multiple of 8 from the parameter start. #266's offsets (256, 0) survive. The code reads correctly.
But only blob()'s single-span path is tested. unaligned_straddling_window_is_not_reported_while_aligned_stale_pointer_is (reachability.rs:1046-1069) passes numeric: vec![], so it never enters the base arithmetic; kernel_argument_candidate_offset_counts_from_the_argument_start (:805-822) does check offset 16 across one exclusion but contains no unaligned window, so it would pass unchanged with base = 0. The author's counts now depend on this filter (175,329→22,618 and 170,544→19,417 between heads), so a silent regression here changes the diagnostic's headline numbers with no failing test.
Fix: two cheap CPU-only cases — (1) two numeric spans with the stale pointer in the second span at an argument offset that is a multiple of 8 but not a multiple of 8 relative to that span's start (so base = 0 would wrongly drop it); (2) an argument whose 8-byte fields start at offset 8/16 with a straddling window at offset 4/12, mirroring the real argument 0, offset 4 case from the 2026-11-19 evidence. Only a test settles this.
Nits
reachability.rs:76,:247-263— example selection is first-encountered, so one kernel family can fill all ten slots.UNRESOLVED_EXAMPLES = 10and examples are taken in first-insertorder. The author's rerun shows the effect: all ten printed examples on both ranks came from mHC / dense-GEMM kernels, and the author had to ask whether one example per kernel symbol is wanted (2026-11-28 19:09).docs/TODO.txtalready records "establish whether per-kernel example grouping is needed". Not a defect — the report is explicitly non-blocking and bounded — but the printed evidence is about one kernel family per rank and should not be read as a survey.reachability.rs:50,:67—UnresolvedCandidateandSitearepub(crate)only somod testscan construct aSiteand inspectfirst. A#[cfg(test)]constructor would keepgraphas&strin a struct only ever built internally.reachability.rs:236-246— the summary line cannot say whether a value is a stale pointer or a numeric constant. Accurate as worded, and the PR description states it honestly; #266's case and W4A8 MoE constants are indistinguishable by construction. No change requested.
Verified correct — recorded so a later round need not re-derive it
- Retention semantics are unchanged from
main.candidate()is the single classifier and byte-equivalent tomain'spointer(): inactive hit →Ok(false)with no reference; interval hit →reference+Ok(true); elseOk(false)(reachability.rs:156-170).in_free_blockis deleted. - Only kernel-argument scans report.
scan_spans,contents,opaque_contentspassmisses: None(reachability.rs:396-412); testallocation_contents_still_tolerate_gap_candidates(:1036-1043) covers it. - Symbol lookup index chain holds.
Site.function = node.function as usize(:346) indexeskernels;wire::Kernel.functionis that same kernels index (encode_kernel,capture.rs:889);functionsis pushed once per kernel infor kernel in &mut kernelsorder (capture.rs:3001-3083);graph()errors when the index is out of range (reachability.rs:322-324), sofunctions.get(...)never falls back to "unknown" in production. Testunresolved_report_names_the_kernel_and_its_symbol(:842-874) pins this with a decoy function at position 1. - The
blobsmiss cache cannot drift.candidate()depends only onintervals/inactive, both immutable afternew, so caching the first site's misses per(data, numeric)and replaying them per site is sound. - Numeric exclusions unchanged, subtracted before scanning (
:177-190), offsets still argument-relative across split spans (test:805-822). - Hidden-count arithmetic fixed and tested: distinct and occurrence totals are separate (
:264-279; tests:876-987, including omitting the line when nothing is hidden at:907-942). - stderr is safe to print (
capture.rs:3219-3223): no parent parses export stderr; the Python side reads a JSON summary string (ignition/preparation/runtime_core.py:140-145), and per-rank stderr is already used for progress rows (capture.rs:2864-2868). is_multiple_ofis stable and withinrust-version = "1.88"(heliopause/Cargo.toml:6(not opened)).- Docs landed: the diagnostic is documented in
docs/runtime-core-design.md(reachability paragraph and rank-stderr paragraph, +8/−2), and the pending measurement indocs/TODO.txt(+6).cargo test --locked --manifest-path heliopause/Cargo.toml (not opened) --libwas reported passing (205 passed, 4 ignored).
Open questions / what I could not settle
- W4A8 MoE behaviour is unverified in practice. The Vision-Exp export's ten examples are all mHC kernels, so the description's claim that W4A8 MoE arguments produce numeric noise (and not false pointers) rests on the design, not on printed output. Only a W4A8 MoE export would settle it.
- #266's four-GPU DeepSeek V4.1 failure is not reproduced — neither the author (three RTX PRO 6000s) nor I could run it. Whether the trimmed-geometry fix above would surface the cuBLASLt split-K argument is untested; the shape argument is from
live_piecesand the granule arithmetic, not from a captured graph. - Values outside the recorded envelope and stale values that alias live storage are not detected, by construction (
floor/ceilingatreachability.rs:292-293) — outside this change's scope, noted so the diagnostic is not over-read. docs/TODO.txtanddocs/runtime-core-design.mdprose correctness was read but not audited against the code beyond the reachability paragraph; other lenses cover docs style.