PR #737 — async_transfer: DevToHost, dual-stream H2D, DEFER_TASKRUN io_uring, host-wide RAM pool budgeting
Case file. Facts are cited to file:line at head 46e6a3b or to PR/issue numbers. Nothing here judges merge-worthiness.
Key findings (what the description does not tell you)
- It reverses an invariant the two preceding PRs were built on. Before #737 all device completion writes serialized on a single
copy_stream(the comment saying so was removed in this diff); #721/#727's fault, drain andhost_mirror_on_drainlogic assume that. #737 splits into three streams (copy_streamhigh-prio,bg_copy_stream,d2h_stream) and restores ordering ad hoc withcuStreamWaitEventslot reuse plus a per-slotstream_comp_max: Vec<Cell<u64>>that silently skips a completion write below the slot maximum (helios/src/async_transfer/worker.rs:980-1024,:1422,:1543). A completion write can now be skipped, not merely deferred. Only the live CUDA test covers it (worker.rscuda_tests slots 6/7); there is no CPU-only test andAsyncTransfer.tlahas no per-slot stream dimension. - Undisclosed default changes.
DEFAULT_MAX_TOTAL_IO32→16 andDEFAULT_MAX_BG_IO8→4 (worker.rs:48-49) halve per-channel NVMe read concurrency — entangled with the PR's own NVMe/tail-latency claim.bounce_pool_geometrynow returnsclamp(512 MiB / slot_bytes, 16, 32)(worker.rs:94, test:2434), so 16 MiB extents pin 32×16 MiB = 512 MiB of bounce instead of 256 MiB, which flows intohost_reserveand the newpinned*ranks/512VRAM page-table charge. NewDEFAULT_MAX_D2H = 2(worker.rs:52), while the formal model is checked atMaxD2h = 1(verification/helios-lifecycle/AsyncTransfer.cfg:6). - No telemetry exists for the new path.
ControlHeaderhas onlybytes_disk_to_host/bytes_host_to_dev/bytes_disk_to_dev(ring.rs:200-204),CompletionNoticelikewise;complete_d2h/mark_d2h_faultedset all three to zero (scheduler.rs:994-996,:1021-1023) even thoughmark_d2h_faultedpublishes an error sentinel. Prometheus exposes only the three existing counters. Full-duplex D2H traffic and D2H failures are invisible to operators. - Docs contradict themselves inside one file.
docs/cli-design.md:761now says "Per-host ceiling … (divided evenly across local discrete ranks)", while the sampleflare.toml(not opened) in the same file atdocs/cli-design.md:1418still says "Per-rank ceiling". The--helptext (flare-cli/src/cli.rs:961-969) was already "Per-host", so the behaviour of--pool-ram-memorychanges for existing multi-rank users while the flag's help text does not change. - The performance headline has no baseline. ">5,000 ms → 1,202 ms cross-rank demand-stall spread" names no baseline commit/config, supplies no raw logs or per-rank table, and is confounded by the same PR's IO-depth halving and new 50 ms spin. This sits against
docs/design-review.md:106-115("Performance claims require equivalent baselines … keep raw measurements"). The 2,198,299-transfer smoke run is likewise self-reported with no attached log. - Kani was not run.
kani_proofs.rsgained a DevToHost arm (kani_proofs.rs:199-217) and is disclosed as "awaits CI", butdocs/design-review.md:247-251says an unrun Kani proof "blocks commit and PR acceptance" and "disclosure does not excuse" it; the mitigation is the repo's CIkaniworkflow. - Background prefetch can now starve, not just be capped.
pop_next_io/pop_next_dma/pop_next_d2hskip background classes whenever any demand op is in flight (scheduler.rs:634,:789,:924) with no age/credit mechanism and no liveness property in the model — the mirror image of the head-of-line blocking being fixed. - The motivating consumer is outside this repo. Nothing in-repo emits opcode 5 (
helios/manifest.md,ring.rs,worker.rstests only); no issue or other PR asks for D2H demotion, DEFER_TASKRUN/ReadFixed, host-wide pool scoping or parallel startup. The graph-side consumer is the companionlocal-inference-lab/hyperflare-recipesPR that must land after this one. - It collides with open #726 in
prepare_async_transfers(helios/src/runtime_core/model.rs:1080-1110), which #737 rewrites to start rank workers concurrently viastd::thread::scope.
The change
16 files, +1769/−268 (description and file list agree).
- Driver bindings —
cuCtxGetStreamPriorityRange,cuStreamCreateWithPriority,cuStreamWaitEvent,cuMemcpyDtoHAsync_v2(helios/src/runtime_core/driver.rs, +4). - Ring ABI —
Opcode::DevToHost = 5andValidatedCommand::DevToHost(ring.rs:64), withvalidate_command/ Kani harness extended for priority, alignment, nonzero length, host and device pool bounds, completion-slot bounds, bit-63COMPLETION_ERROR_BITexclusion.ABI_VERSIONstays 1 (ring.rs:12); an older runtime rejects value 5 withInvalidOpcode, so "backward compatible ABI v1 cores" is structurally accurate — a newer core against an older runtime fails cleanly, not silently. - Scheduler — new
d2h_queues,inflight_d2h,With_max_d2h(default 2,scheduler.rs:177,211,229),pop_next_d2h,mark_d2h_faulted,complete_d2h; memory release, epoch advance and drain now wait on D2H; background dispatch gated by demand-in-flight. - Worker — three streams,
wait_other_streams_on_slot, per-slotstream_comp_max,FaultedStreamKind{DemandH2d,BgH2d,D2h}in drain, wider bounce geometry, 50 msACTIVE_SPIN_WINDOW(worker.rs:43), storage-run rotation by a process-globalNEXT_WORKER_ORDINAL(worker.rs:59,948), andbind_worker_thread()+register_buffers()executed on the worker thread before publishingRunning(net effect matches the description; mechanism is recreate-and-rebind on the worker, not create-at-prep). - io_uring backend —
SINGLE_ISSUER | DEFER_TASKRUN | TASKRUN_FLAG | NO_SQARRAYwith kernel fallbacks, 1 GiBReadFixedregistration coveringHOST_POOLand bounce, silent fallback to plainRead,taskrun() || cq_overflow()plus a periodicIORING_ENTER_GETEVENTSwatchdog guarded byqueued_sqes == 0(this guard is what keeps #727's SQE flush accounting exact). - Budget/startup/docs —
async_transfer_device_reservediscrete branch rewritten (helios/src/runtime_core/memory.rs:75-164),host_pool_budget_and_total_with_reserveadded (selene/src/offload.rs:984) with the implicit Selene reserve applied only when--pool-ram-memoryis absent (memory.rs:1360passespool_ram_limit.is_none()), peer-UVA page tables chargedpinned * ranks / 512on discrete multi-rank hosts, integrated path unchanged; concurrent rank startup inmodel.rs;manifest.md,docs/cli-design.md,docs/runtime-core-design.mdupdated.
Said but not done / done but not said. The description's five bullets match the diff. Undeclared: the IO-depth halving, the pinned-bounce footprint increase and its VRAM charge consequence, the process-global ordinal, the default D2H depth of 2 vs modelled 1, the silent stream-priority fallback (when greatest_prio == least_prio every stream is plain cuStreamCreate, with no log/metric), and the CPU cost of 50 ms spinning per channel. Slight understatement: "moved ring creation onto the worker thread" is a rebuild-on-worker.
Verified budget math (memory.rs:75-164): -8G now reserves 8 GiB host-wide total, not 64 GiB; 64G is host-wide then divided (8 GiB/rank on 8 ranks); under MemoryLimit::Reserve the bounce bytes are subtracted before the reserve so the requested free reserve is preserved. New unit cases assert (224 GiB − 8·bounce − 8 GiB)/8 and ((8 GiB + bounce)·8).div_ceil(512). Fraction(f) still uses total RAM before division, though it is min'd against the MemAvailable-derived per-rank ceiling.
The why
Five declared defects: no D2H Copy Engine path for demoting cold VRAM residents; demand and background H2D sharing one stream plus the scheduler dispatching background while demand is in flight; io_uring ring built on the setup thread without SINGLE_ISSUER|DEFER_TASKRUN, unfixed reads, identical cross-rank read order on NVMe RAID-0; --pool-ram-memory divided per-rank before being applied with the implicit reserve always deducted, and pinned/512 under-charging peer-UVA page tables; sequential per-rank worker startup.
Demand trail: no in-repo issue or PR asks for any of it (searches for "DevToHost … demote", "pool-ram-memory host RAM reserve", "io_uring DEFER_TASKRUN NVMe throughput ReadFixed", "multi-tier weight offloading cold resident demote" return only #737 and its predecessors #711/#720/#721). The subsystem is two days old — #711 merged 2026-12-03, #721 2026-12-04, #727 2026-12-04 23:31, #737 opened 2026-12-05 03:33 — so want is short and entirely author-driven. Items 4 and 5 stand on their own as defects in code this author shipped 48 hours earlier; item 4 changes behaviour for existing multi-rank users. The exclusive 2Q VRAM/RAM cache that needs Opcode::DevToHost is not visible in this repository.
Related work
- Stack: #711 (merged 12-03) created the AsyncTransfer ring/scheduler/worker/io_backend/Kani/TLA model and the pool flags; #721 (merged 12-04) hardened startup, DMA/teardown lifetimes,
hardware_signaled,host_mirror_on_drain, EINTR; #727 (merged 12-04 23:31) gated peer-access graphs, fixed teardown/startup drain races and grew the TLA projection to 16 ints (13 and 9 files shared with #737 respectively). #737 grows it to 20 and is the fourth increment in four days, same author, largely the same files. - Collision: open #726 (original-el8) restructures
prepare_async_transfers/release_execution_resources, the same function #737 parallelizes; #727's autobot check already flagged #726 as needing serialization. - Same-file neighbours: open #718 (fakoli, prefill-only KV handoff/pool-only capture) and #314 touch
memory.rsbut not the async-transfer budget function; merged #713 (012219a1, Joshua Cartu, 12-05) touchedmemory.rsbetween #727 and #737 and does not conflict in substance. - Adjacent, not competing: #628 (gate offload Copy Engine batches during peer-copy graphs), #607 (pool staging UAF), #589/#674 (unified-memory budgeting, NVMe throughput), #465/#432/#410/#409/#408 (original-el8 SM103 expert movers — a different mechanism for "cold weights on a slower tier", closed, not superseded), #323 (integrated-GPU headroom, left unchanged), #736/#735 (shared
CU_STREAM_NON_BLOCKINGsymbol only), #255, #576 (unrelated). #504/#492/#486/#477/#436 share onlyselene/src/offload.rsplumbing.
Recent activity
helios/src: Luke Alonso 249 commits/180d, Martin Vit 52, yatesdr 52; 60-day activity includes #705, #729, #723/cfb72093, #691, #621. verification/helios-lifecycle: Luke Alonso 17 of ~24 recent commits, PCCessna 3, Martin Vit 2; #737 extends the files #727 touched four hours earlier. selene/src: yatesdr 38, Luke Alonso 8. memory.rs history: #713, #721, #711, #659, #709, #674, #646, #613, #589 — the function #737 rewrites is two days old and already amended twice by the same author.
#737 builds on #721/#727 rather than undoing them (extends the fault model, refines the spin, preserves flush accounting); the one deliberate reversal is the single-stream completion invariant. No main commit between #727's merge and #737's head touches these files except #713 in memory.rs.
People
lukealonso: COLLABORATOR, named a priority contributor in the charter, 56 merged / 0 closed / 0 open PRs in 180 days, dominant committer in helios/src, docs and the lifecycle verification, author of the entire AsyncTransfer subsystem. The only touched area with a different natural reviewer is selene/src (yatesdr); the 7-line change there is behaviour-preserving for existing callers (host_pool_budget_and_total still forwards with apply_reserve = true, offload.rs:979). Prior review pattern in this series: flare-autobot produced concrete blockers on #713 and #727 (a Blocker in flush ordering, swap_remove/FIFO, CloseStalled, peer-drain join) and each PR took 2–3 fix rounds before merging.
Community
Zero. No comments, no reviews, no reactions as of 2026-12-05; pr_comments returns "No comments.". The usual flare-autobot first-pass review has not appeared yet.
Project fit
Charter: the change stays inside Helios's hardware/OS/lifecycle boundary, adds no per-model branches and no captured-graph op contracts, and supports the charter's host-memory prefix-cache direction — scope is aligned. The tensions are evidential:
docs/design-review.md:106-115(principle 12): equivalent baselines, complete GPU steps across all ranks, keep raw measurements, disclose unrun checks — partly met (the perf headline is baseline-free and entangled).docs/design-review.md:116-123(principle 13): core compatibility preserved — met (ABI_VERSION1, cleanInvalidOpcode).docs/design-review.md:232-261: never touch covered code without running its simulator and formal checks, keep formal bounds aligned with runtime capabilities, and unrun Kani "blocks commit and PR acceptance" — the formal model was run and updated (aligned), while Kani was not run (tension), and the modelledMaxD2h = 1is below the production default of 2.docs/design-review.md:252-259: live multi-GPU execution mandatory for cross-rank transport changes — met only by a self-reported smoke run.docs/design-review.md:147-160(principle 16): four-part description, before/after, expected vs measured — followed in order.
Claims and evidence
| Claim | Backing |
|---|---|
| D2H opcode, validation, bounds | Diff + ring.rs:64, kani_proofs.rs:199-217; Kani unrun |
TLA+ DispatchD2h/CompleteD2h/MarkD2hFaulted, 20-int projection |
Real: AsyncTransfer.tla:158-186, invariants wire inD2h in; MaxD2h = 1 |
| 1,847,851 generated / 125,668 distinct states, 4,410 observed Rust transitions, 64/64 mutations, exit 0 | Self-reported command output; no CI artefact attached |
| >5,000 ms → 1,202 ms stall spread | Single isolated run, no baseline commit, no raw data, confounded by IO-depth change |
| 2,198,299 transfers, 0 errors, 9.1 s drain | Self-reported flare run smoke, no log attached |
| Rust test counts (helios lib 1,973; 60/60 targeted; other crates) | Plausible; 6 disclosed failures are unrelated gated-HF template downloads (HTTP 403), same disclosure as #727 |
| "Backward compatibility for existing ABI v1 cores" | Structurally verified |
Host-wide --pool-ram-memory, page-table charging |
Verified in memory.rs:75-164; only unit-test coverage, no operator-facing doc of multi-rank semantics beyond the changed table |
Reach
Config/default changes: IO depth 32→16 (bg 8→4), bounce pinning up to 512 MiB, default D2H depth 2, silent priority fallback, 50 ms per-channel spin, process-global rotation ordinal. Operator-visible: --pool-ram-memory semantics for existing multi-rank configs change with unchanged --help text (flare-cli/src/cli.rs:961-969), flare/src/runtime_settings.rs (not opened), flare-winui/bridge/src/lib.rs:1494 (not opened) and ignition/cli/config.py (not opened) pass the string through unvalidated. Published contract: helios/manifest.md:170-230 gains opcode 5 and the multi-stream rules; docs/runtime-core-design.md:729-780 updated. Telemetry unchanged. Platform: the fast path is Linux-only (DEFER_TASKRUN prefers ≥6.1, three fallbacks then plain IoUring::new); non-Linux pread and Windows paths untouched and untested here (disclosed). No new crate dependencies; cuMemcpyDtoHAsync_v2/priority bindings are available on all platforms via the dynamic driver. ReadFixed failure is swallowed (let _ = in worker_main) so nobody can tell if the fast path is active.
Process
Open, marked ready for review, unlabelled (sibling PRs carry triage:review/priority:P1/performance), opened and last updated 2026-12-05, head 46e6a3b, branch feat/async-transfer-d2h-and-uring-perf. CI on head pending. Zero reviews, zero comments. Description imposes an ordering constraint: merge this before the companion local-inference-lab/hyperflare-recipes PR (the same pattern #711 used with recipes#150).
Open questions / not found
- No raw measurement, baseline commit or log for either the 1,202 ms figure or the 2,198,299-transfer smoke; no token-throughput number anywhere in the PR.
- Whether CI's
kaniworkflow coversasync_transfer::kani_proofsand whether it passes: not determinable from here. - Whether the
stream_comp_maxskip path can drop a distinct completion (as opposed to a stale one) is asserted by construction and one live GPU test only; the TLA model cannot answer it (no per-slot stream dimension) and there is no CPU test. - No in-repo issue or report establishes demand; the consumer lives in the companion recipes repository and cannot be inspected here.
- Branch-level conflicts with #726 in
prepare_async_transferscannot be determined without the merge simulation. - Nothing found under: reactions/community interest beyond zero engagement; any charter-level scope objection.