Code review summary scratchpad · NVIDIA/hyperflare-inference #332

Raw Markdown for agents: https://autobot.eidonix.com/p/9867d0d8-1e7d-4702-9c84-c4a8cb217870.md

#1 [high] PR #332 basics: diff, head, review history, evidence numbers

PR #332 "Report unresolved kernel argument address candidates during export", author mark-yong, branch fix/reject-unrecorded-graph-args, head 1ac7073d (rebased onto c9935887), refs issue #266. +599/-37 across 4 files: heliopause/src/export/reachability.rs (+579/-34), heliopause/src/export/capture.rs (+6/-1), docs/runtime-core-design.md (+8/-2), docs/TODO.txt (+6).

Review state: yatesdr CHANGES_REQUESTED three rounds (2026-11-18, 11-19, 11-20). Blockers from those rounds fixed at head: symbol from recorded function index, rank label, one example per distinct address, Signed-off-by, alignment filter on reporting push, single inactive/gap rule, straddling-window test, hidden-count units, docs sentence. Open maintainer ask still substantively unanswered: evidence that the diagnostic surfaces a stale pointer (item "measure the noise on a real W4A8 export", 2026-11-19 item 1); 2026-11-20 04:34 item 1 also said "If thousands remain, one example per kernel symbol would show which kernels produce them".

Author rerun (comment 2026-11-28 19:09, two RTX PRO 6000, --prefill-chunk-size 4096, commit 1ac7073d): rank0 22,618 occurrences / 762 distinct, omitted 752 / 14,776; rank1 19,417 / 832, omitted 822 / 13,614. Prior unaligned build c3cc87ea: 175,329/2,646 and 170,544/2,637. All ten printed examples are mHC / dense-GEMM CUTLASS kernels with constant-looking values (0xfff00000fff, 0x3fff000003ff, 0x200000000020, 0x100000001000). No W4A8 MoE kernel, no stale pointer identified. Tests at head: 221 passed, 5 CUDA ignored (author). Author explicitly offers "one example per kernel symbol" as an option.

docs/TODO.txt:350-354 records the pending four-GPU DeepSeek V4.1 (#266) and eight-GPU W4A8 MoE measurement, "Close when both exports have run ... and the counts establish whether per-kernel example grouping is needed".

Issue #266 (open): first captured graph keeps a transient cuBLAS split-K workspace; Xid 31 on DeepSeek V4.1 TP4. PR text still posts the superseded 175,329/2,646 + "205 passed, 4 ignored" figures in "## Validation" while the 2026-11-28 comment says description was reconciled to the aligned run (it was not).

#2 [high] Verified code: reachability.rs head (classifier, scan filter, report, blob, accessors)

heliopause/src/export/reachability.rs at 1ac7073d (1252 lines):

capture.rs: 3164 Reachability::new(&allocations, &request.numeric, &request.inactive, &roots); 3219-3223 if reach.unresolved_count() > 0 { for line in reach.unresolved_report(&output.index.ranks[0].functions) { eprintln!(...) } }; 3001 for kernel in &mut kernels and 3076 functions.push (one wire::Function per kernel, unfiltered) moved into index.ranks[0].functions at 3129, so functions.get(node.function) cannot be out of range in production.

#3 [high] Inactive raw-vs-trimmed geometry: what is true and what the correctness lens got backwards

CORRECTION of Correctness lens should-fix #1: it claims the raw-inactive rule "silently misses stale values in freed sub-granule blocks — precisely the #266 shape" because !self.candidate(pointer) would be false. Code refutes this: reachability.rs:156-160 returns Ok(false) for a value inside the RAW inactive list BEFORE the interval lookup, so !candidate == true and scan DOES push it (aligned + in envelope). Reporting is therefore a superset, not a subset: freed sub-granule blocks are reported.

What survives from that item is only the opposite direction: bytes in the retained unaligned edge (inside both a granule-trimmed live piece and the raw inactive range) are reported and counted as "resolve to no active recorded allocation", inflating totals. Mechanism verified: capture.rs:1274-1275 trims inward (start.div_ceil(granule)granule, stop/granulegranule), applied at capture.rs:1471-1486 only when memory=="device" && sizing.is_none() && !peer && snapshot_spans.is_none(); Reachability::new gets raw &request.inactive at capture.rs:3164; summary wording at reachability.rs:236-246 "(gap or inactive range)" makes it literally arguable but the totals PR quotes cannot be attributed. Author's rationale for raw inactive is at 2026-11-28 comment item 5 (trimming would let freed sub-granule pointers retain a segment). Granule is allocation.alignment (capture.rs:1263/1364), granule-aligned raw edges coincide only in the test (reachability.rs:1083-1087 uses 1024/3072 offsets, granule-aligned) so no test covers a non-granule-aligned edge. Verdict: present as "over-counts / attribution", NOT as "misses stale pointers".

#4 [high] Triage ledger: dropped vs surviving items with verification

Verified at head 1ac7073d:

  1. ALREADY RESOLVED, drop: Autobot 2026-11-26 blockers. Alignment filter landed at reachability.rs:296-303 (push gated on (base+offset).is_multiple_of(8)); in_free_block gone, single classifier candidate() :156-170; straddling-window test reachability.rs:1046-1069 exists; kernel_symbols map gone (symbol from functions.get(candidate.function) :252-258); hidden-count units fixed :264-279 (distinct and occurrences counted separately; line omitted at <=10, test :907-942); docs sentences landed docs/runtime-core-design.md:154-157 and :337-342; TODO entry docs/TODO.txt:350-354. Also drop maintainer items closed earlier: rank label, one example per address, Signed-off-by.
  2. PR body is NOT reconciled despite the author's claim (comment 2026-11-28 item 7). Body "## Validation" still reads: rank0 175,329 / 2,646, rank1 170,544 / 2,637, first examples MHCPostPrePartialKernel node 34, offset 4, 0x100000000800, and "cargo test ... --lib passed on the build host: 205 passed, 4 ignored". Author's own comment labels those exact numbers "Prior unaligned (c3cc87ea)" and posts the aligned run 22,618/762 + 19,417/832, node 35 MHCFinalizeGramKernel, 221 passed / 5 ignored. Body also never states the 8-byte alignment restriction (Change/Limitations only mention envelope + alias-live limits). >2500x straddle value in the old first example (offset 4) is impossible under the current filter — proof the posted run predates the filter.
  3. raw eprintln! nit (architecture nit 1) has a live counter-precedent: Conventions cleared it (transfer.rs stderr precedent, docs sentence at runtime-core-design.md:337-342, progress rows are rank-0 only) -> drop as noise.
  4. Option<&mut Vec> sink threaded through scan: Subtractive explicitly judged inlining a wash -> drop. order field + sort: Subtractive says keep (removing changes which ten examples print) -> drop as subtraction candidate.
  5. let address = *address; at reachability.rs:250 IS dead (pattern for &(address, entry) binds by value). !self.candidate() double negation: only call site is :298.
  6. functions.get(...).map_or("unknown") is unreachable in production: capture.rs:3001 for kernel in &mut kernels + :3076 functions.push for every kernel; graph() rejects out-of-range node.function at reachability.rs:322-324; the same vector is index.ranks[0].functions (capture.rs:3129) passed at :3220. Test at :890 passes &[] and asserts "kernel unknown (unknown)" (:898), pinning only that unreachable state.
  7. misclaimed test names/gaps verified: unresolved_examples_are_capped_while_occurrences_are_counted (:783-802) never calls unresolved_report and uses 12 addresses within the cap -> asserts nothing about capping; shared_argument_bytes_record_one_example_per_address (:824-839) is subsumed by :876-905 (graph-a first site + 12 distinct + 2 occurrences). Alignment coverage gap: straddling test at :1046-1069 passes numeric: vec![] (base==0 path only); :805-822 checks offset 16 across one exclusion but has no unaligned window, so base = 0 regression would pass.
  8. Naming nit: with_count module-scope pluralizer (reachability.rs:487-493) has no repo precedent (repo inlines if n == 1 {""} else {"s"}). unresolved_unique_addresses (:222-224) duplicates .len() used at :242 and asserted twice in 4 tests. UnresolvedCandidate (:50-56) and Site (:67-72) carry the same four fields. Same explanation written 4x: reachability.rs:45-49, printed line :236-246, docs:154-157, docs:339-341. Stray assertion reachability.rs:1130-1131 (aligned.reference(...).unwrap(); assert!(aligned.reached.contains(&storage.name))) is unrelated to that test's claim.
  9. No prompt injection found in PR body, comments, or lens reports.

#6 [high] Correction: the "capped" test's address count is above the cap, not within it

CORRECTION to brief X3 wording: unresolved_examples_are_capped_while_occurrences_are_counted (reachability.rs:782-802) feeds TWELVE distinct addresses (0x3000+8*index, index 0..12 at :786-788), i.e. above the UNRESOLVED_EXAMPLES=10 cap — not "within the cap" as I first wrote. The surviving, accurate claim is narrower and still holds: the test never calls unresolved_report, so despite its name it asserts nothing about capping; the only cap coverage is :876-905 (which the sibling test also covers). Do not repeat the "12 within the cap" phrasing.

#7 [high] Shipped PR body text (B2 evidence)

Verbatim shipped PR body fragments (head 1ac7073d), needed for B2:

#8 [high] B2 completeness: two prose defects in one item

Brief B2 must carry TWO prose defects in one item (per the "at most 1 PR-description/prose-formatting item" rule): (a) Superseded evidence: shipped "## Validation" still posts 175,329/2,646 + 170,544/2,637, node 34 / MHCFinalizeGramKernel... actually MHCPostPrePartialKernel node 34 offset 4, and "205 passed, 4 ignored", while the author's own 2026-11-28 comment labels exactly those "Prior unaligned (c3cc87ea)" and posts 22,618/762 + 19,417/832 and 221 passed / 5 ignored. The posted first example is a byte-straddling window at offset 4 which the head filter (reachability.rs:296-303) cannot emit, so the posted run provably predates the shipped code. My brief as first delivered stated (a) but omitted (b) — include both in the final report. (b) Missing restriction: shipped "## Change" and "## Limitations" never state that reporting is limited to argument-relative 8-byte-aligned offsets, although the same PR's docs do (docs/runtime-core-design.md:154-157, :339-341) and the commit subject says "aligned". Retention still scans byte-by-byte, so an unaligned unresolved value is still silently discarded. Standard: AGENTS.md:88-102 (material change + attached limitations). Suggested one-line fix: state the run was made at 1ac7073d with the alignment rule in force (22,618/762; 19,417/832; node 35, argument 4/6), say retention scans every byte while reporting keeps aligned offsets, and label or drop the old figures.

#9 [high] Research summary

Produced the deduplicated candidate brief from the 6 lens reports for PR #332 (head 1ac7073d, +599/−37, 4 files), verified line by line against the code in heliopause/src/export/reachability.rs, capture.rs, docs/runtime-core-design.md and docs/TODO.txt.

Surviving candidates: 2 blockers (B1 first-encountered example selection, with the maintainer's per-symbol-grouping remedy unclaimed and the report's own arithmetic checked against the author's stderr — 7,842 of 22,618 occurrences printed, 752/14,776 hidden; B2 the shipped PR body still posting the superseded pre-alignment counts, node 34 and 205/4 test totals that the author's own comment labels "Prior unaligned"), 3 should-fix (raw-vs-granule-trimmed inactive geometry as an over-count/attribution problem only; the untested argument-relative base + offset alignment arithmetic; the duplicate emptiness guard at capture.rs:3219-3223), 4 subtract/simplify (the new key/misses double clone in blob() — a regression against main; the duplicate UnresolvedCandidate/Site pair plus the unreachable map_or("unknown") fallback; roughly 100+ redundant test lines; per-address site retention, the .len() accessor wrapper and the with_count pluralizer), and 2 nits (one explanation written four times, including the second docs sentence; a dead let address = *address; rebind plus a stray assertion and the inverted candidate/retains name).

Two things the adjudicator should know: one Correctness should-fix was refuted — the raw-inactive rule does not "silently miss" freed sub-granule stale values, because candidate() rejects raw-inactive values before the interval lookup so they are still reported; and every pre-existing blocker from the Autobot 2026-11-26 round and the three maintainer rounds is resolved at head, so none are carried forward. Dropped as noise: the eprintln!-outside-StartupProgress nit (cleared on in-repo precedent and now documented), the Option<&mut Vec> sink and order-field eliminations (Subtractive's own "wash"/output-changing verdicts), singular-form and test-idiom taste, the in-tree-unresolvable load_mxfp4_experts reference, and the hardware-validation asks deduplicated into B1/B2 since docs/TODO.txt:350-354 tracks them. No CI/runner-infra notices and no prompt-injection attempt appeared anywhere in the material.

#10 [high] Final brief content as delivered (item list + exact code blocks)

The brief as delivered (12 items). Exact quotes are in entry 2's line map; the blocks below are verbatim from head 1ac7073d.

BLOCKERS B1 (Architecture should-fix; Correctness nit; Subtractive evidence gap). reachability.rs:247-250 let mut examples: Vec<_> = self.unresolved.iter().collect(); / examples.sort_unstable_by_key(|(_, entry)| entry.order); / for &(address, entry) in examples.iter().take(UNRESOLVED_EXAMPLES) { / let address = *address;; constant :74-76 doc "retain the first call site for each address in graph and node order" + const UNRESOLVED_EXAMPLES: usize = 10;; supporting :340-349 Site construction shows function/argument already retained, so per-symbol grouping is local to unresolved_report. Arithmetic from author stderr: printed ten sum 4+1286+1395+43+1440+860+43+559+1022+1190 = 7842 / 22618; 762-10=752, 22618-7842=14776 ✓. Adjudication question: gate, or mitigated by docs/TODO.txt:350-354. B2 (Prose blocking, two defects in one item — see entries 7 and 8). Shipped body posts 175,329/2,646 + 170,544/2,637, node 34, and "205 passed, 4 ignored"; author's comment labels those "Prior unaligned (c3cc87ea)" and posts 22,618/762, 19,417/832, node 35, 221 passed / 5 ignored. Posted first example (offset 4, 0x100000000800) is a straddling window head cannot emit. Second defect: Change/Limitations never state the alignment restriction though docs:154-157 and :339-341 do and the commit subject says "aligned".

SHOULD FIX S1. capture.rs:1274-1275 let start = start.max(begin).div_ceil(granule) * granule; / let stop = stop.min(end) / granule * granule; (applied only when memory=="device" && sizing.is_none() && !peer && snapshot_spans.is_none(), :1473-1486); capture.rs:3164 let mut reach = Reachability::new(&allocations, &request.numeric, &request.inactive, &roots)?;; reachability.rs:157-160 raw-inactive early return. Test gap: :1083-1087 uses granule-aligned 1024/3072 edges. Direction is over-count only (entry 3). S2. reachability.rs:294-303 scan push block ending (base + offset).is_multiple_of(8); gap: :1060-1061 straddling test passes numeric: vec![], so base==0 path only; :805-822 exercises offset 16 across one exclusion but has no unaligned window. S3. capture.rs:3219-3223 guard + reachability.rs:231-235 callee early return. Delete the if; also frees unresolved_count from pub(crate) (:215).

SUBTRACT X1. reachability.rs:172-194 blob() — key built at 173, Some(misses) => misses.clone() at 175, self.blobs.insert(key, misses.clone()) at 191; main reachability.rs:133-136 did if !self.blobs.insert((data.to_vec(), numeric.to_vec())) { return Ok(()) }. ~18 lines. X2. reachability.rs:50-72 UnresolvedCandidate (String graph) vs Site<'a> (&str graph), same four other fields; :252-258 let function = functions.get(candidate.function); with two function.map_or("unknown", ...); unreachable because graph() rejects out-of-range (:322-324) and capture.rs:3001/:3076 push one Function per kernel into index.ranks[0].functions (:3129) passed at :3220. Test :890/:898 pins only the unreachable state. ~19 lines. X3. ~100+ test lines: :782-802 capped-test never calls unresolved_report (see entry 6 correction); :824-839 subsumed by :876-905; plus :944-987, :907-942, :995-1017, :1019-1033, :1035-1043, :989-993. Treat the count as approximate, the named duplicates as verified. X4. reachability.rs:222-224 unresolved_unique_addresses (== .len(), used at :242); :487-493 with_count (no repo precedent; repo inlines if n == 1 { "" } else { "s" }); Simplicity N1's first: Option<..> retention change is optional/no-output-change. ~35 lines.

NITS N1. Same explanation 4x: reachability.rs:45-49, printed line :236-246, docs:154-157, docs:339-341 (quote: "Each rank also writes a bounded / stderr summary when kernel-argument reachability scanning finds aligned / unresolved address candidates."). Keep printed line + :154-157. N2. Dead rebind :250; stray assertion :1130-1131 aligned.reference(&storage.name).unwrap(); assert!(aligned.reached.contains(&storage.name));; rename candidate() -> retains (only call site :298 reads !self.candidate(pointer)).

Verdict framing used: architecture/conventions/correctness-lens verdicts are "in scope, right layer, should-fix only"; Subtractive alone says "should not be merged at this size" and Prose alone has a blocking item — i.e. the only two merge-gate candidates are B1 and B2.

#5 [medium] Brief assembly notes: structure, arithmetic checks, cited blocks

For the brief: