Opened by a workflow run, Nov 29, 2026 9:42 PM EST.
Classify draft
Selected: priority:P1, bug, performance
Threshold: 65%
Priority
- [✓]
priority:P1: 65.1% -
priority:P2: 30.7% -
none: 4.2%
Type
- [✓]
bug: 98.4% - [✓]
performance: 94.7% -
community: 9.5% -
enhancement: 2.6% -
duplicate: 0.5% -
documentation: 0.0%
Area
-
area:caching: 59.3% -
area:selene: 40.7% -
area:preparation: 13.3% -
area:memory: 8.5% -
area:api: 3.3% -
area:kernels: 3.3% -
area:scheduling: 2.0% -
area:rocenante: 1.8% -
area:orbit: 0.4% -
area:packaging: 0.3% -
area:engram: 0.2%
Model
-
model:mimo-v2.6: 1.0% -
model:qwen3.8-27b: 1.0% -
model:glm-5.3: 0.9% -
model:inkling-small: 0.5% -
model:nemotron-3.5-bolt: 0.5% -
model:kimi-k3.1: 0.5% -
model:muse-glimmer: 0.4% -
model:gemma4: 0.4% -
model:deepseek-v4: 0.2% -
model:qwen3.8-flash-next: 0.2% -
model:deepseek-v4.1: 0.2% decide malicious: all_clear (100%): No malicious content found
explore
Author: yatesdr (COLLABORATOR; owner of the Selene host prefix-cache tiers, 80 merged PRs in 180 days); Discord D-Rock Motivation: On SM120 PCIe GPUs, tensor-parallel CUDA graphs whose collectives move data peer-to-peer through in-graph Copy Engine nodes deadlock when prefix-cache offload workers submit concurrent host-device Copy Engine batches on the same devices. This PR adds a per-model lock that pauses offload batches while such a graph runs. Scale: +572 / −72 lines in 14 files Proposal:
- New
helios/src/offload/copy_gate.rs:CopyEngineGatewith RAIIPeerGraphGuard(waits for in-flight offload batches, takes priority) andOffloadBatchGuard(concurrent across ranks, blocked while a peer graph waits/runs). - Mark graphs structurally during reconstruction: any
Node::Copywith aMemory::Peerendpoint setspeer_copy_graphs[i]; exposed onExecutionManifest(has_peer_copies), absent ⇒ false. - Union flags across local
RankPeers::Threadsmanifests; acquire the guard inRankExecutor::submit, release inpoll/close. - Gate the uncompressed, CPU-codec and five GPU-codec offload copy sites per 16 MiB batch with a per-batch event sync.
- One shared
Arc<CopyEngineGate>perNativeModel, threaded throughBinding,open_with_gateandattach_offload; no Protobuf, package-format or flag change. Touches: helios/src/offload/(copy_gate.rs new; transfer.rs, transfer/codec.rs copy paths now synchronize per batch)helios/src/execution/(ranks.rs executor restructure, manifest.rs new public field)helios/src/runtime_core/+server/runtime.rs(detection and gate plumbing) Related items:- #627 helios: TP2 prefill CUDA graphs using in-graph peer Copy Engine nodes deadlock… (open): the bug this fixes, same author, same day
- #497 Reduce disk offload restore latency and integrated-memory intake overhead (merged): retunes the same worker for latency; this PR adds per-batch syncs to it
- #621 entry (open): edits the same
ExecutionManifeststruct — textual collision expected - #504 pure-CUDA lossless KV compression (merged): the codec the five GPU gate sites live in
- #626 Allow speculative reasoning for grammar-constrained requests (merged): only commit landed since the branch point, same
server/runtime.rsLink: https://github.com/NVIDIA/hyperflare-inference/pull/628 Autobot comments: Not in the description: (1)docs/prefix-cache-offload.md:133,907,1015promises "offload work never blocks the model worker thread" — the model worker now blocks inenter_peer_graph()until offload batches drain, and no doc is updated; (2) offload copies synchronize per 16 MiB batch for every prefix-cache run (gate is alwaysSome), contradicting "zero gate overhead" for that path and pulling against #497, with no throughput measurement; (3) the multi-host disk-store peer path (offload/shard.rs:47, used by flare-cli) and the Heliopause/Python manifest path (python.rs:331sendspeer_copy_graphs: Vec::new()) stay ungated, despite the claim that pool and CPU-codec paths share the wiring; (4) detection covers only literalNode::Copynodes onMemory::Peerallocations; (5) the gate is per-process, so multi-process TP is not coordinated; (6) charter root-cause rule (#397) and performance-evidence rule (#210) are not clearly satisfied — #627's own ablation shows a cross-rank offload mutex still deadlocked, and the only comparison is unpatchedmaindeadlocking; (7) CI failed on head1870a27while the description reports clean local checks and test runs with no attached logs. Zero comments/reviews and no bot case-file yet.
Classify intake
Selected: triage:review, priority:P1, bug, performance
Threshold: 65%
Triage
- [✓]
triage:review: 98.9% -
triage:design-review: 0.7% -
triage:validation: 0.3% -
triage:investigate: 0.1% -
none: 0.0% -
triage:integration: 0.0% -
triage:partial: 0.0% -
triage:verify-for-closure: 0.0% -
triage:superseded: 0.0%
Priority
- [✓]
priority:P1: 89.6% -
priority:P2: 8.3% -
none: 2.1%
Type
- [✓]
bug: 97.1% - [✓]
performance: 79.8% -
community: 20.2% -
duplicate: 4.7% -
enhancement: 0.3% -
documentation: 0.1%
Area
-
area:selene: 53.1% -
area:caching: 46.9% -
area:preparation: 32.1% -
area:rocenante: 5.3% -
area:api: 2.6% -
area:kernels: 2.6% -
area:scheduling: 1.6% -
area:memory: 1.4% -
area:packaging: 0.5% -
area:orbit: 0.3% -
area:engram: 0.1%
Model
-
model:glm-5.3: 7.6% -
model:qwen3.8-flash-next: 2.9% -
model:kimi-k3.1: 2.6% -
model:mimo-v2.6: 1.6% -
model:deepseek-v4: 0.9% -
model:inkling-small: 0.9% -
model:gemma4: 0.6% -
model:qwen3.8-27b: 0.5% -
model:deepseek-v4.1: 0.4% -
model:nemotron-3.5-bolt: 0.4% -
model:muse-glimmer: 0.3%
Value Proposition
Value Proposition — PR #628 helios: gate offload Copy Engine batches during peer-copy graphs
Verdict: Worth it with changes
Charter alignment. The change lands in Helios (scheduling/offload), not in recipes, carries no per-model branch, adds no flag, and changes no Protobuf or package format — so it respects the runtime-vs-recipes split (#267/#334) and the "smallest footprint in shared code" rule. It targets SM120 PCIe workstations, the charter's stated focus, and fixes a reproducible P1 deadlock (#627), the class of change the charter says gets merged. Two tensions are real: the fix coordinates around the Copy Engine conflict rather than root-causing it — #627's own ablation shows serializing offload against itself still deadlocked — which sits uneasily with #397; and it inverts a documented invariant (docs/prefix-cache-offload.md:133, 907, 1015 promise the model stream never waits on offload, but RankExecutor::submit now blocks until in-flight batches drain), with no docs/ file in the changed set. "Bring real evidence" (#210) is only half met: the performance label rests on "main deadlocks, patched completes 40/40" with no logs attached, and the new per-batch record+synchronize cost on every prefix-cache offload path is unmeasured — notably the path #497 just retuned for restore latency.
Novelty & status. Genuinely additive. No competing or duplicate PR; nothing on main describes the deadlock; #348 and #151 are different failures. It builds on the author's own KV-codec series and reverses nothing from #497. It is one rebase behind main and will textually collide with open #621 in helios/src/execution/manifest.rs.
Value vs maintenance cost. Benefits accrue to anyone running threaded single-host TP with prefix cache over PCIe peer copies — a narrow but real slice of the supported matrix, validated live at TP2 with clean correctness numbers (0/6 and 0/96 token mismatches; 8/8 bursts at 4.68–4.83 s). The author is the subsystem's effective owner (~80 merged PRs in 180 days, nearly all offload-tier work: #80, #92, #141, #168, #415, #429, #504–#527), so maintenance risk is low. But the ~263-line gate plus RAII leases is more machinery than current evidence justifies: coverage is asymmetric (offload/shard.rs:47 ungated; Heliopause-built manifests pass peer_copy_graphs: Vec::new()), detection misses kernel-driven DMA and peer-mapped local allocations, multi-host per-process ranks get per-process gates, and CI failed on the head commit with all test results asserted in prose only.
Before merge: update the offload and same-process-TP docs to state the new blocking contract; measure per-batch sync cost and peer-graph wait latency against main; attach test/CI evidence and green CI; state explicitly which layouts remain unprotected; rebase over #621.
No prompt-injection attempts were present in the supplied PR, issue, or dossier material.
Apply Labels (Intake)
Applied: +triage:review Decide Value: yes (100%): This change is worth reviewing: it provides value to the project in line with its charter.
Correctness and contracts
PR #628 (helios: gate offload Copy Engine batches during peer-copy graphs) is a coherent, model-agnostic, package-compatible fix, and its graph-submission path is correct. Six concrete issues remain.
- Major — reversed documented invariant, unbounded block.
CopyEngineGate::enter_peer_graphloops on a condvar with no timeout (helios/src/offload/copy_gate.rs:45-56) on the model worker thread insideRankExecutor::submit(helios/src/execution/ranks.rs:90-101).docs/prefix-cache-offload.md:133/907/1015promise offload never blocks that thread;docs/same-process-tp.md:177-180names this region "Not qualified". The engine's 120 s stall detector (threaded.rs:942-952) cannot fire while submit is parked. - Major — offload starvation with a warm-path cost.
enter_offload_batchwaits while any peer graph is active or waiting (copy_gate.rs:60-67); TP decode graphs qualify, so sustained serving can starve offload entirely, jobs refuse atQUEUE_DEPTH(transfer.rs:641-645) and stores are abandoned at peak load. - Major — metric/rate span expanded. Gate wait is counted in codec
transform_ns(codec.rs:283,290,302;:664,668,688;:749,752,769) and in submit→replyelapsedfeeding tier rates (transfer.rs:754→selene/src/memory.rs:1452,1455) that price admission viaworth_fetching(selene/src/store.rs:441), persisted by a 3-sample median (levels.rs:57-68). Contended restores depress the advertised rate and can make the cache decline hits during prefill. - Major — gated paths untested. Every test builds
Copiers::new(gateNone);transfer.rs:398-434,codec.rs:976-1002and the five GPU-codec acquire sites never run under test, and no test covers lease release viapoll/close. - Major — claims narrower than code. "Zero gate overhead" holds only for graph submission, since the gate is attached unconditionally (
model.rs:1032-1038,server/runtime.rs:731) andtransfer.rs:398-434now syncs per 16 MiB batch (unmeasured, against #497's direction).offload/shard.rs:47is ungated andheliopause/src/python.rs:331disables detection. - Minor — the batch lease is acquired while holding the shared
gpu.codecmutex (codec.rs:666-668,:751-752), serializing other ranks' codec work; andpeer_copy_graphsis never length-validated (manifest.rs:436-449), so a short vector silently disables the gate.
Sound: fence-ordered release, no guard leak on backpressure, correct index alignment, real backward compatibility, consistent lock ordering, correct drain-before-release.
Open: which CI job failed; unmeasured per-batch cost; whether Memory::Peer detection covers all real peer transfers; multi-host/pool/CPU-codec/non-SM120 untested.
Subtraction and simplicity
Reviewed PR #628 for subtraction/simplicity/conventions. The diff is lean overall — no new flag, env var, CLI option, Protobuf or serde change, no dependency; the new offload/copy_gate.rs duplicates no existing repo abstraction and has no speculative generality. Four things can still go:
- HIGH
helios/src/offload/transfer.rs:398-428— astruct DrainOnDropdeclared inside the batch loop with a body identical to the pre-existingRankWorker::drain()(transfer.rs:440-444), plus the wholecopy_batchcall and its SAFETY comment duplicated into anelsearm;codec.rs:976-1001repeats the same gated/ungated split a third time. One smallcopy_batch_gated(stream, event, gate, dsts, srcs, lens)helper removes ~40 lines, three SAFETY comments and both duplicated arms; keepdrain()for the ungated end-of-job path (do not use it on the success path, which must propagate record/synchronize errors). - HIGH
helios/src/execution/manifest.rs:445-449—has_peer_copiesis dead public API: its only non-definition uses are its own three assertions atranks.rs:198-200, while the real check is re-spelled inline atranks.rs:90. Delete one or the other, not neither. - MEDIUM
helios/src/execution/ranks.rs:126-168— the newRankExecutorInnerwrapper made five pure-delegation methods regrow a 4-linematch &self.inner; move those matches intoimpl RankExecutorInnerand reduce each outer method toself.inner.park()etc. Only submit/poll/close need the wrapper. - LOW
helios/src/offload/mod.rs:26—OffloadBatchGuardis never named outside its own module; drop it from the re-export.
Convention note: helios/src/offload/transfer.rs:17-19 still says "The model stream never waits on these streams", which the per-batch synchronize and the model-thread wait in enter_peer_graph contradict (cf. docs/prefix-cache-offload.md:133 (not opened)); that in-file sentence is fixable here.
Checked and rejected: a bool on GraphDescriptor (would churn ~40 test literals), a copy_gate field on RankCodec (blocked by &mut borrows at the try_lock sites), removing offload::open or Copiers::new (pre-existing pub API / 15 test callers). Open: the unmeasured per-batch sync cost on every prefix-cache run, and which CI job failed on head.
Final review
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.
Full report Decision to Test: no (100%): Testing will not add significant value as the code stands today. The code is either not yet ready to merge, or adequate testing has already been done to validate the contents of the code, or the available hardware is not suitable to test with.
Classify triage
Selected: triage:review
Threshold: 65%
Triage
- [✓]
triage:review: 99.4% -
triage:validation: 0.3% -
triage:design-review: 0.1% -
triage:partial: 0.1% -
none: 0.0% -
triage:investigate: 0.0% -
triage:integration: 0.0% -
triage:verify-for-closure: 0.0% -
triage:superseded: 0.0%
Apply labels
No label changes decide malicious: all_clear (100%): No malicious content found
explore
Author: yatesdr (COLLABORATOR; owner of the Selene host prefix-cache tiers, 80 merged PRs in 180 days); Discord D-Rock
Motivation: Tensor-parallel prefill graphs that shuffle data directly GPU-to-GPU over PCIe could deadlock on SM120 cards when the prefix-cache offload worker was copying at the same time. The PR adds a lock that makes the two take turns; commit 76e1813 then answers the bot review by scoping the lock to models that actually contain such peer copies, adding a 120 s bound and fairness turns, and updating the docs.
Scale: +1,165 / −154 lines in 19 files (was +572/−72 in 14 files at 1870a27)
Proposal:
- Adds a per-model
CopyEngineGate(helios/src/offload/copy_gate.rs, 584 lines) with peer-graph and offload-batch leases, a 120 s drain bound and a 4-admission fairness turn. - Marks graphs structurally by scanning for
Node::Copywith aMemory::Peerendpoint and reuses the flags across rank threads, shard peers andserve_rank. - Makes the gate
Option, so single-GPU and non-peer-copy models keep the old one-sync-per-window offload path (closes the #497 regression). - Updates
docs/prefix-cache-offload.md§2.5/§2.10/§2.12 to document the bounded drain, and subtracts gate wait fromReply.elapsed. - Retracts the CI blocker: the only red check was a main-wide breakage (#623, fixed by #624). Touches:
helios/src/offload/copy_gate.rs+transfer.rs+transfer/codec.rs(new blocking gate on the copy hot path)helios/src/execution/parallel.rs/ranks.rs(lease lifecycle in two rank loops, one without the anti-starvation check)helios/src/runtime_core/model.rs+server/runtime.rs(gate creation and worker-failure propagation) Related items:- #627 SM120 TP2 prefill deadlock (open): the bug this fixes
- #497 disk offload restore latency (merged): retuned the same worker; no longer contradicted
- #624 Python CPU tests fix (merged): cleared the false CI red, with #623 (closed)
- #621 ExecutionManifest changes (open): textual rebase risk on
manifest.rs(not opened) - #334 per-rank manifests (open): shares
execution/ranks.rsLink: https://github.com/NVIDIA/hyperflare-inference/pull/628 Autobot comments: The anti-starvation mechanism only works in the in-process worker loop:RankExecutor::can_submit(ranks.rs:181-184) is the sole enabler, andserve_ranktakes the lease with no such check (parallel.rs:652-656), so multi-process/multi-host TP — newly gated by this same commit — can still starve offload indefinitely, and its fairness test simulates the pause rather than driving the real loop. Undocumented side effects: the lease is held across GPU-codec compute, not just a 16 MiB copy (codec.rs:288-303); a 120 sDrainerror now fails and tears down the served worker (runtime.rs:2332-2339,759-776);Reply.elapsedminus gate wait now feeds theworth_fetchingscheduling heuristic (transfer.rs:780,795-798). Still no performance measurement of any kind — the author says the A/B run is pending because the SM120 GPUs are busy — and the new gated tests are#[ignore]or two-device-gated, so no gated path has run anywhere. #627's ablations still show the Copy Engine mechanism is not root-caused.
Classify intake
Selected: triage:review, priority:P1, bug, performance
Threshold: 65%
Triage
- [✓]
triage:review: 94.3% -
triage:validation: 4.7% -
triage:design-review: 0.9% -
triage:investigate: 0.0% -
none: 0.0% -
triage:partial: 0.0% -
triage:integration: 0.0% -
triage:verify-for-closure: 0.0% -
triage:superseded: 0.0%
Priority
- [✓]
priority:P1: 88.9% -
priority:P2: 10.6% -
none: 0.5%
Type
- [✓]
bug: 89.3% - [✓]
performance: 75.5% -
community: 13.3% -
duplicate: 13.3% -
enhancement: 4.7% -
documentation: 0.2%
Area
-
area:caching: 56.2% -
area:scheduling: 56.2% -
area:preparation: 43.8% -
area:selene: 43.8% -
area:rocenante: 14.8% -
area:api: 13.3% -
area:memory: 10.7% -
area:orbit: 7.6% -
area:kernels: 5.3% -
area:packaging: 1.0% -
area:engram: 0.4%
Model
-
model:glm-5.3: 3.7% -
model:qwen3.8-flash-next: 2.9% -
model:qwen3.8-27b: 2.3% -
model:kimi-k3.1: 2.0% -
model:deepseek-v4.1: 1.6% -
model:mimo-v2.6: 0.5% -
model:inkling-small: 0.4% -
model:muse-glimmer: 0.4% -
model:deepseek-v4: 0.2% -
model:nemotron-3.5-bolt: 0.2% -
model:gemma4: 0.1%
Apply Labels (Intake)
No label changes
Value Proposition
Value Proposition — PR #628 "helios: gate offload Copy Engine batches during peer-copy graphs"
1. Charter alignment — in scope, right layer. The PR fixes #627, a TP2 prefill deadlock on discrete PCIe SM120 GPUs (the project's named target hardware) caused by host-device Copy Engine batches racing in-graph peer copies. It adds no recipes, aliases, backends, or per-model branches: detection is structural (Node::Copy with a Memory::Peer endpoint) and sits in Helios scheduling/offload/caches, with package format and Protobuf contract unchanged. Counterweight: a new 584-line copy_gate.rs threaded through five codec sites, both rank loops, and Selene pool wiring is a large addition to the very layer the charter asks to keep small.
2. Novelty & status — genuinely additive. #627 reproduces on unpatched main ("deadlocked during the first burst"); the dossier shows no merged fix and no competing open PR, so it is neither obsolete nor superseded. Five of the seven earlier bot findings were closed at 76e1813. Engagement is still bot-plus-author: no human review, no inline comment, no reaction.
3. Value vs maintenance cost. Beneficiaries are concrete — anyone serving prefix-cache offload on PCIe SM120 tensor-parallel — and evidence is strong for that one configuration: live TP2 Qwen3.8-Flash-Next and GLM-5.3-Flash runs with warm/restart restores (5.08x/2.45x, 3.50x/1.55x), 8-way bursts, 40/40 HTTP 200 where main deadlocked. It is weak where the charter is strictest: no A/B offload latency and no gate-cost figure (#210), and the root cause stays partly uncharacterised since cross-rank mutex serialization still deadlocked (#397). Gated verification is CI-invisible (#[ignore], two-GPU-only), and the author states the gated tests plus A/B measurement were not run on 76e1813 — so the newly gated multi-process, CPU-codec, Selene and multi-host paths have no runtime evidence.
Remaining risks are shared-runtime, not nits. Fairness depends on RankExecutor::can_submit (ranks.rs:181-184), but serve_rank takes the lease without it (parallel.rs:652-656), so offload can starve on RankPeers::Processes — the layout this same commit newly gates (cluster.rs:254-261 → shard.rs:47-61). A 120 s Drain propagates through Worker::submit into worker.fail_all and executor teardown (runtime.rs:2332-2339, 759-776), letting a stuck offload batch kill the served worker, undocumented. Docs promise a "bounded in-flight 16 MiB batch" drain while leases cover codec compute under gpu.codec (codec.rs:288-303,318-338,748-780). Gate wait is subtracted from Reply.elapsed and feeds Selene worth_fetching, unvalidated.
Verdict: Worth it with changes. The bug is fatal, reproducible, in-scope and unfixed elsewhere; the layer is right. Required before merge: honour the drain check in serve_rank (or scope the gate to RankPeers::Threads), degrade on gate timeout instead of failing the worker, correct the documented drain scope, run the gated codec/transfer tests plus one multi-process SM120 run, and supply A/B offload latency and gate-cost measurements per #210.
Full report Decide Value: yes (100%): This change is worth reviewing: it provides value to the project in line with its charter.
Subtraction and simplicity
Subtraction/Simplicity/Conventions review of PR #628 (head 76e1813, 19 files, +1,165/−154). The diff is mostly lean and its refactors are net-negative-line, but four slabs of self-inflicted complexity are removable, and every one of them is a deletion rather than a patch.
- Three pure-delegation wrappers were added instead of replacing their predecessors:
offload::open(helios/src/offload/mod.rs:114-119) has no caller at all in the repo (the one helios caller,server/runtime.rs:731, usesopen_with_gate);shard::join_peer(shard.rs:37-45) is test-only now thatflare-cli/src/cluster.rs:254usesjoin_peer_with_gate;Copiers::new(transfer.rs:2167-2171) is#[cfg(test)]and only forwardsNonetowith_gate. - "Gated ⇒ lease+sync per batch; ungated ⇒ one sync at window end" is implemented three times —
copy_batch_gated(transfer.rs:308-339, hand-rolledDrainOnDrop+mem::forget),copy_spans_batch(codec.rs:978-1033, a second, differently-shapedFenceguard, its own twois_none()tests and anothermem::forget), andRankWorker::run(transfer.rs:459-474) — absorbable into one smallGatedCopies { stream, event, gate }withbatch()/finish(). gate_wait/max_gate_waitis ~60 lines threaded through nine signatures and five restructured GPU-codec blocks, solely to subtract gate wait fromReply.elapsed(transfer.rs:795-798) — which feeds Selene'sworth_fetchingheuristic (selene/src/memory.rs:1450-1456), so a stalled transfer reports as faster. Delete the channel; keep timers where they are.- The fairness state machine (
copy_gate.rs:34-68,94-100,115-125,191-196,211-221) is honoured only byRankExecutor::can_submit(ranks.rs:181-184), never byserve_rank(parallel.rs:652-656), so onRankPeers::Processesit never arms; andenter_peer_graph_timeout(copy_gate.rs:110) ispubfor one test.
Conventions: no substantive AGENTS.md violation — the gate is structural, adds no flag/env/config, no per-model branch. Praise: RankExecutorInner split, PeerGraphLeases consolidation, drain_stream extraction, dead has_peer_copies removal.
Open: no measurement justifies the gate_wait adjustment; no A/B offload figure exists (dossier 5).
Correctness and contracts
Correctness / contracts / system-level review of PR #628 @ 76e1813 (19 files, +1,165/−154).
- Blocker — offload starvation is unbounded on the multi-process rank layout the PR newly gates.
serve_ranktakes the lease on COMMIT with nocan_submitcheck (helios/src/execution/parallel.rs:652-656), while the only mechanism that lets peer leases drain to zero —RankExecutor::can_submit(helios/src/execution/ranks.rs:181-184) — is consumed solely byWorker::submit(helios/src/server/runtime.rs:2261).enter_offload_batchwaits on an unbounded condvar (copy_gate.rs:184). With 2-frame pipelining,turnnever becomesOffloadand that process's restores/checkpoint unpins block forever. - Major —
Reply.elapsednow excludes cumulative gate wait (helios/src/offload/transfer.rs:795-798), feedingRate::observe(selene/src/levels.rs:57-68) →worth_transfer(selene/src/store.rs:424-442) → admission: contended restores look cheapest and stay admitted; zero-clamped samples are silently dropped. - Major — GPU-codec leases cover encode/decode compute, not "a bounded 16 MiB batch drain" as
docs/prefix-cache-offload.md:133-136,1025-1029claims (helios/src/offload/transfer/codec.rs:288-303,318-338,354-377). - Major — a 120 s stall fails the whole served worker (
copy_gate.rs:136-146→ranks.rs:153→runtime.rs:2332-2339→fail_all/closeatruntime.rs:774-777), after the scheduler already recorded the submission. - Major — the fairness test simulates the loop instead of driving it (
copy_gate.rs:453-461); gated codec coverage is#[ignore]d and CUDA-only, so no gated path has run in CI. - Minor — peer-copy detection is literal (
Node::Copywith declaredMemory::Peerendpoints only); gate is per process; multi-process gate wait can surface as "rank graph completion deadline expired" (parallel.rs:667-671);docs/same-process-tp.md(not opened) not updated. - Charter (#210) — no A/B offload figure or gate-cost measurement; author defers the GPU re-run.
Sound: detection/manifest field and length validation, rank-0 union, zero overhead without peer copies, lock ordering, RAII/panic release, lease clear after drain, Heliopause path unreachable. Open: is a maintainer satisfied that the fairness mechanism is sufficient for RankPeers::Processes?
Re-review
Recommendation: Changes Requested
Head 76e1813 cleanly resolves all Round 1 blockers on the in-process threaded TP path—scoping CopyEngineGate exclusively to models with peer-copy graphs (zero overhead on single-GPU and non-peer-copy models), adding bounded fairness in CopyEngineGate wired into RankExecutor::can_submit, bounding peer-graph waits at 120 s, and updating docs/prefix-cache-offload.md. However, 76e1813 also extends gating to multi-process peer ranks (serve_rank / join_peer_with_gate) without wiring should_drain_for_offload() into serve_rank, leaving unbounded offload starvation on RankPeers::Processes, and subtracts max_gate_wait from Reply.elapsed, which distorts Selene's end-to-end inbound_rate / worth_fetching admission pricing; the new gated CUDA tests and A/B latency measurement also remain pending on 76e1813.
Merge Risk
Level: Medium
- Multi-process TP liveness regression (
RankPeers::Processes): Newly gating peer offload workers (flare-cli/src/cluster.rs:254-261->helios/src/offload/shard.rs:47-61) alongsideserve_rank(helios/src/execution/parallel.rs:563-566, 652-663) without checkingleases.should_drain_for_offload()lets 2-frame pipelined decode starve peer-rank offload workers indefinitely whenever rank 0's local gate has no waiting offload batches. - Prefix-cache admission pricing distortion: Subtracting
max_gate_waitfromReply.elapsed(helios/src/offload/transfer.rs:780, 795-799) hides real restore wait time fromMemoryStore::inbound_rate(selene/src/memory.rs:1455) andworth_fetching/RestoreWait::defer, biasing heavily gate-contended restores to look faster than prefill. - Zero blast radius on non-peer-copy models, unverified gated GPU paths on
76e1813:NativeModel.copy_gateisNonewhen no rank reconstructed a peer-copy graph (helios/src/runtime_core/model.rs:827-831), keeping single-GPU and non-peer-copy models untouched, but the new gated CUDA transfer/codec tests and peer-copy A/B measurements have not yet run on76e1813.
Walkthrough
- Structural peer-copy graph detection (
helios/src/runtime_core/mod.rs:119, 919, 1149-1156, 1238, 1347-1349,helios/src/runtime_core/serving.rs:49, 59, 202,helios/src/execution/manifest.rs:838-843): Recordspeer_copy_graphs[i] = truewhen anyNode::Copyreferences aMemory::Peerallocation, validates populated lengths inExecutionManifest::validate(), and only instantiatesNativeModel.copy_gatewhen at least one rank has peer-copy graphs (helios/src/runtime_core/model.rs:827-831). - Bounded fairness & timeout gate (
helios/src/offload/copy_gate.rs:1-583,helios/src/offload/mod.rs:26, 39-60, 114-130,helios/src/offload/shard.rs:37-61,flare-cli/src/cluster.rs:254-261): AddsCopyEngineGate(withMAX_PEER_STREAK_WHILE_OFFLOAD_WAITING = 4andPEER_GRAPH_GATE_TIMEOUT = 120 s) andPeerGraphLeases, wired acrossNativeModel,offload::Binding,open_with_gate, and multi-process peerjoin_peer_with_gate. - Execution boundary (
helios/src/execution/ranks.rs:19-196,helios/src/execution/parallel.rs:563-566, 652-665, 692,helios/src/server/runtime.rs:718-733, 2340-2360): SplitsRankExecutorInner, merges asymmetricpeer_copy_graphsacrossRankPeers::Threads, checks!self.leases.should_drain_for_offload()inRankExecutor::can_submit, acquires/releases leases in fence order in bothRankExecutorandserve_rank, and recordsprefill_startedonly afterexecutor.submit()succeeds. - Offload transfer & codec gating (
helios/src/offload/transfer.rs:292-339, 441-505, 780, 795-799,helios/src/offload/transfer/codec.rs:288-376, 673-700, 760-782, 971-1034): Gates uncompressed batches viacopy_batch_gated(preserving single end-of-window sync whencopy_gateisNone), gates all five GPU-codec sites withgpu.codeclocked beforeCopyEngineGate, movestransform_nstimers after gate acquisition, and threadsgate_waitintoReply.elapsed. - Documentation & tests (
docs/prefix-cache-offload.md:133-138, 917-924, 1025-1029,copy_gate.rs:308-583,ranks.rs:198-227,transfer.rs:2013-2053,codec.rs:1286-1292): Updates offload blocking/queueing invariants and adds unit tests for gate fairness/timeout/lease ordering plus ignored CUDA tests for gated transfer and codec paths.
Pre-merge Checks
- [PASS] Security / malicious screen: Pure host-side synchronization and manifest metadata; no new dependencies, external I/O, wire/Protobuf contract changes, or prompt-injection attempts.
- [WARN] Charter & value fit: Model-agnostic Helios fix addressing a reproducible SM120 TP2 deadlock (#627) with preserved core compatibility (#267/#334), but peer-copy A/B offload latency measurements remain pending on
76e1813(#210) andReply.elapsedsubtraction weakens Selene's admission cost model. - [PASS] Related / duplicate / conflict check: Fixes #627 with no competing or duplicate PR; pre-existing Python CPU CI failure was unrelated (
#623/#624). - [WARN] Tests & verification evidence: Full
--locked --releaseCPU suites (helios1,740/1,740,flare245/245,flare-cli201/201 + 4 integration suites) andRUSTFLAGS="-D warnings" cargo check --locked --all-targetspassed on76e1813; however,offload_makes_forward_progress_under_pipelined_peer_graphshand-simulates the loop rather than exercisingserve_rank, the new gated CUDA tests and A/B latency measurements have not yet run on76e1813, andpython3 verification/helios-lifecycle/check.py(not opened) (or greenHelios lifecycleCI) should confirm the final head perdocs/design-review.md:209-215.
Blockers
- Unbounded offload starvation on multi-process peer ranks (
helios/src/execution/parallel.rs:627-666,helios/src/execution/ranks.rs:181-184,helios/src/offload/copy_gate.rs:55-68, 120-125, 173-199):- Verified behavior & impact:
76e1813wiresowner.copy_gate()into multi-process peer offload workers (flare-cli/src/cluster.rs:254-261->helios/src/offload/shard.rs:47-61) and acquiresPeerGraphLeasesinserve_rank(parallel.rs:563-566, 652-665). However,should_drain_for_offload()is only checked byRankExecutor::can_submit(ranks.rs:181-184) on rank 0 against rank 0's process-localCopyEngineGate;serve_ranknever checksleases.should_drain_for_offload(). Under 2-frame pipelined decode (protocol::can_submit_pendinginhelios/src/execution/threaded/protocol.rs:28), whenever rank 0's local gate hasoffload_batches_waiting == 0while a peer process still has a waiting offload batch (e.g., rank 0 finished its batches first, a peer batch arrived slightly later over TCP, or a peer is serving a codec/pool transfer), rank 0 keeps pipeliningPREPARE->READY->COMMITback-to-back. On the peer,serve_rankenters frameN+1while frameNis still active (peer_graphs_activeoscillates1 -> 2 -> 1 -> 2and never hits0),maybe_arm_offload_wave()never fires (copy_gate.rs:56requirespeer_graphs_active == 0), and the peer offload worker blocks indefinitely inenter_offload_batch's unboundedCondvar::wait(copy_gate.rs:183-185)—stalling multi-rank restores (which wait for every shard) and keeping GPU checkpoints pinned until decode goes idle. - Concrete fix: In
serve_rank(helios/src/execution/parallel.rs:627-640), do not defer afterCOMMIT(at that point rank 0 has already launched its local CUDA graph incommit_and_launchatparallel.rs:359-372). Instead, whenPREPARE/PREPARE_MOREarrives andleases.should_drain_for_offload()is true, hold back sendingREADY(without armingprepared_at) while continuing to pollexecutor.poll()so active frames finish,leases.release_throughdropspeer_graphs_activeto0and arms the peer's offload wave, and sendREADYonce!leases.should_drain_for_offload(). Add a CPU unit test drivingserve_rank(or its frame-coordination loop) alongside a waiting offload thread to verify forward progress under 2-frame pipelining.
- Verified behavior & impact:
Should Fix
- Subtracting
max_gate_waitfromReply.elapseddistorts Selene'sinbound_rateandworth_fetchingadmission pricing (helios/src/offload/transfer.rs:780, 795-799,selene/src/memory.rs:1174, 1450-1457,selene/src/levels.rs:57-68,selene/src/store.rs:424-442,helios/src/server/runtime.rs:223-235, 2834, 2858):- Verified behavior & impact:
Transfers::absorbreportspending.started.elapsed().saturating_sub(pending.max_gate_wait)asReply.elapsed.MemoryStore::absorbfeedsreply.elapsedintoinbound_rate.observe(reply.bytes, reply.elapsed), which computesestimated_secondsforworth_fetching/worth_transfer(estimated_seconds < 0.5 * gained_tokens / prefill_rate) andRestoreWait::defer. Selene's own contract requiresinbound_rateto measure end-to-end effective wall-clock restore latency (cf.selene/src/disk_store/coalesce/tests.rs:1444 (not opened), 1982, 2153); stripping gate wait makes gate-contended restores look artificially fast so the scheduler keeps admitting restores that actually lose to prefill (and clampingelapsedto zero causesRate::observeto silently drop the sample atselene/src/levels.rs:58-60). - Concrete fix: Delete the
gate_wait/max_gate_waitsubtraction fromReply.elapsed(keeppending.started.elapsed(), and remove the ~60 lines ofgate_waitplumbing acrosstransfer.rsandcodec.rs—see Subtract #1—updatingtransfer.rs:2047-2051accordingly). Keep the two valid metric isolations already in76e1813: GPU-codectransform_nstimers starting after gate acquisition andprefill_startedrecorded afterexecutor.submit()succeeds.
- Verified behavior & impact:
- Complete pending SM120 GPU verification and A/B offload latency measurement (
helios/src/offload/transfer.rs:2013-2053,helios/src/offload/transfer/codec.rs:1286-1292):- Concrete fix: Once the SM120 GPUs are free, run the newly added gated CUDA transfer and CPU/GPU codec tests on the final commit, post a peer-copy A/B offload throughput/latency comparison per Charter #210, and confirm
Helios lifecycle(python3 verification/helios-lifecycle/check.py(not opened)) passes on the final head.
- Concrete fix: Once the SM120 GPUs are free, run the newly added gated CUDA transfer and CPU/GPU codec tests on the final commit, post a peer-copy A/B offload throughput/latency comparison per Charter #210, and confirm
Subtract / Simplify
- Delete
gate_wait/max_gate_waitplumbing (~60 lines, subsumes Should Fix #1): RemoveRankReply.gate_wait(helios/src/offload/transfer.rs:78),Pending.max_gate_wait(:85), thesaturating_sub(:780, 795-799), theDurationreturn fromenter_offload_batch/copy_batch_gated/copy_spans_batch/RankWorker::run/RankCodec::run/capture_window/restore_window/decode_pages_cpu_batch, and revert the five(stored_len, elapsed, waited)tuple blocks inhelios/src/offload/transfer/codec.rs:288-305, 318-340, 354-376, 673-700, 760-782to simplerlet start = Instant::now(); ... stats.transform_ns += ...blocks (still placed after gate acquisition). - Collapse unused/test-only pass-through wrappers into single entry points:
helios/src/offload/mod.rs:114-130:openhas zero callers repo-wide (server/runtime.rs:731already callsopen_with_gate). Deleteopenand renameopen_with_gatetoopen.helios/src/offload/shard.rs:37-61:join_peeris only called in two tests (helios/src/offload/shard/tests.rs:20,helios/src/offload/pool/tests.rs:146); production (flare-cli/src/cluster.rs:254) already callsjoin_peer_with_gate. Delete the wrapper, passNoneat those two test sites, and keep onejoin_peer.
- Deduplicate gated/ungated batch-sync logic (
helios/src/offload/transfer.rs:308-339, 459-474,helios/src/offload/transfer/codec.rs:978-1034): BothRankWorker::runandcopy_spans_batchrepeat theif copy_gate.is_none() { record; synchronize; }pattern and duplicateDrainOnDrop/Fencedrop guards plusstd::mem::forget. A smallGatedCopies<'a>helper withbatch(...)andfinish()(draining inline on error viadrain_stream) replaces all three sites cleanly. - Narrow
CopyEngineGate::enter_peer_graph_timeoutvisibility (helios/src/offload/copy_gate.rs:110): Its only callers areenter_peer_graph(:106) and two unit tests (:509, :518); make it private (fn) instead of widening the public crate API for a test knob.
Nits
- Accurate drain bound in docs (
docs/prefix-cache-offload.md:919-922, 1025-1028): Line 1026 states that the model worker thread waits only for "a bounded in-flight 16 MiB batch drain", whereas at the five GPU-codec sites (helios/src/offload/transfer/codec.rs:288-303, 318-338, 354-374, 674-695, 761-779)OffloadBatchGuardspans an entire GPU encode/decode call—including up toMAX_PIPELINE_BATCHES = 4pipelined batches + host emission (gpu_codec.rs:1601-1665) and CPU CRC/staging (gpu_codec.rs:1723-1747). Reword to "a bounded in-flight 16 MiB copy batch or GPU-codec batch/wave drain".
Dropped on verification
- 120 s
ExecutionError::Draintearing down the worker (Correctness Finding 4 / Dossier §5.4): Dropped. Disk I/O never holdsOffloadBatchGuard(only pinned host <-> VRAM DMA and GPU codec calls do); a 120 s drain failure indicates a wedged CUDA stream and intentionally matchesThreadedExecutor::TIMEOUT(helios/src/execution/threaded.rs:23, 120 s). The proposed fix of returningOk(false)fromWorker::submitafterself.scheduler.submitted_step(fence)(helios/src/server/runtime.rs:2282) would corrupt scheduler state and reintroduce an unbounded hang. serve_ranklaundering gate wait intoprepared_at/starteddeadline errors (Correctness Finding 5 / Dossier §5.6): Dropped as misread.prepared_at = Noneruns athelios/src/execution/parallel.rs:643beforeleases.enter(graph)?at:652, andstarted.push_backruns at:657after (whenleases.enterblocks,peer_graphs_active == 0). A 120 s stall can race rank 0'sframe.dispatcheddeadline (parallel.rs:306-315) against the peer's 120 sPEER_GRAPH_GATE_TIMEOUT, which is low-signal diagnostic detail on a catastrophic hang.- Per-process gate vs cluster-wide invariant (Correctness Finding 6): Dropped. Each process owns its own GPUs and local offload workers, so per-process gating is the right synchronization boundary for preventing local Copy Engine collisions; the actual multi-process bug is the missing
should_drain_for_offload()check inserve_rank(Blocker #1). - Literal
Node::Copy+Memory::Peerdetection (Correctness Finding 7): Dropped. VerifiedMemoryvariants inhelios/src/runtime_core/(Device,MappedHost,Peer); structural detection is model-agnostic and already accurately scoped indocs/prefix-cache-offload.md:135-136, 917-918. - Deleting the fairness machinery (Subtraction §4a): Dropped. Round 1 established unbounded offload starvation under 2-frame pipelined decode as a Blocker; deleting fairness would reintroduce it.
- Deleting
#[cfg(test)] Copiers::new(Subtraction §1c): Dropped. Churning 15 untouched test sites acrossgpu_tests.rs(not opened),transfer.rs, andcodec.rsadds diff noise without simplifying production code. - Claim that
codec.rs:1005Fencehas nothing to protect on the ungated path (Subtraction §2 parenthetical): Dropped as inaccurate—on the ungated pathcopy_batch_gatedenqueues without syncing, soFencedrains earlier batches if a later batch errors. - Claim that a single rank's
gate_waitsum can exceedpending.started.elapsed()(Correctness Finding 2 detail): Dropped as inaccurate—batches on one rank execute sequentially afterpending.started, somax_gate_waitis bounded by wall time; the actual bug is the admission-pricing span shrinkage documented in Should Fix #1. - Stale
docs/same-process-tp.md:177-180(Dossier / Lenses): Dropped. Verified lines 177-180 discuss external process checkpoint/restore while parked onDispatchRing, unrelated to prefix-cache offload.
Classify triage
Selected: triage:review
Threshold: 65%
Triage
- [✓]
triage:review: 98.5% -
triage:validation: 1.1% -
triage:design-review: 0.3% -
triage:investigate: 0.0% -
none: 0.0% -
triage:partial: 0.0% -
triage:integration: 0.0% -
triage:verify-for-closure: 0.0% -
triage:superseded: 0.0%
Apply labels
No label changes Decision to Test: no (99%): Testing will not add significant value as the code stands today. The code is either not yet ready to merge, or adequate testing has already been done to validate the contents of the code, or the available hardware is not suitable to test with.