Recommendation: Changes Requested
The four prefix-cache subsystems in PR #674 are technically sound, well-tested (CI green on 7d7dcdc with 8/8 TLA+ models and mutation guards passing), and free of verified correctness or concurrency blockers; our deep-dive confirmed that several upstream candidate alarms (including an alleged eviction spin loop and metric unit mismatch) were false. However, a small decay-clock reset bug in RowRestoreLatency::start on failed fetches, missing PR-description disclosures for real behavior/wire changes, and A/B benchmarks measured against 5d53040e (four commits behind base 1fbcc3c9, before #663 and #667) should be addressed before merging this +11.2k-line cache-core change.
Merge Risk
Level: Medium
- Large cross-crate cache-core blast radius (+11,210 / −704 across 40 files): Touches GPU VMM alias planning (
helios/src/runtime_core/cache_memory.rs), scheduler eviction/pricing (helios/src/scheduler/), host offload/sharding/direct I/O (selene/), and manager arena/waiter scheduling (selene-manager/src/store.rs), though every core invariant is backed by targeted unit/integration tests and debug assertions. - Operator-visible metric, startup, and wire-event behavior changes:
flare_host_cache_intake_slotsdrops to0without local disk, sub-page memory-only budgets now fail startup cleanly (selene/src/offload.rs:711-717),flare_host_cache_disk_{records,bytes}excludes uncommitted reservations (requiringtests/server/test_conditioned_input_cache.py:144-149to update), andselene/src/shard.rs:470,484adds rank-relay event codeKind::StoreInvalidated = 4. - Concurrent PR overlap: Open PRs
#665(helios/src/cache.rs,docs/prefix-cache-offload.md) and#659(helios/src/runtime_core/cache_memory.rs) edit the same regions; merge order should be coordinated.
Walkthrough
- Resident-aware lookup, zero diskless intake & metric split (
helios/src/server/runtime.rs,helios/src/server/metrics.rs,selene/src/offload.rs,selene/src/pool/store.rs,selene/src/disk_store.rs): Forwards GPU-resident token offsets on pool lookups with a once-per-episode stale-ticket refresh (runtime.rs:3227-3243), allocates zero local intake slots when local disk is disabled (offload.rs:681-685), splits ready disk inventory from uncommitted reservations (disk_store.rs:2788-2929), and exports per-levelflare_host_cache_pool_inbound_bytes_per_second{level}(metrics.rs:1408-1422). - L1 DRAM clean retention & non-blocking drain (
selene/src/memory.rs,selene/src/composite.rs,selene/src/pool/store.rs): Retainspersisted_in_poolrecords in L1 DRAM with invariant-checkedclean_slots/reclaimable_clean_slotsaccounting (memory.rs:1060-1121), decouples capture headroom from disk streaming intake (offload.rs:233-240), and narrows shutdown drain topending_pool_drain()(pool/store.rs:309-313). - GPU snapshot-alias packing, pressure eviction & restore pricing (
helios/src/runtime_core/cache_memory.rs,helios/src/runtime_core/memory.rs,helios/src/scheduler/cache_memory.rs,helios/src/scheduler/checkpoints.rs,helios/src/cache.rs): Admits exact half-width alias planes with midpoint-ordered chunks and symmetric exponential+binary handle budgeting (cache_memory.rs:67-85, 248-319, 654-777), addsevict_for_pressure(scheduler/cache_memory.rs:615-670), and prices restores via read-onlyestimate_prefill_delta_ns(checkpoints.rs:441-481) paired with per-tierRowRestoreLatency(runtime.rs:285-351). - Direct packed NVMe writes, event-driven waiters, clean arena retention & offer coalescing (
selene/src/disk.rs,selene/src/shard.rs,selene-manager/src/store.rs,selene-manager/src/arena.rs,selene-manager/src/pool/): Uses 4 KiB-alignedO_DIRECTwhole-record writes with exactset_lentruncation (disk.rs:848-949, 1353-1478), propagatesStoreInvalidatedacross sharded ranks (shard.rs:470, 650-735), replaces tick-polled put waits with losslessWindowReleaseSignal+ epoch-tracked rotating waiter scans (store.rs:1690-1776, 5277-5281, 5540-5620), retains clean manager RAM extents evicted via buddycoalescing_block(arena.rs:163-200,store.rs:2445-2480), and coalesces matching in-flight put offers.
Pre-merge Checks
- [PASS] Security / malicious screen: No credential handling, external network exfiltration, unsafe bypasses, or prompt-injection issues found;
unsafeslice construction inselene/src/disk.rs:878,1429is bounded by caller-pinned slab/input lifetimes. - [WARN] Charter & value fit: Strongly aligned with the prefix-caching goal, model-agnostic, and fixes open issue
#451; however, A/B tables A–C compare against5d53040e(4 commits behind base1fbcc3c9, before#663and#667), and several behavior changes are omitted from the PR description (charter #210 /docs/design-review.mdPrinciples 12 & 16). - [WARN] Related / duplicate / conflict check: Directly addresses
#451(issue still open and un-updated); overlaps open PRs#665(helios/src/cache.rs,docs/prefix-cache-offload.md) and#659(helios/src/runtime_core/cache_memory.rs) with no agreed merge sequence. - [PASS] Tests & verification evidence: CI passed on
7d7dcdc,verification/helios-lifecycle/check.py --mutations(8/8 TLA+ models + Rust mutations) passed, and new CPU/unit/integration tests cover each mechanism without process-global state leaks; SM120 GPU tables A–F are author-reported without attached raw logs.
Blockers
None.
Should Fix
- Re-baseline headline A/B evidence against
1fbcc3c9and disclose omitted behavior changes in the PR description (docs/design-review.mdPrinciples 12 & 16; charter#210):- A/B tables A–C compare against
5d53040e, which is 4 commits behind the PR base1fbcc3c9(#657,#666,#663,#667, with#663touching scheduler waiting-age pricing and#667touching Orbit/GB10/multi-host peer exports; Table F was run on7d7dcdcb). Re-verify the headline A/B against1fbcc3c9(or confirm#663/#667caused no baseline shift) and update#451with the midpoint half-width conflict-span conclusion. - Add explicit disclosure to the PR body for: (a) sub-page warm memory budgets without local disk now failing startup (
selene/src/offload.rs:711-717), (b) the new rank-relay wire eventKind::StoreInvalidated = 4(selene/src/shard.rs:470,484) requiring matching rank builds in multi-host TP deployments, (c) retention and narrowed sampling of the fallbackprefill_rateEMA (helios/src/server/runtime.rs:2793-2803, 3110-3115, 3334-3335) rather than complete removal, (d) once-per-episode stale pool-lookup ticket refresh (helios/src/server/runtime.rs:3227-3243), and (e) the documentation updates indocs/andselene-manager/docs/operating.md.
- A/B tables A–C compare against
- Prevent
RowRestoreLatency::startfrom resurrecting a decayed latency median on failed fetches (helios/src/server/runtime.rs:302-304):start()unconditionally overwritesbucket.last = Some(now)wheneverbucket.median_seconds.is_some(). If a tier experienced a slow spike long ago (so its estimate has decayed toward zero via the 10 s half-life) and a new row-only restore fails synchronously (store.fetch(...)returnsErr) or asynchronously (finish(&key, false)does not callobserve()),bucket.in_flightreturns to0whilebucket.laststays reset tonow—jumpingestimate_seconds()back to 100% of the stale median for another recovery window.- Fix: Do not overwrite
bucket.lastinstart()(estimate_seconds()already returns the undecayedmedianwhilebucket.in_flight > 0at:341); only refreshbucket.lastinsideobserve()(or upon successful completion).
Subtract / Simplify
- Collapse
TierStore::retiredandTierStore::retired_offeredinto one method (selene/src/store.rs:433-444,selene/src/memory.rs:1185-1189, 3612-3626,selene/src/pool/local.rs:120-137,selene/src/pool/cascade.rs:415):- The trait default forwards
retired_offered -> retired, while every real implementor overrides both and forwardsretired -> retired_offered(&[]). Replace both with a singlefn retired(&mut self, _key: PrefixKey, _tier: PoolTier, _how: Retirement, _offered: &[Retiring]) {}and pass&[]at non-cascade call sites.
- The trait default forwards
- Deduplicate
writeback_wake_cursor/writeback_wake_remainingbookkeeping inselene-manager/src/store.rs(:1586-1594,:1743-1768,:1850-1858,:4161-4168,:4236-4243):- The modulo/clamp cursor fixup is duplicated across six sites, and
close_operations(:4237-4243) omits theremoved_before_cursoradjustment thatresolve_published_waiters(:1571-1591) andexpire_waiters(:1826-1855) perform. Extractremove_writeback_waiter(index)andretain_writeback_waiters(predicate)helpers to own the invariant in one place.
- The modulo/clamp cursor fixup is duplicated across six sites, and
- Pass transfer and prefill seconds directly to
Metrics::host_lookup_cost(helios/src/server/runtime.rs:3408-3415,helios/src/server/metrics.rs:538-560):- Currently
admit_with_host_storecomputeseffective_rate = gained as f64 / prefill_saved_seconds(withf64::INFINITYfor0.0) and clonesHostHitjust to satisfyhost_lookup_cost(&priced_hit, effective_rate), which dividesmissing / rate.max(1.0)right back into seconds (and clamps if0 < effective_rate < 1.0). Accepting(missing_tokens, transfer_seconds, prefill_saved_seconds)directly deletes theHostHit::clone(), thef64::INFINITYtrick, and the round-trip distortion.
- Currently
- Extract
Incoming::clear_pool_lookup(&mut self)inhelios/src/server/runtime.rs(:1800-1803,:2614-2617,:3030-3033,:3044-3047,:3076-3079):- Five sites repeat the same four-field reset (
pool_lookup,pool_lookup_started,pool_lookup_reissued,pool_plan). One helper eliminates the duplication and prevents leavingpool_lookup_reissuedstale on future edits.
- Five sites repeat the same four-field reset (
- Narrow
is_role_preserving_compactionvisibility and simplify the redundant branch inhelios/src/cache.rs(:646-654,:688-695):is_role_preserving_compactionis markedpub(crate)but only called athelios/src/cache.rs:637; make it private. The three-armlet tokens = ...ladder at:688-695can collapse toif role_preserving { 0 } else { self.protected_eviction_tokens(node, rank) }, provided the literal mutation match inverification/helios-lifecycle/check.py:517("let tokens = self.protected_eviction_tokens(node, rank);") is updated in the same commit (and coordinated with#665).
Nits
- Duplicated pool level ordering (
selene/src/levels.rs:121-128,helios/src/server/metrics.rs:1415-1418):Ranking::rates()returns[f64; 4]positionally whilemetrics.rshardcodes the matching label array["neighbour_gpu", "host_dram", "host_nvme", "remote_nvme"]. Co-locating aLevel::ALL/ label constant prevents silent positional drift.
Dropped on verification
- Upstream F7 ("zero-progress eviction can spin
ensure_resources' unbounded loop when every checkpoint is pinned"): False.helios/src/scheduler.rs:1284-1289explicitly checksif evicted.retired.is_empty()and immediately returnsErr(Error::admission(AdmissionError::Capacity, ...)). - Upstream F3 ("
host_transfer_nsmixes wrong units andhost_prefill_nsrecords a fabricated 0 ns"): False.helios/src/server/metrics.rs:917-925exposesflare_host_cache_estimated_transfer_nsandflare_host_cache_estimated_prefill_ns(both estimated durations in ns matchingworth_restore), andestimate_prefill_delta_ns(helios/src/scheduler/checkpoints.rs:438-439) legitimately returnsSome(0)when both start offsets execute the exact same quantized prefill graph sequence. The real cleanup (passing seconds directly withoutHostHit::clone()/f64::INFINITY) was moved to## Subtract / Simplify. - Upstream F1 ("Major correctness bug in
prefill_rateEMA; GPU-only timing biasesworth_restoretoward restores"): Inverted math & overstated. Excluding queue wait (observed_duration_ns) yields a higherprefill_rate, which makesgained / ratesmaller and biasesworth_restoreagainst marginal restores (not toward them), and the EMA is only a cold fallback untilPrefillPredictormeasures each prefill capacity (which learns on all prefill steps). Only the PR-description accuracy gap survives under## Should Fix. - Upstream F2 ("sub-page startup failure is a Major bug and
intake_warningwent dead"): Misread design. Without local disk, intake is intentionally0so an intake-shrinkage warning should not fire (verified inselene/src/offload/tests.rs:684-738), and failing startup cleanly whencheckpoint_memory < page_record_bytesavoids a 0-byteSlabPoolmmap failure and is explicitly documented (docs/prefix-cache-offload.md:169-171) and tested (selene/src/offload/tests.rs:1494-1511). Only PR-body disclosure survives. - Upstream F4 ("lost
StoreEvent::FetchedpinsRowRestoreLatencyforever"): Overstated.StoreEvent::Fetchedis also the sole trigger forscheduler.finish_inbound(helios/src/server/runtime.rs:2850); a store droppingFetchedalready leaks GPU pages/requests by violatingHostStore's core contract, and suspending decay while a slow fetch is actively in flight is deliberate backpressure. Replaced by the actual verifiedbucket.lastreset issue instart(). - Upstream F6 ("
row_conflicts/verify_physical_invariantsare#[cfg(test)]-only andplan_mapping_handlesrebuilds layouts per search step"): Low-signal. Startup-only binary search runs only when handle count exceedsRM_HANDLE_RANGE(524,288) and memoizes identical TP rank geometries (helios/src/runtime_core/cache_memory.rs:706-716); keeping heavyweight verification helpers#[cfg(test)]is standard. - Upstream S4 ("delete
DiskThread::start_with_faults"): Low-value churn.start_with_faultshas 10 existing test call sites across 4 files (selene/src/disk.rs,selene/src/composite.rs,selene/src/disk_store.rs,selene/src/shard/tests.rs). - Upstream minor subtraction on
capture_headroom_slots(selene/src/offload.rs:233-240): Buggy suggestion. The proposed.clamp(1, retention_slots.max(1))would return1instead of0whenretention_slots == 0(breaking the explicit test atselene/src/offload/tests.rs:1528). - Upstream dossier inaccuracies corrected:
5d53040eis 4 commits behind1fbcc3c9(not 6;#656and#638predate5d53040e);eviction_candidate_within_budgetinhelios/src/cache.rs:711-718was retained as a wrapper (not renamed away);helios/src/runtime_core/memory/codec_layout_tests.rswas modified, not newly added.