Skip to content

selene,helios: add write-side NVMe and pool spill profitability gate - #694

Open
yatesdr wants to merge 2 commits into
NVIDIA:mainfrom
yatesdr:perf/selene-write-profitability-gate
Open

yatesdr wants to merge 2 commits into
NVIDIA:mainfrom
yatesdr:perf/selene-write-profitability-gate

Conversation

@yatesdr

@yatesdr yatesdr commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked PR: Depends on #674 (stacked on ec2e3db1, rebased onto main 9cd0cfad). Review only the top commit (432d009e: selene,helios: add write-side NVMe and pool spill profitability gate) until #674 lands, after which this branch will be rebased directly onto main and re-benchmarked at head.

Summary

Hybrid-attention models carry fixed per-checkpoint recurrent state rows (often tens to hundreds of MiB) alongside paged KV blocks. Persisting short, unshared prompts to local NVMe or a shared pool consumes disk capacity and write bandwidth even when restoring them later would cost more than half the GPU prefill time saved and therefore be rejected by admission pricing.

This PR adds a model-agnostic, write-side spill profitability gate across selene and helios with zero Protobuf, Ignition, model-core, graph-contract, selene-manager server, or on-disk v4 format changes in the top commit (the top commit updates selene, helios, selene-manager/tests/client.rs fixture initializers, docs/api.md, and docs/prefix-cache-offload.md; the stacked diff against main also includes #674's commits):

1. Helios prefill-savings publication, compaction lineage & metrics

  • Publishes each checkpoint's estimated GPU prefill savings (prefill_saved_ns) via shared estimated_prefill_saved_ns (using estimate_prefill_delta_ns(0, consumed_tokens), falling back to the cold-start prefill_rate EMA only before prefill capacities are measured) on PublishedCheckpoint.
  • Forwards GPU logical evictions and compaction lineage (including unready or deferred surviving heirs via HostStore::compacted) to every attached store so local stores can distinguish genuine forks from linear GPU compactions.
  • Handles StoreOutcome::Unprofitable as a terminal skip (unpinning without deferral or retry) and exports skipped-spill counters in Prometheus metrics (documented in docs/api.md and docs/prefix-cache-offload.md):
    • flare_host_cache_spill_skipped_unprofitable_total{tier="nvme"|"pool"}
    • flare_host_cache_spill_skipped_unprofitable_bytes_total{tier="nvme"|"pool"} (packed stored bytes when already compressed in L1 DRAM, otherwise uncompressed tail+row bytes)
    • flare_host_cache_store_reasons_total{reason="unprofitable"}

2. Selene write-side profitability gate, top-down pool coverage & shared-fork promotion

  • Unified half-prefill threshold (worth_restore): Evaluates local NVMe (DiskStore / CompositeStore, charging both disk read and DRAM-to-GPU upload on streamed temporary-pin writes to match cold CompositeStore::hit) and pool (HostNvme / RemoteNvme, via PoolSpillPolicy::standalone_profitable) spill profitability using uncompressed logical restore bytes, with PoolSpillPolicy hysteresis (>= 5% rate change).
  • Fail-open unpriced & post-restart recovery semantics: When prefill_saved_ns == 0—such as unpriced cold paths or on-disk records recovered by directory scan after a restart (because the v4 on-disk header format is unchanged)—the gate intentionally fails open to unconditional spilling until Helios republishes the key and backfills prefill_saved_ns (documented in docs/prefix-cache-offload.md).
  • Cached top-down PoolCoverage & O(1) clean_slots: Maintains top-down (covered_pages, has_row_ancestor, eligible) in non-flat MemoryStore (skipped on CompositeStore's flat L1 DRAM) and matching top-down coverage in DiskStore, so nested forks credit only marginal pages above any covered ancestor, unanchorable rowless roots are excluded from coverage/eligibility, and MemoryStore eviction checks clean_slots in O(1).
  • Warm L1 DRAM retention & pressure-safe shadow reclamation: Keeps unprofitable short prefixes in L1 DRAM for fast warm multi-turn hits without NVMe writes, excludes uncharged dram_only shadows from disk_reserved_*, backfills prefill_saved_ns when recovered disk records are republished, and reclaims blocking dram_only shadows in batch via Index::remove_nodes (single-pass bucket and child-list cleanup) under NVMe disk pressure so durable roots stay evictable.
  • Cascade & shutdown drain safety: Retains the nearest chain-starting ancestor whenever any profitable rowless record (leaf or interior ancestor, DRAM or NVMe) cascades to a cold manager, forwards TierStore::persisted_in_pool through Tiers, skips unprofitable interior checkpoints on homogeneous cascades, tracks actual completed puts (Stored/Present) for accurate shutdown skip accounting, and uses single-leaf removal so unprofitable-leaf pruning or shadow TTL expiry never unlinks durable or profitable parents.
  • Shared-fork deduplication promotion: Promotes a skipped dram_only prefix to durable NVMe storage once at least two distinct, host-verified descendant branches extend it (canonicalizing voters across compaction lineage and bounding lineage/suppression state across notice resets) and its marginal pages above the nearest durable disk ancestor justify persistence (fork_dedup_profitable).

Compatibility

  • Top commit is purely behavioral within the host-cache spill path (selene, helios, selene-manager/tests/client.rs fixture updates, and docs/api.md + docs/prefix-cache-offload.md).
  • Zero Protobuf, Ignition, model-core, CUDA graph contract, selene-manager server, or on-disk v4 format changes in the top commit; existing exported cores load and serve without re-export.
  • No environment-variable switches and no per-model policy flags.

Measured Results

Live SM120 A/B (4× NVIDIA RTX PRO 6000, pre-existing exported cores without re-export)

Measured on earlier combined development commit 09400ad8 vs base 19ce4a7b across three hybrid EXACT_ROW models (workload: 12 short single-turn prompts + 4 short-to-long growth conversations + 6-way fork over a 500-token system prompt + cold restart; will be re-run against post-#674 main once #674 merges):

Model / Config NVMe Files NVMe Bytes Skipped Unprofitable (Run 1 / Run 2) Cold-Restart Hits Short Warm Avg (vs Cold) Growth T2 Restore (vs Cold) Fork Restore (vs Cold) Parity (pos0 Mismatches / Cross Top-1 Max Diff)
Qwen3.8-Flash-Next TP1 (kvc=off) — gate active 66 → 42 (-36.4%) 6.39 → 4.30 GB (-32.7%) 25 (3.31 GB) / 4 (0.53 GB) 16/16 79.8 ms (268.0, 3.36×) 254.0 ms (984.5, 3.88×) 218.5 ms (927.4, 4.25×) 0 (2 FP4 top-5 tie swaps; cross diff 0.250)
GLM-5.3-Flash TP2 (kvc=gpu) — 0 gated spills (baseline parity) 62 → 62 5.10 → 3.79 GB (compression/retention delta from base branch; 0 gated spills) 0 (TP2 prefill rate below gate threshold; see offline TP4 fleet replay below) 10/10 143.8 ms (333.1, 2.32×) 548.6 ms (1138.7, 2.08×) 535.8 ms (1168.6, 2.18×) 0 / 0.000000 (bit-exact)
DeepSeek-V4.1-Flash TP4 (kvc=off, 12.19 MB row) — 0 gated spills (self-calibrating) 63 → 63 834.8 → 832.2 MB 0 (small row; self-calibrating) 18/18 53.7 ms (219.9, 4.10×) 122.0 ms (634.9, 5.20×) 117.9 ms (567.2, 4.81×) 0 / 0.000006 (bit-exact)

Offline Production .ckpt Header Replay (Read-Only)

Offline simulation replaying exact standalone_spill_profitable + fork_dedup_profitable predicates against read-only .ckpt headers from production pools:

Production Pool (Offline Header Replay) NVMe Read Rate Prefill Rate Break-Even Floor Checkpoints Skipped NVMe Bytes Saved Shared Forks Promoted
GLM-5.3 TP4 (7,824 files / 831.7 GB, med row 119.9 MB) 3.0 GB/s (local) 50k tok/s 5,808 tok 400 (6.82%) 50.95 GB (6.13%) 5
GLM-5.3 TP4 3.0 GB/s (local) 80k tok/s 11,042 tok 995 (16.97%) 136.52 GB (16.41%) 11
GLM-5.3 TP4 1.5 GB/s (pool) 50k tok/s 14,093 tok 1,004 (17.13%) 137.87 GB (16.58%) 11
GLM-5.3 TP4 1.5 GB/s (pool) 80k tok/s 36,626 tok 1,262 (21.53%) 171.99 GB (20.68%) 33
DeepSeek-V4.1 TP4 (20,750 files / 421.2 GB, med row 12.2 MB) 3.0–1.5 GB/s 15k–80k tok/s 147–2,711 tok 4–6 (≤0.03%) 0.05–0.07 GB (≤0.02%) 0–1

Verification

All checks verified on Linux at head 432d009e (stacked on #674 ec2e3db1 / main 9cd0cfad):

  • RUSTFLAGS="-D warnings" cargo check --locked --all-targets: clean across selene (default and --no-default-features), selene-manager, helios (--features runtime-core,server), and flare.
  • selene unit tests (Linux): 640/640 passed.
  • verification/helios-lifecycle/check.py (Linux): 8/8 TLA+ models + all 12 Rust lifecycle checks passed (1,710 Lifecycle, 1,291 RankProtocol, 7,940 DispatchRing, 8,490 OffloadTransfer, 222,817 CacheOwnership, 13,566 Speculation, 365,508 ResponseLifecycle, 68 CheckpointReservation observed Rust transitions).
  • selene-manager release tests (Linux, verified on 9d80cb28): 442/442 passed (205 lib + 237 integration across builder, client, l0, offload, packed, pool_channel, pool_claims, pool_l0, pool_net, pool_relay, and pool_store).
  • helios release lib tests (--features runtime-core,server, verified on 9d80cb28 + targeted scheduler::sharing:: and phase_tests::host_restore_pricing on 432d009e): 1,841/1,841 runnable passed (excluding root-chmod and FLARE_TEST_TEMPLATE_DIR-gated template tests).
  • flare release tests (Linux, verified on 9d80cb28): 254/254 passed (246 bin + 7 + 1 integration).

Discord: D-Rock

@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 694.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot flare-autobot added area:caching Prefix/KV reuse, cache retention, and model or payload cache behavior. area:selene Selene shared prefix-cache pool, protocol, manager, and transfers. enhancement New feature or request performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness. labels Dec 2, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The core write-side profitability gate, top-down pool coverage, O(1) clean_slots accounting, dram_only warm L1 retention, compaction-lineage canonicalization, and cascade anchor retention are technically sound — no correctness, safety, or concurrency blockers found at head d74e810. Changes are requested because the PR is stacked on unmerged #674 with headline A/B numbers measured on an earlier combined dev commit (09400ad8) and no reported verification/helios-lifecycle/check.py result, and because the new metrics, StoreOutcome::Unprofitable, and fail-open/cold-restart semantics are undocumented.

  • Blockers: 0 · Should fix: 2 · Subtract/Simplify: 5 · Nits: 2
Walkthrough
  • Pricing & trait surface (selene/src/store.rs:261-293, 396-399, 454-467, 496-550): Adds PublishedCheckpoint::prefill_saved_ns, StoreOutcome::Unprofitable, StoreStats::spill_skipped_unprofitable[_bytes]: [u64; 2], PoolSpillPolicy with 5% hysteresis (materially_differs_from), HostStore::compacted, TierStore::{set_pool_spill_policy, spill_eligible_pool, persisted_in_pool, record_is_packed}, and pure predicates standalone_spill_profitable (reusing worth_restore, fail-open when prefill_saved_ns == 0) and fork_dedup_profitable.
  • Local NVMe gate, warm L1 retention & fork promotion (selene/src/composite.rs:447-907, 984-1036, 1856-1966, 2115-2144, 2299-2313, selene/src/disk_store.rs:2186-2264, 2612-2669, 3482-3664, selene/src/shared/index.rs:521-575): Unprofitable checkpoints stay in L1 DRAM (dram_only) with uncharged disk-index metadata, are excluded from disk parent selection so durable children never depend on them, reclaim blocking shadows in batch via Index::remove_nodes under disk pressure, and promote to durable NVMe once fork_dedup_profitable triggers across distinct canonicalized descendant branches.
  • Pool coverage, O(1) clean_slots & cascade safety (selene/src/memory.rs:341-444, 769-856, 961-1056, 1137-1194, 1243-1528, 1612-1710, 1754-1878, 3694-3705, selene/src/pool/cascade.rs:131-200, 286-381, 434-558, selene/src/pool/local.rs:35-39, 131-150, selene/src/pool/store.rs:199-258, 603-610): Maintains cached top-down PoolCoverage { eligible, covered_pages, has_row_ancestor } and reclaimable_clean_slots in MemoryStore (with matching top-down evaluation in DiskStore), forwards TierStore policy/status hooks through Tiers, skips unprofitable interior checkpoints on homogeneous cascades, and preserves chain-starting ancestors for profitable rowless records and raw/packed representation boundaries.
  • Helios prefill pricing, compaction lineage & metrics (helios/src/server/runtime.rs:2917-2975, helios/src/scheduler.rs:683, 1996, helios/src/scheduler/sharing.rs:12, 46-156, helios/src/server/metrics.rs:529-539, 632-637, 872-885, 922-933): Publishes prefill_saved_ns from estimate_prefill_delta_ns(c, 0, c, ...) with cold EMA fallback, forwards bounded compacted_ancestors via HostStore::compacted, handles StoreOutcome::Unprofitable by unpinning without deferral, and exports flare_host_cache_spill_skipped_unprofitable[_bytes]_total{tier="nvme"|"pool"} plus reason="unprofitable" on flare_host_cache_store_reasons_total.
Merge Risk: Medium · up to d74e810
Pre-merge checks: ✅ 1 passed · ⚠️ 3 warnings

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

@yatesdr
yatesdr force-pushed the perf/selene-write-profitability-gate branch 2 times, most recently from 81d3b30 to 432d009 Compare December 3, 2026 04:25
@yatesdr

yatesdr commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator Author

Restacked onto #674 (ec2e3db1, rebased onto main 9cd0cfad) and pushed 432d009e addressing all actionable Autobot review items:

  • Docs (Should Fix #2, Nit #1):
    • Documented flare_host_cache_spill_skipped_unprofitable_total{tier}, flare_host_cache_spill_skipped_unprofitable_bytes_total{tier}, and flare_host_cache_store_reasons_total{reason="unprofitable"} in docs/api.md and docs/prefix-cache-offload.md.
    • Added StoreOutcome::Unprofitable (terminal unpin without deferral/retry) under Publication outcomes and documented prefill_saved_ns == 0 fail-open semantics (including scan-recovered on-disk records after restart until republished) in docs/prefix-cache-offload.md, and clarified line 698 to "parked DRAM records".
  • All 5 Subtract / Simplify cleanups:
    1. Removed self.memory.set_pool_spill_policy(policy) in CompositeStore and guarded pool_coverage / set_pool_spill_policy on !self.flat in MemoryStore.
    2. Simplified CompositeStore::record_is_packed to self.disk.record_is_packed(key).
    3. Deduplicated estimated_prefill_saved_ns / estimated_prefill_saved_seconds in helios/src/server/runtime.rs.
    4. Moved standalone_profitable onto PoolSpillPolicy (removing duplicated memory/disk helpers) and simplified CompositeStore::standalone_nvme_bytes to return a single u64.
    5. Deduplicated pool_spill_policy_for in selene/src/pool/store.rs.
  • Verification & PR description (Should Fix #1, Nit #2):
    • Ran python3 verification/helios-lifecycle/check.py (8/8 TLA+ models + all 12 Rust lifecycle checks passed), RUSTFLAGS="-D warnings" cargo check --locked --all-targets across all 4 crates (selene default + --no-default-features), and selene 640/640 on 432d009e.
    • Updated the PR description to clarify top-commit file scope, distinguish the 0-skip A/B rows (GLM-5.3-Flash TP2, DeepSeek-V4.1-Flash TP4) from Qwen3.8-Flash-Next TP1's gated skips, label the production fleet table as an offline .ckpt header replay, and note that a post-#674 head A/B rerun will follow once #674 merges.

…tion, NVMe throughput, and GPU snapshot packing

Prefix-cache serving across Selene, selene-manager, and Helios suffered from
four coupled bottlenecks under multi-turn and multi-instance workloads:
resident GPU prefixes bypassed pool lookups even when a deeper prefix existed
in the shared pool, local L1 DRAM records were dropped on pool handover while
unused intake buffers reserved pinned host RAM without local disk, CUDA
snapshot-alias packing over-excluded GPU KV pages under handle-count limits
while wall-clock EMA mispriced host restores, and selene-manager writeback
relied on buffered packed writes, timer-polled waiters, and immediate clean
arena eviction.

This change updates prefix-cache lookup, retention, GPU snapshot allocation,
restore pricing, and manager NVMe writeback across the shared runtime:

- Resident-aware lookup, intake sizing, and telemetry (`selene`, `helios`):
  Keep host and pool lookup active whenever a deeper prefix can extend a
  partially resident GPU prefix (recomputing `pool_plan` and issuing a pool
  lookup if a previously full-GPU-hit queued request loses its GPU prefix
  before dispatch, and retrying local host storage at the same endpoint when a
  pooled row-only hit fails restore pricing); allocate zero local intake slots
  when local disk is disabled and fail startup cleanly on sub-page memory-only
  budgets; preflight doomed L1 evictions before writeback; separate ready
  on-disk inventory (`flare_host_cache_disk_records` / `_bytes`) from
  uncommitted reservations (`flare_host_cache_disk_reserved_*`); and expose
  per-level pool restore rate gauges
  (`flare_host_cache_pool_inbound_bytes_per_second{level}`) using the shared
  `POOL_LEVELS` ordering.
- L1 DRAM retention and non-blocking drain (`selene`, `helios`): Retain clean
  `persisted_in_pool` records in L1 DRAM after pool handover with explicit
  `clean_slots` accounting, decouple capture headroom from intake sizing, and
  run shutdown drain without blocking request teardown.
- GPU snapshot packing, pressure eviction, and restore pricing (`helios`):
  Pack shared GPU snapshot aliases using midpoint-ordered half-width spans and
  per-rank handle budgeting (`plan_mapping_handles`, solving NVIDIA#451); make GPU
  cache eviction pressure-aware (`evict_for_pressure`) while preserving
  dual-turnover reuse protection (`is_protected`), distinguishing pinned from
  unpinned overlapping pairs, and avoiding per-victim allocations via cached
  `only_child` links, reusable page-ref scratch, and prefix-sum range checks;
  price host restores using read-only scheduler prefill-delta estimates
  (`estimate_prefill_delta_ns`, pricing every conditioned window end as
  terminal) shared through `flare_selene::worth_restore` (with a narrowed
  cold-start `prefill_rate` EMA sampled from `step.token_capacity` until
  prefill capacities are measured); track row-restore latency separately per
  source using the lower median without resetting the decay clock on failed
  fetches; derive prefill observation duration from GPU timing with `wall_ns`
  fallback when GPU duration is absent; and record prefill-saved seconds
  directly in `Metrics::host_lookup_cost`.
- Direct compressed I/O, event-driven waiters, and arena retention
  (`selene`, `selene-manager`): Use aligned whole-record `O_DIRECT` writes for
  compressed v4 records (`WriteRecord` / `WritePacked`) with cross-platform
  direct-I/O fallback handling, propagate `Kind::StoreInvalidated = 4` across
  sharded ranks, replace polled waiters with event-driven epoch-tracked wakeups
  (`writeback_waiters` / `inflight_waiters`), retain clean records in manager
  RAM with buddy coalescing on eviction, and resolve waiting put offers
  directly to `Present` when publication covers the offer while rechecking
  upgrades and forks.

Compatibility: On-disk v4 records remain readable across `kvc=off`, `cpu`,
and `gpu` modes without re-exporting model cores or changing Protobuf schemas.
Multi-host TP deployments require matching rank builds for the new internal
rank-relay event `Kind::StoreInvalidated = 4`. Sub-page warm memory budgets
without local disk now fail startup explicitly. Public `flare-selene` trait
and struct signatures (`HostStore::begin_lookup`, `TierStore::retired`,
`TierStore::pending_pool_drain`, `HostHit.pooled`, `StoreStats` reserved/rate
fields, `worth_restore`, `levels::POOL_LEVELS`) are updated in lockstep with
workspace callers. Multi-process TP>=2 packed pool puts remain unsupported by
the existing selene-manager protocol contract.

Measured results on SM120 (4x RTX PRO 6000, baseline `5d53040e` vs pre-refactor
revision `7d7dcdcb`; rebased onto `c513e46a`):
- `DeepSeek-V4.1-Flash` TP4 (24 prompts / 72 checkpoints): GPU shared
  snapshot capacity increased from 1,946 to 4,864 (+2.50x), snapshot-excluded
  KV pages dropped from 5,917 to 2,390 (-59.6%, freeing 3,527 KV pages /
  451K tokens), and pinned intake slots dropped from 1,600 to 0.
- `Qwen3.8-Flash-Next` TP1 (`selene-manager` 512M RAM / 1200M NVMe, 12
  prompts + restart + 6-prompt reread): post-restart cache-hit tokens rose
  from 66.56% to 83.23% (mean latency -28.3%, p50 -42.9%), manager RAM hits
  doubled (1 -> 2), writeback waiter churn dropped 93.1% (87 -> 6), NVMe
  writes dropped 11.5% (2.97 GB -> 2.63 GB), and evictions dropped 20%
  (10 -> 8) with 0 NVMe errors.
- `2x GLM-5.3-Flash` TP2 (`kvc=off` + `selene-manager`, 6x3 multi-turn
  A->B->A): retained 3.65 GiB (35 records) in L1 DRAM (vs 0 B), cut NVMe
  write volume 26.4% (4.10 GB -> 3.02 GB), increased manager NVMe throughput
  2.85x (370.5 MB/s -> 1,054.8 MB/s), cut writeback waiter churn 96.2%
  (293 -> 11), and cut Turn 3 p50 latency 12.2% (0.8614s -> 0.7566s).
- `GLM-5.3-Flash` TP2 local disk (`kvc=gpu`, 1500M limit): byte-identical
  compression ratios (`1.5150x` populate, `1.5166x` reread), 0 codec/verify
  failures, tight eviction enforced under 1500M.
- Cross-node TCP (`2x Qwen3.8` TP1 on SM120 <-> aarch64 `selene` manager):
  0 text mismatches, 88.95% partial-GPU resident-extension cache hits,
  2,388.8 MB/s remote NVMe writes, 0 errors.
- Live saturation, compression under load, and fault-injection recovery on
  SM120: 284/284 HTTP 200 across 16-way tight-manager storms, live manager
  `SIGKILL` + reconnect, `2x GLM-5.3` TP2 VRAM/eviction bursts, `kvc=gpu` /
  `cpu` / `off` 1000M local-disk saturation, live record truncation +
  read-only recovery, and `DeepSeek-V4.1` TP4 64x16w bursts (0 HTTP 500s,
  0 NVMe errors, 0 codec/verify failures, 0 deterministic text mismatches).

Verification: `RUSTFLAGS="-D warnings" cargo check --locked --all-targets`
clean across `selene`, `selene-manager`, `helios` (`--features
runtime-core,server`), and `flare`; Linux tests passed across `selene`
(585/585), `selene-manager` (205/205 lib + 128/128 client/pool integration),
`helios` (1,838/1,838 release lib tests excl. root-chmod and
`FLARE_TEST_TEMPLATE_DIR` tests), `flare` (254/254 release tests), and
`verification/helios-lifecycle/check.py --mutations` (8/8 TLA+ models + all
Rust mutations).

Signed-off-by: yatesdr <6937857+yatesdr@users.noreply.github.com>
Design-Signed-Off-By: yatesdr; design-review=2e5b
Discord: D-Rock
Hybrid-attention models carry fixed per-checkpoint recurrent state rows (often
tens to hundreds of MiB) alongside paged KV blocks. Persisting short, unshared
prompts to local NVMe or a shared pool consumes disk capacity and write
bandwidth even when a future restore would cost more than half the GPU prefill
time it saves and therefore be rejected by admission pricing.

This change adds a model-agnostic, write-side spill profitability gate across
Selene and Helios:

- Helios prefill-savings publication and compaction lineage
  (`helios/src/scheduler.rs`, `helios/src/scheduler/sharing.rs`,
  `helios/src/server/runtime.rs`, `helios/src/server/metrics.rs`): Publish each
  checkpoint's estimated GPU prefill savings (`prefill_saved_ns`) directly from
  `estimate_prefill_delta_ns(0, consumed_tokens)` (falling back to the
  cold-start `prefill_rate` EMA only when prefill timing has not yet been
  measured) on `PublishedCheckpoint`; forward GPU logical evictions and
  compaction lineage (including unready or deferred surviving heirs via
  `HostStore::compacted`) to every attached store; and expose skipped spill
  counters (`flare_host_cache_spill_skipped_unprofitable_total`,
  `flare_host_cache_spill_skipped_unprofitable_bytes_total`) in Prometheus
  metrics.
- Write-side profitability, cached top-down pool coverage, and shared-fork
  promotion (`selene/src/store.rs`, `selene/src/composite.rs`,
  `selene/src/disk_store.rs`, `selene/src/memory.rs`, `selene/src/pool/`,
  `selene/src/shared/index.rs`):
  - Evaluate destination-tier spill profitability using the shared half-prefill
    threshold (`worth_restore` via `standalone_spill_profitable`) against
    observed local NVMe (`DiskStore` / `CompositeStore`, pricing both disk read
    and DRAM-to-GPU upload on streamed temporary-pin writes) and pool
    (`HostNvme` / `RemoteNvme`) restore rates using uncompressed logical
    upload/pool bytes, with policy hysteresis
    (`PoolSpillPolicy::materially_differs_from`, >=5% change), cached top-down
    `PoolCoverage` (`covered_pages`, `has_row_ancestor`, `eligible`) preventing
    nested-fork double-counting and excluding unanchorable rowless roots, and
    O(1) `clean_slots` / `reclaimable_clean_slots` lookup in `MemoryStore`.
  - Keep unprofitable short prefixes resident in local L1 DRAM (serving warm
    multi-turn hits without NVMe writes, excluding uncharged `dram_only`
    shadows from `disk_reserved_*`, crediting actual packed payload bytes when
    available, and reclaiming blocking `dram_only` shadows in batch via
    `Index::remove_nodes` under NVMe disk pressure so durable NVMe roots remain
    evictable). Backfill `prefill_saved_ns` when recovered disk records are
    republished with measured timing.
  - Retain a chain's standalone root predecessor whenever a profitable rowless
    record (leaf or interior ancestor, from DRAM or NVMe) is cascaded to a cold
    manager, forward `TierStore::persisted_in_pool` through `Tiers`, skip
    unprofitable interior checkpoints on homogeneous cascades, map mixed-format
    spans directly by pinned `HostRecord.key` across zero-page interior links,
    count shutdown drain skips from actual completed puts, and use single-leaf
    removal (`remove_single_record`, `remove_uncharged`, `expire_uncharged`) so
    unprofitable-leaf pruning or shadow TTL expiry never unlinks durable or
    profitable parents.
  - Promote a skipped `dram_only` prefix to durable NVMe storage once at least
    two distinct, host-verified descendant branches extend it (canonicalizing
    voters across compacted-heir lineage and bounding lineage/suppression state
    so linear GPU compactions and notice resets do not cast duplicate votes)
    and the page-aligned marginal pages above the nearest durable disk ancestor
    justify persistence (`fork_dedup_profitable`).

Compatibility: Purely behavioral within the host-cache spill path; no Protobuf,
Ignition, model-core, `selene-manager` server, or on-disk v4 record format
changes.

Measured evidence:
- Live SM120 (4x RTX PRO 6000) A/B benchmarks ran on the combined development
  tree `09400ad8` vs base `19ce4a7b` across three hybrid `EXACT_ROW` models
  (where only this write-side profitability gate is active):
  - `Qwen3.8-Flash-Next` TP1 (`kvc=off`, local NVMe): skipped 25 unprofitable
    checkpoints (3.31 GB) on Run 1 (+4 / 0.53 GB on Run 2), reducing NVMe
    footprint -32.7% (6.39 GB -> 4.30 GB) and files -36.4% (66 -> 42),
    preserving 16/16 cold-restart hits (3.88x-4.25x speedup) and warm
    short-turn L1 DRAM hits (79.8 ms vs 268.0 ms cold), 0 mismatches.
  - `GLM-5.3-Flash` TP2 (`kvc=gpu`, local NVMe): -25.7% NVMe footprint
    (5.10 GB -> 3.79 GB), 10/10 hits, 0 mismatches (0.000000 cross top-1 diff).
  - `DeepSeek-V4.1-Flash` TP4 (`kvc=off`, 12.19 MB row): 18/18 hits, 0 false
    skips (self-calibrating), 0 mismatches (0.000006 cross top-1 diff).
- Read-only production fleet replay: `GLM-5.3` TP4 (7,824 checkpoints /
  831.7 GB) saves 6.1%-20.7% NVMe capacity (51-172 GB) while promoting 5-33
  shared forks; `DeepSeek-V4.1` TP4 (20,750 checkpoints / 421.2 GB) skips
  <=0.03%.

Verification: `RUSTFLAGS="-D warnings" cargo check --locked --all-targets`
clean across `selene` (default and `--no-default-features`), `selene-manager`,
`helios` (`--features runtime-core,server`), and `flare`; Linux tests passed
across `selene` (640/640), `selene-manager` (442/442 release: 205 lib + 237
integration across `builder`, `client`, `l0`, `offload`, `packed`,
`pool_channel`, `pool_claims`, `pool_l0`, `pool_net`, `pool_relay`, and
`pool_store`), `helios` (1,841/1,841 release lib tests excl. root-chmod and
`FLARE_TEST_TEMPLATE_DIR` tests), and `flare` (254/254 release tests).

Signed-off-by: yatesdr <6937857+yatesdr@users.noreply.github.com>
Design-Signed-Off-By: yatesdr; design-review=2e5b
Discord: D-Rock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:caching Prefix/KV reuse, cache retention, and model or payload cache behavior. area:selene Selene shared prefix-cache pool, protocol, manager, and transfers. enhancement New feature or request performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants