Final review report · NVIDIA/hyperflare-inference #647

Raw Markdown for agents: https://autobot.eidonix.com/p/b482ee42-3e66-4829-818c-ccd29a70c1ca.md

Recommendation: Changes Requested

Most of the core fixes in this PR are technically solid—the externalized core-signing rewrite (protection.rs/conversion.rs/conversion/edit.rs), stream-ordered granule zeroing (core_storage.py), CUmemAccessDesc ABI fix (peer_storage.py), multi-host ForwardCache relative paths (aot.py), sharded autotune reconciliation (#631, tuning.py), AOT storage region clamping and multi-storage mutation tracking (compilation.py), RankSupervisor lock decoupling (processes.rs/python.rs), and eos::ReadRing::flush lifetime accounting all hold up under direct inspection. However, verification uncovered two concrete blockers—a silent weight-corruption bug in weight_reuse.rs::map_groups whenever an omitted view shares bytes with a retained view (such as tied embed_tokens/lm_head weights under --reuse-weights --no-mtp), and an unmocked torch.cuda.current_stream call in DeviceRegion.grow that breaks the 12 CPU-mocked tests in tests/preparation/test_persistent.py on GPU-less runners (alongside red CI on head e029dc8 and test evidence reported only on origin/main 8da73911).

Merge Risk

Level: Medium

Walkthrough

Pre-merge Checks

Blockers

  1. Silent weight omission when an omitted view shares bytes with a retained view (heliopause/src/export/weight_reuse.rs:576-620).
    • map_groups builds omitted_by_allocation from every old in prior.views whose name is absent from current.views, then subtracts those ranges directly from every prior weight initializer (subtract_ranges(old_start, old_end, excluded) at line 617) without excluding ranges covered by retained views (prior.views ∩ current.views).
    • Whenever an omitted view aliases or overlaps a retained view's bytes—for example, tied embed_tokens or lm_head weights shared between target and MTP draft layers under --reuse-weights --no-mtp, or interleaved strided views sharing an allocation—the retained target bytes are silently subtracted out. If retained_pieces becomes empty (line 618), the initializer is skipped altogether; neither map_groups nor resolve_weight_payload checks that every non-empty span in catalog.groups is covered by result, so those retained target weights are silently left zeroed in the exported core.
    • Fix: Collect retained_by_allocation (merged intervals of old in &prior.views where current_names.contains(old.name.as_str()) && old.nbytes > 0) and subtract retained_by_allocation from omitted_by_allocation before clipping previous.initializers. Add a regression test in weight_reuse.rs where an omitted draft view aliases a retained target view's offset/range, asserting the retained target initializer is preserved intact.
  2. Unmocked torch.cuda.current_stream in DeviceRegion.grow breaks CPU-only test suite (ignition/preparation/core_storage.py:619-621, tests/preparation/test_persistent.py:40-72).
    • DeviceRegion.grow now unconditionally executes stream = torch.cuda.current_stream(device).cuda_stream. The packed_storage fixture in tests/preparation/test_persistent.py:48-72 (used by 12 unit tests designed to run on CPU with a fake Memory driver stub) does not monkeypatch torch.cuda.current_stream, so on any GPU-less CI runner torch.cuda.current_stream(0) fails immediately before cuMemsetD8Async is reached. Additionally, Memory.call (test_persistent.py:40-42) only asserts len(args) == 4 without verifying that the stream pointer was actually passed through.
    • Fix: In packed_storage (tests/preparation/test_persistent.py:48-72), monkeypatch torch.cuda.current_stream to return a sentinel SimpleNamespace(cuda_stream=0x1234) (asserting the passed device == storage.device), and assert args[3].value == 0x1234 in Memory.call. Re-run the test suite and confirm CI passes on the updated PR head.

Should Fix

  1. Re-run verification on PR head and satisfy charter #210 evidence for the performance changes (heliopause/src/export/{capture.rs,io.rs,transfer.rs}).
    • The PR description reports test runs gathered on origin/main (8da73911) rather than the PR head (e029dc8), and explicitly notes that the export-pipeline performance changes (capture.rs Pass-1 numeric skip, io.rs DirectRing reuse, transfer.rs 8 MiB batching and payload hashing skip) were not benchmarked end-to-end on GPUs. In addition, capture.rs:3420-3425 has no unit test covering the cache_scan branch (request.weight_payload.is_some() && request.options.cache.is_some() without --reuse-weights).
    • Fix: Either (a) add a unit/integration test for the cache_scan Pass-1 skip path and provide before/after export timing measurements on the PR head, or (b) split the unbenchmarked export-pipeline performance work into a follow-up PR with measurements so the urgent correctness fixes (sign_rewritten_envelope, stream-0 zeroing, #631 multi-host tuning/AOT, CUmemAccessDesc ABI, ReadRing::flush, compilation.py) can land promptly.

Subtract / Simplify

  1. Delete duplicate merge_runs in heliopause/src/export/weight_payload.rs:560-583, 1230-1235: With partial-overlap merging (start <= last.1), merge_runs is identical to heliopause/src/export/reachability.rs:12-24 (merge_ranges, which also sorts and drops empty spans). Replace lines 561–562 (runs.sort_unstable(); return Ok(merge_runs(runs));) with return Ok(super::reachability::merge_ranges(runs)); and delete merge_runs and its redundant test.
  2. Delete dead Linux transfer_batch in heliopause/src/export/io.rs:914-921: Every remaining Linux caller of transfer_batch (read_bounced at io.rs:648 and read_at at io.rs:679) passes a 1-element slice, making IoUring::new + transfer_batch_on_ring at io.rs:919-920 unreachable on Linux. Call a single-job helper (transfer_single_direct on Linux, transfer_batch on Windows) from those two sites and remove Linux transfer_batch.
  3. Deduplicate stop_flag and metrics resolution in heliopause/src/export/binding.rs:355-455: Both blocks repeat the same object extraction, non-empty allocation validation, default-0 offset parsing, resolve_mapped_host, alignment check, and JSON re-insertion. Extracting one helper (resolve_host_ref) eliminates ~35 lines.
  4. Delete test-only window_host_base wrapper in heliopause/src/allocator.rs:269-272: It has zero production callers (only tests at allocator.rs:1414-1433); point those assertions directly at window_host_layout(..., 1, None).

Nits

Dropped on verification