PR #711: helios,heliopause,ignition,flare: add domain-agnostic AsyncTransfer primitive, runtime-sized device pools, and capture cache seeding

Raw Markdown for agents: https://autobot.eidonix.com/api/v1/cases/6a8b9314-8921-44af-9631-e489577835e0

Opened by a workflow run, Dec 3, 2026 2:40 PM EST. decide malicious: all_clear (100%): No malicious content found

explore

Author: lukealonso (COLLABORATOR; charter-named priority contributor and the project owner named in docs/design-review.md as the approver of new captured-graph op contracts; 42 merged PRs in 180 days; Discord: lukealonso) Motivation: Captured CUDA graphs cannot do host direct-I/O reads, pin host memory, size device byte pools at load, or run non-blocking Copy-Engine transfers with stream-ordered completion, so models whose weights exceed one GPU's VRAM cannot stage weight bytes inside a captured graph. This adds that transport primitive to Helios (plus two operator pool-size limits and some Ignition capture-seeding fixes) so external model recipes can do tiered weight caching without model-specific code in the runtime. Scale: +6,387 / −72 lines in 57 files Proposal:

Full report · Notes

Value Proposition

Value Proposition — PR #711 (AsyncTransfer, runtime-sized device pools, capture cache seeding)

1. Charter alignment

The shape of the change is charter-correct: one domain-agnostic transport primitive in Helios instead of per-model offloading layouts or flags — exactly the "keep the runtime small and model-agnostic" rule (#267, #334) — and it follows the house pattern for new concurrency (bounded TLA+ spec + Rust conformance harness + Kani proofs, as in #430/#613/#595). Two gates are unmet:

2. Novelty & status

Genuinely additive: nothing competes (items_touching("helios/src/async_transfer") → only #711), nothing is obsoleted, and the proto additions are backward-compatible by construction. Caveat: Execution/RankBody field numbers and memory.rs are among the busiest surfaces in the repo (open #483/#664/#229/#314/#334; #709/#694/#659/#314), so landing is a coordination problem. The capture-seeding third is not additive: #606 (open, avifenesh) fixes the same transient-workspace defect in the same capture_forwards region, on top of merged #331 — textual conflict likely, semantic duplication plausible.

3. Value vs maintenance cost

Beneficiaries are recipe authors who must exceed single-GPU VRAM, and none exists yet. Cost is ~3,780 new lines of concurrency, a pinned-host VRAM reserve subtracted before pool/KV sizing, a silent rank-min clamp that rewrites Execution.buffers to floor(bytes/row_bytes) rows, an undocumented flare_async_transfer_* metric family, and untested TP>1 — the most material gap given the "larger than one GPU" motivation.

Verdict

Worth it with changes. Split out the capture-seeding fix (reconcile with #606 or drop it here); for the transport half, record Principle 1 approval, land one in-tree consumer that emits an extent directory, and attach a flare run served measurement covering SM120/SM121 and TP>1 before merge.

Full report Decide Value: yes (99%): This change is worth reviewing: it provides value to the project in line with its charter.

Classify intake

Selected: triage:design-review, enhancement, area:memory, area:preparation

Threshold: 65%

Triage

Priority

Type

Area

Model

Apply Labels (Intake)

Applied: +triage:design-review, +enhancement, +area:memory, +area:preparation

Subtraction and simplicity

Subtraction & Simplicity audit — PR #711 (head 6916f22, 57 files, +6,387/−72)

Not lean. The new AsyncTransfer runtime is densely commented and mostly well-factored at the module level, but it ships one whole duplicated config type, one dead public helper, one parameter set that recomputes its own input, a duplicated verbatim sizing expression, a duplicated /proc/meminfo parser, and three out-of-scope drive-bys. Each item below is a concrete deletion, with the number of lines it recovers.


High value

1. PoolMemoryLimit is a near-verbatim clone of MemoryLimit — delete it (−~75 lines)

helios/src/runtime_core/limits.rs:42-48 and :132-137 are the same three-variant enum:

pub enum MemoryLimit { Bytes(u64), Reserve(u64), Fraction(f64) }        // :44
pub enum PoolMemoryLimit { Bytes(u64), Reserve(u64), Fraction(f64) }    // :133

The FromStr bodies are the same parser twice (:70-105 vs :159-193, identical invalid closure, strip_prefix('-'), alphabetic-suffix branch, fraction branch), differing only in that the pool version skips the "must be positive" rejection of 0 (:167-169). validate is the same shape with one different message (:51-59 vs :140-147). And Display already delegates to the other type:

Self::Bytes(bytes) => write!(f, "{}", MemoryLimit::Bytes(*bytes)),      // :199
Self::Reserve(bytes) => write!(f, "{}", MemoryLimit::Reserve(*bytes)),  // :200

One enum plus validate(allow_zero: bool) / parse(allow_zero: bool) covers both, and the duplicated test pairs (:210-267) collapse into one table. Related: MemoryLimit::occupied_bytes (:61-67) and PoolMemoryLimit::cap_bytes (:150-156) are the same function with the Reserve arm split out — occupied_bytes returning Option and its callers re-matching Reserve by hand (memory.rs:287, :356) is the reason both exist.

2. prepare_async_transfers takes 3 parameters that recompute its 1 useful parameter — delete the parameters (−~10 lines, one less place to diverge)

helios/src/runtime_core/memory.rs:78-83 computes the host cap during planning:

let cap = match pool_ram_limit {
    Some(limit) => limit
        .cap_bytes(host_ram_available, host_ram_total)
        .min(host_ram_available),
    None => host_ram_available,
};

and that exact expression is recomputed verbatim in the allocator, helios/src/runtime_core/mod.rs:1477-1481:

let mut remaining_host = match pool_ram_limit {
    Some(limit) => limit.cap_bytes(host_ram_available, host_ram_total).min(host_ram_available),
    None => host_ram_available,
}
.min(planned_host_cap);

Since planned_host_cap is cap (memory.rs:99-102 returns it, model.rs:963/:971 threads it through), the .min(planned_host_cap) makes the recomputation a no-op. Replace the body with let mut remaining_host = planned_host_cap; and NativeResources::prepare_async_transfers (mod.rs:1462-1470) drops host_ram_available, host_ram_total, pool_ram_limit; model.rs:961 (async_transfer_host_ram) then serves planning only, and model.rs:963-971 loses a parameter pass-through. Same for memory.rs:1170-1171, which re-maps pool_vram_limit per rank even though cap_bytes has no per-rank variance (it is a pure function of available/total and the limit).

3. io_backend::open_direct_backend is dead and duplicates the caller's platform dispatch (−18 lines)

helios/src/async_transfer/io_backend.rs:284-301 defines the canonical constructor:

pub fn open_direct_backend(files: &[File]) -> io::Result<Box<dyn IoBackend>> {

…and nothing calls it. A repo-wide search finds the identifier only at its own definition. The production path instead re-implements the identical #[cfg(target_os = "linux")] / #[cfg(not(…))] split inline at helios/src/runtime_core/mod.rs:1572-1588:

#[cfg(target_os = "linux")] { Box::new(... IoUringBackend::new(opened_files) ... ) }
#[cfg(not(target_os = "linux"))] { Box::new(... PreadBackend::new(opened_files)) }

Delete one of the two. Deleting the helper is cheapest; deleting the inline block and calling the helper is better (it also moves the O_DIRECT reopen crate::os::direct_reopen — which the inline path never applies — into one place, i.e. the extracted opened_files at mod.rs:1503-1517 are currently not O_DIRECT-reopened, unlike what the helper does; a behavioural divergence hiding behind the duplication).

4. The meminfo MemTotal: parser is copied — selene::offload already owns it (−15 lines, one cfg)

helios/src/runtime_core/memory.rs:41-53:

#[cfg(unix)]
let host_total = std::fs::read_to_string("/proc/meminfo")
    .ok()
    .and_then(|info| { info.lines().find_map(|line| { let rest = line.strip_prefix("MemTotal:")?; ... }) })
    .unwrap_or(host_available);

selene/src/offload.rs:983-993 already parses the same field, with the same parse::<u64>()/checked_mul(1024) logic, inside host_pool_budget_with_reserve, next to available_memory (:959-971) which parses MemAvailable. memory.rs already imports from that module four lines later (use flare_selene::offload::host_reserve_bytes; at :107). A public host_memory() -> Result<(available, total)> in selene::offload removes the second parser and the unix/not(unix) fork at :52-53.

5. max_bg_io / max_bg_dma are configuration fields whose only production value is 0 (−~10 lines)

helios/src/runtime_core/mod.rs:1602-1603 is the only construction of a production ChannelConfig, and it hardcodes:

max_bg_io: 0,
max_bg_dma: 0,

which ChannelConfig::default_bg_caps (worker.rs:70-79) immediately replaces with the constants. The fields exist solely so unit tests can lower the caps (worker.rs:1180-1181, :1351-1352, lifecycle_tests.rs:67-76 (not opened)). TransferScheduler::new (scheduler.rs:151-179) already takes them explicitly — so the test seam belongs there, not on the exported ChannelConfig (worker.rs:54-68) which is part of async_transfer's public re-exports (mod.rs:30). Either drop the two fields and have worker_main use DEFAULT_MAX_BG_IO/DMA (worker.rs:622-628), or gate them #[cfg(test)].


Medium value

6. Opcode::CancelEpoch => unreachable!() is created by validate-then-match (−2 lines, one panic path)

helios/src/async_transfer/ring.rs:369-375 early-returns ValidatedCommand::CancelEpoch before the priority/alignment work, so the later dispatch match must carry dead arm :463:

Opcode::CancelEpoch => unreachable!(),

One match over all four opcodes, where the cancel arm does its own bounds work, removes both the duplicate decoding and the panic. validate_command is the module's central safety gate (:348-350 "No disk I/O or CUDA DMA may be issued unless this function returns Ok(_)"), so it is the last function that should contain an unreachable branch.

7. validate_extent_entry's segment_index/segment_count bounds check is unkillable in its only caller (−4 lines)

helios/src/async_transfer/ring.rs:302:

if segment_index >= segment_count || nbytes == 0 {

The sole caller (:500-503) does segments.get(seg_idx as usize).ok_or_else(...) immediately before, so seg_idx < segments.len() == seg_count is already proven; the check and two of its six parameters (:291-298) can only ever be true for Kani. Keep the overflow/alignment checks, drop the index/count pair (or keep the helper const-only for the proof, not on the loader path).

8. Triple parse of pool_vram/pool_ram across three config surfaces (−~20 lines)

The same nonempty(...).map(parse::<PoolMemoryLimit>).transpose()? block is written three times:

plus the identity plumbing duplicated field-for-field in flare/src/runtime_settings.rs:18-19, 41-42, 91-92, 181-182, 198-199. One fn parse_pool_limit(name: &str, value: Option<&str>) in limits.rs (it already owns FromStr and the error text) collapses all three call sites and their three message formats.

9. The "channels require native core serving" refusal is a verbatim string in three places

ignition/preparation/execution.py:461-465 (not opened) and :484-488, and ignition/preparation/model.py:99-101 (not opened), all raise:

"async transfer channels require native core serving (export a core and serve with flare run)"

plus the mirrored Rust check at heliopause/src/python.rs:311-322 (not opened). Two guards inside one class (PreparedExecution.start_executor and .serve) that already share self.async_transfers should collapse into one _reject_async_transfers() (or one module constant), so the message can only ever be changed in one place.

10. Two flat_map passes materialise every snapshot twice for one summary line

helios/src/runtime_core/model.rs:976-987:

let host_total_mapped: u64 = self.ranks.iter().flat_map(|r| r.async_transfer_snapshots()).map(|s| s.host_pool_bytes).sum();
let dev_total_mapped: u64 = self.ranks.iter().flat_map(|r| r.async_transfer_snapshots()).map(|s| s.device_pool_bytes).sum();

Each async_transfer_snapshots() (mod.rs:1642-1644) clones a String name and reads 9 atomics; this runs it twice per phase to format "{:.2} GiB VRAM pool · {:.2} GiB RAM pool". One fold((0, 0)). Also: AsyncTransferRuntime exposes host_pool_bytes()/device_pool_bytes() (worker.rs:369-375) and repeats both in AsyncTransferSnapshot (worker.rs:569-570) — one of the two is redundant.

11. Python seeding helpers: redundant device contexts and undeclared private state

ignition/preparation/capture.py (new _seed_auxiliary_workspaces) enters the device twice:

with torch.cuda.device(device):
    index = torch.cuda.current_device()
graph_pool = getattr(warmup_storage, "graph_pool", None)
pool_ctx = nullcontext() if graph_pool is None else torch.cuda.use_mem_pool(graph_pool)
with torch.cuda.device(index), torch.cuda.stream(aux), pool_ctx:

the first with can be index = torch.cuda.current_device() alone (which is what _seed_library_device_caches then does again two lines into its own with). _seed_library_device_caches also invents warmup_storage._seeded_library_caches (set at the end of the function, read from getattr(..., False) at the top) on an object it does not own — an attribute that should be declared on CoreStorage or replaced by seeding at the single call site after the cache is built.


Subtraction, not simplification: out-of-scope cargo

12. Drive-by packaging test belongs to merged #687, not to a transport PR (−36 lines)

flare-cli/src/cli.rs:2506-2541 adds debian_man_page_documents_every_visible_subcommand, which reads ../packaging/debian/flare.1 and asserts .SH COMMANDS matches Cli::command()'s visible subcommands. It asserts nothing about --pool-*; packaging/debian/flare.1 is not in this PR's file list; and the PR description never mentions it. It couples a crate's unit tests to a packaging file and will red-line any future subcommand rename in an unrelated PR.

13. The capture-seeding half duplicates open #606 and should not ride in this PR (−~215 lines incl. tests)

ignition/preparation/capture.py:74-140 (_seed_auxiliary_workspaces, _seed_library_device_caches) plus tests/preparation/test_transient_retention.py (not opened) (+88) fix the same "seeded workspace lives outside exported storage" defect that open #606 addresses in the same capture_forwards region, and both sit on merged #331. Two competing fixes for one bug, in one file, is the subtraction opportunity: land one.

14. Two new operator flags for a feature with no in-repo producer

flare-cli/src/cli.rs:945-963 adds --pool-vram-memory / --pool-ram-memory; they feed only Capacity::DEVICE_POOL sizing (memory.rs:1169-1177) and AsyncTransfer host pools (mod.rs:1477). No code in the repository writes an extent directory or declares DEVICE_POOL, so both flags are operator-visible surface with no reachable effect today, documented at docs/cli-design.md:760-761 (not opened). If DEVICE_POOL sizings can already be expressed with --memory-limit's Reserve/Fraction verbs (same grammar, same parser per finding 1), one flag is enough until a producer exists.


What is already lean (checked, no action)

Not verified (did not read in the time available)

resize_device_pool_buffer (memory.rs:1546-1558, referenced at :1202) — its truncating floor(bytes/row_bytes) rewrite looks like a candidate for a single validation-and-return-rows helper rather than an in-place mutation, but I did not read it, so I make no claim. Likewise heliopause/src/export/binding.rs:470-569, whose resolve_ref closure handles a "buffer" and an "allocation" arm with near-identical expected_memory/sizing.is_some()/overflow checks repeated at :523-527 and :541-545 — likely a ~25-line dedup, unconfirmed.

Full report

Gates and contracts

Audit — Contracts, Charter & Verification Gates (PR #711)

Bottom line: Gate 2 passes cleanly. Gates 1, 3 and 4 have real violations: one recorded-approval blocker on a new captured-graph operation family, and verification/doc-contract gaps that are stated explicitly by docs/design-review.md and AGENTS.md. Not flagged, and deliberately, because they are false-positive traps: CI status (pending, no failure reported anywhere), docs/TODO.txt bookkeeping, or stale-base over-attribution.


Gate 1 — Signed core-format / wire / captured-graph / public-contract boundaries — FAIL

The PR does add a new captured-graph operation family and new signed core-format records, and the additions themselves look correctly additive:

Blocker — new operation contract with no recorded owner approval. docs/design-review.md:22-26: "Introducing a captured-graph operation family requires prior explicit approval from project owner Luke Alonso… A new operation contract requires approval even if it reuses a graph kind or enum value. A design acknowledgment does not grant approval." AGENTS.md:376-381 repeats it, and the charter's Standards section repeats it a third time. Execution.async_transfers carries four new host-driven opcodes (disk→host, host→device, disk→device, cancel-epoch) over a new mapped-host control region (ABI_VERSION = 1), i.e. squarely a new operation contract. pr_comments on #711 contains only the Autobot case-file notice: no approval line, no reviewer, no label. The repo shows the required form: in the structurally identical #430 (Execution.persistent_workers), yatesdr asked and lukealonso answered "Approved, including Principle 1 approval for the Execution.persistent_workers captured-graph operation contract." The author here is the named owner, so the substance is presumably intended — but the gate is recorded, prior, explicit approval, and none exists. Remedy is one line in the PR description/thread in #430's wording; it is not a design objection.

Major — the governed normative docs were not updated for the new members/behaviour.

Gate 2 — Vendored upstream deps & cross-PR dependencies — PASS

Info / Nit (explicitly not a blocker per calibration): open #606 (avifenesh) fixes the same transient-workspace seeding defect in the same capture_forwards region of ignition/preparation/capture.py; both sit on merged #331. Textual conflict likely, reconcile before merge. Purely informational.

Gate 3 — Mandatory verification evidence — PARTIAL (credit where due, three real gaps)

Credit, verified in the diff, not just claimed: the TLA+ work is genuinely integrated, not a side artifact — verification/helios-lifecycle/AsyncTransfer.tla (+267) with a .cfg listing all eight invariants, check.py appends ("AsyncTransfer", "async_transfer::lifecycle_tests::async_transfer_scheduler_matches_lifecycle_model", "ASYNC_TRANSFER_EDGE ", 13) to CHECKS (so MODELS and the observed-edge runner pick it up automatically), four new Rust mutation cases and three model mutations were added for the new guards, and the Kani harnesses sit in cfg(kani) beside the production module they verify with the required command (cargo kani --manifest-path helios/Cargo.toml --features runtime-core --lib). Disclosed unrun items (5 Jinja tests, SM103/SM121, Windows PreadBackend, cross-node) are stated. I am not flagging CI: pr_comments reports no failure, and the dossier says only "pending" — unobservable-CI is not a finding.

Major — Principle 13 legacy-core replay is missing. docs/design-review.md:116-123: "Validate previous cores through loading and serving." docs/verification.md:32: "A core field change needs loading and compatibility tests." This PR changes the signed core format (external_extents), the runtime payload set (reader.rs:225), and the accepted capacity values. The stated evidence contains no pre-#711 core loaded and served through flare run; it reports schema/lib unit tests only. Compatible-by-construction is the right design, but the gate asks for the demonstration.

Major — the Start server reserve path and the pool-sizing branch were never exercised end-to-end. The PR's own claim is a behavioural one about the serving path: oversized --pool-vram-memory with large pinned RAM "clamp[s] safely instead of failing cuStreamCreate during Start server". The only support is the arithmetic unit test async_transfer_device_reserve_accounts_for_pinned_host_page_tables (memory.rs:~2358-2430) plus cache_geometry_ignores_device_pool_and_resizes_2d_pool_buffer. The listed GPU runs are async_transfer:: (live_cuda_async_transfer_end_to_end) and cuda_memory_limits…; nothing exercises allocate_caches' DEVICE_POOL sizing/mapping branch (memory.rs:1110-1209), NativeResources::map_device_pool, or prepare_async_transfers orchestration for an exported core containing a pool. Per Principle 12 that claim needs an exported core served through flare run, or it should be softened to "accounted for by construction".

Major — TP>1 untested on a contract whose sizing is cross-rank. The pool is agreed as the rank minimum and the host cap is divided per local rank (async_transfer_host_ram(local_ranks), memory.rs:36-56), and rank_options forwards the new limits across ranks (flare-cli/src/cli.rs). Given the stated motivation (weights larger than one GPU), a TP=2 serve of a DEVICE_POOL core is the affected shape, and it is untested. The hard multi-GPU clause for helios/src/execution/{threaded,parallel,roce}* is not triggered — those files are untouched — so this is a Principle 12/13 affected-shape gap, not the mandatory-collective rule.

Minor — no check.py --mutations result reported although this PR adds safety guards (unconfirmed-drain retention, bounce-slot release, background DMA cap) and authored the matching mutation cases. The non-substitution clause lists crate tests, simulator sweeps, TLA+ conformance and Kani rather than mutations, so this is a "state the run" request, not a block.

Gate 4 — Material scope / claim contradictions — one Major


Required before merge: (1) record the explicit Principle-1 approval in #430's wording; (2) update docs/core-format-design.md's RankBody row and state the rank-min pool agreement and view rewrite in the governing runtime docs, plus the flare_async_transfer_* rows in docs/api.md; (3) load and serve a pre-#711 core through flare run; (4) exercise one exported core containing a DEVICE_POOL (single-GPU at minimum, TP=2 preferred) so the Start server reserve/clamp path is real rather than arithmetic; (5) report the check.py --mutations result; (6) reconcile with #606 and split or justify the capture-seeding half.

No blocker: no vendored-upstream fork, no unpinned or unmerged-external dependency, no reported failing test or CI failure, and no fabricated evidence — the formal-verification work is the strongest part of this PR.

Full report

Code correctness

Deep Code Correctness, Invariants & Hot-Path Performance Audit — PR #711 @ 6916f22

Partitioning. The PR spans 57 files / ~7.4k lines across 4 subsystems, so I split it into 3 disjoint slices and ran them concurrently (helios/src/async_transfer/**, heliopause/** + TLA+, ignition/** + flare-cli/flare config). The heliopause sub-agent died without producing a report, so I audited that entire slice myself, plus the helios/src/runtime_core/{mod,memory,protobuf,model}.rs wiring that no sub-agent owned. I independently re-read and confirmed every finding below; I dropped sub-agent claims I could not prove (listed at the end).

Result: 3 Major, 4 Minor. No Blocker. The ABI layout, ring/directory bounds validation, pool-size arithmetic, DEVICE_POOL mapping, and extent authentication are sound; the real defects are in the completion-signal contract, the shutdown drain, and bounce-pool sizing.


MAJOR 1 — HOST_TO_DEV never publishes a completion word: the host word is skipped on success and the device word is skipped on failure

Diff site: helios/src/async_transfer/worker.rs:786-792 (step 4) and worker.rs:822-871 (step 5). Callee/contract: worker.rs:673-699 (publish_notice(notice, write_slot)), worker.rs:650-671 (signal_completion_slot), Proto contract helios/proto/runtime_core.proto:855-857, host-word offset helios/src/async_transfer/ring.rs:242-249 (host_completions_offset).

// worker.rs:786-792  (step 4: DMA completion harvested)
let ok = status == 0;
if let Some((slot, val)) = done.signal_host_slot {
    signal_completion_slot(slot, val);
}
if let Some(notice) = scheduler.complete_dma(done.op_id, ok) {
    publish_notice(notice, false);          // <-- write_slot == false
}
// worker.rs:822-853 (step 5: submit)
if copy_status == 0 {
    if let Some(slot) = dma.completion_slot {
        if args.use_write_value64 {
            let target_addr = if args.config.device_completions_base != 0 {
                args.config.device_completions_base + u64::from(slot) * 8
            } else { /* cuMemHostGetDevicePointer on the host word */ };
            if target_addr != 0 { /* cuStreamWriteValue64_v2 → device word only */ }
            else { signal_host_on_event = Some((slot, dma.signal_value)); }
        } else { signal_host_on_event = Some((slot, dma.signal_value)); }
    }
}
...
if copy_status == 0 && signal_status == 0 && rec_status == 0 { /* push pending_dma_events */ }
else { free_events.push(ev);
       if let Some(notice) = scheduler.complete_dma(dma.op_id, false) {
           publish_notice(notice, true); } }   // <-- host word only, never the device word

On the success path with device_completions configured and attribute 122 supported (exactly the PR's own CUDA-test configuration), signal_host_on_event stays None, and step 4 calls publish_notice(..., false), so neither the host word (host_completions_offset) nor the device word for that slot is ever written beyond the cuStreamWriteValue64 device write. On the failure path the complement holds: the host word is written, the device word never is.

Concrete counterexample: the PR's own test at worker.rs:1223-1238 publishes HostToDev{completion_slot: 1, signal_value: 2002} and waits on the device word, so it passes. Change it to wait on the host word — wait_host_comp(ctrl_ptr, 1, 2002), defined at worker.rs:1129-1140 and used at line 1219/1220 — and it times out and panics: the success path never calls signal_completion_slot(1, 2002). Symmetrically, make cuMemcpyHtoDAsync fail (copy_status != 0) with a graph blocked on device word 1: word 1 stays 0 forever. Because CompletionNotice still carries completion_slot: Some(1) (scheduler.rs:638-651), one of the two consumer types starves on every transfer, and the doc sentence "written in stream order … after Copy Engine DMA completes" (manifest.md:178-182) holds for neither consumer in the general case.

Fix: make every path publish both sides, e.g. on success publish_notice(notice, true) after complete_dma (the second host store is idempotent; guard the cuStreamWriteValue64 so it is not issued twice), or restructure signal_completion_slot to always write the host word and, when device_completions_base != 0, to record the same value to the device word on signal_stream on the event/failure paths too.


MAJOR 2 — Shutdown drain reports success with storage reads still in flight; finish_drain is never called

Diff sites: helios/src/async_transfer/worker.rs:936-944 and worker.rs:974. Callee/contract: helios/src/async_transfer/scheduler.rs:687-710 (finish_drain), scheduler.rs:262-268 (can_release_memory), helios/src/async_transfer/io_backend.rs:182-211 (cancel_and_drain), consumer helios/src/runtime_core/mod.rs:1628-1639 → worker.rs:499-509.

// worker.rs:936-944
let io_drained = args.io_backend.cancel_and_drain(DRAIN_TIMEOUT);
if io_drained {
    // Clear scheduler inflight IO accounting now that backend confirmed zero pending reads.
    io_completions.clear();
    let _ = args.io_backend.poll_completions(&mut io_completions);
    for c in io_completions.drain(..) { let _ = scheduler.complete_io(c.op_id, c.ok); }
}
// worker.rs:974
let ok = io_drained && stream_drained && scheduler.inflight_dma_count() == 0;
// io_backend.rs:197-210 — cancellation CQEs are consumed and thrown away
let deadline = Instant::now() + timeout;
let mut discarded = Vec::new();
while !self.expected.is_empty() {
    discarded.clear();
    let _ = self.poll_completions(&mut discarded);   // removes from `expected`, result DROPPED
    if self.expected.is_empty() { break; }
    ...
}
true

scheduler.finish_drain(...) — the only code that enforces inflight_io.is_empty() && inflight_dma.is_empty() and that can raise FailedDrain for the I/O side (scheduler.rs:695-701) — is never called by the worker (verified: the only call sites are lifecycle_tests.rs:270 and scheduler.rs:835,853). cancel_and_drain harvests each cancellation CQE into discarded and drops it, so the follow-up poll_completions at worker.rs:940 yields nothing and scheduler.inflight_io is never cleared. /verify/ run() — the lifecycle model's FinishDrainFail/FinishDrainOk actions (AsyncTransfer.tla:132-141) therefore have no counterpart in the worker.

Concrete counterexample: queue one DISK_TO_HOST of a 64 KiB extent (ring_capacity = 16, completion_slots = 8) against a slow device, then stop the server while it is in flight. cancel_and_drain pushes AsyncCancel for that op_id, harvests -ECANCELED into discarded, expected empties → returns true; the worker's poll sees nothing; scheduler.inflight_io_count() == 1; ok is computed without that term → true; stop() (worker.rs:499-509) sets ChannelState::Stopped, writes Stopped into ControlHeader.worker_state, and release_owned_resources_locked destroys the streams and unregisters/munmaps the pinned host + bounce pools while an I/O operation still targets that memory. This violates the invariants the PR adds to check: StoppedHasZeroInflight and CanReleaseExact (AsyncTransfer.tla:178-183, 200-201) and the Rust harness assertion at lifecycle_tests.rs:118-127 (Stopped ⇒ inflight == 0 && free_bounce == bounce_slots && can_release_memory()). The laundering point is that the worker writes the scheduler's Stopped claim into the exported control header, advertising Stopped to captured graphs that may publish more commands.

Fix: after the I/O drain, finish through the state machine and only release on confirmation:

let ok = io_drained && stream_drained && scheduler.inflight_io_count() == 0
         && scheduler.inflight_dma_count() == 0
         && scheduler.finish_drain(stream_drained).is_ok();

and make cancel_and_drain return the harvested IoCompletions (or leave them for the caller) so complete_io frees bounce slots and inflight_io; otherwise force FailedDrain and retain pinned memory as the doc claims.


Diff site: helios/src/async_transfer/worker.rs:249-258; cap constants worker.rs:47-50; reserve computation helios/src/runtime_core/memory.rs:64-103; validation of alignment ring.rs:280-282 and heliopause/src/export/binding.rs:633-637.

// worker.rs:249-257
let max_extent = config.extents.iter().map(|e| e.nbytes).max().unwrap_or(0);
let (bounce_slots, bounce_slot_bytes) = if max_extent > 0 {
    let align = u64::from(config.alignment);
    let slot_bytes = max_extent.min(MAX_BOUNCE_SLOT_BYTES).div_ceil(align) * align;
    (DEFAULT_BOUNCE_SLOTS, slot_bytes)
} else { (0, 0) };
let bounce_total = usize::try_from(bounce_slot_bytes.saturating_mul(bounce_slots as u64))
// memory.rs:94-101 (the reserve that exists to make startup safe)
pinned = pinned.saturating_add(host_pool)
              .saturating_add(crate::async_transfer::worker::MAX_BOUNCE_POOL_BYTES);
...
let page_tables = pinned.div_ceil(512);

alignment is only constrained to be a power of two ≥ 4096 (ring.rs:280-282; binding.rs:633-637 allows up to u32::MAX), and div_ceil(align) * align is applied after the min(MAX_BOUNCE_SLOT_BYTES) clamp, so the cap is not a cap.

Concrete counterexample: a channel with alignment = 1 GiB and a single 4 KiB extent. max_extent = 4096 → slot_bytes = 4096.min(32 MiB).div_ceil(1 GiB) * 1 GiB = 1 GiB → bounce_total = 16 GiB of map_host + cuMemHostRegister_v2 (and map_host prefaults, so this is not overcommit-cheap). The reserve charged in memory.rs:96-98 is MAX_BOUNCE_POOL_BYTES / 512 = 1 MiB of VRAM page tables, i.e. 16 384× less than the real 16 GiB registration cost. prepare_async_transfers then fails in PinnedHostRegion::allocate (worker.rs:247-267) or exhausts host RAM after allocate_caches has already committed DEVICE_POOL and the KV cache — the exact failure this reserve was added to prevent. With alignment = 64 MiB the inflation is 16 × 64 MiB = 1 GiB per channel.

Fix: clamp after rounding and make the charger use the same function:

let slot_bytes = max_extent.div_ceil(align).checked_mul(align)?;
if slot_bytes > MAX_BOUNCE_SLOT_BYTES { /* disable bounce staging: slots = 0 */ }

and call that helper from async_transfer_device_reserve so reserved VRAM always equals registered pinned bytes.


MINOR 4 — Dead break in the I/O dispatch loop starves Demand/older-epoch reads behind a bounce-blocked background op

helios/src/async_transfer/scheduler.rs:437-457:

for prio in [Priority::Demand, Priority::Prefetch, Priority::Warm] {
    ...
    let queue = &mut self.io_queues[prio.index()];
    while let Some(front) = queue.front().copied() {
        ...
        if needs_bounce && self.free_bounce_slots.is_empty() { break; }

break exits only the inner while, then the for advances to the next priority — so it is not the "stop dispatching" it reads as, but it also never re-examines the same queue: for prio = Warm it exits the loop entirely. Combined with the single global pop_next_io/pop_next_dma per iteration, a WARM-priority bounce-backed DISK_TO_DEV at the head of the Warm queue blocks a Demand non-bounce read behind it only when slots are exhausted — the "DEMAND > PREFETCH > WARM" preemption claim in manifest.md:190-192 then does not hold under bounce exhaustion. Counterexample: 16 bounce slots held by in-flight Warm ops, one Warm DISK_TO_DEV queued, then a Demand DISK_TO_HOST queued: the Warm op is skipped but the loop exits that queue, and the Demand read is dispatched — correct — yet the same structure lets the Warm head keep the bounce slot it will never get while pop_next_io returns None once all priorities are bounce-blocked, with no back-pressure signal to the producer. Fix: use break 'outer semantics or continue 'next_priority explicitly, and record ErrorCode/telemetry when dispatch is bounce-blocked.


MINOR 5 — Ring overrun by the producer is undetected

helios/src/async_transfer/worker.rs:734-739:

let tail = header.cmd_tail.load(Ordering::Acquire);
while head < tail {
    let slot_idx = (head & ring_mask) as usize;
    let cmd = unsafe { std::ptr::read_volatile(ring_base.add(slot_idx)) };
    head = head.wrapping_add(1);

ring_capacity is a validated power of two (ring.rs:271-276), so & ring_mask is exact, but nothing checks tail - head <= ring_capacity. A captured graph that publishes more than ring_capacity outstanding commands (ring_capacity = 16) overwrites unconsumed slots and the worker silently executes overwritten commands instead of raising ErrorCode. Fix: before the loop, if tail.wrapping_sub(head) > u64::from(args.config.ring_capacity) { header.last_error.store(ErrorCode::RingOverrun as u32, Release); header.cmd_head.store(tail, Release); break; } (new error code).


MINOR 6 — The worker busy-spins a full core for the whole duration of every in-flight transfer

helios/src/async_transfer/worker.rs:913-925:

if did_work {
    sync_telemetry(&scheduler);
    idle_spins = 0;
} else if scheduler.inflight_io_count() == 0 && scheduler.inflight_dma_count() == 0 {
    idle_spins = idlespins.saturating_add(1);
    if idle_spins < IDLE_SPIN_LIMIT { std::hint::spin_loop(); }
    else { thread::sleep(IDLE_PARK_INTERVAL); }
} else {
    std::hint::spin_loop();
}

The park path is unreachable while work is in flight, so each channel's thread spins at 100 % CPU for the entire duration of a multi-GiB pinned-RAM→VRAM copy or a cold O_DIRECT read; N channels cost N cores and contend with the thread that must submit the next DMA. Fix: after a bounded number of unproductive polls with work in flight, thread::yield_now() then a short sleep (the 200 µs IDLE_PARK_INTERVAL is already defined) or wait on the DMA event with a timeout.


MINOR 7 — _seed_library_device_caches relies on an ambient pool it never enters, then latches permanently

ignition/preparation/capture.py:123-146 (new function):

    # CoreStorage.__enter__ keeps warmup_storage.pool active outside transient(),
    # so allocations here land directly in persistent exported storage.
    with torch.cuda.device(index):
        for fn in (...):
            if fn is not None and hasattr(fn, "cache_clear"): fn.cache_clear()
        ...
    warmup_storage._seeded_library_caches = True

Unlike its sibling _seed_auxiliary_workspaces (capture.py:89-91), which explicitly does torch.cuda.use_mem_pool(graph_pool), this function never enters warmup_storage.pool; it is correct only if the caller happens to be inside with CoreStorage(...): (the scope created at core_storage.py:118 and entered by __enter__). capture_forwards is a public entry point (capture.py:155) whose only in-repo caller contract is that the caller holds the storage. Counterexample: any second capture_forwards call after CoreStorage.__exit__ has popped the scope, or a duck-typed storage (the new test itself uses SimpleNamespace(pool=object()), tests/preparation/test_transient_retention.py:219): the seed tensors allocate from PyTorch's default pool, _seeded_library_caches = True at line 146 makes that permanent, and capture records default-pool pointers — the illegal-access failure this change exists to remove. Fix: mirror the sibling — pool_ctx = torch.cuda.use_mem_pool(warmup_storage.pool) inside the with — or assert the storage scope is active and raise instead of silently seeding into the wrong pool.

I also drop two sub-agent claims I could not prove or judged out of bar: (a) PoolMemoryLimit "0.0" → Display → "0" round-trip asymmetry (limits.rs:167-168, 201) — real but semantically identical at runtime (cap_bytes returns 0 for both), so it is an identity-string nit, not a serving defect; (b) AsyncTransferChannel.device_pool not validated in ignition/preparation/execution.py:317-331 — an unknown name is rejected at export by heliopause/src/export/binding.rs ("device_pool allocation not found"), so it is a diagnostics nit, not a bug.


Checked and verified correct (no finding)

Full report

Final review

Recommendation: Changes Requested

The ABI layout, ring/directory bounds validation, extent authentication, pool arithmetic, and the TLA+/Kani/conformance harness work all check out as described — this is a carefully built primitive. I could not sustain several upstream claims (notably the "failure path never writes the device word" half of the completion-word finding and the "unmaps memory while I/O is in flight" framing of the drain finding), but I did independently verify four Should-Fix defects in the new runtime plus a hard, explicitly documented merge gate that has no recorded approval. The verdict is driven by the unrecorded Principle-1 approval for a new captured-graph operation family (docs/design-review.md:22-26) plus the verified sizing/drain/doc-contract defects.

Merge Risk

Level: High

Walkthrough

Pre-merge Checks

Blockers

  1. New captured-graph operation contract with no recorded owner approval — docs/design-review.md:22-26 ("Introducing a captured-graph operation family requires prior explicit approval from project owner Luke Alonso… A new operation contract requires approval even if it reuses a graph kind or enum value. A design acknowledgment does not grant approval."). Execution.async_transfers (field 9, runtime_core.proto:837-862) carries four new host-driven opcodes over a new mapped-host control region, i.e. squarely a new operation contract, and pr_comments holds no review and no approval line; #430 shows the required form ("Approved, including Principle 1 approval for the Execution.persistent_workers captured-graph operation contract"). Fix: record the explicit approval in the PR thread in #430's wording before merge (the author is the named owner, so this is a recording step, not a design objection).

Should Fix

  1. Bounce-slot size is rounded up after the 32 MiB cap, so the cap is not a cap and the VRAM reserve no longer matches registered pinned bytes — worker.rs:249-257: max_extent.min(MAX_BOUNCE_SLOT_BYTES).div_ceil(align) * align. alignment is only constrained to be a power of two ≥ 4096 (ring.rs:280-282, binding.rs:633-637 allows up to u32::MAX), so alignment = 64 MiB with one 4 KiB extent yields slot_bytes = 64 MiB and bounce_total = 1 GiB; alignment = 1 GiB yields 16 GiB of map_host + cuMemHostRegister_v2. Meanwhile memory.rs:94-98 charges the fixed MAX_BOUNCE_POOL_BYTES (512 MiB → 1 MiB of page tables), so the reserve is off by up to 32×/16384× and prepare_async_transfers can fail after DEVICE_POOL/KV were already committed — the exact failure the reserve exists to prevent. Fix: round first, then clamp (max_extent.div_ceil(align) * align, and disable bounce staging when it exceeds MAX_BOUNCE_SLOT_BYTES), and call the same helper from async_transfer_device_reserve.
  2. The worker never runs the scheduler's drain transition, and in-flight I/O accounting is never cleared — worker.rs:936-976 computes let ok = io_drained && stream_drained && scheduler.inflight_dma_count() == 0; and never calls scheduler.finish_drain(...) (only call sites are lifecycle_tests.rs:270 and scheduler.rs:835/853), while io_backend.rs:197-210 harvests cancellation CQEs into a local discarded vector and drops them, so the follow-up poll_completions at worker.rs:939-943 yields nothing and scheduler.inflight_io is never emptied. Result: stop() (worker.rs:499-509) sets ChannelState::Stopped, writes Stopped into ControlHeader.worker_state, and releases the streams/pinned pools with inflight_io > 0, so post-stop telemetry (active_inflight, worker.rs:714-720) is non-zero and the invariant the PR itself models and asserts (StoppedHasZeroInflight/CanReleaseExact, AsyncTransfer.tla, lifecycle_tests.rs:118-127) is not enforced on the production path. Fix: end the drain through the state machine (scheduler.finish_drain(stream_drained)), include inflight_io_count() == 0 in ok, and have cancel_and_drain return the harvested IoCompletions (or leave them queued) so complete_io frees bounce slots and accounting; force FailedDrain otherwise.
  3. HOST_TO_DEV skips the host completion word on success when device completions are configured — worker.rs:822-853 writes only the device word via cuStreamWriteValue64 and leaves signal_host_on_event = None, so step 4 (worker.rs:786-792) calls publish_notice(notice, false) and signal_completion_slot never stores into host_completions_offset (ring.rs:242-249). Every other opcode publishes both (worker.rs:770-793, 808-813, 866-871), so the contract is inconsistent per opcode and a host-side consumer of the host completion array stalls forever on H2D. The PR's own CUDA test only waits on the device word for this op (worker.rs:1238), which is why it passes. Fix: publish the host word on the success path too (an idempotent store after complete_dma, with the cuStreamWriteValue64 issuance guarded so it is not repeated).
  4. Governed docs were not updated for two new signed/observable surfaces and an undocumented load-time behaviour — docs/core-format-design.md:213 still describes RankBody without external_extents, although those tables are now signed Weights-role payloads entering required_payloads (core/reader.rs:225-230) and AGENTS.md:235 makes that file required guidance; docs/api.md has no flare_async_transfer_* rows although the family ships (metrics.rs:1536-1571) and AGENTS.md:230 requires the API docs; and docs/runtime-core-design.md:677-691 omits that the pool byte count is the rank minimum (memory.rs:1178) and that Execution.buffers views are rewritten to floor(bytes/row_bytes) rows (memory.rs:1202, resize_device_pool_buffer 1546-1563) — a silently truncated exported shape. Fix: add the RankBody member and the 24-byte directory layout, the metric rows, and the rank-min/view-rewrite sentences.
  5. Operator- and core-visible surface ships with no producer, so none of it can take effect — ignition/preparation/runtime_core.py:431-438 exports extent tables only when ch.extent_directory is set, and no code in the repository writes such a directory (extent_directory appears only at execution.py:171,212-213 and runtime_core.py:434-438); consequently --pool-vram-memory/--pool-ram-memory (cli.rs:1174-1177, documented at docs/cli-design.md:760-761) and the new metrics have no reachable effect. AGENTS.md:196-198 asks that scaffolding not be presented as supported and that a PR keep one coherent outcome. Fix: land one producer (or state in the docs that the surface is unreachable pending a follow-up), and split the unrelated capture-seeding fix (reconcile with #606) out of this PR.

Subtract / Simplify

  1. PoolMemoryLimit is a near-verbatim clone of MemoryLimit — limits.rs:44-48 vs :132-137, identical FromStr bodies (:70-105 vs :159-193), same validate shape, and Display already delegates to MemoryLimit (:199-200); one enum plus allow_zero collapses both and their duplicated tests (:210-267).
  2. io_backend::open_direct_backend (io_backend.rs:283-301) is dead — a repo-wide search finds only its definition; the production path re-implements the same cfg(target_os) split inline at runtime_core/mod.rs:1572-1588.
  3. prepare_async_transfers takes three parameters it does not need — runtime_core/mod.rs:1477-1481 recomputes the exact cap memory.rs:78-83 already produced and then .min(planned_host_cap), which is that same value (model.rs:963), making the recomputation a no-op; host_ram_available/host_ram_total/pool_ram_limit can drop.
  4. The /proc/meminfo MemTotal: parser at memory.rs:41-53 duplicates selene/src/offload.rs:983-993, in a module that already imports flare_selene::offload two lines later (memory.rs:107).
  5. ChannelConfig::max_bg_io/max_bg_dma are configuration fields whose only production value is 0 (runtime_core/mod.rs:1602-1603), replaced immediately by default_bg_caps (worker.rs:70-79); the test seam belongs on TransferScheduler::new, which already takes them.
  6. Opcode::CancelEpoch => unreachable!() (ring.rs:463) is created by the early return at :369-375, leaving a panic arm in the module's central safety gate.
  7. Two flat_map passes materialise every channel snapshot twice for one summary line (runtime_core/model.rs:976-987); one fold((0, 0)) suffices.

Nits

Dropped on verification

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

Apply labels

Applied: +triage:review, -triage:design-review