Repository navigation
Conversation
On discrete PCIe GPUs (observed on SM120 RTX PRO 6000 under CUDA driver 595.99.02), tensor-parallel CUDA graphs whose collectives drive peer-to-peer transfers through in-graph Copy Engine nodes (`Node::Copy` with a `Memory::Peer` endpoint, such as `b12x` `PCIeDmaAllReduce`) deadlock when prefix-cache offload workers issue concurrent host-device Copy Engine batches on the same devices. Even a single concurrent device-to-host copy from an unrelated allocation on the offload stream stalls both ranks inside the graph's peer-copy collectives. Coordinating host offload batches against peer-copy graph execution directly in Helios eliminates the deadlock for already-exported model packages without changing the package format, scheduling policy, or per-model behavior. Detect peer-copy graphs structurally during CUDA graph reconstruction in `NativeResources`: record `peer_copy_graphs[i] = true` whenever any `Node::Copy` node in graph `i` has a `Memory::Peer` source or destination, carry that vector on `ExecutionManifest`, and union it across local `RankPeers::Threads` manifests in `RankExecutor`. Share one `offload::CopyEngineGate` per `NativeModel` across `RankExecutor`, local `offload::Binding` / `offload::open_with_gate`, and `NativeModel::attach_offload` (for Selene pool workers). When submitting a graph flagged with peer copies, `RankExecutor` acquires a `PeerGraphGuard` (blocking until in-flight offload batches drain and giving waiting peer-copy graphs priority over new batches) and releases it on `poll` completion or after `close` drains. Offload workers acquire an `OffloadBatchGuard` per `BATCH_BYTES` batch in uncompressed `RankWorker::run`, CPU-codec `copy_spans_batch`, and all five GPU-codec capture/restore entry points (preserving strict `gpu.codec` before `CopyEngineGate` lock order and draining the CUDA stream before releasing the guard on error). Graphs without peer-copy nodes incur no gate locking. Eliminates the TP2 prefill deadlock under concurrent prefix-cache offload while preserving multi-rank offload concurrency outside peer-copy graphs and maintaining warm/restore correctness and burst latency. Validation: - `RUSTFLAGS="-D warnings" cargo check --locked --all-targets` passed for `helios --features runtime-core,server`, `flare`, `flare-cli`, and `heliopause --lib` (0 warnings). - Unit tests passed: `helios` `offload::copy_gate` and `execution::ranks` (5/5), `helios` `server::runtime` and `execution::threaded` (162/162), `flare` (245/245), and `flare-cli` (200/201 under root and 200/201 under non-root, with all 201 distinct tests passing across the two permission contexts). - SM120 4-GPU CUDA `helios` `offload::` tests passed: 19/19 default tests plus 6/6 ignored `offload::transfer::` GPU/CPU codec and multi-GPU split pool tests (`FLARE_RUN_CUDA_TESTS=1`). - Live SM120 TP2 (`--gpus 0,1`, `--prefix-cache-memory 4G`, 16 GiB disk tier) on `Qwen3.8-Flash-Next` (`--lossless-kv-compression off`): cold, warm (0/6 pos0 mismatches, 5.08x speedup), restart + disk restore (0/6 pos0 mismatches, 2.45x speedup), 8-way burst with 2 aborts (8/8, 4.15s), and 5x 8-way uncached 6578-token bursts (40/40 HTTP 200, 4.68-4.83s/burst; unpatched `main` deadlocked during the first burst). - Live SM120 TP2 on `GLM-5.3-Flash` (`--lossless-kv-compression gpu`): cold, warm (0/96 token mismatches, 3.50x speedup), restart + restore (0/96 token mismatches, 1.55x speedup), and 8-way burst with 2 aborts (8/8, 5.88s). Limitations: - Tested on single-host threaded TP2 on SM120 (RTX PRO 6000) with local DRAM and disk tiers (uncompressed and GPU KV codec). Multi-host TP, live Selene pool serving, CPU KV codec live serving, and non-SM120 GPUs were not exercised live (though pool and CPU codec paths share the same `CopyEngineGate` wiring and unit/CUDA codec tests). Fixes NVIDIA#627 Signed-off-by: yatesdr <6937857+yatesdr@users.noreply.github.com> Design-Signed-Off-By: yatesdr; design-review=2e5b
|
A case file has been opened for 628. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedClean engineering of structural peer-copy detection, RAII gate primitives, strict
Walkthrough
Merge Risk: High · up to
|
…ls, and preserve metrics Address starvation, non-peer-copy overhead, timeout, metrics, multi-host coverage, and cleanup gaps in `CopyEngineGate`: - Add bounded fairness to `CopyEngineGate` (`MAX_PEER_STREAK_WHILE_OFFLOAD_WAITING = 4`): when offload batches are waiting under sustained 2-frame pipelined peer-copy decode, `PeerGraphLeases::should_drain_for_offload()` signals `RankExecutor::can_submit()` to pause pipelining for one frame so active peer-copy leases drain to zero, then grants one concurrent wave to all waiting offload ranks before resuming peer-copy graphs. Only arm an offload wave when `peer_graphs_active == 0` so a single-threaded pipelined worker cannot self-deadlock. - Scope `CopyEngineGate` creation in `NativeModel` to models where at least one rank reconstructed a graph with `Node::Copy` referencing `Memory::Peer` (`NativeResources::has_any_peer_copy_graphs()`). Single-GPU and non-peer-copy TP models receive `copy_gate = None` and stay on the ungated single-sync-per-window offload fast path. - Bound `CopyEngineGate::enter_peer_graph` with `PEER_GRAPH_GATE_TIMEOUT` (120 s, aligned with `ThreadedExecutor::TIMEOUT`), returning `ExecutionError::Drain` instead of parking the model worker thread indefinitely if an offload Copy Engine batch fails to drain, and update the invariants in `docs/prefix-cache-offload.md` and `helios/src/offload/transfer.rs`. - Exclude gate-wait pauses from throughput metrics: start the transform timer after acquiring the gate in all five GPU-codec call sites in `codec.rs`, accumulate per-rank `gate_wait` and subtract `max_gate_wait` from `Reply.elapsed` in `Transfers::absorb`, and record `prefill_started` in `Worker::submit` after `executor.submit()` succeeds. - Share `PeerGraphLeases` between `RankExecutor` and multi-host `serve_rank` (`execution/parallel.rs`), and wire `owner.copy_gate()` through `offload::shard::join_peer_with_gate` (`flare-cli/src/cluster.rs`). - Deduplicate gated/ungated `stream.copy_batch` and stream-drain helpers into `transfer::copy_batch_gated` and `transfer::drain_stream`; remove dead `ExecutionManifest::has_peer_copies` and unused `OffloadBatchGuard` re-export; move pure delegation matches onto `RankExecutorInner`; validate `peer_copy_graphs.len() == graphs.len()` (when non-empty) in `ExecutionManifest::validate()`; and add unit and gated CUDA transfer tests. Validation: - `RUSTFLAGS="-D warnings" cargo check --locked --all-targets` passed with 0 warnings on `helios --features runtime-core,server`, `heliopause --lib`, `flare`, and `flare-cli`. - `cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server`: 1,740/1,740 lib tests passed (1,739 with `io_uring` + 1 non-root chmod test) and all integration tests passed (excluding the 9 HF-template fixture tests requiring `FLARE_TEST_TEMPLATE_DIR`). - `cargo test --locked --release --manifest-path flare/Cargo.toml`: 245/245 passed. - `cargo test --locked --release --manifest-path flare-cli/Cargo.toml`: all 201 unit tests (across root and non-root permission contexts) and all 4 integration test suites passed. Limitations: - New gated CUDA transfer tests (`split_pools_cost_each_device_its_part_and_round_trip_units` and `gated_cpu_and_gpu_codec_capture_and_restore_defer_while_peer_graph_holds_gate`) and an A/B peer-copy offload latency comparison have not yet been executed on this commit because the SM120 host GPUs are currently occupied by another job; the earlier SM120 CUDA `offload::` tests and live `Qwen3.8-Flash-Next` TP2 / `GLM-5.3-Flash` TP2 runs passed on `1870a27`. Signed-off-by: yatesdr <6937857+yatesdr@users.noreply.github.com> Design-Signed-Off-By: yatesdr; design-review=2e5b
|
Addressed the Autobot review findings in
Validation on
Discord: D-Rock |
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedHead
Walkthrough
Merge Risk: Medium · up to
|
Fixes #627
Problem and approach
On discrete PCIe SM120 GPUs (RTX PRO 6000, CUDA driver
595.99.02), tensor-parallel CUDA graphs whose collectives execute in-graph peer-to-peer Copy Engine nodes (Node::Copywith aMemory::Peerendpoint, such asb12xPCIeDmaAllReducepaired withFlagLaunchSM spin-waits) deadlock when Helios prefix-cache offload workers issue concurrent host-device Copy Engine batches on the same devices. Node-level frontier probes and controlled copy-path ablations isolated the stall specifically to concurrent Copy Engine DMA submission during peer-copy graph execution.Coordinating host offload batches against peer-copy graph execution directly in Helios resolves the deadlock for already-exported model packages without changing the package format, Protobuf contract, scheduling policy, or per-model behavior.
Summary of changes
helios/src/runtime_core/mod.rs,helios/src/runtime_core/serving.rs,helios/src/execution/manifest.rs): During CUDA graph reconstruction inNativeResources, recordpeer_copy_graphs[i] = truewhenever anyNode::Copynode in graphihas aMemory::Peersource or destination. Exposepeer_copy_graphsandhas_peer_copiesonExecutionManifest(defaulting absent entries tofalsefor non-core manifests).helios/src/offload/copy_gate.rs,helios/src/offload/mod.rs,helios/src/runtime_core/model.rs,helios/src/server/runtime.rs): AddCopyEngineGatewith RAIIPeerGraphGuardandOffloadBatchGuardleases. Multiple offload workers holdOffloadBatchGuardconcurrently across ranks while no peer-copy graph is waiting or active; waiting peer-copy graphs take priority over new offload batches and wait only for in-flight batches to drain. Share oneArc<CopyEngineGate>perNativeModelacrossRankExecutor, localoffload::Binding/offload::open_with_gate, andNativeModel::attach_offload(Selene pool workers).helios/src/execution/ranks.rs): Unionpeer_copy_graphsacross localRankPeers::Threadsmanifests so asymmetric peer copies are covered. Acquire aPeerGraphGuardinRankExecutor::submitonly when the submitted graph contains peer copies, release completed leases inRankExecutor::poll, and release remaining leases inRankExecutor::closeafterinner.close()drains. Graphs without peer-copy nodes do not touch the gate.helios/src/offload/transfer.rs,helios/src/offload/transfer/codec.rs): AcquireOffloadBatchGuardperBATCH_BYTESbatch in uncompressedRankWorker::run, CPU-codeccopy_spans_batch, and all five GPU-codec capture/restore entry points. Preserve strict lock ordering (gpu.codecbeforeCopyEngineGate) to prevent lock inversion againsttry_lock, and drain the offload stream before releasing the guard on error.Resulting behavior
Validation
RUSTFLAGS="-D warnings"):cargo check --locked --all-targetspassed with 0 warnings onhelios --features runtime-core,server,flare,flare-cli, andheliopause --lib.heliosoffload::copy_gate+execution::ranks: 5/5 passed (multi-rank concurrency, peer-graph wait/drain, priority under continuous offload, panic-unwind release, asymmetric rank union).heliosserver::runtime+execution::threaded: 162/162 passed.flare: 245/245 passed.flare-cli: 200/201 passed under root and 200/201 passed under non-root (all 201 distinct tests passed across the two permission contexts).FLARE_RUN_CUDA_TESTS=1):heliosoffload::passed 19/19 default tests plus 6/6 ignoredoffload::transfer::CPU/GPU KV codec and multi-GPU split-pool tests.--gpus 0,1,--prefix-cache-memory 4G, 16 GiB disk tier):Qwen3.8-Flash-NextTP2 (--lossless-kv-compression off): cold, warm (0/6pos0 mismatches,5.08xspeedup), restart + disk restore (0/6pos0 mismatches,2.45xspeedup), 8-way burst with 2 aborts (8/8,4.15 s), and 5x 8-way uncached 6,578-token bursts (40/40HTTP 200,4.68–4.83 s/burst; unpatchedmaindeadlocked during the first burst).GLM-5.3-FlashTP2 (--lossless-kv-compression gpu): cold, warm (0/96token mismatches,3.50xspeedup), restart + restore (0/96token mismatches,1.55xspeedup), and 8-way burst with 2 aborts (8/8,5.88 s).Limitations
CopyEngineGatewiring and passed unit and CUDA codec tests).Discord: D-Rock