Repository navigation
helios,flare-cli: harden AsyncTransfer startup, DMA and teardown lifetimes, unified DRAM, and Copy Engine safety - #721
Merged
Conversation
…s, unified DRAM, and CopyEngine safety
AsyncTransfer channels sit directly at the CUDA, Linux io_uring, unified-DRAM,
and Copy Engine hardware boundaries. Eight boundary defects threaten live
serving and multi-rank bring-up:
1. AsyncTransferRuntime::start() previously marked the channel Running and
returned Ok(()) before worker_main bound its CUDA context, allocated its
event pool, or wrote ControlHeader::worker_state = Running, causing startup
tuning kernels that require Running headers to fail spuriously and silently
dropping cuCtxSetCurrent failures.
2. When cuMemcpyHtoDAsync_v2 succeeded on copy_stream while a subsequent
cuStreamWriteValue64_v2 or cuEventRecord failed, the worker immediately
called scheduler.complete_dma(..., false), recycling the bounce slot and
clearing inflight_dma while the Copy Engine was still reading src_ptr.
3. Writing device completions from a separate unsynchronized signal_stream
raced copy_stream on reused completion slots, and deferred
EventCompletionAction::HostOnly stores could regress host_comp[slot]
backwards after slot reuse.
4. On IoFailure or CudaFailure, TransferScheduler and worker_main published
the caller's requested success signal_value into completion slots, allowing
GPU waiters to treat failed transfers as valid payload data.
5. IoUringBackend::cancel_and_drain called blocking submit_and_wait(1) without
a kernel timeout, defeating DRAIN_TIMEOUT when storage reads did not finish.
6. AsyncTransferRuntime::snapshot() dereferenced raw control_address after
NativeResources::release_execution_resources() unmapped MappedHost storage,
leaving retained metrics Arc handles exposed to use-after-free.
7. On integrated unified-DRAM GPUs (such as GB10 and Jetson), memory sizing
only subtracted pinned/512 + 256 MiB from the shared budget instead of full
HOST_POOL + bounce_pool bytes, ignored planned host_future prefix-cache and
vision windows, and sized DEVICE_POOL via local rank min() without
cluster-wide CacheAgreement across multi-host ranks.
8. Cores combining Execution.async_transfers with graphs containing Copy Engine
Memory::Peer copy nodes were allowed to load without CopyEngineGate
protection, risking Copy Engine deadlock because in-graph demand waits cannot
yield to CopyEngineGate.
What changed:
- Startup readiness, single-stream completions, partial-DMA retention, and
control-lifetime guard (helios/src/async_transfer/{ring,scheduler,worker,
mod}.rs, helios/src/runtime_core/mod.rs):
- Added a synchronous startup readiness channel in AsyncTransferRuntime::start
so start() blocks until worker_main binds the CUDA context, creates all
DEFAULT_MAX_TOTAL_DMA CUDA events, and publishes ControlHeader::worker_state
= Running; initialization errors propagate cleanly and restore io_backend
while keeping the channel Idle.
- Added TransferScheduler::mark_dma_faulted and InflightDma::faulted so
post-enqueue CUDA failures (cuStreamWriteValue64_v2, cuEventRecord, or
sticky cuEventQuery errors) retain inflight_dma and bounce-slot ownership
until cuEventQuery or cuStreamQuery(copy_stream) confirms hardware drain
(or remain pinned through FailedDrain).
- Removed signal_stream and serialized all device completion writes on
copy_stream (routing device_completions_base == 0 writes through
copy_stream when cuStreamWriteValue64_v2 is active), updated CPU host
completion mirrors via AtomicU64::fetch_max, and checked CUDA return
statuses in signal_completion_slot.
- Reserved bit 63 (COMPLETION_ERROR_BIT) in ring.rs for fault sentinels
(completion_error_sentinel(ErrorCode)), rejected caller signal_value values
with bit 63 set when a completion slot is active, and emitted fault
sentinels instead of requested success cookies on IoFailure/CudaFailure.
- Added ControlRegionGuard (RwLock<ControlAccess>) and
AsyncTransferRuntime::invalidate_control(), called in
NativeResources::release_execution_resources() before unmapping MappedHost
allocations, so post-teardown snapshot() returns captured final counters
without dereferencing unmapped memory.
- Bounded io_uring drain (helios/src/async_transfer/io_backend.rs, worker.rs):
- Replaced submit_and_wait(1) in IoUringBackend::cancel_and_drain with
submitter().submit_with_args(1, &SubmitArgs::new().timespec(&ts)), handling
ETIME and EINTR cleanly; retained io_backend on unconfirmed drain so
IoUring::drop cannot block thread join.
- Unified-DRAM budgeting, multi-host DEVICE_POOL agreement, and peer-copy load
gate (helios/src/runtime_core/{memory,model,mod,cache_memory}.rs,
helios/src/execution/rendezvous.rs, flare-cli/src/cluster.rs):
- Coordinated discrete-GPU async_transfer_host_ram with host_future and
bounce-pool headroom, deducted full pinned + page_tables + margin on
integrated GPUs (defaulting integrated HOST_POOL to 0 unless
--pool-ram-memory is explicitly configured and clamping explicit requests
above min_kv_reserve), and deducted async_transfer and integrated
DEVICE_POOL reservations from prefix-cache capture host_growth.
- Added CacheAgreement::device_pools, rendezvous::{agree,propose}_device_pools,
and Membership::device_pools (invoked only when DEVICE_POOL allocations are
present, keeping wire framing unchanged for existing cores) with local
bound and alignment validation before map_device_pool.
- Added load-time rejection in NativeModel::load_agreeing (and a defensive
guard in NativeResources::prepare_async_transfers) when
has_any_peer_copy_graphs() and !async_transfers.is_empty().
- Added missing external_extents initializer in a cache_memory.rs unit test.
- Formal verification and documentation (verification/helios-lifecycle/
{AsyncTransfer.tla,AsyncTransfer.cfg,check.py,README.md},
helios/src/async_transfer/{lifecycle_tests,kani_proofs}.rs,
helios/manifest.md, docs/runtime-core-design.md):
- Extended AsyncTransfer.tla with faultedDma, MarkDmaFaulted, and
FaultedDmaRetainsOwnership; expanded observed-edge projection to 14 fields
and added TLA+ and Rust mutation checks for early bounce release and
success-cookie signaling on error; extended Kani validate_command proofs
to verify signal_value disjointness from COMPLETION_ERROR_BIT.
Claimed benefit and result:
Eliminates the eight verified startup-race, bounce-slot/snapshot UAF,
dual-stream completion regression, silent error-corruption, unbounded shutdown
drain, unified-DRAM over-allocation, multi-host pool divergence, and PCIe
peer-copy Copy Engine deadlock hazards on AsyncTransfer channels while keeping
existing cores without AsyncTransfer or DEVICE_POOL wire-compatible and
unaffected.
Supporting evidence and limitations:
- Live CUDA integration test (CUDA_VISIBLE_DEVICES=1 FLARE_RUN_CUDA_TESTS=1
helios async_transfer::worker::cuda_tests::live_cuda_async_transfer_end_to_end
on NVIDIA RTX PRO 6000 Blackwell Max-Q): 1 passed, 0 failed; verified
immediate Running header state after start(), same-slot HostToDev ->
DiskToHost reuse, real EOF IoFailure emitting completion_error_sentinel on
both host and device completion slots, and post-munmap snapshot() after
invalidate_control().
- TLA+ models, Rust trace conformance, and mutation suite
(verification/helios-lifecycle/check.py --mutations with tla2tools-1.7.4.jar
and OpenJDK 21): all 10 TLA+ models, all 9 conformance suites (359 observed
Rust transitions checked against AsyncTransfer.tla), and all TLA+ and Rust
mutations (including FaultedDmaRetainsOwnership, failed io/dma error
sentinels, and faulted DMA bounce retention) passed.
- Kani 0.68.0 (helios --features runtime-core --lib
--harness async_transfer::kani_proofs::): 5/5 harnesses verified with 0
failures.
- Rust crate tests and release build (Linux x86_64):
- eos: 12 passed, 0 failed.
- selene (--features test-support): 586 passed, 0 failed.
- selene-manager (--features test-support): 448 passed, 0 failed, 1 ignored.
- helios (--features runtime-core,server --lib): 1904 passed, 49 ignored, 6
failed exclusively due to unset FLARE_TEST_TEMPLATE_DIR (targeted
async_transfer:: 15/15, runtime_core::memory:: 27/27 + 1 GPU-ignored,
runtime_core::model:: 7/7, execution::rendezvous:: 6/6 all passed).
- flare: 255 passed, 0 failed, 4 ignored.
- flare-cli: 249 passed, 0 failed, 3 ignored; release binary built and
--features roce check succeeded.
- heliopause (export::binding::): 15 passed, 0 failed.
- Limitations: live multi-host RoCE cluster loading with DEVICE_POOL, live
GB10/Jetson unified-DRAM execution, live TP>=2 PCIe peer-copy rejection on an
exported core, and the 6 FLARE_TEST_TEMPLATE_DIR template tests were not run
in this pass.
Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
Signed-off-by: Luke Alonso <lalonso@gmail.com>
jcartu
added a commit
to jcartu/hyperflare-inference
that referenced
this pull request
Dec 4, 2026
… inherit orbit memory reserve, and log integrated MemInfo Why - On Linux unified-memory GPUs (such as GB10), CUDA allocations and context creation can respond to Linux `MemFree` rather than `MemAvailable` when tens of gigabytes of clean page cache accumulate from core distribution and buffered cache I/O (NVIDIA#630). - `flare-cli`'s peer-serving path (`distribution::serve_source`) streamed core shards via buffered `RangeReader` before dropping page cache, leaving multi-GiB bursts in the page cache during transfer, and four buffered I/O sites across `flare-cli` and `helios` omitted `release_page_cache`. - `flare orbit run` did not inherit `[memory] reserve` from host configuration (`config.rs`), unlike `flare run`, while persistent groups still needed their stored `--memory-limit` preserved unless overridden on the command line and must not freeze config defaults into saved `GroupSpec.serving` definitions. - When integrated-GPU cache planning was memory-limited or `cuDevicePrimaryCtxRetain` / `cuCtxCreate_v2` returned `CUDA_ERROR_OUT_OF_MEMORY`, diagnostics did not surface Linux `MemFree / MemAvailable / Cached` or hint when reclaimable page cache was likely blocking allocation. What changed - Direct peer serving and missed `release_page_cache` sites: - Re-exported `eos` direct-I/O helpers (`FileReadAt`, `allocate_aligned`, `direct_reopen`, `free_aligned`) from `helios/src/lib.rs`. - Updated `flare-cli/src/distribution.rs::serve_source` to reopen files with `direct_reopen` on Unix and stream 4 MiB aligned chunks from a zero-initialized `AlignedBuffer` (handling arbitrary unaligned offsets, multi-range requests, and unaligned EOF byte-for-byte identically to `cache::RangeReader`), falling back cleanly to buffered `RangeReader` when `O_DIRECT` is unsupported or returns `EINVAL`, and executing one unconditional post-branch `release_page_cache_range` loop in `copy_source_ranges` for every served range (including on error). - Added `release_page_cache` / `release_page_cache_range` at the four missed buffered I/O sites: `flare-cli/src/orbit/controller.rs`, `flare-cli/src/core_cache.rs`, `flare-cli/src/orbit/agent.rs::get`, and `helios/src/core/cache.rs` (`write_stream`, `verify_file`, `hash_file`, `import_legacy_into`, and non-Windows `copy_file`). Collapsed `verify_file` onto `hash_file(path, release: bool)` so `import_legacy_into` hashes with `release = false` (avoiding double storage reads before `insert_legacy_container`) and releases the source file unconditionally after `insert_legacy_container` returns. - Orbit `[memory] reserve` propagation: - Added `#[arg(skip)] pub config_memory_limit: Option<MemoryLimit>` to `OrbitRun` (`flare-cli/src/cli.rs`) and `RunOptions` (`flare-cli/src/orbit/controller.rs`), populated from `[memory] reserve` in `flare-cli/src/config.rs` only when `--memory-limit` is unset on the command line. - Kept config-derived `--memory-limit` out of `OrbitRun::rank_options` and `GroupSpec.serving` so persistent groups never freeze config defaults; applied it only at launch via `apply_config_memory_limit` when neither the saved group nor the CLI specifies `--memory-limit`. - Added a persistent-group round-trip unit test through `save_group` / `Orbit::save` / `Orbit::load` verifying config reserve edits take effect on reload while explicit saved and CLI `--memory-limit` values retain precedence. - Linux integrated-GPU `/proc/meminfo` diagnostics: - Added `LinuxMemInfo { free, available, cached }` parser and `CUDA_ERROR_OUT_OF_MEMORY` constant in `helios/src/runtime_core/`. - Appended `MemFree / MemAvailable / Cached` to the `Plan cache` summary on Linux integrated GPUs and emitted a concise stderr warning when `MemAvailable - MemFree > 10 GiB` and KV sizing is limited by memory (without repeating the triple already logged in `Plan cache`). - Enriched `cuDevicePrimaryCtxRetain` and `cuCtxCreate_v2` `CUDA_ERROR_OUT_OF_MEMORY` failures on Linux integrated GPUs via `enrich_integrated_ctx_oom(error, meminfo: Option<LinuxMemInfo>)` with `MemFree / MemAvailable / Cached` (and a `drop_caches` hint when `MemAvailable - MemFree > 4 GiB`) while preserving the structured `ExecutionError::Driver(CudaError { code: 2, .. })` error. - Documentation: - Documented `orbit run` `[memory] reserve` inheritance, non-persistence, and saved/CLI `--memory-limit` precedence in `docs/orbit.md` and `docs/cli-design.md`, and integrated-GPU `Plan cache` / context-OOM `/proc/meminfo` diagnostics in `docs/cli-design.md`. Verification - Rebased onto `origin/main` (`f705086b`, including `NVIDIA#720` and `NVIDIA#721`). - CPU-only verification on Linux x86_64 (no live GB10 run yet): - Verified `.githooks/commit-msg` passes on the staged diff and message. - `cargo test --locked --release --manifest-path flare-cli/Cargo.toml`: 254 passed (228 bin + 9 cache_commands + 6 cli + 4 inspect + 7 unverified_payload), 0 failed, 3 ignored. - `cargo test --locked --release --manifest-path flare/Cargo.toml`: 255 passed (247 lib + 7 packed_canonical_download + 1 reference_workflows), 0 failed, 4 ignored. - `cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib`: `core::cache` 106 passed, 0 failed, 2 ignored; `runtime_core::` 206 passed (including `runtime_core::memory` 30 passed), 0 failed, 13 ignored. - `rustfmt --edition 2024`: clean on all touched lines across all 12 Rust files. Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b Signed-off-by: Joshua Cartu <jcartu@users.noreply.github.com>
This was referenced Dec 4, 2026
lukealonso
pushed a commit
that referenced
this pull request
Dec 4, 2026
… inherit orbit memory reserve, and log integrated MemInfo (#713) Why - On Linux unified-memory GPUs (such as GB10), CUDA allocations and context creation can respond to Linux `MemFree` rather than `MemAvailable` when tens of gigabytes of clean page cache accumulate from core distribution and buffered cache I/O (#630). - `flare-cli`'s peer-serving path (`distribution::serve_source`) streamed core shards via buffered `RangeReader` before dropping page cache, leaving multi-GiB bursts in the page cache during transfer, and four buffered I/O sites across `flare-cli` and `helios` omitted `release_page_cache`. - `flare orbit run` did not inherit `[memory] reserve` from host configuration (`config.rs`), unlike `flare run`, while persistent groups still needed their stored `--memory-limit` preserved unless overridden on the command line and must not freeze config defaults into saved `GroupSpec.serving` definitions. - When integrated-GPU cache planning was memory-limited or `cuDevicePrimaryCtxRetain` / `cuCtxCreate_v2` returned `CUDA_ERROR_OUT_OF_MEMORY`, diagnostics did not surface Linux `MemFree / MemAvailable / Cached` or hint when reclaimable page cache was likely blocking allocation. What changed - Direct peer serving and missed `release_page_cache` sites: - Re-exported `eos` direct-I/O helpers (`FileReadAt`, `allocate_aligned`, `direct_reopen`, `free_aligned`) from `helios/src/lib.rs`. - Updated `flare-cli/src/distribution.rs::serve_source` to reopen files with `direct_reopen` on Unix and stream 4 MiB aligned chunks from a zero-initialized `AlignedBuffer` (handling arbitrary unaligned offsets, multi-range requests, and unaligned EOF byte-for-byte identically to `cache::RangeReader`), falling back cleanly to buffered `RangeReader` when `O_DIRECT` is unsupported or returns `EINVAL`, and executing one unconditional post-branch `release_page_cache_range` loop in `copy_source_ranges` for every served range (including on error). - Added `release_page_cache` / `release_page_cache_range` at the four missed buffered I/O sites: `flare-cli/src/orbit/controller.rs`, `flare-cli/src/core_cache.rs`, `flare-cli/src/orbit/agent.rs::get`, and `helios/src/core/cache.rs` (`write_stream`, `verify_file`, `hash_file`, `import_legacy_into`, and non-Windows `copy_file`). Collapsed `verify_file` onto `hash_file(path, release: bool)` so `import_legacy_into` hashes with `release = false` (avoiding double storage reads before `insert_legacy_container`) and releases the source file unconditionally after `insert_legacy_container` returns. - Orbit `[memory] reserve` propagation: - Added `#[arg(skip)] pub config_memory_limit: Option<MemoryLimit>` to `OrbitRun` (`flare-cli/src/cli.rs`) and `RunOptions` (`flare-cli/src/orbit/controller.rs`), populated from `[memory] reserve` in `flare-cli/src/config.rs` only when `--memory-limit` is unset on the command line. - Kept config-derived `--memory-limit` out of `OrbitRun::rank_options` and `GroupSpec.serving` so persistent groups never freeze config defaults; applied it only at launch via `apply_config_memory_limit` when neither the saved group nor the CLI specifies `--memory-limit`. - Added a persistent-group round-trip unit test through `save_group` / `Orbit::save` / `Orbit::load` verifying config reserve edits take effect on reload while explicit saved and CLI `--memory-limit` values retain precedence. - Linux integrated-GPU `/proc/meminfo` diagnostics: - Added `LinuxMemInfo { free, available, cached }` parser and `CUDA_ERROR_OUT_OF_MEMORY` constant in `helios/src/runtime_core/`. - Appended `MemFree / MemAvailable / Cached` to the `Plan cache` summary on Linux integrated GPUs and emitted a concise stderr warning when `MemAvailable - MemFree > 10 GiB` and KV sizing is limited by memory (without repeating the triple already logged in `Plan cache`). - Enriched `cuDevicePrimaryCtxRetain` and `cuCtxCreate_v2` `CUDA_ERROR_OUT_OF_MEMORY` failures on Linux integrated GPUs via `enrich_integrated_ctx_oom(error, meminfo: Option<LinuxMemInfo>)` with `MemFree / MemAvailable / Cached` (and a `drop_caches` hint when `MemAvailable - MemFree > 4 GiB`) while preserving the structured `ExecutionError::Driver(CudaError { code: 2, .. })` error. - Documentation: - Documented `orbit run` `[memory] reserve` inheritance, non-persistence, and saved/CLI `--memory-limit` precedence in `docs/orbit.md` and `docs/cli-design.md`, and integrated-GPU `Plan cache` / context-OOM `/proc/meminfo` diagnostics in `docs/cli-design.md`. Verification - Rebased onto `origin/main` (`f705086b`, including `#720` and `#721`). - CPU-only verification on Linux x86_64 (no live GB10 run yet): - Verified `.githooks/commit-msg` passes on the staged diff and message. - `cargo test --locked --release --manifest-path flare-cli/Cargo.toml`: 254 passed (228 bin + 9 cache_commands + 6 cli + 4 inspect + 7 unverified_payload), 0 failed, 3 ignored. - `cargo test --locked --release --manifest-path flare/Cargo.toml`: 255 passed (247 lib + 7 packed_canonical_download + 1 reference_workflows), 0 failed, 4 ignored. - `cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib`: `core::cache` 106 passed, 0 failed, 2 ignored; `runtime_core::` 206 passed (including `runtime_core::memory` 30 passed), 0 failed, 13 ignored. - `rustfmt --edition 2024`: clean on all touched lines across all 12 Rust files. Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b Signed-off-by: Joshua Cartu <jcartu@users.noreply.github.com> Co-authored-by: Joshua Cartu <jcartu@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The asynchronous extent-transfer runtime (
helios/src/async_transfer/) and runtime-sized device weight pool allocator (Capacity::DEVICE_POOL) introduced in #711 cross four hardware and OS boundaries—CUDA streams and events, Linuxio_uring, unified-DRAM memory sizing, and Copy Engine peer-to-peer transfers—where eight boundary defects break correctness or stability under live serving and multi-rank bring-up:AsyncTransferRuntime::start()transitioned its host state toChannelState::Runningand returnedOk(())immediately after spawning the worker thread, before the worker bound the rank's CUDA context (cuCtxSetCurrent), created its CUDA event pool, or wroteChannelState::Runninginto the mapped-host control header (ControlHeader::worker_state). Startup kernels that validate a live channel header (such as tiered MoE initialization in local-inference-lab/hyperflare-recipes#150) can observeChannelState::Idle, andcuCtxSetCurrentfailures were silently ignored.cuMemcpyHtoDAsync_v2succeeded oncopy_streamwhile the subsequentcuStreamWriteValue64_v2orcuEventRecordfailed, the worker immediately calledscheduler.complete_dma(..., false), releasing the staging bounce slot and decrementinginflight_dmawhile the GPU Copy Engine was still reading that pinned host buffer.signal_streamwhile DMAs and inline completion writes ran oncopy_stream, allowing out-of-order writes on reused completion slots. On the host mirror (host_comp), deferredEventCompletionAction::HostOnlyupdates used plain release stores that could overwrite a newer completion value backwards after slot reuse.ErrorCode::IoFailureorErrorCode::CudaFailure,TransferSchedulerand the worker wrote the caller's requested success cookie (signal_value) into completion slots, allowing GPU waiters spinning onsignal_valueto treat unwritten or stale destination memory as valid payload data.io_uringshutdown hang:IoUringBackend::cancel_and_drain()called blockingring.submit_and_wait(1)with no kernel timeout, defeating theDRAIN_TIMEOUTbound when storage operations stalled during teardown.munmapuse-after-free inAsyncTransferRuntime::snapshot():NativeResources::release_execution_resources()unmapped the channel'sMappedHostcontrol region while retainedArc<AsyncTransferRuntime>metric handles could still call safesnapshot(), which dereferenced the rawcontrol_addresspointer.DEVICE_POOLagreement: On integrated unified-DRAM GPUs (such as GB10 and Jetson), memory sizing deducted onlypinned.div_ceil(512) + 256 MiBrather than full pinnedHOST_POOLand bounce-pool bytes from the shared physical RAM budget, failed to reserveHOST_POOLand bounce memory against host prefix-cache growth (host_future) and vision offload windows, and sizedDEVICE_POOLusing only the local host minimum without exchanging sizes across multi-host ranks viaCacheAgreement.Execution.async_transferswith CUDA graphs containing Copy Engine peer-to-peer copy nodes (Memory::Peer) were accepted at load time without Copy Engine serialization. Captured graphs that wait on in-graph demand transfers cannot yield toCopyEngineGatewithout circular deadlock, and ungated concurrent Copy Engine host-to-device transfers deadlock PCIe peer copies.What changed
Worker startup, DMA lifetime, completion ordering, and control-region lifetime (
helios/src/async_transfer/{ring,scheduler,worker,mod}.rs,helios/src/runtime_core/mod.rs)AsyncTransferRuntime::start()publishedChannelState::Runninglocally and returned before the worker thread initialized CUDA. Nowstart()blocks on a synchronousmpsc::sync_channeluntilworker_mainbinds the CUDA context (cuCtxSetCurrent), creates allDEFAULT_MAX_TOTAL_DMACUDA events, and writesChannelState::RunningintoControlHeader::worker_statewithReleaseordering. Initialization errors returnErr(...), restoreio_backend, and leave the channelChannelState::Idle.cuStreamWriteValue64_v2,cuEventRecord, or stickycuEventQueryerrors) immediately released the bounce slot. NowInflightDmatracks afaultedflag andTransferScheduler::mark_dma_faulted()keeps bothinflight_dmaand bounce-slot ownership pinned while pausing new DMA submissions untilcuEventQuery(for tracked events) orcuStreamQuery(copy_stream) == 0(for untracked faulted DMAs) confirms the Copy Engine has drained. OnChannelState::FailedDrain, faulted DMA events and any undrainedio_backendremain pinned rather than being destroyed while hardware may still reference their buffers.worker_mainmaintained bothcopy_streamand an unsynchronizedsignal_streamand updatedhost_compwith plain atomic stores. Nowsignal_streamis removed; all device completion writes serialize oncopy_stream(including host-only completions whendevice_completions_base == 0and stream-memory writes are active),signal_completion_slot()checks CUDA return statuses, andupdate_host_completion()updateshost_compwithAtomicU64::fetch_max.signal_value. Nowring.rsreserves bit 63 (COMPLETION_ERROR_BIT = 1u64 << 63) for fault sentinels viacompletion_error_sentinel(ErrorCode), addsErrorCode::InvalidSignalValue = 12, and rejects commands with(signal_value & COMPLETION_ERROR_BIT) != 0whencompletion_slot != NO_COMPLETION_SLOT. OnIoFailureorCudaFailure,TransferSchedulerand the worker emitcompletion_error_sentinel(...)rather than the caller's success cookie so GPU waiters observe a non-success fault value without silently consuming invalid bytes.snapshot()dereferencedcontrol_addressunconditionally. NowControlRegionGuard(RwLock<ControlAccess>) guards control-region reads and writes, andNativeResources::release_execution_resources()callschannel.invalidate_control()before unmappingMappedHostallocations, capturing final ring counters so subsequentsnapshot()calls never touch unmapped memory.Bounded
io_uringshutdown (helios/src/async_transfer/io_backend.rs)IoUringBackend::cancel_and_drain()called blockingself.ring.submit_and_wait(1)in a loop.deadlineand callssubmitter().submit_with_args(1, &SubmitArgs::new().timespec(&ts)), handlingETIME,EINTR, and bounded sleep/poll fallback whensubmit_with_argsreturns another error.Unified-DRAM accounting, prefix-cache coordination, and multi-host
DEVICE_POOLagreement (helios/src/runtime_core/{memory,model}.rs,helios/src/execution/rendezvous.rs,flare-cli/src/cluster.rs)memory.rsdeducted onlypinned.div_ceil(512) + 256 MiBfor integrated ranks and did not account forHOST_POOLor bounce pools when planning host prefix-cache growth (host_future) orprepare_offload. NowAsyncTransferBudgetandasync_transfer_host_ram()account for fullpinned + pinned.div_ceil(512) + 256 MiBon integrated GPUs, defaultHOST_POOLto0on integrated GPUs unless--pool-ram-memoryis explicitly provided (preventingHOST_POOLfrom competing withDEVICE_POOLin the same physical DRAM while still permitting explicit 3-tier sizing clamped against minimum KV reserves), and deductasync_transfer_host_total + device_pool_integrated_bytesfrom host prefix-cache growth budgets.DEVICE_POOLagreement: Previously, each host sizedDEVICE_POOLusing only its local rank minimum. NowCacheAgreementgains adevice_pools(&mut self, local: &[u64]) -> Result<Vec<u64>>method (defaulting toOk(local.to_vec())for single-host callers), implemented inflare-cli/src/cluster.rs(Membership::device_pools) overhelios/src/execution/rendezvous.rs(agree_device_pools/propose_device_pools).memory.rsgathers canonical sorteddevice_pool_names, exchanges local minima across cluster ranks, and validates agreed sizes viavalidate_agreed_device_poolsbeforemap_device_pool. Multi-host cores withoutCapacity::DEVICE_POOLnever invoke this exchange, preserving wire compatibility.Load-time rejection of
async_transferswith Copy Engine peer-copy graphs (helios/src/runtime_core/{model,mod}.rs)NativeModel::load_agreeing()constructedCopyEngineGatewhenhas_any_peer_copy_graphs()was true without checking forExecution.async_transfers.validate_async_transfer_peer_copy_compatibility()fails fast afterprepare_graphs(with a matching defensive guard inNativeResources::prepare_async_transfers) whenever any rank has Copy Engine peer-copy graphs alongsideExecution.async_transfers. Single-GPU, NVLink SM P2P, and RoCE cores without Copy Engine peer-copy nodes continue to load normally.Formal models, tests, documentation, and test-build fix (
verification/helios-lifecycle/,helios/src/async_transfer/{lifecycle_tests,kani_proofs}.rs,helios/manifest.md,docs/runtime-core-design.md,helios/src/runtime_core/cache_memory.rs)AsyncTransfer.tla/AsyncTransfer.cfgwithfaultedDma,MarkDmaFaulted, andFaultedDmaRetainsOwnership; expanded the Rust conformance trace projection to 14 fields; added TLA+ and Rust mutation checks covering early bounce-slot release and success-cookie signaling on error; extended Kani'svalidate_command_guarantees_bounds_and_alignment_for_all_inputsharness to assertsignal_valuedisjointness fromCOMPLETION_ERROR_BIT.helios/manifest.mdanddocs/runtime-core-design.mdto specify theCOMPLETION_ERROR_BITcontract, synchronous startup readiness, single-stream completion ordering, unified-DRAM deductions,CacheAgreement::device_pools, and the peer-copy load-time rejection.external_extents: vec![]field in aCoreunit-test literal inhelios/src/runtime_core/cache_memory.rssoheliosunit tests compile onorigin/main(this 1-line fix overlaps with open PR fix(helios): add missing external_extents field in cache_memory test Core literal #714).Claimed benefit and result
AsyncTransferRuntimeandDEVICE_POOLallocation.Execution.async_transfersorCapacity::DEVICE_POOL.io_uringbounded drain, and peer-copy rejection are verified; live multi-host RoCE, live GB10/Jetson unified-DRAM, and live TP>=2 PCIe exported-core execution remain untested (see limitations below).Supporting evidence and limitations
All checks ran on Linux x86_64 against commit
d612cd1c(branched fromorigin/main17961ccd):CUDA_VISIBLE_DEVICES=1 FLARE_RUN_CUDA_TESTS=1 cargo test --locked --release \ --manifest-path helios/Cargo.toml --features runtime-core,server --target-dir flare-cli/target \ --lib async_transfer::worker::cuda_tests::live_cuda_async_transfer_end_to_end -- --exact --nocaptureControlHeader::worker_state == ChannelState::Runningimmediately uponstart()returning, same-slotHostToDevfollowed byDiskToHostreuse oncopy_stream, real EOFIoFailurewritingcompletion_error_sentinel(ErrorCode::IoFailure)to both host and device completion slots, andsnapshot()returning retained counters afterinvalidate_control()andMappedHostunmapping.tla2tools-1.7.4.jar, OpenJDK 21, perdocs/verification.md):AsyncTransfer.tla), and all TLA+ and Rust mutation checks passed (including mutations that violateFaultedDmaRetainsOwnershipor emit success cookies on failed I/O or DMA).cargo kani --manifest-path helios/Cargo.toml --features runtime-core --lib \ --harness 'async_transfer::kani_proofs::'--locked --release --target-dir flare-cli/target):eos: 12 passed, 0 failed.selene --features test-support: 586 passed, 0 failed.selene-manager --features test-support: 448 passed, 0 failed, 1 ignored.helios --features runtime-core,server --lib: 1904 passed, 49 ignored, 6 failed. All 6 failures are chat-template tests (frontend::jinja::tests::*,frontend::templates::tests::*,server::protocol::decode::native_prompt_tests::*) that requireFLARE_TEST_TEMPLATE_DIRpopulated bytests/frontend/prepare_templates.py. All targeted suites passed:async_transfer::(15/15),runtime_core::memory::(27/27, 1 GPU-ignored),runtime_core::model::(7/7), andexecution::rendezvous::(6/6).flare: 255 passed, 0 failed, 4 ignored.flare-cli: 249 passed, 0 failed, 3 ignored;cargo build --locked --release --manifest-path flare-cli/Cargo.tomlandcargo check --locked --release --manifest-path flare-cli/Cargo.toml --features rocesucceeded with 0 warnings.heliopause(export::binding::): 15 passed, 0 failed.Capacity::DEVICE_POOLwas not executed (covered by TCP loopback rendezvous andMembership::device_poolsunit tests).validate_async_transfer_peer_copy_compatibilityunit tests).FLARE_TEST_TEMPLATE_DIR-dependent frontend template tests inhelioswere not run because the template fixtures were not fetched in this environment.Discord: lukealonso