Repository navigation
Conversation
|
A case file has been opened for 694. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedThe core write-side profitability gate, top-down pool coverage,
Walkthrough
Merge Risk: Medium · up to
|
81d3b30 to
432d009
Compare
|
Restacked onto
|
…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
432d009 to
493621c
Compare
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
seleneandhelioswith zero Protobuf, Ignition, model-core, graph-contract,selene-managerserver, or on-disk v4 format changes in the top commit (the top commit updatesselene,helios,selene-manager/tests/client.rsfixture initializers,docs/api.md, anddocs/prefix-cache-offload.md; the stacked diff againstmainalso includes#674's commits):1. Helios prefill-savings publication, compaction lineage & metrics
prefill_saved_ns) via sharedestimated_prefill_saved_ns(usingestimate_prefill_delta_ns(0, consumed_tokens), falling back to the cold-startprefill_rateEMA only before prefill capacities are measured) onPublishedCheckpoint.HostStore::compacted) to every attached store so local stores can distinguish genuine forks from linear GPU compactions.StoreOutcome::Unprofitableas a terminal skip (unpinning without deferral or retry) and exports skipped-spill counters in Prometheus metrics (documented indocs/api.mdanddocs/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
worth_restore): Evaluates local NVMe (DiskStore/CompositeStore, charging both disk read and DRAM-to-GPU upload on streamed temporary-pin writes to match coldCompositeStore::hit) and pool (HostNvme/RemoteNvme, viaPoolSpillPolicy::standalone_profitable) spill profitability using uncompressed logical restore bytes, withPoolSpillPolicyhysteresis (>= 5%rate change).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 backfillsprefill_saved_ns(documented indocs/prefix-cache-offload.md).PoolCoverage&O(1)clean_slots: Maintains top-down(covered_pages, has_row_ancestor, eligible)in non-flatMemoryStore(skipped onCompositeStore's flat L1 DRAM) and matching top-down coverage inDiskStore, so nested forks credit only marginal pages above any covered ancestor, unanchorable rowless roots are excluded from coverage/eligibility, andMemoryStoreeviction checksclean_slotsinO(1).dram_onlyshadows fromdisk_reserved_*, backfillsprefill_saved_nswhen recovered disk records are republished, and reclaims blockingdram_onlyshadows in batch viaIndex::remove_nodes(single-pass bucket and child-list cleanup) under NVMe disk pressure so durable roots stay evictable.TierStore::persisted_in_poolthroughTiers, 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.dram_onlyprefix 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
selene,helios,selene-manager/tests/client.rsfixture updates, anddocs/api.md+docs/prefix-cache-offload.md).selene-managerserver, or on-disk v4 format changes in the top commit; existing exported cores load and serve without re-export.Measured Results
Live SM120 A/B (
4× NVIDIA RTX PRO 6000, pre-existing exported cores without re-export)Measured on earlier combined development commit
09400ad8vs base19ce4a7bacross three hybridEXACT_ROWmodels (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-#674mainonce#674merges):pos0Mismatches / Cross Top-1 Max Diff)Qwen3.8-Flash-NextTP1 (kvc=off) — gate active66 → 42(-36.4%)6.39 → 4.30 GB(-32.7%)25(3.31 GB) /4(0.53 GB)16/1679.8 ms(268.0,3.36×)254.0 ms(984.5,3.88×)218.5 ms(927.4,4.25×)0(2FP4 top-5 tie swaps; cross diff0.250)GLM-5.3-FlashTP2 (kvc=gpu) — 0 gated spills (baseline parity)62 → 625.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/10143.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-FlashTP4 (kvc=off,12.19 MBrow) — 0 gated spills (self-calibrating)63 → 63834.8 → 832.2 MB0(small row; self-calibrating)18/1853.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
.ckptHeader Replay (Read-Only)Offline simulation replaying exact
standalone_spill_profitable+fork_dedup_profitablepredicates against read-only.ckptheaders from production pools:GLM-5.3TP4 (7,824files /831.7 GB, med row119.9 MB)3.0 GB/s(local)50k tok/s5,808 tok400(6.82%)50.95 GB(6.13%)5GLM-5.3TP43.0 GB/s(local)80k tok/s11,042 tok995(16.97%)136.52 GB(16.41%)11GLM-5.3TP41.5 GB/s(pool)50k tok/s14,093 tok1,004(17.13%)137.87 GB(16.58%)11GLM-5.3TP41.5 GB/s(pool)80k tok/s36,626 tok1,262(21.53%)171.99 GB(20.68%)33DeepSeek-V4.1TP4 (20,750files /421.2 GB, med row12.2 MB)3.0–1.5 GB/s15k–80k tok/s147–2,711 tok4–6(≤0.03%)0.05–0.07 GB(≤0.02%)0–1Verification
All checks verified on Linux at head
432d009e(stacked on#674ec2e3db1/main9cd0cfad):RUSTFLAGS="-D warnings" cargo check --locked --all-targets: clean acrossselene(default and--no-default-features),selene-manager,helios(--features runtime-core,server), andflare.seleneunit tests (Linux): 640/640 passed.verification/helios-lifecycle/check.py(Linux): 8/8 TLA+ models + all 12 Rust lifecycle checks passed (1,710Lifecycle,1,291RankProtocol,7,940DispatchRing,8,490OffloadTransfer,222,817CacheOwnership,13,566Speculation,365,508ResponseLifecycle,68CheckpointReservationobserved Rust transitions).selene-managerrelease tests (Linux, verified on9d80cb28): 442/442 passed (205lib +237integration acrossbuilder,client,l0,offload,packed,pool_channel,pool_claims,pool_l0,pool_net,pool_relay, andpool_store).heliosrelease lib tests (--features runtime-core,server, verified on9d80cb28+ targetedscheduler::sharing::andphase_tests::host_restore_pricingon432d009e): 1,841/1,841 runnable passed (excluding root-chmod andFLARE_TEST_TEMPLATE_DIR-gated template tests).flarerelease tests (Linux, verified on9d80cb28): 254/254 passed (246bin +7+1integration).Discord: D-Rock