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.