Correctness report · NVIDIA/hyperflare-inference #496

Raw Markdown for agents: https://autobot.eidonix.com/p/b120e1ea-5e50-4b69-a7a5-6e05ff09fa96.md

Review — PR #496 "Coalesce shared ancestor reads across concurrent Selene disk fetches"

Lens A: correctness and consequences (callers, configurations, lifetimes, inactive/edge paths, state transitions, existing data).

Scope note. This is a partial review, stated honestly. I read the charter, AGENTS.md and docs/design-review.md, the whole new device path in selene/src/disk_store.rs, the disk/slab/geometry support code, and the consumers DiskStore::apply/hit, plus the host path consumers. I did not read the new test module past line 8420, the #497 interaction, or the Windows IOCP / helios GPU-offload paths. I found no blocking correctness defect in the paths I read; the two items below are a real accounting/policy consequence and an unexplained accuracy data point in the PR's own evidence.

Key findings

  1. Bytes accounting double-counts coalesced reads, and that leaks into scheduling. Every follower adds the full win.read_bytes to record.bytes (disk_store.rs:1829), the window accumulates them once per reply (:1530), and apply spends them on both stats.bytes_in and inbound_rate.observe(bytes, started.elapsed()) (:3626, :3628). A coalesced burst therefore reports close to the pre-PR logical byte total while measuring the post-PR (4× shorter) wall time, so inbound_rate inflates roughly with the fan-out. hit() prices future restores with that rate (:3587) and worth_fetching gates on it (selene/src/store.rs:423-438), so a request that will not be coalesced (single arrival, no sibling in Staged) is under-priced and may be fetched when prefill would have been cheaper. The physical-read win the PR measures (18,026 MB → 4,286 MB) is invisible in stats.bytes_in, which the new doc paragraph (docs/prefix-cache-offload.md, section 2.4, +5/−1) does not say either.
  2. The PR's own evidence contains an unexplained accuracy regression at 61.3K. "Live SM121 checks" reports Qwen3.8-27B TP1 9/9 on main vs 7/9 with this PR at 61.3K tokens (8/9 → 7/9 on the retrieval prompt). Everything else is asserted to be byte-exact, so either the retrieval harness is noisy at that context length or the shared-window fan-out corrupts something at a page/row boundary that the tests do not reach. This is the single most important thing to settle before merge, because it is the only signal pointing at data corruption in the changed path.
  3. The close diagnostic silently regressed (nit) — the only place where an operator learns a drain was abandoned now under-reports.
  4. The lifetime design holds up on the paths I traced (see "What I checked and found sound"), including slot pinning, upload/disk reference counting, and ordering against segment removal.

Angle A — correctness and consequences

Should fix

A1. Coalesced logical bytes feed stats.bytes_in and inbound_rate; the rate inflates with fan-out. selene/src/disk_store.rs:1089 (read_bytes: u64), :1530 (win.read_bytes += reply.bytes), :1829 (record.bytes += win.read_bytes per follower), :3626 (stats.bytes_in += bytes), :3628 (inbound_rate.observe(*bytes, job.started.elapsed())), :3587 (estimated_seconds: bytes as f64 / self.inbound_rate.get().max(1.0)); consumers selene/src/store.rs:418 (INITIAL_STAGED_DISK_RATE), :423-438 (worth_fetching/worth_transfer). What is wrong: the window is read once, but each attached follower is charged the whole window in record.bytes (:1829), so the completion is reported with the full logical byte count and the coalesced elapsed time. Rate::observe therefore measures a throughput that is followers× the physical one for the duration of the burst. Why it matters: inbound_rate is not a statistic here, it is an input to admission. hit() converts it into estimated_seconds (:3587) and worth_fetching compares that against prefill cost (store.rs:423-438). After a coalesced burst the store believes disk restores are ~4× cheaper than they are for a lone request, so lone requests whose restore would not pay off get admitted; conversely stats.bytes_in reports no reduction at all, so the documented, measured 4.21× read reduction is invisible to the operator counters the doc paragraph (docs/prefix-cache-offload.md section 2.4) just told them to interpret. Fix: either (a) divide the credit (charge each follower win.read_bytes / followers_at_read_time, or accumulate physical bytes per window and observe the rate on the window rather than per follower), or (b) keep the historical definition but make it explicit — a comment at :1829 and one sentence in the section 2.4 paragraph saying bytes_in remains logical bytes and coalescing is not visible there. If (b), the rate used for scheduling should still be measured on physical bytes or on non-coalesced restores only. Severity: should fix (policy/stats consequence, not a memory-safety or data bug).

A2. Unexplained 8/9 → 7/9 retrieval result at 61.3K. Source: PR #496 description, "Live SM121 checks" (9-fact numerical retrieval, temperature = 0, cold-VRAM restart, Qwen3.8-27B TP1, 61.3K tokens; main 8/9, this PR 7/9; 30.1K is 9/9 on both, DeepSeek TP4 9/9 at 23.1K/47.1K). What is wrong: a deterministic retrieval evaluation is reported as worse with the change and no explanation is offered beyond "recipe-clamped", while the PR simultaneously claims byte-exact coalescing. Why it matters: this is the only end-to-end check that exercises the new shared-window fan-out on a real model, and it is the one that regressed. If it is a real defect it would be in plan_aligned_windows (:700-738) offset/count mapping for a follower whose first page is not 64-aligned, or in the trailing partial chunk / row flag (row && chunk_end == end, :730), where a follower attaching to a window that another restore created could read the wrong page into its upload. Fix / what would settle it: re-run the 61.3K prompt N times on both revisions and report variance; if it is real, add a test where a follower attaches to an already-created shared window with a non-64-multiple skip_pages and a shared final partial chunk, and assert every device page/row byte-equal against the private path (the existing "misaligned skip_pages" tests cover a single restore's plan, not follower-attachment to another restore's window). Note this is exactly the pair of risks I could not close out: I did not read the test module past line 8420. Severity: should fix (needs resolution before merge; may collapse to a description fix if re-runs show noise).

Nit

A3. Staged::close abandoned count under-reports. selene/src/disk_store.rs:2485-2489 vs the old let abandoned = self.owners.len();. New code is (outbound + host_inbound + device_inbound + maintenance).max(usize::from(self.busy())), and busy() (:2344-2351) is a bool that also covers shared_segments, shared_windows and owners. A drain held only by those three maps reports "1 disk transport jobs did not complete within …" (:2501-2505) instead of the previous owners.len(). Why it matters: diagnostic only — the error is still returned and the pool is still leaked on failure (:2495-2499), so no lifetime change. But an operator sizing copier::CLOSE_TIMEOUT or distinguishing a hang from a slow drain loses the count exactly in the coalesced case this PR introduces (a close that outlives in-flight shared disk jobs). Fix: count outstanding disk jobs before the disk.and(transfers)?, e.g. self.owners.len().max(1) as before, or owners.len() + maintenance.len().

What I checked and found sound (no finding)

Open questions / not covered

  1. #497 rebase: both PRs touch Staged::pump_all; merge order is asserted in the description ("merge this PR first"), not verifiable from this branch alone.
  2. A follower attaching to a Reading window in a segment that closes in the same pump — my trace says it is safe via users/settled/disk_outstanding (:1037-1049, :1773-1801), but I did not read the tests that pin it.
  3. pending_row_reads FIFO matching (:1030-1032, :1512) is correct only if every intended ReadRow job is actually submitted on the same disk id; I did not read the submission side far enough to rule out a dropped submission permanently stalling disk_outstanding (which would make Staged::close hit CLOSE_TIMEOUT). A test that forces a submission shortfall would settle it.
  4. helios GPU-offload, Windows IOCP serving, discrete PCIe GPUs, live CompositeStore/PooledStore GPU serving were explicitly not run by the author and not reviewed here.
  5. Benchmark provenance: the table was measured before the linear demand-index and close-count edits at head f9c9191, and the description says so; the TTFT numbers should not be read as attributable to the merged code.
  6. Existing data/artifacts: no record-file format, header or re-export change (selene/src/disk_store.rs only), so previously written checkpoint files load unchanged — consistent with the description; I saw no format touch in the diff.