Repository navigation
helios: add scan-resistant dual-turnover prefix cache eviction - #665
lukealonso merged 1 commit into
Conversation
|
A case file has been opened for 665. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedPR #665 lands a clean, zero-knob, model-agnostic scan-resistant eviction policy (~68 net production LOC, no flags/floats/
Walkthrough
Merge Risk: Medium · up to
|
a7568c2 to
c919742
Compare
|
Addressed all review items in squashed commit
|
Why
`PrefixCheckpointCache::eviction_candidate_within_budget` previously ordered
removable checkpoints solely by `(RetentionRank { use_epoch, role,
consumed_tokens }, id)` (NVIDIA#568). Because `RequestScheduler::retire` refreshes
`use_epoch` via `cache.touch` on every normal completion (NVIDIA#298, NVIDIA#416), one-shot
cold prefills with zero prefix reuse finished at the most-recently-used end of
the cache ahead of idle multi-turn sessions waiting between turns. Under KV page
pressure, `evict` discarded actively reused multi-turn checkpoints before dead
one-shot leaves.
What
- `helios/src/cache.rs` (`+138/-22`, `116` net LOC incl. test-only stats
invariant): Track cross-request reuse state (`reused`,
`reused_at_evicted_pages`, `reused_at_evicted_nodes`) on `Checkpoint`, plus
`ready_tail_pages`, `evicted_pages`, and `evicted_checkpoints` on
`PrefixCheckpointCache` (counting both retired ready leaves in `retire_leaf`
and compacted ready ancestors in `compact_ancestor`).
- Add `PrefixCheckpointCache::touch_hit` for genuine cross-request prefix reuse
without promoting creator-completion `touch` refreshes, and
`publish_with_retention_with_hit` so duplicate capture publications promote
while waiterless or preempted-only host-store `Existing` restores refresh
demand recency only.
- Inherit reuse protection on a newly published child only when its parent is
protected and `parent_len * 2 >= tail_tokens` (`>= 33%` reused prefix),
protecting linear multi-turn continuations while keeping low-reuse scans that
share a short boilerplate prefix probationary.
- Make demotion sticky: `demote_expired_reused` permanently clears `node.reused`
when retirements since the last reuse hit turn over either both
`ready_tail_pages.max(1)` and `ready_checkpoints.max(1)`, or `2x`
`ready_checkpoints.max(1)` under snapshot-bound or compaction pressure.
- Order `eviction_candidate_within_budget` by `(self.is_protected(node),
node.retention_rank(), node.id)` while keeping `eviction_candidates()`,
`reclaimable_if_pinned`, `RetentionRank`, and optional-capture budget filters
unchanged.
- `helios/src/scheduler.rs` (`+32/-13`, `19` net LOC): Gate GPU-hit `touch_hit`
on `accounting.is_none()`, track per-waiter `(RequestHandle, bool)` freshness
on `Ticket` so cancelling a fresh waiter recomputes freshness from remaining
live waiters, and gate both `Created` and `Existing` `finish_inbound` reuse
promotion on `ticket.waiters.iter().any(|&(_, fresh)| fresh)`.
- `docs/core-design.md`, `docs/scheduling-runtime-design.md`,
`docs/prefix-cache-offload.md`, `helios/README.md`: Reconcile two-tier
protection ordering, child inheritance, sticky turnover aging, and
host-restore admission gating across all cache/offload specifications.
- `helios/src/cache/tests.rs`, `helios/src/cache/lifecycle_tests.rs`,
`helios/src/scheduler/tests.rs`, `helios/src/scheduler/policy_tests.rs`: Add
unit and policy tests for scan resistance, inheritance, sticky demotion,
compaction aging, reused-document regime shifts, per-waiter cancellation, and
`Existing` restore gating, and include reuse/turnover state in
`Fixture::key()`.
Result
Single-boot A/B vs `5d53040e` on 4x NVIDIA RTX PRO 6000 (`DeepSeek-V4.1-Flash`
TP4, core `gb202-tp4-202612010626`, `--kv-cache-limit memory --memory-limit
83GiB --prefix-cache-memory 0`, `2,606,848` KV tokens / `20,366` pages, `n = 2`
cold-salted trials/arm, measured on `a7568c2c` prior to sticky-demotion,
compaction-turnover, and restore-gating hardening):
- Scan-thrash (`24 x 8K` agents vs `8 x 214K` scans, `100s`): hit rate
`33.95% / 8.91%` (mean `19.76%`) -> `51.82% / 25.99%` (mean `37.31%`, `1.89x`),
saved prefill `2,083.8 / 749.6` -> `3,335.5 / 2,228.1 tok/s` (`+96.4%`).
- Long-context multi-turn (`4 x 127K` 4-turn vs `12 x 8K` noise): hit rate
`24.61% / 32.58%` (mean `28.62%`) -> `49.38% / 50.04%` (mean `49.71%`,
`1.74x`), median TTFT `23,886.7 / 22,228.7` -> `2,876.8 / 3,459.5 ms`
(`-86.3%` from avoiding 127K re-prefill queueing stalls), saved prefill `+75.8%`.
Limits: Default-ON with no opt-out flag; under a sudden workload shift, stale
reused entries survive until full dual turnover or `2x` ready-checkpoint
turnover, evicting newly admitted probationary entries first during the
transition window. No effect when KV capacity fits idle sessions without
eviction or active scans exceed total KV capacity. Live GPU A/B ran on
`a7568c2c` with `--prefix-cache-memory 0`; host-restore gating is verified by
scheduler unit tests rather than live offload serving.
Evidence
- Clean-archive Rust release checks & tests atop `1fbcc3c9` (`rustc 1.94.1`,
tree `402aa4794d46`, `RUSTFLAGS="-D warnings"` `0` warnings across `helios
--features runtime-core,server --lib/--tests`, `flare --lib`, `flare-cli
--bins`, `heliopause --features extension-module --lib`):
- `helios --features server --lib`: `1,284 passed; 0 failed; 14 ignored` (`8`
`FLARE_TEST_TEMPLATE_DIR`-gated template tests skipped)
- `helios --features runtime-core,server --lib`: `1,796 passed; 0 failed; 46
ignored` (`8` `FLARE_TEST_TEMPLATE_DIR`-gated template tests skipped)
- Targeted: `cache::` `49` (`server`) / `139` (`runtime-core,server`),
`scheduler::policy_tests::policy_` `6/6`, `scheduler::tests::finish_inbound_`
`5/5`
- `flare --lib`: `246 passed; 0 failed; 4 ignored`
- `flare-cli`: `245 passed; 0 failed; 3 ignored` (`219+9+6+4+7`)
- TLA+ lifecycle & mutation gate (`verification/helios-lifecycle/check.py`,
Temurin JRE `21.0.13+9`, TLA+ `1.7.4`, `--jobs 4`):
- `10/10` TLA+ model configs (`0` errors), `8/8` observed Rust trace suites
(`621,390` transitions total, incl. `222,817` `CacheOwnership.tla`), `12/12`
aux checks passed.
- `check.py --mutations`: `26/26` Rust mutations KILLED, `13/13` TLA+ model
mutations KILLED, and `1/1` `DispatchRing SlotReuseSafe` bad-edge KILLED.
- Python checks: `pytest tests/preparation/test_core_boundary.py
tests/test_scheduling*.py` (`834 passed; 0 failed`); `ruff==0.12.8` reports
`0` issues on PR-touched files (no Python files modified).
Discord: Dooner
Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
c919742 to
c5b3923
Compare
|
Rebased onto
|
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Ready To MergeRebased onto
Walkthrough
Merge Risk: Medium · up to
|
…l swap
Why
Under concurrent mixed prefill and decode load (multiple long cold prompts
competing alongside active decoders), prefill valuation in
helios/src/scheduler/policy.rs and scripts/scheduling_sim/utility.py has two
structural defects:
1. Scalar min_i(rem_i) collapse: clamping the decode-batch coalescing horizon
and expected speculative output across active decoders to min_i(rem_i)
collapses coalescing credit whenever one active decoder nears completion.
2. Multi-chunk prefill lockstep: ServicePrice::observe credits each
intermediate prefill chunk, dropping the executing prompt's normalized
price below untouched peers so long prompts advance in lockstep instead of
completing sequentially and freeing KV pages.
Averaging bounded per-decoder remaining budgets across active decoders prevents
single-stream collapse without inflating credit past the cohort's remaining
output. Recording planned normalized-entitlement swaps among competing
multi-chunk prefills at submission, projecting queued swaps across depth-2
pipelines, and applying the exchange only at validated completion conserves
aggregate prefill entitlement relative to active decoders while preserving
completion-only accounting and rejection safety.
What
- Helios scheduler (helios/src/scheduler.rs, helios/src/scheduler/policy.rs,
helios/src/scheduler/service.rs, helios/src/scheduler/utility.rs; +263/-39,
+224 net non-test Rust production LOC; zero CLI, config, decode, ABI, unsafe,
or lock changes):
- Replaced scalar min_i(rem_i) in coalescing_prefill_log_bonus with the
cohort mean across all active decoders for both speculative expected output
and the coalescing horizon (bounded by coalescing_horizon_tokens and each
prefiller's post-prefill output budget).
- Added ServicePrice::{log_normalized_share, swap_normalized_share},
best_prefill_chunk, stack-allocated heavy_prefill_donors (zero heap Vec
allocations), projected_services, and Submission::prefill_share_swap.
- Multi-chunk pairing activates only when active non-terminal decoders exist
(excluding retiring Snapshot requests), token_fairness > 0,
decode_age_price > 0 (inactive under --scheduler-policy throughput), and at
least two non-terminal, non-prompt_logprobs prefills exceed
prefill_chunk_size (including deferred TerminalPrefill chunks). Single-chunk
prefills (remaining <= prefill_chunk_size) are excluded even when the
highest-throughput chunk c_max is smaller than prefill_chunk_size.
- Submission records any non-self (recipient, donor) handle pair computed
from projected prices without mutating stored prices. Depth-2 projection
(projected_services) applies pending swaps before projecting queued frames.
observe_service executes swap_normalized_share only after
observed_duration_ns returns Some, verifying non-error status, positive
useful_tokens on the recipient, and matching live request handles.
- Python scheduling simulator (scripts/scheduling_sim/utility.py; +105/-7):
mirrored cohort-mean coalescing and weighted-conserving multi-chunk share
exchange (ranking and swapping log_price to conserve aggregate sum q_i across
unequal weights, gated on reference is not None, age_price > 0,
rate_history == "service", and remaining_prefill > max_prefill_cap, using
log-space urgency to avoid overflow on tiny durations, and validating
duration_ms and committed rows before mutating prices or clearing donors).
- Documentation and tests (+127/-35 docs; +784/-0 Rust tests; +245/-0 Python
tests): placed canonical specification and linear-aging preemption limits in
docs/scheduling-utility.md, reconciled docs/scheduling-runtime-design.md,
docs/scheduling-theory.md, and helios/README.md, and added unit tests
covering packed/unpacked speculative cohort-mean, zero-fairness/throughput
opt-out, prompt_logprobs exclusion, single-chunk exclusion below
prefill_chunk_size, arrival-wait aging and tie-breakers, completion-only
depth-2 pipelining, error/zero-timing invariance, Mixed prefill swaps, and
weighted Python conservation.
Result
Measured incrementally atop post-NVIDIA#663 main (1fbcc3c):
- All 21 standard simulator workloads in scripts/scheduling_sim/workloads.py
under both standard and mixed catalogs and both balanced and throughput
policies show zero regressions (0/21 changed).
- --scheduler-policy throughput (decode_age_price == 0) is byte-for-byte
unchanged by share swaps across all tested workloads.
- Under balanced policy on concurrent multi-chunk workloads alongside active
decoders (standard catalog): 2 decoders + 2x16k shifts heavy TTFTs from
[593.1, 678.4] ms to [383.9, 857.2] ms (first -35.3%, mean 320.1 -> 312.5 ms,
max_output_gap_ms unchanged at 217.3 ms, output_tok_s -1.9%, decode_age_area
+6.2%); 4 decoders + 4x16k shifts heavy TTFTs from [1436.0..1637.3] ms to
[788.0, 970.6, 1968.6, 2200.6] ms (first -45.1%, mean 773.5 -> 744.7 ms,
max_output_gap_ms 213.0 -> 226.6 ms, output_tok_s -2.4%, decode_age_area
+7.9%). On mixed catalog: 2 decoders + 2x16k shifts mean TTFT -17.2% (first
-36.9%, gap unchanged 145.0 ms, out -1.8%); 4 decoders + 4x16k shifts mean
TTFT -21.1% (first -57.4%, gap unchanged 114.7 ms, out -1.5%). Live
SM120/SM121 flare run GPU A/B is pending before upstream review.
Evidence
Verified on clean git archive (tree d0c622a) atop 1fbcc3c:
- Merge-tree: 0 conflicts vs upstream/main (1fbcc3c), NVIDIA#660 (9709d49),
NVIDIA#661 (c588d61), NVIDIA#665 (c5b3923), and composed main + NVIDIA#660 + NVIDIA#665.
- Rust builds & tests: RUSTFLAGS="-D warnings" cargo check --locked --release
across helios, flare, flare-cli, and heliopause passed with 0 warnings;
helios --features server --lib 1,284 passed; helios --features
runtime-core,server --lib 1,796 passed (excl. 6 FLARE_TEST_TEMPLATE_DIR
tests); flare --lib 246 passed; flare-cli 245 passed (0 failed).
- Python & simulator: pytest (test_core_boundary.py + test_scheduling*.py) 838
passed; ruff==0.12.8 0 issues; full 21-workload sweep under balanced and
throughput (standard + mixed catalogs).
- Formal & mutations: 10/10 standalone Java TLC configs, 8/8 observed Rust
TLA+ traces (594,065 transitions, 0 errors), 12/12 aux tests, 26/26 check.py
Rust lifecycle mutations + 13/13 TLA+ model mutations + 1/1 DispatchRing
SlotReuseSafe observed-edge check KILLED (0 survivors), plus 13/13 reachable
custom Rust PR mutations and 12/12 custom Python PR mutations KILLED.
- Limits: live SM120/SM121 flare run GPU A/B is pending; learning.py --preset
validate and cargo-kani were not run because their covered code is unchanged.
Discord: Dooner
Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
Why
In Helios's prepared-graph scheduler (`helios/src/scheduler/policy.rs`),
the per-prefill-token decode-batch coalescing bonus
(`coalescing_prefill_log_bonus`) prices the steady-state throughput gain
unlocked when queued prefills join an under-batched active decode cohort
over a bounded output-token horizon (`coalescing_horizon_tokens`, default
64.0). Previously, `coalescing_prefill_log_bonus` reduced all active
decoders' remaining output budgets to a single scalar minimum
(`peer_budget = peer_budget.min(rem)`), and the Python reference scheduler
(`scripts/scheduling_sim/utility.py`) used the same scalar minimum for the
coalescing horizon. Under heterogeneous mixed serving, any single active
decoder within one token of its output limit (`rem = 1`) collapsed both the
speculative per-round expected output (`mean_out`) and the coalescing
horizon to 1 token for the entire cohort, eliminating over 98% of the
coalescing incentive even when all other active decoders had large remaining
budgets.
Averaging per-decoder clamped budgets across the active cohort preserves
accurate continuation value when individual requests approach completion
while still shrinking smoothly as the cohort as a whole approaches its
output limit.
What
- In `helios/src/scheduler/policy.rs::coalescing_prefill_log_bonus` (+11/-10
lines, +1 net Rust production LOC; function visibility unchanged):
- Replace the scalar minimum `peer_budget` with a bounded per-decoder
remaining-budget array (`decoder_rems`), where each `rem` is an active
decoder's remaining output tokens.
- Compute speculative per-round expected output (`mean_out`) by clamping
`expected_at(width)` (speculative expected accepted tokens per round,
evaluated at `eff_width` in the packed branch and `width` in the
unpacked branch) to each active decoder's `rem` and averaging across
`decoder_rems[..decoder_count]`.
- Compute each prefiller's coalescing `horizon` by clamping each active
decoder's `rem` to `min(coalescing_horizon_tokens, post_prefill)`
(where `post_prefill` is the prefiller's remaining output budget after
its first generated token) and averaging across
`decoder_rems[..decoder_count]`.
- In `scripts/scheduling_sim/utility.py` (+2/-6, -4 net Python LOC): replace
`peer_budget = min(v.output_budget for v in decoders)` in the coalescing
horizon calculation with the cohort mean across active decoders, matching
Helios and the existing cohort-mean `mean_out` in `best_decode_rate`.
- In `docs/scheduling-runtime-design.md`: update the coalescing horizon
specification to reflect cohort-averaged per-decoder clamping.
- In `helios/src/scheduler/policy_tests.rs` and
`tests/test_scheduling_utility.py`: add unit tests covering pure Decode,
packed and full-width Speculative cohorts with a near-EOS (`rem = 1`)
decoder alongside a long decoder, single-decoder equivalence, and
zero-decoder / single-token-prefill no-op invariants.
Result
- Single-decoder cohorts and homogeneous-budget cohorts produce identical
values to the prior minimum formula.
- Mixed cohorts with one near-EOS decoder (`rem = 1`) and one long decoder
(`rem = 100`) retain a 32.5-token coalescing horizon instead of collapsing
to 1 token.
- Measured on `DeepSeek-V4.1-Flash` (`tokbench v0.3.0`, seed 42, temp 0,
base `1fbcc3c990b5`) on 4x NVIDIA RTX PRO 6000 Blackwell (SM120, TP4):
- Solo `long-context-mixed` (1-rep): +1.8% output (655.4 -> 667.3 tok/s),
stalled >250ms 28.1% -> 26.3%, -4.0% TTFT p50 (1,510 -> 1,449 ms),
+2.8 pp SLO (89.8% -> 92.6%).
- Solo `mixed-c32` (2-rep medians): -0.4% output (1,281.7 -> 1,276.8
tok/s), TTFT p50 1,425.3 -> 1,390.2 ms (-2.5%), stalled >250ms 11.29%
-> 11.49%, SLO 93.0% -> 91.1%.
- Solo `cold-heavy-mix` (1-rep): -3.7% output (541.8 -> 521.8 tok/s),
-9.0 pp SLO (88.1% -> 79.1%). Default-ON trade-off: keeping coalescing
active near EOS pulls competing 150K-250K cold prefills ahead of
decoders without chunk shrinking, raising `agentic_multiturn` TTFT p99
from 3,323 to 5,144 ms.
- Combined stack atop open PRs NVIDIA#660, NVIDIA#661, and NVIDIA#665 (attributed to that
composed stack):
- `mixed-c32` (2-rep medians): +1.4% output (1,374.6 -> 1,394.2 tok/s),
overall TTFT p50 1,001.0 -> 921.8 ms (-7.9%), stalled >250ms 4.82% ->
4.34% (-10.0% rel; spread [3.45%, 5.23%] vs [4.77%, 4.88%]), SLO
96.5% -> 97.1% (+0.6 pp). Trial-2 (1-trial rep): 233 -> 120 stalls,
Gap p99 230.2 -> 183.0 ms, `agentic_multiturn` TTFT p50 845 -> 681 ms
vs `heavy_prefill` 3,239 -> 7,551 ms.
- `long-context-mixed` (1-rep): output 707.8 -> 692.1 tok/s (-2.2%),
stalled >250ms 6.0% -> 4.0% (141 -> 94 stalls), SLO 94.1% -> 92.9%.
- `cold-heavy-mix` (1-rep): output 579.1 -> 574.0 tok/s (-0.9%), stalls
567 -> 672, cache hit 48.1% -> 52.8% (+4.7 pp).
- Measured on 4x NVIDIA DGX Spark GB10 (SM121, TP4, RoCEv2, signed core
`gb10-tp4-202612010547`, combined stack atop NVIDIA#660+NVIDIA#661+NVIDIA#665):
- `mixed-c8` (2-rep medians): output 128.4 -> 129.4 tok/s (+0.8%), TTFT
p50 1,181 -> 1,118 ms (-5.3%), stalled >250ms 41.8% -> 38.0%, SLO 79.0%
-> 81.7% (+2.7 pp).
- `agentic-coding` C=8 (1-rep): output 137.1 -> 135.0 tok/s (-1.5%), TTFT
p50 1,024 -> 877 ms (-14.4%), Gap p99 1,354 -> 725 ms (-46.5%), >1s
stalls 35 -> 12 (-65.7%), stalled >250ms 45.4% -> 34.5%, SLO 81.8% ->
85.7% (+3.9 pp), cache hit 74.6% -> 76.4%.
Evidence
Verified on clean `git archive` of tree `40596880cc64`:
- Rust (`RUSTFLAGS="-D warnings"`): `cargo check --locked --release` across
`eos`, `selene`, `selene-manager`, `helios` (`runtime-core,server`),
`flare`, `flare-cli` and `helios` tests -> 0 warnings.
- `cargo test --locked --release`: `helios --features server --lib` (1,283
passed, 15 ignored), `helios --features runtime-core,server --lib` (1,795
passed, 47 ignored), `flare --lib` (246 passed, 4 ignored), `flare-cli`
(245 passed, 3 ignored).
- Python (`pytest`): 853 passed across `tests/preparation/test_core_boundary.py`,
`tests/test_scheduling*.py`, and `tests/test_design_review_hook.py`.
- Scheduling simulator (`scripts/scheduling_sim`, 21 workloads x {std, mixed}
x {balanced, throughput}): 84/84 identical traces vs `1fbcc3c9`, 0
regressions.
- Cohort-mean mutation checks: reverting packed `mean_out`, Rust `horizon`,
and Python `utility.py` `horizon` back to `.min()` fails tests (3/3
reachable sites killed; the `!saw_packed` fallback branch in `policy.rs`
is structurally unreachable because `ActionCosts::duration(Speculative, b, w)`
queries `packed = b * w != 0` which `packed_round_shapes()` always yields).
- Formal lifecycle verification (`verification/helios-lifecycle/check.py`):
10/10 TLA+ configs, 8/8 observed Rust traces (594,065 edges) + negative
`DispatchRing SlotReuseSafe` check, 12/12 aux tests, 13/13 TLA+ model
mutations, and 26/26 Rust lifecycle mutations killed.
- `git merge-tree --write-tree`: clean against `1fbcc3c9`, NVIDIA#660 (`9709d496`),
NVIDIA#661 (`c588d610`), and NVIDIA#665 (`c5b39236`).
- Hardware binaries were built from unpushed local build trees `df9a8ebd`
(solo) and `dbbf65df` (stack) whose `helios/src/scheduler/policy.rs` is
byte-identical to this commit. SM120 `flare run` flags:
`--scheduler-policy balanced --max-concurrency 32 --mtp-draft-tokens 7
--mtp-adaptive-verification --mtp-max-verification-token-budget 128
--mtp-adaptive-verification-alpha 1.0 --embedding-table-cache-size 84GiB
--kv-cache-limit memory --prefix-cache-memory 0`. External client harness
(`tokbench`): `python3 -m tokbench run --url http://127.0.0.1:8002
--scenario <mixed-c32|long-context-mixed|cold-heavy-mix> -c <32|20|32>
--warmup <15|15|20> --duration <75|90|120> --drain <20|30|45>
--repeats <2|1|1> --seed 42 --temperature 0`. Standalone GB10, other GPUs,
and other model recipes were not benchmarked.
Discord: Dooner
Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
Why
In Helios's prepared-graph scheduler (`helios/src/scheduler/policy.rs`),
the per-prefill-token decode-batch coalescing bonus
(`coalescing_prefill_log_bonus`) prices the steady-state throughput gain
unlocked when queued prefills join an under-batched active decode cohort
over a bounded cohort-mean output horizon (`coalescing_horizon_tokens`,
default 64.0). Previously, `coalescing_prefill_log_bonus` reduced all
active decoders' remaining output budgets to a single scalar minimum
(`peer_budget = peer_budget.min(rem)`), and the Python reference scheduler
(`scripts/scheduling_sim/utility.py`) used the same scalar minimum for the
coalescing horizon (while already averaging per-decoder expected output
`mean_out` across active decoders in `best_decode_rate`). Under
heterogeneous mixed serving, any single active decoder within one token of
its output limit (`rem = 1`) collapsed both Rust's speculative per-round
expected output (`mean_out`) and both implementations' coalescing `horizon`
to 1 token for the entire cohort, eliminating over 98% of the coalescing
incentive even when all other active decoders had large remaining budgets.
Averaging per-decoder clamped budgets across the active cohort repairs the
Rust-to-simulator `mean_out` parity gap and extends cohort averaging to the
coalescing `horizon`, preserving continuation value when individual requests
approach completion while still shrinking smoothly as the cohort approaches
its output limit.
What
- In `helios/src/scheduler/policy.rs::coalescing_prefill_log_bonus`
(+16/-18 lines, -2 net Rust production LOC; visibility unchanged):
- Replace the scalar minimum `peer_budget` with a bounded per-decoder
remaining-budget array (`decoder_rems`), where each `rem` is an active
decoder's remaining output tokens clamped by KV sequence headroom
(`max_sequence_tokens - scheduled_consumed`).
- Extract local helper `mean_capped(rems: &[usize], cap: f64) -> f64`,
hoist `expected_at(eff_width)` and `expected_at(width as f64)` out of
the per-decoder loop, and delete provably dead `.max(1.0)` clamps and
the unreachable `if horizon > 0.0` branch while keeping the
`per_token.is_finite() && per_token > 0.0` guard.
- Compute speculative per-round expected output (`mean_out`, parity with
`utility.py`) and each prefiller's coalescing `horizon` (clamped to
`min(coalescing_horizon_tokens, post_prefill)`, where `post_prefill` is
the prefiller's remaining output budget after its first generated token)
via `mean_capped`.
- In `scripts/scheduling_sim/utility.py` (+2/-6, -4 net Python production
LOC): replace `peer_budget = min(v.output_budget for v in decoders)` in
the coalescing horizon calculation with the cohort mean across active
decoders, matching Helios and `best_decode_rate`'s existing cohort-mean
`mean_out`.
- In `docs/scheduling-runtime-design.md`: update the coalescing horizon
specification to describe the bounded cohort-mean decode horizon and
per-decoder clamped cohort averaging.
- In `helios/src/scheduler/policy_tests.rs` and
`tests/test_scheduling_utility.py`: add unit tests covering `[1, 100]`
and `n=3` `[1, 20, 100]` heterogeneous cohorts, Rust-specific KV-headroom
clamping, packed and unpacked speculative cohorts (reusing
`super::rounds::forecast_tokens`), single-decoder equivalence, zero-bonus
invariants, and an end-to-end `scripts/scheduling_sim` heterogeneous-budget
test (`max_new_tokens < 64`) under `balanced` (`age_price = 0.1`).
Result
- Single-decoder and homogeneous-budget cohorts produce identical values to
the prior minimum formula; a `[1, 100]` cohort retains a 32.5-token
horizon instead of collapsing to 1 token.
- End-to-end `scripts/scheduling_sim` (`catalog()`, `balanced`,
`age_price = 0.1`, cohort-mean vs prior `min(rem, ph)` horizon):
- Non-speculative (`short0` `max_new_tokens=8` + 3 long decoders + 4
queued 4K prefills): makespan 7,779.0 -> 7,734.0 ms (-45.0 ms), mean
prefill TTFT 266.8 -> 201.0 ms (-24.6%), max prefill TTFT 373.0 ->
327.0 ms (-12.3%), max output gap 226.0 -> 182.0 ms (-19.5%).
- Speculative (`short0` `max_new_tokens=32` + 3 long decoders + 5 queued
4K prefills): makespan 1,912.0 -> 1,878.0 ms (-34.0 ms), mean prefill
TTFT 293.6 -> 266.4 ms (-9.3%), max prefill TTFT 468.0 -> 432.0 ms
(-7.7%), max output gap 278.0 -> 212.0 ms (-23.7%).
- Measured on `DeepSeek-V4.1-Flash` (`FujitsuPolycom/tokbench`, seed 42,
temp 0, base `1fbcc3c990b5`) on 4x RTX PRO 6000 Blackwell (SM120, TP4)
and 4x DGX Spark GB10 (SM121, TP4, `gb10-tp4-202612010547`):
- Solo on `1fbcc3c9`: `long-context-mixed` (1-rep) +1.8% output (655.4 ->
667.3 tok/s), stalls 28.1% -> 26.3%, SLO 89.8% -> 92.6%; `mixed-c32`
(2-rep) output 1,281.7 -> 1,276.8 tok/s, TTFT p50 1,425 -> 1,390 ms,
stalls 11.29% -> 11.49%, SLO 93.0% -> 91.1%; `cold-heavy-mix` (1-rep)
regresses output 541.8 -> 521.8 tok/s (-3.7%) and SLO 88.1% -> 79.1%
(-9.0 pp, `agentic_multiturn` TTFT p99 3,323 -> 5,144 ms) because
keeping coalescing active near EOS pulls 150K-250K cold prefills ahead
of decoders without `NVIDIA#661` chunk shrinking.
- Atop `NVIDIA#661` (`3d868f84`, primary stall reduction from `NVIDIA#661`):
`mixed-c32` (2-rep med) output 1,254 -> 1,261 tok/s, stalls 6.65% ->
5.95%, TTFT p50 1,479 -> 1,439 ms, SLO 89.4% -> 90.5%;
`long-context-mixed` (1-rep) stalls 16.4% -> 9.8% while SLO dropped
89.3% -> 82.1% (-7.2 pp); `cold-heavy-mix` (1-rep) output 545.6 ->
547.8 tok/s, stalls 56.3% -> 55.7%, SLO 81.6% -> 79.8%.
- Composed 4-PR stack (`NVIDIA#660 + NVIDIA#661 + NVIDIA#665`, where prefix-cache hit-rate
gains come from `NVIDIA#665` and primary stall cuts from `NVIDIA#661`): SM120
`mixed-c32` (2-rep) output 1,374.6 -> 1,394.2 tok/s (+1.4%), stalls
4.82% -> 4.34%, TTFT p50 1,001 -> 922 ms (-7.9%), SLO 96.5% -> 97.1%;
GB10 `mixed-c8` (2-rep) stalls 41.8% -> 38.0%, TTFT p50 1,181 -> 1,118
ms, SLO 79.0% -> 81.7%; GB10 `agentic-coding` C=8 (1-rep) stalls 45.4%
-> 34.5%, TTFT p50 1,024 -> 877 ms, SLO 81.8% -> 85.7%.
Evidence
Verified on clean `git archive` of tree `fe2b8739991e`:
- Rust (`RUSTFLAGS="-D warnings"`): `cargo check --locked --release` across
`eos`, `selene`, `selene-manager`, `helios` (`runtime-core,server --tests`),
`flare`, `flare-cli` -> 0 warnings.
- `cargo test --locked --release`: `eos` (12 passed), `selene --features
test-support` (553 passed), `selene-manager --features test-support`
(426 passed, 1 ignored), `helios --features server --lib` (1,283 passed,
15 ignored), `helios --features runtime-core,server --lib` (1,795 passed,
47 ignored), `flare --lib` (246 passed, 4 ignored), `flare-cli` (245
passed, 3 ignored).
- Python: `ruff==0.12.8` passed on modified Python files; `pytest` passed
(854 passed across `tests/preparation/test_core_boundary.py`,
`tests/test_scheduling*.py`, and `tests/test_design_review_hook.py`,
including `test_coalescing_heterogeneous_budget_end_to_end_balanced`).
- Fault mutation checks (scratch copies): reverting `scripts/scheduling_sim/
utility.py` `horizon` to `min(ph, min(output_budget))` failed both
`test_coalescing_heterogeneous_budget_end_to_end_balanced` and
`test_coalescing_horizon_averages_active_decoder_budgets`; reverting
`helios/src/scheduler/policy.rs::mean_capped` to `.min()` failed both
Rust coalescing unit tests (`2/2` killed).
- `git merge-tree --write-tree`: clean (`rc=0`) against `main` (`4cc6f2fd`),
`2acc3f3a`, `NVIDIA#660` (`9709d496`), `NVIDIA#661` (`3d868f84`), and `NVIDIA#665`
(`c5b39236`).
- Hardware binaries were built from earlier equivalent trees `df9a8ebd`
(solo), `38130855` (on `NVIDIA#661`), and `dbbf65df` (stack) before the
semantics-preserving `mean_capped` / hoist refactor; final rebase onto
`main` after `NVIDIA#661` lands and CI/A/B confirmation on the rebased head
remain pending. Standalone GB10, other GPUs, and other recipes were not
benchmarked.
Discord: Dooner
Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
Why
In Helios's prepared-graph scheduler (`helios/src/scheduler/policy.rs`),
the per-prefill-token decode-batch coalescing bonus
(`coalescing_prefill_log_bonus`) prices the steady-state throughput gain
unlocked when queued prefills join an under-batched active decode cohort
over a bounded cohort-mean output horizon (`coalescing_horizon_tokens`,
default 64.0). Previously, `coalescing_prefill_log_bonus` reduced all
active decoders' remaining output budgets to a single scalar minimum
(`peer_budget = peer_budget.min(rem)`), and the Python reference scheduler
(`scripts/scheduling_sim/utility.py`) used the same scalar minimum for the
coalescing horizon (while already averaging per-decoder expected output
`mean_out` across active decoders in `best_decode_rate`). Under
heterogeneous mixed serving, any single active decoder within one token of
its output limit (`rem = 1`) collapsed both Rust's speculative per-round
expected output (`mean_out`) and both implementations' coalescing `horizon`
to 1 token for the entire cohort, eliminating over 98% of the coalescing
incentive even when all other active decoders had large remaining budgets.
Averaging per-decoder clamped budgets across the active cohort repairs the
Rust-to-simulator `mean_out` parity gap and extends cohort averaging to the
coalescing `horizon`, preserving continuation value when individual requests
approach completion while still shrinking smoothly as the cohort approaches
its output limit.
What
- In `helios/src/scheduler/policy.rs::coalescing_prefill_log_bonus`
(+16/-18 lines, -2 net Rust production LOC; visibility unchanged):
- Replace the scalar minimum `peer_budget` with a bounded per-decoder
remaining-budget array (`decoder_rems`), where each `rem` is an active
decoder's remaining output tokens clamped by KV sequence headroom
(`max_sequence_tokens - scheduled_consumed`).
- Extract local helper `mean_capped(rems: &[usize], cap: f64) -> f64`,
hoist `expected_at(eff_width)` and `expected_at(width as f64)` out of
the per-decoder loop, and delete provably dead `.max(1.0)` clamps and
the unreachable `if horizon > 0.0` branch while keeping the
`per_token.is_finite() && per_token > 0.0` guard.
- Compute speculative per-round expected output (`mean_out`, parity with
`utility.py`) and each prefiller's coalescing `horizon` (clamped to
`min(coalescing_horizon_tokens, post_prefill)`, where `post_prefill` is
the prefiller's remaining output budget after its first generated token)
via `mean_capped`.
- In `scripts/scheduling_sim/utility.py` (+2/-6, -4 net Python production
LOC): replace `peer_budget = min(v.output_budget for v in decoders)` in
the coalescing horizon calculation with the cohort mean across active
decoders, matching Helios and `best_decode_rate`'s existing cohort-mean
`mean_out`.
- In `docs/scheduling-runtime-design.md`: update the coalescing horizon
specification to describe the bounded cohort-mean decode horizon and
per-decoder clamped cohort averaging.
- In `helios/src/scheduler/policy_tests.rs` and
`tests/test_scheduling_utility.py`: add unit tests covering `[1, 100]`
and `n=3` `[1, 20, 100]` heterogeneous cohorts, Rust-specific KV-headroom
clamping, packed and unpacked speculative cohorts (reusing
`super::rounds::forecast_tokens`), single-decoder equivalence, zero-bonus
invariants, and an end-to-end `scripts/scheduling_sim` heterogeneous-budget
test (`max_new_tokens < 64`) under `balanced` (`age_price = 0.1`).
Result
- Single-decoder and homogeneous-budget cohorts produce identical values to
the prior minimum formula; a `[1, 100]` cohort retains a 32.5-token
horizon instead of collapsing to 1 token.
- End-to-end `scripts/scheduling_sim` (`catalog()`, `balanced`,
`age_price = 0.1`, cohort-mean vs prior `min(rem, ph)` horizon):
- Non-speculative (`short0` `max_new_tokens=8` + 3 long decoders + 4
queued 4K prefills): makespan 7,779.0 -> 7,734.0 ms (-45.0 ms), mean
prefill TTFT 266.8 -> 201.0 ms (-24.6%), max prefill TTFT 373.0 ->
327.0 ms (-12.3%), max output gap 226.0 -> 182.0 ms (-19.5%).
- Speculative (`short0` `max_new_tokens=32` + 3 long decoders + 5 queued
4K prefills): makespan 1,912.0 -> 1,878.0 ms (-34.0 ms), mean prefill
TTFT 293.6 -> 266.4 ms (-9.3%), max prefill TTFT 468.0 -> 432.0 ms
(-7.7%), max output gap 278.0 -> 212.0 ms (-23.7%).
- Measured on `DeepSeek-V4.1-Flash` (`FujitsuPolycom/tokbench`, seed 42,
temp 0, base `1fbcc3c990b5`) on 4x RTX PRO 6000 Blackwell (SM120, TP4)
and 4x DGX Spark GB10 (SM121, TP4, `gb10-tp4-202612010547`):
- Solo on `1fbcc3c9`: `long-context-mixed` (1-rep) +1.8% output (655.4 ->
667.3 tok/s), stalls 28.1% -> 26.3%, SLO 89.8% -> 92.6%; `mixed-c32`
(2-rep) output 1,281.7 -> 1,276.8 tok/s, TTFT p50 1,425 -> 1,390 ms,
stalls 11.29% -> 11.49%, SLO 93.0% -> 91.1%; `cold-heavy-mix` (1-rep)
regresses output 541.8 -> 521.8 tok/s (-3.7%) and SLO 88.1% -> 79.1%
(-9.0 pp, `agentic_multiturn` TTFT p99 3,323 -> 5,144 ms) because
keeping coalescing active near EOS pulls 150K-250K cold prefills ahead
of decoders without `#661` chunk shrinking.
- Atop `#661` (`3d868f84`, primary stall reduction from `#661`):
`mixed-c32` (2-rep med) output 1,254 -> 1,261 tok/s, stalls 6.65% ->
5.95%, TTFT p50 1,479 -> 1,439 ms, SLO 89.4% -> 90.5%;
`long-context-mixed` (1-rep) stalls 16.4% -> 9.8% while SLO dropped
89.3% -> 82.1% (-7.2 pp); `cold-heavy-mix` (1-rep) output 545.6 ->
547.8 tok/s, stalls 56.3% -> 55.7%, SLO 81.6% -> 79.8%.
- Composed 4-PR stack (`#660 + #661 + #665`, where prefix-cache hit-rate
gains come from `#665` and primary stall cuts from `#661`): SM120
`mixed-c32` (2-rep) output 1,374.6 -> 1,394.2 tok/s (+1.4%), stalls
4.82% -> 4.34%, TTFT p50 1,001 -> 922 ms (-7.9%), SLO 96.5% -> 97.1%;
GB10 `mixed-c8` (2-rep) stalls 41.8% -> 38.0%, TTFT p50 1,181 -> 1,118
ms, SLO 79.0% -> 81.7%; GB10 `agentic-coding` C=8 (1-rep) stalls 45.4%
-> 34.5%, TTFT p50 1,024 -> 877 ms, SLO 81.8% -> 85.7%.
Evidence
Verified on clean `git archive` of tree `fe2b8739991e`:
- Rust (`RUSTFLAGS="-D warnings"`): `cargo check --locked --release` across
`eos`, `selene`, `selene-manager`, `helios` (`runtime-core,server --tests`),
`flare`, `flare-cli` -> 0 warnings.
- `cargo test --locked --release`: `eos` (12 passed), `selene --features
test-support` (553 passed), `selene-manager --features test-support`
(426 passed, 1 ignored), `helios --features server --lib` (1,283 passed,
15 ignored), `helios --features runtime-core,server --lib` (1,795 passed,
47 ignored), `flare --lib` (246 passed, 4 ignored), `flare-cli` (245
passed, 3 ignored).
- Python: `ruff==0.12.8` passed on modified Python files; `pytest` passed
(854 passed across `tests/preparation/test_core_boundary.py`,
`tests/test_scheduling*.py`, and `tests/test_design_review_hook.py`,
including `test_coalescing_heterogeneous_budget_end_to_end_balanced`).
- Fault mutation checks (scratch copies): reverting `scripts/scheduling_sim/
utility.py` `horizon` to `min(ph, min(output_budget))` failed both
`test_coalescing_heterogeneous_budget_end_to_end_balanced` and
`test_coalescing_horizon_averages_active_decoder_budgets`; reverting
`helios/src/scheduler/policy.rs::mean_capped` to `.min()` failed both
Rust coalescing unit tests (`2/2` killed).
- `git merge-tree --write-tree`: clean (`rc=0`) against `main` (`4cc6f2fd`),
`2acc3f3a`, `#660` (`9709d496`), `#661` (`3d868f84`), and `#665`
(`c5b39236`).
- Hardware binaries were built from earlier equivalent trees `df9a8ebd`
(solo), `38130855` (on `#661`), and `dbbf65df` (stack) before the
semantics-preserving `mean_capped` / hoist refactor; final rebase onto
`main` after `#661` lands and CI/A/B confirmation on the rebased head
remain pending. Standalone GB10, other GPUs, and other recipes were not
benchmarked.
Discord: Dooner
Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
Why
eviction_candidate_within_budgetranked victims solely by(RetentionRank { use_epoch, role, consumed_tokens }, id)(#568). Becauseretirerefreshesuse_epochviacache.touch(#298, #416), cold one-shot prefills land at MRU ahead of idle multi-turn sessions, evicting reused sessions before dead scans. Naive 1-bit caches fail on linear multi-turn frontiers (0 hits until turnk+1) and livelock on phase shifts or compaction.What
Zero-knob policy (135 net prod LOC:
cache.rs+138/-22,scheduler.rs+32/-13; 0 flags, floats,unsafe, model branches, or core changes):cache.rs,scheduler.rs): Trackreused,reused_at_evicted_*,ready_tail_pages,evicted_pages,evicted_checkpoints(retire_leaf+compact_ancestor), and per-waiter(RequestHandle, bool)freshness onTicket(recomputed on cancel). Promote viatouch_hitonly on fresh GPU hits (accounting.is_none()), duplicate captures, andfinish_inbound(Created/Existingviapublish_with_retention_with_hit) with a live fresh waiter; completiontouch, preemptions, and waiterless restores refresh recency only.cache.rs): Children inherit iff parent is protected andparent_len * 2 >= tail_tokens(>=33%reused prefix).demote_expired_reusedpermanently clearsreusedafter dual turnover (ready_tail_pages.max(1)&ready_checkpoints.max(1)) or2xready_checkpoints.max(1)under compaction.(is_protected, retention_rank, id)after filters; synccore-design.md,scheduling-runtime-design.md,prefix-cache-offload.md,helios/README.md; add unit/policy tests &Fixture::key()reuse/turnover state.Result
Single-boot A/B vs
5d53040e, 4x RTX PRO 6000 (DeepSeek-V4.1-FlashTP4,gb202-tp4-202612010626, 2,606,848 KV tok / 20,366 pages, 0 err,n=2/arm;a7568c2cpre-hardening):24x8K/8x214K4x127K/12x8KLong-MT TTFT drops -86.3% by avoiding 127K queueing stalls. Trade-offs/limits: default-ON (no opt-out); on cold shifts, stale reused entries survive until dual or 2x checkpoint turnover, evicting new probationary entries first. No effect without eviction/overload; A/B ran on
a7568c2c(--prefix-cache-memory 0); restore gating is unit-tested, not live offload.Evidence
flare run <model> --gpus 0,1,2,3 --max-concurrency 32 --mtp-draft-tokens 7 --mtp-adaptive-verification --mtp-max-verification-token-budget 128 --mtp-adaptive-verification-alpha 1.0 --scheduler-policy balanced --embedding-table-storage disk --embedding-table-cache-size 84GiB --embedding-table-workers 1 --embedding-table-resident-scales --kv-cache-limit memory --memory-limit 83GiB --prefix-cache-memory 0; 2-workload client suite (seed=42,T=0.0,n=2cold-salted): Scan24x8KMT vs8x214Kcold; Long-MT4x127KMT vs12x8Kcold.ce649b30, tree402aa479== pushedc5b39236on1fbcc3c9,rustc 1.94.1):-D warnings0 warn (4 crates);heliosserver1,284 &runtime-core,server1,796 (excl. 8 gated;cache::49/139,policy_*6,finish_inbound_*5),flare246,flare-cli245,pytest834,ruff==0.12.80 PR issues;check.py --mutations: 10/10 TLC, 8/8 obs (621,390), 12/12 aux, 26/26 Rust + 13/13 TLA+ + 1/1 bad-edge KILLED.Discord: Dooner