Recommendation: Changes Requested
The core fixes for #722's PCIe kernel-P2P CopyEngineGate detection, the three-phase cross-rank teardown barrier, the Reply::Started(Result<()>) startup drain handshake, and the global-rank Prometheus metrics label are sound and well-structured. However, verification at 224fb40 confirmed one Blocker in AsyncTransfer's new unflushed-IO tracking (where swap_remove desynchronizes inflight_io order from io_uring SQ FIFO order after a partial submit, causing complete_io to permanently drop a real kernel completion) and two Should Fix defects in ThreadedExecutor (RankWedgeWatchdog::CloseStalled aborting progressing/multi-stage teardowns and best_effort_drain_peers skipping already-drained peers after a wedged peer exhausts the shared deadline).
Merge Risk
Level: High
- A partial
io_uringsubmission followed by any earlier completion causesmark_io_flushedto flag the wrongInflightIo, which makescomplete_iosilently drop a live kernel CQE and permanently hang GPU demand waits and leak pinned pools intoFailedDrain. RankWedgeWatchdogcallsstd::process::abort()insideclose()after a fixed 150 s wall-clock timer without tracking teardown progress, which can abort legitimate slow or poisoned teardowns whose own stage timeouts exceed 150 s.best_effort_drain_peerscan drop unjoinedJoinHandles for healthy peers that already sentReply::Drainedwhen an earlier peer consumes the shared 120 s timeout.
Walkthrough
- PCIe peer-access
CopyEngineGate&AsyncTransferdecoupling (helios/src/runtime_core/{payload,mod,serving,model}.rs,docs/prefix-cache-offload.md): Splitspeer_copy_graphs(strictlyNode::Copy(Memory::Peer), still used by load-timevalidate_async_transfer_peer_copy_compatibility) frompeer_access_graphs(peer copies/memsets, kernel arg/attr relocations or inline peer addresses, payload-scanned pointer tables, and peer-referencing module globals), enablingCopyEngineGateon single-host multi-rank deployments without all-pairs NVLink via NVMLP2P_CAPS_INDEX_NVLINK. - Three-phase cross-rank teardown barrier (
helios/src/runtime_core/{mod,model}.rs,docs/runtime-core-design.md): Replaces short-circuiting per-rank teardown withteardown_model_ranks— (1) stop persistent + async-transfer workers without short-circuiting andcuCtxSynchronizeon all ranks, (2) joinengram.clear()andoffload.reset()whileMappedHost/CUDA contexts remain live then destroy per-rank execution resources, (3) release green contexts, VA reservations, and primary CUDA contexts in reverse rank order (retaining resources until exit if any rank fails drain). AsyncTransferflush/fault hardening, rank metrics, and TLA+ (helios/src/async_transfer/{io_backend,scheduler,worker,lifecycle_tests}.rs,helios/src/server/metrics.rs,verification/helios-lifecycle/{AsyncTransfer.tla,AsyncTransfer.cfg,README.md (not opened),check.py}): Addsflush_queued_sqesandpending_submissions()to retryEINTR/partial submissions, tracksflushedonInflightIoandhardware_signaledon faulted DMAs to prevent completion-slot sentinel clobbering, fixesflare_async_transfer_*ranklabels to report global rank IDs, and extends the TLA+ model/conformance/mutation suite to 16-integer projections.- Startup drain handshake and rank-wedge watchdog (
helios/src/execution/threaded.rs): CarriesResult<()>inReply::Startedso peers failingfinish_startupremain inrun_startup_phaseto answerCommand::Drain -> Reply::Drained, shares a single deadline inbest_effort_drain_peers, and addsRankWedgeWatchdogto monitor coordinator/peer/close stalls and abort on wedges.
Pre-merge Checks
- [PASS] Security / malicious screen: No suspicious network, exfiltration, unsafe boundary bypass, or instruction-injection patterns; payload scanning reads already-authenticated bytes.
- [PASS] Charter & value fit: Directly addresses reproducible P1 release bug #722 on target SM120 PCIe hardware using topology-derived gating with no per-model branches or wire/core-format changes.
- [WARN] Related / duplicate / conflict check: Same-day follow-up to #721; sibling open PRs #726/#723 touch
prepare_async_transfers/release_execution_resourcesand should be serialized if merged alongside #727. - [WARN] Tests & verification evidence: Unit tests, TLA+ conformance/mutations, and an SM120 TP4 live run are documented (and environmental 403 failures on gated HF templates plus unrun SM103/SM121/RoCE/Kani are disclosed), but the live run used a different core/workload than #722 and existing
AsyncTransfertests did not catch theswap_remove/partial-flush ordering bug below.
Blockers
mark_io_flushed+complete_ioswap_removedesynchronizesinflight_iofromio_uringSQ FIFO order and permanently drops real kernel completions (helios/src/async_transfer/scheduler.rs:231-243,578-583;helios/src/async_transfer/worker.rs:994-1001,1226-1248)- Verified behavior:
pop_next_io()pushes newInflightIoentries to the back ofself.inflight_io(scheduler.rs:566), andworker.rs:1228-1248computesflushed_now = scheduler.unflushed_io_count().saturating_sub(args.io_backend.pending_submissions())and passes it toscheduler.mark_io_flushed(flushed_now), which marks the firstcountunflushed entries inVecindex order (scheduler.rs:233-241). However,complete_io()removes finished entries viaself.inflight_io.swap_remove(pos)(scheduler.rs:583), swapping the last element intoposand scrambling submission order relative to the kernelio_uringSQ FIFO. - Concrete failure trace:
- Stage reads
A, B, C->inflight_io = [A(unflushed), B(unflushed), C(unflushed)],io_uringSQ FIFO =[A, B, C],queued_sqes = 3. - Partial flush submits 1 SQE (
A) (Ok(1)thenEBUSY/Ok(0)):queued_sqes = 2,flushed_now = 1->mark_io_flushed(1)marksA. Acompletes (normalok = trueorok = false) ->complete_io(A, _)executesswap_remove(0)->inflight_iobecomes[C(unflushed), B(unflushed)], while theio_uringSQ still holds[B, C].- Next partial flush submits 1 SQE (
B):queued_sqes = 1,flushed_now = 1->mark_io_flushed(1)marksC(inflight_io[0]) asflushed = truewhile leavingBasflushed = false. poll_completions()(io_backend.rs:198-201) reapsB's CQE (IoCompletion { op_id: B, ok: true }) and removesBfromIoUringBackend.expected;worker.rs:998callsscheduler.complete_io(B, true).scheduler.rs:580-582executesif ok && !self.inflight_io[pos].flushed { return None; }and silently discardsB's completion without removingBfrominflight_io.
- Stage reads
- Impact:
B's CQE is permanently lost. Any GPU demand wait onB's completion slot hangs forever, any bounce slot held byBleaks permanently, and shutdownfinish_drain()(scheduler.rs:814) permanently fails intoChannelState::FailedDrain, leaking pinned pools and CUDA handles until process exit. - Fix: Preserve submission order in
inflight_ioby replacingswap_remove(pos)withremove(pos)atscheduler.rs:583(max_total_iois 32, so ordered removal is O(32) and preserves exact SQ FIFO order), or track a monotonic dispatch sequence number onInflightIoand havemark_io_flushedmark thecountunflushed entries with the lowest dispatch sequence. Add a regression test exercising partial flush -> completion of first op -> second partial flush ->complete_io(B, true).
- Verified behavior:
Should Fix
-
RankWedgeWatchdogCloseStalledfiresstd::process::abort()during legitimate slow or multi-stage teardowns (helios/src/execution/threaded.rs:594-598,679-687,1015-1029,1211-1233)- Verified behavior:
begin_close()setsclosing = true(one-way) and incrementsactivity, but theclosingarm of the watchdog loop (679-687) never readsactivityand never resetsclose_since. It applies a single fixed 150 s wall-clock deadline (TIMEOUT + WATCHDOG_GRACE) across all stages ofThreadedExecutor::close(): drainingself.pendingviaself.poll()?(up toTIMEOUT = 120 sper frame),close_peers(..., TIMEOUT = 120 s), fallbackbest_effort_drain_peers(..., TIMEOUT = 120 s)wheneverpoll()orclose_peersfails, andself.local.close(). As a result, a poisoned teardown wherepoll()orclose_peershits its 120 s deadline only gets 30 s insidebest_effort_drain_peersbefore the watchdog callsstd::process::abort(), and a healthy slow teardown draining frames plus peers in >150 s while actively progressing also aborts. - Fix: Track
activityin theclosingbranch (resettingclose_since = Some(now)wheneveractivityadvances, matching thebusybranch at703-707), and callself.watchdog_state.record_progress()acrossclose()stage transitions (afterpendingdrains, as each peer joins inclose_peers/best_effort_drain_peers, and beforeself.local.close()).
- Verified behavior:
-
best_effort_drain_peersshared deadline skips later peers without checking already-queuedReply::Drained, leaving finished threads detached (helios/src/execution/threaded.rs:1278-1316)- Verified behavior: Hoisting
let deadline = Instant::now() + timeout;outside thefor peer in peers.iter_mut()loop (1292) means that if an earlier peer is wedged and consumes the 120 s budget,deadline.checked_duration_since(Instant::now())returnsNonefor all subsequent peers (1298). Thewhilebody never executes even once, so peers that already exited cleanly and queuedReply::Drainedinpeer.receiverare never polled,exitedstaysfalse, and theirJoinHandles are dropped withoutjoin(). - Fix: Even when
deadlinehas expired, run a non-blockingtry_recv()loop on every remaining peer so peers that already sentReply::Drained/Err(_)/Disconnectedare still joined (or poll remaining peers round-robin against the shared deadline so a wedged peer at index 0 cannot starve peers1..N-1). Do not join peers that have not confirmed exit.
- Verified behavior: Hoisting
Subtract / Simplify
- Delete
RankWedgeWatchdog::stop_and_join(helios/src/execution/threaded.rs:738-753): Byte-for-byte duplicate ofimpl Drop for RankWedgeWatchdog;self.watchdog.take()(1231-1233) already drops and joins the watchdog thread. - Delete unreachable duplicate
async_transferspeer-copy check inNativeResources::prepare_async_transfers(helios/src/runtime_core/mod.rs:1750-1755):NativeModel::loadnow enforcesvalidate_async_transfer_peer_copy_compatibilityright afterprepare_graphs(model.rs:925), andprepare_async_transfershas no other caller. - Deduplicate interval builder and double
collect_peer_referencing_allocationscall (helios/src/runtime_core/mod.rs:162-174,258-269,994-998,1117-1121): Share one helper to build merged(address, end)intervals fromStorageiterators, and compute(peer_refs, peer_ref_intervals)once instead of repeating the identical relocation fixpoint in bothprepare_kernelsandprepare_graphs.
Nits
all_nvlink_p2ppair symmetry (helios/src/runtime_core/model.rs:152-160): Querying both(handles[i], handles[j])and(handles[j], handles[i])is 2 lines and guards against directional/asymmetric NVML P2P reports.- Bound
EINTRretries inflush_queued_sqes(helios/src/async_transfer/io_backend.rs:146-161): CappingEINTRretries per call (e.g., 16 attempts) avoids theoretical livelock under heavy signal delivery sinceworker.rs:1240already retries flushing on the next iteration wheneverpending_submissions() > 0. - Unused
AsyncTransferRuntime::rank()accessor (helios/src/async_transfer/worker.rs:493-495): Added with zero callers (metrics readsAsyncTransferSnapshot::rank); can be removed unless needed externally. - Documentation clarity: Note explicitly in the PR description that
RankWedgeWatchdogterminates viastd::process::abort(), and clarify indocs/api.md(not opened) that theflare_async_transfer_*ranklabel is the global rank ID.
Dropped on verification
- Upstream claim that
CopyEngineGatecan be silentlyNonewhilegate_peer_access == true(model.rs:921-942): False positive.copy_gate_policyreturns(true, false)only whenhas_peer_copy_nodes == falseandhas_peer_access_graphs == false— meaning every entry inpeer_access_graphson every rank is alreadyfalse, so no graph ever requests a gate lease andcopy_gate == Noneis completely consistent. - Upstream Major escalation for
flush_queued_sqesEINTRretry /stop()handle.join(): Over-escalated.ring.submit()(io_uring_enterwithmin_complete=0) is non-blocking and retryingEINTRmatches existing repo patterns (payload.rs:230,io_backend.rs:251);stop()'shandle.join()is pre-existing and bounded internally byDRAIN_TIMEOUT = 5 s. Downgraded to a Nit. - Upstream Major-5b claim about runtime-populated
rank_datapointer tables: Speculative limitation of static analysis; in captured Helios/b12x coresrank_datais populated before capture and stored in the payload (covered by the payload scan). - Upstream Minor claim that
peer_exit_grace = 30 s<TIMEOUT: Intentional design for #722 —mark_peer_exitedonly fires on unrecoverable peer exit/timeout (already poisoning the executor), so 30 s grace to enterclose()before aborting a wedged rank 0 is deliberate. - Upstream Minor claim that
chunk_bytes = ((CHUNK / ranks) & !7).max(8)introduces non-4096 read amplification / div-by-zero: Not a regression — pre-PRCHUNK / ranksalready had identicalranks = 3non-4096 sizing andranks >= 1assumption;& !7simply avoids splitting 8-byte pointers across chunk boundaries. - Upstream Minor claim of "2.58 × 10⁸
partition_pointbinary searches" inpayload::load: False —address_in_intervals(mod.rs:177-180) short-circuits onvalue < floor || value >= ceilingbefore callingpartition_point, so almost all weight words perform only two integer comparisons overlapped with direct I/O. - Upstream Subtraction claim that
WatchdogCallGuard::enter'skeep_busyparameter is dead (threaded.rs:611-619,1070): False —ThreadedExecutor::submit()has multiple early return paths (1071,1075,1085,1088,1130,1133) before line1127; passing!self.pending.is_empty()toenter()is necessary so early returns (e.g.,can_submit == falsewhile frames are pending) do not clearbusytofalse. - Upstream Subtraction claims to delete
stop_rank_workers(mod.rs:2035) andteardown_model_ranks(model.rs:1275): Dropped — both are deliberate testable seams providing the sole CPU-runnable unit tests for the non-short-circuit worker stop and three-phase teardown barrier. - Process/scope complaints (splitting PR into 4 PRs, unrun SM103/SM121/RoCE, live workload differing from #722, CI status not observable): Disclosed limitations or non-blocking process preferences; noted concisely in Pre-merge Checks rather than escalated.