Repository navigation
helios/scheduler: use active cohort mean in coalescing horizon - #681
Conversation
|
A case file has been opened for 681. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedThe arithmetic change is memory-safe, deterministic, and fixes a real
Walkthrough
Merge Risk: Medium · up to
|
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>
e15b836 to
975f825
Compare
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedHead
Walkthrough
Merge Risk: Medium · up to
|
Stacking and merge order (recommended after
#661): This+1net Rust production LOC change merges cleanly ontomain(1fbcc3c9, zero merge conflicts with#660,#661, or#665). Merging#661(3d868f84) first gives the largest latency and smoothness gains:#661unlocks smaller non-terminal prefill chunks and draining under active age-priced streams so cohort-averaged coalescing can pack queued prefills without blocking decoders (cutting SM120mixed-c32>250 msstalls-74.9%vsmain, from538to135). The four-PRStackrows also include#660(budgeted interior conversation-anchor splits) and#665(scan-resistant prefix-cache eviction); this PR contributes only the cohort-mean coalescing change incoalescing_prefill_log_bonusandscripts/scheduling_sim/utility.py.Why
coalescing_prefill_log_bonus(helios/src/scheduler/policy.rs) prices decode-batch gain when queued prefills join active decoders overcoalescing_horizon_tokens(64.0). Previously, Helios andscripts/scheduling_sim/utility.pytook a single minimum (peer_budget.min(rem)), so a single active decoder withrem = 1remaining output token collapsedmean_outandhorizonto1(over98%loss). Cohort-averaging preserves continuation value across the active batch while decaying smoothly near EOS.What
helios/src/scheduler/policy.rs::coalescing_prefill_log_bonus(+11/-10,+1net production LOC): Replacespeer_budgetwithdecoder_rems(rem: each active decoder's remaining output tokens), averagesexpected_at(width).min(rem).max(1.0)across active decoders formean_out, and averagesmin(rem, coalescing_horizon_tokens, post_prefill)(post_prefill: the prefilling request's remaining output budget after its first generated token) forhorizon.scripts/scheduling_sim/utility.py+2/-6,docs/scheduling-runtime-design.md,policy_tests.rs,tests/test_scheduling_utility.py): Updatesutility.pyto match the cohort-meanhorizonformula, updates the scheduler design spec, and adds unit tests including a[1, 100]heterogeneous decoder pair.Result
Single-decoder and homogeneous-remaining cohorts are unchanged; a
[1, 100]pair retains a32.5-token coalescing horizon. Measured onDeepSeek-V4.1-Flash(main1fbcc3c9), 4x RTX PRO 6000 (SM120) and 4x GB10 (SM121,gb10-tp4-202612010547), TP4:mixed-c32(2)long-context-mixed(1)cold-heavy-mix(1)#661[1] ∥mixed-c32(2)#661[1] ∥long-context-mixed(1)#661[1] ∥cold-heavy-mix(1)mixed-c32(2)mixed-c8(2)agentic-codingC=8 (1)Workloads come from
FujitsuPolycom/tokbench(v0.4.0, closed-loop client,--seed 42 --temperature 0.0). SLO passes when a request achieves at least15 tok/sper-user decode speed and meets its class TTFT target (<= 2 sinteractive,<= 3 sagentic and long-decode,<= 10 s/30 s/45 sheavy prefill):mixed-c32(C=32) runs 10 interactive chat (0.7K–2.2K tokens), 12 multi-turn coding agents (3.5K–8K tokens sharing a 2K prefix), 4 cold heavy prefills (10K–22K), and 6 long-decode streams (480–850 output tokens), whilemixed-c8(C=8) scales those counts to 3, 3, 1, and 1;long-context-mixed(C=20) mixes 6 interactive (1K–3K), 8 multi-turn (12K–24K), and 6 cold prefills (32K–128K);cold-heavy-mix(-c 32) splits 32 clients evenly between multi-turn agents (4.5K–10K) and cold prefills (150K–250K);agentic-coding(-c 8) mixes 20 multi-turn coding-agent weight shares (4.5K–9K sharing a 2K prefix) and 4 cold-prefill shares (12K–22K) at 8 concurrent clients.On #661(3d868f84-> tree38130855): Representativemixed-c32output moved1,258 -> 1,274 tok/s, stalls365 -> 135(8.2% -> 4.0%,-74.9%vsmain538), burst gap p99254.7 -> 234.9 ms, and prefix cache hit rate48.6% -> 52.5%;long-context-mixedoutput stayed+1.0%overmain(661.3) with stalls503 -> 244(-71.7%vsmain863);cold-heavy-mixoutput was+2.4%overmain(534.8) with stalls2,732 -> 2,452(7client-side 45 s drain cutoffs,0server errors); in a cold-burst probe (4 active decoders plus staggered14K,32K, and64Kprefills,n=2), peak gap dropped433.7 -> 224.1 ms(-19.2%vsmain277.4 ms) and mean max gap243.8 -> 190.6 ms.Stack(#660 + #661 + #665) & trade-off: SM120mixed-c32burst gap p99 improved230.2 -> 183.0 ms,long-context-mixedmoved707.8 -> 692.1(6.0% -> 4.0%), andcold-heavy-mixmoved579.1 -> 574.0(14.9% -> 17.9%); GB10agentic-codingburst gap p99 dropped1,354 -> 725 msand>1 sstalls dropped35 -> 12. Trade-off: on solocold-heavy-mix, keeping coalescing active near EOS pulls 150K–250K cold prefills ahead of decoders without chunk shrinking, raisingagentic_multiturnTTFT p993,323 -> 5,144 ms.Evidence
40596880cc64):cargo check --locked --releaseandcargo test --locked --releasepassed across 6 crates (helios1,283/1,795,flare246,flare-cli245);pytest853passed;verification/helios-lifecycle/check.pypassed (10/10TLC configs,8/8trace models /594,065transitions plus negative model,12/12auxiliary models,13/13TLA+ mutations, and26/26Rust mutations);scripts/scheduling_sim(84runs) matched1fbcc3c984/84 with3/3reachable.min()mutations killed;git merge-treeis clean againstmain,#660,#661, and#665.df9a8ebd,dbbf65df, and38130855; SM120flare runused--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. Standalone GB10 and other GPUs or recipes are untested.Discord: Dooner