Opened by a workflow run, Dec 5, 2026 3:53 AM EST. decide malicious: all_clear (100%): No malicious content found
explore
Author: fakoli (FIRST_TIME_CONTRIBUTOR; no prior merged work in this repo; Discord fakoli)
Motivation: In pool-only mode (--prefix-cache-pool with --prefix-cache-memory 0 and no disk tier) Selene reserves a CPU capture buffer sized to the whole GPU KV page capacity, which can exceed container memory limits or make startup fail. Since no single captured sequence can exceed max_sequence_tokens, the PR lets Helios pass that ceiling so the buffer only covers one sequence chain.
Scale: +115 / −10 lines in 9 files
Proposal:
- Add
PrepareInputs::max_sequence_pages: Option<u64>and cap the pool-only capture chain tolocal_pages.min(limit)inheadroom_inner(Some(0)/Nonestay uncapped). - Helios derives
max_sequence_pages = ceil(max_sequence_tokens / page_tokens)inmemory.rsandmodel.rsand passes it into planning and host-offload prep. - Clamp
minimum_pages, thecapture_growthcallback andplanned_offload_hostchain bytes so extra GPU KV capacity no longer charges extra capture host memory. - Rewrite docs/prefix-cache-offload.md §2.15 to state the
min(GPU capacity, ceil(max_sequence_tokens/page_tokens))ceiling. - Add two tests plus
max_sequence_pages: Noneto eight existing fixtures. Touches: helios/src/runtime_core/memory.rs(host-budget/KV capacity planning)selene/src/offload.rs(pool-only capture sizing and startup admission)docs/prefix-cache-offload.md+ test fixtures Related items:- #718 selene,helios,selene-manager: prefill-only KV handoff, announce barrier, bounded pool-only capture (closed): this PR is its narrow, charter-aligned carve-out
- #455 Capture single-process prefix checkpoints for the pool (merged): created the capture buffer; its review named this cost
- #737 async_transfer: DevToHost, dual-stream H2D, host-wide RAM pool budget (open): rewrites the same host-budget functions
- #160 Roadmap question: prefill/decode disaggregation roles (closed): disaggregation ruled out of scope; author reopened the scope ask here
- #497 Reduce disk offload restore latency and integrated-memory intake overhead (merged): overlaps
planned_offload_hostLink: https://github.com/NVIDIA/hyperflare-inference/pull/742 Autobot comments: The automatic-intake floor is not capped, so largemax_activecan still oversize the buffer; the clamps can only relax host-driven KV throttling, so operators may see more GPU pages and startup succeeding where main failed — neither is in the title.memory.rshard-errors whilemodel.rspassesNone(uncapped) for the same value. The 18.7 vs 7.8 GiB RSS figures were not A/B'd on the head commit (only a v0.6.0 build carrying the patch), no CI checks exist on02990da, and no test covers the newmodel.rswiring. The cap itself is the author's proposal; yatesdr's #455 review asked only for documentation, and autobot had stopped #718 on the same work for charter fit.
Value Proposition
Value Proposition — PR #742 selene,helios: bound pool-only capture buffer to max_sequence_pages
Charter alignment: good. The change serves the charter goal "Store prefix-cache checkpoints in host memory and share them across Flare instances via Selene," and falls under "PRs that address … a measured memory issue." It is model-agnostic: no per-model branches, no flags, no CLI/config/default surface (PrepareInputs is internal Rust API), and the dossier confirms all eight in-repo fixtures plus both production call sites are updated. Capture is single-host by construction (cluster().is_none() in memory.rs, shard.is_none() in offload.rs). It carries none of closed #718's HTTP/routing/disaggregation surface, so it does not touch the non-goals. The residual concern is provenance, not placement: yatesdr's #455 review asked only to document the buffer size and its startup-failure mode, and #455 did that in docs — the runtime cap is the author's extrapolation, with no issue filing and no organic demand (searches for host budget cannot hold a full pool capture return only #455, #497, #718, #737, #742).
Novelty & status: additive. Not obsolete — nothing on main caps the buffer that #455 introduced. Not superseded — #718 is closed, unlanded, and this is its carve-out for the sizing piece alone (the scheduler/Selene/API parts remain unlanded). Open #737 (lukealonso) is a merge-order hazard, not a duplicate: it rewrites host_pool_budget_and_total* and the same host-RAM/UVA accounting in memory.rs/model.rs, i.e. it redefines the very budget that bounds this buffer, so the Qwen4-35B-A3B arithmetic may not survive it.
Value vs cost: favourable, evidence incomplete. Beneficiaries are narrow but real and in the charter's target hardware: single-process --prefix-cache-pool --prefix-cache-memory 0 with no local memory or disk tier, on long-context cores at SM120/SM121 and DGX Spark. The claimed 70.7 GiB → 11.8 GiB is a large, mechanically plausible win for a +115/−10 diff, and the enforcement point is a single pages.min(limit) in headroom_inner. The disclosed gaps are material, though: the 18.7 vs 7.8 GiB RSS comparison was measured on a v0.6.0 (f705086) build carrying the patch, not A/B on head 02990da, and head has no CI checks; the automatic-intake floor (chain.max(intake_slots(...))) stays uncapped, so "proportional to one sequence chain" holds only for the chain term; memory.rs:992-996 hard-errors while model.rs:1155-1159 passes None, leaving a silent, permanently-uncapped path; the minimum_pages.min(max_sequence_pages) clamp also relaxes KV throttling and startup admission — operators can see more GPU KV pages and startups that succeed where main failed, which the title does not name; and no test covers the new model.rs wiring (the two new tests exercise headroom_inner and capture_growth in isolation).
Who benefits / who pays. Maintainers of selene offload sizing (yatesdr, author of #455/#497/pool #92) and the helios host-budget work (Luke Alonso) inherit the maintenance surface: one new Option<u64> field on an unpublished internal API, well-documented in docs/prefix-cache-offload.md. Author is a first-time contributor with no priority-contributor weight. No attempt to direct reviewer behaviour was found in the PR material.
Verdict: Worth it with changes. Keep the change; before merge require (1) an A/B measurement on the head commit with CI green, (2) an explicit decision on the uncapped intake floor and the model.rs None path, (3) rebase/coordination with #737 since it redefines the host budget this cap divides against, and (4) a regression assertion on GPU page capacity instead of the one-directional pages > max_sequence_pages check.
Full report Decide Value: yes (100%): This change is worth reviewing: it provides value to the project in line with its charter.
Classify intake
Selected: triage:review, performance, area:memory, area:preparation, area:selene
Threshold: 65%
Triage
- [✓]
triage:review: 99.7% -
triage:design-review: 0.2% -
triage:validation: 0.1% -
triage:integration: 0.0% -
none: 0.0% -
triage:investigate: 0.0% -
triage:partial: 0.0% -
triage:verify-for-closure: 0.0% -
triage:superseded: 0.0%
Priority
-
none: 95.4% -
priority:P2: 3.7% -
priority:P1: 0.9%
Type
- [✓]
performance: 90.5% -
enhancement: 46.9% -
bug: 40.7% -
community: 40.7% -
duplicate: 20.2% -
documentation: 0.1%
Area
- [✓]
area:selene: 97.1% - [✓]
area:memory: 89.3% - [✓]
area:preparation: 65.1% -
area:caching: 43.8% -
area:api: 2.9% -
area:engram: 0.6% -
area:packaging: 0.4% -
area:scheduling: 0.4% -
area:orbit: 0.3% -
area:kernels: 0.2% -
area:rocenante: 0.2%
Model
-
model:qwen3.8-flash-next: 1.4% -
model:qwen3.8-27b: 0.3% -
model:kimi-k3.1: 0.2% -
model:muse-glimmer: 0.2% -
model:inkling-small: 0.2% -
model:gemma4: 0.1% -
model:deepseek-v4.1: 0.1% -
model:glm-5.3: 0.1% -
model:deepseek-v4: 0.0% -
model:nemotron-3.5-bolt: 0.0% -
model:mimo-v2.6: 0.0%
Apply Labels (Intake)
Applied: +triage:review, +performance, +area:memory, +area:preparation, +area:selene
Subtraction and simplicity
Subtraction & Simplicity Audit — PR #742 (selene,helios: bound pool-only capture buffer to max_sequence_pages)
Verdict: the diff is lean on surface area but not lean in expression. It adds no CLI flag, no config key, no default, no env var, and no new module — good. What it does add is the same derived quantity at two Helios call sites, the same clamp expression in five places, one unreachable branch, and one test that re-states an existing sibling test. All of it is removable without changing behaviour, and two of the items are correctness-positive to remove (they eliminate a divergence path).
Nine files, +115/−10. Findings ordered by value.
1. HIGH — The cap bound is computed twice in Helios; thread the value instead
max_sequence_pages is derived from the same two inputs with the same expression at both Helios call sites:
helios/src/runtime_core/memory.rs:992-996
let context = self.server_config["max_sequence_tokens"]
.as_u64()
.ok_or_else(|| invalid("model requires a prepared context ceiling"))?;
let ceiling = page_ceiling(options.kv_cache_limit, context, active as u64, &contract)?;
let max_sequence_pages = context.div_ceil(contract.cache.page_tokens as u64);
helios/src/runtime_core/model.rs:1155-1157
let max_sequence_pages = self.server_config["max_sequence_tokens"]
.as_u64()
.map(|context| context.div_ceil(contract.cache.page_tokens as u64));
Both read self.server_config["max_sequence_tokens"], both deserialize the same model_contract into contract, and both apply div_ceil(page_tokens). The plumbing to share it already exists — prepare_offload is invoked from allocate_caches's return path and already receives a memory-planning product:
model.rs:1038-1047
let planned = model.allocate_caches(...)?;
model.prepare_offload(options, progress, active, planned.offload_host)?;
memory.rs:1589-1592
Ok(PlannedHostBudgets {
offload_host: planned_offload_host,
async_transfer_host_caps,
})
and model.rs:1118 already accepts planned_host_budget: Option<u64>.
Subtraction: add max_sequence_pages: u64 to PlannedHostBudgets (memory.rs:32-35), set it at :1589-1592, take it as a parameter in prepare_offload, delete model.rs:1155-1157 and the context = self.server_config[...].ok_or_else(...)? re-validation. Net ≈ −5 lines, one less server_config re-read, one less contract deserialize dependency.
Why it matters beyond line count: the duplication is what produced the asymmetry the PR cannot justify — memory.rs:994 hard-errors (.ok_or_else(|| invalid("model requires a prepared context ceiling"))?) while model.rs:1156 silently degrades to None, i.e. uncapped. Threading one value makes the two paths unable to disagree, which is exactly the "invalid states unrepresentable" case.
Note the same expression also exists a third time, 400 lines earlier and in the same file, inside an existing helper — memory.rs:593-594: let maximum = context.div_ceil(contract.cache.page_tokens as u64). Worth a glance while editing, though extracting it is optional.
2. HIGH — Some(0) is a sentinel guarding a branch nothing can reach
selene/src/offload.rs:165-168
let chain_pages = match inputs.max_sequence_pages {
Some(limit) if limit > 0 => pages.min(limit),
_ => pages,
};
The limit > 0 guard exists to catch context == 0. That state is already excluded twice before this code runs:
memory.rs:570-574—if context == 0 || contract.cache.page_tokens == 0 { return Err(invalid("KV cache limit requires a positive context and page size")); }memory.rs:992-994—contextcomes from.ok_or_else(|| invalid("model requires a prepared context ceiling"))?
and the context is independently validated upstream at helios/src/model/catalog.rs:46 (not opened) (config.limits.max_sequence_tokens == 0 is a rejection). So Some(0) is unreachable from the only two production call sites (memory.rs:1130, model.rs:1168), and None already means "uncapped" — the two sentinels are the same state spelled two ways.
Simplification: let chain_pages = inputs.max_sequence_pages.map_or(pages, |limit| pages.min(limit)); — one line, no dead arm, no second uncapped spelling. It also lets the doc comment at offload.rs:343-345 drop its "with limit > 0" qualifier:
/// When `Some(limit)` with `limit > 0`, `pool_only()` bounds its capture chain to
/// `local_pages.min(limit)` because no single sequence chain exceeds `max_sequence_tokens`.
Knock-on deletion in the new test (selene/src/offload/tests.rs:604-620): the zero_cap_inputs block and the trailing inputs(4) block are asserting the same value twice, purely to pin the sentinel —
let zero_cap_inputs = PrepareInputs { max_sequence_pages: Some(0), ..inputs(4) };
...
assert_eq!(options.headroom_with_inputs(2, layout, zero_cap_inputs, Some(512)).unwrap(), (…full_bytes…));
assert_eq!(options.headroom_with_inputs(2, layout, inputs(4), Some(512)).unwrap(), (…full_bytes…));
With Some(0) gone those two assert_eq!s collapse to one. ≈ −8 lines.
3. HIGH — memory.rs:1132 clamps with the identical bound that :1130 already delivers
helios/src/runtime_core/memory.rs:1125-1133
crate::offload::PrepareInputs {
max_active: active,
input_staging: staging,
shard: self.cluster().map(|cluster| (cluster.rank, cluster.world)),
integrated: integrated > 0,
max_sequence_pages: Some(max_sequence_pages),
},
capture.then_some(minimum_pages.min(max_sequence_pages)),
capture.then_some(..) is non-None only when the pool-capture branch is live, and in that branch headroom_inner applies exactly this cap to the local_pages argument it receives:
selene/src/offload.rs:163-171
let capture = local_pages.filter(|_| self.pool_only());
let intake = if let Some(pages) = capture {
let chain_pages = match inputs.max_sequence_pages {
Some(limit) if limit > 0 => pages.min(limit),
So pages.min(limit) with limit == max_sequence_pages is applied to minimum_pages.min(max_sequence_pages). The .min(max_sequence_pages) at :1132 is a second clamp with a bound it has just handed to the callee — it can be deleted with no behaviour change:
capture.then_some(minimum_pages),
which is also exactly what the line looked like before this PR (-capture.then_some(minimum_pages), in the diff), so this removes a hunk rather than adding one.
4. MEDIUM — The chain→bytes product is hand-rolled twice; Layout already has the helper
The "pages + one row's slots, times record bytes" product appears twice, once per crate, both hand-rolled with saturating_add:
selene/src/offload.rs:169-171
let chain = chain_pages
.checked_add(layout.row_slots() as u64)
.ok_or("pool capture slot count overflow")?;
helios/src/runtime_core/memory.rs:1552-1555
let chain_bytes = pages
.min(max_sequence_pages)
.saturating_add(layout.row_slots() as u64)
.saturating_mul(layout.page_record_bytes);
Layout already exposes this arithmetic family at selene/src/geometry.rs:229-235:
/// Bytes a record with `pages` tail pages and a row occupies.
pub fn record_bytes(&self, pages: u64) -> u64 {
self.record_bytes_for(pages, true)
}
record_bytes(pages) computes pages * page_record_bytes + row_record_bytes, which is the same quantity modulo row_record_bytes vs row_slots() * page_record_bytes. Add the one missing sibling next to it (pub fn chain_record_bytes(&self, pages: u64) -> u64 { (pages + self.row_slots() as u64) * self.page_record_bytes }, or make record_slots/record_bytes compose) and both sites shrink to one call — memory.rs:1552-1555 becomes layout.chain_record_bytes(pages.min(max_sequence_pages)), and capture_growth (memory.rs:674-675, which computes the same product a third time) reuses it too.
That also addresses the real hazard here: the clamp is now spelled four different ways in one function region — memory.rs:1130, :1132, :1486 (capture_growth(layout, pages.min(max_sequence_pages), …)), :1552-1555 — plus the enforcement point at offload.rs:165-169. headroom_inner clamping pages does not protect capture_growth or planned_offload_host, which is why the author had to repeat .min(max_sequence_pages) at each of them. Single-sourcing the product removes the reason for the repetition.
5. MEDIUM — The new test re-walks the sibling test it sits next to
selene/src/offload/tests.rs:566-621 (pool_only_caps_capture_buffer_to_max_sequence_pages) duplicates the fixture and assertion skeleton of selene/src/offload/tests.rs:525-563 (pool_only_sizes_registered_capture_and_headroom_for_local_ranks), 3 lines above it:
| existing :528-556 | new :568-597 | |
|---|---|---|
| options | PrefixCacheOffload { pool: Some(pool("unix:/run/selene.sock")), ..Default::default() } |
identical |
| ranks | vec![geometry(64, &[("kv", 4096)], 8192); 2], ranks[0].page_capacity = 8 / 512 |
identical shape, both = 512 |
| registrar | TrackingRegistrar::default() |
identical |
| buffer assert | assert_eq!((buffer.slot_count(), buffer.intake_slots()), (slots, 0)) |
identical |
| headroom assert | (2 * STORE_DEVICE_MARGIN_BYTES + bytes.div_ceil(512), bytes) |
identical |
The existing test even loops over for pages in [10, 512] calling inputs(4) — the new test could be three lines inside that loop (one extra PrepareInputs { max_sequence_pages: Some(64), ..inputs(4) } case), or both could call a shared fn capture_buffer(options, ranks, inputs) -> (usize, u64, TrackingRegistrar). ≈ −40 lines of duplicated fixture for the same coverage.
6. LOW — Nits, listed for completeness
selene/src/offload.rs:628—max_sequence_pages: _,in the destructure forces every futurePrepareInputsfield to touch this line (the compiler will not let_-named bindings absorb extras)...would be inert to growth. Marginal, but this struct is on a growth trajectory.docs/prefix-cache-offload.md:1603— the re-wrap left one long line in a 79-column paragraph:"--prefix-cache-memoryto choose the host memory explicitly. While the manager can accept"` (~92 chars). Pre-existing text; the PR reflowed the whole paragraph and this line escaped. Diff hygiene only.docs/prefix-cache-offload.md:1599-1601— "the full-chain floor is 7.1 GiB" now sits next to a formula that redefined what "full chain" means (min(GPU page capacity, …)). The 7.1 GiB figure is inherited from #455 and is not re-derived under the cap; it is stale-adjacent rather than wrong. Not a subtraction item, flagged because the sentence around it was rewritten.
What is correctly lean (no action)
- No new knob.
max_sequence_pagesis internal Rust API onPrepareInputs, not a flag, config key, or default. The PR could have added--prefix-cache-capture-pagesand did not. - No new abstraction, trait, wrapper, or module. The change is one struct field, one
match, and four.min(..)calls. - No duplicated helper invented —
row_slots()(geometry.rs:217-222) andintake_slots(offload.rs:227-229) are pre-existing and reused rather than re-derived. - Eight fixture call sites (
helios/src/offload/pool/tests.rs:134,memory.rs:2031,selene-manager/tests/client.rs:3255,3509,selene-manager/tests/offload.rs:139,selene/src/offload/sharded/tests.rs:118,261,392,558,selene/src/offload/tests.rs:14,51) all passNone— correct given the field must default to the existing behaviour. Adding#[derive(Default)]or aPrepareInputs::new(..)builder to avoid the churn would be more code, not less; leave it. - No dead code introduced other than item 2's branch.
Suggested minimal patch summary
| Item | File:line | Change | Δ |
|---|---|---|---|
| 1 | memory.rs:32-35,1589-1592; model.rs:1118,1155-1157 |
Pass max_sequence_pages through PlannedHostBudgets → prepare_offload |
≈ −5 |
| 2 | offload.rs:165-168,343-345 |
map_or(pages, |limit| pages.min(limit)), delete Some(0) semantics |
≈ −3 |
| 2b | tests.rs:604-620 |
delete the Some(0)/None equivalence assertions |
≈ −8 |
| 3 | memory.rs:1132 |
capture.then_some(minimum_pages) (restores the pre-PR line) |
−1 |
| 4 | geometry.rs:229+; offload.rs:169-171; memory.rs:674-675,1552-1555 |
One Layout::chain_record_bytes(pages) helper |
≈ −6 |
| 5 | tests.rs:566-621 |
Fold into the existing loop / shared fixture | ≈ −40 |
Total ≈ −60 lines, with the two highest-value items (1 and 3) also removing a silent None-divergence path and a redundant clamp.
Gates and contracts
Contracts, Charter & Verification Gates Audit — PR #742 (selene,helios: bound pool-only capture buffer to max_sequence_pages)
Verdict: No contract or verification gate blockers.
The diff (9 files, +115/−10) is a single coherent outcome: one new Option<u64> on an unpublished internal Rust struct, one min() at the single sizing/enforcement point, three clamped call sites in Helios startup memory planning, one documentation paragraph rewritten, two new unit tests and eight fixture fields. Nothing in the hard-gate set is violated. Details per gate below, followed by two Info / Nit observations and the one thing a maintainer should consciously accept.
Gate 1 — Signed core-format / wire / captured-graph / public-contract boundaries: PASS
- No proto, core-format, or wire changes. The diff touches no
.proto,helios/src/core/, noFORMAT_VERSION(docs/core-format-design.md:8-9), no enum, no reserved identifier, no signature domain. Design-review principle 13 (model core compatibility, retained readers for legacy cores) is not engaged: previously exported cores still load unchanged because nothing about prepared metadata, allocation payloads, or graph catalogs changes. - No captured-graph op contract. Principle 1 (
docs/design-review.md:22-26) requires owner approval for a captured-graph operation family; this PR adds no operation, no shape/capacity variant, no graph kind. No approval is needed and none is claimed. - No public/CLI/config surface. The only API addition is
PrepareInputs::max_sequence_pages: Option<u64>(selene/src/offload.rs:343-346), a struct in selene, which the charter roadmap records as not published (#6, "the crates aren't published yet"). No flag, no config key, no environment variable, no default changed — so principle 10 ("use explicit configuration", no env behavior switches) and the "no magic defaults / no per-model flags" charter rule are respected. All eight in-repo construction sites are updated (selene/src/offload/tests.rs:14,51,selene/src/offload/sharded/tests.rs:118,261,392,558,helios/src/offload/pool/tests.rs:134,helios/src/runtime_core/memory.rs:2031,selene-manager/tests/client.rs:3255,3509,selene-manager/tests/offload.rs:139) plus both production sites (helios/src/runtime_core/memory.rs:1130,helios/src/runtime_core/model.rs:1168), i.e. 11 insertion points, exactly as the description claims. - No contradicted normative doc left stale. The one doc that specifies this buffer is updated in place:
docs/prefix-cache-offload.md:1593-1608now states the capped chain rather than the old whole-GPU-capacity chain, and the automatic-intake floor is stated correctly there (chain.max(intake_slots(...)),selene/src/offload.rs:179-181).docs/runtime-core-design.md:732-738("deduct the pinned host reservation from prefix-cache capture growth") anddocs/core-design.md:295("Shared CPU/GPU DRAM is one budget") remain true descriptions — the cap changes the size charged into that one budget, not the accounting rule.docs/scheduling-theory.mdanddocs/scheduling-runtime-design.mdwere checked and contain no statement about this buffer (no matches for "capture buffer", "host budget", "pool-only", "page capacity").
Gate 2 — Vendored upstream dependencies & cross-PR coupling: PASS
- No vendored upstream file is forked.
helios/native/,selene-manager/docs/, and all vendored C/build.rs(not opened) inputs are untouched; the diff contains noCargo.toml/Cargo.lockchange, so dependencies remain pinned as onmain(charter: "pin dependencies to exact versions or commits", #215). - No unmerged external recipe or PR is depended on. The change is self-contained in-repo.
- Merge-order overlap with open #737 (lukealonso) — which rewrites
host_pool_budget_and_total*inselene/src/offload.rsand the host-RAM/future accounting in the samememory.rs/model.rs— is a sequencing risk, not a gate violation: #742 does not fork #737's code or require it.Info / Nitonly.
Gate 3 — Mandatory verification evidence & failing tests: PASS (with a disclosed-evidence caveat)
- No failing test or failing CI is reported anywhere in the description or the Discovery Dossier, and the PR reports green runs on the head commit for all six crates that
.github/workflows/native-serving.yml:45-81(not opened) exercises, in--locked --release(eos 12, selene 650 with--features test-support, selene-manager 448, helios 2,041 with--features runtime-core,server, flare 255, flare-cli 254). That matches Layer 1 ofdocs/design-review.md:180-193exactly. No CI checks are observable on02990da, which by itself is not a finding. - TLA+
verification/helios-lifecycle/check.pyis not a mandatory gate for this diff. Layer 3 / the "mandatory enforcement" block (docs/design-review.md:209-240) triggers on admission, fences, generations, cancellation, speculation accounting, cache compaction, snapshot aliases, response buffering/ownership, offload aggregation (rank job aggregation,helios/src/offload/transfer.rs(not opened)), readiness, or rank coordination. The changed functions —headroom_innerstartup sizing (selene/src/offload.rs:150-222),capacities/capture_growth/planned_offload_hoststartup planning (helios/src/runtime_core/memory.rs:667-681, 683-780, 1550-1556) — are none of those, andhelios/src/runtime_core/memory.rsappears in noCHECKSentry or mutation target incheck.py:18-36, 473-792. No new protocol state or geometry bound is added, so the "keep formal bounds aligned" clause does not apply. Same reasoning for Kani: no completion-vector validation, prepared completion contract, state-view extent arithmetic, or sequential validator is touched. - The memory claim is a live trace, not an unattributable combined-stack speedup. Principle 12 requires "actual Helios service measurements" for performance claims and "the target benchmark or live trace" for memory cost (
docs/verification.md:15); the author suppliesdocker statsRSS on identical Qwen4-35B-A3B / 24 GiB-cgroup hardware (18.74–19.06 GiB pool-only vs 7.83–8.04 GiB at--prefix-cache-memory 1G, delta matching the configured slab delta), plus the startup log linepool only: capture buffer 11.8 GiB (16475 slots, …). The provenance is disclosed rather than hidden ("observed on av0.6.0(f705086) build carrying this exact patch rather than re-measured via an A/B restart onf46a99220a"), which is whatAGENTS.md:194-199and principle 12's "keep raw measurements and disclose unrun checks and material limitations" require. This is therefore not a hard gate failure — but it is the one item a maintainer should consciously accept rather than infer: the head commit has nomain-vs-branch A/B for the RSS or the 70.7 → 11.8 GiB figure, and no test drives the newmodel.rswiring (the two new tests exerciseheadroom_innerandcapture_growthin isolation). If the merging maintainer wants principle 12 evidence tightened, that is the ask; it is not a blocker under the gates as written, because the disclosed provenance is honest and the mechanism is otherwise covered by a passing head-commit unit test. - Charter "bring real evidence": PR description has all four required parts in order (why → what changed → claimed benefit → evidence), including an explicit "Unrun checks" section (hardware CUDA,
tests/server/test_prefix_cache_offload.py(not opened),qualify/host_cache.py(not opened), unified memory, sharded/RoCE, Windows, Kani/TLA+). Discord line present (Discord: fakoli, principle 17 satisfied).
Gate 4 — Material scope / claim contradictions: PASS
I verified every concrete artifact the description names against the diff:
pool_only_caps_capture_buffer_to_max_sequence_pages— present,selene/src/offload/tests.rs:566-621; asserts both the capped slot count and theSome(0)/Noneuncapped headroom, as described.pool_capture_growth_caps_at_max_sequence_pages_without_throttling_gpu_pages— present,helios/src/runtime_core/memory.rs:2440-2457.- The three clamps — present at
memory.rs:1132(capture.then_some(minimum_pages.min(max_sequence_pages))),:1486,:1553; the derivation at:996; the attach-path value atmodel.rs:1155-1159. - Doc rewrite — matches the before/after in the diff (
docs/prefix-cache-offload.md:1593-1603), and the GLM-5.3-Flash TP4 11.0 GiB / 1,664 slot / 7.1 GiB floor example is retained. - No unrelated tooling, no bundled feature surface, no thousands of stray lines. Nothing claimed that is absent; nothing present that is unclaimed in material terms (the
None/Some(0)uncapped semantics and the intake floor are both stated in the description). - Scope is not expanded. No HTTP surface, no prefill/decode routing, no cluster orchestration — none of closed #718's out-of-scope material is carried. Capture remains single-host by construction (
self.cluster().is_none()inmemory.rs:998,shard.is_none()inoffload.rs:700), consistent withdocs/prefix-cache-offload.md:1608. The charter non-goals are untouched. - Charter authorisation question (flagging for the maintainer, not as a gate breach):
AGENTS.md:165-169accepts a contribution that addresses "an explicit maintainer request, a demonstrated defect, a measured performance or memory problem, or inaccurate documentation." This PR claims a measured memory problem with a disclosed live trace, which lands inside that list. But the origin remark in yatesdr's #455 review asked only to state the size and the failure case, which #455 satisfied in docs; the runtime cap itself is the author's extrapolation with no issue filing. This is a judgement call for the merging maintainer (charter line: "PRs that address … a measured performance/memory issue" is satisfied; "explicit maintainer request" is arguably not) — not a contract-, vendored-file-, or verification-gate violation.
Info / Nit (non-blocking)
- Doc precision:
docs/prefix-cache-offload.md:1596says the chain is bounded bymin(GPU page capacity, ceil(max_sequence_tokens / page_tokens)), but on the Helios path thelocal_pagesargument it is combined with isminimum_pages.min(max_sequence_pages)(helios/src/runtime_core/memory.rs:1132), i.e. the pre-planned minimum page capacity, not the allocated capacity. The prose is correct for a caller that passes the allocated capacity; it is slightly loose about which capacity Helios supplies. Documentation wording only. - Merge-order with open #737 (lukealonso): it redefines the host-budget functions this cap divides against and touches the same
selene/src/offload.rsandmemory.rs/model.rsregions. Sequencing, not a gate.
Explicitly not flagged (per calibration)
- No CI is observable on
02990da; the PR does not claim a failure, and the reported local runs cover every cratenative-serving.ymltests, so absence of observable checks is not reported. - No
docs/TODO.txtbookkeeping ask. heliopauseis not in the native-serving workflow's test list, so not running it is not a gap for a change that touches noheliopausecode (verified: noPrepareInputs/prepare_with_inputsuse there).- PR-description phrasing, the intake-floor design choice, the
memory.rs/model.rsNoneasymmetry, and thepages > max_sequence_pagesassertion strength are all correctness/design-lens items, disclosed in the description, and out of scope for this governance gate.
Code correctness
Deep Code Correctness / Invariants / Hot-Path Audit — PR #742 (selene,helios: bound pool-only capture buffer to max_sequence_pages) @ 02990da
Scope note: 9 files, ~115 changed lines across selene/, helios/, selene-manager/ tests, and one doc — below the >12-file/>900-LOC threshold, so I audited directly (no sub-agents). I read the whole diff, both changed production functions (selene::offload::headroom_inner, helios::runtime_core::memory::allocate_caches/capture_growth, helios::runtime_core::model::prepare_offload), and every callee/enum they touch (page_ceiling, capacities, capture_growth, PageLimit, KvCacheLimit, Layout::row_slots, intake_slots, slab::WINDOW_PAGES, MemoryStore::fits/allocate_slots/shortfall, CompositeStore::store, StoreOutcome/StoreReason, PageCapacity/CacheGeometry).
Two verified defects. One is Major (silently undersizes the capture slab and livelocks full-context captures).
F1 — Major (Blocker-class for the feature's stated use case): the capture slab is sized from minimum_pages, not from the GPU capacity or the bound, so a full max_sequence_tokens chain can never fit and every publication retries forever
Diff site — helios/src/runtime_core/memory.rs:1132 (changed line, capture.then_some(minimum_pages) → capture.then_some(minimum_pages.min(max_sequence_pages))):
1122: let (device, tier_host) = options.prefix_cache.headroom_with_inputs_for_budget(
...
1125: crate::offload::PrepareInputs {
1126: max_active: active,
1127: input_staging: staging,
1128: shard: self.cluster().map(|cluster| (cluster.rank, cluster.world)),
1129: integrated: integrated > 0,
1130: max_sequence_pages: Some(max_sequence_pages),
1131: },
1132: capture.then_some(minimum_pages.min(max_sequence_pages)),
1133: initial_budget,
1134: )?;
Callee that consumes it — selene/src/offload.rs:163-181 (the whole capture branch, only line 165-169 is new, but the surrounding semantics are what F1 turns on — the parameter is documented at selene/src/offload.rs:125 as "local_pages is the largest GPU page capacity when all ranks share this process"):
163: let capture = local_pages.filter(|_| self.pool_only());
164: let intake = if let Some(pages) = capture {
165: let chain_pages = match inputs.max_sequence_pages {
166: Some(limit) if limit > 0 => pages.min(limit),
167: _ => pages,
168: };
169: let chain = chain_pages
170: .checked_add(layout.row_slots() as u64)
171: .ok_or("pool capture slot count overflow")?;
...
179: chain
180: .max(intake_slots(layout, inputs.max_active) as u64)
181: .min(budget)
So chain_pages = min(minimum_pages, max_sequence_pages).
But minimum_pages is not the GPU page capacity. memory.rs:997 (context line, unchanged):
997: let minimum_pages = ceiling.map_or(active as u64 * 8192u64.div_ceil(page_tokens), |limit| limit.minimum);
With the default KvCacheLimit::Memory (helios/src/runtime_core/limits.rs:11-17, #[default] Memory), page_ceiling returns Ok(None) at memory.rs:567-569, so minimum_pages = active * ceil(8192 / page_tokens) — a concurrency floor, not the capacity. capacities(...) (memory.rs:683-829) then binary-searches the real capacity up to maximum_pages, whose bound is only the virtual extent (memory.rs:710,742) — i.e. it can be far above minimum_pages.
Concrete counterexample (the PR's own config): context = 1,048,576, page_tokens = 64 ⇒ max_sequence_pages = 16,384 (memory.rs:996). active = 32 ⇒ minimum_pages = 32 * ceil(8192/64) = 32 * 128 = 4,096. GPU capacity actually allocated = 99,008 pages (the PR's own table). Then:
- Slab slots (
offload.rs:169-181) =min(4,096, 16,384) + row_slots= 4,096 + row slots ≈ 2.9 GiB at ~748 KiB/page-record — not the 16,475 slots / 11.8 GiB the PR's table claims. - Planning charges instead
pages.min(max_sequence_pages) + row_slots= 16,384 + row slots = 16,475 slots (memory.rs:1550-1556,memory.rs:1486), so startup logs/accounts 11.8 GiB while ~2.9 GiB is actually mapped.
Failure path (proved by reading the callees): a request that reaches max_sequence_tokens publishes a root chain whose tail pages can be up to max_sequence_pages = 16,384 (a root holds the whole chain — selene/src/memory.rs:529-534, and GPU page_chain concatenates every ancestor's tail_pages, helios/src/cache.rs:600-606). Then
selene/src/memory.rs:4183-4190(MemoryStore::store):if !self.core.fits(record_slots(tail.len(), row))— note this is the only pre-check and it returnsOversize; but the flat/capture store is reached throughCompositeStore, andselene/src/memory.rs:1730-1732:fn fits(&self, slots: usize) -> bool { slots + self.pool.intake_slots() <= self.pool.slot_count() }—slot_count() = 4,096 + row_slots<16,384 + row_slots⇒false; and if it did pass,allocate_slots(memory.rs:771-793) loopswhile self.pool.free_slots() < needed + intake_slots()and returnsNonewhen no candidate is evictable (memory.rs:784-792),- so
start_record→allocatereturnsOk(None)(memory.rs:645-647),store/store_recordreturnsOk(false)(memory.rs:606-608), which surfaces asStoreOutcome::Retry(StoreReason::Slabs)(selene/src/composite.rs:2043-2054andselene/src/memory.rs:4195-4199).
That retry is re-attempted every poll pass with the checkpoint still pinned (helios/src/server/runtime.rs:3470-3511: self.scheduler.pin_checkpoint(...), then StoreOutcome::Retry(reason) => { ...; continue; } never unpins until a later outcome), so a long sequence's checkpoint is retained on the GPU and re-offered indefinitely and the pool never receives it. This is exactly the "long-context core exports to the manager" scenario the PR exists to fix, just now silently instead of with host budget cannot hold a full pool capture.
Fix: pass the bound, not the floor:
// memory.rs:1132
capture.then_some(max_sequence_pages), // keep `minimum_pages` only for the
// feasibility/error check below
(memory.rs:763-773 already errors with a precise message when minimum_pages cannot be backed, so nothing is lost.) Alternatively, keep min(...) here but then also cap the validation side (capture_growth at memory.rs:1486 and planned_offload_host at memory.rs:1550-1556) to the same min(minimum_pages, max_sequence_pages) — but that would re-introduce the per-publication livelock for any core with active * ceil(8192/page_tokens) < ceil(max_sequence_tokens/page_tokens), which is the common case (4,096 < 16,384 above). The first fix is the correct one.
Why the tests miss it: the new helios test at helios/src/runtime_core/memory.rs:2440-2456 calls capture_growth(&layout, pages.min(max_sequence_pages), ...) inlined in the test, never through allocate_caches line 1132, so it cannot observe a disagreement between the slab size and the growth charge:
2443: let max_sequence_pages = 128u64;
2444: let reserved = (max_sequence_pages + layout.row_slots() as u64) * layout.page_record_bytes;
2445: assert_eq!(
2446: capture_growth(&layout, 512u64.min(max_sequence_pages), reserved, 0, 1),
2447: Some(0)
2448: );
...
2450: let (_, pages, _) = capacities(&cores, &[1 << 30], 1, 1, 64, None, |_, pages| {
2451: capture_growth(&layout, pages.min(max_sequence_pages), reserved, 0, 1)
2452: })
It also never asserts that slot_count() from prepare_with_inputs equals pages.min(max_sequence_pages) + row_slots, nor that a full-chain publication goes Queued. The new selene test (selene/src/offload/tests.rs:567-621) passes Some(512) as local_pages — a capacity — so it validates headroom_inner in isolation and likewise cannot see the helios caller feeding it minimum_pages.
F2 — Minor: div_ceil by page_tokens panics on a zero page_tokens contract, where the code previously returned a graceful error
Diff sites (helios/src/runtime_core/memory.rs:996, context line but newly required to be total; and the new line helios/src/runtime_core/model.rs:1155-1157):
995: let ceiling = page_ceiling(options.kv_cache_limit, context, active as u64, &contract)?;
996: let max_sequence_pages = context.div_ceil(contract.cache.page_tokens as u64);
1155: let max_sequence_pages = self.server_config["max_sequence_tokens"]
1156: .as_u64()
1157: .map(|context| context.div_ceil(contract.cache.page_tokens as u64));
Callee/enum resolution: the only in-function guard against page_tokens == 0 is inside page_ceiling, and it is conditional on the limit mode — memory.rs:567-574:
567: if mode == KvCacheLimit::Memory {
568: return Ok(None);
569: }
570: if context == 0 || contract.cache.page_tokens == 0 {
571: return Err(invalid(
572: "KV cache limit requires a positive context and page size",
573: ));
574: }
KvCacheLimit::Memory is the #[default] (helios/src/runtime_core/limits.rs:11-17), so for the default mode page_ceiling returns Ok(None) before the zero check, and line 996 then divides by zero. PreparedContract::validate does reject cache.page_tokens == 0 (helios/src/model/contract.rs:536), but that path is only reached from catalog::validate on the server config (helios/src/model/catalog.rs:31); runtime_core::allocate_caches deserializes server_config["model_contract"] itself at memory.rs:899-901 without calling validate(), and prepare_offload does the same at model.rs:1139-1141. capacities has an explicit page_tokens == 0 guard (memory.rs:696) and page_ceiling an explicit context == 0 guard, which shows the function is designed to stay total on malformed prepared geometry — the new line removes that property and turns a clean invalid(...) error into an arithmetic panic during startup of a tampered/foreign core. model.rs:1157 is worse: page_tokens comes from a contract that was already deserialized in this function at model.rs:1139 and never validated.
Fix: reuse the value already validated, or guard inline:
996: let max_sequence_pages = match contract.cache.page_tokens {
997: 0 => return Err(invalid("model requires a positive cache page size")),
998: tokens => context.div_ceil(tokens as u64),
999: };
and the same guard in model.rs:1155-1157.
Checks that found nothing (stated plainly)
headroom_innerbound semantics (selene/src/offload.rs:165-168) are correct as written.Some(limit) if limit > 0 => pages.min(limit), elsepages:Some(0)andNoneboth stay uncapped, which matches the doc comment (offload.rs:343-346) and is exactly whatselene/src/offload/tests.rs:604-620asserts.limit > 0is not dead:pages(apage_capacityfromCacheGeometry::validate,selene/src/geometry.rs:115, which requires> 0) is> 0, soSome(0)really is reachable and really selects the uncapped branch.checked_addonrow_slotsbefore the budget comparison preserves the overflow error. No order-of-operations defect:budgetis computed frompage_record_bytesbefore thechain > budgettest, and theSome(budget)override is applied before the division (offload.rs:172-178).capture_growth(memory.rs:667-681) is monotone inpages(slots = pages + row_slots,extra = slots*record_bytes - reserved,Nonewhenextra > host_free), so capping its argument atmax_sequence_pageskeeps the binary search incapacities(memory.rs:775-783) well-ordered:fitsstays monotone non-increasing, solowis still the maximum feasible page count and the search cannot oscape. The new capping removes an artificial ceiling atmax_sequence_pages(previously GPU pages were throttled once the capture slab exceededhost_free), which is the intended behaviour and is asserted bymemory.rs:2450-2454(assert!(pages > max_sequence_pages)).planned_offload_host(memory.rs:1550-1556) andcapture_growthnow use the samepages.min(max_sequence_pages)expression, so the plan is self-consistent (the inconsistency is with the slab, F1).saturating_add/saturating_mulkeep it total.max_sequence_pagesderivation is correct on well-formed cores.catalog::validaterequiresmax_sequence_tokensto be a positive multiple ofpage_tokens(helios/src/model/catalog.rs:46-56), sodiv_ceilis exact and>= 1;Some(limit)withlimit > 0therefore always engages in production.memory.rs:996andmodel.rs:1157derive the same value from the sameserver_config+ contract, so planning and attachment agree (both areNone-free in practice).- Hot path: no algorithmic change. All new code runs once per process at startup (
allocate_caches,prepare_offload,prepare_with_inputs_budget_with_progress); nothing added lies on the per-step / per-request / per-victim loops.Layout::row_slots()(selene/src/geometry.rs:217-222) is O(ranks) and is called O(1) times. No new allocation in a loop, no O(N·span) scan. - Test fixtures are semantically sound. Adding
max_sequence_pages: Noneto the existingPrepareInputsliterals (helios/src/offload/pool/tests.rs:134,selene-manager/tests/client.rs:3255,3509,selene-manager/tests/offload.rs:139,selene/src/offload/sharded/tests.rs:118,261,392,558,selene/src/offload/tests.rs:14,51) preserves prior behaviour exactly (None⇒ uncapped), andPrepareInputsderivesClone, Copy, Debug(offload.rs:332) so the struct-by-value signature is unaffected.prepare_with_inputs_budget_with_progressdestructures the new field withmax_sequence_pages: _(offload.rs:628), which is correct since it forwards the wholeinputstoheadroom_inneratoffload.rs:704-710and never needs the field itself.
Verdict
- F1 (Major):
memory.rs:1132must passmax_sequence_pages, notminimum_pages.min(max_sequence_pages), or pool-only capture of any chain longer thanactive * ceil(8192 / page_tokens)pages is permanently un-storable (Retry(Slab)) while the GPU checkpoint stays pinned — and the slab is silently ~4× smaller than the host budget the planner charges for. - F2 (Minor): add an explicit
page_tokens == 0guard atmemory.rs:996/model.rs:1157instead of relying onpage_ceiling, which short-circuits in the defaultKvCacheLimit::Memorymode. - No other correctness, state-ordering, boundary, or hot-path performance defects found in the changed code; the
Some(0)/None/limit == 1boundary behaviour, the overflow guards, and the binary-search monotonicity all check out.
Full report · Notes Merge Risk: medium_high (100%): Medium or high merge risk (core runtime/scheduler/GPU/CUDA/VMM/RoCE/multi-rank/contracts/ABI, large multi-crate changes, or Blocker/Major findings) — route to Super Agent.
Final review
Recommendation: Changes Requested
The core pool-only capture-buffer bound in selene/src/offload.rs, helios/src/runtime_core/memory.rs, and helios/src/runtime_core/model.rs is sound: planning, binary-search growth charging, planned_offload_host, and final slab allocation agree on min(GPU page capacity, ceil(max_sequence_tokens / page_tokens)), and the docs and unit tests accurately match the implementation. One verified defect warrants a small fix before merge: the new context.div_ceil(contract.cache.page_tokens as u64) lines in memory.rs:996 and model.rs:1155-1157 are unguarded against contract.cache.page_tokens == 0 (turning a previously clean Err(invalid(...)) into an unconditional divide-by-zero panic under the default KvCacheLimit::Memory mode) and against context == 0 (which creates a 0-vs-uncapped mismatch with selene). Guarding those inputs and threading max_sequence_pages through PlannedHostBudgets resolves the defect cleanly.
Merge Risk
Level: Low
- Small, localized startup-only change (+115/−10 across 9 files) with no CLI/config/wire/core-format surface and no hot-path runtime impact.
- Strictly relaxes pool-only host-budget sizing on single-process deployments (
--prefix-cache-pool --prefix-cache-memory 0, no disk tier); deployments with a local memory or disk tier and multi-host sharded ranks are unaffected. - Overlaps with open PR #737 in
selene/src/offload.rs,helios/src/runtime_core/memory.rs, andhelios/src/runtime_core/model.rs(host-budget accounting); coordinate merge/rebase order if #737 lands first.
Walkthrough
selene/src/offload.rs: Addspub max_sequence_pages: Option<u64>toPrepareInputs(:340-347), clampschain_pagesinheadroom_innertopages.min(limit)whenSome(limit)withlimit > 0(:165-169), and updates the destructure inprepare_with_inputs_budget_with_progress(:628) while forwardinginputsintoheadroom_inner(:704-710).helios/src/runtime_core/memory.rs: Computesmax_sequence_pages = context.div_ceil(contract.cache.page_tokens as u64)(:996), passesSome(max_sequence_pages)andminimum_pages.min(max_sequence_pages)into initialheadroom_with_inputs_for_budget(:1130-1132), and clampspages.min(max_sequence_pages)in bothcapture_growth(:1486) andplanned_offload_host(:1553).helios/src/runtime_core/model.rs: Derivesmax_sequence_pagesfromself.server_config["max_sequence_tokens"]andcontract.cache.page_tokens(:1155-1157) and passes it toprepare_with_inputs_budget_with_progress(:1168), wherelocal_pagesis the actual allocated GPUpage_capacity.docs/prefix-cache-offload.md: Updates the pool-only capture buffer section (:1593-1603) to document the single-sequence chain cap and capped minimum-capacity startup failure behavior.- Tests (
selene/src/offload/tests.rs,helios/src/runtime_core/memory.rs, and existingPrepareInputstest fixtures): Addspool_only_caps_capture_buffer_to_max_sequence_pagesandpool_capture_growth_caps_at_max_sequence_pages_without_throttling_gpu_pages, and setsmax_sequence_pages: Noneacross existing test fixtures.
Pre-merge Checks
- [PASS] Security / malicious screen: No obfuscation, prompt injection, external network/secret access, or suspicious code paths.
- [PASS] Charter & value fit: Model-agnostic fix for a measured host-memory issue on target SM120/SM121 workstation hardware under the Selene prefix-cache offload goal; carries none of closed #718's out-of-scope HTTP/routing/disaggregation surface.
- [PASS] Related / duplicate / conflict check: Not a duplicate; carves out only the #455 pool-only capture bound from closed #718. Open PR #737 touches adjacent host-budget code in
selene/src/offload.rs,memory.rs, andmodel.rs(rebase coordination only). - [WARN] Tests & verification evidence: Author reports all six Rust crates passing in
--locked --releaseon02990da; live RSS telemetry (18.74–19.06 GiBvs7.83–8.04 GiB) was collected on av0.6.0(f705086) build carrying the same patch rather than re-measured A/B on02990da, and hardware CUDA /tests/server/test_prefix_cache_offload.py(not opened) /qualify/host_cache.py(not opened) were not run on head (all transparently disclosed).
Blockers
None.
Should Fix
- Unguarded
div_ceil(contract.cache.page_tokens as u64)panics on zeropage_tokensand mishandlescontext == 0under defaultKvCacheLimit::Memory(helios/src/runtime_core/memory.rs:992-996,helios/src/runtime_core/model.rs:1155-1157)- Verified behavior: In
allocate_caches(memory.rs:995-996),page_ceilingreturnsOk(None)immediately whenoptions.kv_cache_limit == KvCacheLimit::Memory(the#[default],memory.rs:567-569), bypassing itsif context == 0 || contract.cache.page_tokens == 0check atmemory.rs:570. Becausecontractis deserialized fromself.server_config["model_contract"]atmemory.rs:899-901without callingPreparedContract::validate(),context.div_ceil(contract.cache.page_tokens as u64)atmemory.rs:996now runs unconditionally on every load (even with offload disabled) and panics with division by zero whencontract.cache.page_tokens == 0, whereas before this PRcache_geometry→CacheGeometry::validate()(selene/src/geometry.rs:114) returned a cleanErr(invalid(...)). The same unguardeddiv_ceilappears atmodel.rs:1155-1157. In addition, ifcontext == 0underKvCacheLimit::Memory,memory.rs:996computesmax_sequence_pages = 0, which clampsmemory.rs:1132,1486,1553to0pages whileselene/src/offload.rs:165-168treatsSome(0)as uncapped (pages), causing planning and preparation to disagree. - Fix: Validate both
context != 0andcontract.cache.page_tokens != 0inmemory.rs:992-996, returningErr(invalid(...))before callingdiv_ceil(matchingmemory.rs:570,696,897). Then either thread the validatedmax_sequence_pagesintoprepare_offloadviaPlannedHostBudgets(see Subtract / Simplify #1) or add the matching non-zero guard inmodel.rs:1155-1157.
- Verified behavior: In
Subtract / Simplify
- Thread
max_sequence_pagesthroughPlannedHostBudgetsinstead of recomputing it inmodel.rs(helios/src/runtime_core/memory.rs:32-35,1589-1592,helios/src/runtime_core/model.rs:1038-1047,1113-1168):allocate_cachesalready returnsPlannedHostBudgetsdirectly toprepare_offload. Passingmax_sequence_pagesthere eliminates the duplicateserver_config["max_sequence_tokens"]/div_ceillogic inmodel.rs:1155-1157as well as thememory.rs(error on missing) vsmodel.rs(silentNone/uncapped fallback) asymmetry. - Remove the redundant clamp at
helios/src/runtime_core/memory.rs:1132:headroom_with_inputs_for_budgetreceivesmax_sequence_pages: Some(max_sequence_pages)at:1130and already appliespages.min(limit)insideheadroom_inner(selene/src/offload.rs:165-168). Keepingcapture.then_some(minimum_pages)restores the pre-PR line and leaves clamping in a single place. - Avoid dual uncapped sentinels (
NoneandSome(0)) if desired (selene/src/offload.rs:165-168,346): Oncememory.rs:992-996rejectscontext == 0, Helios never passesSome(0). UsingOption<NonZeroU64>(or documenting/keeping onlyNoneas uncapped) removes the redundantlimit > 0branch and the duplicateSome(0)assertion inselene/src/offload/tests.rs:604-614.
Nits
helios/src/runtime_core/memory.rs:2456: Inpool_capture_growth_caps_at_max_sequence_pages_without_throttling_gpu_pages, assertingassert_eq!(pages, 1024)(the synthetic core's fullmaximum_pages) is sharper thanassert!(pages > max_sequence_pages)and directly proves zero GPU page throttling.selene/src/offload.rs:628:..in thePrepareInputsdestructure (instead ofmax_sequence_pages: _) avoids churn whenever another field is added toPrepareInputs.docs/prefix-cache-offload.md:1603: Re-wrap line 1603 (~91 chars) to match the ~80-column paragraph wrapping around it.selene/src/offload/tests.rs:567-621: Could share fixture setup withpool_only_sizes_registered_capture_and_headroom_for_local_ranksright above it (:526-564) to trim ~30 lines of boilerplate.
Dropped on verification
- Upstream Code Correctness F1 ("Major: capture slab is sized from
minimum_pages, undersizing the slab ~4× and livelocking full-context captures"): Verified false.memory.rs:1122-1134callsheadroom_with_inputs_for_budgetonly to compute the initial minimum-capacitytier_hostreservation beforecapacities()selects GPUpages; it does not allocate any slab. Actual slab allocation happens inmodel.rs:1158-1172→selene/src/offload.rs:700-755, wherelocal_pagesisgeometry.iter().map(|rank| rank.page_capacity).max()(the allocated GPU page capacity, e.g.99,008) andhost_budgetisplanned_offload_host(memory.rs:1550-1556, computed frompages.min(max_sequence_pages)). Both allocate and budgetmin(allocated_pages, max_sequence_pages) + row_slots. - Upstream Value Proposition ("automatic-intake floor
intake_slotsleft uncapped"): Intentional design, explicitly documented in both the PR description anddocs/prefix-cache-offload.md:1594-1597so concurrent publication bursts retain adequate streaming slots. - Upstream Contracts Nit 1 ("
docs/prefix-cache-offload.md:1596loosely saysGPU page capacityinstead ofminimum_pages"): Verified false. Lines 1595-1597 describe the capture buffer's slot count (which uses allocated GPUpage_capacityviamodel.rs:1158→offload.rs:700), while lines 1600-1602 separately and accurately describe the "capped minimum page capacity" startup check (memory.rs:1132). - Upstream Subtraction Item 4 ("add
Layout::chain_record_byteshelper onselene::Layout"): Not worth adding new public API surface toselene::Layout—offload.rs:169operates in slots (not bytes) andcapture_growthvsplanned_offload_hostintentionally usechecked_*vssaturating_*arithmetic. - Upstream process/evidence escalations (unobservable CI checks on head, requiring A/B RSS re-measurement on
02990da, or blocking on #737 merge order / #455 provenance): Dropped from Blockers/Should Fix per review calibration; the change addresses a measured memory issue within Charter scope, discloses its evidence provenance and unrun checks honestly, and the sizing math is verified by unit tests on head.
Full report Decision to Test: no (92%): Testing will not add significant value as the code stands today. The code is either not yet ready to merge, or adequate testing has already been done to validate the contents of the code, or the available hardware is not suitable to test with.
Classify triage
Selected: triage:review
Threshold: 65%
Triage
- [✓]
triage:review: 99.9% -
triage:design-review: 0.0% -
triage:validation: 0.0% -
none: 0.0% -
triage:integration: 0.0% -
triage:investigate: 0.0% -
triage:verify-for-closure: 0.0% -
triage:partial: 0.0% -
triage:superseded: 0.0%
Apply labels
No label changes decide malicious: all_clear (100%): No malicious content found
explore
Author: fakoli (FIRST_TIME_CONTRIBUTOR; no prior merged work in this repo; Discord fakoli)
Motivation: In pool-only prefix-cache mode the capture buffer was sized to the largest GPU page capacity, so it could reserve roughly the whole GPU KV cache in host RAM and even stop the server from starting. This patch caps that buffer at one sequence's worth of pages, taken from max_sequence_tokens.
Scale: +94 / −21 lines in 9 files (head 66d6af3, 2 commits; was +115/−10 at 02990da)
Proposal:
- Add
PrepareInputs::max_sequence_pages: Option<NonZeroU64>and clamp the pool-only capture chain inheadroom_innerat one point (selene/src/offload.rs:165-167, :342-345). - Derive the bound in Helios from
context.div_ceil(contract.cache.page_tokens)withcontext > 0enforced (helios memory.rs:993-1000) and thread it throughPlannedHostBudgets(memory.rs:32-36, :1593-1597). - Remove the duplicate
max_sequence_tokenslookup inprepare_offload, which removes the oldmemory.rs/model.rsOptionasymmetry (model.rs:1125, :1167-1173). - Apply the same cap to
capture_growth(memory.rs:1490) andplanned_offload_host(memory.rs:1554-1560). - Document the cap and the capped startup-failure condition (docs/prefix-cache-offload.md:1593-1602); tests folded into
pool_only_sizes_registered_capture_and_headroom_for_local_ranksand an equality assertion added to the Helios growth test (memory.rs:2463). Touches: selene/src/offload.rs+selene/src/offload/tests.rs— the sole enforcement point and its sizing tests.helios/src/runtime_core/memory.rs— planning, budget charging, log summary; also where open #737 changesasync_transfer_host_ram.helios/src/runtime_core/model.rs+docs/prefix-cache-offload.md— value plumbing and operator-facing docs. Related items:- #718 fix: prefill-only KV handoff, announce barrier, bounded pool_only() capture (closed): the bundled predecessor; #742 carries only its sizing piece and says it supersedes it.
- #455 Capture single-process prefix checkpoints for the pool (merged): created the buffer; its 2026-11-21 review first named this cost, but asked only for documentation.
- #737 (open): rewrites the host-budget/AsyncTransfer accounting in the same two files; merge order can move the bound this buffer is charged against.
- #160 (closed): disaggregation ruled out of scope; the author's reopen request with 1P1D numbers cites #742 as the in-scope remnant.
- #497 Reduce disk offload restore latency (merged): introduced the
planned_offload_hostbudget this patch adds.min(…)to. Link: https://github.com/NVIDIA/hyperflare-inference/pull/742 Autobot comments: The 09:11 autobot review is stale — it is labelled "up to02990da", quotes +115/−10, and its single should-fix (unguardeddiv_ceil/context == 0) is closed at66d6af3byNonZeroU64plus a> 0filter. Unchanged: the intake floor is still uncapped (chain.max(intake_slots(...)), offload.rs:178-180), now disclosed in prose but not quantified — widemax_activecan still exceed one chain. Because every clamp only shrinks the charge, operators may see more GPU KV pages and startup succeeding where main failed; not in the title. The RSS evidence (18.74–19.06 vs 7.83–8.04 GiB) is still av0.6.0/f705086build, not an A/B on the head, and hardware CUDA/multi-host/Windows/Kani/TLA+ remain unrun (disclosed). Base label is stale: main is now012219a1(#713), ≈+161 lines of drift above the hunks. No maintainer review, no CI checks.
Classify intake
Selected: triage:review, performance, area:memory, area:preparation, area:selene
Threshold: 65%
Triage
- [✓]
triage:review: 99.8% -
triage:validation: 0.1% -
triage:design-review: 0.1% -
triage:partial: 0.0% -
triage:investigate: 0.0% -
none: 0.0% -
triage:integration: 0.0% -
triage:verify-for-closure: 0.0% -
triage:superseded: 0.0%
Priority
-
none: 100.0% -
priority:P1: 0.0% -
priority:P2: 0.0%
Type
- [✓]
performance: 97.1% -
enhancement: 43.8% -
community: 37.8% -
bug: 24.5% -
duplicate: 8.5% -
documentation: 0.5%
Area
- [✓]
area:selene: 98.9% - [✓]
area:memory: 93.2% - [✓]
area:preparation: 86.7% -
area:caching: 16.5% -
area:kernels: 0.1% -
area:orbit: 0.1% -
area:api: 0.1% -
area:rocenante: 0.1% -
area:engram: 0.1% -
area:scheduling: 0.0% -
area:packaging: 0.0%
Model
-
model:glm-5.3: 2.3% -
model:qwen3.8-27b: 1.1% -
model:muse-glimmer: 0.4% -
model:qwen3.8-flash-next: 0.3% -
model:nemotron-3.5-bolt: 0.2% -
model:mimo-v2.6: 0.2% -
model:kimi-k3.1: 0.2% -
model:deepseek-v4.1: 0.2% -
model:deepseek-v4: 0.1% -
model:gemma4: 0.0% -
model:inkling-small: 0.0%
Apply Labels (Intake)
No label changes
Gates and contracts
Audit report — PR #742 selene,helios: bound pool-only capture buffer to max_sequence_pages @ 66d6af3
Verdict: No contract or verification gate blockers.
All four hard gates pass. Nothing in this diff adds or changes a signed core-format/wire/captured-graph contract, forks a vendored upstream file, requires a formal or GPU-benchmark gate, or contains a claim contradicted by the tree.
Gate 1 — Signed core-format / wire / captured-graph / public-contract boundaries: PASS
- No proto, core-format, graph-catalog, enum, or wire change. The diff touches no
.proto, nohelios/src/core/, noFORMAT_VERSION, no reserved identifier, no signature domain — 9 files, +94/−21, all sizing arithmetic, one doc paragraph, and test fixtures. Existing exported cores load unchanged: nothing about prepared metadata, allocation payloads, or graph catalogs moves (principle 13 not engaged). - No captured-graph operation contract.
docs/design-review.md:22-26requires owner approval for a new operation family; this adds no operation, shape/capacity variant, or graph kind, so no approval is engaged and none is claimed. - The only API addition is internal and unpublished.
PrepareInputs::max_sequence_pages: Option<NonZeroU64>(selene/src/offload.rs:342-345) is a field on an internal Rust struct in selene, which the charter roadmap records as not yet published (#6, "the crates aren't published yet"). No CLI flag, config key, environment variable, or default value changes, sodocs/design-review.md:89-92(principle 10) and the charter's "no magic defaults / no per-model flags" rule are respected. - No new per-model branch or policy flag. The bound derives from
max_sequence_tokensandcontract.cache.page_tokens— prepared structural metadata, not model identity — consistent with principle 3 and the charter's model-agnostic runtime rule. Reach is narrow by construction: capture requiresoptions.prefix_cache.pool_only() && self.cluster().is_none()(helios/src/runtime_core/memory.rs:1002) andpool_only()with no shard (selene/src/offload.rs:163). - The one normative doc that specifies this buffer is updated in place, not left contradicted.
docs/prefix-cache-offload.md:1593-1609now states the ceilingmin(GPU page capacity, ceil(max_sequence_tokens / page_tokens))plus one row's slots, bounded by the host budget, and the capped startup-failure condition (:1600-1602). Adjacent normative statements remain true:docs/core-design.md:293-296("Shared CPU/GPU memory is one budget") anddocs/runtime-core-design.md:737-738("deduct the pinned host reservation from prefix-cache capture growth") describe the accounting rule, which this PR does not change — it changes the size charged into that budget.docs/scheduling-theory.mdanddocs/scheduling-runtime-design.md(not opened) contain no statement about this buffer (only the unrelatedscheduling-theory.md:551"captured graph is faster" remark). - No hidden contract weakening. The clamps only shrink a startup host-memory charge; no validation is removed — the
chain > budgetadmission error is retained atselene/src/offload.rs:175-177, now applied to the capped chain.
Gate 2 — Vendored upstream dependencies and cross-PR coupling: PASS
- No vendored upstream file is touched (
helios/native/,selene-manager/docs/, all vendored C andbuild.rs(not opened) inputs remain as onmain), and there is noCargo.toml(not opened) /Cargo.lockchange, so dependencies stay pinned exactly (charter: "pin dependencies to exact versions or commits", #215). - The change depends on no unmerged external recipe or PR; it is self-contained in-repo, and the eight
max_sequence_pages: Nonefixture insertions preserve every existing caller's behaviour (None= uncapped) exactly. - Info / Nit — merge order with open #737 (lukealonso). #737 rewrites the adjacent host-budget/
AsyncTransferaccounting in the sameselene/src/offload.rsandhelios/src/runtime_core/{memory,model}.rsregions and extendsPlannedHostBudgets, so it can move the free-host bound this buffer is charged against. A sequencing hazard, not a gate violation; the author addressed it in the PR reply (2026-12-05 09:19).
Gate 3 — Mandatory verification evidence and failing tests: PASS
- No failing test or failing CI is reported anywhere. The PR conversation has three entries (case-file notice 08:55, autobot review 09:11, author reply 09:19); none reports a red check. Per calibration, absence of observable CI runs is not treated as a finding.
- Layer 1 (
docs/design-review.md:180-194) is satisfied and correctly scoped. The PR reportscargo test --locked --releaseforeos(12),selene --features test-support(649 = 648 unit + 1 doctest),selene-manager --features test-support(448, 1 ignored, incl.rank_processes3),helios --features runtime-core,server(2,041 passed, 88 ignored),flare(255),flare-cli(254, 3 ignored) — exactly the crates.github/workflows/native-serving.yml(not opened) exercises (:47, :51, :52, :55, :63, :68, :73, :77; plusflare-winui/bridgeat:81, untouched by a numeric-only change).heliopauseis not in that workflow's test list and repo-wide search finds noPrepareInputs/prepare_with_inputsuse there, so not running it is not a gap.--locked --releaseis used as required;cargo checkis not substituted. - Layer 3 is not triggered (
docs/design-review.md:209-230). Its triggers are admission, fences, generations, cancellation, speculation accounting, cache compaction, snapshot aliases, response buffering/ownership, offload aggregation, readiness, and rank coordination. The changed functions are startup sizing only —headroom_inner(selene/src/offload.rs:150-205),allocate_cachescapacity planning with itscapture_growth/planned_offload_hostcallbacks, andprepare_offloadplumbing.verification/helios-lifecycle/check.pydeclares nine checked protocols (check.py:22-36) and none targets this arithmetic;helios/src/runtime_core/memory.rsappears only as a mutation target forcache_memorycode atcheck.py:723, unrelated to this diff. No new protocol state or geometry bound is added, sodesign-review.md:241-246does not apply. Same for Kani:#[cfg(kani)]harnesses exist only inhelios/src/{async_transfer/mod.rs (not opened), execution/transport.rs (not opened), model.rs, model/contract.rs (not opened), output/tagged.rs (not opened)}, none covering this arithmetic; no completion-vector validation, prepared completion contract, state-view extent arithmetic, or sequential validator is touched. - The memory-cost claim is a live trace, honestly limited.
docs/verification.md:15asks for "the target benchmark or live trace" for memory cost; the author suppliesdocker statscontainer RSS on identical hardware (18.74–19.06 GiB pool-only vs 7.83–8.04 GiB at--prefix-cache-memory 1G, delta 10.91–11.02 GiB matching the 11.8 vs 0.9 GiB slab delta) plus the startup log line, discloses that the figures came from av0.6.0(f705086) build carrying the same sizing rule rather than an A/B restart on the head, and lists the unrun checks (hardware CUDA,tests/server/test_prefix_cache_offload.py(not opened),qualify/host_cache.py(not opened), integrated memory, sharded/RoCE, Windows, Kani, TLA+). That is exactly the disclosureAGENTS.md:103-112and principle 12 (design-review.md:106-115) require. It is a scope-of-conclusion limitation a maintainer should read consciously, not a hard gate failure, and it is not an unattributable combined-stack speedup of the kind the gate targets. - Charter "bring real evidence" / four-part description. All four parts are present in order (why → what changed → claimed benefit → evidence), the bounded and unbounded formulas are distinguished with a metric table, the live numbers are attributed to their actual build rather than the head, and the required
Discord: fakoliline is present (AGENTS.md:142-153, principle 17).
Gate 4 — Material scope / claim contradictions: PASS
Every concrete artifact the description names exists on the head and matches:
pool_only_sizes_registered_capture_and_headroom_for_local_rankswith the(10, None),(512, None),(512, Some(64))cases —selene/src/offload/tests.rs:531-576, including the strictly-smaller assertion in the bounded case.pool_capture_growth_caps_at_max_sequence_pages_without_throttling_gpu_pageswith the equality assertionpages == uncapped_pagesandpages > max_sequence_pages—helios/src/runtime_core/memory.rs:2443-2464.- The clamps:
capture_growth(layout, pages.min(max_sequence_pages.get()), …)(memory.rs:1490), theplanned_offload_hostchain clamp (memory.rs:1557), and the single enforcement point (selene/src/offload.rs:165-167). - The plumbing:
PlannedHostBudgets::max_sequence_pages(memory.rs:32-36, filled:1595), passed atmodel.rs:1047-1053, acceptedmodel.rs:1125, forwarded intoPrepareInputs(model.rs:1167-1173); the duplicatedserver_config["max_sequence_tokens"]lookup inmodel.rsis genuinely gone. - The doc rewrite matches the diff (
docs/prefix-cache-offload.md:1593-1609) with the GLM-5.3-Flash TP4 11.0 GiB / 1,664 slot / 7.1 GiB example retained. - No unrelated tooling, no bundled feature surface, no scope expansion: none of closed #718's HTTP
X-Flare-Prefill-Only, scheduler anchoring, or Selene announce-barrier surface is carried, and capture remains single-host by construction. The charter non-goals (disaggregation, cluster orchestration, non-NVIDIA backends) are untouched. - Compile-consistency of the fixture story checks out: every
PrepareInputsliteral either setsmax_sequence_pagesor uses struct-update syntax from a base that does (helios/src/runtime_core/memory.rs:2070-2073,selene/src/offload/tests.rs:962-965), so the reported green runs are consistent with the tree.
Info / Nit (non-blocking, no action required)
- The 09:11 autobot review is stale relative to the head. Its merge-risk block is labelled "up to
02990da", quotes +115/−10, and its single Should-Fix (unguardeddiv_ceil/context == 0producingSome(0), which selene treated as uncapped) is closed at66d6af3:contextis filteredtokens > 0(helios/src/runtime_core/memory.rs:993-996), the bound isNonZeroU64::new(context.div_ceil(...))(:998-1000), and selene's match is the singlemap_or(pages, |limit| pages.min(limit.get()))(selene/src/offload.rs:165-167) with nolimit > 0arm. That should-fix should not be carried forward against this head. - Base-label drift in the PR body. The body reports the six-crate runs against base
f46a99220a;mainhas since fast-forwarded (#713), addingLinuxMemInfo/append_integrated_meminforoughly 160 lines above these hunks.PlannedHostBudgets(memory.rs:32-36) andcapture_growthare unaffected onmain, so the rebase is mechanical. A stale base label with no reported failure is not a gate item. - Doc sentence neighbouring the new ceiling.
docs/prefix-cache-offload.md:1605-1606still says a capture with no resident ancestor "copies the full GPU chain", two sentences below the new ceiling at:1595-1597. Behaviour is safe (an over-long chain is dropped rather than overrunning the slab), so this is prose precision only, and the paragraph was rewritten rather than newly authored. - Charter authorization is a maintainer judgement call, not a violation.
AGENTS.md:165-166accepts a contribution addressing "an explicit maintainer request, a demonstrated defect, a measured performance or memory problem, or inaccurate documentation". This PR supplies a live memory trace and a reproducible startup failure mode, which lands inside that list; the fact that yatesdr's #455 review asked only for documentation (with the runtime cap being the author's extrapolation, no issue filed, and no organic demand — searches forhost budget cannot hold a full pool capturereturn only #455, #497, #718, #737, #742) is a scoping call for the merging maintainer, not a breach of any hard gate. - Security / process. No obfuscation, injection attempt, external network or secret access, or attempt to direct reviewer behaviour appears in the diff or the PR conversation.
Explicitly not flagged (per calibration)
- No CI is observable on the head; the PR claims no failure and reports runs covering every crate the native-serving workflow tests, so absence of observable check runs is not reported.
- No
docs/TODO.txtbookkeeping ask; no PR-description phrasing nit as a gate item. - The
#737overlap and the deliberately uncappedintake_slotsfloor (selene/src/offload.rs:178-180, now stated in the doc at:1594-1597and in the PR body) are design/sizing matters for the correctness and value lenses, disclosed rather than concealed — out of scope for this governance gate.
Conclusion: the diff satisfies every hard contract boundary, is vendored/pinned clean, carries the Layer 1 verification the testing hierarchy mandates for a startup-only sizing change with no Layer 3 trigger, and contains no material scope or claim contradiction. The only residual items are the merge-order note for #737 and prose/label housekeeping.
Subtraction and simplicity
Subtraction & Simplicity Audit — PR #742 (selene,helios: bound pool-only capture buffer to max_sequence_pages), head 66d6af3
Verdict: the diff is essentially lean. +94/−21 across 9 files, of which only +9/−1 is real logic (selene/src/offload.rs:164-168) and +32/−1 is planning plumbing (helios/src/runtime_core/memory.rs); the rest is one doc paragraph and 8 test-fixture lines. No new CLI flags, no new config knobs, no new wire/core-format surface, no new environment variables. The change is a clamp, not a feature, and the author kept it that way. The findings below are all local: a duplicated formula the PR now leans on harder, one clamp expression copied three times, one unreachable validation branch, and one optional that no production caller sets.
1. High value — duplicated minimum-page formula, now load-bearing in two places
The same default page floor is computed independently in two functions in the same file, and this PR's first-pass charge (helios/src/runtime_core/memory.rs:1136) now hands the second copy's result into the first copy's consumer:
helios/src/runtime_core/memory.rs:704-706 (inside capacities):
let minimum_pages = page_limit.map_or(active * 8192u64.div_ceil(page_tokens), |limit| {
limit.minimum
});
helios/src/runtime_core/memory.rs:1001 (inside allocate_caches):
let minimum_pages = ceiling.map_or(active as u64 * 8192u64.div_ceil(page_tokens), |limit| limit.minimum);
Two identical 8192u64.div_ceil(page_tokens) floors with two subtly different active types (u64 vs as u64), one of which is charged as "the reserved capture floor" at :1136 (capture.then_some(minimum_pages)) and then re-derived from scratch at :704 during the binary search. Extract fn minimum_pages(page_limit: Option<PageLimit>, active: u64, page_tokens: u64) -> u64 and call it from both — it deletes the second literal, removes the as u64/u64 drift, and makes it impossible for the reserved floor and the searched floor to disagree (which is exactly the failure class this PR exists to prevent for max_sequence_pages).
2. High value — the cap expression pages.min(max_sequence_pages.get()) is copy-pasted three times in production and three times in tests
helios/src/runtime_core/memory.rs:1490:capture_growth(layout, pages.min(max_sequence_pages.get()), tier_host, host_growth, shared)helios/src/runtime_core/memory.rs:1556-1559:.min(max_sequence_pages.get())+layout.row_slots()+* layout.page_record_bytesselene/src/offload.rs:165-168:.map_or(pages, |limit| pages.min(limit.get()))- Test copies:
helios/src/runtime_core/memory.rs:2453,:2460, andselene/src/offload/tests.rs:556.
Note that memory.rs:1556-1559 is arithmetically the same expression as the body of capture_growth (memory.rs:668-682: slots = pages.checked_add(layout.row_slots()), slots * layout.page_record_bytes), just without the reserved subtraction. Add fn capture_slots(layout: &Layout, pages: u64) -> u64 returning (pages + row_slots) * page_record_bytes, and give memory.rs a one-line local let chain_pages = pages.min(max_sequence_pages.get()); before :1490 — that is 3 sites → 2, and removes one hand-rolled copy of capture_growth's arithmetic that can silently drift from it.
3. Medium value — the second context validation is unreachable (dead error branch)
helios/src/runtime_core/memory.rs:993-1000:
let context = self.server_config["max_sequence_tokens"]
.as_u64()
.filter(|&tokens| tokens > 0)
.ok_or_else(|| invalid("model requires a prepared context ceiling"))?;
let ceiling = page_ceiling(options.kv_cache_limit, context, active as u64, &contract)?;
let max_sequence_pages =
std::num::NonZeroU64::new(context.div_ceil(contract.cache.page_tokens as u64))
.ok_or_else(|| invalid("model requires a positive prepared context ceiling"))?;
context > 0 is guaranteed by :995, page_tokens != 0 is guaranteed by :896-899 (.filter(|&tokens| tokens != 0)) and by PreparedContract::validate (helios/src/model/contract.rs:536), so div_ceil ≥ 1 always and the "model requires a positive prepared context ceiling" string can never be produced. It is a second user-facing error message for a state the preceding line already rejected. Drop the .ok_or_else and merge the two checks into one, e.g. keep the filter(|&tokens| tokens > 0) and write NonZeroU64::new(context.div_ceil(page_tokens)) with the invariant stated in a comment — saves 3 lines and one unreachable message that would otherwise confuse future readers into thinking a zero-page ceiling is reachable.
4. Medium value — Option<NonZeroU64> is speculative generality: no production caller ever passes None
helios/src/runtime_core/model.rs:1125:
max_sequence_pages: Option<std::num::NonZeroU64>,
The single production call site passes Some(planned.max_sequence_pages) (model.rs:1052) and every other call site in the repo is a test passing None (model.rs:1562, :1574). The Option then propagates into selene/src/offload.rs:345 and forces the map_or at offload.rs:165-167 plus the if max_sequence_pages.is_some() branch in selene/src/offload/tests.rs:558-560.
Two clean options, in order of preference:
- Make
prepare_offloadtakeNonZeroU64(notOption): the parameter is private, both tests already passNoneonly because the type invites it, and it deletes theOptionfrommodel.rs:1052/:1125.PrepareInputs::max_sequence_pagescan stay optional for library callers — theOptionthen exists in exactly one place instead of two. - If the
Nonesemantic ("unbounded") must survive inPrepareInputs, say so where it costs nothing: the doc atoffload.rs:342-345explainsSome, never says whatNonemeans or which caller uses it.
Whatever the choice, the 8 fixture lines (helios/src/offload/pool/tests.rs:134, selene-manager/tests/client.rs:3255, :3509, selene-manager/tests/offload.rs:139, selene/src/offload/sharded/tests.rs:118, :261, :392, :558, plus selene/src/offload/tests.rs:14, :51, helios/src/runtime_core/memory.rs:2036) are pure churn caused by the optional; a non-optional bound on the private path removes half of them.
5. Low value — the doc paragraph states the same bound twice, and one sentence now contradicts it
docs/prefix-cache-offload.md:1593-1602 says the ceiling three times:
:1594-1597— "one full single-sequence capture chain (min(GPU page capacity, ceil(max_sequence_tokens / page_tokens))plus one row's slots), bounded by the host budget.":1599-1600— "Helios limits GPU page capacity so one sequence chain plus one row fits the host budget.":1601-1602— "If even the capped minimum page capacity plus one row does not fit …"
(2) restates (1) with no new information. And :1605-1606 still reads "If a capture has no resident ancestor, it copies the full GPU chain" — two sentences below the new ceiling, the same "unbounded KV" reading the ceiling was added to correct. Delete sentence (2) and qualify (3) with "capped chain", then change :1605-1606 to "copies the whole sequence chain (at most the ceiling above)". Net −2 lines and the paragraph stops arguing with itself.
6. Nits
- Fully-qualified
std::num::NonZeroU64spelled out 3× in a ~100-line span:helios/src/runtime_core/memory.rs:34,:999,helios/src/runtime_core/model.rs:1125. The crate's own style imports the type (helios/src/runtime_core/persistent_worker.rs:10(not opened):use std::num::NonZeroU32;;flare-cli/src/cli.rs:10(not opened)). Oneuseper file is shorter and matches precedent. - Constant expression in a test:
helios/src/runtime_core/memory.rs:2453:capture_growth(&layout, 512u64.min(max_sequence_pages), reserved, 0, 1)withmax_sequence_pages = 128on the line above — this is128written as a two-operand expression that re-enacts the clamp under test. Passmax_sequence_pagesdirectly so the assertion reads as "the capped chain costs nothing extra". - Test re-derives the production clamp:
selene/src/offload/tests.rs:556copiesmax_sequence_pages.map_or(pages, |limit| pages.min(limit.get()))verbatim fromselene/src/offload.rs:165-167. It already had to be edited in lockstep in this PR. Exporting the clamp as a tinypub(crate)helper (finding 2) lets the test assert against the real implementation instead of a transcript of it.
Confirmed lean (checked, no action)
- No new flags/knobs: the only user-visible surface is prose in
docs/prefix-cache-offload.md;PrepareInputsis internal Rust API;page_ceiling,KvCacheLimit,--prefix-cache-memoryare untouched. - No dead branches introduced beyond finding 3: every clamp only shrinks the charge, and
offload.rs:175-177's admission test now runs against the capped value — one code path, not two. PlannedHostBudgets::max_sequence_pagesis justified, not speculative: it replaces the secondserver_config["max_sequence_tokens"]lookup that would otherwise live inmodel.rs, so planning and attach cannot diverge. This is the right kind of subtraction-adjacent change — one value, one owner.PrepareInputs { .. }destructuring (selene/src/offload.rs:622-628) correctly avoids re-listing future fields; keep it.- Fixtures in
selene-manager/shardedtests are unavoidable one-liners for a new struct field on a pub type; only half are removable via finding 4.
Code correctness
Deep Code Correctness / Invariants / Hot-Path Audit — PR #742 (selene,helios: bound pool-only capture buffer to max_sequence_pages), head 66d6af3
PR size: 9 files, ~90 changed lines, 3 crates (selene, helios, selene-manager tests only) — under the >12 files / >900 LOC partitioning threshold, so I audited directly with batched reads instead of spawning sub-agents.
Verdict
No Blocker, no Major, and no hot-path complexity defect found. The changed logic is arithmetically sound: the new bound cannot under-size the capture buffer relative to any real capture chain, it cannot throttle GPU KV pages, and it does not break the sub-100-LOC hot path (it is one min per fits probe, O(1)). Two Minor defects are verified below: a guard that can never fire (with an unguarded division next to it that panics where the author intended an error), and a max() term that is provably a no-op (dead expression) in planned_offload_host.
Invariants I verified (all hold)
- The cap cannot under-size a real chain. A captured record's page count is the logical prefix length in pages.
helium/src/scheduler.rs:2098-2101(not opened) computeschain_pages: self.cache.page_chain(id)/tail_pages: (consumed_tokens / page_tokens - parent.consumed_tokens / page_tokens), so full chain pages =consumed_tokens / page_tokens;helios/src/model/catalog.rs:46-55enforcesmax_sequence_tokens <= prepared_sequence_tokens,max_sequence_tokens.is_multiple_of(page_tokens),page_tokens != 0, andhelios/src/model.rs:268-272(fit_context) only lowers the runtime ceiling, sochain_pages <= max_sequence_tokens / page_tokens = max_sequence_pagesexactly (thediv_ceilatmemory.rs:999is exact, not over/under-shooting). - Planning and attach cannot diverge.
memory.rs:1593-1597returnsPlannedHostBudgets { offload_host, max_sequence_pages, .. };model.rs:1047-1053passesSome(planned.max_sequence_pages)intoprepare_offload, which threads it verbatim intoPrepareInputs { max_sequence_pages, .. }(model.rs:1167-1173) down toselene/src/offload.rs:703-709→headroom_inner, which applies the identicalpages.min(limit.get())formula (offload.rs:165-170). No second caller in production code exists (search_code PrepareInputs\\s*\\{: onlymemory.rs:1129,model.rs:1167, plus test fixtures). - Budget accounting stays conservative.
capture_growth(layout, pages.min(max_seq), tier_host, host_growth, shared)(memory.rs:1490) uses the same clamp asheadroom_inner, so the host byte reservation and the host byte consumption agree;reserved = tier_hostalready contains theintake_slotsfloor, sosaturating_sub(reserved)can only under-stateextra, never over-state (ahost_freeshortfall fails closed withNone). intake_slotsfloor genuinely preserved (offload.rs:178-180:chain.max(intake_slots(layout, inputs.max_active)).min(budget)), so concurrent transfer windows are not starved — matching the PR's stated intent.- The new helios test does discriminate.
pool_capture_growth_caps_at_max_sequence_pages_without_throttling_gpu_pages(memory.rs:2446-2464) is not tautological: withhost_free = 0andreserved = (128 + row_slots) * page_record_bytes, removing.min(max_sequence_pages)makescapture_growthreturnNoneforpages > 128, the binary search (memory.rs:776-784) converges to 128, andassert!(pages > max_sequence_pages)fails. Doubling the cap to 256 also failsassert_eq!(pages, uncapped_pages)(uncapped = 1024, not 256). Good counterexample coverage.
Finding 1 — Minor: new error branch is unreachable, and the reachable path divides by a possibly-zero page_tokens (panic instead of the intended error)
Diff site: helios/src/runtime_core/memory.rs:993-1000
let context = self.server_config["max_sequence_tokens"]
.as_u64()
.filter(|&tokens| tokens > 0)
.ok_or_else(|| invalid("model requires a prepared context ceiling"))?;
let ceiling = page_ceiling(options.kv_cache_limit, context, active as u64, &contract)?;
let max_sequence_pages =
std::num::NonZeroU64::new(context.div_ceil(contract.cache.page_tokens as u64))
.ok_or_else(|| invalid("model requires a positive prepared context ceiling"))?;
Callee resolution (never assume):
page_ceiling(memory.rs:562-609) returns before validating the page size when the limit mode is the defaultMemory:
(if mode == KvCacheLimit::Memory { return Ok(None); } if context == 0 || contract.cache.page_tokens == 0 { return Err(invalid("KV cache limit requires a positive context and page size")); }KvCacheLimit::Memoryis the documented default:memory.rs:1526-1528options.memory_limit.unwrap_or(...)pattern andmemory.rs:1541-1543KvCacheLimit::Memory => {}.)contextis already> 0(line 995).page_tokensthere iscontract.cache.page_tokens: usize(definitionhelios/src/model/contract.rsPageTableView-adjacentCacheContract, andcontract.validatecontract.rs:536rejectspage_tokens == 0— but that validation is not re-run on this deserialized copy:memory.rs:900-902only doesserde_json::from_value).
Two concrete defects, same three lines:
- Unsatisfiable guard / dead error. With
context >= 1andpage_tokens >= 1,u64::div_ceilreturns>= 1, soNonZeroU64::new(...)is neverNone. Error message"model requires a positive prepared context ceiling"is unreachable code. Counterexample:max_sequence_tokens = 1,page_tokens = 8192→1.div_ceil(8192) = 1→Some(1). - Unguarded divisor on the reachable path. Under the default
--kv-cache-limit memory,page_ceilingreturnsOk(None)at line 568-570 and never checkspage_tokens. Counterexample:server_config["model_contract"].cache.page_tokens = 0,max_sequence_tokens = 1024→ line 999 executes1024u64.div_ceil(0)→attempt to divide by zeropanic during model startup, where the surrounding code style (and the author's own new.ok_or_else) clearly intends a recoverableinvalid(...)error. Note this is a new panic site: before this PR nothing divided bycontract.cache.page_tokenson theMemory-mode path (page_ceilingused it only after its zero check).
Fix (validate the divisor itself, and drop the impossible NonZeroU64 failure):
let page_tokens = std::num::NonZeroU64::new(contract.cache.page_tokens as u64)
.ok_or_else(|| invalid("model requires a prepared context ceiling and page size"))?;
let max_sequence_pages = std::num::NonZeroU64::new(context.div_ceil(page_tokens.get()))
.expect("positive context over a positive page size is at least one page");
(or hoist a single if context == 0 || contract.cache.page_tokens == 0 { return Err(...) } above page_ceiling and keep NonZeroU64::new(..).expect(..)).
Side note (not a defect, recorded for completeness): the added .filter(|&tokens| tokens > 0) means a 0 ceiling under KvCacheLimit::Context|Concurrency now reports "model requires a prepared context ceiling" instead of page_ceiling's "KV cache limit requires a positive context and page size". Both are clean startup errors; only the message changes.
Finding 2 — Minor: pages.min(max_sequence_pages.get()) in planned_offload_host is provably a no-op (dead expression), so it neither bounds what it appears to bound nor can detect divergence
Diff site: helios/src/runtime_core/memory.rs:1554-1560
let planned_offload_host = if capture {
let layout = capture_layout.as_ref().unwrap();
let chain_bytes = pages
.min(max_sequence_pages.get())
.saturating_add(layout.row_slots() as u64)
.saturating_mul(layout.page_record_bytes);
Some(tier_host.max(chain_bytes))
Proof of no-op. tier_host is the second tuple element returned by headroom_with_inputs_for_budget (memory.rs:1126-1138), i.e. offload.rs:199-220:
let intake = ...; // slots after .max(intake_slots(..)).min(budget)
let host = memory.checked_add(intake)?; // memory == 0 in pool-only capture
Ok((tiers + pool, host))
and in the pool-only branch chain = min(local_pages, max_sequence_pages) + row_slots (offload.rs:164-180) where local_pages = capture.then_some(minimum_pages) (memory.rs:1136). Also capture_growth during the search raises the reservation to min(pages, max_seq) + row_slots records whenever that exceeds tier_host, and capacities guarantees pages >= minimum_pages (memory.rs:776 let (mut low, mut high) = (minimum_pages, maximum_pages);, returned as the second element and only ever min-reduced by agree.caches to the same value across ranks). Therefore tier_host >= (min(minimum_pages,max_seq)+row_slots)*record >= chain_bytes always, so tier_host.max(chain_bytes) == tier_host in every reachable configuration. Counterexample check for the case the code seems designed for (minimum_pages = 10, max_sequence_pages = 1000, agreed pages = 500, intake_slots = 144): tier_host = 144*record while chain_bytes = 501*record — this looks like the max is doing work, but capture_growth would have returned None for pages = 500 (extra 357*record > host_free) and the search would have converged at 144 - row_slots, so pages = 500 is unreachable; pages is always <= minimum_pages or fully host-funded, and in the latter case tier_host already includes it (memory.rs:1485-1491).
Why it matters: the expression advertises a bound on planned_offload_host that it does not enforce (the real bound is enforced inside capture_growth and inside headroom_inner), and because it is a no-op it would silently mask a future divergence between the GPU-page clamp in capture_growth and the attach-time sizing in selene::offload::headroom_inner — exactly the class of bug the PR says it is removing. It is also a second hand-written copy of the + row_slots / * page_record_bytes formula (offload.rs:168-170, memory.rs:675-676, memory.rs:1556-1559).
Fix: make the invariant explicit instead of redundant — either assert it,
let chain_bytes = pages.min(max_sequence_pages.get())
.saturating_add(layout.row_slots() as u64)
.saturating_mul(layout.page_record_bytes);
debug_assert!(chain_bytes <= tier_host, "attach-sized capture budget diverged from planning");
Some(tier_host)
or make selene the single owner by exposing the plan (flare_selene::offload::pool_capture_slots(layout, chain_pages, max_active)) and calling it from both headroom_inner and capture_growth/planned_offload_host.
Hot-path / complexity check (protocol part 4) — clean
The only per-iteration change is pages.min(max_sequence_pages.get()) inside the fits closure (memory.rs:1485-1491), evaluated O(log(maximum_pages)) times (≈ 17 probes for 150k pages, memory.rs:776-784) — O(1), no allocation. capture_growth remains allocation-free (checked_add/checked_mul/div_ceil only). max_sequence_pages is computed once per startup (memory.rs:998), not per step/request/victim. upstream: None in PrepareInputs keeps Copy semantics, so headroom_with_inputs(.., inputs, ..) callers (offload.rs:133, 147, 703-709, 1063-1120 test fixtures) pass it by value with no clone; adding a NonZeroU64 does not change the struct's Copy-ness or size class materially. No new Vec/HashMap anywhere in the diff.
Nothing found in these areas (checked, clean)
docs/prefix-cache-offload.md(+15/−12) — documentation only; wording accuracy (e.g. the buffer being one full chain vs. theintake_slots/minimum_pagesfloor) is explicitly out of my scope.selene/src/offload.rs:622-628destructuring with..— forward-compatible, andmax_sequence_pagesis consumed through the still-passedinputsvalue at lines 703-709, so the field is not silently dropped.- All test-fixture updates (
helios/src/offload/pool/tests.rs:134,selene-manager/tests/client.rs:3255,3509,selene-manager/tests/offload.rs:139,selene/src/offload/sharded/tests.rs:118,261,392,558,selene/src/offload/tests.rs:14,51) setmax_sequence_pages: None, whichmap_or(pages, ..)(offload.rs:167) treats as uncapped — identical to pre-PR behavior, so no test silently changes meaning. selene/src/offload/tests.rs:531-574: the(512, NonZeroU64::new(64))case yieldschain = 66,intake_slots(layout,4) = 144, soslots = 144 < 514— the assertion at line 558-560 is meaningful (removing the cap yields 514 and fails it), and theheadroom_with_inputscross-check at 569-574 recomputes the same formula independently of the implementation under test.- No state-machine, refcount/pin/unpin, or retirement/eviction ordering was touched by this diff (
selene/src/memory.rs,composite.rs(not opened),disk_store.rs(not opened) are unmodified), so protocol part 2 (same-loop flag read-before-write) has no new surface here.
Full report Merge Risk: medium_high (99%): Medium or high merge risk (core runtime/scheduler/GPU/CUDA/VMM/RoCE/multi-rank/contracts/ABI, large multi-crate changes, or Blocker/Major findings) — route to Super Agent.
Re-review
Recommendation: Changes Requested
Commit 66d6af3 cleanly resolved most of Round 1's feedback: max_sequence_pages: NonZeroU64 is now threaded through PlannedHostBudgets into NativeModel::prepare_offload (eliminating the duplicate lookup and model.rs None fallback), max_sequence_tokens == 0 is rejected in memory.rs, PrepareInputs::max_sequence_pages uses Option<NonZeroU64> with a single clamp in headroom_inner, and the tests and docs were tightened. However, one half of Round 1's Should Fix remains unfixed: helios/src/runtime_core/memory.rs:999 still calls context.div_ceil(contract.cache.page_tokens as u64) without guarding contract.cache.page_tokens == 0 (panicking on division by zero under default KvCacheLimit::Memory before PreparedContract::validate ever runs), and the new .ok_or_else(...) at :1000 is unreachable dead code. A 2-line non-zero check on contract.cache.page_tokens before div_ceil will make this ready to merge.
Merge Risk
Level: Low
- Small, localized startup-only change (+94/−21 across 9 files) with no CLI/config/wire/core-format surface and no hot-path runtime impact.
- Strictly relaxes pool-only host-budget sizing on single-process deployments (
--prefix-cache-pool --prefix-cache-memory 0, no disk tier); deployments with local memory/disk tiers and multi-host sharded ranks are unaffected. - Overlaps adjacent host-budget code in open PR #737 (
helios/src/runtime_core/memory.rs,model.rs,selene/src/offload.rs), requiring only routine rebase coordination if #737 merges first.
Walkthrough
selene/src/offload.rs: Addspub max_sequence_pages: Option<std::num::NonZeroU64>toPrepareInputs(:342-345), clampschain_pagesinheadroom_innerviainputs.max_sequence_pages.map_or(pages, |limit| pages.min(limit.get()))(:165-167), and destructures with..inprepare_with_inputs_budget_with_progress(:627) while forwardinginputsintoheadroom_inner(:703-709).helios/src/runtime_core/memory.rs: Addsmax_sequence_pages: std::num::NonZeroU64toPlannedHostBudgets(:34, :1595), rejectsmax_sequence_tokens == 0(:993-996), computesmax_sequence_pages(:998-1000), passesSome(max_sequence_pages)into initialheadroom_with_inputs_for_budget(:1134) without double-clampingminimum_pages(:1136), and clampspages.min(max_sequence_pages.get())incapture_growth(:1490) andplanned_offload_host(:1556-1560).helios/src/runtime_core/model.rs: ThreadsSome(planned.max_sequence_pages)fromallocate_cachesintoprepare_offload(:1047-1053, :1125) and directly intoPrepareInputs(:1167-1173), removing the duplicatedserver_config["max_sequence_tokens"]derivation.docs/prefix-cache-offload.md: Updates the pool-only capture buffer section (:1593-1609) to document the single-sequence ceilingmin(GPU page capacity, ceil(max_sequence_tokens / page_tokens))and capped minimum-capacity startup failure behavior, reflowed to ~79 columns.- Tests (
selene/src/offload/tests.rs,helios/src/runtime_core/memory.rs, and existing test fixtures): Folds(512, NonZeroU64::new(64))intopool_only_sizes_registered_capture_and_headroom_for_local_ranks(selene/src/offload/tests.rs:531-576), addspool_capture_growth_caps_at_max_sequence_pages_without_throttling_gpu_pagesassertingpages == uncapped_pages(memory.rs:2446-2465), and addsmax_sequence_pages: Noneacross existingPrepareInputs/prepare_offloadtest fixtures.
Pre-merge Checks
- [PASS] Security / malicious screen: No obfuscation, prompt injection, external network/secret access, or suspicious code paths.
- [PASS] Charter & value fit: Model-agnostic fix for a measured host-memory issue on target SM120/SM121 workstation hardware under the Selene prefix-cache offload goal; carries none of closed #718's out-of-scope surface.
- [PASS] Related / duplicate / conflict check: Not a duplicate; carves out only the #455 pool-only capture bound from closed #718. Already rebased onto
012219a1(#713); only minor adjacent overlap with open PR #737. - [WARN] Tests & verification evidence: Author reports all six workspace crates passing in
--locked --releaseon66d6af3; live RSS measurements (18.74–19.06 GiBvs7.83–8.04 GiB) come from av0.6.0(f705086) build running the same rule, and CUDA/integration/Windows/formal suites were not run on head (all transparently disclosed).
Blockers
None.
Should Fix
- Unfixed half of Round 1 Should Fix #1:
div_ceil(contract.cache.page_tokens as u64)still panics on zerocontract.cache.page_tokens, and the newNonZeroU64::new(...).ok_or_else(...)branch is dead code (helios/src/runtime_core/memory.rs:993-1000)- Verified behavior: In
allocate_caches(memory.rs:884),memory.rs:896-899validatesself.server_config["page_tokens"] != 0, notcontract.cache.page_tokens.contractis deserialized fromself.server_config["model_contract"]atmemory.rs:900-902without callingPreparedContract::validate(), andNativeModel::load_agreeingrunsallocate_caches(flare-cli/src/main.rs:323->model.rs:1038) beforeModelConfig::from_server_config/PreparedContract::validate(helios/src/model/contract.rs:536), whileprotobuf::serving_contract(helios/src/runtime_core/protobuf.rs:75-89) does not validatecontract.cache.page_tokens. Under the defaultKvCacheLimit::Memorymode,page_ceilingreturnsOk(None)immediately atmemory.rs:568-570before itscontract.cache.page_tokens == 0check at:571. Consequently:- If
contract.cache.page_tokens == 0, line999executescontext.div_ceil(0)unconditionally on every model load (even with offload disabled) and panics withattempt to divide by zerobeforeNonZeroU64::newis called — regressingmain, which returnedErr(invalid(...))viacache_geometry->CacheGeometry::validate()(memory.rs:1024,1890). - Because
context > 0is already enforced atmemory.rs:995andu64::div_ceilon a positive dividend with any positive divisor is always>= 1,.ok_or_else(|| invalid("model requires a positive prepared context ceiling"))?atmemory.rs:1000is unsatisfiable dead code.
- If
- Fix: Validate
contract.cache.page_tokensas non-zero before callingdiv_ceiland replace the dead.ok_or_elsewith.expect(...):let logical_page_tokens = std::num::NonZeroU64::new(contract.cache.page_tokens as u64) .ok_or_else(|| invalid("model requires a positive cache page size"))?; let max_sequence_pages = std::num::NonZeroU64::new(context.div_ceil(logical_page_tokens.get())) .expect("positive context divided by positive page size is non-zero");
- Verified behavior: In
Subtract / Simplify
- Take
NonZeroU64(instead ofOption<NonZeroU64>) in privateNativeModel::prepare_offload(helios/src/runtime_core/model.rs:1052,1125,1172):prepare_offloadis private (unsafe fn), its sole production call site passesSome(planned.max_sequence_pages), and only the two early-returning unit tests (model.rs:1562,1574) passNone. KeepingOption<NonZeroU64>only onPrepareInputs(for library callers) avoids redundantOptionwrapping at the private Helios boundary.
Nits
helios/src/runtime_core/memory.rs:34,999andhelios/src/runtime_core/model.rs:1125: Ause std::num::NonZeroU64;import matches crate convention and avoids repeating the full path.helios/src/runtime_core/memory.rs:2453:512u64.min(max_sequence_pages)withmax_sequence_pages = 128evaluates tomax_sequence_pagesdirectly; passingmax_sequence_pages(or assertingcapture_growth(&layout, 512, reserved, 0, 1).is_none()alongside the clamped call) makes the test intent sharper.
Dropped on verification
- Upstream Code Correctness F2 ("
pages.min(max_sequence_pages.get())inplanned_offload_hostatmemory.rs:1554-1560is a provable no-op; replaceSome(tier_host.max(chain_bytes))withSome(tier_host)"): Verified false (and applying its suggested fix would break pool-only startup).tier_hostis an immutableu64computed once atmemory.rs:1126-1138fromminimum_pages(capture.then_some(minimum_pages)) and is never mutated bycapture_growth. Whenever host RAM letscapacities()(memory.rs:1478-1492) selectpages > minimum_pages(e.g.minimum_pages = 512,max_sequence_pages = 16,384,pages = 99,008,intake_slots = 144,row_slots = 2),chain_bytes = (16,384 + 2) * page_record_bytes >> tier_host = (512 + 2) * page_record_bytes. PassingSome(tier_host)asplanned_host_budgettoprepare_offload->headroom_innerwould fail startup withhost budget cannot hold a full pool capture. - Upstream Discovery Dossier Amendment 3, Gates Audit Nit 1, and Subtraction Item 3 ("Round 1 Should Fix is closed" / "
page_tokens != 0is guaranteed bymemory.rs:896-899"): Verified false.memory.rs:896-899checksself.server_config["page_tokens"], notcontract.cache.page_tokens, andPreparedContract::validatedoes not run until afterNativeModel::load_agreeingreturns. - Upstream Discovery Dossier Amendment 7 & Gates Audit Nit 2 ("Base drift: branch is still on pre-
#713f46a9922and needs rebase onto012219a1"): Verified false on the branch history:66d6af33is already directly on top of012219a1(LinuxMemInfois present atmemory.rs:1568); only the PR description text still citesf46a99220a(not a review issue). - Upstream Subtraction Items 1, 2, 5 (extracting pre-existing
minimum_pageshelper; adding acapture_slotshelper / sharedchain_pageslocal; editingdocs/prefix-cache-offload.md:1605-1606): Dropped as out-of-scope refactoring on Round 2+ (minimum_pagesduplication at:704/:1001is pre-existing;pagesat:1490and:1556are distinct variables in different scopes and a newLayoutbyte/slot helper was already dropped in Round 1; "copies the full GPU chain" at:1605-1606accurately describes a single sequence's chain). - Upstream process/evidence escalations (unobservable CI runs, non-head RSS telemetry provenance,
#737merge-order overlap): Non-blocking per review calibration; provenance and unrun checks are transparently disclosed and#737overlap is routine rebase coordination.
Classify triage
Selected: triage:review
Threshold: 65%
Triage
- [✓]
triage:review: 99.9% -
triage:design-review: 0.0% -
none: 0.0% -
triage:partial: 0.0% -
triage:validation: 0.0% -
triage:integration: 0.0% -
triage:investigate: 0.0% -
triage:verify-for-closure: 0.0% -
triage:superseded: 0.0%
Apply labels
No label changes Decision to Test: no (98%): 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. decide malicious: all_clear (100%): No malicious content found
explore
Author: fakoli (FIRST_TIME_CONTRIBUTOR; no prior merged work; Discord fakoli)
Motivation: In single-process pool-only mode a CPU-readable host buffer is registered to export prefix-cache checkpoints to selene-manager, and it was sized to the whole GPU KV page capacity plus one row, which reserved tens of GiB of host memory and could stop startup. This PR caps that chain at one maximum-length sequence, so the buffer no longer grows with the number of sequences the GPU could hold.
Scale: +105 / −21 in 9 files (single squashed commit f26d8a8b on base f46a9922) — amended; earlier this run it was +94/−21 at 66d6af3 and +115/−10 at 02990da.
Proposal:
- Add
pub max_sequence_pages: Option<NonZeroU64>to Selene's internalPrepareInputs(selene/src/offload.rs:342-345). - Clamp the pool-only capture chain once, in
headroom_inner:chain_pages = pages.min(limit.get())(offload.rs:165-167), feeding both slab sizing and thehost budget cannot hold a full pool captureadmission test (:175-177). - Compute the bound through a new guarded helper
max_sequence_pages(context, page_tokens) -> Result<NonZeroU64>(helios/src/runtime_core/memory.rs:562-569, called :1007) and thread it asPlannedHostBudgets::max_sequence_pages(:34) intoprepare_offload(model.rs:1047-1053), removing the duplicatedmax_sequence_tokenslookup. - Clamp
capture_growth(:1497) andplanned_offload_host(:1563-1566) the same way; leave the automatic-intake floor uncapped. - Document the ceiling in docs/prefix-cache-offload.md:1593-1609 and add tests at selene/src/offload/tests.rs:531-560 and memory.rs:2452-2476. Touches:
- helios/src/runtime_core/memory.rs — host-budget and KV-capacity planning, plus a new helper that now runs on every model load.
- selene/src/offload.rs — the single enforcement point for capture sizing and the startup admission failure.
- docs/prefix-cache-offload.md — section 2.15 sizing wording. Related items:
- #718 helios,selene,selene-manager: prefill-only KV handoff, announce barrier, bounded pool-only capture (closed): superseded by this PR for the sizing piece only; HTTP/routing/announce-barrier surface remains unlanded.
- #455 Capture single-process prefix checkpoints for the pool (merged): created the buffer; its 2026-11-21 review named the cost and asked for documentation.
- #737 async_transfer: DevToHost, dual-stream H2D, DEFER_TASKRUN, host-wide RAM budgeting (open): edits
async_transfer_host_ram/_total, which feed this buffer's bound; merge order matters. - #160 Roadmap question: prefill/decode disaggregation roles (closed): yatesdr ruled disaggregation out of design; author calls this PR the charter-aligned remnant.
- #713 release page cache with O_DIRECT peer serving (merged): included in the branch's base; the earlier "base drift" finding was withdrawn.
Link: https://github.com/NVIDIA/hyperflare-inference/pull/742
Autobot comments: The previous autobot review (09:51) is stale on arrival and reviews
66d6af3, not the current head; its only should-fix — an unguardeddiv_ceil(page_tokens)— is fixed atf26d8a8. The V0 guards say "0 blockers / 1 should fix / 1 subtract / 2 nits", but that is unsigned and reports the previous head. Both autobot merge-risk labels understate size. Notable gaps (per PR's own V0): the RSS comparison (18.74-19.06 GiB vs 7.83-8.04 GiB) is still the v0.6.0 build ([Draft]), not an A/B on head, no CI check is visible, and no maintainer has reviewed any head; the intake floor is still uncapped and unquantified in the impact table; the clamps can only shrink the host charge, so pool-only operators may see more GPU KV pages and startup succeeding where main failed — a user-visible direction the title omits.
Classify intake
Selected: triage:review, performance, area:memory, area:preparation, area:selene
Threshold: 65%
Triage
- [✓]
triage:review: 99.9% -
triage:design-review: 0.0% -
triage:validation: 0.0% -
none: 0.0% -
triage:integration: 0.0% -
triage:investigate: 0.0% -
triage:partial: 0.0% -
triage:verify-for-closure: 0.0% -
triage:superseded: 0.0%
Priority
-
none: 99.8% -
priority:P1: 0.2% -
priority:P2: 0.0%
Type
- [✓]
performance: 94.7% -
community: 43.8% -
enhancement: 43.8% -
bug: 20.2% -
duplicate: 16.5% -
documentation: 0.8%
Area
- [✓]
area:selene: 99.0% - [✓]
area:memory: 97.1% - [✓]
area:preparation: 88.1% -
area:caching: 8.5% -
area:rocenante: 0.2% -
area:scheduling: 0.2% -
area:kernels: 0.1% -
area:engram: 0.1% -
area:orbit: 0.0% -
area:api: 0.0% -
area:packaging: 0.0%
Model
-
model:qwen3.8-flash-next: 1.0% -
model:glm-5.3: 0.5% -
model:qwen3.8-27b: 0.1% -
model:gemma4: 0.1% -
model:muse-glimmer: 0.1% -
model:inkling-small: 0.1% -
model:kimi-k3.1: 0.1% -
model:nemotron-3.5-bolt: 0.1% -
model:deepseek-v4.1: 0.0% -
model:mimo-v2.6: 0.0% -
model:deepseek-v4: 0.0%
Apply Labels (Intake)
No label changes
Gates and contracts
Contracts, Charter & Verification Gates Audit — PR #742 (selene,helios: bound pool-only capture buffer to max_sequence_pages) @ f26d8a8
Verdict: No contract or verification gate blockers.
All four hard gates pass. The diff is 9 files, +105/−21 (pr_files: docs +15/−12, helios/src/runtime_core/memory.rs +43/−1, helios/src/runtime_core/model.rs +12/−3, selene/src/offload.rs +9/−1, selene/src/offload/tests.rs +18/−4, plus six single-line fixture insertions in helios/src/offload/pool/tests.rs, selene-manager/tests/{client,offload}.rs, selene/src/offload/sharded/tests.rs). Nothing in it adds or changes a signed core-format/wire/captured-graph contract, forks a vendored upstream file, triggers a formal or GPU-benchmark gate, or asserts a claim contradicted by the tree.
Gate 1 — Signed core-format / wire / captured-graph / public-contract boundaries: PASS
- No proto, core-format, graph-catalog, enum, or wire change. The diff touches no
.proto, nohelios/src/core/, noFORMAT_VERSION, no reserved identifier, no signature domain. Existing exported cores load unchanged: prepared metadata, allocation payloads, and graph catalogs are untouched, sodocs/design-review.md:116-120(principle 13, model-core compatibility) is not engaged. - No captured-graph operation contract.
docs/design-review.md:22-26requires owner approval for a new operation family; this PR adds no operation, shape/capacity variant, or graph kind. No approval is engaged and none is claimed. - The only API addition is internal and unpublished.
PrepareInputs::max_sequence_pages: Option<std::num::NonZeroU64>(selene/src/offload.rs:339-345) is a field on an internal Rust struct in a crate that is not published —selene/Cargo.toml:7publish = false,helios/Cargo.toml:7publish = false, matching the charter roadmap (#6, "the crates aren't published yet"). No CLI flag, config key, environment variable, or default changes, sodocs/design-review.md:89-92(principle 10) and the charter's "no magic defaults / no per-model flags" rule are respected. - No per-model branch or policy flag. The bound derives from prepared structural metadata (
max_sequence_tokens,contract.cache.page_tokens), not model identity —docs/design-review.md:47-61(principle 3) satisfied. Scope is narrow by construction: capture requirespool_only() && self.cluster().is_none()(helios/src/runtime_core/memory.rs:1009) andshard.is_none()(selene/src/offload.rs:163). - The one normative doc that specifies this buffer is updated in place.
docs/prefix-cache-offload.md:1593-1609now states the ceilingmin(GPU page capacity, ceil(max_sequence_tokens / page_tokens))plus one row's slots, bounded by the host budget, and the capped startup-failure condition (:1601-1602). Adjacent normative statements remain true and are not contradicted:docs/core-design.md:293-296(not opened) ("shared CPU/GPU DRAM is one budget") — the accounting rule is unchanged; only the size charged into that budget shrinks.docs/runtime-core-design.md:732-738("deduct the pinned host reservation from prefix-cache capture growth") — still exactly whatcapture_growthdoes, with a clampedpages(memory.rs:1494-1497).docs/core-format-design.md— grep forcapture|host budget|max_sequence_tokensreturns only unrelated capture-device/capture-storage prose (lines 13, 87, 110-112, 337, 418, 448, 819, 843); nothing about this host buffer.docs/scheduling-theory.mdanddocs/scheduling-runtime-design.md— searches forcapture buffer/host budget/pool-only/page capacity/offload/prefix cache/intakereturn no matches. There is no normative statement to contradict.
- No hidden validation removal. The admission error
host budget cannot hold a full pool captureis retained (selene/src/offload.rs:175-177, still the only definition —grepreturnsoffload.rs:176and the doc linedocs/prefix-cache-offload.md:1602), now applied to the capped chain.AGENTS.md:182-187("reject weakened guarantees ... do not remove validation") is not violated; the PR adds validation (max_sequence_pages(context, page_tokens)athelios/src/runtime_core/memory.rs:562-569rejects zero page size and zero context, and it is called unconditionally at:1007, i.e. every model load).
Gate 2 — Vendored upstream dependencies & cross-PR coupling: PASS
- No vendored upstream file is forked.
helios/native/,selene-manager/docs/, and all vendored C /build.rs(not opened) inputs are untouched. There is noCargo.tomlorCargo.lockchange in the diff, so dependencies remain pinned exactly as onmain(charter #215). - No unmerged external recipe or PR dependency. The change is self-contained in-repo; the eight
max_sequence_pages: Nonefixture insertions preserve every existing caller's behaviour (None⇒ uncapped,selene/src/offload.rs:165-167). - Info / Nit — merge order with open #737 (lukealonso).
related_itemsconfirms #737 shares exactly three files (helios/src/runtime_core/memory.rs,helios/src/runtime_core/model.rs,selene/src/offload.rs) and extendsPlannedHostBudgets; it can move the free-host bound this buffer is charged against. This is a sequencing hazard, not a gate violation, and no shared line is forked. Flagged at theInfo / Nitlevel only, per calibration. - Closed #718 shares all nine files, but it is closed/unlanded and this PR carries none of its HTTP/routing/announce-barrier surface — no dependency in either direction.
Gate 3 — Mandatory verification evidence & failing tests: PASS
- No failing test or failing CI is reported anywhere. The PR conversation (3 comments: author 09:19, author 09:49, autobot 09:51 — plus the case-file notice) contains no red check and no failing-test report. Both earlier autobot rounds say "Blockers: 0". Nothing in the description or the Discovery Dossier states a test or CI failure on
f26d8a8. - Layer 1 (
docs/design-review.md:180-194) is satisfied and correctly scoped. The PR reportscargo test --locked --releaseon the head foreos(12),selene --features test-support(649 = 648 unit + 1 doctest),selene-manager --features test-support(448, 1 ignored),helios --features runtime-core,server(2,041 passed, 88 ignored),flare(255),flare-cli(254, 3 ignored) underRUSTFLAGS="-D warnings"in a pinnedrust:1.94.1-slim-trixiecontainer. I verified this covers every crate the mandatory workflow executes:.github/workflows/native-serving.yml:47(not opened) (eos),:51-52(selene, selene-manager),:63(helios--features runtime-core,server),:73(flare-cli),:77(flare),:81(flare-winui/bridge, untouched).--locked --releaseis used;cargo checkis not substituted.heliopauseis not in that test list andgrepforPrepareInputs|headroom_with_inputs|prepare_with_inputsunderheliopause/returns no matches, so not running it is not a gap. - Layer 3 is not triggered (
docs/design-review.md:209-230). Its triggers are admission, fences, generations, cancellation, speculation accounting, cache compaction, snapshot aliases, response buffering/ownership, offload aggregation, readiness, rank coordination. The changed functions are startup host/KV sizing only:headroom_inner(selene/src/offload.rs:150-221),allocate_cachesplanning with itscapture_growth(memory.rs:677-691) /planned_offload_host(:1562-1568) callbacks, andprepare_offloadplumbing (helios/src/runtime_core/model.rs:1119-1179). Concretely:verification/helios-lifecycle/check.py:22-36declares nine checked protocols (Lifecycle, RankProtocol, DispatchRing, OffloadTransfer, CacheOwnership, Speculation, ResponseLifecycle, CheckpointReservation, AsyncTransfer).grepforruntime_core/memory.rs|offload.rs|runtime_core/model.rsunderverification/helios-lifecycle/returns no matches; the mutation targets listed atcheck.py:473-792touchscheduler.rs(not opened),scheduler/policy.rs(not opened),scheduler/cache_memory.rs(not opened),scheduler/checkpoints.rs(not opened),cache.rs(not opened),server/runtime.rs(not opened),offload/copy_gate.rs(not opened),offload/transfer.rs(not opened),execution/threaded{,.rs},async_transfer/scheduler.rs(not opened) — none of them this diff.- Kani:
#[cfg(kani)]modules exist only athelios/src/async_transfer/mod.rs:11(not opened),helios/src/execution/transport.rs:219(not opened),helios/src/model.rs:14(not opened),helios/src/model/contract.rs:15(not opened),helios/src/output/tagged.rs:1214(not opened).helios/src/runtime_core/has none. No completion-vector validation, prepared completion contract, state-view extent arithmetic, or sequential validator is touched. - No new protocol state or geometry bound is added, so
design-review.md:241-246("keep formal bounds aligned") does not apply. - Note
.github/workflows/helios-lifecycle.yml:3-11(not opened) does trigger onhelios/**,selene/**,selene-manager/**, so the lifecycle and Kani jobs are queued by CI regardless; the author's "not re-run because this PR does not modify … Kani-proven validators" is about relevance, not execution.
- The memory claim is a live trace, not an unattributable stacked speedup.
docs/verification.md:15requires "the target benchmark or live trace" for memory cost. The author suppliesdocker statscontainer RSS on identical Qwen4-35B-A3B hardware under a 24 GiB cgroup (18.74–19.06 GiB at--prefix-cache-memory 0vs 7.83–8.04 GiB at1G, delta 10.91–11.02 GiB matching the 11.8 vs 0.9 GiB slab delta) plus the startup log linepool only: capture buffer 11.8 GiB (16475 slots, …). It is not a performance speedup claim, so principle 12'smain-vs-branch served-workload A/B requirement (design-review.md:106-115) is not the applicable test; and the provenance is disclosed verbatim ("observed on av0.6.0(f705086) build running the samemax_sequence_pagessizing rule rather than re-measured via an A/B restart onf46a99220a"), together with an explicit "Unrun checks" list (hardware CUDA,tests/server/test_prefix_cache_offload.py(not opened),qualify/host_cache.py(not opened), integrated memory, sharded/RoCE, Windows, Kani, TLA+). That is the disclosureAGENTS.md:103-112and principle 12 require. Tightening it to an A/B on head is a maintainer judgement call, not a hard gate failure under the hierarchy as written. - Charter "bring real evidence" / four-part description. All four parts are present in order (why → what changed → claimed benefit → evidence), the bounded and unbounded formulas are distinguished with a metric table, and the required
Discord: fakoliline is present (AGENTS.md:142-153, principle 17). - Charter authorisation is satisfied on the
AGENTS.md:165-166test. The change addresses "a measured performance or memory problem" with a live trace and a reproducible startup failure (host budget cannot hold a full pool capture), which lands inside the accepted list. That yatesdr's #455 review asked only for documentation is a provenance nuance for the merging maintainer, not a gate breach.
Gate 4 — Material scope / claim contradictions: PASS
Every concrete artifact the description names exists on the head:
pool_only_sizes_registered_capture_and_headroom_for_local_rankswith the folded bounded/unbounded cases —selene/src/offload/tests.rs:525-576(loop cases(10, None),(512, None),(512, Some(64))at:531-535, strictly-smaller assertion at:558-560).pool_capture_growth_caps_at_max_sequence_pages_without_throttling_gpu_pages—helios/src/runtime_core/memory.rs:2453-2476, including the zero-input rejections (:2454-2455), the ceiling rounding1025/64 == 17(:2456),1_048_576/64 == 16_384(:2457), and the parity assertionspages == uncapped_pagesandpages > max_pages.- The clamps:
capture_growth(layout, pages.min(max_sequence_pages.get()), …)(memory.rs:1497), theplanned_offload_hostchain clamp (:1564), and the single enforcement point (selene/src/offload.rs:165-170). - The plumbing:
PlannedHostBudgets::max_sequence_pages(memory.rs:34, filled:1602), passedmodel.rs:1052, acceptedmodel.rs:1125, forwarded intoPrepareInputs(model.rs:1172); the duplicatedserver_config["max_sequence_tokens"]lookup inmodel.rsis genuinely gone (grep max_sequence_pagesshows nodiv_ceilinmodel.rs). - The guarded helper
fn max_sequence_pages(context: u64, page_tokens: usize) -> Result<NonZeroU64>—memory.rs:562-569, called at:1007right after the retained> 0filter onmax_sequence_tokens(:1002-1005). - Doc rewrite matches the diff with the GLM-5.3-Flash NVFP4 TP4 11.0 GiB / 1,664 slot / 7.1 GiB floor example retained (
docs/prefix-cache-offload.md:1598-1599). - No scope expansion. None of closed #718's HTTP
X-Flare-Prefill-Only, scheduler anchoring, or Selene announce-barrier surface is carried; capture remains single-host by construction. The charter non-goals (disaggregation, cluster orchestration, non-NVIDIA backends, multi-model hosting) are untouched. No unrelated tooling, no docs/TODO churn, no bundled standalone scripts. - Compile-consistency of the fixture story checks out: every
PrepareInputsliteral either setsmax_sequence_pagesor uses struct-update syntax from one that does (helios/src/runtime_core/memory.rs:2038-2044then:2077-2080;selene/src/offload/tests.rs:451-454,:962-965,:540-543), so the reported green runs are consistent with the tree.PrepareInputsderivesCopy, so adding aNonZeroU64option does not disturb the by-value call sites.
Info / Nit (non-blocking, no action required)
- Description wording, not code. The body says the bound is passed "into
headroom_with_inputs_for_budget(whereheadroom_innerclampsminimum_pages)". The code clampschain_pages(selene/src/offload.rs:165-170);minimum_pagesreaches selene unmodified aslocal_pages(memory.rs:1143). Cosmetic, and per calibration a PR-description phrasing nuance is not a gate item. - Doc sentence neighbouring the new ceiling.
docs/prefix-cache-offload.md:1605-1606still says a capture with no resident ancestor "copies the full GPU chain", two sentences below the new ceiling at:1595-1597. Behaviour is safe (an over-long chain drops rather than overrunning the slab) and the paragraph pre-dates this PR; prose precision only. - Base label.
search_historyatmainreturnsf46a9922as the tip, which matches the body's "basef46a99220a" — the branch sits on the current main tip, so there is no base-drift issue.memory.rsat head is 3046 lines vs main's 3004, a +42 net consistent with this PR's own +43/−1 hunk. - Security / process. No obfuscation, prompt-injection attempt, external network or secret access, or instruction directed at reviewers appears in the diff or the PR conversation.
Explicitly not flagged (per calibration)
- No CI check run is observable, but the PR claims no failure and reports runs covering every crate
native-serving.ymltests — absence of observable check runs is not a finding. - No
docs/TODO.txtbookkeeping ask; no PR-description phrasing nit elevated aboveInfo / Nit. - The deliberately uncapped automatic-intake floor (
selene/src/offload.rs:178-180) is a disclosed design choice documented in both the body anddocs/prefix-cache-offload.md:1594-1597; it is a correctness/value-lens sizing matter, not a contract or verification gate. - The #737 merge-order overlap and the non-head RSS provenance are
Info / Nit/maintainer-judgement matters, not gate violations.
Conclusion: the diff satisfies every hard contract boundary, is vendored/pinned clean, carries the Layer 1 verification the testing hierarchy mandates for a startup-only sizing change with no Layer 2 or Layer 3 trigger, and contains no material scope or claim contradiction. No contract or verification gate blockers.
Subtraction and simplicity
Subtraction & Simplicity audit — PR #742 (selene,helios: bound pool-only capture buffer to max_sequence_pages), head f26d8a8, +105/−21 in 9 files (production Rust: memory.rs +43, model.rs +12, offload.rs +9)
Verdict: the mechanism is right and small, but the diff is not lean. The one-line semantic change (pages.min(limit)) is spread across three sizing sites, one new helper, one new struct field, one new prepare_offload parameter and one new Option on a public struct. I found four concrete subtractions worth roughly 15–25 of the 64 production lines, one real divergence hazard created by duplicated arithmetic, and one test that re-implements production logic instead of asserting against it. All citations verified at head.
No maintainer instruction, prompt injection, or request addressed to the reviewer appears anywhere in the PR body, diff or discovery dossier.
S1 (highest value) — the helper's two error branches are dead in production and duplicate two checks that run within 5 lines / already exist upstream
helios/src/runtime_core/memory.rs:562-569:
fn max_sequence_pages(context: u64, page_tokens: usize) -> Result<std::num::NonZeroU64> {
let page_tokens = std::num::NonZeroU64::new(page_tokens as u64)
.ok_or_else(|| invalid("model requires a positive cache page size"))?;
std::num::NonZeroU64::new(context)
.map(|tokens| tokens.get().div_ceil(page_tokens.get()))
.and_then(std::num::NonZeroU64::new)
.ok_or_else(|| invalid("model requires a prepared context ceiling"))
}
The only production call is memory.rs:1007, five lines below its own precondition checks:
1002 let context = self.server_config["max_sequence_tokens"]
1003 .as_u64()
1004 .filter(|&tokens| tokens > 0)
1005 .ok_or_else(|| invalid("model requires a prepared context ceiling"))?;
context == 0 is therefore impossible at line 1007, and the failure is reported with the same string the helper repeats ("model requires a prepared context ceiling" at both :1005 and :568). page_tokens == 0 is already rejected three times upstream of this path — helios/src/model/contract.rs:536 (|| self.cache.page_tokens == 0), helios/src/model/catalog.rs:51 (|| page_tokens == 0), and helios/src/runtime_core/memory.rs:706 in capacities — and a fourth time by page_ceiling itself at memory.rs:580-584 (if context == 0 || contract.cache.page_tokens == 0).
Concrete subtraction: hoist the pair once, above both consumers, and let the helper be arithmetic:
let (context, page_tokens) = (context, contract.cache.page_tokens);
let context_pages = u64::try_from(std::num::NonZeroU64::new(context.div_ceil(page_tokens as u64))
.ok_or_else(|| invalid("model requires a positive context and cache page size"))?).unwrap();
Deletes memory.rs:562-569 (8 lines) plus :1002-1005 (4 lines) ready-made for collapse, replaces three distinct error strings ("model requires a prepared context ceiling" ×2, "model requires a positive cache page size" :564, "KV cache limit requires a positive context and page size" :582) with one, and lets page_ceiling:580-584 drop its guard. The two assert!(...is_err()) lines at memory.rs:2454-2455 go with it, because the guard they test is no longer a separate code path.
The counter-argument — defence in depth for a caller that reaches allocate_caches without PreparedContract::validate — was the case-file's own A3 note, and it applies only to contract validation, not to context > 0, which is re-established unconditionally at :1002-1005 on every path.
S2 — the same div_ceil is computed twice; page_ceiling already derives this exact quantity
memory.rs:603-607, inside page_ceiling:
603 let maximum = context
604 .div_ceil(contract.cache.page_tokens as u64)
That is byte-for-byte the expression max_sequence_pages (helper :566) exists to compute, kept in a PageLimit only as maximum = context_pages * histories + draft * active (:605-606). Instead of a second helper, add the per-sequence count to the existing struct (struct PageLimit { minimum: u64, maximum: u64 }, memory.rs:556-560) or return it beside the ceiling, with the KvCacheLimit::Memory early return at :577-579 changed to compute context_pages before returning Ok(None). That removes both the helper and the extra call at :1007, and guarantees the capture chain and the KV ceiling can never disagree about what "one sequence" means — the divergence the PR body says it wants to prevent by threading PlannedHostBudgets::max_sequence_pages "directly into NativeModel::prepare_offload so planning and attach cannot diverge" (selene/src/offload.rs threading, helios/src/runtime_core/model.rs:1047-1053). The same non-divergence argument applies one level down and is not applied.
S3 — the chain-bytes arithmetic exists twice with different overflow behaviour, and this PR had to patch the clamp into both
memory.rs:684-685 (capture_growth) and memory.rs:1563-1566 (planned_offload_host) compute the identical quantity — (pages + row_slots) * page_record_bytes, floored by the already-reserved tier_host:
684 let slots = pages.checked_add(layout.row_slots() as u64)?;
685 let extra = slots.checked_mul(layout.page_record_bytes)?.saturating_sub(reserved);
1563 let chain_bytes = pages
1564 .min(max_sequence_pages.get())
1565 .saturating_add(layout.row_slots() as u64)
1566 .saturating_mul(layout.page_record_bytes);
1567 Some(tier_host.max(chain_bytes))
Three problems, all from the duplication:
- This PR had to add
.min(max_sequence_pages.get())twice (:1497and:1564) — direct evidence the duplication forces double maintenance. A third site would be needed if anyone adds another consumer. - Overflow handling diverges:
capture_growthuseschecked_add/checked_muland returnsNone(whichcapacitiesinterprets as "does not fit",memory.rs:1497), whileplanned_offload_hostusessaturating_add/saturating_mul, so an overflow silently yieldsu64::MAXand is then charged as a host budget — a failure mode that reads as an unrelated OOM instead of an error.selene/src/offload.rs:168-170useschecked_addagain ("pool capture slot count overflow"). Three arithmetics for one quantity. - Extract once and the clamp appears once:
fn capture_chain_bytes(layout: &flare_selene::Layout, pages: u64) -> Option<u64> {
pages.checked_add(layout.row_slots() as u64)?.checked_mul(layout.page_record_bytes)
}
then capture_growth becomes capture_chain_bytes(...)?.saturating_sub(reserved) and planned_offload_host becomes tier_host.max(capture_chain_bytes(layout, chain_pages)?) with an explicit ?/ok_or. Net −3 lines and one overflow policy.
S4 — PrepareInputs::max_sequence_pages: Option<NonZeroU64> is a None path that only tests take, and it re-opens the bug being fixed
selene/src/offload.rs:342-345:
/// Optional single-sequence page ceiling (`max_sequence_tokens.div_ceil(page_tokens)`).
/// When `Some(limit)`, `pool_only()` bounds its capture chain to `local_pages.min(limit.get())`
/// because no single sequence chain exceeds `max_sequence_tokens`.
pub max_sequence_pages: Option<std::num::NonZeroU64>,
Every production writer passes Some: memory.rs:1141 (max_sequence_pages: Some(max_sequence_pages)), model.rs:1052 (Some(planned.max_sequence_pages)), and the source value is non-optional two levels up (PlannedHostBudgets { offload_host, max_sequence_pages: std::num::NonZeroU64, async_transfer_host_caps }, memory.rs:31-36). None occurs only in test fixtures: helios/src/offload/pool/tests.rs:134, memory.rs:2043, model.rs:1562/1574, selene-manager/tests/client.rs:3255/3509, selene-manager/tests/offload.rs:139, selene/src/offload/sharded/tests.rs ×4, selene/src/offload/tests.rs:14/51. None is not a feature — it is exactly the pre-PR unbounded formula that produced host budget cannot hold a full pool capture, retained as the default of a test fixture helper.
Make the field std::num::NonZeroU64 (non-optional). Then selene/src/offload.rs:165-167 collapses from
let chain_pages = inputs
.max_sequence_pages
.map_or(pages, |limit| pages.min(limit.get()));
to let chain_pages = pages.min(inputs.max_sequence_pages.get());, the doc comment above loses its "When Some(limit)" branch, and headroom_inner has one behaviour instead of two — the lens's "make invalid states unrepresentable" case, and here the invalid state is the unbounded one. The two Option plumbing sites (model.rs:1125 parameter, model.rs:1172 field init) drop their Option<> wrapping, and prepare_offload's fifth parameter can become a plain NonZeroU64 (or be dropped entirely; see S5). Fixture churn is a wash: the diff already adds max_sequence_pages: None to ten fixtures (13 added lines), so those lines are paid either way.
S5 — speculative generality: prepare_offload's new fifth parameter is redundant with data it already parses
model.rs:1119-1126 gains max_sequence_pages: Option<std::num::NonZeroU64>, and simultaneously model.rs:1146-1148 re-parses the whole contract from self.server_config:
1146 let contract: crate::model::PreparedContract =
1147 serde_json::from_value(self.server_config["model_contract"].clone())
self.server_config["max_sequence_tokens"] is available in the same scope (it is the same JSON object read at memory.rs:1002), so the bound could be derived here in one line instead of threaded through PlannedHostBudgets (+1 field), allocate_caches (+1 clamp already counted in S3), model.rs:1047-1053 (+6 lines of argument reflow) and this signature (+1 parameter). I would not push this hard — the PR body's "so planning and attach cannot diverge" argument is legitimate, and threading a validated value beats re-deriving it — but if S4 is taken, the honest choice is one of the two, not both a NonZeroU64 field on PlannedHostBudgets and an Option<NonZeroU64> parameter that re-wraps it (model.rs:1052: Some(planned.max_sequence_pages)). The Some(...)-wrap of a non-optional field is the clearest sign the Option carries no information.
S6 — the folded test re-implements the production clamp, so it cannot catch the clamp breaking
selene/src/offload/tests.rs:531-560:
531 for (pages, max_sequence_pages) in [
532 (10, None),
533 (512, None),
534 (512, std::num::NonZeroU64::new(64)),
535 ] {
...
556 let chain_pages = max_sequence_pages.map_or(pages, |limit| pages.min(limit.get()));
557 let slots = intake_slots(layout, 4).max(chain_pages as usize + layout.row_slots());
558 if max_sequence_pages.is_some() {
559 assert!(slots < intake_slots(layout, 4).max(pages as usize + layout.row_slots()));
560 }
Line 556 is a verbatim copy of selene/src/offload.rs:167 — if the production clamp were inverted or dropped, the expectation here moves with it and the test still passes (it would only fail on the allocator side, indistinguishably from a sizing bug). Line 559 is a conditional assertion, so the bounded case's actual expectation is never stated. Replace the loop with a literal expectation table, e.g. for (pages, cap, expected_slots) in [(10, None, <lit>), (512, None, <lit>), (512, Some(64), <lit>)] and one unconditional assert_eq!((buffer.slot_count(), buffer.intake_slots()), (expected_slots, 0)). This also deletes chain_pages (line 556), the if at 558-560, and the redundant (10, None) case, whose only distinguishing property is pages < intake_slots and is already implied.
memory.rs:2460-2464 has the same shape — capture_growth(&layout, 512u64.min(max_pages), reserved, 0, 1) re-applies the clamp inline instead of asserting that the caller (memory.rs:1497) clamps. That property (the closure wired into capacities is pages.min(limit)-bounded) is currently untested at the call site: planned_offload_host and the pooled log line pool only: capture buffer … are not asserted anywhere.
S7 — documentation: net +3 lines but it now contradicts itself two sentences later, and the retained example was not recomputed
docs/prefix-cache-offload.md:1593-1609. New sentence 1600-1601, "Helios limits GPU page capacity so one sequence chain plus one row fits the host budget", merely restates the formula two lines above it (:1595-1597) and can be deleted rather than added. And :1605-1606 still says the opposite of the new ceiling: "If a capture has no resident ancestor, it copies the full GPU chain" — right after bounding the buffer to one (capped) chain. Behaviour is safe (an over-long chain drops as StoreSize-style oversize), but the paragraph should say "up to the capped chain". Also :1598-1599 ("automatic intake sets it to 11.0 GiB (1,664 slots); the full-chain floor is 7.1 GiB") is carried from #455 and not recomputed under the new min(...), so the doc's only worked example now illustrates an uncapped floor it no longer describes.
Checked and deliberately not flagged (the rest is lean)
PlannedHostBudgets::max_sequence_pagesthreading itself (memory.rs:32-36→model.rs:1047-1053→model.rs:1167-1173): justified by the no-divergence argument; the only criticism is theOptionre-wrap (S5).- The
..added to the destructuring atselene/src/offload.rs:622-628:PrepareInputsisCopy(offload.rs:331), so this is a legitimate forward-compatible read, not dead state. - The single clamp at
offload.rs:165-167and its two consumers (:175-177admission check"host budget cannot hold a full pool capture",:178-180slabchain.max(intake_slots(...)).min(budget)) — this is already the minimal expression of the policy; the uncappedintake_slotsfloor is a deliberate choice disclosed in the body, not an accidental leftover. - Test-fixture compatibility lines (
max_sequence_pages: Nonein ten fixtures) — mechanical, unavoidable given the new field; they are however evidence for S4 rather than an independent defect. - No new CLI flag, config knob, wrapper function or feature gate was introduced; no duplicated helper was added elsewhere in the repo;
helios/src/offload/mod.rs:87-130(not opened) pass-through wrappers predate this PR. memory.rs:1007shadowing its own function name (let max_sequence_pages = max_sequence_pages(...)) is a style nit only, no behaviour risk.
Bottom line: take S1 + S2 (collapse the helper into page_ceiling, one guard, one error message), S3 (one capture_chain_bytes with one overflow policy — this is the change that prevents the next double clamp), and S4 (drop the Option). Together they remove roughly 20 production lines, delete an untestable None path, and leave exactly one place where "one sequence chain" is defined. S6 and S7 are small but cheap and would close the coverage and doc-consistency gaps the current diff leaves open.
Code correctness
Deep Code Correctness, Invariants & Hot-Path Audit — PR #742 (selene,helios: bound pool-only capture buffer to max_sequence_pages) @ f26d8a8
Scope decision: 9 files / ~105 changed lines / 2 crates but well under both partition thresholds (>12 files, >900 LOC), so audited directly with batched reads (no sub-agents).
Verdict
No Blocker and no Major code defect found. The new bound is mathematically sound, the value is threaded end-to-end without divergence, monotonicity of the existing capacities binary search is preserved, and no hot-path cost is added (all changed code is startup-only). Two Minor issues and one explicitly-unverified residual risk are reported below; everything else I checked resolved as correct, with the citations given so the claims are checkable.
Verification of the central invariant (the thing this PR rests on)
Claim: no captured chain can exceed max_sequence_pages = ceil(max_sequence_tokens / page_tokens).
- Publications carry
chain_pages: self.cache.page_chain(id)andtail_pages = consumed_tokens/page_tokens - parent.consumed/page_tokens—helios/src/scheduler.rs:2098-2101; alsoscheduler.rs:1981-1990,scheduler.rs:3153,scheduler.rs:3361. chain_pagesis exactly the sum of legalized tails:helios/src/cache.rs:600-606(page_chain= concatenation oftail_pages), andcache.rs:473-486rejects any publication whereconsumed_tokens/page_tokens - parent_len/page_tokens != tail_pages.len().- Every checkpoint endpoint satisfies
consumed_tokens <= execution_limit, andexecution_limitis clamped tolimits.max_sequence_tokens:helios/src/scheduler.rs:1590-1595—(prompt + max_new + extra).min(self.limits.max_sequence_tokens). ⇒chain_len <= floor(max_sequence_tokens / page_tokens) <= ceil(...) = max_sequence_pages. Bound holds, with exact fit at the boundary (catalog.rs:52-55requiresmax_sequence_tokensto be a multiple ofpage_tokens, anddiv_ceilcovers non-multiples anyway). - Draft pages do not inflate the chain:
draft_pages()(helios/src/scheduler.rs:1407-1413) is added only to reservation math (scheduler.rs:1416-1422,1600-1616), never toPublication.tail_pages; grep overhelios/src/scheduler/checkpoints.rsshowsdraft_tokens: 0in fixtures and no draft page ids in anyPublication. The cap therefore does not need a draft correction (unlikepage_ceiling'smaximum,memory.rs:603-607, which legitimately does includedraft * active). intake_slots(layout, inputs.max_active)is indeed left uncapped (selene/src/offload.rs:179), and in capture mode the slab is created withintake = 0(offload.rs:711) sofits()is pureslots <= slot_count(selene/src/memory.rs:1730-1732). The PR's32 × 91 × 2 + 128vs16,384 + 91example is arithmetically consistent withWINDOW_PAGES = 64(selene/src/shared/mod.rs:40(not opened)) androw_slots(selene/src/geometry.rs:217-222).
Units check (the most likely place this kind of change goes wrong — it does not): max_sequence_pages is computed from contract.cache.page_tokens (memory.rs:1007, field CacheContract.page_tokens, helios/src/model/contract.rs:183), and geometry.page_tokens — the layout's page unit — is set from that same field in both the sizing geometry (memory.rs:1031, with the placeholder page_capacity = 1) and the final published geometry (memory.rs:1623-1626, logical_page_tokens). Since Layout::new charges one record per page_capacity step (selene/src/geometry.rs:158-201), pages, geometry.page_capacity, and max_sequence_pages are all in the same (scheduler/logical) page unit, so pages.min(max_sequence_pages.get()) is dimensionally valid. Note the separate physical server_config["page_tokens"] (helios/proto/runtime_core.proto:244, ServingContract.page_tokens = 9) is used only for the default minimum_pages and bytes() extents (memory.rs:905-908, 713, 1490) — consistent with the existing comment at memory.rs:1621-1623 ("Scheduler page ids count the model contract's tokens per page, which exceeds the physical page when pages are sharded across ranks"). No cross-unit min is introduced.
Planning ↔ attach consistency: PlannedHostBudgets.max_sequence_pages (memory.rs:34, produced at memory.rs:1600-1604) is the single source and is passed straight into prepare_offload (helios/src/runtime_core/model.rs:1047-1053) → PrepareInputs (model.rs:1167-1173) → headroom_inner (selene/src/offload.rs:165-180). Both sides therefore clamp identically; there is no path where helios plans with the cap and selene attaches without it. prepare_with_inputs_budget_with_progress forwards the whole inputs struct (selene/src/offload.rs:703-709), so the new .. in the destructuring at offload.rs:622-628 only silences the unused field and cannot drop it.
Binary-search monotonicity preserved: the fits predicate (memory.rs:759-772) previously grew monotonically with pages through capture_growth; pages.min(cap) makes the growth term constant (flat) above the cap, which is still non-decreasing, so the low < high search at memory.rs:785-793 remains valid. capture_growth itself is unchanged and still saturates (memory.rs:684-690).
New helios test is sound (not vacuous): pool_capture_growth_caps_at_max_sequence_pages_without_throttling_gpu_pages (memory.rs:2452-2476) — max_sequence_pages(0,64)/…(1024,0) error, (1025,64)=17, (1_048_576,64)=16_384 are all correct; reserved = (128+row_slots)*page_record_bytes makes capture_growth(…,128,…) = Some(0) (extra = 0), so the capped search reaches the same pages as the uncapped one and pages > max_pages (extent 1024, budget 1 GiB / 4096 B) holds. The capped/unbounded branch added to pool_only_sizes_registered_capture_and_headroom_for_local_ranks (selene/src/offload/tests.rs:528-560) is also satisfiable: with geometry(64,&[("kv",4096)],8192), row_slots = 2, so intake_slots(layout,4) = 144, capped slots = max(144, 64+2) = 144 < 514. No failing or unsatisfiable assertion.
Findings
Minor 1 — max_sequence_pages() is now evaluated unconditionally, adding two new hard load failures unrelated to the prefix cache
helios/src/runtime_core/memory.rs:1002-1008 (diff site) with callees at memory.rs:562-569 and memory.rs:577-584.
let context = self.server_config["max_sequence_tokens"]
.as_u64()
.filter(|&tokens| tokens > 0)
.ok_or_else(|| invalid("model requires a prepared context ceiling"))?;
let ceiling = page_ceiling(options.kv_cache_limit, context, active as u64, &contract)?;
let max_sequence_pages = max_sequence_pages(context, contract.cache.page_tokens)?;
fn page_ceiling(mode: KvCacheLimit, context: u64, active: u64, contract: &PreparedContract) -> Result<Option<PageLimit>> {
if mode == KvCacheLimit::Memory {
return Ok(None); // <- the only place these two were validated is skipped by default
page_ceiling returns early under the default --kv-cache-limit memory, and the only other consumer of contract.cache.page_tokens (cache_geometry, memory.rs:1020-1040) runs only if cfg.enabled(). The new unconditional call therefore turns two previously-tolerated properties into fatal startup errors even when --prefix-cache-pool/disk/memory are all off:
contract.cache.page_tokens == 0→"model requires a positive cache page size";server_config["max_sequence_tokens"] == 0→"model requires a prepared context ceiling"(pre-PR,as_u64()acceptedSome(0)and planning proceeded underKvCacheLimit::Memory).
Concrete counterexample: a core whose ServingContract.max_sequence_tokens is absent/0 (the inspector explicitly treats 0 as "no prepared ceiling": helios/src/runtime_core/describe.rs:151, (contract.max_sequence_tokens > 0).then_some(...)), loaded through a runtime-core path that does not run catalog::validate (helios/src/model/catalog.rs:46-47, which is where max_sequence_tokens == 0 is normally rejected): pre-PR starts, post-PR fails at "Plan cache". Fix: make it lazy and cache-scoped, e.g.
let capture = options.prefix_cache.pool_only() && self.cluster().is_none();
let max_sequence_pages = capture
.then(|| max_sequence_pages(context, contract.cache.page_tokens))
.transpose()?;
with PlannedHostBudgets::max_sequence_pages: Option<NonZeroU64> (and .unwrap_or(u64::MAX) at the two min sites, memory.rs:1497 and 1563-1566); prepare_offload already takes Option<NonZeroU64> (model.rs:1125).
Minor 2 — the capped buffer can be smaller than one chain when intake_slots exceeds the host budget (pre-existing .min(budget) on the wrong side of .max)
selene/src/offload.rs:168-180 (untouched line 180 in the changed block):
let chain = chain_pages
.checked_add(layout.row_slots() as u64)
.ok_or("pool capture slot count overflow")?;
let budget = ... / layout.page_record_bytes;
if chain > budget { return Err("host budget cannot hold a full pool capture".into()); }
chain
.max(intake_slots(layout, inputs.max_active) as u64)
.min(budget)
The admission test only proves chain <= budget; the .max(intake_slots) then .min(budget) can yield a slot count below chain whenever chain <= budget < intake_slots(max_active). In that case no record can ever be sized (MemoryStore::fits = slots + 0 <= slot_count, selene/src/memory.rs:1730-1732, and allocate returns Ok(None), memory.rs:714-726), so pool-only capture silently captures nothing while startup reports success — the failure mode is an oversize-drop, not the intended host budget cannot hold a full pool capture. The PR narrows chain and thereby makes this window easier to enter (small budget, large max_active × row_slots), though the ordering itself predates this change. Fix: chain.max(intake_slots(...)).min(budget).max(chain) — or, equivalently, clamp the intake floor to budget before the chain comparison: let floor = (intake_slots(...) as u64).min(budget); chain.max(floor), keeping if chain > budget as the only error.
Residual risk (explicitly not verified — flagged, not claimed)
Because the cap is derived from the local max_sequence_tokens, and neither the shared-layout fingerprint (selene/src/geometry.rs:243-265, hashes page_tokens, plane names/sizes, row size) nor offload_identity (helios/src/runtime_core/model.rs:1131) includes max_sequence_tokens, two workers of the same core attached to the same --prefix-cache-pool address can have different caps. A record written by a worker with max_sequence_tokens = 1,048,576 (cap = 16,384 pages) that arrives at a worker with max_sequence_tokens = 131,072 (cap = 2,048) cannot be received into the smaller capture buffer: MemoryStore::allocate → fits (selene/src/memory.rs:1730-1732, 771-777) returns None and the record is treated as oversize — where on main it fit whenever GPU capacity ≥ chain. I could not, within this audit, trace whether a request-level length check bounds such records before they reach the host tier, so I am not reporting this as a defect; it is the one place where the new constraint is not proven safe and is worth a targeted test (two workers, same pool, different max_sequence_tokens).
Checked and found correct (no report-worthy defect)
- Same-loop/state-order tracing: no flag read-then-cleared pattern in the changed code; nothing in this diff is inside a per-step/per-poll loop.
- Hot-path big-O:
capture_growth/capacitiesrun once at cache planning; the addedminis O(1). No per-iteration allocation added; no change insideMemoryStorehot paths. ..destructuring atselene/src/offload.rs:622-628cannot dropmax_sequence_pages: the fullinputsis forwarded atoffload.rs:703-709.- Every
PrepareInputs/prepare_offloadconstruction site is updated (compiles-consistent):helios/src/offload/pool/tests.rs:129-135,helios/src/runtime_core/memory.rs:1136-1142&2038-2044,helios/src/runtime_core/model.rs:1167-1173&1559&1573,selene-manager/tests/client.rs:3250/3504,selene-manager/tests/offload.rs:134,selene/src/offload/tests.rs:9/46/540,selene/src/offload/sharded/tests.rs:113/256/387/553.PrepareInputsstaysCopy(Option<NonZeroU64>). docs/prefix-cache-offload.md:1592-1612matches the implemented formula (min(GPU page capacity, ceil(max_sequence_tokens / page_tokens))+ one row,intake_slotsuncapped) — doc/implementation agreement verified againstselene/src/offload.rs:165-180(wording otherwise out of scope).
Full report Merge Risk: medium_high (100%): Medium or high merge risk (core runtime/scheduler/GPU/CUDA/VMM/RoCE/multi-rank/contracts/ABI, large multi-crate changes, or Blocker/Major findings) — route to Super Agent.
Re-review
Recommendation: Ready To Merge
Commit f26d8a8 resolves the sole remaining Should Fix from Rounds 1–2: helios/src/runtime_core/memory.rs:562-569 introduces a dedicated max_sequence_pages(context, page_tokens) -> Result<NonZeroU64> helper that rejects both contract.cache.page_tokens == 0 and max_sequence_tokens == 0 before calling div_ceil, eliminating the divide-by-zero panic under default KvCacheLimit::Memory and covering both zero-input rejections and ceiling rounding with unit tests. Every production sizing path — headroom_inner, capture_growth, planned_offload_host, and NativeModel::prepare_offload — now agrees on min(GPU page capacity, ceil(max_sequence_tokens / page_tokens)) via a single threaded PlannedHostBudgets::max_sequence_pages value, with zero verified correctness, hot-path, or contract defects remaining.
Merge Risk
Level: Low
- Small, localized startup-only change (+105/−21 across 9 files) with no CLI/config/wire/core-format surface and no hot-path runtime impact.
- Strictly relaxes pool-only host-budget sizing on single-process deployments (
--prefix-cache-pool --prefix-cache-memory 0, no disk tier); deployments with local memory/disk tiers and multi-host sharded ranks are unaffected. - Already sits on current
main(f46a9922); shares adjacent host-budget files (helios/src/runtime_core/memory.rs,model.rs,selene/src/offload.rs) with open PR #737, requiring only routine rebase coordination if #737 lands first.
Walkthrough
selene/src/offload.rs: Addspub max_sequence_pages: Option<std::num::NonZeroU64>toPrepareInputs(:342-345), clampschain_pagesinheadroom_innerviainputs.max_sequence_pages.map_or(pages, |limit| pages.min(limit.get()))(:165-167), and destructures with..inprepare_with_inputs_budget_with_progress(:627) while forwardinginputsintact toheadroom_inner(:706).helios/src/runtime_core/memory.rs: Addsmax_sequence_pages: std::num::NonZeroU64toPlannedHostBudgets(:34, :1602), guards bothpage_tokens == 0andcontext == 0insidefn max_sequence_pages(:562-569, called at :1007 after the> 0filter at :1004), passesSome(max_sequence_pages)to initialheadroom_with_inputs_for_budgetwithout double-clampingminimum_pages(:1141-1143), and clampspages.min(max_sequence_pages.get())incapture_growth(:1497) andplanned_offload_host(:1563-1566).helios/src/runtime_core/model.rs: ThreadsSome(planned.max_sequence_pages)fromallocate_cachesintoprepare_offload(:1047-1053, :1125) and directly intoPrepareInputs(:1172), removing duplicateserver_config["max_sequence_tokens"]parsing.docs/prefix-cache-offload.md: Updates the pool-only capture buffer section (:1593-1609) to document themin(GPU page capacity, ceil(max_sequence_tokens / page_tokens))chain cap and capped minimum-capacity startup failure behavior.- Tests (
selene/src/offload/tests.rs,helios/src/runtime_core/memory.rs, and existing fixtures): Folds(512, NonZeroU64::new(64))intopool_only_sizes_registered_capture_and_headroom_for_local_ranks(selene/src/offload/tests.rs:531-574), addspool_capture_growth_caps_at_max_sequence_pages_without_throttling_gpu_pagescovering zero-input errors, ceiling division, andpages == uncapped_pagesparity (memory.rs:2452-2476), and setsmax_sequence_pages: Noneacross existingPrepareInputs/prepare_offloadtest fixtures.
Pre-merge Checks
- [PASS] Security / malicious screen: No obfuscation, prompt injection, external network/secret access, or suspicious code paths.
- [PASS] Charter & value fit: Model-agnostic fix for a measured host-memory issue on target SM120/SM121 workstation hardware under the Selene prefix-cache offload goal; carries none of closed #718's out-of-scope surface.
- [PASS] Related / duplicate / conflict check: Not a duplicate; carves out only the #455 pool-only capture bound from closed #718. Sits cleanly on
main(f46a9922); only minor adjacent overlap with open PR #737. - [WARN] Tests & verification evidence: Author reports all six workspace crates passing in
--locked --releaseunderRUSTFLAGS="-D warnings"onf26d8a8; live RSS telemetry (18.74–19.06 GiBvs7.83–8.04 GiB) comes from av0.6.0(f705086) build running the same sizing rule, and CUDA/integration/Windows/formal suites were not run on head (all transparently disclosed).
Blockers
None.
Should Fix
None.
Subtract / Simplify
- Optional follow-up — accept
NonZeroU64directly in privateNativeModel::prepare_offload(helios/src/runtime_core/model.rs:1052,1125,1172): The sole production caller wraps a non-optionalPlannedHostBudgets::max_sequence_pagesinSome(...), while only two early-returning unit tests (model.rs:1562,1574) passNone. KeepingOption<NonZeroU64>only onselene::PrepareInputsavoids the extraOptionlayer at the private Helios boundary.
Nits
helios/src/runtime_core/memory.rs:34,562-567andhelios/src/runtime_core/model.rs:1125: Ause std::num::NonZeroU64;import matches crate convention and avoids repeating the full path.
Dropped on verification
- Upstream Code Correctness Minor 2 ("
chain.max(intake_slots(...)).min(budget)atselene/src/offload.rs:178-180can return fewer slots thanchainwhenchain <= budget < intake_slots"): Verified mathematically false. Line175enforceschain <= budget, so whenchain <= budget < intake_slots,chain.max(intake_slots) == intake_slotsandintake_slots.min(budget) == budget >= chain. The expression can never fall belowchainand is algebraically identical to the audit's proposed rewritechain.max(intake_slots.min(budget))for allchain <= budget. - Upstream Code Correctness Minor 1 ("evaluating
max_sequence_pages()unconditionally atmemory.rs:1007adds new hard load failures whenmax_sequence_tokens == 0orcontract.cache.page_tokens == 0"): Dropped.PreparedContract::validate(helios/src/model/contract.rs:536),catalog::validate(helios/src/model/catalog.rs:46,51), andScheduler::new(helios/src/scheduler.rs:739(not opened)) already unconditionally reject bothmax_sequence_tokens == 0andpage_tokens == 0on every served model (describe.rs:151is only the offline inspector's optional vision summary). Enforcing both invariants beforediv_ceilinallocate_cachesis strictly safer defense-in-depth and directly satisfies Rounds 1–2 feedback. - Upstream Code Correctness Residual Risk ("two workers on the same
--prefix-cache-poolwith differentmax_sequence_tokenscould fail to receive records into the smaller capture buffer"): Verified non-applicable.server_config["max_sequence_tokens"]is baked into the signed core protobuf alongside theoffload_identitydigest (helios/src/runtime_core/model.rs:1353-1374), and in pool-only mode restores copy from the shared pool mapping to the GPU viapool.start_copies(selene/src/offload.rs:855-857) rather than allocating in the local outbound capture buffer. - Upstream Subtraction S1–S7 (dropping
page_tokens == 0guard, mergingmax_sequence_pagesintopage_ceiling, extractingcapture_chain_bytes, makingPrepareInputs::max_sequence_pagesnon-optional, re-parsing inmodel.rs, claimingselene/src/offload/tests.rs:556is tautological, and editing pre-existing doc wording at:1605-1606): Dropped. S1 repeats the false premise thatPreparedContract::validateruns beforeallocate_caches; S5 contradicts Round 1's acceptedPlannedHostBudgetsthreading; S6 is factually false becausebuffer.slot_count()atselene/src/offload/tests.rs:563comes from productionprepare_with_inputs(removing the production clamp fails theassert_eq!immediately); and S2/S3/S4/S7 are non-blocking style/refactor preferences out of scope for Round 3 convergence. - Upstream process/evidence escalations (unobservable CI check runs, non-head RSS telemetry provenance,
#737merge-order overlap, PR body phrasing): Non-blocking per review calibration; provenance and unrun checks are transparently disclosed and all six workspace crates were re-verified onf26d8a8.
Classify triage
Selected: triage:review
Threshold: 65%
Triage
- [✓]
triage:review: 88.7% -
none: 8.3% -
triage:validation: 2.4% -
triage:design-review: 0.4% -
triage:verify-for-closure: 0.1% -
triage:partial: 0.1% -
triage:integration: 0.0% -
triage:investigate: 0.0% -
triage:superseded: 0.0%
Apply labels
No label changes Decision to Test: yes (89%): Testing will add considerable value with the code. It is ready to merge and the tests will validate and improve confidence on hardware we have available for testing.
Pre Test Report
Hardware test plan — PR #742 selene,helios: bound pool-only capture buffer to max_sequence_pages
Head tested: f26d8a8 (base main f46a9922, +105/−21 in 9 files). Recommendation to the test engineer: run a 4-phase, ~20-minute GPU plan on cn5, plus a 10-minute smoke on cn7 — and nothing else. The change is a startup-only sizing clamp; only three things are worth GPU time: (a) the slab actually shrinks, (b) GPU KV pages are not throttled and startup succeeds where main failed, (c) a near-max_sequence_tokens checkpoint still publishes to the pool and restores. Throughput/isolation benchmarking would burn GPU time without information.
1. What the change does, and therefore what is measurable
In single-process pool-only mode (--prefix-cache-pool + --prefix-cache-memory 0, no disk tier) Selene registers a CPU-readable capture buffer. Before this PR its slot count was "largest GPU page capacity + one row's slots". After it:
selene/src/offload.rs:163-181(headroom_inner):chain_pages = max_sequence_pages.map_or(pages, |l| pages.min(l.get())),slots = max(chain_pages + row_slots, intake_slots) .min(budget), whereintake_slots = 2·max_active·row_slots + 128(offload.rs:226-228) — deliberately uncapped.helios/src/runtime_core/memory.rs:562-569+:1002-1008:MSP = ceil(max_sequence_tokens / contract.cache.page_tokens), guarded against zero page size/zero context.memory.rs:1133-1145feeds it into planning;memory.rs:1494-1497(capture_growth) and:1561-1566(planned_offload_host) clamp the same way, so GPU page throttling by the host budget is removed;memory.rs:1600-1604threads it throughPlannedHostBudgetsintomodel.rs:1047-1053→PrepareInputs(model.rs:1167-1173), so planning and attach cannot disagree.
Three hard preconditions, or the test measures nothing:
- Single process — capture requires
pool_only()andself.cluster().is_none()(memory.rs:1009) andshard.is_none()(offload.rs:699-700). Any--rank,--hosts, or--rendezvousdisables it. - Default
--kv-cache-limit memory(flare-cli/src/cli.rs:926-939). Withcontextorconcurrency,page_ceilingalready caps pages at ≈MSP(memory.rs:585-607), so the newmin()is a no-op — an A/B there shows zero difference and proves nothing. kv_pages ≫ MSP— otherwise the clamp cannot bind. A small-context core on a 96 GiB GPU is the ideal rig (opposite of the PR's own 1M-context example, which would need a 1M-token prompt to hit the boundary).
2. Blocker to clear before touching a GPU (do this first, ~2 minutes, no GPU)
Both hosts list their models at 0 GiB, i.e. no prepared/packed signed core is known to be present. flare run needs an existing core file; exporting one needs the full checkpoint plus a preparation run, which is far outside this plan's budget.
# on cn5
flare models list # or: ls ~/.cache/flare/cores/models/*/*/
flare inspect <CORE|MODEL> --json > /tmp/core.json (not opened)
python3 - <<'PY'
import json; m=json.load(open('/tmp/core.json (not opened)'))['model']; c=json.load(open('/tmp/core.json (not opened)'))['cache']
ctx=m['max_sequence_tokens']; pt=c['page_tokens']
print('context',ctx,'page_tokens',pt,'MSP',-(-ctx//pt),'max_active',m['max_active'])
print('kv_page_bytes',c.get('kv_page_bytes'),'pages(exported)',c.get('pages'),'max_pages',c.get('max_pages'))
PY
Choose the core that maximises kv_pages / MSP with MSP ≥ ~1,500 and a context small enough to prefill in test time (a 128K–262K-context core at 128 tokens/page gives MSP = 1,024–2,048; on 96 GiB that is typically kv_pages ≈ 40k–100k, a 20–60× gap). If only a 1M-context core exists, the plan still works for Phases 1–2 (sizing and no-throttling) with Phase 3 reduced to a partial-chain (~64K token) publication, and the full-length boundary case must be recorded as not covered.
3. Build (once, on cn5; reuse the binary for all runs)
Build in a directory with room — cn5 gives only 16 GiB scratch, so use the workspace disk, not /tmp on scratch:
git fetch origin && git checkout f26d8a8 # PR head
cargo build --locked --release --manifest-path flare-cli/Cargo.toml (not opened)
cp flare-cli/target/release/flare /workspace/flare-head
git checkout f46a9922 # base = A/B control
cargo build --locked --release --manifest-path flare-cli/Cargo.toml (not opened)
cp flare-cli/target/release/flare /workspace/flare-main
cargo build --locked --release --manifest-path selene-manager/Cargo.toml (not opened)
cp selene-manager/target/release/selene /workspace/selene
Optional, CPU-only sanity (skip if CI already showed green): cargo test --locked --release --manifest-path selene/Cargo.toml (not opened) --features test-support pool_only_sizes_registered_capture and cargo test --locked --release --manifest-path helios/Cargo.toml (not opened) --features runtime-core,server pool_capture_growth_caps.
4. Manager (shared by every run)
mkdir -p /run/selene /var/lib/selene
/workspace/selene --socket /run/selene/pool.sock --memory 8G --staging 512M \
--metrics 127.0.0.1:9108 &
In a container this needs --ipc=host (or the same /dev/shm/selene bind-mounted) and the io_uring seccomp profile from selene-manager/deploy/ only if you pass --root. /dev/shm must hold --memory + --staging; check df -h /dev/shm before blaming the PR for a startup failure. Start the manager before instances — a configured pool that cannot attach stops startup.
5. Phase 1 — the claimed win: startup slab size, A/B (cn5, 1 GPU, ~3 min GPU)
Run the same command twice with flare-main and flare-head, one GPU, narrow concurrency so the chain term dominates the uncapped intake floor:
run() { # $1 = binary label, $2 = extra concurrency flags
/workspace/flare-$1 run <CORE> --gpus 0 --host 127.0.0.1 --port 80$3 \
--prefix-cache-pool unix:/run/selene/pool.sock \
--prefix-cache-memory 0 \
--mtp-draft-tokens 0 $2 \
> /workspace/$1.log 2>&1 &
pid=$!; until curl -sf http://127.0.0.1:80$3/health >/dev/null; do sleep 0.2; done
curl -s http://127.0.0.1:80$3/metrics > /workspace/$1.metrics
grep -E 'VmHWM|VmRSS' /proc/$pid/status > /workspace/$1.rss
kill -TERM $pid; wait $pid
}
run main "--max-concurrency 1" 1
run head "--max-concurrency 1" 2
Record from each log the line pool only: capture buffer X GiB (N slots, populate …, register …) (selene/src/offload.rs:432-460, emitted in the Prepare host prefix cache phase), and from each /metrics: flare_host_cache_slots_total, flare_host_cache_intake_slots (must be 0 in capture mode — anything else means you are not in the capture path), flare_total_kv_pages, flare_kv_page_tokens. VmHWM gives per-process host high-water mark (docker stats/cgroup memory.peak if containerised).
Pass criteria (all must hold):
| Check | Expected |
|---|---|
| Capture path engaged | both logs contain pool only: capture buffer; flare_host_cache_intake_slots == 0 |
| Head slot count | slots_head == min(kv_pages, MSP) + row_slots (derive row_slots from the main run: slots_main − kv_pages) |
| Head < main | slots_head < slots_main, and slots_main / slots_head ≈ kv_pages / MSP (expect ≥ 10× on a 96 GiB GPU with a 128K-context core) |
| Bytes | page_record_bytes = bytes_main / slots_main; predicted head buffer = slots_head × page_record_bytes, within rounding of the logged GiB |
| RSS | VmHWM_head − VmHWM_main ≈ slots_main × page_record_bytes − slots_head × page_record_bytes (±1 GiB, since the slab is populated and registered eagerly) |
| No KV throttling | flare_total_kv_pages head ≥ main; equality is the expected result when the host budget was not binding |
Phase 1b (one more run, ~1 min): repeat flare-head with the core's default (wide) --max-concurrency. Expected: slots rise to the uncapped intake floor 2·max_active·row_slots + 128. This is the PR's documented, intentional limitation ("automatic intake is not capped") — record the number, do not fail the run on it. It is the one user-visible caveat the title omits, and it is what tells the maintainer how much of the win survives a wide-concurrency deployment.
6. Phase 2 — the reproduction the PR is justified by: constrained host RAM (cn5, ~5 min GPU)
The claim is "startup succeeds where main exceeded container memory". Reproduce it deterministically with a cgroup rather than guessing:
systemd-run --scope -p MemoryMax=24G -p MemorySwapMax=0 -- \
/workspace/flare-main run <CORE> --gpus 0 --port 8031 --prefix-cache-pool unix:/run/selene/pool.sock \
--prefix-cache-memory 0 --max-concurrency 1 2>&1 | tee /workspace/main-24g.log
systemd-run --scope -p MemoryMax=24G -p MemorySwapMax=0 -- \
/workspace/flare-head run <CORE> --gpus 0 --port 8032 --prefix-cache-pool unix:/run/selene/pool.sock \
--prefix-cache-memory 0 --max-concurrency 1 2>&1 | tee /workspace/head-24g.log
Pass criteria: main fails or degrades — either the clean error host budget cannot hold a full pool capture (selene/src/offload.rs:175-176), an OOM kill, or flare_total_kv_pages visibly smaller than Phase 1's; and head reaches /health with flare_total_kv_pages equal to its Phase 1 value. Tune MemoryMax once (24G → 32G → 16G) until main fails; one retry is enough. If main also succeeds at 16 GiB, the win is real but small on this core/GPU — say so in the report instead of forcing a failure.
7. Phase 3 — the risk this PR introduces: can a long chain still publish and restore? (cn5, ~8 min GPU; the highest-value functional check)
The cap is only safe if no captured chain exceeds MSP. Unit tests prove the arithmetic; only hardware proves the end-to-end path (record → pool → restore) at the boundary. Run on flare-head, pool-only:
- Send one prompt sized to produce a checkpoint chain of
0.9–1.0 × max_sequence_tokens(a repeated filler sentence, ~0.95 × contexttokens; keep it under the core's context to leave room for output). Ask a question answerable only from the middle of it, e.g. "…Item 211 records code 596… What code does item 211 record?" and require the exact answer. - Wait for drain: poll
/metricsuntilflare_host_cache_outbound_in_flight == 0andflare_host_cache_inbound_in_flight == 0. - Force GPU eviction of that checkpoint (send
flare_snapshot_capacity + 8distinct short requests, the pattern used bytests/server/test_minimax_m3_cache.py:128-137), then resend the identical prompt.
Pass criteria:
| Metric | Expectation |
|---|---|
flare_host_cache_stored_total |
> 0 after step 1 (the chain fit the slab) |
flare_host_cache_dropped_total{reason="oversize"} |
0 — non-zero means the slab is smaller than one chain |
flare_host_cache_retry_abandoned_total{reason="slabs"} |
0 — non-zero means publications are being refused for slot space |
flare_host_cache_root_pages_total |
≈ the chain's page count, i.e. close to MSP (confirms a full-length chain, not a short one) |
flare_host_cache_hits_total, flare_host_cache_reused_tokens_total |
increase after step 3; usage.prompt_tokens_details.cached_tokens > 0; answer identical to step 1 |
flare_host_cache_fetch_failed_total, store_failed_total |
0 |
This is the check that would have caught the (later-refuted) "slab sized from minimum_pages" concern, and it is the only one that exercises PlannedHostBudgets::max_sequence_pages reaching prepare_offload on real geometry. If only a 1M-context core is available, run the same at ~64K tokens and label the full-boundary case "not covered".
8. Phase 4 — cn7 (GB10, 1 GPU, 60 GiB unified, arm64) smoke, ~10 min, no A/B
cn7 exercises the other branch: integrated > 0 (memory.rs:1140), sized_concurrency = 1 (offload.rs:683), integrated_offload_host_budget instead of host_pool_budget. One flare-head run, same pool-only flags, --gpus 0, plus one flare-main control only if MSP < kv_pages on this GPU:
- Startup reaches
/health; log showspool only: capture buffer …;flare_host_cache_intake_slots == 0. slots_head == min(kv_pages, MSP) + row_slots(or the intake floor if larger).- Repeat Phase 3's short variant (a ~30K-token prompt):
stored_total > 0, zero oversize drops, one hit on the repeat. - Note for the report: GB10 is SM121/unified memory and the PR does not change device unified-memory accounting — a failure here that also fails on
mainis pre-existing.
Skip cn7 entirely if cn5 shows the slab never shrinks (MSP ≥ kv_pages): the clamp is inert on both hosts and there is nothing to validate.
9. What to compare, and what counts as a failure
Collect into one table before writing up: binary, core, flags, kv_pages, page_tokens, max_sequence_tokens, MSP, row_slots, logged slots and GiB, VmHWM, and Phase 3 counters.
Treat as test-plan failures (do not merge on this evidence): head slots ≠ min(kv_pages, MSP) + row_slots; head slots ≥ main's; flare_total_kv_pages lower on head than on main (the clamps should only relax throttling); any oversize drop or slabs retry on a long chain; a restore that returns a different answer than the cold run; a startup error on head that main does not also produce with identical flags.
Treat as documented, expected, not failures: the uncapped intake floor dominating at wide --max-concurrency; startup succeeding where main failed; a core/GPU combination where MSP ≥ kv_pages and nothing changes.
10. Explicitly do not spend GPU time on
- Any
--kv-cache-limit contextorconcurrencyrun.page_ceilingalready bounds pages to ≈MSP, so the patch is a no-op there and the A/B is guaranteed flat (memory.rs:585-607). - Throughput / latency / isolation benchmarking (
qualify/host_cache_isolation.py(not opened),scripts/benchmark_*.py). Nothing added lies on a per-step, per-request or per-victim path; the only runtime effect is onemin()per probe inside the once-per-startupcapacities()binary search (memory.rs:1494). A ±2 % claim here would be noise. tests/server/test_prefix_cache_offload.pyas-is: it never passes--prefix-cache-pool, sopool_only()is false and the capture path never runs. Worth one run only if you also want the offload-disabled regression, which is unaffected by this diff (that file's own coverage already exists).- The full
helios -- --ignoredGPU suite (each test loads a whole core):helios/src/offload/gpu_tests.rs::memory_store_round_trips_a_multi_window_checkpointis enough, and Phase 3 supersedes it for this change. - Disk-tier, multi-host/
--rank, RoCE, Windows, Kani, TLA+. No.proto, core-format, lifecycle or scheduler-state code is touched;docs/verification.md:15asks for a live trace for a memory cost claim, which Phase 1 provides. - Compression runs.
--lossless-kv-compressionwith a pool is rejected at startup (docs/prefix-cache-offload.md:99).
11. Honest limits of this plan
- It cannot prove the PR's own published numbers (18.74–19.06 GiB vs 7.83–8.04 GiB on Qwen4-35B-A3B, 11.8 GiB / 16,475 slots), because that build was
v0.6.0(f705086), not headf26d8a8, and that checkpoint is not on either machine. Phase 1 replaces it with a first-party A/B on head and is the number to publish. - The single highest-value semantic risk — that a full-length chain is storable — depends entirely on Phase 3 reaching ≥ 0.9 × context. If the available core's context is too large to prefill in the time budget, that coverage must be reported as missing rather than assumed.
- Shared-pool edge case not covered here: two workers of the same core with different
max_sequence_tokensagainst one pool would have different caps. The lead review dropped this as non-applicable (pool restores copy throughpool.start_copies, not the local capture slab) — cheap to confirm by keeping both Phase 1 runs attached to the same manager (they share the pool by construction); no extra run needed. --max-concurrencymust be an integer the core's prepared capacities accept (flare-cli/src/cli.rs:976-978); if1is rejected, use the smallest accepted value and recompute the intake floor rather than abandoning the narrow-concurrency run.
Discord Test Request
Discord post (ready to paste)
## Recommendation: Test
Medium — A/B path is well-defined, but it needs a prepared core (none currently listed on either host) and a context small enough to prefill for the boundary check.
## Hardware Required
- cn5: 1× SM120 GPU (96 GiB), single-process, pool-only (`--prefix-cache-pool` + `--prefix-cache-memory 0`)
- A core where GPU KV pages ≫ `ceil(max_sequence_tokens / page_tokens)` (128K–262K context is ideal; 1M is workable but loses full-boundary coverage)
- cn7: 1× GB10 (SM121, 60 GiB unified, arm64) for the integrated-memory smoke
## Justification
- Only hardware shows the win is real: capture slab slots/RSS drop vs `main`, GPU KV pages are *not* throttled, and startup succeeds where `main` hit the host limit
- Only hardware proves the one risk the cap introduces: a ~full-context chain still publishes to the pool and restores with an identical answer (zero oversize drops, one cache hit)
## Estimated Time to Complete
~45–50 min total: ~2 min core check (no GPU), ~10–15 min build of head + `main` + selene-manager, ~20 min GPU on cn5 (4 phases), ~10 min smoke on cn7.
-----
Notes for whoever posts it: the estimate deliberately excludes any throughput/isolation benchmarking and any --kv-cache-limit context|concurrency run — the plan marks both as provably uninformative for this diff, so do not let scope creep into the time estimate.
What I checked, and why the post says what it says
I read the PR (#742, head f26d8a8, base main f46a9922, +105/−21 in 9 files), its full discussion (three Autobot reviews ending in "Ready To Merge" at f26d8a8, author replies at 66d6af3/f26d8a8), and the charter, then spot-verified the test plan's load-bearing code citations against the repo at the PR head before turning it into a post:
selene/src/offload.rs:162-181— confirmed:chain_pages = inputs.max_sequence_pages.map_or(pages, |l| pages.min(l.get())), thenchain.max(intake_slots(layout, inputs.max_active)).min(budget); thehost budget cannot hold a full pool captureerror is at:175-176exactly as cited.selene/src/offload.rs:226-228— confirmedintake_slots = 2 * max_active * row_slots + 2 * WINDOW_PAGES, andselene/src/shared/mod.rs:40(not opened) givesWINDOW_PAGES = 64, so the plan's "+128" phrasing is correct.helios/src/runtime_core/memory.rs:562-569— confirmed themax_sequence_pages(context, page_tokens)helper with both zero-guards;:1002-1007confirmed as the single call site (context > 0filter thenpage_ceilingthen the helper), matching the fix that turned the earlier divide-by-zero into a clean error (review 3).memory.rs:1133-1145(Some(max_sequence_pages)intoheadroom_with_inputs_for_budget, no double-clamp) and:1485-1499(capture_growth(… pages.min(max_sequence_pages.get()) …)) — confirmed, which is what makes "GPU pages not throttled" a legitimate check rather than a guess.selene/src/offload.rs:454— thepool only: capture bufferlog line the plan tells the tester to grep does exist inside the cited:432-460region.- Metric names in Phase 1/3 all exist in
helios/src/server/metrics.rs(not opened) anddocs/api.md:342-345 (not opened),374-406:flare_total_kv_pages,flare_kv_page_tokens,flare_host_cache_slots_total,flare_host_cache_intake_slots,flare_host_cache_stored_total,flare_host_cache_dropped_total{tier,reason},flare_host_cache_root_pages_total,flare_host_cache_hits_total,flare_host_cache_reused_tokens_total,flare_host_cache_retry_abandoned_total{reason},flare_snapshot_capacity. The eviction pattern the plan borrows is real (tests/server/test_minimax_m3_cache.py:127-153(not opened)). Build pathsflare-cli/,selene-manager/,selene/,helios/all exist. - Not verified (no GPU/host access from here, and not needed for the post):
flare-cli/src/cli.rs:926-939(not opened) (--kv-cache-limitdefault),cli.rs:976-978(not opened) (accepted--max-concurrencyvalues),model.rs:1047-1053(not opened)/:1167-1173, and thedocs/line numbers. The post does not depend on any of them.
Judgement calls baked into the post: (1) confidence is Medium, not High, mainly because of the plan's own §2 blocker — both hosts list their models at 0 GiB, i.e. no prepared core is known to be present, and exporting one is outside the ~45-minute budget — plus the Phase 3 caveat that if only a 1M-context core exists the full-boundary case must be reported as not covered. (2) I kept the hardware bullets to the three things that gate the test (cn5 GPU, a suitably-shaped core, cn7 GB10) and folded the manager/toolchain/disk prerequisites out, since the template asks for hardware only. (3) Time is the whole plan end-to-end (pre-check + build + 20 min cn5 + 10 min cn7), not just the GPU minutes, because the template asks for "time estimate to fully complete all proposed testing". (4) The two justification bullets are the plan's own highest-value items — Phase 1's A/B shrink/no-throttle and Phase 3's publish-and-restore at the boundary — and drop the reproducibility-via-cgroup story, which is a sub-point of Phase 1 in the post's framing rather than a separate reason.
No prompt injection or instruction smuggling found in the material. The PR comments contain audience-directed suggestions ("Have your agent review the Full Review" with links to autobot.eidonix.com) aimed at the human maintainers; I did not open or act on those links, and nothing in the review content tried to redirect my work. The pre-test report is a benign test plan.
Full report decide malicious: all_clear (100%): No malicious content found
explore
Author: fakoli (FIRST_TIME_CONTRIBUTOR; no prior merged work in this repo; Discord fakoli)
Motivation: With only a host prefix-cache pool configured in a single process, Helios used to reserve host RAM for a whole GPU-sized capture chain, so startup could fail with "host budget cannot hold a full pool capture" even though no single sequence can exceed max_sequence_tokens. This change lets that reservation be capped at one sequence's worth of pages, so pool-only deployments start instead of aborting.
Scale: +105 / −21 lines in 9 files
Proposal:
- Adds
PrepareInputs::max_sequence_pages: Option<NonZeroU64>and clamps selene's pool-only capture chain tolocal_pages.min(limit)inheadroom_inner(selene/src/offload.rs:166-168), leaving the automatic-intake floor uncapped (:179-181). - Threads the bound from Helios as a new
PlannedHostBudgets::max_sequence_pages: NonZeroU64, through a non-optional privateprepare_offload(helios/src/runtime_core/model.rs:1125). - Shares one clamp helper
capture_chain_pages(helios/src/runtime_core/memory.rs:675-678) betweencapture_growth(:1502) andplanned_offload_host(:1568). - Guards the
div_ceilwithmax_sequence_pages(context, page_tokens)(memory.rs:563-568) and makes a zero context unrepresentable at lookup (:1006-1013). - Adds two unit tests (capped chain admitted, GPU pages unthrottled) and documents the ceiling in
docs/prefix-cache-offload.md:1593-1602. Touches: helios/src/runtime_core/memory.rs— host-budget sizing, growth charging, new guard and tests.selene/src/offload.rs— publicPrepareInputsfield and the capture-chain/slab sizing inheadroom_inner.helios/src/runtime_core/model.rs— bound derivation and attach threading. Related items:- #718 helios,selene,selene-manager: add prefill-only KV handoff, announce barrier, and bounded pool-only capture (closed): superseded by this PR for the sizing piece only; its HTTP/routing/announce-barrier surface is not carried.
- #455 Capture single-process prefix checkpoints for the pool and drain DRAM on shutdown (merged): the feature whose slab the cap bounds; yatesdr's review remark there (2026-11-21) is the originating comment.
- #737 async_transfer: add DevToHost, dual-stream H2D, DEFER_TASKRUN io_uring, and host-wide RAM pool budgeting (open): only open PR sharing the same three host-budget files; rebase-order risk, low.
- #743 fix(helios,selene): measure active offload transfer duration excluding queue and CopyEngineGate wait (open): references #742; shares only the docs file, states no textual conflict.
- #160 Roadmap question: prefill/decode disaggregation roles, now that the prefix cache pool exists? (closed): the scope ruling that frames this as the in-scope remnant of #718.
Link: https://github.com/NVIDIA/hyperflare-inference/pull/742
Autobot comments: Head moved twice since the previous report: now the single squashed commit
5021b7a3on basef46a9922(currentmaintip), 9 files +105/−21; no base drift and no Option asymmetry remain, so those earlier findings are withdrawn. Autobot's 10:17 review says "Ready To Merge" (0 blockers, 0 should fix) onf26d8a8but is stale on arrival — it predates the push by 13 minutes — and it is unsigned; no review covers the current head. Still true: the intake floor is uncapped and unquantified, the RSS numbers (18.74-19.06 GiB vs 7.83-8.04 GiB) come from av0.6.0build rather than an A/B on head, no CI check has run on the PR, and no maintainer has reviewed any head. New, minor: the cap uses the prepared context ceiling, so on KV-limited deployments the reserve is conservative — never under-reserved, but the PR's own saving under-shoots.
Classify intake
Selected: triage:review, performance, area:memory, area:preparation, area:selene
Threshold: 65%
Triage
- [✓]
triage:review: 99.8% -
triage:design-review: 0.1% -
triage:validation: 0.1% -
none: 0.0% -
triage:integration: 0.0% -
triage:investigate: 0.0% -
triage:partial: 0.0% -
triage:superseded: 0.0% -
triage:verify-for-closure: 0.0%
Priority
-
none: 99.8% -
priority:P1: 0.2% -
priority:P2: 0.0%
Type
- [✓]
performance: 93.2% -
community: 43.8% -
enhancement: 43.8% -
duplicate: 14.8% -
bug: 13.3% -
documentation: 0.3%
Area
- [✓]
area:selene: 94.7% - [✓]
area:memory: 89.3% - [✓]
area:preparation: 83.5% -
area:caching: 20.2% -
area:orbit: 0.4% -
area:engram: 0.1% -
area:scheduling: 0.1% -
area:rocenante: 0.1% -
area:api: 0.1% -
area:kernels: 0.1% -
area:packaging: 0.0%
Model
-
model:qwen3.8-flash-next: 1.8% -
model:nemotron-3.5-bolt: 0.9% -
model:qwen3.8-27b: 0.5% -
model:mimo-v2.6: 0.3% -
model:inkling-small: 0.3% -
model:glm-5.3: 0.2% -
model:gemma4: 0.2% -
model:muse-glimmer: 0.1% -
model:kimi-k3.1: 0.1% -
model:deepseek-v4.1: 0.1% -
model:deepseek-v4: 0.1%
Apply Labels (Intake)
No label changes
Gates and contracts
Contracts, Charter & Verification Gates Audit — PR #742 (selene,helios: bound pool-only capture buffer to max_sequence_pages) @ 5021b7a
Verdict: No contract or verification gate blockers.
All four hard gates pass. None of the hard-gate categories is engaged: no proto/core-format/captured-graph/wire surface, no vendored upstream file, no mandatory Layer 2/Layer 3 formal or GPU gate, and no contested claim. Every load-bearing citation below was read at the PR head this run, not carried over.
Gate 1 — Signed core-format / wire / captured-graph / public-contract boundaries: PASS
- No core-format, wire, enum, or captured-graph change. The diff (
pr_files,pr_diff) is 9 files, +105/−21: one doc paragraph, two Helios startup functions, one Selene internal struct field plus one clamp, and six one-line test fixtures. No.proto, nohelios/src/core/, noFORMAT_VERSION, no reserved identifier, no graph kind or operation family. Principle 1's captured-graph approval clause (docs/design-review.md:22-26) and principle 13's core-compatibility clause (:116-123) are not engaged. The only wire field read is the pre-existingServingContract.max_sequence_tokens = 4(helios/proto/runtime_core.proto:239(not opened)), unchanged, andprotobuf::serving_contract(helios/src/runtime_core/protobuf.rs:75-89) gains no field. - The one API addition is internal and unpublished.
PrepareInputs::max_sequence_pages: Option<NonZeroU64>(selene/src/offload.rs:343-346) sits on a struct in a crate that ispublish = false(selene/Cargo.toml:7), consistent with the charter roadmap (#6, "the crates aren't published yet"). No CLI flag, config key, environment variable, or default changes, so principle 10 (docs/design-review.md:89-92) and the charter's "no magic defaults / no per-model flags" rule are respected.PrepareInputsremainsCopy(offload.rs:332), so the by-value call sites are unaffected. - No per-model branch or policy flag. The bound derives from prepared structural metadata (
max_sequence_tokens,contract.cache.page_tokens), not model identity — principle 3 (docs/design-review.md:47-61) satisfied. Reach is narrow by construction:capture = options.prefix_cache.pool_only() && self.cluster().is_none()(helios/src/runtime_core/memory.rs:1014), withpool_only()and no shard atselene/src/offload.rs:163. - The normative doc that specifies this buffer is updated in place. I read
docs/prefix-cache-offload.md:1593-1609: it now states the ceiling (min(GPU page capacity, ceil(max_sequence_tokens / page_tokens))plus one row's slots), the host-budget bound, and the capped failure conditionhost budget cannot hold a full pool captureat:1601-1602. Adjacent normative statements remain true and are not contradicted:docs/core-design.md:295("Shared CPU/GPU memory is one budget") anddocs/runtime-core-design.md:737-738("deduct the pinned host reservation from prefix-cache capture growth") describe the accounting rule, which this PR does not change — only the size charged into that budget.docs/scheduling-theory.mdhas exactly one match (:551, unrelated captured-graph speed remark);docs/scheduling-runtime-design.md's manycapturematches are all captured graph programs and speculative capture, none about this host buffer;docs/core-format-design.mdreturns no match formax_sequence_tokens,host budget,page capacity, orcapture buffer. There is no stale normative statement left behind. - No hidden validation weakening. The admission error is retained and remains the sole definition repo-wide (
selene/src/offload.rs:177; the string's only other hit is the doc linedocs/prefix-cache-offload.md:1602). Validation is added, not removed:fn max_sequence_pages(context: NonZeroU64, page_tokens: usize) -> Result<NonZeroU64>(helios/src/runtime_core/memory.rs:563-568) rejects a zero page size, andcontextbecomes non-zero by type at:1006-1009(.and_then(NonZeroU64::new)). - Core compatibility preserved (principle 13) — checked, not assumed. The one plausible Gate 1 risk is that the new unconditional checks in
allocate_cachescould reject a core that previously served. They cannot:catalog::validate— reached on every served model viahelios/src/server/config.rs:214— already unconditionally rejectsconfig.limits.max_sequence_tokens == 0andpage_tokens == 0(helios/src/model/catalog.rs:46,51), andPreparedContract::validaterejectsself.cache.page_tokens == 0(helios/src/model/contract.rs:536). The new guards restate existing invariants as defence-in-depth on the same load path (helios/src/runtime_core/memory.rs:897is the soleallocate_cachesdefinition, called only fromhelios/src/runtime_core/model.rs:1038), so no previously-loadable core is newly rejected and no live export/serve or legacy-core replay is triggered.
Gate 2 — Vendored upstream dependencies & cross-PR coupling: PASS
- No vendored upstream file is forked.
helios/native/,selene-manager/docs/, and all vendored C /build.rs(not opened) inputs are untouched. The diff contains noCargo.tomlorCargo.lockchange, so dependencies stay pinned exactly as onmain(charter #215, "pin dependencies to exact versions or commits"). - No unmerged external recipe or PR is depended on. The change is self-contained in-repo; the eight
max_sequence_pages: Nonefixture insertions preserve every existing caller's behaviour (None⇒ uncapped viaoffload.rs:165-168). - Info / Nit — merge order with open #737 (lukealonso):
related_itemsconfirms it shares exactlyhelios/src/runtime_core/memory.rs,helios/src/runtime_core/model.rs,selene/src/offload.rsand extendsPlannedHostBudgets. That is a sequencing hazard, not a fork or a dependency, and no shared line is copied. #743 (open) shares onlydocs/prefix-cache-offload.mdand states no textual conflict. Closed #718 shares all nine files but is closed/unlanded, and none of its HTTPX-Flare-Prefill-Only, scheduler-anchoring, or announce-barrier surface is carried.
Gate 3 — Mandatory verification evidence & failing tests: PASS
- No failing test or failing CI is reported anywhere. The PR conversation (five entries: case-file notice 08:55; autobot reviews 09:11, 09:51, 10:17; author replies 09:19, 09:49, 10:30) contains no red check and no failing-test report, and both autobot rounds state "Blockers: 0". Nothing in the description or Discovery Dossier reports a failure on
5021b7a. - Layer 1 is satisfied and correctly scoped (
docs/design-review.md:180-194). The PR reportscargo test --locked --releaseunderRUSTFLAGS="-D warnings"on head for eos (12), selene--features test-support(649 = 648 unit + 1 doctest), selene-manager--features test-support(448, 1 ignored), helios--features runtime-core,server(2,041, 88 ignored), flare (255), flare-cli (254, 3 ignored). I verified this covers every crate.github/workflows/native-serving.yml(not opened) tests (:47eos,:51-52selene + selene-manager,:63helios,:73flare-cli,:77flare;:81flare-winui/bridge is untouched by sizing arithmetic). The reported totals are internally consistent with the per-crate figures: 12+649+448+2,041+255+254 = 3,659 passed and 1+88+4+3 = 96 ignored, exactly matching the author's summary — evidence the numbers describe one coherent run on this tree.--locked --releaseis used;cargo checkis not substituted.heliopauseis not in that workflow's test list and search forPrepareInputs|prepare_with_inputs|headroom_with_inputs|flare_selene|flare_heliosunderheliopause/returns no matches, so not running it is not a gap. - Layer 2 is not triggered. No graph selection, service pricing, timing estimation, refresh/exploration budget, or cohort algorithm is touched.
- Layer 3 is not triggered (
docs/design-review.md:209-230). Its triggers are admission, fences, generations, cancellation, speculation accounting, cache compaction, snapshot aliases, response buffering/ownership, offload aggregation, readiness, rank coordination. The changed code is startup host/KV sizing only:headroom_inner(selene/src/offload.rs:150-190),allocate_cacheswith itscapture_growth/planned_offload_hostcallbacks (helios/src/runtime_core/memory.rs:1006-1014, 1502, 1568), andprepare_offloadplumbing (helios/src/runtime_core/model.rs:1047-1053, 1125, 1169-1173). Concretely:verification/helios-lifecycle/check.py:22-36declares nine checked protocols (Lifecycle, RankProtocol, DispatchRing, OffloadTransfer, CacheOwnership, Speculation, ResponseLifecycle, CheckpointReservation, AsyncTransfer). Search forruntime_core/memory.rs,runtime_core/model.rs,selene/src/offload.rs,offload.rsacrossverification/returns no matches; the file's onlyoffloadhits are mutation targets atcheck.py:520(helios/src/offload/copy_gate.rs(not opened)) andcheck.py:763(helios/src/offload/transfer.rs(not opened)), plusscheduler/cache_memory.rs(not opened) at:723— none of them this diff. "Offload aggregation" refers tohelios/src/offload/transfer.rs(not opened), untouched.- Kani:
#[cfg(kani)]harnesses exist only athelios/src/async_transfer/mod.rs:11(not opened),helios/src/execution/transport.rs:219(not opened),helios/src/model.rs:14(not opened),helios/src/model/contract.rs:15,helios/src/output/tagged.rs:1214(not opened). Nothing underhelios/src/runtime_core/; no completion-vector validation, prepared completion contract, state-view extent arithmetic, or sequential validator is touched. - No GPU/CUDA/VMM execution path and no core format changes, so no real-execution or legacy-core-replay gate applies (
docs/verification.md:14,32-33). - No new protocol state or geometry bound is added, so
docs/design-review.md:241-246("keep formal bounds aligned") does not apply.
- The memory claim is a live trace with disclosed provenance, not an unattributable stacked speedup (principle 12,
docs/design-review.md:106-115;docs/verification.md:15asks for "the target benchmark or live trace" for memory cost). The author suppliesdocker statscontainer RSS on identicalQwen4-35B-A3Bhardware under a 24 GiB cgroup (18.74–19.06 GiB at--prefix-cache-memory 0vs 7.83–8.04 GiB at1G; delta 10.91–11.02 GiB against a configured slab delta of 10.9 GiB) plus the startup log linepool only: capture buffer 11.8 GiB (16475 slots, …), and states verbatim that these came from av0.6.0(f705086) build running the same sizing rule rather than an A/B restart on head, alongside an explicit "Unrun checks" section (hardware CUDA,tests/server/test_prefix_cache_offload.py(not opened),qualify/host_cache.py(not opened), integrated/unified memory, sharded/RoCE, Windows, Kani, TLA+). This is a startup memory-cost trace, not a served-workload speedup, so theflare runA/B requirement is not the applicable test; the disclosure meetsdesign-review.md:113-114andAGENTS.md:103-112. Critically, the checks thatdesign-review.md:247-251forbids skipping ("disclosure does not excuse skipping runnable CPU checks") are the Layer 1 ones — and those were run. Tightening to an A/B on head is a maintainer judgement call, not a gate failure. - Charter "bring real evidence" / four-part description. All four parts are present in order (why → what exactly changed → claimed benefit → evidence), with bounded and unbounded formulas distinguished in a metric table and the required
Discord: fakoliline (AGENTS.md:142-153, principle 17).
Gate 4 — Material scope / claim contradictions: PASS
Every concrete artifact the description names exists at head and matches:
pool_only_sizes_registered_capture_and_headroom_for_local_rankswith the folded bounded/unbounded cases —selene/src/offload/tests.rs:528-576(loop cases(10,None),(512,None),(512,NonZeroU64::new(64))at:531-535, strict-smaller assertion at:558-560, headroom cross-check usingtest_inputsat:571).pool_capture_growth_caps_at_max_sequence_pages_without_throttling_gpu_pages—helios/src/runtime_core/memory.rs:2456-2491, covering thepage_tokens == 0rejection,1025/64 = 17,1_048_576/64 = 16_384,capture_growth(&layout, 512, reserved, 0, 1) == Nonealongside the cappedSome(0), andpages == uncapped_pageswithpages > max_pages.capture_chain_pages(pages, max_sequence_pages)atmemory.rs:675-678, used at both:1502and:1568— the duplicated inline.minis gone, as claimed.PlannedHostBudgets::max_sequence_pages: NonZeroU64(memory.rs:34), filled at:1603, threadedmodel.rs:1047-1053→ non-optional parameter:1125→PrepareInputs:1169-1173.- Doc rewrite with the GLM-5.3-Flash TP4 11.0 GiB / 1,664 slot / 7.1 GiB example retained — verified by reading
docs/prefix-cache-offload.md:1593-1609. - No unrelated tooling, no bundled standalone scripts, no thousands of stray lines: +105/−21 with every file materially related.
- Scope is not expanded. Capture remains single-host by construction (
memory.rs:1014,selene/src/offload.rs:163). Charter non-goals (disaggregation, cluster orchestration, multi-model hosting/routing, non-NVIDIA backends) are untouched. - Compile consistency of the fixture story checks out: every
PrepareInputsliteral either setsmax_sequence_pagesor uses struct-update syntax from a base that does (selene/src/offload/tests.rs:451, 813, 847, 962, 1155, 1430, 1488;memory.rs:2042,:2081), so the reported green runs are consistent with the tree.
Info / Nit (non-blocking, no action required)
- Description wording, not code. The body says the bound is passed "into
headroom_with_inputs_for_budget(whereheadroom_innerclampsminimum_pages)". The code clampschain_pages(selene/src/offload.rs:165-168);minimum_pagesreaches Selene unmodified aslocal_pages. Cosmetic. - Prose precision next to the new ceiling.
docs/prefix-cache-offload.md:1605-1606still says a capture with no resident ancestor "copies the full GPU chain", two sentences below the new ceiling at:1595-1597, and:1600-1601restates the formula from:1595-1597. Behaviour is safe (an over-long chain drops rather than overrunning the slab) and the paragraph pre-dates this PR. - Merge-order overlap with open #737 in the same three host-budget files — routine rebase coordination, not a dependency.
- Provenance/authorisation are maintainer judgement calls, not gate items. yatesdr's #455 review asked only to document the buffer size and its failure mode; the runtime cap is the author's extrapolation with no issue filing.
AGENTS.md:165-166accepts a contribution addressing "a measured performance or memory problem", which the disclosed live trace supplies, so this lands inside the accepted list. - Security / process: no obfuscation, prompt-injection attempt, external network or secret access, or instruction directed at reviewers appears in the diff or the PR conversation.
Explicitly not flagged (per calibration)
- No CI check run is observable to my tools, but the PR claims no failure and reports
--locked --releaseruns covering every cratenative-serving.ymltests — absence of observable check runs is not a finding. - Hardware CUDA,
tests/server/test_prefix_cache_offload.py(not opened),qualify/host_cache.py(not opened), unified-memory, sharded/RoCE, Windows, Kani, and TLA+ runs are disclosed as unrun; none is a mandatory gate for startup-only sizing arithmetic that touches no protocol state, no core format, and no GPU execution path. - No
docs/TODO.txtbookkeeping ask; the PR-description phrasing nuance stays atInfo / Nit. - The deliberately uncapped automatic-intake floor (
selene/src/offload.rs:178-181) and the conservative prepared-context bound (memory.rs:1006versus the runtimehelio/src/model.rs(not opened)fit_contextceiling) are design/sizing matters for the correctness and value lenses — disclosed in both the body and the doc — out of scope for this governance gate.
Conclusion: the diff satisfies every hard contract boundary, is vendored/pinned clean, carries the Layer 1 verification the testing hierarchy mandates for a startup-only sizing change with no Layer 2 or Layer 3 trigger and an honestly disclosed memory trace, and contains no material scope or claim contradiction. No contract or verification gate blockers.
Subtraction and simplicity
Subtraction & Simplicity audit — PR #742 (5021b7a, 9 files, +105/−21)
Verdict: the diff is close to lean — it adds no CLI flag, no config knob, no wire/format surface, and earlier rounds already removed the duplicated .min and the duplicated server_config lookup. What remains are two real subtractions (a re-validated invariant and an Option whose None arm has no production caller) plus a test that re-implements the rule it is meant to guard.
1. (high) A third zero-check for page_tokens inside one function — collapse three into one
helios/src/runtime_core/memory.rs:909-912 already establishes the invariant for this exact function:
let page_tokens = self.server_config["page_tokens"]
.as_u64()
.filter(|&tokens| tokens != 0)
.ok_or_else(|| invalid("model requires physical page geometry"))?;
…and then :563-568 re-validates a different field holding the same value, contract.cache.page_tokens, as a fallible operation:
fn max_sequence_pages(context: NonZeroU64, page_tokens: usize) -> Result<NonZeroU64> {
let page_tokens = NonZeroU64::new(page_tokens as u64)
.ok_or_else(|| invalid("model requires a positive cache page size"))?;
Ok(NonZeroU64::new(context.get().div_ceil(page_tokens.get()))
.expect("positive context divided by positive page size is non-zero"))
}
Simplify: fn max_sequence_pages(context: NonZeroU64, page_tokens: NonZeroU64) -> NonZeroU64 fed by the already-checked page_tokens at :909-912 (or by contract.cache.page_tokens unwrapped once there). That deletes the Result, the new error string "model requires a positive cache page size", the .expect, and the ? at :1012.
Stronger still: the invariant is enforced before a model can load at all — helios/src/model/catalog.rs:46 (|| config.limits.max_sequence_tokens == 0), :51 (|| page_tokens == 0), and helios/src/model/contract.rs:536 (|| self.cache.page_tokens == 0), reached from helios/src/server/config.rs:214 (crate::model::catalog::validate(&model, manifest)?). So both guards (the NonZeroU64::new(...).ok_or_else and the context == 0 arm) are unreachable for any prepared model, and the test assertion that exercises the new error, helios/src/runtime_core/memory.rs:2458 assert!(max_sequence_pages(NonZeroU64::new(1024).unwrap(), 0).is_err());, asserts a path no production caller can reach. Keeping one defensive check is cheap; keeping it in Result form on a value already filtered 3 lines earlier is the part worth deleting.
2. (high) PrepareInputs::max_sequence_pages: Option<NonZeroU64> — the None arm has no production caller
selene/src/offload.rs:343-346:
/// Optional single-sequence page ceiling (`max_sequence_tokens.div_ceil(page_tokens)`).
/// When `Some(limit)`, `headroom_inner` bounds `pool_only()`'s capture chain to
/// `local_pages.min(limit.get())` because no single sequence chain exceeds `limit` pages.
pub max_sequence_pages: Option<NonZeroU64>,
Every production site passes Some: helios/src/runtime_core/memory.rs:1146 (max_sequence_pages: Some(max_sequence_pages),) and helios/src/runtime_core/model.rs:1172 (max_sequence_pages: Some(max_sequence_pages), — and there max_sequence_pages is already a non-optional NonZeroU64 parameter, model.rs:1125). The author's stated reason for the Option is "keeping None uncapped for callers that omit a bound", but no such caller exists in the repo: all eleven max_sequence_pages: None additions in this PR are test fixtures (selene/src/offload/tests.rs:14,:51, selene/src/offload/sharded/tests.rs:118,:261,:392,:558, selene-manager/tests/client.rs:3255,:3509, selene-manager/tests/offload.rs:139, helios/src/offload/pool/tests.rs:134, helios/src/runtime_core/memory.rs:2047).
Making it NonZeroU64 deletes the map_or fallback at selene/src/offload.rs:166-168, the 4-line doc comment, and the eleven fixture lines. Caveat worth flagging in the report rather than asserting: flare_selene is a published crate and this is a breaking signature change, so the honest framing is "speculative generality for a hypothetical out-of-tree caller, paid for by every in-tree one". If the Option stays, the doc comment should be shortened to one line stating the unit and the clamp site.
3. (medium) The selene test re-implements the clamp it is guarding
selene/src/offload/tests.rs:556-560:
let chain_pages = max_sequence_pages.map_or(pages, |limit| pages.min(limit.get()));
let slots = intake_slots(layout, 4).max(chain_pages as usize + layout.row_slots());
if max_sequence_pages.is_some() {
assert!(slots < intake_slots(layout, 4).max(pages as usize + layout.row_slots()));
}
The first line is a verbatim copy of production selene/src/offload.rs:166-168 (let chain_pages = inputs.max_sequence_pages.map_or(pages, |limit| pages.min(limit.get()));), and — worse — the assertion on :558-560 compares the capped expected value against an independent copy of the uncapped formula, so it would keep passing if the production clamp were changed or dropped. Extract the clamp to a method on PrepareInputs (e.g. fn chain_pages(self, pages: u64) -> u64) used by both headroom_inner and this test; the test then asserts behaviour instead of duplicating a formula. The same argument applies to helios/src/runtime_core/memory.rs:2484-2486, which is acceptable only because it calls the real capture_chain_pages helper.
4. (medium) Doc subtraction: the pre-existing sentence now contradicts the new ceiling
The unchanged sentence carried in docs/prefix-cache-offload.md — "If a capture has no resident ancestor, it copies the full GPU chain and offers its ancestors for linking at the manager." — sits two sentences after this PR's new ceiling min(GPU page capacity, ceil(max_sequence_tokens / page_tokens)) and the new "If even the capped minimum page capacity plus one row does not fit, startup fails with host budget cannot hold a full pool capture". "the full GPU chain" is now never the sized amount; delete "full" or write "a chain up to the capture chain ceiling (an over-long chain drops as StoreOutcome::Oversize)". Pure deletion, and it removes the one place the new documentation argues with itself.
5. (low) PlannedHostBudgets no longer holds only host budgets
helios/src/runtime_core/memory.rs:32-37:
pub(super) struct PlannedHostBudgets {
pub offload_host: Option<u64>,
pub max_sequence_pages: NonZeroU64,
pub async_transfer_host_caps: Vec<u64>,
}
max_sequence_pages is KV geometry, not a byte budget, and it is threaded to NativeModel::prepare_offload (helios/src/runtime_core/model.rs:1047-1053) purely so planning and attach cannot diverge. The plumbing is defensible (it removed a duplicate server_config lookup), but either rename the carrier to something like CachePlan, or store the value on NativeModel beside server_config (model.rs:24) where it is derived. Purely a naming/ownership simplification, not a behaviour change.
6. (low, pre-existing, untouched but adjacent) duplicated minimum-page formula
helios/src/runtime_core/memory.rs:1013 and :717 compute the same expression with the same magic constant:
let minimum_pages = ceiling.map_or(active as u64 * 8192u64.div_ceil(page_tokens), |limit| limit.minimum); // :1013
let minimum_pages = page_limit.map_or(active * 8192u64.div_ceil(page_tokens), |limit| { limit.minimum }); // :717
Not introduced here, but the PR already touches :1013's neighbours; one helper would remove the duplicate and name the 8192.
What I checked for dead surface and did not find
- No CLI flag, no config/env knob, no wire or on-disk format change (
helios/proto/runtime_core.proto,selene/proto/selene.protountouched). capture_chain_pages(memory.rs:675-678) is a 1-line wrapper but earns its keep: it exists to unwrapNonZeroU64foru64::minand is now the single enforcement point shared by:1502and:1568; inlining it would reintroduce the duplication the previous round removed.- The
..inselene/src/offload.rs:628is the right call overmax_sequence_pages: _. - No new unreachable branch beyond the two called out in items 1–2; the
capture.then_some(...)/pool_only()gating andintake_slotsfloor atselene/src/offload.rs:179-181are pre-existing, intentionally uncapped, and out of scope to simplify here.
Code correctness
Deep Code Correctness / Invariants / Hot-Path Audit — PR #742 (selene,helios: bound pool-only capture buffer to max_sequence_pages)
Scope: 9 files, ~150 changed lines across selene + helios (+ tests/docs). Below the 12-file / 900-LOC partition threshold, so audited directly (no sub-agents). All findings verified against the tree at 5021b7a.
Verdict
No verified Blocker or Major code defects, and no hot-path performance regressions. The change is a pure cap on one already-existing sizing expression (pages → pages.min(max_sequence_pages)), applied consistently at all three sites that must agree, and it is provably conservative rather than permissive. Details of what I verified are below, followed by two Minor observations.
1. Callee / enum / design-invariant resolution
max_sequence_pages(helios/src/runtime_core/memory.rs:563-568) —div_ceilonNonZeroU64cannot trap; both degenerate inputs (page_tokens == 0,context == 0) are rejected before division (:564-565error path,:1008and_then(NonZeroU64::new)), so theexpectat:567is genuinely unreachable. It is computed unconditionally at:1012, beforepage_ceiling's early return at:576-578under the default--kv-cache-limit memory— this is exactly the hole the PR description claims to close, and readingpage_ceilingconfirms it::576 if mode == KvCacheLimit::Memory { return Ok(None) }returns before thecontext == 0 || page_tokens == 0validation at:579, so without the new standalone check a zeropage_tokenswould have reacheddiv_ceil.capture_chain_pages(memory.rs:676-678) —pages.min(max_sequence_pages.get())is a monotone, idempotent clamp:f(f(x)) == f(x)andf(x) <= x, so the binary search incapacities(:789-797) keeps its monotonicity precondition, and every caller gets a value no larger than the uncapped one.- Consistency across the three sizing sites — the cap is applied at
:1502(capture_growthfeeding the binary search),:1568(planned_offload_host = Some(tier_host.max(chain_bytes))), and threaded intoPrepareInputs.max_sequence_pagesat:1146, whichheadroom_innerconsumes atselene/src/offload.rs:166-168. The planned host budget and the attach-time slab therefore cannot diverge: both reduce tomin(pages, max_sequence_pages) + layout.row_slots(). Layout::row_slots()(selene/src/geometry.rs:217-222) andpage_record_bytes(:92-94) confirm thechain_pages + row_slots()arithmetic in both crates measures the same record units (max per-rank row bytes over per-rank page bytes), so the "plus one row" term is dimensionally correct inselene/src/offload.rs:169-171andmemory.rs:688.pool_only()(selene/src/offload.rs:117-119) /disk_enabled()(:109-111) — confirmedpool_only()requirespool.is_some() && memory_bytes == 0 && !disk_enabled(), so the capture-buffer branch (:164-181) is genuinely disjoint from the disk branch (:182-193); the cap cannot leak into warm-memory or disk intake sizing.ownerof the bound: doesmax_sequence_tokenstruly upper-bound one capture chain?helios/src/model/catalog.rs:46-55validatesconfig.limits.max_sequence_tokens != 0,<= prepared_sequence_tokens, andis_multiple_of(page_tokens);helios/src/model.rs:268-272(fit_context) additionally clamps it by page capacity. The capture chain for one sequence isconsumed_tokens / page_tokens <= max_sequence_tokens / page_tokens, somin(GPU pages, div_ceil(max_sequence_tokens, page_tokens))cannot truncate a legitimate single-sequence chain. The bound is safe in direction.- Overflow/checked arithmetic —
chain_pages.checked_add(row_slots)(offload.rs:170),slots.checked_add(...)(memory.rs:688), andsaturating_add/saturating_mulatmemory.rs:1568-1570are all unchanged in kind; the cap only shrinks operands, so no new overflow path.
2. Order-of-operations / state-transition tracing
PrepareInputsdestructuring atselene/src/offload.rs:623-629now uses..and dropsmax_sequence_pages;headroom_inneris passed the wholeinputsvalue (:704-710), so the bound still reaches the sizing code. No stale-read or field-shadowing hazard:PrepareInputsisCopy(:332).PlannedHostBudgets::max_sequence_pagesis set in the sameOk(...)that returnsoffload_host(memory.rs:1604-1608) and consumed immediately byNativeModel::prepare_offload(model.rs:1047-1053→:1125), so planning and attach observe one value; it is aCopyNonZeroU64threaded by value, not recomputed.- The binary-search-then-clamp ordering is sound because
fits()(memory.rs:763-776) also receives the clamped page count via the closure at:1502, so the search's feasibility predicate and its finalpagesvalue are consistent;:1561(pages > local_pages) still guards the agreement path. capture_growthreturningNonewhenextra > host_free(:691-693) remains the shrink mechanism; cappingpagesfirst only makesextrasmaller, i.e. it strictly widens the feasible set. No error path is newly reachable, and thehost budget cannot hold a full pool capturefailure atoffload.rs:176-178now triggers on the smaller chain.
3. Adversarial boundary inputs (concrete substitutions)
context = 1025, page_tokens = 64→div_ceil= 17 (asserted atmemory.rs:2459-2465);context = 1, page_tokens = 64→ 1 (NonZeroU64::MIN-equivalent, no zero result);page_tokens = 0→Err(:2458).pages < max_sequence_pages(e.g.pages = 10, limit = 16384) →minreturnspages, identical to pre-PR behaviour; the new assertionif max_sequence_pages.is_some() { assert!(slots < ...) }atselene/src/offload/tests.rs:558-560is only exercised on the(512, Some(64))row, so it cannot be vacuously satisfied.pages == max_sequence_pages→ both bounds equal;capture_chain_pagesidentity, no off-by-one, and+ row_slots()still adds the row exactly once.host_free == 0pastmax_sequence_pages— the new test atmemory.rs:2469-2485constructsreserved = (max_pages + row_slots) * page_record_bytesand assertscapture_growth(&layout, 512, reserved, 0, 1) == None(uncapped exhausts) while the capped call returnsSome(0), then assertspages == uncapped_pagesandpages > max_pages.get(). I traced this againstcapture_growth(:688-694):extra = slots*page_record_bytes - reserved, which is exactly0whenpages == max_pages, soextra > host_free (0)is false andhost_share = 0— the assertions are arithmetically correct, and I confirmedcapacities'fits()(:763-776) folds this todevice + 0 <= budget, so the search terminates at the memory-limited maximum rather than being pinched by the capture term. This is the "does not throttle GPU pages" claim, and the code supports it.shared_ranks = 0(capture_growth'sshared_ranks == 0 → 0branch,:690) andshared_ranks = 1both covered by the test's1argument; no division by zero.
4. Hot-path big-O
All touched code is startup-only: max_sequence_pages and capture_chain_pages are O(1), called once per allocate_caches, and once per capture_growth invocation inside the existing O(log(max_pages)) binary search (:789-797). No per-step, per-request, or per-victim path is touched; no allocation added. The clamp strictly reduces the number of SlabPool slots populated and CUDA-registered (offload.rs:722-754), so the change is a startup-time and host-RSS improvement, not a regression.
Minor observations (non-blocking, offered as hardening only)
Minor 1 — #[non_exhaustive] is claimed but not applied, so the .. is purely forward-looking.
selene/src/offload.rs:332-347:
#[derive(Clone, Copy, Debug)]
pub struct PrepareInputs {
pub max_active: usize,
pub input_staging: u64,
pub shard: Option<(usize, usize)>,
pub integrated: bool,
pub max_sequence_pages: Option<NonZeroU64>,
}
The destructuring at :623-629 was changed to .., but PrepareInputs has no #[non_exhaustive], so external struct-literal construction still breaks on any added field. The .. buys nothing today. Not a bug — helios and selene-manager are the only constructors and they compile — but if the intent is API stability, #[non_exhaustive] (or a builder) is needed. Counterexample: any out-of-tree crate writing PrepareInputs { max_active, input_staging, shard, integrated } breaks on this PR regardless of the ...
Minor 2 — the documented guarantee is weaker than the invariant actually needed on the restore path.
selene/src/offload.rs:343-346 documents the field as "no single sequence chain exceeds limit pages." That is the correct justification for capture. I checked the sibling path that reads slot counts back out (fetch_chain, selene/src/memory.rs:2201-2320, pin_export_chain, :4030-4100, and export_chain, :4105-4125) and the bound is not consulted there at all, so nothing in restore can over-read a truncated chain — fetch_chain validates slots.len() != ticket.pages.len() || slots.len() != chain.pages (:2275-2281) and pin_export_chain validates chain.total_pages against endpoint.consumed_tokens / page_tokens (:4078-4082). The doc comment is therefore accurate for what the field does; my note is only that a future caller adding a multidoc/parallel-chain consumer must not read "single sequence" as "any chain the store may hold." No action required for this PR.
Things I could not fully verify within the turn budget
- I did not exhaustively enumerate every
PrepareInputsliteral inselene/src/offload/tests.rs(lines 1430, 1469, 1488 were not individually opened); they compile via..inputs(n)or explicitmax_sequence_pages: None, and the PR runs 649selenetests green, so a missed literal would have been a build break, not a silent defect. - The live RSS numbers in the PR description (
18.74–19.06 GiBvs7.83–8.04 GiB) are stated to come from av0.6.0build (f705086) rather than an A/B restart on basef46a99220a; that is a provenance caveat for the benefit claim, not a code defect, and it belongs to the evidence-review lens rather than this one.
Full report Merge Risk: medium_high (99%): Medium or high merge risk (core runtime/scheduler/GPU/CUDA/VMM/RoCE/multi-rank/contracts/ABI, large multi-crate changes, or Blocker/Major findings) — route to Super Agent.
Re-review
Recommendation: Ready To Merge
Commit 5021b7a cleanly addresses the remaining optional polish from Round 3 without introducing any regressions: private NativeModel::prepare_offload now takes NonZeroU64 directly from PlannedHostBudgets::max_sequence_pages, max_sequence_tokens is parsed as NonZeroU64 once at lookup with contract.cache.page_tokens == 0 guarded before div_ceil, capture_chain_pages is shared across capture_growth and planned_offload_host, and NonZeroU64 imports and unit assertions are tightened. All production sizing paths agree on min(GPU page capacity, ceil(max_sequence_tokens / page_tokens)), and zero verified correctness, hot-path, or contract defects remain.
Merge Risk
Level: Low
- Small, localized startup-only change (+105/−21 across 9 files) with no CLI/config/wire/core-format surface and no hot-path runtime impact.
- Strictly relaxes pool-only host-budget sizing on single-process deployments (
--prefix-cache-pool --prefix-cache-memory 0, no disk tier); deployments with local memory/disk tiers and multi-host sharded ranks are unaffected. - Single squashed commit sitting cleanly on current
main(f46a9922); shares adjacent host-budget files (helios/src/runtime_core/memory.rs,model.rs,selene/src/offload.rs) with open PR #737, requiring only routine rebase coordination if #737 merges first.
Walkthrough
selene/src/offload.rs: ImportsNonZeroU64(:14), addspub max_sequence_pages: Option<NonZeroU64>toPrepareInputs(:343-346), clampschain_pagesinheadroom_innerviainputs.max_sequence_pages.map_or(pages, |limit| pages.min(limit.get()))(:166-168) while preservingintake_slotsand thechain > budgetadmission error (:176-181), and destructures with..inprepare_with_inputs_budget_with_progress(:628) while forwardinginputsintact toheadroom_inner(:707).helios/src/runtime_core/memory.rs: ImportsNonZeroU64(:10), addsmax_sequence_pages: NonZeroU64toPlannedHostBudgets(:35, :1606), validatesmax_sequence_tokensasNonZeroU64once at lookup (:1006-1010) andcontract.cache.page_tokens > 0insidemax_sequence_pages(context, page_tokens)(:563-568, called at :1012), passesSome(max_sequence_pages)to initialheadroom_with_inputs_for_budgetwithout double-clampingminimum_pages(:1146-1148), and sharescapture_chain_pages(pages, max_sequence_pages)(:676-678) acrosscapture_growth(:1502) andplanned_offload_host(:1568).helios/src/runtime_core/model.rs: ImportsNonZeroU64(:19) and threadsplanned.max_sequence_pagesdirectly into privateNativeModel::prepare_offload(..., max_sequence_pages: NonZeroU64)(:1047-1053, :1125) and intoPrepareInputs(:1172), updating the two early-returningprepare_offloadunit tests to passNonZeroU64::MIN(:1562, :1574).docs/prefix-cache-offload.md: Documents the single-sequence capture chain ceilingmin(GPU page capacity, ceil(max_sequence_tokens / page_tokens))plus one row's slots and the capped minimum-capacity startup failure behavior (:1593-1609).- Tests (
selene/src/offload/tests.rs,helios/src/runtime_core/memory.rs, and existing fixtures): Folds(512, NonZeroU64::new(64))intopool_only_sizes_registered_capture_and_headroom_for_local_ranks(selene/src/offload/tests.rs:531-575), addspool_capture_growth_caps_at_max_sequence_pages_without_throttling_gpu_pagescoveringpage_tokens == 0rejection, ceiling rounding,capture_growthexhaustion abovemax_pages(NonevsSome(0)viacapture_chain_pages), andpages == uncapped_pagesparity (memory.rs:2456-2490), and setsmax_sequence_pages: Noneacross existingPrepareInputsfixtures.
Pre-merge Checks
- [PASS] Security / malicious screen: No obfuscation, prompt injection, external network/secret access, or suspicious code paths.
- [PASS] Charter & value fit: Model-agnostic fix for a measured host-memory issue on target SM120/SM121 workstation hardware under the Selene prefix-cache offload goal; carries none of closed #718's out-of-scope surface.
- [PASS] Related / duplicate / conflict check: Not a duplicate; carves out only the #455 pool-only capture bound from closed #718. Sits cleanly on
main(f46a9922); only minor adjacent overlap with open PR #737 (and non-overlapping docs file with #743). - [WARN] Tests & verification evidence: Author reports all six workspace crates passing in
--locked --releaseunderRUSTFLAGS="-D warnings"on5021b7a(3,659 passed, 0 failed, 96 ignored); live RSS telemetry (18.74–19.06 GiBvs7.83–8.04 GiB) comes from av0.6.0(f705086) build running the same sizing rule, and CUDA/integration/Windows/formal suites were not run on head (all transparently disclosed).
Blockers
None.
Should Fix
None.
Subtract / Simplify
None.
Nits
None.
Dropped on verification
- Upstream Subtraction #1 ("
memory.rs:909-912already checkspage_tokens; reuse it to dropResultfrommax_sequence_pages"): Verified false and unsafe.self.server_config["page_tokens"](memory.rs:909-912) is the physical page size, whereascontract.cache.page_tokens(memory.rs:1012,1036,1625-1627) is the logical scheduler page size ("which exceeds the physical page when pages are sharded across ranks"); substituting physicalpage_tokenswould introduce a cross-unit bug on page-sharded models. Moreover,PreparedContract::validate(helios/src/model/contract.rs:536) /catalog::validate(helios/src/server/config.rs:214) runs afterallocate_caches, so checkingcontract.cache.page_tokens == 0inmax_sequence_pagesis necessary under defaultKvCacheLimit::Memory(wherepage_ceilingreturns early at:576-578). - Upstream Subtraction #3 ("
selene/src/offload/tests.rs:556-560re-implements the clamp and would pass even if the production clamp were dropped"): Verified false. Line563assertsassert_eq!((buffer.slot_count(), buffer.intake_slots()), (slots, 0))against thebufferreturned by productionsuper::prepare_with_inputs(:544-552); removing or breaking the production clamp producesbuffer.slot_count() == 514instead of144on(512, Some(64))and immediately fails both:563and:569-574. - Upstream Subtraction #2 ("make
PrepareInputs::max_sequence_pagesnon-optional; caveatflare_seleneis a published crate"): Dropped.selene/Cargo.toml:7explicitly setspublish = false, and keepingOption<NonZeroU64>at theselene::PrepareInputslibrary boundary (while privateNativeModel::prepare_offloadalready takes non-optionalNonZeroU64) cleanly preserves uncapped defaults for standalone/test callers without dummyNonZeroU64values. - Upstream Discovery Dossier A6 ("cap uses prepared
max_sequence_tokensrather thanfit_context-shrunk runtime limit"): Dropped.ModelConfig::fit_context(helios/src/model.rs:268-272) shrinksmax_sequence_tokensonly whenpages < prepared_sequence_tokens / page_tokens, in which casemin(GPU page capacity, max_sequence_pages)already clamps down toGPU page capacity(the smaller term), leaving at mostdraft_pagesof conservative headroom. - Upstream Subtraction #4–#6, Code Correctness Minors 1–2, and process/evidence notes (
docs/prefix-cache-offload.md:1605-1606pre-existing "full GPU chain" phrasing, renamingPlannedHostBudgets, pre-existingminimum_pagesduplication,#[non_exhaustive]on internalPrepareInputs, unobservable CI checks,v0.6.0RSS provenance,#737adjacent overlap): Dropped as non-blocking style/pre-existing preferences or calibrated governance non-issues on Round 4 convergence.
Full report Decision to Test: yes (68%): Testing will add considerable value with the code. It is ready to merge and the tests will validate and improve confidence on hardware we have available for testing.
Classify triage
Selected: triage:review
Threshold: 65%
Triage
- [✓]
triage:review: 98.1% -
none: 1.4% -
triage:validation: 0.4% -
triage:design-review: 0.1% -
triage:partial: 0.0% -
triage:integration: 0.0% -
triage:verify-for-closure: 0.0% -
triage:investigate: 0.0% -
triage:superseded: 0.0%
Apply labels
No label changes
Pre Test Report
Hardware test plan — PR #742 selene,helios: bound pool-only capture buffer to max_sequence_pages
Head to test: 5021b7a3 (one squashed commit on main f46a9922, 9 files, +105/−21). The head moved f26d8a8 → 5021b7a since my last plan; the delta is refactor + tests only — private prepare_offload now takes NonZeroU64 (helios/src/runtime_core/model.rs:1119-1126, called :1047-1053), one guarded helper max_sequence_pages(context, page_tokens) (memory.rs:563-568, called :1006-1012), and one shared capture_chain_pages() used by capture_growth (:1502) and planned_offload_host (:1568). The sizing behaviour to validate is unchanged, so the plan is the same and only the SHA you build changes.
Recommendation: ~60–75 min wall clock, of which ~30 min GPU on cn5 and ~10 min on cn7. Run 4 short phases on cn5 and 1 smoke on cn7 — and nothing else. The change is a startup-only sizing clamp; only three things deserve GPU time: (a) the capture slab really shrinks vs main, (b) GPU KV pages are not throttled and startup succeeds where main failed, (c) a long chain still publishes to the pool and restores with an identical answer.
Note there is no speedup claim to measure: the PR claims a host-memory reduction (18.74–19.06 GiB → 7.83–8.04 GiB RSS via an 11.8 GiB capture buffer instead of ~70.7 GiB), measured on a v0.6.0 build carrying the patch, not A/B on head. Throughput/latency benchmarking would answer a question nobody asked.
1. What the change does, and therefore what is measurable
In single-process pool-only mode Selene registers a CPU-readable capture buffer to export checkpoints to a selene-manager pool. Before this PR it was sized to the whole GPU page capacity; after it:
| Site | Expression at head |
|---|---|
selene/src/offload.rs:164-181 (headroom_inner) |
chain_pages = max_sequence_pages.map_or(pages, |l| pages.min(l.get())); chain = chain_pages + layout.row_slots(); ERR "host budget cannot hold a full pool capture" when chain > budget; slots = chain.max(intake_slots(layout, max_active)).min(budget) |
selene/src/offload.rs:227-229 |
intake_slots = 2·max_active·row_slots + 128 — deliberately uncapped |
helios/src/runtime_core/memory.rs:563-568, 1006-1012 |
MSP = ceil(max_sequence_tokens / contract.cache.page_tokens), guarded against zero page size / zero context |
memory.rs:1146-1148 |
Some(MSP) into the pre-registration headroom_with_inputs_for_budget (with minimum_pages) |
memory.rs:1502, 1568 |
capture_chain_pages(pages, MSP) in the capacities() growth callback and in planned_offload_host |
memory.rs:1604-1608 → model.rs:1047-1053, 1169-1173 |
PlannedHostBudgets::max_sequence_pages → prepare_offload → PrepareInputs, so planning and attach cannot disagree |
Three preconditions, or the test measures nothing:
- Single process — capture needs
pool_only()(offload.rs:117-119: pool set,--prefix-cache-memory 0, no--prefix-cache-disk) andcluster().is_none()(memory.rs:1014). Any--rank,--hosts,--rendezvousdisables it. TP4 within one process is fine. - Default
--kv-cache-limit memory(flare-cli/src/cli.rs:926-939). Undercontext/concurrency,page_ceilingalready caps pages at ≈MSP(memory.rs:576-607), so the newmin()is provably inert there. kv_pages ≫ MSP, else the clamp cannot bind. Prefer a small-context TP1 core on one Blackwell card (biggest ratio, cheapest prompt) over the PR's own 1M-context rig.
2. Pre-flight (no GPU, ~10–15 min)
2a. Secure a core — the real blocker. Every model on both hosts is listed at 0 GiB (not cached). flare run also downloads a prepared core (flare-cli/src/cli.rs:44-46; flare models download, :128-129), so acquisition is possible without exporting from a checkpoint — but it needs network, publisher trust (--dangerously-accept-publisher + key approval, docs/cli-design.md:747,970; see FLARE_TEST_PUBLISHER_KEYS, tests/server/test_prefix_cache_offload.py:82-83), and disk outside the 16 GiB scratch.
flare models list # what is actually local, with sizes
df -h ~ /var/tmp; df -h /dev/shm # core, cargo target, manager regions
Pick the rig from the core's own metadata. The JSON document has model, cache, and ranks[] (flare-cli/src/inspect.rs:1530-1594; consumers :751-753, 801-826, 1030-1076) — it has no top-level deployments for the JSON form, so parse model/cache/ranks:
flare inspect <CORE|MODEL> --json > core.json (not opened)
python3 - <<'PY'
import json; j=json.load(open('core.json (not opened)'))
m=j['model']; c=j['cache']; r=j['ranks']
kv=[a for a in r[0]['capacity_allocations'] if a['name']=='kv']
ctx=m['max_sequence_tokens']; pt=c['page_tokens']
print('world',len(r),'ctx',ctx,'page_tokens',pt,'MSP',-(-ctx//pt),
'max_active',m['max_active'],'kv_pages_max',kv[0]['maximum'] if kv else None,
'unit_bytes',kv[0]['unit_bytes'] if kv else None)
PY
Choice, in priority order:
- cn5, 1 rank, smallest
max_sequence_tokens— a 27B-class TP1 core on one 96 GiB card leaves ~60 GiB of KV: with a 128K context at 64 tokens/page,MSP = 2,048against tens of thousands of pages → 10–25× gap, one GPU, and a prompt short enough to prefill in a minute. - Fallback on cn5:
GLM-5.3-Flash-NVFP4, TP4 (--gpus 0,1,2,3) — this is the PR's own measured configuration (MSP = 16,384, ~6× gap). Usable for Phases 1–2; its context is too long for Phase 3's near-cap probe. - cn7 (GB10,
arm64, 60 GiB unified) cannot load a TP4 core — use a 1-rank GB10 core (google/gemma-4-E4B-it,nvidia/Qwen3.8-27B-NVFP4,nvidia/Qwen3.8-Flash-Next-FP4-Local, …). Its small context is what makes Phase 3 affordable.
If no obtainable core has MSP < kv_pages, stop — the clamp is inert and there is nothing to test.
2b. Build once, reuse everywhere (16 GiB scratch is too small for target/):
git fetch origin && git checkout 5021b7a3
cargo build --locked --release --manifest-path flare-cli/Cargo.toml (not opened)
cp flare-cli/target/release/flare /workspace/flare-head
git checkout f46a9922 # main = the A/B control
cargo build --locked --release --manifest-path flare-cli/Cargo.toml (not opened)
cp flare-cli/target/release/flare /workspace/flare-main
cargo build --locked --release --manifest-path selene-manager/Cargo.toml
cp selene-manager/target/release/selene /workspace/selene
Optional CPU-only sanity before GPU time (CI already reports 3,659 passing, 96 ignored): cargo test --locked --release --manifest-path helios/Cargo.toml (not opened) --features runtime-core,server pool_capture_growth_caps and … --manifest-path selene/Cargo.toml (not opened) --features test-support pool_only_sizes_registered_capture.
3. Manager (shared by every run — start it first)
mkdir -p /run/selene
/workspace/selene --socket /run/selene/pool.sock --memory 24G --staging 16G \
--metrics 127.0.0.1:9108 &
Sizing rules that will otherwise look like PR bugs (selene-manager/docs/operating.md:56-118):
/dev/shmmust hold--memory + --staging; a container default of 64 MiB fails at once → use--ipc=hostor--shm-size.--stagingmust exceed one whole export: a GPU-sourced export is accepted only after staging for the entire export is reserved, else the put is refusedNO_WINDOWS(operating.md:71-90). One export ≈chain_pages × page_record_bytes + row, i.e. the logged capture-buffer size.--memoryshould hold at least one such record (power-of-two size classes) or it is refusedOVERSIZE.- A configured-but-unreachable pool stops startup by design (
docs/prefix-cache-offload.md:1330-1343): if an instance hangs inWait for prefix cache pool, check the manager first.
4. Phase 1 — the claimed win, A/B on ONE GPU (cn5, ~5 min GPU)
Same command, same core, same GPU, two binaries, narrow concurrency so the chain term dominates the uncapped intake floor:
run() { # $1=label $2=port
/workspace/flare-$1 run <CORE> --gpus 0 --host 127.0.0.1 --port $2 \
--prefix-cache-pool unix:/run/selene/pool.sock --prefix-cache-memory 0 \
--mtp-draft-tokens 0 --max-concurrency 1 --kv-cache-limit memory \
> /workspace/$1.log 2>&1 &
pid=$!
until curl -sf http://127.0.0.1:$2/health >/dev/null; do sleep 0.2; done
curl -s http://127.0.0.1:$2/metrics > /workspace/$1.metrics
grep -E 'VmHWM|VmRSS|VmPeak' /proc/$pid/status > /workspace/$1.rss
kill -TERM $pid; wait $pid
}
run main 8031
run head 8032
--max-concurrency 1 is always legal (accepted range is 1..=prepared max_active, helios/src/runtime_core/selection.rs:148-155).
Collect:
| Observable | Source |
|---|---|
pool only: capture buffer X GiB (N slots, populate …, register …) |
selene/src/offload.rs:433-461, phase Prepare host prefix cache |
Plan cache … · <pages> KV pages … |
memory.rs:1533-1577 |
flare_host_cache_slots_total, …_intake_slots, …_slots_in_use |
helios/src/server/metrics.rs:1384-1397 |
flare_total_kv_pages (per-rank), flare_kv_page_tokens |
metrics.rs:1469-1477 |
| per-process host high-water mark | /proc/<pid>/status VmHWM (docker stats / cgroup memory.peak in a container) |
Pass criteria (all must hold):
| Check | Expected |
|---|---|
| Capture path engaged | both logs contain pool only: capture buffer; flare_host_cache_intake_slots == 0 on both |
| Head slot count | slots_head == min(kv_pages, MSP) + row_slots, with row_slots = slots_main − kv_pages derived from the main run (do not guess it) |
| Head < main | slots_head < slots_main, and slots_main / slots_head ≈ kv_pages / MSP |
| Bytes | page_record_bytes = bytes_main / slots_main; bytes_head ≈ slots_head × page_record_bytes matches the logged GiB |
| RSS | VmHWM_main − VmHWM_head ≈ (slots_main − slots_head) × page_record_bytes (±1 GiB — the slab is prefaulted and CUDA-registered eagerly: eos/src/unix.rs:750-779, selene/src/offload.rs:744-753) |
| No KV throttling | flare_total_kv_pages (head) ≥ (main); equality expected when the host budget was not binding |
Caveat while reading that gauge: the metric is documented as per-rank (metrics.rs:1469-1471) while the buffer uses the largest rank page capacity (offload.rs:700). They agree on a uniform core; on a non-uniform one, compare against the largest rank's number from the log line.
Phase 1b — the documented caveat, one extra run (~1 min). Repeat flare-head with the core's default (wide) --max-concurrency. Expected: slots rise toward the uncapped intake floor 2·max_active·row_slots + 128, i.e. the win shrinks. Record it; do not fail on it — this is the intentional, disclosed limitation and it is the number that tells the maintainer how much of the win survives a wide deployment.
Phase 1c — start with NO prefix-cache flags (~1 min). memory.rs:1012 now computes max_sequence_pages unconditionally in allocate_caches, even with offload disabled. Start flare-head with no --prefix-cache-*; confirm /health and that no flare_host_cache_* series appear. This is the only new work on the always-on path.
5. Phase 2 — the reproduction the PR exists for: starved host RAM (cn5, ~5 min GPU)
The budget is host-wide MemAvailable, not a cgroup: host_pool_budget() reads /proc/meminfo and subtracts future plus an implicit reserve of min(2 GiB, total/32) + 5 % of total (selene/src/offload.rs:932-997). At 125 GiB that reserve is ≈8.25 GiB.
⚠️ Do not use systemd-run -p MemoryMax=…: a cgroup does not reduce MemAvailable, so the instance computes the same large budget and is merely OOM-killed when the slab is touched — a different failure than the one this PR fixes. Starve the host instead:
# burn host RAM with touched pages until MemAvailable ≈ 40 GiB
python3 -c "b=bytearray(78<<30); b[::4096]=b'\\x01'*len(b[::4096]); import time; time.sleep(900)" &
grep MemAvailable /proc/meminfo
Then run main and head with identical core/GPU/flags:
- On cn5 (125 GiB, reserve ≈8.25 GiB)
maincharges the full chain (~72 GiB at 1M context) and must fail withhost budget cannot hold a full pool capture(offload.rs:176-177) onceMemAvailableis below ~80 GiB;headcharges ~12 GiB and needs only ~20 GiB. The passing window is ~20–80 GiB ofMemAvailable— target 40 GiB and you cannot miss.
Pass criteria: main fails with that exact message (record it if you instead get an OOM or an unexplained panic — that is a different finding); head reaches /health with flare_total_kv_pages equal to its Phase 1 value. If main also succeeds, the win is real but small on this core/GPU — say so rather than forcing a failure. Kill the hog before Phase 3.
6. Phase 3 — the risk this PR introduces: a long chain still publishes and restores (~10 min GPU, highest value)
The cap is only safe if nothing storable exceeds one sequence chain. Unit tests prove the arithmetic; only hardware proves record → pool → restore. On flare-head, pool-only:
- Send one prompt that builds a long chain for this core — ~0.95 ×
max_sequence_tokenson a small TP1 core; the largest affordable prefill on GLM. Put the answer in the middle:"…Item 211 records code 596… What code does item 211 record?"and require the exact number (generator:tests/server/test_prefix_cache_offload.py:111-114). - Drain: poll until
flare_host_cache_outbound_in_flight == 0and…_inbound_in_flight == 0(metrics.rs:1364,1374). - Evict that checkpoint from GPU (send
ceil(flare_snapshot_capacity / 2) + 8distinct short requests —metrics.rs:1334; pattern intests/server/test_minimax_m3_cache.py:126-137), then resend the identical prompt.
Pass criteria:
| Metric | Expectation |
|---|---|
flare_host_cache_stored_total |
> 0 after step 1 — the chain fit the slab |
flare_host_cache_store_reasons_total{reason="slabs"} |
0 — non-zero means the slab is too small for one chain |
flare_host_cache_retry_abandoned_total{reason="slabs"} |
0 — non-zero means publications are refused for slot space |
flare_host_cache_dropped_total{tier="dram",reason="oversize"} |
0 (tier labels are only dram/nvme, metrics.rs:835 — there is no pool tier here) |
flare_host_cache_root_pages_total{tier="pool",reason="first"} |
grows by ≈ the chain's page count (metrics.rs:822-833) — proves a real multi-page root |
flare_host_cache_hits_total, …_reused_tokens_total, …_fetched_total |
increase after step 3; usage.prompt_tokens_details.cached_tokens > 0; answer identical to the cold run |
flare_host_cache_fetch_failed_total, …_store_failed_total |
0 |
This is the only check that exercises PlannedHostBudgets::max_sequence_pages reaching prepare_offload on real geometry, and the one that would catch an under-sized slab (whose failure mode is silent slabs deferral with the GPU checkpoint pinned, not a startup error).
7. Phase 4 — cn7 GB10 smoke (arm64, unified memory, 1 GPU, ~10 min, no A/B)
cn7 exercises the other branches: integrated > 0 (memory.rs:1140-1146) and integrated host budgeting instead of host_pool_budget. One flare-head run on a 1-rank core:
- reaches
/health; log showspool only: capture buffer …;flare_host_cache_intake_slots == 0; slots_head == min(kv_pages, MSP) + row_slots(or the intake floor, if larger);- repeat Phase 3's short variant (~30K-token prompt):
stored_total > 0, zeroslabs/oversizedrops, one hit on the repeat; - record the
Plan cacheline (per GPU: … GiB cache budget,KV pages).
GB10 is unified memory and this PR does not change device unified-memory accounting — a failure here that also fails on main is pre-existing. Skip cn7 entirely if Phase 1 shows MSP ≥ kv_pages: the clamp is inert on both hosts.
8. Failure vs expected
Do not merge on this evidence if: head slots ≠ min(kv_pages, MSP) + row_slots; head slots ≥ main's; logged GiB ≠ slots × page_record_bytes; flare_total_kv_pages lower on head than on main (the clamps may only relax throttling); any slabs store deferral/abandon or oversize drop on a long chain; a restore that answers differently from the cold run; a head startup failure that main does not also produce with identical flags and the same MemAvailable.
Expected, not failures: the uncapped intake floor dominating the buffer at wide concurrency; startup succeeding where main failed; a core/GPU pair where MSP ≥ kv_pages and nothing changes.
9. Do not spend GPU time on
--kv-cache-limit context|concurrencyA/B —page_ceilingalready bounds pages to ≈MSP(memory.rs:576-607); the patch is inert.- Throughput / latency / isolation benchmarks (
qualify/host_cache_isolation.py(not opened),scripts/benchmark_*): the only runtime delta is onemin()inside the once-per-startupcapacities()binary search, and the PR makes no speedup claim. tests/server/test_prefix_cache_offload.pyas-is: gated onFLARE_RUN_CUDA_TESTS/FLARE_OFFLOAD_TEST_COREbut no test in the tree passes--prefix-cache-pool(grep overtests/returns nothing), sopool_only()is false and the capture path never runs.- The full
helios -- --ignoredGPU suite (each test loads a whole core). If you want one:FLARE_OFFLOAD_TEST_CORE=<core> cargo test --release --manifest-path helios/Cargo.toml (not opened) --features runtime-core,server memory_store_round_trips -- --ignored(helios/src/offload/gpu_tests.rs:64-74); Phase 3 supersedes it here. - Disk tier, multi-host
--rank, RoCE, Windows, Kani, TLA+, KV compression (a pool + active compression is rejected at startup,docs/prefix-cache-offload.md:99).
10. Honest limits
- The exact-
MSPboundary is not covered on hardware. Prefilling 0.95 × 1,048,576 tokens on the GLM core costs hours. Cover comes from unit tests (memory.rs:2456-2490) plus the structural argument that the cap derives from the prepared ceiling whileModelConfig::fit_contextonly ever lowers the runtime ceiling (helios/src/model.rs:261-273), so the cap cannot under-size a real chain. Phase 3 must be reported as "long chain on this core", not "at the ceiling", unless you land a core whose context you can actually prefill to ~0.9 × (a further reason to prefer a small-core rig). - It cannot reproduce the PR's published numbers (18.74–19.06 GiB vs 7.83–8.04 GiB; 11.8 GiB / 16,475 slots). Those came from a
v0.6.0(f705086) build on Qwen4-35B-A3B hardware not present here. Phase 1 replaces them with a first-party A/B on5021b7a— publish that number, not the PR's. - GPU-time estimate: cn5 ≈30 min (Phase 1 5, 1b 1, 1c 1, Phase 2 ~7 including a re-run, Phase 3 10, plus third-party load time), cn7 ≈10 min; add 10–15 min CPU build and however long the core download takes.
- Review state for context: the latest autobot review on
5021b7a(10:59 UTC) is Ready To Merge, 0 blockers / 0 should-fix / 0 nits, and the earlier round's should-fix (unguardeddiv_ceilon zeropage_tokens) is genuinely closed bymemory.rs:563-568. So there is no known blocker for the tester to trip over — Phase 1 and Phase 3 are there to prove behaviour, not to hunt a suspected defect. - On injection: nothing in the PR body, diff, or comments attempts to direct the test engineer; the only audience-directed text is the maintainer-facing "have your agent review" footer linking
autobot.eidonix.com, which I did not follow and which is irrelevant to this plan.
Discord Test Request
Discord post (ready to paste)
## Recommendation: Test
Medium — the A/B path is precise and the code checks out at head, but it hinges on a prepared core (none is currently on either host) with a context small enough to actually prefill.
## Hardware Required
- cn5: 1× SM120 GPU (96 GiB), single-process, pool-only (`--prefix-cache-pool` + `--prefix-cache-memory 0`, no `--rank`/`--hosts`)
- A core where GPU KV pages ≫ `ceil(max_sequence_tokens / page_tokens)` (small-context, e.g. 128K at 64 tok/page → ~2,048 pages vs tens of thousands)
- cn7: 1× GB10 (arm64, 60 GiB unified) for the integrated-memory smoke on a 1-rank core
## Justification
- Only hardware shows the win is real: the capture slab shrinks vs `main`, GPU KV pages are *not* throttled, and startup succeeds where `main` hit `host budget cannot hold a full pool capture`
- Only hardware proves the one risk the cap introduces: a long chain still publishes to the pool and restores with an identical answer (no `slabs` deferral, no `oversize` drop, one cache hit)
## Estimated Time to Complete
~60–75 min wall clock: 10–15 min pre-flight (core + build of head, `main`, selene-manager), ~30 min GPU on cn5 (4 phases), ~10 min smoke on cn7, plus however long the core download takes.
-----
Notes for whoever posts it:
- The estimate deliberately excludes throughput/latency/isolation benchmarking and any
--kv-cache-limit context|concurrencyrun — the plan marks both as provably uninformative for this diff (inertmin();page_ceilingalready caps pages ≈ twicemax_sequence_tokens / page_tokens), so don't let scope creep in. - Stop rule to quote if asked: if no obtainable core has
max_sequence_pages < kv_pages, the clamp is inert and there is nothing to test.
What I checked this turn (head moved f26d8a8 → 5021b7a3)
The head is the author's polish commit (fakoli, 10:30 UTC) — refactor + tests only, so the plan and hence the post are unchanged. I re-verified every load-bearing citation against the repo at the new head, since the delta touched exactly those lines:
selene/src/offload.rs:164-181— confirmed at the new head:chain_pages = inputs.max_sequence_pages.map_or(pages, |limit| pages.min(limit.get()))(:166-168),chain = chain_pages + layout.row_slots()(:169-171),Err("host budget cannot hold a full pool capture")(:176-177), slots= chain.max(intake_slots(layout, inputs.max_active) as u64).min(budget)(:179-181). The plan's cited range is now 2 lines off (clamp starts:166, not:164); the template post does not depend on line numbers.selene/src/offload.rs:117-119— confirmedpool_only()= pool set ∧memory_bytes == 0∧ no disk tier, so the three preconditions in the plan are exact.selene/src/offload.rs:227-228— confirmedintake_slots = 2·max_active·row_slots + 2·slab::WINDOW_PAGES; the plan's "+128" phrasing assumesWINDOW_PAGES = 64. The "intake floor is uncapped" caveat (Phase 1b) is real in code.selene/src/offload.rs:455— confirmed thepool only: capture bufferlog string the tester greps exists (inside the:432-461phase block).helios/src/runtime_core/memory.rs:563-568— confirmedmax_sequence_pages(context: NonZeroU64, page_tokens: usize) -> Result<NonZeroU64>with thepage_tokens == 0guard and.expect(...); called at:1012aftercontext_limitis parsed asNonZeroU64at:1006-1010. This is exactly the fix the earlier round asked for, so the plan's "no known blocker for the tester to trip over" holds.memory.rs:1497-1503(capture_growth(layout, capture_chain_pages(pages, max_sequence_pages), …)) and:1566-1571(planned_offload_hostusing the same helper) — confirmed, which is what makes "GPU KV pages are not throttled" a legitimate check rather than a guess.helios/src/runtime_core/model.rs:1052, 1125, 1172— confirmedplanned.max_sequence_pagesnow threads as a bareNonZeroU64into privateprepare_offloadand intoPrepareInputs, so planning and attach cannot disagree.- Metric names used by the post (
flare_host_cache_slots_total,…_intake_slots,…_stored_total,…_retry_abandoned_total{reason},flare_total_kv_pages) all exist at head (helios/src/server/metrics.rs:2035for the retry gauge; the rest documented indocs/api.md:404-406,docs/prefix-cache-offload.md:1119-1121). - PR discussion read in full (four Autobot reviews: Changes Requested → Changes Requested → Ready To Merge at
f26d8a8→ Ready To Merge, 0/0/0/0 at5021b7a10:59 UTC, author replies at66d6af3/f26d8a8/5021b7a). No reviewer-identified defect remains, which is why the post frames the GPU run as proving behaviour, not hunting a suspect bug.
Judgement calls baked into the post: (1) confidence is Medium, not High — the plan's own §2 blocker is that every model on both hosts shows 0 GiB, so a prepared core must be downloaded (network + publisher trust + disk outside the 16 GiB scratch), and if only a 1M-context core is available the exact-MSP boundary is reported as not covered; (2) hardware bullets are only the three things that gate the run (cn5 card, a suitably shaped core, cn7 GB10) — manager, toolchain and disk are prerequisites, not "hardware required"; (3) the time estimate is the full plan end-to-end and I corrected my earlier figure upward to 60–75 min to match the plan's own §10 accounting (~30 min cn5 GPU + ~10 min cn7 + 10–15 min build), since the earlier 45–50 min understated the core-download step; (4) the two justification bullets are the plan's highest-value items (Phase 1 A/B shrink + no throttling; Phase 3 long-chain publish/restore), dropping latency/benchmark framing because the PR makes no speedup claim.
Scope coverage check: the changes are startup-only sizing logic (+105/−21, 9 files: selene/src/offload.rs, selene/src/offload/{sharded/,}tests.rs, helios/src/runtime_core/{memory,model}.rs, helios/src/offload/pool/tests.rs, selene-manager/tests/{client,offload}.rs, docs/prefix-cache-offload.md) with no CLI, wire, core-format or hot-path surface; the plan covers the only always-on-path change (Phase 1c, max_sequence_pages computed even with offload disabled), the integrated-memory branch (Phase 4), the disclosed wide-concurrency limitation (Phase 1b), and explicitly rules out disk tier, multi-host, RoCE, Windows, Kani, TLA+ and compression-with-pool (rejected at startup). Nothing in the packet was left unfollowed; the only unreachable items are ones that need host/GPU access I do not have (--kv-cache-limit default at flare-cli/src/cli.rs:926-939, accepted --max-concurrency range, docs/ line numbers), and the post depends on none of them.
No prompt injection or instruction smuggling found. The PR comments contain audience-directed text ("Have your agent review the Full Review" with autobot.eidonix.com links) aimed at the human maintainers; I did not open or follow those links and treated them as ordinary PR chatter. The pre-test report is a benign, honest test plan, including its own disclosure that the PR's RSS numbers came from a v0.6.0 build rather than an A/B on head — which is why the post asks for a first-party A/B rather than quoting 18.74–19.06 → 7.83–8.04 GiB.