#1 [high] PR 332 structure: files and behaviour
PR 332 (mark-yong), base main, head c3cc87e, 2 files +434/−30: heliopause/src/export/capture.rs, heliopause/src/export/reachability.rs.
reachability.rs (head):
- 45-55 UnresolvedCandidate {graph,node,function,argument,offset}; 57-61 UnresolvedEntry {first, order, occurrences}; 66-71 Site<'a>; 75 UNRESOLVED_EXAMPLES=10.
- 84 blobs: HashMap<(Vec,Vec<(usize,usize)>), Vec<(usize,u64)>> (was HashSet); 85 unresolved: HashMap<u64,UnresolvedEntry>.
- 131-145 candidate(): inactive check first (returns Ok(true) without referencing), then interval check → reference + Ok(true), else Ok(false). Same semantics as old pointer().
- 147-188 blob(): first site scans once and caches misses (offset,address); every site (cache hit or miss) replays misses into
unresolved, order = map len at first insert. - 190-246 unresolved_count (sum occurrences), unresolved_unique_addresses (map len), unresolved_report(functions): summary line, up to 10 examples sorted by entry.order, then "… N more occurrences not shown" where hidden = occurrences − min(distinct,10).
- 248-274 scan(data, base, misses): windows(8); if pointer in [floor,ceiling): in_free_block = inactive contains pointer;
if (!self.candidate(pointer)? || in_free_block) && let Some(misses) = ... { misses.push((base+offset,pointer)) }. - 276-362 graph(name, nodes, kernels): node_index enumerate; Site{graph:name,node:node_index,function:node.function as usize,argument:position}.
- 364-380 scan_spans passes base 0 / misses None; contents() and opaque_contents() pass misses None (never report).
capture.rs:
- 3102 reach.graph(&graph.name,&nodes,&kernels)
- 3074 Reachability::new(&allocations,&request.numeric,&request.inactive,&roots) — raw, unaligned request.inactive
- 1408-1423 live_pieces() trims allocations to granule-aligned holes for memory=="device" && sizing.is_none() && !peer && snapshot_spans.is_none()
- 3137-3141 if reach.unresolved_count()>0 → eprintln!("export: rank {}: {line}", request.rank) for reach.unresolved_report(&output.index.ranks[0].functions)
- functions pushed per kernel in order (2986-2992); wire::Kernel.function = kernels index (encode_kernel 889) ⇒ functions.get(candidate.function) aligns.
- request.inactive from ignition/preparation/runtime_core.py:296 storage.unused_ranges(); core_storage.py:303-318 (packed weight arena inactive ranges, torch segment inactive blocks/slack, persistent arena unused ranges).
#2 [high] Blocking: report still counts unaligned 8-byte windows (maintainer item 1 unaddressed)
heliopause/src/export/reachability.rs:248-274 scan iterates data.windows(8).enumerate() (line 259) and pushes (base + offset, pointer) for every byte offset; there is no offset % 8 == 0 (or argument-relative count-offset) filter anywhere in the head commit c3cc87e. blob (147-169) then reports each of those as a candidate.
Consequence: within one argument, every byte offset produces an 8-byte window, and all but the naturally aligned ones straddle two CUDA parameter fields, so they are not pointer-shaped values of any field. The counts in the PR description (rank 0: 175,329 occurrences / 2,646 distinct addresses) are therefore dominated by straddling window values, and the printed first examples are exactly such windows: the description's first example is argument 0, offset 4: 0x100000000800. The tests confirm unaligned offsets are reported, e.g. kernel_argument_candidate_offset_counts_from_the_argument_start asserts offset 16 and unresolved_examples_are_capped... asserts offsets 0,8,16…; nothing asserts that a straddling window at offset 4 is excluded.
This is exactly maintainer yatesdr's 2026-11-20 blocking review item 1 ("Keep retention as it is, report only argument-relative offsets divisible by 8"), which the head does not implement. Related missing test: their item 3 (a live pointer followed by a small integer in one argument, asserting the straddling window is not reported).
Fix: in scan, only record a miss when (base + offset) % 8 == 0 (or step data.chunks_exact at aligned offsets while keeping the per-byte retention scan), and add the straddle test. Keep retention iteration over all windows so the pre-existing conservative retention is unchanged.
Cited: PR #332 review 2026-11-20 (yatesdr), reachability.rs:259-269, 147-169, tests at 749-796.
#3 [high] Should fix: in_free_block uses raw inactive ranges while intervals are granule-trimmed
heliopause/src/export/reachability.rs:261-271 computes in_free_block from self.inactive, the raw merged ranges from CaptureRequest::inactive (Reachability::new line 107). But self.intervals, which decide what is a live allocation, are built from the allocations after live_pieces trims each inactive range at allocation.alignment boundaries (capture.rs:1196-1240: 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()).
So whenever an inactive range edge is not granule-aligned, the trimmed live piece still covers [raw_start, aligned_start) and [aligned_stop, raw_stop). A kernel-argument value there resolves to a live recorded allocation (it is inside an interval), and candidate() would return true for it — but candidate() returns early on the raw inactive hit (reachability.rs:131-135) before the interval lookup, and scan's in_free_block is also true, so line 266's (!candidate || in_free_block) reports it. The summary line then asserts the value falls "outside every live recorded allocation", which is false for those values, and the export cannot tell them apart from #266's real gap pointer.
Granularity comes from cuMemGetAllocationGranularity (ignition/preparation/core_storage.py:93 via the allocator snapshot, virtual_storage.py:28-36), i.e. 2 MiB-class granule on the supported devices, while storage.unused_ranges() ranges come from torch block addresses/sizes and packing padding (core_storage.py:303-318, packed_weights.py:100-105, alignment 512). Unaligned (non-granule-multiple) hole edges are thus the normal case, and each hole contributes up to a granule of live-but-reported addresses on each side, on every graph argument — a large false-positive source that also inflates occurrence and distinct-address counts.
Fix: derive in_free_block from the same geometry as intervals, i.e. treat a value as a candidate only when it falls in no self.intervals entry (the interval lookup already covers granule-trimmed holes), and delete the separate raw-inactive check, which also answers the maintainer's "one rule, one place" item. A test with a non-granule-aligned inactive range asserting that the value in the retained edge is not reported would settle it.
Cited: reachability.rs:131-145, 259-271; capture.rs:1196-1240, 1408-1423; ignition/preparation/core_storage.py:93, 303-318; tests reachability.rs:902-966 use granule-aligned holes (256-aligned offsets) so they do not cover this case.
#4 [medium] Should fix: duplicate inactive rule, untested print path, hidden-count wording; and unaffected-behaviour notes
-
Duplicated rule (should fix, maintainer item 2):
candidate()treats an inactive range as a hit (reachability.rs:131-135) andscanrepeats the lookup asin_free_block(262-265). Two copies of one rule; combined with the raw-vs-trimmed mismatch in note 3 this is the mechanism of the false positives. State the rule once, fromself.intervalsonly. -
No test for the print path: the only caller is capture.rs:3137-3141 (
eprintln!("export: rank {}: {line}", request.rank)), which needs a CUDA context, sounresolved_report's wiring, the rank label and thefunctionsargument beingoutput.index.ranks[0].functionsare unverified by any test. The alignment ofwire::Kernel.function(capture.rs:889 sets it to the kernels index) with thefunctionspush order (capture.rs:2986-2992) is the only reason symbol lookup is right; a test or an assertion would settle it. Only a test can settle this. -
Nit in wording:
unresolved_report(reachability.rs:238-243) computeshidden = occurrences - examples.len().min(10), i.e. it mixes occurrences and distinct addresses: with 2,646 distinct addresses and 175,329 occurrences the line says "… 175,319 more occurrences not shown", while what is omitted is 2,636 distinct addresses as well. Say which quantity is hidden ("… 2,636 more distinct addresses, 175,319 occurrences not shown"). -
Nit:
UnresolvedCandidate/Site/UnresolvedEntryarepub(crate)only so the test module can inspect them (reachability.rs:45-71);candidate()returningboolplus the separatein_free_blockpredicate makes the "hit" and "report" notions distinct in a way that invites the drift in note 3. Consider a singleclassify()returning hit/report/gap. -
Prose (medium): the summary line says the values fall "outside every live recorded allocation" (reachability.rs:212-214) which, per note 3, is not always true, and the PR description's example ("argument 0, offset 4") is a straddling window that cannot be a pointer (note 2). Under the repo prose skill and AGENTS.md "Bring real evidence", the counts in the description should be re-run after the alignment and trimmed-hole fixes before they are presented as evidence about noise from W4A8 MoE kernels.
-
What is clean (no finding): retention semantics are unchanged —
candidate()returns exactly what the oldpointer()returned (inactive hit = no reference, interval hit = reference, else miss),contents/opaque_contents/allocation scans passmisses: Noneso they never report (reachability.rs:364-380, 421-441), andblobscaching now caches only the first site's miss list, which is correct because the miss set depends only on (data, numeric) while retention still runs per site. Numeric exclusions still subtract before scanning (147-165).unresolved_reportis bounded at 10 examples, memory growth is bounded by distinct addresses per rank. Non-retention of inactive storage is preserved and tested (reachability.rs:929-966). Ranks other than 0 print with a rank label to stderr, which is not JSON-framed output anywhere I found (transfer.rs stdout protocol unaffected), so it does not corrupt a machine-readable stream.