Skip to content

Fix externalized core signing, stream-0 weight race, export I/O, and multi-host tuning - #647

Merged
lukealonso merged 1 commit into
mainfrom
close-export-128mib-combine-stream0
Nov 30, 2026
Merged

lukealonso merged 1 commit into
mainfrom
close-export-128mib-combine-stream0

Conversation

@lukealonso

@lukealonso lukealonso commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Why these changes are needed

Preparation, export, and core-signing workflows contain defects across five areas:

  1. Signed envelopes above 128 MiB fail in combine and promote: export::publish externalizes signed metadata bodies larger than 128 MiB into EXTERNAL_BODY_PREFIX tensors and clears inline signed.body and rank.body bytes. helios/src/core/conversion.rs::inject_dependency_descriptors decoded those empty inline byte slices directly and re-signed with EnvelopeBuilder::sign instead of sign_envelope, causing combine and promote to fail deterministically on externalized cores.
  2. Legacy stream-0 zeroing races with non-blocking weight copies: ignition/preparation/core_storage.py::DeviceRegion.grow zeroed newly mapped 2 MiB virtual memory granules with cuMemsetD8_v2 on legacy stream 0 without synchronizing against non-blocking PyTorch streams copying persistent weights (ignition/preparation/persistent.py), allowing zero-fills to overwrite live weights.
  3. Cached export performs redundant D2H copies, hashing, ring setup, FD duplication, and rejects --reuse-weights --no-mtp:
    • heliopause/src/export/capture.rs downloaded all of request.numeric over PCIe in Pass 1 even when cache_scan was active and the cache pass downloads weights separately.
    • heliopause/src/export/io.rs created a fresh IoUring per 4 MiB chunk in single-job reads/writes, transfer.rs pre-hashed and stream-hashed content-addressed payload objects verified against PayloadId on install, weight_payload.rs::merge_runs dropped partial overlaps while Claimed sorted a vector per piece (O(V² log V)), and core.rs::convert_prepared scanned payload views linearly.
    • binding.rs::NativeExportStage retained duplicate file-descriptor leases across ranks (risking EMFILE) and held its directory mutex across filesystem checks under the Python GIL; python.rs::NativeRankSupervisor held an outer mutex without detaching the GIL during finish_shutdown/abort.
    • weight_reuse.rs::map_groups rejected reused speculative weight cores when --no-mtp omitted draft weight views.
    • eos/src/ioring.rs::ReadRing::flush returned on a partial-submit error before adding submitted operations to self.in_flight, allowing Drop to free DMA buffers while kernel reads remained active.
  4. Multi-host preparation and AOT lowering fail on distinct roots, sharded autotune, and multi-storage dependencies (Fixes Multi-host autotune: rank selection divergence recurs on every retry (2042/2078/2078 across 3 consecutive attempts, warm caches included); only --autotune-effort off succeeds #631):
  5. ABI, device-selection, and 32-bit bound bugs in native preparation helpers:
    • ignition/preparation/peer_storage.py::_Access declared flags as c_uint64 (16 bytes) instead of c_uint32 (12 bytes matching CUmemAccessDesc).
    • ignition/preparation/kv_codec.py queried GPU SM architecture from device 0 instead of the rank's storage device, and kv_codec_gpu.cu used a 30-entry gf2_pow table (broken at >= 1 GiB half-lengths), 32-bit packet-plan offsets (wrapping at >= 4 GiB), and fixed __shared__[64] batch limits.
    • heliopause/src/export/binding.rs did not resolve optional PersistentWorker.metrics buffers, and heliopause/src/allocator.rs placed host windows at a fixed 12 TiB HOST_BASE without checking virtual_address_bits(device) for narrow WDDM GPU VA spaces.

What changed

  • Externalized signed-envelope rewriting (helios/src/core/{protection.rs,conversion.rs,conversion/edit.rs}):
    • Before: conversion/edit.rs re-signed envelopes inline while conversion.rs::inject_dependency_descriptors decoded signed.body / rank.body directly and called builder.sign(key).
    • After: Extracted protection::sign_rewritten_envelope and sign_rewritten_envelope_with_limit to refresh deployment body_digests, read rank bodies through read_rank_body(rank, body_store), and sign via EnvelopeBuilder::sign_envelope(key). Both conversion/edit.rs and conversion.rs::inject_dependency_descriptors use this helper; conversion.rs reads bodies through metadata.body_store(), strips stale EXTERNAL_BODY_PREFIX tensors when rewriting the container, writes signed.external_bodies, and drops metadata before fs::rename.
  • Stream-ordered granule zeroing, ctypes ABI, and GPU KV codec (ignition/preparation/{core_storage.py,peer_storage.py,kv_codec.py,runtime_core.py,kv_codec_gpu.cu}):
    • Before: DeviceRegion.grow called synchronous stream-0 cuMemsetD8_v2; peer_storage._Access.flags was c_uint64; compile_gpu_codec_cubin queried device 0; kv_codec_gpu.cu used gf2_pow[30][32], uint32_t plan totals, and __shared__[64].
    • After: DeviceRegion.grow calls cuMemsetD8Async on torch.cuda.current_stream(device).cuda_stream and adopts host_extent from flare_core_snapshot; _Access.flags is c_uint32; runtime_core.py passes device=storage.device to compile_gpu_codec_cubin; kv_codec_gpu.cu expands gf2_pow to [64][32], widens packet-plan accumulators to uint64_t and the *low_base_ptr + lane_byte_offs[lane_id] offset expression to size_t, and uses caller-supplied batch arrays instead of __shared__[64].
  • Heliopause export pipeline, allocator, supervisor, and eos::ReadRing (heliopause/src/{allocator.rs,processes.rs,python.rs}, heliopause/src/export/{capture.rs,io.rs,transfer.rs,weight_payload.rs,core.rs,binding.rs,weight_reuse.rs}, eos/src/ioring.rs):
    • Before: Pass 1 copied request.numeric over PCIe even when cache_scan was active; io.rs created a new IoUring per single-job read/write; transfer.rs hashed cached payload files twice; weight_payload.rs missed partial overlaps in merge_runs and sorted Claimed on every insert; convert_prepared scanned views linearly; NativeExportStage stored duplicate leases and held locks under the GIL; NativeRankSupervisor serialized abort behind finish_shutdown without detaching the GIL; map_groups rejected prior initializers covering omitted views; PersistentWorker ignored metrics; allocator.rs used a fixed 12 TiB HOST_BASE; ReadRing::flush returned errors before accounting submitted into in_flight.
    • After: capture.rs skips request.numeric D2H in Pass 1 via pass_one_skip_numeric when cache_scan is true while still pointer-scanning non-numeric bytes and preserving data_spans; io.rs reuses one DirectRing per scan/write worker and uses transfer_single_direct (pread/pwrite) for single-job Linux I/O; transfer.rs skips redundant payload-object SHA-256 pre-hashing/stream-hashing (relying on PayloadId verification at install and per-frame HMAC-SHA256) and batches reads up to super::io::BLOCK (8 MiB, split into 4 MiB BLOCK_BYTES wire frames); weight_payload.rs reuses reachability::merge_ranges and switches Claimed to a BTreeMap<u64, u64>, and convert_prepared uses a HashMap; NativeExportStage deduplicates leases by PayloadId and releases its lock/GIL around filesystem checks; RankSupervisor isolates its join handle behind its own Mutex and NativeRankSupervisor detaches the GIL; weight_reuse.rs::map_groups subtracts only exclusively omitted byte ranges ((prior.views \ current.views) \ retained_by_allocation) from prior initializers so tied/aliased retained views are preserved intact; binding.rs resolves and validates stop_flag and metrics through a shared resolve_host_ref helper; allocator.rs computes window_host_layout against virtual_address_bits(device) and exports host_extent; eos::ReadRing::flush updates queued and in_flight before check(status)? and returns InvalidData if submitted > queued.
  • Multi-host ForwardCache, sharded autotune reconciliation, and AOT lowering (ignition/preparation/{aot.py,tuning.py,compilation.py}):
    • Before: ForwardCache._prepare_ranks sent absolute paths across hosts; sharded multi-host tuning skipped share_selections and reconcile_selections; _storage_regions aligned before grouping without clamping to storage.nbytes(); _reads_across_mutations cleared all pending storages on the first mutated input.
    • After: ForwardCache._prepare_ranks exchanges cache-root-relative POSIX paths and _share_artifacts(..., root=self.root) resolves and bounds them to each host's cache root; tuning.py shares rank 0's cached selections before sharded tuning and runs reconcile_selections with configure_tuning_shard(0, (0,)) afterward (restoring shard_rank in finally); _storage_regions groups raw overlaps before per-group clamped alignment and _lower_storage slices clamped multi-dtype uint8 bases before aten.view.dtype; _reads_across_mutations removes only pending & mutations[node].

Claimed benefit and result

  • Verified correctness fixes (covered by unit/contract tests): Externalized signed envelopes succeed through inject_dependency_descriptors and promote; DeviceRegion.grow passes the active CUDA stream to cuMemsetD8Async; peer_storage._Access matches the 12-byte CUmemAccessDesc ABI; capture.rs cache_scan skips numeric D2H in Pass 1 while preserving data_spans; PersistentWorker.metrics, omitted-draft and aliased-tied-view --reuse-weights --no-mtp, Claimed, window_host_layout VA-width checks, relative-path ForwardCache sharing, multi-host sharded autotune cache sharing and reconciliation (Multi-host autotune: rank selection divergence recurs on every retry (2042/2078/2078 across 3 consecutive attempts, warm caches included); only --autotune-effort off succeeds #631), per-group clamped _storage_regions, and multi-storage _reads_across_mutations behave as specified; kv_codec_gpu.cu compiles cleanly with nvcc and zero global/constant ELF symbols.
  • Expected performance and lifetime improvements (not benchmarked end-to-end on GPUs here): Cached exports avoid the duplicate Pass-1 full-weight PCIe D2H copy, per-chunk IoUring creation, redundant payload SHA-256 passes, quadratic view/range scans, and cross-rank payload FD duplication; eos::ReadRing prevents freeing kernel-owned DMA buffers after partial submit errors.

Supporting evidence and limitations

All checks below ran on PR head 5b700f57 (rebased onto origin/main 555db719):

  • eos (cargo test --locked --release --manifest-path eos/Cargo.toml): 2 passed, 0 failed.
  • heliopause (cargo test --locked --release --manifest-path heliopause/Cargo.toml --lib): 221 passed, 0 failed, 6 ignored (CUDA), including cache_scan_skips_numeric_ranges_in_pass_one_without_dropping_data_spans, map_groups_skips_omitted_draft_weights_and_clips_coalesced_initializers, map_groups_preserves_retained_initializer_when_omitted_view_aliases_it, claimed_tracks_disjoint_and_overlapping_pieces_in_order, persistent_worker_resolves_metrics_buffer_and_validates_alignment, and explicit_device_windows_are_validated.
  • helios (cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib -- core::): 502 passed, 0 failed, 12 ignored (including inject_dependency_descriptors_and_promote_handle_externalized_bodies).
  • flare-cli (cargo test --locked --release --manifest-path flare-cli/Cargo.toml -- --test-threads=1): 227 passed (201 unit, 26 integration), 0 failed, 3 ignored.
  • Python CPU tests:
    • With CUDA_VISIBLE_DEVICES="" against the paired public-b12x FlashInfer checkout: tests/preparation/{test_persistent,test_tuning_shards,test_peer_storage_groups}.py passed 33/33 with zero NVIDIA driver calls (verifying stream handle forwarding in cuMemsetD8Async).
    • Targeted preparation suites (test_persistent.py, test_tuning_shards.py, test_forward_artifact_sharing.py, test_peer_storage_groups.py, test_core_storage.py, test_storage_lifetimes.py, test_core_boundary.py, test_persistent_worker.py): 294 passed, 1 skipped (Windows-only layout test), 0 failed.
    • tests/cli: 133 passed, 0 failed against .venv.
  • CUDA compilation (FLARE_RUN_CUDA_TESTS=1 pytest tests/test_kv_codec.py): 4 passed, 0 failed (nvcc compilation + cubin ELF symbol check).
  • Previously verified on parent e029dc84 (unchanged crates): selene (549 passed), selene-manager (426 passed, 1 ignored), flare (237 unit + 8 integration passed, 4 ignored), helios --skip frontend:: (1,658 passed, 46 ignored, 1 failing test requiring gated FLARE_TEST_TEMPLATE_DIR), and FLARE_RUN_CUDA_TESTS=1 test_storage_lifetimes_cuda.py + test_packed_weights_cuda.py.

Material limitations and unrun checks:

  • Live VRAM-allocating GPU tests (tests/preparation/test_virtual_storage_cuda.py, live kv_codec_gpu.cu kernel execution, end-to-end GPU export/serving, and multi-host live export) could not run because all 16 host GPUs were occupied (~95–96 GiB / 97.9 GiB in use by an external workload).
  • Windows runtime execution for WDDM HOST_BASE placement and eos::ReadRing Windows IoRing paths was not exercised on Linux.

Discord: lukealonso

@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 647.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot flare-autobot added area:preparation Ignition checkpoint loading, tuning, compilation, capture, and export. bug Something isn't working performance Performance, latency, throughput, or memory-efficiency investigation or improvement. priority:P2 Normal bug priority: workflow failure or diagnosis with narrower impact or an available workaround. triage:review Proposed change needs code review; this does not imply merge readiness. labels Nov 30, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The core correctness fixes (externalized envelope signing, stream-ordered VMM zeroing, CUmemAccessDesc ABI, multi-host ForwardCache/autotune, AOT storage clamping, RankSupervisor lock decoupling, ReadRing::flush) hold up under direct inspection, but two blockers remain: silent weight omission in weight_reuse.rs when an omitted view shares bytes with a retained one, and an unmocked torch.cuda.current_stream call that breaks the CPU-only test_persistent.py suite.

  • Blockers: 2 · Should fix: 1 · Subtract/Simplify: 4 · Nits: 5
Walkthrough
  • Externalized signed-envelope rewriting (helios/src/core/{protection.rs,conversion.rs,conversion/edit.rs}): Extracts sign_rewritten_envelope[_with_limit] to refresh deployment body_digests, read rank bodies through body_store, and sign via sign_envelope; updates inject_dependency_descriptors and conversion/edit.rs to rewrite flare.body.* external bodies and drop metadata before fs::rename.
  • Stream-ordered VMM zeroing, ctypes ABI, and GPU KV codec (ignition/preparation/{core_storage.py,peer_storage.py,kv_codec.py,runtime_core.py,kv_codec_gpu.cu}): Switches DeviceRegion.grow to cuMemsetD8Async on torch.cuda.current_stream(device).cuda_stream, adopts host_extent from flare_core_snapshot, fixes _Access.flags to c_uint32 (12-byte CUmemAccessDesc), compiles KV codec cubins for storage.device, widens gf2_pow to [64][32] and 64-bit packet-plan accumulators, and removes the __shared__[64] batch cap.
  • Heliopause export pipeline, allocator, supervisor, and eos::ReadRing (heliopause/src/{allocator.rs,processes.rs,python.rs}, heliopause/src/export/{binding,capture,core,io,transfer,weight_payload,weight_reuse}.rs, eos/src/ioring.rs): Skips request.numeric D2H in Pass 1 when cache_scan is active; reuses one DirectRing per scan/write worker and uses direct pread/pwrite for single jobs; removes redundant payload container hashing and batches transfer reads to 8 MiB; switches Claimed to BTreeMap and convert_prepared to HashMap; deduplicates NativeExportStage payload leases; isolates RankSupervisor's join handle and detaches the GIL; resolves/validates PersistentWorker.metrics; relaxes map_groups for omitted views; computes WDDM-aware window_host_layout; and updates ReadRing::flush to account submitted before returning errors.
  • Multi-host preparation and AOT lowering (ignition/preparation/{aot.py,tuning.py,compilation.py}, tests/preparation/*.py): Exchanges cache-root-relative POSIX paths in ForwardCache._prepare_ranks with path-traversal guards in _resolve_shared_path; runs share_selections and reconcile_selections (with temporary (0, (0,)) shard override) for sharded multi-host tuning (Multi-host autotune: rank selection divergence recurs on every retry (2042/2078/2078 across 3 consecutive attempts, warm caches included); only --autotune-effort off succeeds #631); groups raw overlaps before per-group clamped alignment in _storage_regions, slices multi-dtype bases before aten.view.dtype, and clears only pending & mutations[node] in _reads_across_mutations.
Merge Risk: Medium · up to e029dc8
  • Silent weight corruption on --reuse-weights --no-mtp with shared/tied weights: heliopause/src/export/weight_reuse.rs:576-620 subtracts all byte ranges of prior.views \ current.views from prior initializers without protecting overlapping current.views ranges, which can silently drop initializers for retained target weights and leave them zero-initialized at runtime.
  • Broad multi-subsystem blast radius (27 files across helios, heliopause, eos, and ignition): Touches core signing, cached export capture/I/O/transfer, weight reuse, multi-host tuning/AOT sharing, CUDA VMM zeroing, and GPU KV codec kernels in one PR with red CI on head e029dc8 and no live GPU/WDDM/multi-host execution evidence.
  • Unbenchmarked hot-path export I/O changes: Pass-1 numeric skip (capture.rs), DirectRing reuse (io.rs), 8 MiB read batching and payload SHA-256 elision (transfer.rs) modify the export pipeline without end-to-end GPU measurements on the PR head.
Pre-merge checks: ✅ 3 passed · ⚠️ 2 warnings

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

…multi-host tuning

Why these changes are needed

Preparation, export, and core-signing workflows contain defects across five areas:

1. Signed envelopes above 128 MiB fail in `combine` and `promote`: `export::publish` externalizes signed metadata bodies larger than 128 MiB into `EXTERNAL_BODY_PREFIX` tensors and clears inline `signed.body` and `rank.body` bytes. `helios/src/core/conversion.rs::inject_dependency_descriptors` decoded those empty inline byte slices directly and re-signed with `EnvelopeBuilder::sign` instead of `sign_envelope`, causing `combine` and `promote` to fail deterministically on externalized cores.
2. Legacy stream-0 zeroing races with non-blocking weight copies: `ignition/preparation/core_storage.py::DeviceRegion.grow` zeroed newly mapped 2 MiB virtual memory granules with `cuMemsetD8_v2` on legacy stream 0 without synchronizing against non-blocking PyTorch streams copying persistent weights (`ignition/preparation/persistent.py`), allowing zero-fills to overwrite live weights.
3. Cached export performs redundant D2H copies, hashing, ring setup, FD duplication, and rejects `--reuse-weights --no-mtp`:
   - `heliopause/src/export/capture.rs` downloaded all of `request.numeric` over PCIe in Pass 1 even when `cache_scan` was active and the cache pass downloads weights separately.
   - `heliopause/src/export/io.rs` created a fresh `IoUring` per 4 MiB chunk in single-job reads/writes, `transfer.rs` pre-hashed and stream-hashed content-addressed payload objects verified against `PayloadId` on install, `weight_payload.rs::merge_runs` dropped partial overlaps while `Claimed` sorted a vector per piece (O(V^2 log V)), and `core.rs::convert_prepared` scanned payload views linearly.
   - `binding.rs::NativeExportStage` retained duplicate file-descriptor leases across ranks (risking `EMFILE`) and held its directory mutex across filesystem checks under the Python GIL; `python.rs::NativeRankSupervisor` held an outer mutex without detaching the GIL during `finish_shutdown`/`abort`.
   - `weight_reuse.rs::map_groups` rejected reused speculative weight cores when `--no-mtp` omitted draft weight views.
   - `eos/src/ioring.rs::ReadRing::flush` returned on a partial-submit error before adding `submitted` operations to `self.in_flight`, allowing `Drop` to free DMA buffers while kernel reads remained active.
4. Multi-host preparation and AOT lowering fail on distinct roots, sharded autotune, and multi-storage dependencies:
   - `ignition/preparation/aot.py::ForwardCache._prepare_ranks` exchanged host-local absolute paths across nodes instead of cache-root-relative paths.
   - `ignition/preparation/tuning.py` skipped pre-tuning cache sharing and post-tuning `reconcile_selections` when multi-host tuning was sharded, leaving ranks with divergent kernel selections across retries (issue #631).
   - `ignition/preparation/compilation.py::_storage_regions` aligned spans before grouping and could extend past `storage.nbytes()`, while `_reads_across_mutations` cleared all pending storage dependencies on the first mutated storage instead of only the mutated subset.
5. ABI, device-selection, and 32-bit bound bugs in native preparation helpers:
   - `ignition/preparation/peer_storage.py::_Access` declared `flags` as `c_uint64` (16 bytes) instead of `c_uint32` (12 bytes matching `CUmemAccessDesc`).
   - `ignition/preparation/kv_codec.py` queried GPU SM architecture from device 0 instead of the rank's storage device, and `kv_codec_gpu.cu` used a 30-entry `gf2_pow` table (broken at >= 1 GiB half-lengths), 32-bit packet-plan offsets (wrapping at >= 4 GiB), and fixed `__shared__[64]` batch limits.
   - `heliopause/src/export/binding.rs` did not resolve optional `PersistentWorker.metrics` buffers, and `heliopause/src/allocator.rs` placed host windows at a fixed 12 TiB `HOST_BASE` without checking `virtual_address_bits(device)` for narrow WDDM GPU VA spaces.

What changed

- Externalized signed-envelope rewriting (`helios/src/core/{protection.rs,conversion.rs,conversion/edit.rs}`):
  - Before: `conversion/edit.rs` re-signed envelopes inline while `conversion.rs::inject_dependency_descriptors` decoded `signed.body` / `rank.body` directly and called `builder.sign(key)`.
  - After: Extracted `protection::sign_rewritten_envelope` and `sign_rewritten_envelope_with_limit` to refresh deployment `body_digest`s, read rank bodies through `read_rank_body(rank, body_store)`, and sign with `EnvelopeBuilder::sign_envelope(key)`. Both `conversion/edit.rs` and `conversion.rs::inject_dependency_descriptors` use this helper; `conversion.rs` reads bodies through `metadata.body_store()`, strips stale `EXTERNAL_BODY_PREFIX` tensors on container rewrite, writes `signed.external_bodies`, and drops `metadata` before `fs::rename`.
- Stream-ordered granule zeroing, ctypes ABI, and GPU KV codec (`ignition/preparation/{core_storage.py,peer_storage.py,kv_codec.py,runtime_core.py,kv_codec_gpu.cu}`):
  - Before: `DeviceRegion.grow` called synchronous stream-0 `cuMemsetD8_v2`; `peer_storage._Access.flags` was `c_uint64`; `compile_gpu_codec_cubin` queried device 0; `kv_codec_gpu.cu` used `gf2_pow[30][32]`, `uint32_t` plan totals, and `__shared__[64]`.
  - After: `DeviceRegion.grow` calls `cuMemsetD8Async` on `torch.cuda.current_stream(device).cuda_stream` and adopts `host_extent` from `flare_core_snapshot`; `_Access.flags` is `c_uint32`; `runtime_core.py` passes `device=storage.device` to `compile_gpu_codec_cubin`; `kv_codec_gpu.cu` expands `gf2_pow` to `[64][32]`, widens plan accumulators to `uint64_t` and the `*low_base_ptr + lane_byte_offs[lane_id]` offset expression to `size_t`, and uses caller-supplied batch arrays instead of `__shared__[64]`.
- Heliopause export pipeline, allocator, supervisor, and `eos::ReadRing` (`heliopause/src/{allocator.rs,processes.rs,python.rs}`, `heliopause/src/export/{capture.rs,io.rs,transfer.rs,weight_payload.rs,core.rs,binding.rs,weight_reuse.rs}`, `eos/src/ioring.rs`):
  - Before: Pass 1 copied `request.numeric` over PCIe even when `cache_scan` was active; `io.rs` created a new `IoUring` per single-job read/write; `transfer.rs` hashed cached payload files twice; `weight_payload.rs` missed partial overlaps in `merge_runs` and sorted `Claimed` on every insert; `convert_prepared` scanned views linearly; `NativeExportStage` stored duplicate leases and held locks under the GIL; `NativeRankSupervisor` serialized `abort` behind `finish_shutdown` without detaching the GIL; `map_groups` rejected prior initializers covering omitted views; `PersistentWorker` ignored `metrics`; `allocator.rs` used a fixed 12 TiB `HOST_BASE`; `ReadRing::flush` returned errors before accounting `submitted` into `in_flight`.
  - After: `capture.rs` skips `request.numeric` D2H in Pass 1 via `pass_one_skip_numeric` when `cache_scan` is true while still pointer-scanning non-numeric bytes and preserving `data_spans`; `io.rs` reuses one `DirectRing` per scan/write worker and uses `transfer_single_direct` (`pread`/`pwrite`) for single-job Linux I/O; `transfer.rs` skips redundant payload-object SHA-256 pre-hashing/stream-hashing (relying on `PayloadId` verification at install and per-frame HMAC-SHA256) and batches reads up to `super::io::BLOCK` (8 MiB, split into 4 MiB `BLOCK_BYTES` wire frames); `weight_payload.rs` reuses `reachability::merge_ranges` and switches `Claimed` to a `BTreeMap<u64, u64>`, and `convert_prepared` uses a `HashMap`; `NativeExportStage` deduplicates leases by `PayloadId` and releases its lock/GIL around filesystem checks; `RankSupervisor` isolates its join handle behind its own `Mutex` and `NativeRankSupervisor` detaches the GIL; `weight_reuse.rs::map_groups` subtracts only exclusively omitted byte ranges (`(prior.views \ current.views) \ retained_by_allocation`) from prior initializers so tied/aliased retained views are preserved intact; `binding.rs` resolves and validates `stop_flag` and `metrics` through a shared `resolve_host_ref` helper; `allocator.rs` computes `window_host_layout` against `virtual_address_bits(device)` and exports `host_extent`; `eos::ReadRing::flush` updates `queued` and `in_flight` before `check(status)?` and returns `InvalidData` if `submitted > queued`.
- Multi-host `ForwardCache`, sharded autotune reconciliation, and AOT lowering (`ignition/preparation/{aot.py,tuning.py,compilation.py}`):
  - Before: `ForwardCache._prepare_ranks` sent absolute paths across hosts; sharded multi-host tuning skipped `share_selections` and `reconcile_selections`; `_storage_regions` aligned before grouping without clamping to `storage.nbytes()`; `_reads_across_mutations` cleared all pending storages on the first mutated input.
  - After: `ForwardCache._prepare_ranks` exchanges cache-root-relative POSIX paths and `_share_artifacts(..., root=self.root)` resolves and bounds them to each host's cache root; `tuning.py` shares rank 0's cached selections before sharded tuning and runs `reconcile_selections` with `configure_tuning_shard(0, (0,))` afterward (restoring `shard_rank` in `finally`); `_storage_regions` groups raw overlaps before per-group clamped alignment and `_lower_storage` slices clamped multi-dtype `uint8` bases before `aten.view.dtype`; `_reads_across_mutations` removes only `pending & mutations[node]`.

Claimed benefit and result

- Verified fixes (exercised by unit and contract tests): externalized signed envelopes succeed through `inject_dependency_descriptors` and `promote`; `DeviceRegion.grow` passes the active CUDA stream to `cuMemsetD8Async`; `peer_storage._Access` matches the 12-byte `CUmemAccessDesc` ABI; `capture.rs` `cache_scan` skips numeric D2H in Pass 1 while preserving `data_spans`; `PersistentWorker.metrics`, omitted-draft and aliased-tied-view `--reuse-weights --no-mtp`, `Claimed`, `window_host_layout` VA-width checks, relative-path `ForwardCache` sharing, multi-host sharded autotune cache sharing and reconciliation (issue #631), per-group clamped `_storage_regions`, and multi-storage `_reads_across_mutations` behave as specified; `kv_codec_gpu.cu` compiles cleanly with `nvcc` and zero global/constant ELF symbols.
- Expected performance and lifetime improvements (not benchmarked end-to-end on GPUs here): cached exports avoid the duplicate Pass-1 full-weight PCIe D2H copy, per-chunk `IoUring` creation, redundant payload SHA-256 passes, quadratic view/range scans, and cross-rank payload FD duplication; `eos::ReadRing` avoids freeing kernel-owned DMA buffers after partial submit errors.

Supporting evidence and limitations

All commands below ran on this rebased PR commit (parent `origin/main` `555db719`):

- `eos` (`cargo test --locked --release`): 2 passed, 0 failed.
- `heliopause` (`cargo test --locked --release --lib` with `PYO3_PYTHON` and Python `LIBDIR`): 221 passed, 0 failed, 6 ignored (CUDA), including `cache_scan_skips_numeric_ranges_in_pass_one_without_dropping_data_spans`, `map_groups_skips_omitted_draft_weights_and_clips_coalesced_initializers`, `map_groups_preserves_retained_initializer_when_omitted_view_aliases_it`, `claimed_tracks_disjoint_and_overlapping_pieces_in_order`, `persistent_worker_resolves_metrics_buffer_and_validates_alignment`, and `explicit_device_windows_are_validated`.
- `helios` (`cargo test --locked --release --features runtime-core,server --lib -- core::`): 502 passed, 0 failed, 12 ignored (including `inject_dependency_descriptors_and_promote_handle_externalized_bodies`).
- `flare-cli` (`cargo test --locked --release -- --test-threads=1`): 227 passed (201 unit, 26 integration), 0 failed, 3 ignored.
- Python CPU tests with `CUDA_VISIBLE_DEVICES=""` against the paired public-`b12x` FlashInfer checkout: `test_persistent.py`, `test_tuning_shards.py`, and `test_peer_storage_groups.py` passed 33/33 with zero NVIDIA driver calls; `tests/preparation/{test_persistent,test_tuning_shards,test_forward_artifact_sharing,test_peer_storage_groups,test_core_storage,test_storage_lifetimes,test_core_boundary,test_persistent_worker}.py` passed 294 passed, 1 skipped (Windows-only), 0 failed; `tests/cli` passed 133/133 against `.venv`.
- CUDA compilation (`FLARE_RUN_CUDA_TESTS=1 pytest tests/test_kv_codec.py`): 4 passed, 0 failed (`nvcc` compilation + cubin ELF symbol check).

Material limitations and unrun checks:
- Live VRAM-allocating GPU tests (`tests/preparation/test_virtual_storage_cuda.py`, live `kv_codec_gpu.cu` kernel execution, end-to-end GPU export/serving, and multi-host live export) could not run because all 16 host GPUs were occupied (~95-96 GiB / 97.9 GiB in use by an external workload).
- Windows runtime execution for WDDM `HOST_BASE` placement and `eos::ReadRing` Windows `IoRing` paths was not exercised on Linux.

Design-Signed-Off-By: Antigravity (Gemini); design-review=2e5b
@lukealonso
lukealonso force-pushed the close-export-128mib-combine-stream0 branch from e029dc8 to 5b700f5 Compare November 30, 2026 20:32
@lukealonso
lukealonso merged commit f2ca2c4 into main Nov 30, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:preparation Ignition checkpoint loading, tuning, compilation, capture, and export. bug Something isn't working performance Performance, latency, throughput, or memory-efficiency investigation or improvement. priority:P2 Normal bug priority: workflow failure or diagnosis with narrower impact or an available workaround. triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

2 participants