Repository navigation
helios/scheduler: use active cohort mean in coalescing horizon - #55
Draft
FujitsuPolycom wants to merge 1 commit into
Draft
FujitsuPolycom wants to merge 1 commit into
FujitsuPolycom wants to merge 1 commit into
Conversation
FujitsuPolycom
force-pushed
the
fix/helios-cohort-mean-coalescing
branch
from
December 2, 2026 05:01
04887ed to
e15b836
Compare
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>
FujitsuPolycom
force-pushed
the
fix/helios-cohort-mean-coalescing
branch
from
December 2, 2026 18:06
e15b836 to
975f825
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacking and merge order (hold for
#661): This-2net Rust production LOC (-6total net production LOC) change merges cleanly ontomain(4cc6f2fd, zero merge conflicts with#660,#661, or#665), but standaloneSoloruns againstmainwithout#661regresscold-heavy-mix(-3.7%output,-9.0 ppSLO) andmixed-c32SLO (-1.9 pp). Hold merge until#661(3d868f84) lands, then rebase ontomainand confirm green CI and matched-tree A/B on the rebased head. In the four-PRStackrows below,#661supplies the primary stall reduction (smaller non-terminal prefill chunks and draining under active age-priced streams),#665supplies the prefix-cache hit-rate gains (scan-resistant prefix-cache eviction), and#660(now merged inmain4cc6f2fd) supplies budgeted interior conversation-anchor splits; this PR contributes only the cohort-mean coalescing update incoalescing_prefill_log_bonusandscripts/scheduling_sim/utility.py.Why
coalescing_prefill_log_bonus(helios/src/scheduler/policy.rs) prices the decode-batch efficiency gain unlocked when queued prefills join under-batched active decoders over a bounded cohort-mean decode horizon (coalescing_horizon_tokens, default64.0). Previously, Helios reduced all active decoders' remaining output budgets to a single scalar minimum (peer_budget = peer_budget.min(rem)), andscripts/scheduling_sim/utility.pyused that same scalar minimum forhorizon(whileutility.py:215-219already computed speculativemean_outas a per-decoder clamped cohort mean). Under heterogeneous serving, a single active decoder atrem = 1collapsed both Rustmean_outand both implementations' coalescinghorizonto1token (over98%loss).Averaging per-decoder clamped budgets across the active cohort repairs the Rust-to-simulator
mean_outparity gap and extends cohort averaging to the coalescinghorizon, preserving continuation value across long active decoders while still decaying smoothly as the cohort approaches completion.What
helios/src/scheduler/policy.rs::coalescing_prefill_log_bonus(+16/-18,-2net Rust production LOC):peer_budgetwithdecoder_rems(rem: each active decoder's remaining output tokens clamped by KV sequence headroommax_sequence_tokens - scheduled_consumed).mean_capped(rems: &[usize], cap: f64) -> f64, hoistsexpected_at(eff_width)andexpected_at(width as f64)out of the per-decoder loop, and removes provably dead.max(1.0)clamps and the unreachableif horizon > 0.0guard while preservingper_token.is_finite() && per_token > 0.0.mean_outparity withutility.py:215-219and computes cohort-meanhorizonagainstmin(coalescing_horizon_tokens, post_prefill)(post_prefill: prefiller remaining output budget after its first generated token) viamean_capped.scripts/scheduling_sim/utility.py+2/-6,docs/scheduling-runtime-design.md,helios/src/scheduler/policy_tests.rs,tests/test_scheduling_utility.py):utility.pyhorizonto match the cohort-mean formula (leaving existing cohort-meanmean_outintact) and updatesdocs/scheduling-runtime-design.mdto describe the bounded cohort-mean decode horizon.[1, 100]andn = 3([1, 20, 100]) heterogeneous cohorts, Rust-specific KV-headroom clamping, packed/unpacked speculative cohorts (reusingsuper::rounds::forecast_tokens), single-decoder parity, and zero-bonus boundaries; adds an end-to-endscripts/scheduling_simtest withmax_new_tokens < 64near-EOS decoders underbalanced(age_price = 0.1).Result
Single-decoder and homogeneous-budget cohorts are unchanged; a
[1, 100]cohort retains a32.5-token horizon instead of collapsing to1.End-to-end
scripts/scheduling_sim(catalog(),balanced,age_price = 0.1)Because the existing 21 workloads in
scripts/scheduling_sim/workloads.pyall use defaultmax_new_tokens = 4096,output_budget < 64cohorts are evaluated intests/test_scheduling_utility.py::test_coalescing_heterogeneous_budget_end_to_end_balancedcomparing cohort-meanhorizonagainst the priormin(rem, ph)horizon:max_new_tokens < 64near-EOS + long decoders + 4K prefills)min->mean)1x8+3x256decoders,4x4Kprefills at50 ms)1x32+3x256decoders,5x4Kprefills at50 ms)Served hardware A/B (
DeepSeek-V4.1-Flash, TP4)Measured on 4x RTX PRO 6000 Blackwell (SM120) and 4x DGX Spark GB10 (SM121,
gb10-tp4-202612010547) atop base1fbcc3c9: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) & regressions: Primary stall reduction relative tomaincomes from#661; adding cohort-mean coalescing atop#661moved representativemixed-c32output1,258 -> 1,274 tok/s, stalls365 -> 135(8.2% -> 4.0%,-74.9%vsmain538), burst gap p99254.7 -> 234.9 ms, and cold-burst peak gap433.7 -> 224.1 ms(n=2, 4 active decoders + staggered14K/32K/64Kprefills). Trade-offs and SLO drops: onSolo,cold-heavy-mixregressed output541.8 -> 521.8 tok/s(-3.7%), SLO88.1 -> 79.1%(-9.0 pp), andagentic_multiturnTTFT p993,323 -> 5,144 ms, andmixed-c32SLO moved93.0 -> 91.1%(-1.9 pp) because keeping coalescing active near EOS pulls 150K–250K cold prefills ahead of decoders without#661chunk shrinking; onOn #661,long-context-mixed(n=1) cut stalls16.4 -> 9.8%(503 -> 244) while SLO dropped89.3 -> 82.1%(-7.2 pp), andcold-heavy-mix(n=1,7client-side 45 s drain cutoffs,0server errors) SLO moved81.6 -> 79.8%.Stack(#660 + #661 + #665): Attributes combined stack gains across the four changes —#665drives prefix-cache hit-rate increases,#661drives the primary stall reduction, and#660(now merged inmain) supplies budgeted conversation-anchor splits. Adding this PR atop the 3-PR stack improved SM120mixed-c32burst gap p99230.2 -> 183.0 msand GB10agentic-codingburst gap p991,354 -> 725 ms(>1 sstalls35 -> 12), while SM120long-context-mixed(n=1) moved707.8 -> 692.1 tok/s(6.0% -> 4.0%stalls) andcold-heavy-mix(n=1) moved579.1 -> 574.0 tok/s(14.9% -> 17.9%stalls).Evidence
git archivechecks on975f82578a7b(treefe2b8739991e):RUSTFLAGS="-D warnings"):cargo check --locked --releasepassed with 0 warnings acrosseos,selene,selene-manager,helios(--features runtime-core,server --tests),flare, andflare-cli.cargo test --locked --release:eos(12passed),selene --features test-support(553passed),selene-manager --features test-support(426passed,1ignored),helios --features server --lib(1,283passed,15ignored),helios --features runtime-core,server --lib(1,795passed,47ignored),flare --lib(246passed,4ignored), andflare-cli(245passed,3ignored).ruff==0.12.8passed on modified Python files;pytestpassed (854passed acrosstests/preparation/test_core_boundary.py,tests/test_scheduling*.py, andtests/test_design_review_hook.py, includingtest_coalescing_heterogeneous_budget_end_to_end_balanced).scripts/scheduling_sim/utility.pyhorizonback tomin(ph, min(output_budget))fails bothtest_coalescing_heterogeneous_budget_end_to_end_balancedandtest_coalescing_horizon_averages_active_decoder_budgets; revertinghelios/src/scheduler/policy.rs::mean_cappedto.min()fails both Rust coalescing unit tests (2/2killed).git merge-tree --write-tree: clean (rc=0) againstmain(4cc6f2fd),2acc3f3a,#660(9709d496),#661(3d868f84), and#665(c5b39236).df9a8ebd(solo),38130855(on#661), anddbbf65df(stack) prior to themean_capped/ hoisted-expected_atcleanup; 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. Rebase ontomainafter#661lands, GitHub Actions CI on the rebased head, and matched-tree served A/B confirmation on the rebased head remain pending. Standalone GB10, other GPUs, and other model recipes were not benchmarked.Discord: Dooner