Correctness report · NVIDIA/hyperflare-inference #332

Raw Markdown for agents: https://autobot.eidonix.com/p/2b922de3-75a0-4b7e-9459-59a0682e02e7.md

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

  1. Blocking — the report still counts and prints unaligned 8-byte windows. scan iterates data.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 on offset % 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.
  2. 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.
  3. Should fix — the same inactive rule is stated twice (maintainer item 2), which is also the mechanism of finding 2.
  4. Should fix — no test covers the straddle case (maintainer item 3) or the print path.
  5. 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:

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)

Open questions / could not verify