Recommendation: Changes Requested
The structural peer-copy detection, RAII gate primitives, strict gpu.codec → CopyEngineGate lock ordering, GPU-codec stream drains, and executor.close()-before-store.close() shutdown sequence are cleanly engineered and target a real SM120 P1 deadlock (#627) without breaking existing exported cores. However, head 1870a27 introduces indefinite offload starvation under pipelined TP decode (freezing both inbound restores and pinned outbound checkpoint unpins), unconditionally adds per-16 MiB blocking event.synchronize() overhead to every prefix-cache deployment including single-GPU/non-peer-copy runs without benchmark evidence, and has a failing CI run with incomplete release/lifecycle verification gates.
Merge Risk
Level: High
- Serving & prefix-cache liveness regression under TP pipelining:
CopyEngineGate::enter_offload_batch(helios/src/offload/copy_gate.rs:60-67) gives strict priority to peer-copy graphs whileThreadedExecutorsupports 2-frame decode pipelining (helios/src/execution/threaded/protocol.rs:28), keepingpeer_graphs_active >= 1continuously during sustained TP decode and starving both inbound restores (store.fetch) and outbound checkpoint unpins. - Hot-path regression for all prefix-cache users:
NativeModelattachesSome(copy_gate)unconditionally (helios/src/runtime_core/model.rs:986-989, 1032-1038), converting every 16 MiBBATCH_BYTESbatch (helios/src/cuda.rs:169) into a blockingrecord+event.synchronize()on every prefix-cache run—including single-GPU and non-peer-copy TP runs—directly opposing #497's latency tuning with zero A/B offload measurement. - Worker-thread blocking & failing CI:
RankExecutor::submitnow blocks the model worker thread on an unboundedCondvar::waitoutsideThreadedExecutor's 120 s stall detector (helios/src/execution/threaded.rs:23, 942-952), reversing documented invariants without doc updates, and CI failed on head1870a27.
Walkthrough
- Structural peer-copy graph detection (
helios/src/runtime_core/mod.rs:119, 919, 1149-1156, 1238,helios/src/runtime_core/serving.rs:49, 59, 202,helios/src/execution/manifest.rs:436-449): Recordspeer_copy_graphs[i] = trueduring CUDA graph reconstruction whenever anyNode::Copyreferences aMemory::Peerallocation, exposespeer_copy_graphsandhas_peer_copiesonExecutionManifest(defaulting absent entries tofalse), and initializesVec::new()in non-core test/Heliopause manifest literals (heliopause/src/python.rs:331,helios/src/execution/tests.rs:206,helios/src/model/contract.rs:983,helios/src/model/testing.rs:396). - Per-model Copy Engine gate (
helios/src/offload/copy_gate.rs:1-263,helios/src/offload/mod.rs:19-60, 114-130,helios/src/runtime_core/model.rs:27, 662, 985-991, 1032-1038,helios/src/server/runtime.rs:715-733): AddsCopyEngineGatewith RAIIPeerGraphGuardandOffloadBatchGuardleases and shares oneArc<CopyEngineGate>perNativeModelacrossoffload::Binding,offload::open_with_gate, andNativeModel::attach_offload(Selene pool peer workers viaselene/src/offload.rs:943→selene/src/pool/builder.rs:235). - Execution boundary (
helios/src/execution/ranks.rs:26-181): WrapsRankExecutorInner, unionspeer_copy_graphsacrossRankPeers::Threadsmanifests (merge_peer_copy_graphs), acquiresPeerGraphGuardinsubmitonly for flagged graphs, pops completed leases in fence order inpoll, and clears residual leases incloseafterinner.close()drains (and beforeworker.close_storeruns athelios/src/server/runtime.rs:775-776). - Offload transfer gating (
helios/src/offload/transfer.rs:293-436, 480-555, 2070-2113,helios/src/offload/transfer/codec.rs:153-370, 533-795, 958-1031): ThreadsOption<&CopyEngineGate>into uncompressedRankWorker::run, CPU-codeccopy_spans_batch, and all five GPU-codec encode/decode entry points, preservinggpu.codec→CopyEngineGatelock order and draining the stream before releasing the lease on both success and error.
Pre-merge Checks
- [PASS] Security / malicious screen: Pure host-side synchronization and metadata wiring; no new dependencies, external I/O, wire/Protobuf changes, or prompt-injection attempts.
- [WARN] Charter & value fit: Model-agnostic Helios fix targeting SM120 workstation hardware with preserved core compatibility (#267/#334 respected), but carries the
performancelabel without an A/B offload throughput/latency benchmark (#210), leaves the underlying driver/CE mechanism uncharacterized (#397—worth explicitly acknowledging as a coordination mitigation), and reverses a documented non-blocking worker invariant without updatingdocs/. - [PASS] Related / duplicate / conflict check: No competing or duplicate PR; builds cleanly on #504/#525/#527 and #497; base
c146d7bis one commit behindmain(#626, orthogonalserver/runtime.rshunk) and does not textually collide with open #621. - [WARN] Tests & verification evidence: The 5 new unit tests (
copy_gate.rs,ranks.rs) are well-isolated with no global state mutation, but they never exercise the gated offload transfer arms orRankExecutorlease lifecycle; the PR reportscargo checkand narrow test filters rather than full--locked --releasecrate suites (docs/design-review.md:180-186) orhelios-lifecycle.ymlchecks; and CI failed on head1870a27.
Blockers
-
Indefinite offload starvation under pipelined / sustained peer-copy graphs freezes both inbound restores and pinned GPU checkpoints (
helios/src/offload/copy_gate.rs:60-67,helios/src/execution/ranks.rs:90-124,helios/src/execution/threaded/protocol.rs:23-38,helios/src/server/runtime.rs:1170-1181,selene/src/memory.rs:1463-1489).- Verified behavior & impact:
enter_offload_batchblocks wheneverpeer_graphs_active > 0 || peer_graphs_waiting > 0with strict peer-graph priority and no aging or fairness window.ThreadedExecutorpermits 2-frame pipelining (pending.len() < 2) forDecode/Speculativegraphs (protocol.rs:28), andWorker::runexecutesexecutor.poll()(runtime.rs:1170) andself.submit()(runtime.rs:1180) in the same loop iteration. When two peer-copy decode frames are pipelined, completing frame $N$ only dropspeer_graphs_activefrom2to1and frame $N+2$ immediately bumps it back to2—sopeer_graphs_activenever reaches0for the entire duration of active generation (and even at depth 1,submit()re-acquirespeer_graphs_waitingmicroseconds afterpoll()notifies). Becauseselene/src/memory.rs:1463-1489keeps queued windows pending whilein_flight_jobs() > 0, outbound captures keep GPU checkpoints pinned indefinitely (blocking page reclamation) and newly arriving requests with prefix-cache hits have theirstore.fetchrestores starved until all active decode finishes—turning prefix-cache hits into unbounded TTFT head-of-line blocking. - Concrete fix: Add bounded fairness/aging to
CopyEngineGate(e.g., trackoffload_batches_waitingand allow waiting offload batches—prioritizing inbound restores or draining one window after $N$ consecutive peer graphs / $T$ ms—to take a turn before admitting the next peer-copy graph, temporarily pausing pipelining at that boundary sopeer_graphs_activereaches0), and add a unit test proving offload makes bounded forward progress under a continuous 2-frame pipelined peer-graph stream.
- Verified behavior & impact:
-
Unconditional per-16 MiB blocking
event.synchronize()on every prefix-cache deployment (including single-GPU and non-peer-copy models) without benchmark evidence (helios/src/runtime_core/model.rs:662, 986-989, 1032-1038,helios/src/server/runtime.rs:719-731,helios/src/offload/transfer.rs:398-434,helios/src/offload/transfer/codec.rs:978-1028,helios/src/cuda.rs:169).- Verified behavior & impact:
NativeModelunconditionally passesSome(Arc::clone(&self.copy_gate))toBinding::newandCopiers::with_gateeven when zero graphs in any rank have peer-copy nodes (all single-GPU runs and non-peer-copy TP runs). As a result,RankWorker::runandcopy_spans_batchalways execute the gated branch: acquiring a mutex and callingstream.record(&event)+ blockingevent.synchronize()everyBATCH_BYTES(16 MiB,cuda.rs:169) instead of once per window (transfer.rs:431-434,codec.rs:1025-1028). A 1 GiB checkpoint window becomes 64 blocking host-GPU syncs instead of 1, contradicting the PR's claim of "zero gate overhead on graphs without peer-copy nodes" and risking a restore-latency regression against #497 with no measured offload throughput/latency comparison. - Concrete fix: Only wire
Some(Arc::clone(&self.copy_gate))when at least one rank has a peer-copy graph (self.ranks.iter().any(|r| r.has_any_peer_copy_graphs())); passNoneotherwise so single-GPU and non-peer-copy models stay on the ungated single-sync fast path. For peer-copy models where the gate is active, attach an A/B offload capture/restore latency measurement againstmain(or remove theperformancelabel and document the measured per-batch sync overhead).
- Verified behavior & impact:
-
CI failed on head
1870a27and mandatory release/lifecycle verification gates were not run in full (docs/design-review.md:180-186, 234-251,.github/workflows/native-serving.yml:63(not opened),.github/workflows/helios-lifecycle.yml:34 (not opened), 47).- Verified behavior & impact: The case file records CI as failed on
1870a27, and the PR Validation section reportscargo checkplus narrow test filters (offload::copy_gate,execution::ranks,server::runtime,execution::threaded) rather than the fullcargo test --locked --release --manifest-path helios/Cargo.toml (not opened) --features runtime-core,serversuite andverification/helios-lifecycle/check.py(not opened) /cargo kanigates triggered byhelios/**. - Concrete fix: Fix the CI failure on head, run the full
--locked --releasecrate test suites andhelios-lifecycle.ymlchecks perdocs/design-review.md, and ensure GitHub Actions is green before merge.
- Verified behavior & impact: The case file records CI as failed on
Should Fix
-
Unbounded
Condvar::waiton the model worker thread bypasses the 120 s stall detector and contradicts documented offload invariants (helios/src/offload/copy_gate.rs:45-56,helios/src/execution/ranks.rs:90-101,helios/src/execution/threaded.rs:23, 942-952,helios/src/offload/transfer.rs:14-19,docs/prefix-cache-offload.md:133, 907, 1015,docs/same-process-tp.md:177-180).- Verified behavior & impact:
CopyEngineGate::enter_peer_graphloops onself.changed.wait(state)with no timeout on the serving worker thread insideRankExecutor::submit, beforeinner.submitruns.ThreadedExecutor::poll_ranks'sTIMEOUT = 120sdeadline cannot trigger while the worker thread is parked insubmit, so a wedged offload CUDA copy turns a prefix-cache failure into a permanent silent serving hang. Meanwhile,helios/src/offload/transfer.rs:14-19anddocs/prefix-cache-offload.md:133, 907, 1015still promise "Offload work never blocks the model worker thread or the model stream" anddocs/same-process-tp.md:177-180leaves the qualification list unupdated. - Concrete fix: Use a bounded
Condvar::wait_timeoutinenter_peer_graph(returning an explicitResult<PeerGraphGuard>error/diagnostic if an offload batch fails to drain within a bound aligned withTIMEOUT), and updatehelios/src/offload/transfer.rs:14-19,docs/prefix-cache-offload.md:133, 907, 1015, anddocs/same-process-tp.md:177-180to document the bounded peer-copy coordination contract.
- Verified behavior & impact:
-
Gate wait duration distorts KV codec transform metrics, Selene tier bandwidth rates (
worth_fetchingadmission pricing), andprefill_rate(helios/src/offload/transfer/codec.rs:283-302, 315-335, 349-369, 664-688, 749-769,helios/src/server/metrics.rs:686-690,helios/src/offload/transfer.rs:652, 754,selene/src/memory.rs:1451-1457,selene/src/levels.rs:34, 57-75,selene/src/store.rs:424-442,helios/src/server/runtime.rs:2293-2295, 2353, 2646-2657).- Verified behavior & impact:
- All five GPU-codec timing sites in
codec.rscapturelet start = Instant::now()beforeenter_offload_batch(), attributing gate wait time toflare_kv_codec_transform_nanoseconds_total(metrics.rs:686-690). Transfers::absorbreportselapsed: pending.started.elapsed()(transfer.rs:754), which now includes arbitrary gate pauses.MemoryStore::absorbfeeds that directly intoinbound_rate/outbound_rate(selene/src/memory.rs:1452, 1455), a 3-sample median (levels.rs:57-68) with a10 sdoubling recovery (levels.rs:34, 69-75). Contended restores depressinbound_rate, causingworth_fetching(store.rs:441) to reject worthwhile prefix-cache hits during busy bursts.- Conversely,
Worker::submitpushesInstant::now()intoself.prefill_started(runtime.rs:2293-2295) beforeexecutor.submit()(runtime.rs:2353), so blocking inenter_peer_graph()also depressesself.prefill_rate(runtime.rs:2646-2657).
- All five GPU-codec timing sites in
- Concrete fix: Move
let start = Instant::now()after_ceacquisition in all fivecodec.rssites; track cumulative gate wait time per job/rank and subtract it fromReply.elapsed(or report it separately) soRate::observemeasures actual transfer throughput; and recordprefill_startedafterexecutor.submit()(or after acquiringPeerGraphGuard).
- Verified behavior & impact:
-
Zero test coverage of gated offload copy paths and
RankExecutorlease lifecycle (helios/src/offload/gpu_tests.rs:126 (not opened), 286, 456, 588, 650, 856, 1004, 1266, 1271, 1558,helios/src/offload/transfer.rs:1507, 1850,helios/src/offload/transfer/codec.rs:1129, 1133, 1249, 1359, 1363,helios/src/execution/ranks.rs:108-124, 170-181).- Verified behavior & impact: Every test in
gpu_tests.rs(not opened),transfer.rs, andcodec.rscallsCopiers::new(...)(copy_gate = None), so the new gated copy/sync/drain-on-drop branches intransfer.rs:398-428andcodec.rs:978-989and all five GPU-codec gate acquisitions are completely unexercised by tests. Likewise,ranks.rs:189only testsmerge_peer_copy_graphs, leavingRankExecutor's fence-orderedpoll()release andclose()cleanup untested. - Concrete fix: Add at least one test driving
Copiers::with_gate(..., Some(gate))(verifying that holdingPeerGraphGuarddefers offload batches until dropped, and verifying stream drain before gate release on error) plus aRankExecutorlifecycle test verifyingPeerGraphGuardrelease onpoll()completion andclose().
- Verified behavior & impact: Every test in
-
Multi-host peer ranks (
serve_rank+offload::shard::join_peer) remain ungated (helios/src/offload/shard.rs:47,flare-cli/src/cluster.rs:254,flare-cli/src/main.rs:559-561,helios/src/execution/parallel.rs:546-685).- Verified behavior & impact: Multi-host peer ranks run
serve_rankdirectly onGraphExecutor(bypassingRankExecutor) and constructCopiers::new(gpu_cubins)inshard::join_peer, so neither their local graph submissions nor their disk-store transfers touchCopyEngineGate. - Concrete fix: Either wire
CopyEngineGateintoshard::join_peerandserve_rankfor per-process rank coordination, or explicitly document in the PR description and offload docs thatCopyEngineGatecovers only single-host threaded TP (RankPeers::Threads) and does not protect multi-host peer ranks.
- Verified behavior & impact: Multi-host peer ranks run
Subtract / Simplify
- Deduplicate
DrainOnDrop/Fenceand three copies ofunsafe { stream.copy_batch(...) }(helios/src/offload/transfer.rs:398-428, 440-444,helios/src/offload/transfer/codec.rs:966-1001):RankWorker::rundefines a nestedstruct DrainOnDropinside the batch loop whoseDropbody repeatsRankWorker::drain()(transfer.rs:440-444), and bothtransfer.rs:398-428andcodec.rs:976-1001duplicate the entire gated/ungatedcopy_batch+SAFETYblock. Extract one crate-visiblecopy_batch_gated(stream, event, gate, dsts, srcs, lens)helper so both call sites collapse to one line while preservingrecord/synchronizeerror propagation on success and drain-before-gate-release on error. - Delete dead public method
ExecutionManifest::has_peer_copies(helios/src/execution/manifest.rs:445-449,helios/src/execution/ranks.rs:90, 198-200):has_peer_copieshas zero production callers—its only references are three assertions in this PR's own test (ranks.rs:198-200), whileRankExecutor::submit(ranks.rs:90) spells.get(graph).copied().unwrap_or(false)inline on the mergedVec<bool>. Delete the unused method and its test assertions. - Move pure-delegation
match &self.innermethods ontoRankExecutorInner(helios/src/execution/ranks.rs:126-168):park,outstanding,manifest,can_submit, andnext_fencedo not touchcopy_gateorpeer_guards; moving the variant matches intoimpl RankExecutorInnerreducesRankExecutorto one-line forwarding and trims ~20 lines of diff churn.
Nits
- Remove unused
OffloadBatchGuardfrom the re-export athelios/src/offload/mod.rs:26—no call site outsidecopy_gate.rsnames the type. - Validate
self.peer_copy_graphs.is_empty() || self.peer_copy_graphs.len() == self.graphs.len()inExecutionManifest::validate()(helios/src/execution/manifest.rs:436-449) so a truncated vector cannot silently leave higher-indexed graphs unprotected.
Dropped on verification
- Upstream F6 (
gpu.codeclock ordering inhelios/src/offload/transfer/codec.rs:666-668, 751-752): Dropped as factually wrong and dangerous.SharedGpuCodecs(codec.rs:22, 113-124) is keyed by(context, rank)(per-rank, not a single global mutex across all ranks),try_lock()falls back to CPU decode rather than blocking, and the suggested "acquireCopyEngineGatebeforegpu.codec" fix would introduce a 3-way deadlock (Thread AholdingOffloadBatchGuardwaiting ongpu.codec.lock()↔Thread Bholdinggpu.codecwaiting onCopyEngineGatebecausepeer_graphs_waiting > 0↔ model worker waiting onOffloadBatchGuard). The author'sgpu.codec→CopyEngineGateordering is correct. - Upstream F5b claim on
heliopause/src/python.rs:331("offload still pays per-batch cost while Python manifests disable detection"): Dropped as false.heliopause/src/python.rs:318setsoffload: None, so Python-built manifests have no offload binding and incur no gate cost;peer_copy_graphs: Vec::new()matchesmanifest.rs:437-438. - Upstream claim of a textual merge collision with open PR #621 in
helios/src/execution/manifest.rs: Dropped as false. PR #621 addsGraphKind::is_text_forward()around lines89-104, ~330 lines away from #628'sExecutionManifestfield at lines436-449. - Upstream F2 claim that
QUEUE_DEPTHrefusal (transfer.rs:641-645) immediately fails and abandons stores (host_retry_abandoned[5]): Corrected on verification.selene/src/memory.rs:1463-1489only fails a job on refusal whenself.in_flight_jobs() == 0; while workers are paused onCopyEngineGate,in_flight_jobs() > 0, so queued windows remain pending—keeping GPU checkpoints pinned and starving inbound restores instead of failing immediately. - Verified sound (not flagged): All four GPU-codec methods (
gpu_codec.rs:911, 926, 1172, 1628, 1658, 1985) plussync_on_err(codec.rs:812-817) synchronize the stream before_cedrops;Workerteardown (server/runtime.rs:775-776) callsexecutor.close()(clearingpeer_guardsatranks.rs:178) strictly beforeworker.close_store()callsstore.close(); and Selene pool peer workers (runtime_core/model.rs:985-991→selene/src/offload.rs:943→selene/src/pool/builder.rs:235) do inherit the gatedCopiers.