Recommendation: Changes Requested
The core runtime implementation at 46e6a3b is solid — adversarial verification found no Blocker code bugs (all upstream blocker/major concurrency and event-pool claims were disproven on direct inspection of worker.rs, scheduler.rs, and memory.rs), and the host-wide --pool-ram-memory and multi-rank UVA page-table budgeting fixes are cleanly implemented and unit-tested. Changes are requested for four concrete, verified contract/documentation/evidence gaps before merge: an internal contradiction in docs/cli-design.md on pool_ram, an undocumented per-slot monotonicity narrowing on device_completions (with no CPU unit test), an unattributed/confounded performance claim alongside undisclosed IO-depth default halving, and a stale lifecycle verification README.
Merge Risk
Level: Medium
- Multi-stream completion ordering: Splitting the single
copy_streaminto three Copy Engine streams (copy_stream,bg_copy_stream,d2h_stream) withcuStreamWaitEventandstream_comp_maxchangesdevice_completionsfrom unconditional stream-order writes to lifetime per-slot monotonic non-regression; this path is currently exercised only by the gated live-CUDA test. - Operator-visible flag semantics & defaults:
--pool-ram-memorychanges from per-rank to host-wide on multi-rank discrete hosts (fixing a real bug, but altering existing multi-rank invocations), and per-channel NVMe concurrency defaults are halved (DEFAULT_MAX_TOTAL_IO32 -> 16,DEFAULT_MAX_BG_IO8 -> 4) with a new50 msactive spin window per worker. - Linux fast path & Kani coverage:
DEFER_TASKRUN/ReadFixedfallbacks are silent (let _ =), non-Linux/Windows paths are unexercised, and the updated Kani proof awaits CI execution.
Walkthrough
- CUDA bindings & ABI v1 ring (
helios/src/runtime_core/driver.rs,helios/src/async_transfer/ring.rs,helios/src/async_transfer/kani_proofs.rs): AddscuCtxGetStreamPriorityRange,cuStreamCreateWithPriority,cuStreamWaitEvent, andcuMemcpyDtoHAsync_v2, plusOpcode::DevToHost = 5andValidatedCommand::DevToHostwith full bounds, alignment, nonzero-length, and bit-63 error-sentinel validation while preservingABI_VERSION = 1and the 256-byteControlHeader. - Scheduler & formal model (
helios/src/async_transfer/scheduler.rs,lifecycle_tests.rs,verification/helios-lifecycle/AsyncTransfer.{tla,cfg},check.py): Addsd2h_queues/inflight_d2h(pop_next_d2h,mark_d2h_faulted,complete_d2h), gates background IO/H2D/D2H dispatch when demand work of the gated class is in flight, extends drain/release ownership to cover in-flight D2H, widens the TLA+ projection to 20 integers (MaxD2h = 1), switches Rust conformance exploration to BFS withqueue_shape_key(), and adds D2H TLA+/Rust mutations. - Multi-stream worker & Linux
io_uringbackend (helios/src/async_transfer/worker.rs,io_backend.rs): Splits Copy Engine execution across high-prioritycopy_stream, normal-prioritybg_copy_stream, and normal-priorityd2h_streamwith cross-streamcuStreamWaitEventslot synchronization and per-slotstream_comp_maxmonotonicity; widensbounce_pool_geometryup to 32 slots within512 MiB; halves default IO depth (32 -> 16, bg8 -> 4); adds a50 msACTIVE_SPIN_WINDOWand per-worker contiguous storage-run rotation; bindsio_uringon the worker thread withSINGLE_ISSUER | DEFER_TASKRUN | TASKRUN_FLAG | NO_SQARRAY(with fallbacks) and 1 GiB-chunkReadFixedbuffer registration. - Host-wide RAM budgeting, parallel worker startup, and docs (
selene/src/offload.rs,helios/src/runtime_core/memory.rs,model.rs,docs/cli-design.md,docs/runtime-core-design.md,helios/manifest.md): Addshost_pool_budget_and_total_with_reserve(omitting Selene's implicit host reserve when--pool-ram-memoryis explicitly supplied), applies--pool-ram-memoryhost-wide before dividing across local discrete ranks (preserving free reserve after aggregate bounce underMemoryLimit::Reserve), charges peer-UVA page tables aspinned.saturating_mul(ranks).div_ceil(512)on discrete multi-rank hosts, starts rank workers concurrently viastd::thread::scope, and updates runtime/manifest docs.
Pre-merge Checks
- [PASS] Security / malicious screen: No suspicious code, credential/network exfiltration, or prompt-injection vectors;
validate_commandenforces overflow-freechecked_addrange checks and bit-63 exclusion forOpcode::DevToHost. - [PASS] Charter & value fit: Stays strictly inside Helios's model-agnostic hardware/OS/lifecycle boundary (no per-model branches, no new captured-graph op families, no vendored-file forks, ABI v1 backward compatible); the host-wide
--pool-ram-memoryand multi-rank UVA page-table fixes resolve real bugs on multi-GPU hosts. - [WARN] Related / duplicate / conflict check: Additive over
main(building on #711/#721/#727); overlaps with open #726 inNativeModel::prepare_async_transfers(helios/src/runtime_core/model.rs:1080-1110) — coordinate merge order. Merge this PR before the companionhyperflare-recipesPR as stated. - [WARN] Tests & verification evidence: TLA+ conformance/mutations and crate/GPU tests are reported passing (6 unrelated HF HTTP 403 frontend template tests disclosed), but CI's
kanijob (.github/workflows/helios-lifecycle.yml:49(not opened)) must confirm green on head46e6a3bsincedocs/design-review.md:247-251treats applicable Kani proofs as mandatory, and theDEFER_TASKRUNstall-spread measurement lacks an isolated equivalent baseline (see Should Fix #3).
Blockers
None.
Should Fix
-
Resolve the
docs/cli-design.mdself-contradiction on--pool-ram-memory/pool_ram(docs/cli-design.md:761vsdocs/cli-design.md:1418):- Line 761 updates
--pool-ram-memoryto"Per-host ceiling ... (divided evenly across local discrete ranks)"matchinghelios/src/runtime_core/memory.rs:115-130andflare-cli/src/cli.rs:961-962, but the sampleflare.toml(not opened) in the same file at line 1418 still states# pool_ram = "" # Per-rank ceiling for pinned AsyncTransfer host pools. - Fix: Update
docs/cli-design.md:1418to describepool_ramas a per-host ceiling divided across local discrete ranks.
- Line 761 updates
-
Document the new per-slot monotonic non-regression contract on
device_completionsand add CPU unit-test coverage (helios/src/async_transfer/worker.rs:977-990,:1000,:1024,:1422,:1543;helios/manifest.md:188-196;docs/runtime-core-design.md:767-772):- Before this PR,
update_host_completion(worker.rs:313-314) enforced per-slot lifetime monotonicity viafetch_maxon host mirrors whiledevice_completions[slot]was written unconditionally on the single stream. Withstream_comp_max,device_completionsnow also permanently latches the highest written value per slot and silently skips any later write withsignal_value < stream_comp_max[slot](and makes bit-63 error sentinels sticky on device slots). That behavior is necessary to prevent priority-preempted background ops from regressingdevice_completionsafter a higher-value demand op finishes and is harvested (worker.rs:2176-2229), but neitherhelios/manifest.mdnordocs/runtime-core-design.mddocuments it — both only statefetch_maxmonotonicity for host mirrors. An ABI-v1 core that only pollsdevice_completionsand resets/reuses slots with smaller cookies would silently hang without an error. - Fix: Update
helios/manifest.md:188-196anddocs/runtime-core-design.md:767-772to specify thatdevice_completionsenforces per-slot monotonic non-regression (matching hostfetch_max, with sticky bit-63 error sentinels), and extract a small testable helper (e.g.StreamCompWatermark) with a CPU unit test inworker.rs::unit_testscovering equal/greater writes, skipped regressions, and sticky error sentinels.
- Before this PR,
-
Fix performance-claim attribution and disclose changed IO-depth defaults (
helios/src/async_transfer/worker.rs:43,48-49,52;docs/design-review.md:106-115;AGENTS.md:92-108):- The PR attributes
"reduced cross-rank demand-stall spread from >5,000 ms to 1,202 ms"to worker-ownedDEFER_TASKRUNwithout a baseline commit/config or raw per-rank data, while the same diff halves per-channel NVMe read concurrency (DEFAULT_MAX_TOTAL_IO: 32 -> 16,DEFAULT_MAX_BG_IO: 8 -> 4) and adds a50 msACTIVE_SPIN_WINDOW— both of which directly affect NVMe contention and stall spread. In addition, the32 -> 16/8 -> 4IO-depth halving andDEFAULT_MAX_D2H = 2default are omitted from the "What changed" section (AGENTS.md:92-94). - Fix: Either provide the equivalent baseline commit, configuration, and raw per-rank measurements isolating
DEFER_TASKRUN(or clearly attributing the combined diff) perdocs/design-review.md:106-115, or state the latency reduction as an expected benefit rather than an isolated measurement; explicitly noteDEFAULT_MAX_TOTAL_IO(32 -> 16),DEFAULT_MAX_BG_IO(8 -> 4), andDEFAULT_MAX_D2H = 2in the PR description.
- The PR attributes
-
Update
verification/helios-lifecycle/README.mdto match the 20-integerAsyncTransfermodel (verification/helios-lifecycle/README.md:353-384;docs/verification.md:118-119):AsyncTransfer.tla,AsyncTransfer.cfg,check.py, andlifecycle_tests.rsnow use a 20-integer projection withMaxD2h = 1and three new transitions (dispatch_d2h,complete_d2h,mark_d2h_faulted), whileREADME.md:357-382still documents a 16-integer projection and omitsMaxD2hand the D2H transitions.- Fix: Update
verification/helios-lifecycle/README.md:353-384to listMaxD2h = 1, the three D2H transitions, and all 20 projection fields.
Subtract / Simplify
- Deduplicate completion-slot signaling and stream queues in
worker_main(helios/src/async_transfer/worker.rs:938-943,:992-1043,:1418-1475,:1539-1587): Theshould_write_stream_comp/wait_other_streams_on_slot/use_write_value64/record_stream_comp/EventCompletionActionblock is duplicated three times (host-initiated, H2D, D2H), andpublish_notice/signal_completion_slotmanually forward two&VecDeque<PendingEventDma>arguments across ~14 call sites. Indexing pending queues byFaultedStreamKind([VecDeque<PendingEventDma>; 3]) and extracting one completion-signaling helper eliminates ~100 lines of duplication and removes manual queue-pair selection. - Replace process-global
NEXT_WORKER_ORDINALwith deterministic rank/channel identity (helios/src/async_transfer/worker.rs:59,948):args.config.rankis already passed intoworker_main(worker.rs:102,611). Deriving the rotation offset from(args.config.rank, channel_idx)removes the process-global atomic, makes per-rank stagger reproducible across restarts/tests, and also staggers multi-host single-local-rank setups where a process-local counter always starts at0. - Flatten the redundant
ACTIVE_SPIN_WINDOWcheck (helios/src/async_transfer/worker.rs:1685-1697):last_active.elapsed() < ACTIVE_SPIN_WINDOWis evaluated twice per tight spin iteration; bindinglet in_active_window = last_active.elapsed() < ACTIVE_SPIN_WINDOW;once removes redundant clock reads and simplifies the branching. - Trim single-use wrappers and duplicated validation:
async_transfer_host_ram(helios/src/runtime_core/memory.rs:41-44) is a single-callerunwrap_or((0, 0))passthrough;TransferScheduler::with_max_d2h(scheduler.rs:229-232) is inconsistent with the constructor caps and only called in production with its own default2(worker.rs:929); andOpcode::HostToDev/Opcode::DevToHostinring.rs:438-458,497-517share identical validation logic. - Surface
DEFER_TASKRUN/ReadFixedactivation status instead oflet _ =(helios/src/async_transfer/worker.rs:895-905,io_backend.rs:32-43,258-323): Combining or returning activation flags frombind_worker_thread/register_bufferslets startup logs andio_uring_bind_worker_thread_and_register_buffers_read_fixed(io_backend.rs:663-713, which currently passes even on silent fallback to plainRead) verify the fast path is actually active.
Nits
pop_next_d2hdemand reservation (helios/src/async_transfer/scheduler.rs:920-928): Unlikepop_next_io/pop_next_dma,pop_next_d2hyields background ops only todem_dma_inflight() > 0(H2D) and allows background D2H to fill allmax_d2hslots (matching its doc comment). IfDemandD2H is ever mixed withWarmevictions, yielding todem_d2h_inflight() > 0and adding an explicitmax_bg_d2hcap (ensuringmax_d2h = 1in tests/TLA+ still allows background D2H) would align D2H with IO/H2D priority rules.find_fixed_buflinear scan (helios/src/async_transfer/io_backend.rs:158-167): Scanning 1 GiB spans is negligible at ~28 entries (27 GiB/rank) vs NVMe latency, butpartition_pointon sorted spans or O(1) offset math scales cleanly to 512+ GiB single-rank pools.- D2H byte telemetry (
helios/src/async_transfer/ring.rs:200-205,scheduler.rs:994-996,1021-1023,docs/api.md:417-429): D2H completes with zeroed byte counters (keeping ABI v1ControlHeadercache line 3 intact and matchingdocs/api.md); consider documenting or adding a D2H counter if operators need visibility into demotion traffic. - Serial host pinning during startup (
helios/src/runtime_core/model.rs:1077-1109):std::thread::scopeparallelizesch.start()(bind_worker_thread+register_buffers) as described, whilePinnedHostRegion::allocate(cuMemHostRegister_v2) inrank.prepare_async_transfersremains sequential per rank. MemoryLimit::Reservehelper sharing (helios/src/runtime_core/memory.rs:120-126vslimits.rs:174-180): Extracting a sharedcap_byteshelper that accepts extra pinned bytes would keep allReservepaths structurally aligned.
Dropped on verification
- Upstream B1 as a Blocker + proposed in-flight-only fix (
stream_comp_max): Disproven as a Blocker and proposed fix is broken.update_host_completion(worker.rs:313-314) already enforced permanent per-slotfetch_maxmonotonicity onmain(worker.rs:2458-2471), and resettingstream_comp_maxon harvest (or checking only in-flight queues) breaks the PR's own preemption test (worker.rs:2176-2229) becauseDemand (7010)finishes and is harvested beforePrefetch (7009)is even popped from the scheduler (dem_activegates bg dispatch), allowing7009to regressdevice_completions[7]. Retained only as Should Fix #2 to document thedevice_completionsmonotonicity contract and add CPU test coverage. - Upstream M1 (Shared CUDA event pool starving
DevToHost): Mathematically false.event_pool_cap = DEFAULT_MAX_TOTAL_DMA + DEFAULT_MAX_D2H = 16 + 2 = 18(worker.rs:876), whileTransferSchedulercapsinflight_dma.len() <= 16(scheduler.rs:785,worker.rs:925). With 16 H2D ops in flight,18 - 16 = 2events remain infree_eventsfor step 5b (D2H), and every submission failure returns its event immediately (:1399, :1411, :1497). - Upstream M3 (
HostAndDevicebg harvest oncopy_streamregressingdevice_completionswithoutstream_comp_max): False.EventCompletionAction::HostAndDeviceis only set when!use_write_value64(worker.rs:1471) or when bothdevice_completions_base == 0andhost_comp_gpu_base == 0(:1467). In the latter casesignal_completion_slotonly runsupdate_host_comp(fetch_max,:1041); in the former case it runsupdate_host_comp(fetch_max,:999) beforeupload_asyncfromhost_comp_base[slot]on FIFOcopy_stream(:1010), which cannot regress even withoutstream_comp_max. - Upstream M4 (
NEXT_WORKER_ORDINALracing understd::thread::scopedestroying cross-rankordinal % lenseparation): False. Atomicfetch_add(1)across 8 concurrently spawned threads assigns a permutation of{k..k+8}, whose multiset ofordinal % lenresidues is identical to{0..8} % len— cross-rank RAID-0 stagger is preserved on a single host. Retained only as a Simplify item for determinism and multi-host clarity. - Upstream Minor 3 ("Stale
has_faulted_d2hinside dispatch loop re-issuing failing copies"): False. Oncopy_status != 0(worker.rs:1531-1536),scheduler.complete_d2h(d2h.op_id, false)removes the failed op and emitsCudaFailure(nothing was enqueued ond2h_stream, so it is neither re-issued nor an untracked faulted DMA); the only path pushing tountracked_faulted_dmas(event_recordfailure at:1603-1615) immediatelybreaks. - Upstream Kani
DevToHostalignment assertion mismatch (kani_proofs.rs:210): False.validate_transfer_header(ring.rs:377-383) checksalignment >= MIN_ALIGNMENT && alignment.is_power_of_two()for bothHostToDevandDevToHost, so the assertion is strictly true and provable. - Upstream Gate 4 claim that
bounce_pool_geometry512 MiB expansion was undeclared and increasesmemory.rsreserves: False. The PR description explicitly discloses"widened bounce_pool_geometry to up to 32 slots within 512 MiB", andmemory.rs:95-99already budgetedmax_bounce_pool_bytes(alignment) == 512 MiBbefore this PR. - Upstream
MaxD2h = 1vsDEFAULT_MAX_D2H = 2formal-bounds violation: Overstated/false.AsyncTransfer.cfguses the same bounded small-model convention for all queues (MaxTotalDma = 2vs16,MaxBgDma = 1vs4,MaxTotalIo = 2vs16), and all D2H lifecycle states are reachable atMaxD2h = 1.