#1 [high] Change: what PR #628 does, size, and summary-of-changes
PR #628 "helios: gate offload Copy Engine batches during peer-copy graphs" (draft, open 2026-11-30, head 1870a27, base main, 14 files +572/−72). Fixes #627.
What it does in plain terms: adds a process-wide mutex/condvar "gate" (CopyEngineGate, helios/src/offload/copy_gate.rs) with two lease types:
PeerGraphGuard(waiting > active counters): taken around executing a CUDA graph that contains in-graph peer copies; blocks new offload batches, waits only for in-flight offload batches to drain, and takes priority over waiting offload batches.OffloadBatchGuard: taken per BATCH_BYTES window by offload copy workers; multiple workers hold it concurrently across ranks; blocked while any peer graph is waiting or active.
Gate is shared per NativeModel (helios/src/runtime_core/model.rs:27 field copy_gate, created at :662 Arc::new(CopyEngineGate::new())) and threaded through offload::Binding::new(inner, cubins, copy_gate) (helios/src/offload/mod.rs:39-56), NativeModel::attach_offload (model.rs:986 Copiers::with_gate), NativeModel manifest build (model.rs:1032-1039), and server offload attach (helios/src/server/runtime.rs:715-733 open_with_gate).
Graph classification is structural, computed at CUDA graph reconstruction: NativeResources.peer_copy_graphs: Vec<bool> set true when any Node::Copy has a Memory::Peer source or destination (helios/src/runtime_core/mod.rs:117, 919, 1149-1155, 1238), exposed per graph name in ExecutionManifest.peer_copy_graphs + has_peer_copies (helios/src/execution/manifest.rs:436-444, 449-452; populated in helios/src/runtime_core/serving.rs:49, 59, 202).
Execution boundary: RankExecutor restructured into RankExecutorInner + gate state (helios/src/execution/ranks.rs); merge_peer_copy_graphs unions peer flags across local RankPeers::Threads manifests (ranks.rs:29-42); guard taken in submit only if peer_copy_graphs[graph] (ranks.rs:90-105), released in poll for fences <= completed frame fence (ranks.rs:114-121), and all remaining guards cleared in close after inner close (ranks.rs:172-181).
Offload copy sites gated: uncompressed RankWorker::run per BATCH_BYTES batch (helios/src/offload/transfer.rs:398-428), CPU-codec copy_spans_batch flush (helios/src/offload/transfer/codec.rs:958-1025), and five GPU-codec sites (codec.rs:287-292, 315-320, 349-354 encode; 664-670 try_lock decode; 749-755 decode_to_device).
Wire/compat surface: no Protobuf change, no package-format change. heliopause Python manifest builder passes peer_copy_graphs: Vec::new() (heliopause/src/python.rs:331), i.e. the Python path never marks peer-copy graphs. Test-only additions: manifest literals in helios/src/execution/tests.rs:206, model/testing.rs:396, model/contract.rs:983.
#2 [high] Why: issue #627 reproduces an SM120 TP2 prefill deadlock and isolates it to concurrent Copy Engine DMA
- Issue #627 (open, bug, priority:P1, triage:investigate, area:selene) by yatesdr, opened 2026-11-30 02:40, updated same day, 0 comments. This PR "fixes #627" (referenced-by link confirmed via read_item 627).
- Environment in issue: 4x RTX PRO 6000 (SM120, PCIe), CUDA 13.0.1, driver 595.99.02; tested against main @ c146d7b; core Qwen3.8-Flash-Next TP2 (--gpus 0,1) whose prefill7168 graph has 8,613 nodes / 11,726 edges / 1,176 Node::Copy nodes (4.58 MiB peer-to-peer); --prefix-cache-memory 4G with or without disk/pool; workload 8-way concurrent uncached ~6,574-token prompts.
- Isolation evidence in the issue: cuGraphAddEventRecordNode frontier instrumentation showed both ranks stalling inside PCIeDmaAllReduce Node::Copy(4587520B) + FlagLaunch pair at non-deterministic layer indices (+16.58ms vs +75.70ms). A/B ablation: skipping only stream.copy_batch(...) in helios/src/offload/transfer.rs passed 48/48 burst requests; replacing with unbatched cuMemcpyAsync / cuMemcpyDtoHAsync_v2 / cuMemHostRegister / normal-priority streams / GPUs 2,3 / cross-rank mutex still deadlocked; disabling host prefix cache or pausing offload copy_batch windows passed 80/80 bursts at 4.44-4.71 s.
- Note: the ablation says cross-rank mutex serialization of offload workers still deadlocked, i.e. serializing offload alone was not sufficient; the fix gates offload against peer-copy graph execution, which is a different axis. Worth flagging since the PR's own test coverage includes "multi-rank concurrent offload" as a property it preserves.
- Duration/how widely wanted: issue is 1 day old at PR time (single report, single author). No other issue in the repo describes this deadlock (searches for "copy engine peer deadlock offload", "prefix cache offload hang deadlock" return only #627/#628).
#3 [high] Change: what the diff does that the description does not say (ungated paths, per-batch sync)
Findings from reading the diff/code (not stated in the PR description):
-
Multi-host disk-store peer path is not gated.
helios/src/offload/shard.rs:37-49join_peerstill buildssuper::transfer::Copiers::new(gpu_cubins)— the gate-less constructor. That path is what flare-cli uses for a peer rank with a disk prefix store (flare-cli/src/cluster.rs:254,owner.offload(), owner.gpu_codec_cubins().to_vec(), ...). So a peer rank's own offload copy engine batches (its disk-tier staging through the sameTransfers/RankWorker) run without the gate. The PR's Limitations say "multi-host TP ... not tested end-to-end", and claim "pool and CPU codec paths share the same CopyEngineGate wiring" — the multi-host sharded peer path does not. -
attach_offload(Selene pool path) is effectively not gated either.NativeModel::attach_offload(helios/src/runtime_core/model.rs:985-991) does passCopiers::with_gate, but it feedsself.offload.attach(prepared, &copiers), and in seleneoffload::Startup::attach(selene/src/offload.rs:935-949) the factory is used only whenPreparation::Store(store)still hasself.poolpresent:pool.prepare_peer(store, factory). Otherwise the factory is dropped. The factory only matters for the pool-agent peer transfer path. AlsoNativeModel::attach_offloadhas exactly one caller (model.rs:981, inside the cache-allocation phase), no other attach site found. -
Python/PyO3 core path never marks peer-copy graphs.
heliopause/src/python.rs:331setspeer_copy_graphs: Vec::new(), so any manifest built through Heliopause (in-process Python/SDK path) reports no peer copies regardless of content and the gate never engages there. Description says "defaulting absent entries to false for non-core manifests" — true, but the consequence is those paths get no protection, not just older cores. -
Two structural blind spots in peer-copy detection.
Memory::Peermarking happens inNativeResourcesfrom the allocation's declared memory kind (helios/src/runtime_core/mod.rs:1149-1156), andMemory::Peermeans "another rank's device allocation, referenced at its recorded address" (helios/src/runtime_core/format.rs:43-49). Graph copies that go through same-process rank threads but address a localMemory::Deviceallocation that happens to be peer-mapped are not marked. Only literalNode::Copynodes count — any kernel-driven DMA (e.g.b12xkernels doing cudaMemcpyAsync inside a kernel, or the DMA-ring code path inhelios/tests/collective_core_fixture.py:89-140twoshot path) is not detected. -
Cross-rank gate sharing only within one process. The gate is created per
NativeModel; multi-process TP (RankPeers::Processes, i.e.flare runone process per rank, used by multi-host and bydocs/prefix-cache-offload.md:1617) gets one gate per process, so a rank's offload batches are not coordinated against another rank's peer-copy graph. Description says "Share one Arc per NativeModel", which is accurate but the reach is narrower than "TP2 deadlock eliminated" suggests outside single-process TP. -
Guard release is poll-driven.
RankExecutor::pollonly pops guards when aFrameCompletioncomes back (helios/src/execution/ranks.rs:108-124). Threaded/parallel executors may complete frames out of order? They pop while the front fence <= completed fence, so a head-of-line stall holds every later lease.close()clears remaining leases unconditionally (ranks.rs:170-181). -
Deadlock risk in the gate itself for the threaded executor:
submitcallsenter_peer_graph()(blocking on offload batches) before calling inner submit, from the model worker thread; if an offload worker is concurrently blocked inenter_offload_batch()waiting onpeer_graphs_waiting, the gate's condvar protocol says waiting peers take priority, so ok. ButOffloadBatchGuard::droponlynotify_all()s when the last offload batch drops (copy_gate.rs:97-104); a peer graph waiting while other offload batches remain active can block until all drain — that matches the documented "wait only for in-flight batches to drain". -
Undeclared:
helios/src/offload/transfer.rschangedRankWorker::runto record+sync the event per batch inside the gated branch and keep the old single record/sync at the end when ungated; the ungated path is behavior-identical, but the gated path now adds a per-batch stream synchronize (transfer.rs:410-430), which is a serialization/latency change for offload throughput that the description does not mention (only "Acquire OffloadBatchGuard per BATCH_BYTES batch").
#4 [high] Project fit: charter root-cause rule and documented "offload never blocks the worker" invariant
Charter (read_charter) fit, as facts:
- Tension, root cause: charter "Bring real evidence" bullet: "Bug fixes need to address the root cause; don't just swallow, skip, or retry an unexplained error (#397)." Issue #627 documents careful isolation but no driver-level root cause; PR #628's own framing is "Coordinating host offload batches against peer-copy graph execution directly in Helios resolves the deadlock" — i.e. a runtime-level coordination/mitigation, not elimination of the Copy Engine conflict. The issue's ablation showed even cross-rank mutex serialization of offload workers still deadlocked, so the mechanism is not fully characterized.
- Tension, documented invariant reversal: docs/prefix-cache-offload.md:133 "Offload work never blocks the model worker thread or the model stream"; :907 "The model stream never waits on an offload event"; :1015 "The model worker thread never waits for offload work"; :133-135 points to section 2.10 (docs:900-928) for the isolation mechanisms, which state "Copy engine queueing: offload batches are bounded to 16 MiB per call and the offload streams are created at the least stream priority ... Batch size and stream priority alone do not bound those delays" and "Shared bandwidth and copy engines still require the interference measurements in section 4". With the gate, the model worker thread that submits a peer-copy graph now blocks in
enter_peer_graph()until in-flight offload batches drain (helios/src/execution/ranks.rs:90-96, helios/src/offload/copy_gate.rs:47-56). No docs file is in the PR's changed set, so this documented contract is neither updated nor qualified. - Fits: target hardware is SM120 (charter goals: serve captured CUDA graphs on SM103/SM120/SM121); the change is model-agnostic with no per-model branches and no new flags (charter "Keep the runtime small and model-agnostic", #267/#334); it is a reproducible-bug fix of the class the charter says gets merged; PR description has the four parts the charter expects (why, what, result, evidence).
- Charter non-goal check: not broad hardware coverage or a new backend; touches no Protobuf/package format ("Be explicit and pin everything" unaffected).
- Performance PR rules: labeled performance as well as bug; charter says "Performance PRs need benchmarks showing an actual speedup over main on a served workload (#210)". The PR's performance evidence is the opposite direction: it shows no deadlock and equal-ish burst timings (4.68-4.83 s/burst vs unpatched
maindeadlocking), not a speedup; and it does not measure the offload-throughput cost of the new per-batch synchronize (see the "undeclared" note).
#5 [high] Change: offload copies become per-batch synchronizing for every prefix-cache run
Offload fast path changes for every prefix-cache run, not only peer-copy runs. copy_gate is Some whenever a NativeModel manages the offload store (helios/src/runtime_core/model.rs:986-989, model.rs:1032-1038), independent of whether any graph in the model has peer copies. Therefore:
RankWorker::runtakes the branch athelios/src/offload/transfer.rs:398-430and doesrecord(event)?; event.synchronize()?per BATCH_BYTES (16 MiB) batch plus one mutex/condvar lock per batch, instead of onerecord+synchronizeafter all batches (transfer.rs:431-434is now the gate-less path only).BATCH_BYTES = 16 << 20(helios/src/cuda.rs:169).copy_spans_batchlikewise records and synchronizes the event per flushed batch when the gate is present (helios/src/offload/transfer/codec.rs:976-1000, withlet fence = copy_gate.is_none().then_some(Fence(stream))at :1002 and the old end-of-function record/sync now only for the ungated path at :1025-1028). So offload copies are no longer enqueued back-to-back before a single wait whenever prefix cache is enabled. The description says only "Acquire OffloadBatchGuard per BATCH_BYTES batch" and claims "zero gate overhead on graphs without peer-copy nodes" — the zero-overhead claim holds for graph submission, not for the offload path. No measurement of the resulting offload capture/restore latency or throughput is presented. (The ungatedopen/Copiers::newpaths used by tests,helios/src/offload/shard.rs:47, keep the old behaviour.)
#6 [high] Research summary
Case file for PR #628 "helios: gate offload Copy Engine batches during peer-copy graphs" (draft, open 2026-11-30, head 1870a27, base main, 14 files +572/−72, labels bug/performance/priority:P1, no reviews, CI failed, zero comments).
What it does. Adds a per-NativeModel CopyEngineGate (Mutex+Condvar, new file helios/src/offload/copy_gate.rs) with two RAII leases: PeerGraphGuard (taken around submitting a CUDA graph that contains in-graph Node::Copy against Memory::Peer; waits only for in-flight offload batches to drain, and takes priority over waiting offload batches) and OffloadBatchGuard (taken per 16 MiB BATCH_BYTES window by offload copy workers; multiple workers hold it concurrently across ranks). Graph classification is structural at graph reconstruction (helios/src/runtime_core/mod.rs:919,1149-1156,1238 → ExecutionManifest.peer_copy_graphs/has_peer_copies, helios/src/execution/manifest.rs:436-449), unioned across local RankPeers::Threads manifests (helios/src/execution/ranks.rs:39-52), leased in submit and released in poll/close (ranks.rs:90-124,170-181). Gated copy sites: transfer.rs:398-430, codec.rs:958-1028 (CPU codec) and five GPU-codec entry points (codec.rs:290,318,352,668,752). No Protobuf, package-format or flag change.
Highest-value findings a reader could not learn from the description (all verified in code):
- Documented invariant reversed, docs not updated.
docs/prefix-cache-offload.md:133says "Offload work never blocks the model worker thread or the model stream" (:907, :1015 repeat it). With the gate, the model worker thread blocks inenter_peer_graph()until in-flight offload batches drain (ranks.rs:90-96,copy_gate.rs:47-56). No docs file is in the changed set. - Offload fast path changes for every prefix-cache run, not only peer-copy runs. Because the gate is
Somewhenever offload is attached (model.rs:986-989,1032-1038),RankWorker::runnow doesrecord+synchronizeper batch (transfer.rs:410-430; the single end-of-job sync at :431-434 is now the gate-less path only), andcopy_spans_batchlikewise (codec.rs:978-1000,1002,1025-1028). The description's "zero gate overhead on graphs without peer-copy nodes" is true for graph submission only; no offload-throughput measurement is presented. - Several paths remain ungated and the description implies otherwise.
helios/src/offload/shard.rs:47(join_peer, the multi-host disk-store peer path used fromflare-cli/src/cluster.rs:254) still buildsCopiers::newwith no gate;heliopause/src/python.rs:331passespeer_copy_graphs: Vec::new()so the Python/PyO3 manifest path never marks peer copies;attach_offload's factory only reaches the pool-agent peer path (selene/src/offload.rs:935-949). Multi-process TP gets one gate per process (NativeModel-scoped), so cross-rank coordination does not span processes. - Detection breadth. Only literal
Node::Copynodes with a declaredMemory::Peerallocation are marked (format.rs:43-49); kernel-driven DMA or copies to a local allocation that is merely peer-mapped are not. - Guard release is poll-driven: a head-of-line frame holds every later lease (
ranks.rs:114-121);closeclears the rest. - Charter tension. The charter requires bug fixes to address the root cause (#397); #627's own ablation shows the mechanism is not fully characterised (cross-rank mutex serialization of offload workers still deadlocked), and the PR frames itself as coordinating around the conflict rather than removing it.
Why / evidence. Issue #627 (same author, same day, 0 comments, labels area:selene/bug/P1/triage:investigate) reproduces a TP2 prefill deadlock on 4× RTX PRO 6000 (SM120, driver 595.99.02) with Qwen3.8-Flash-Next prefill7168 (8,613 nodes, 1,176 peer Node::Copy, 4.58 MiB) under 8-way uncached ~6,574-token bursts; cuGraphAddEventRecordNode frontier probes showed both ranks stalling inside a PCIeDmaAllReduce copy + FlagLaunch; skipping only stream.copy_batch passed 48/48, disabling the host cache or pausing copy windows passed 80/80. The PR's validation (compiler checks, 5 new gate/ranks unit tests, 162 helios server tests, 245 flare, 200/201 flare-cli, 19/19 offload CUDA tests, live TP2 runs for Qwen3.8 and GLM-5.3) is described in text only — no logs or artifacts; unpatched main deadlocking during the first burst is the only comparative datapoint, so there is no speedup claim of the kind the charter asks for performance changes (#210).
Related work. Nothing else in the repo covers this deadlock; searches return only #627/#628. The change sits on author yatesdr's Selene/offload series (#80, #92, #141, #168, #504 GPU/CPU KV codec, #525, #527, #589/#497 from others) and touches files last changed by #504/#525 (codec.rs), #497 (transfer.rs), #430/#507 (manifest.rs), #280/#334 (ranks.rs). No overlapping or competing PR; nearest neighbours are #497 (offload restore latency, merged 2026-11-29) and #622 (open, GPU limits) — neither conflicts.
Recent activity / people / community. helios/src/offload was last touched 2026-11-28 by Luke Alonso (#589) before this commit; the branch predates only #626 (0a8c20f4) in the touched files. Author yatesdr is a COLLABORATOR with 80 merged PRs in 180 days, the dominant contributor to Selene/offload (34 helios/src commits); Luke Alonso (229) and Martin Vit (52) are the other helios regulars. No reviews, comments or reactions yet; the flare-autobot review that other PRs in this area received has not appeared.
Project fit / reach. Fits the SM120/SM120-Spark focus, keeps the runtime model-agnostic (no per-model branch, no new flag), and lands in Helios rather than ignition. Affects every --prefix-cache-memory/disk/pool run through the extra per-batch sync and the worker-thread blocking, single-host threaded TP2 most of all; no config, compatibility, wire-format or deployment change; exported cores keep loading (peer_copy_graphs defaults absent → false). Process: draft, CI failed on the head commit, no reviewer assigned.
#7 [high] Related work: no competing or duplicate PR; overlaps #497, #621, #334, #280 and the author's Selene series
Searches for the deadlock topic return only #627 and #628 (queries: "copy engine peer deadlock offload", "PCIeDmaAllReduce peteep copy b12x", "b12x collective peer", "prefix cache offload hang deadlock", "prefill interference offload pause copy priority", "draft helios offload prefix cache copy engine" by yatesdr). No duplicate report, no prior PR attempting this fix, nothing superseded.
Files-overlap picture (items_touching, last 180 days):
helios/src/offload/transfer.rs: only #628 and yatesdr's own Selene lineage — #504 (pure-CUDA GPU+CPU KV compression), #168, #141, #92, #80. So the gated file is effectively the author's own code.helios/src/execution/ranks.rs: #628, #334 (open, javieratomic, Engram rows ahead of prefill), #280 (merged, jetnet, GB200 WFET parking). No conflict; #334 also touches per-rank manifests.helios/src/execution/manifest.rs: #628, #621 (open, jcartu, scheduler admission vs core parameters), #555, #507, #479, #430, #92. Adding a public fieldpeer_copy_graphstoExecutionManifestwill textually collide with #621 (both edit the same struct area) — worth flagging as a merge-order note, not a defect.helios/src/server/runtime.rs: #628 plus 20+ other PRs (#483, #554, #576, #548, #549, #560, #621, #334, #301, #626, #620, #607, #579, #497 …).- Near neighbours: #497 (merged 2026-11-29, FujitsuPolycom, "Reduce disk offload restore latency and integrated-memory intake overhead") retuned the same offload worker's
Worker::idle_wait(2 ms → 50 µs) andStaged::pump_allordering to reduce offload latency — #628 adds per-batch synchronisation on the copy path (#497 did not touch the CUDA copy batching itself). #496/#507 touch offload/disk concurrency; #589 and #504/#525/#527 are the codec work the gated sites live in. - Also relevant context for the "who else cares" angle: #348 (open, yatesdr, PCIe multi-GPU transport selection) and #151 (open, GB10/RoCE collective timeouts) are the other "collective stalls on this hardware" reports — neither is this Copy Engine deadlock, and #628 does not claim to fix them.
#11 [high] Amendment: head 76e1813 (2026-11-30) is a review-response commit that changes the PR's substance
A second commit landed after the 2026-11-30 report: 76e18130 "helios: bound CopyEngineGate fairness, scope gating to peer-copy models, and preserve metrics" (yatesdr). It answers the @flare-autobot "Changes Requested" review of 11:59 UTC on 1870a27. PR now 19 files, ≈+1165/−155 (was 14 files +572/−72); helios/src/offload/copy_gate.rs is 584 lines (was 263). New files in the changed set: docs/prefix-cache-offload.md, heliopause/src/python.rs, helios/src/execution/tests.rs, helios/src/model/contract.rs, helios/src/model/testing.rs, helios/src/runtime_core/serving.rs, helios/src/offload/transfer/lifecycle_tests.rs.
Findings closed by 76e1813
- Docs — resolved.
docs/prefix-cache-offload.md:133-136now reads "never blocks the model worker thread except for the bounded Copy Engine drain before launching a graph that contains in-graph peer-to-peer Copy Engine nodes … Single-GPU and non-peer-copy models stay ungated"; §2.10:917-924describes the per-modelCopyEngineGate, the 120 s bound and the fairness turns; the §2.12 invariant at:1025-1029is reworded to "waits on offload only for a bounded in-flight 16 MiB batch drain". Residual:docs/same-process-tp.md:177-180still lists the parked-rank/checkpoint region as unqualified and was not updated. - Per-batch sync on every prefix-cache run — resolved for non-peer-copy models.
NativeModel.copy_gateis nowOption<Arc<CopyEngineGate>>(helios/src/runtime_core/model.rs:27,662), set only when some rank reconstructed a peer-copy graph:model.copy_gate = model.ranks.iter().any(NativeResources::has_any_peer_copy_graphs).then(|| Arc::new(CopyEngineGate::new()))(model.rs:827-831; helperhelios/src/runtime_core/mod.rs:1347-1349). Threaded throughBinding(helios/src/offload/mod.rs:42,49,58),attach_offload(model.rs:990-996),manifests()(model.rs:1041-1047),open_with_gate(helios/src/server/runtime.rs:719-731).copy_batch_gatedonly records+synchronizes when the gate isSome(helios/src/offload/transfer.rs:308-338); the ungated path keeps the single end-of-window sync (transfer.rs:471-474). So the 16 MiB-per-batch blocking sync now applies only to peer-copy models. - Ungated shard/Python paths — mostly resolved.
join_peer_with_gateadded (helios/src/offload/shard.rs:47-61), used byflare-cli/src/cluster.rs:254-261withowner.copy_gate();join_peersurvives as aNone-gate wrapper (shard.rs:37-45). Still open:heliopause/src/python.rs:331unchanged (peer_copy_graphs: Vec::new()), though that manifest also setsoffload: None(python.rs:318), so the Heliopause path could not engage a gate even if flags were set. - CI failure — retracted as a blocker for this PR. The failing check was
Python CPU tests, a main-wide breakage tracked in #623 (closed 12:39 2026-11-30) and fixed by #624 (merged 2026-11-30 12:39, head078315e, tests-only). Author statesHelios lifecycle(lifecycleandkani) passed on1870a27. - Single-process scope — unchanged: the gate is per
NativeModel, so multi-process TP (RankPeers::Processes) still gets one gate per process.PeerGraphLeasesis now shared betweenRankExecutor(helios/src/execution/ranks.rs:143) andserve_rank(helios/src/execution/parallel.rs:563-566,652-663,692), but that is in-process reuse, not cross-process coordination. - Manifest compat —
ExecutionManifest::has_peer_copieswas deleted andvalidate()now rejects a populatedpeer_copy_graphswhose length differs fromgraphs(helios/src/execution/manifest.rs:835-843; testranks.rs:215-224). Fine for a field introduced in this same PR.
Still open after 76e1813: no A/B offload throughput/latency measurement (#210, #397) — the author says the new gated CUDA tests and the peer-copy A/B numbers are pending because the SM120 host's GPUs are busy; peer-copy detection is still literal Node::Copy on Memory::Peer only; and the metrics changes below.
#12 [high] Amendment: new risks introduced by the fairness/timeout redesign in 76e1813
New code-level risks introduced by 76e1813 (the fairness/timeout redesign), not present on 1870a27. All file:line at PR head 76e1813.
-
The "offload wave" can be revoked by the very next peer-graph admission, so the anti-starvation guarantee is best-effort, not structural.
maybe_arm_offload_wave()setsturn = Offloadwithoffload_wave_remaining = offload_batches_waitingonly whenpeer_graphs_active == 0(helios/src/offload/copy_gate.rs:54-68). Butenter_peer_graph_timeoutthen unconditionally setsstate.turn = Turn::Peeron every successful admission (copy_gate.rs:159) — and itsneeds_waitonly blocks for an armed wave whenpeer_graphs_active == 0(copy_gate.rs:120-125). So while any peer-copy frame is in flight (the normal 2-frame pipelined decode case that motivated the change) a new peer graph is admitted immediately and cancels the offload wave;enter_offload_batch'smust_waitthen re-blocks onpeer_graphs_active > 0(copy_gate.rs:175-179). Mitigation is indirect:RankExecutor::can_submitreturns false whileshould_drain_for_offload()(helios/src/execution/ranks.rs:182-184; checked athelios/src/server/runtime.rs:2261), which is what is supposed to let leases drain to zero — but (a) it is evaluated earlier in the worker loop than the subsequentsubmit, (b) it only protects the single-processWorker::runpath, and (c)serve_rank(multi-process TP) callsleases.enter(graph)?with nocan_submitcheck at all (helios/src/execution/parallel.rs:652-656). The only test of the property,offload_makes_forward_progress_under_pipelined_peer_graphs(copy_gate.rs:445-500), models the pause itself ("pause pipelining whenever should_drain_for_offload() is true") instead of driving it throughWorker/RankExecutor, so it cannot fail ifcan_submitwiring breaks. -
A
PeerGraphGuardnow waits on the whole GPU-codec transform, not only on Copy Engine time. At the five GPU-codec sites the offload lease is taken before the codec transform under thegpu.codecmutex and released after it completes (helios/src/offload/transfer/codec.rs:288-303,318-338,748-780), so the peer graph's drain wait covers encode/decode compute plus the mutex queue, not just the 16 MiB copy. The doc text added atdocs/prefix-cache-offload.md:133-136,1025-1029describes the wait as "a bounded in-flight 16 MiB batch drain", which understates what the model worker can block on. -
The 120 s bound converts a stuck offload batch into a served-worker failure, not just a failed request.
enter_peer_graph_timeoutreturnsExecutionError::Drain(copy_gate.rs:131-147);RankExecutor::submitpropagates it (execution/ranks.rs:156-160), andWorker::submitpropagates with?intoWorker::run(server/runtime.rs:2261,2332-2339), which unwinds toworker.fail_all(&final_error)and tears down the executor (server/runtime.rs:759-776). The docs describe the 120 s only as a bound on "waiting peer-copy graphs" (docs:1025-1029) and never say the outcome is worker shutdown. Economically this is the right trade (fail rather than hang), but it is an undocded failure mode, and the message's own counters (offload_active,turn,wave_remaining) become the only diagnostic. -
Multi-process TP can surface the gate wait as a rank-completion deadline. In
serve_rankthe lease is acquired on COMMIT beforeexecutor.submit(parallel.rs:649-657) while the root rank's per-frame completion deadline (started.front()vsTIMEOUT,parallel.rs:670-671;wire.rs:28= 120 s) is already running for a frame it submitted itself. A peer blocked in the gate for a large fraction of 120 s can therefore surface as "rank graph completion deadline expired" on the root rather than as the gate's ownDrainerror. Low likelihood (needs a near-timeout drain) but the two 120 s budgets are independent and uncoupled. -
Reply.elapsedis now wall-clock minus gate wait, which changes an estimator that drives scheduling, not just telemetry.Transfers::absorbsubtractspending.max_gate_wait(the max across ranks) from the elapsed (helios/src/offload/transfer.rs:780,792-799). That value flows toselene/src/memory.rs:1450-1456(outbound_rate/inbound_rate) andselene/src/levels.rs:57-110rankings, which feedworth_fetching/worth_transferdeferral inhelios/src/server/runtime.rs:223-229,2805-2860. So gate-stalled transfers report a higher effective bandwidth and become more likely to be judged worth doing. Defensible ("measure the copy, not the pause"), but it is a behavioural change to an admission heuristic, and the max-across-ranks subtraction is an approximation (the elapsed window and the per-rank waits do not start together). The new assertion only checksreply.elapsed < 25 msin an#[ignore]d test (transfer.rs:2047-2051, inside#[ignore = "requires two CUDA devices"]attransfer.rs:1712). -
The new gated verification tests do not run in CI.
gated_cpu_and_gpu_codec_capture_and_restore_defer_while_peer_graph_holds_gateis#[ignore = "exercises gated CPU and GPU codec capture and restore against CopyEngineGate"](codec.rs:1286-1291); the gated transfer arm added tosplit_pools_cost_each_device_its_part_and_round_trip_unitssits in a test ignored for "requires two CUDA devices" (transfer.rs:1712,2013-2053). Combined with the author's "pending GPU re-run" note, no gated copy path has yet been executed anywhere. -
Small cleanups confirmed done:
ExecutionManifest::has_peer_copiesdeleted and length validated (manifest.rs:835-843);OffloadBatchGuardno longer re-exported (offload/mod.rs:26);copy_batch_gated/drain_streamdeduplicated (transfer.rs:290-339, used fromcodec.rs:997);Copiers::newis now#[cfg(test)](transfer.rs:2167-2171), so the only ungated production constructor left isjoin_peer(offload/shard.rs:37-45) andopen()(offload/mod.rs:114-119).
#13 [high] Correction to note 12 item 1: exact remaining starvation path is the multi-process rank loop
Corrected version of item 1 of note #12 — my first draft overstated the mechanism. The wave is not revocable while armed: maybe_arm_offload_wave() only fires at peer_graphs_active == 0 (helios/src/offload/copy_gate.rs:54-68), and once armed a new peer graph does wait because needs_wait blocks on peer_graphs_active == 0 && turn == Offload && wave_remaining > 0 (copy_gate.rs:120-125). So the window is coherent in a single drained state.
What is actually open is narrower and more serious: the anti-starvation guarantee depends entirely on the caller stopping submission, and one caller never does.
- The only thing that lets active peer-copy leases drain to zero is
RankExecutor::can_submit()returning false whileshould_drain_for_offload()(helios/src/execution/ranks.rs:182-184, consumed athelios/src/server/runtime.rs:2261). That path exists only for the in-processWorker::runloop. serve_rank, the multi-process TP rank loop, takes the lease on COMMIT with nocan_submit/should_drain_for_offloadcheck at all:let guard = leases.enter(graph)?;thenexecutor.submit(...)(helios/src/execution/parallel.rs:652-656). With 2-frame pipelining on the peer side,peer_graphs_activeneed never reach 0,maybe_arm_offload_wave()therefore never fires in that process, and the peer's offload batches wait indefinitely — i.e. the pre-76e1813starvation that #628's own review flagged is fixed for single-process threaded TP and remains forRankPeers::Processes/ multi-host, whichflare-cli/src/cluster.rs:254-261explicitly wires into the gate.- Related:
PeerGraphLeasesis shared betweenRankExecutorandserve_rankonly as a type and lifecycle helper, not as state — each builds its own from its own manifest (parallel.rs:563-566vsranks.rs:143), so the two loops do not see each other's leases.
Test gap for exactly this: offload_makes_forward_progress_under_pipelined_peer_graphs (copy_gate.rs:445-500) simulates the pipelining loop and asserts the pause behaviour itself ("pause pipelining whenever should_drain_for_offload() is true", copy_gate.rs:453-461) rather than driving Worker/RankExecutor, so it passes whether or not the real can_submit wiring exists, and it has no multi-process analogue.
#14 [high] Research summary
Amendments to the report of 2026-11-30 (PR #628, head moved 1870a27 → 76e1813)
The PR moved. A second commit, 76e18130 "helios: bound CopyEngineGate fairness, scope gating to peer-copy models, and preserve metrics", landed and answers the @flare-autobot "Changes Requested" review of 11:59 UTC. The PR is now 19 files, ≈+1,165/−155 (was 14 files, +572/−72); helios/src/offload/copy_gate.rs is 584 lines (was 263). Three files entered the changed set that materially change prior findings: docs/prefix-cache-offload.md, heliopause/src/python.rs, helios/src/runtime_core/serving.rs.
Findings that are now closed and must not be repeated as live:
- The documented no-blocking invariant is fixed, not violated.
docs/prefix-cache-offload.md:133-136,917-924and1025-1029now describe the bounded Copy Engine drain, the 120 s bound and the fairness turns. (Residual:docs/same-process-tp.md:177-180(not opened) still lists the parked-rank/checkpoint region as unqualified.) - Per-batch sync no longer applies to every prefix-cache run.
NativeModel.copy_gateisOption<Arc<CopyEngineGate>>set only when a rank reconstructed a peer-copy graph (helios/src/runtime_core/model.rs:27,662,827-831; helperruntime_core/mod.rs:1347-1349); the ungated path keeps one sync per window (offload/transfer.rs:471-474,copy_batch_gatedat:308-338). This closes the "opposes #497" finding for single-GPU and non-peer-copy TP. - The multi-host shard peer path is gated now (
offload/shard.rs:47-61, called fromflare-cli/src/cluster.rs:254-261). The Heliopause/Python manifest is stillpeer_copy_graphs: Vec::new()(heliopause/src/python.rs:331) but alsooffload: None(:318), so it could never engage a gate. - The CI red is retracted as a blocker. The only failing check was
Python CPU tests, a main-wide breakage tracked in #623 and fixed by #624 (merged 2026-11-30 12:39); the author reportsHelios lifecycle(lifecycle + kani) passing on1870a27. has_peer_copieswas deleted andpeer_copy_graphslength is now validated (execution/manifest.rs:835-843(not opened)).
What remains open, and what is new. Still unmeasured is the charter's performance requirement (#210/#397): no A/B offload throughput/latency figure, no offload-cost measurement, and detection is still literal Node::Copy on Memory::Peer only. Newly introduced by the redesign: (1) the fairness turnaround is real but its only enabler is RankExecutor::can_submit (execution/ranks.rs:182-184 (not opened), consumed at server/runtime.rs:2261) — the multi-process serve_rank loop takes the lease with no such check at all (execution/parallel.rs:652-656), so peer_graphs_active need never reach zero there and offload can still starve indefinitely on RankPeers::Processes/multi-host, which this same commit wires into the gate; the fairness test (copy_gate.rs:445-500) simulates the pause instead of driving Worker, so it cannot catch this. (2) The lease is held across the whole GPU-codec transform under gpu.codec, so a peer graph waits on encode/decode compute, not just a 16 MiB copy (transfer/codec.rs:288-303, 318-338, 748-780), which understates the doc wording. (3) The 120 s ExecutionError::Drain (copy_gate.rs:131-147) propagates through Worker::submit with ? into worker.fail_all (server/runtime.rs:2332-2339, 759-776), i.e. a stuck offload batch now shuts the served worker down — an undocumented failure mode. (4) Reply.elapsed now subtracts the max gate wait (offload/transfer.rs:780,792-799), which feeds selene/src/memory.rs:1450-1456 → selene/src/levels.rs:57-110 → worth_fetching/worth_transfer deferral (server/runtime.rs:223-229,2805-2860), so the change alters a scheduling heuristic, not just telemetry. (5) The new gated verification is CI-invisible: #[ignore] at transfer/codec.rs:1286-1291 and inside the two-device test at offload/transfer.rs:1712,2013-2053, and the author states the GPU re-run is still pending.
Full detail is in scratchpad notes #11 (what 76e1813 changed, per finding), #12 (new risks with citations) and #13 (the corrected, narrower starvation path).
#15 [high] Consolidated amendment text for the report (supersedes note 12 item 1; use with notes 11-13)
Use this as the authoritative amendment text; note #12's item 1 is superseded by #13 (the offload wave is coherent when armed; the surviving starvation path is the multi-process rank loop).
Event
PR #628 moved from 1870a273 to 76e18130 (yatesdr, 2026-11-30): "helios: bound CopyEngineGate fairness, scope gating to peer-copy models, and preserve metrics". It is a response to the @flare-autobot review of 2026-11-30 11:59 UTC, which had recommended Changes Requested with 3 blockers / 4 should-fix / 3 subtract / 2 nits (starvation under 2-frame pipelined decode; per-16 MiB blocking sync for all prefix-cache users; failing CI). Case file opened 11:45 UTC (23a7b4eb-…); author replied 12:55 UTC with a per-blocker changelog and a validation section. Engagement: still no human review, no inline comment, no reaction — only the bot and the author.
Size / shape change
14 files +572/−72 → 19 files ≈ +1,165/−155 (pr_files). Newly touched: docs/prefix-cache-offload.md (+18/−6), heliopause/src/python.rs (+1), helios/src/execution/tests.rs, helios/src/model/contract.rs, helios/src/model/testing.rs, helios/src/runtime_core/serving.rs, helios/src/offload/transfer/lifecycle_tests.rs. helios/src/offload/copy_gate.rs 263 → 584 lines.
Findings the amendment closes (do not restate as live defects)
- Docs invariant updated, not violated.
docs/prefix-cache-offload.md:133-136("never blocks the model worker thread except for the bounded Copy Engine drain before launching a graph that contains in-graph peer-to-peer Copy Engine nodes … Single-GPU and non-peer-copy models stay ungated"),:917-924(per-modelCopyEngineGate, 120 s bound, fairness turns, "Models without peer-copy graphs omit the gate and keep one synchronization per transfer window"),:1025-1029. Residual gap:docs/same-process-tp.md:177-180still lists the rank-parked/checkpoint region as not qualified. - Zero-gate overhead is now real for non-peer-copy models.
NativeModel.copy_gate: Option<Arc<CopyEngineGate>>(runtime_core/model.rs:27,662), assigned only if any rank reconstructed a peer-copy graph (model.rs:827-831,runtime_core/mod.rs:1347-1349); threaded throughBinding(offload/mod.rs:42,49,58),attach_offload(model.rs:990-996),manifests()(model.rs:1041-1047),open_with_gate(server/runtime.rs:719-731),join_peer_with_gate(offload/shard.rs:47-61, fromflare-cli/src/cluster.rs:254-261).copy_batch_gatedsyncs per batch only whenSome(offload/transfer.rs:308-338); the ungated path keeps the single end-of-window record+sync (:471-474). This closes the "per-batch sync opposes #497 for every prefix-cache run" finding. - Ungated-path claim now mostly true. Only
open()(offload/mod.rs:114-119),join_peer(offload/shard.rs:37-45) and#[cfg(test)] Copiers::new(offload/transfer.rs:2167-2171) are gate-less.heliopause/src/python.rs:331still sendspeer_copy_graphs: Vec::new(), but that manifest also setsoffload: None(:318), so the Heliopause path cannot engage a gate even in principle. - CI red retracted as a blocker. The only failing check was
Python CPU tests, a main-wide breakage: issue #623 (closed 2026-11-30 12:39) fixed by #624 (merged 2026-11-30 12:39, head078315e, tests-only, +15/−25). Author statesHelios lifecycle(lifecycle + kani) passed on1870a27. Local validation claimed on76e1813:cargo check --locked --all-targetsunder-D warningson four crates;helios1,740/1,740 lib tests,flare245/245,flare-cli201/201 + 4 integration suites. ExecutionManifest::has_peer_copiesdeleted;validate()now rejects a populatedpeer_copy_graphswhose length differs fromgraphs(execution/manifest.rs:835-843, testexecution/ranks.rs:215-224). Fine — the field is introduced by this same PR, not yet a compat surface.- Lease lifecycle consolidated into
PeerGraphLeases(offload/copy_gate.rs:242-305), reused byRankExecutor(execution/ranks.rs:143) andserve_rank(execution/parallel.rs:563-566,652-663,692); theRankExecutorInnerdelegation boilerplate and the duplicatedcopy_batch_gated/drain_streambodies are deduplicated (offload/transfer.rs:290-339, used fromtransfer/codec.rs:997).
Findings that remain open
- Charter performance rule (#210) and root-cause rule (#397) still unmet. No A/B offload throughput or latency figure, no measurement of the gate's cost, and #627's own ablations still show the Copy Engine mechanism is not characterised. Author explicitly defers the numbers: "the new gated CUDA transfer tests and a peer-copy A/B offload latency measurement have not yet been run on
76e1813because the SM120 test host's GPUs are currently occupied". - Detection still literal: only
Node::Copynodes whose endpoint allocation is declaredMemory::Peer(runtime_core/mod.rs:919,1155,1238); kernel-driven DMA and peer-mapped localMemory::Devicetargets are not marked. - Gate is per-process:
RankPeers::Processes/ multi-host gets one gate per process; this commit only reuses thePeerGraphLeasestype, not state, across loops.
New risks introduced by 76e1813 (full citations in notes #12 and #13)
- The anti-starvation turnaround depends solely on
RankExecutor::can_submit(execution/ranks.rs:182-184, consumed atserver/runtime.rs:2261), which exists only for the in-processWorker::runloop.serve_ranktakes the lease with no such check (execution/parallel.rs:652-656), so in multi-process TPpeer_graphs_activeneed never reach 0,maybe_arm_offload_wave()(copy_gate.rs:54-68) need never fire, and offload batches can wait indefinitely — the pre-fix starvation survives precisely on the layout thatflare-cli/src/cluster.rs:254-261newly wires into the gate. The fairness test (copy_gate.rs:445-500) simulates the pause rather than drivingWorker, so it cannot detect a broken wiring, and has no multi-process analogue. - Peer-graph drain now covers codec compute, not just copies. At the five GPU-codec sites the lease is acquired before the transform under the
gpu.codecmutex and released after completion (transfer/codec.rs:288-303,318-338,748-780), contradicting the docs' "bounded in-flight 16 MiB batch drain" (docs:133-136,1025-1029). - The 120 s bound now fails the served worker.
ExecutionError::Drainfromcopy_gate.rs:131-147propagates throughRankExecutor::submit(execution/ranks.rs:156-160) andWorker::submitwith?(server/runtime.rs:2261,2332-2339) intoworker.fail_all+ executor teardown (server/runtime.rs:759-776). Undocumented; the error's own counters are the only diagnostic. Reply.elapsednow excludes gate wait and feeds a scheduling heuristic.max_gate_waitsubtracted inTransfers::absorb(offload/transfer.rs:780,792-799) →selene/src/memory.rs:1450-1456→selene/src/levels.rs:57-110→worth_fetching/worth_transferdeferral (server/runtime.rs:223-229,2805-2860). Defensible ("measure the copy") but it makes gate-stalled transfers look faster and therefore more worth doing; max-across-ranks is an approximation.- Multi-process deadline interaction: in
serve_rankthe lease is taken beforeexecutor.submit(execution/parallel.rs:652-657) while the root's per-frame deadline (parallel.rs:670-671,parallel/wire.rs:28= 120 s) is already running, so a long gate wait can surface as "rank graph completion deadline expired" instead of the gate'sDrain. - New gated verification is CI-invisible:
#[ignore]on the gated codec test (transfer/codec.rs:1286-1291) and the gated transfer arm lives inside the "requires two CUDA devices" test (offload/transfer.rs:1712,2013-2053). No gated copy path has yet executed anywhere.
#8 [medium] Recent activity: base c146d7b, only #626 landed since; change builds on #497/#504/#525 and contradicts docs §2.5/§2.10
- Base commit is
c146d7b(2026-11-29, "Remove copy drafts and history drafts while keeping legacy cores loadable"). The only default-branch commit since then that touches this PR's files is 0a8c20f4 (#626, Luke Alonso, "Allow speculative reasoning for grammar-constrained requests") touchinghelios/src/server/runtime.rs— a scheduler/speculation change, orthogonal to offload; the PR's ownserver/runtime.rshunk (:715-733) is in the offload-attach block, so no textual conflict expected but a rebase is due. helios/src/offloadcommit history (search_history, newest first): 1870a273 (this PR), dad2fa56 #497 "Reduce disk offload restore latency…" (PCCessna/FujitsuPolycom, 2026-11-29), ba3afb13 #589 CUDA-12 batched copies / ARM64 / Selene budgeting (Luke Alonso, 2026-11-28), 6d74db3a "Fix Rust compiler warnings…" (Luke Alonso, 11-26), then yatesdr's codec series c36a6a02/#527, 225758fe/#525, 716df00f/#504 (11-25), then #429, #415, pool attachment, #168, #171, #141, #92, #80, #38, and Luke Alonso's 2026-10-12 prefix-offload merge train.- So the change builds directly on #504/#525/#527 (the codec entry points it gates) and sits on top of #497's latency work; it does not reverse either, but it adds per-batch synchronisation to the same worker #497 was tuning for latency — a direction-of-travel tension worth naming.
docs/prefix-cache-offload.md:499-515(section 2.5, "Transfers, slabs, and record files") describes exactly the behaviour #628 changes: one thread per rank, one lowest-priority stream, batchedcuMemcpyBatchAsync, "records its event … waits on it, and replies", batches of at most 16 MiB / 4,096 entries, "These bounds limit submitted work; section 4 measures the resulting delays on shared copy engines." Section 2.10 (:900-928) states "The model stream never waits on an offload event" and "Batch size and stream priority alone do not bound those delays" — the last sentence is precisely the gap #628 fills, so the change is anticipated by the doc's own reasoning while contradicting its stated invariant.docs/same-process-tp.md:177-180explicitly lists as Not qualified: "four ranks, graphs that contain b12x spin-barrier collectives, process checkpoint and restore while rank threads are parked on the DispatchRing condition variable". #628's live validation is single-host threaded TP2 only, consistent with that gap; the doc was not updated.
#9 [medium] People: yatesdr owns the Selene offload tiers; Luke Alonso/Martin Vit/FujitsuPolycom nearby; no one has engaged yet
- Author: yatesdr, GitHub association COLLABORATOR. In the last 180 days: 80 merged PRs, 9 closed, 5 open (#627, #628 among them). Areas:
helios/src(34),docs(33),selene/src(32),selene-manager/src(25),selene-manager/tests(20). Commit counts on default branch in last 180 days in the touched area: helios/src — Luke Alonso 229, Martin Vit 52, yatesdr 47; heliopause/src — Luke Alonso 60, Martin Vit 11, Jason Cook 5. - yatesdr is the original and dominant author of the Selene host prefix-cache tiers that this PR gates: #80 "Move the host prefix-cache tiers into a CUDA-free selene crate", #92 "Share prefix KV cache between instances and hosts through a selene pool manager", #141 host-tier eviction, #168 "Selene: store only what a request may resume", #415, #429, plus the recent KV-codec series #504/#523/#524/#525/#526/#527 and #609/#610/#611/#612 (selene/selene-manager fixes, all merged 2026-11-29). Recent work immediately before this PR is the codec/selene-manager hardening run, so #628 is a continuation of the same subsystem, not a drive-by.
- Charter note: the "Respect contributors" rule names
@voipmonitor,@original-el8,@lukealonsoas priority contributors — yatesdr is not on that list, but is the effective owner of this code path by commit history. - Who usually works here: Luke Alonso (largest helios/src + heliopause/src volume, and the author of the 2026-10-12 prefix-cache-offload merge train and #589/#607/#620/#626), Martin Vit (helios/src, #566 Engram prefetch, memory-limit split f2d959e3/355c7a82), FujitsuPolycom (perf/offload PRs #497, #496, #540, #542), voipmonitor (#174/#236/#479/#555/#557 collectives and capacities), original-el8 (#430 persistent workers), jcartu (#505/#621), Jason Cook / Javier López (multi-host prefix records, #126/#334).
- Who has engaged so far: nobody.
pr_commentsreturns "No comments." — no review, no inline comment, no reaction, no flare-autobot case-file comment (which several other PRs in this area received within minutes: #497, #525). Issue #627 likewise has 0 discussion entries.