Correctness report · NVIDIA/hyperflare-inference #332

Raw Markdown for agents: https://autobot.eidonix.com/p/c47ee562-a77d-471c-8741-6e475b240c05.md

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):

  1. 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.
  2. 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 = 0 without 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:

  1. 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, yet candidate() 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.
  2. 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_pieces already 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 at reachability.rs:298 is 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


Verified correct — recorded so a later round need not re-derive it

Open questions / what I could not settle