Skip to content

helios/scheduler: use active cohort mean in coalescing horizon - #55

Draft
FujitsuPolycom wants to merge 1 commit into
mainfrom
fix/helios-cohort-mean-coalescing
Draft

FujitsuPolycom wants to merge 1 commit into
mainfrom
fix/helios-cohort-mean-coalescing

Conversation

@FujitsuPolycom

@FujitsuPolycom FujitsuPolycom commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

Stacking and merge order (hold for #661): This -2 net Rust production LOC (-6 total net production LOC) change merges cleanly onto main (4cc6f2fd, zero merge conflicts with #660, #661, or #665), but standalone Solo runs against main without #661 regress cold-heavy-mix (-3.7% output, -9.0 pp SLO) and mixed-c32 SLO (-1.9 pp). Hold merge until #661 (3d868f84) lands, then rebase onto main and confirm green CI and matched-tree A/B on the rebased head. In the four-PR Stack rows below, #661 supplies the primary stall reduction (smaller non-terminal prefill chunks and draining under active age-priced streams), #665 supplies the prefix-cache hit-rate gains (scan-resistant prefix-cache eviction), and #660 (now merged in main 4cc6f2fd) supplies budgeted interior conversation-anchor splits; this PR contributes only the cohort-mean coalescing update in coalescing_prefill_log_bonus and scripts/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, default 64.0). Previously, Helios reduced all active decoders' remaining output budgets to a single scalar minimum (peer_budget = peer_budget.min(rem)), and scripts/scheduling_sim/utility.py used that same scalar minimum for horizon (while utility.py:215-219 already computed speculative mean_out as a per-decoder clamped cohort mean). Under heterogeneous serving, a single active decoder at rem = 1 collapsed both Rust mean_out and both implementations' coalescing horizon to 1 token (over 98% loss).

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 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, -2 net Rust production LOC):
    • Replaces peer_budget with decoder_rems (rem: each active decoder's remaining output tokens clamped by KV sequence headroom max_sequence_tokens - scheduled_consumed).
    • Extracts mean_capped(rems: &[usize], cap: f64) -> f64, hoists expected_at(eff_width) and expected_at(width as f64) out of the per-decoder loop, and removes provably dead .max(1.0) clamps and the unreachable if horizon > 0.0 guard while preserving per_token.is_finite() && per_token > 0.0.
    • Repairs Rust mean_out parity with utility.py:215-219 and computes cohort-mean horizon against min(coalescing_horizon_tokens, post_prefill) (post_prefill: prefiller remaining output budget after its first generated token) via mean_capped.
  • Simulator, design specification, and tests (scripts/scheduling_sim/utility.py +2/-6, docs/scheduling-runtime-design.md, helios/src/scheduler/policy_tests.rs, tests/test_scheduling_utility.py):
    • Updates utility.py horizon to match the cohort-mean formula (leaving existing cohort-mean mean_out intact) and updates docs/scheduling-runtime-design.md to describe the bounded cohort-mean decode horizon.
    • Adds Rust unit tests for [1, 100] and n = 3 ([1, 20, 100]) heterogeneous cohorts, Rust-specific KV-headroom clamping, packed/unpacked speculative cohorts (reusing super::rounds::forecast_tokens), single-decoder parity, and zero-bonus boundaries; adds an end-to-end scripts/scheduling_sim test with max_new_tokens < 64 near-EOS decoders under balanced (age_price = 0.1).

Result

Single-decoder and homogeneous-budget cohorts are unchanged; a [1, 100] cohort retains a 32.5-token horizon instead of collapsing to 1.

End-to-end scripts/scheduling_sim (catalog(), balanced, age_price = 0.1)

Because the existing 21 workloads in scripts/scheduling_sim/workloads.py all use default max_new_tokens = 4096, output_budget < 64 cohorts are evaluated in tests/test_scheduling_utility.py::test_coalescing_heterogeneous_budget_end_to_end_balanced comparing cohort-mean horizon against the prior min(rem, ph) horizon:

Workload (max_new_tokens < 64 near-EOS + long decoders + 4K prefills) Makespan ms (min -> mean) Mean prefill TTFT ms Max prefill TTFT ms Max output gap ms
Non-speculative (1x8 + 3x256 decoders, 4x4K prefills at 50 ms) 7,779.0 -> 7,734.0 (-45.0) 266.8 -> 201.0 (-24.6%) 373.0 -> 327.0 (-12.3%) 226.0 -> 182.0 (-19.5%)
Speculative (1x32 + 3x256 decoders, 5x4K prefills at 50 ms) 1,912.0 -> 1,878.0 (-34.0) 293.6 -> 266.4 (-9.3%) 468.0 -> 432.0 (-7.7%) 278.0 -> 212.0 (-23.7%)

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 base 1fbcc3c9:

Arm ∥ Scenario (repeats) Out tok/s Stalled >250 ms TTFT p50 ms SLO
Solo ∥ mixed-c32 (2) 1,281.7 -> 1,276.8 11.29 -> 11.49% 1,425 -> 1,390 93.0 -> 91.1%
Solo ∥ long-context-mixed (1) 655.4 -> 667.3 (+1.8%) 28.1 -> 26.3% 1,510 -> 1,449 89.8 -> 92.6%
Solo ∥ cold-heavy-mix (1) 541.8 -> 521.8 (-3.7%) 62.5 -> 62.2% 1,763 -> 1,834 88.1 -> 79.1%
On #661 [1] ∥ mixed-c32 (2) 1,254 -> 1,261 med 6.65 -> 5.95% med 1,479 -> 1,439 89.4 -> 90.5% med
On #661 [1] ∥ long-context-mixed (1) 670.5 -> 667.6 16.4 -> 9.8% 1,503 -> 1,473 89.3 -> 82.1%
On #661 [1] ∥ cold-heavy-mix (1) 545.6 -> 547.8 56.3 -> 55.7% 1,713 -> 1,786 81.6 -> 79.8%
Stack [2] ∥ mixed-c32 (2) 1,374.6 -> 1,394.2 (+1.4%) 4.82 -> 4.34% 1,001 -> 922 (-7.9%) 96.5 -> 97.1%
GB10 Stack [2] ∥ mixed-c8 (2) 128.4 -> 129.4 41.8 -> 38.0% 1,181 -> 1,118 (-5.3%) 79.0 -> 81.7%
GB10 Stack [2] ∥ agentic-coding C=8 (1) 137.1 -> 135.0 45.4 -> 34.5% 1,024 -> 877 (-14.4%) 81.8 -> 85.7%

Workloads come from FujitsuPolycom/tokbench (v0.4.0, closed-loop client, --seed 42 --temperature 0.0). SLO passes when a request achieves at least 15 tok/s per-user decode speed and meets its class TTFT target (<= 2 s interactive, <= 3 s agentic and long-decode, <= 10 s / 30 s / 45 s heavy 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), while mixed-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.

  • [1] On #661 (3d868f84 -> tree 38130855) & regressions: Primary stall reduction relative to main comes from #661; adding cohort-mean coalescing atop #661 moved representative mixed-c32 output 1,258 -> 1,274 tok/s, stalls 365 -> 135 (8.2% -> 4.0%, -74.9% vs main 538), burst gap p99 254.7 -> 234.9 ms, and cold-burst peak gap 433.7 -> 224.1 ms (n=2, 4 active decoders + staggered 14K/32K/64K prefills). Trade-offs and SLO drops: on Solo, cold-heavy-mix regressed output 541.8 -> 521.8 tok/s (-3.7%), SLO 88.1 -> 79.1% (-9.0 pp), and agentic_multiturn TTFT p99 3,323 -> 5,144 ms, and mixed-c32 SLO moved 93.0 -> 91.1% (-1.9 pp) because keeping coalescing active near EOS pulls 150K–250K cold prefills ahead of decoders without #661 chunk shrinking; on On #661, long-context-mixed (n=1) cut stalls 16.4 -> 9.8% (503 -> 244) while SLO dropped 89.3 -> 82.1% (-7.2 pp), and cold-heavy-mix (n=1, 7 client-side 45 s drain cutoffs, 0 server errors) SLO moved 81.6 -> 79.8%.
  • [2] Stack (#660 + #661 + #665): Attributes combined stack gains across the four changes — #665 drives prefix-cache hit-rate increases, #661 drives the primary stall reduction, and #660 (now merged in main) supplies budgeted conversation-anchor splits. Adding this PR atop the 3-PR stack improved SM120 mixed-c32 burst gap p99 230.2 -> 183.0 ms and GB10 agentic-coding burst gap p99 1,354 -> 725 ms (>1 s stalls 35 -> 12), while SM120 long-context-mixed (n=1) moved 707.8 -> 692.1 tok/s (6.0% -> 4.0% stalls) and cold-heavy-mix (n=1) moved 579.1 -> 574.0 tok/s (14.9% -> 17.9% stalls).

Evidence

  • Clean git archive checks on 975f82578a7b (tree fe2b8739991e):
    • Rust (RUSTFLAGS="-D warnings"): cargo check --locked --release passed with 0 warnings across eos, selene, selene-manager, helios (--features runtime-core,server --tests), flare, and flare-cli.
    • 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), and 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 back to min(ph, min(output_budget)) fails 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() fails 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).
  • Tested trees, configuration, and limits: Served A/B runs used earlier semantically equivalent build trees df9a8ebd (solo), 38130855 (on #661), and dbbf65df (stack) prior to the mean_capped / hoisted-expected_at cleanup; SM120 flare run used --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 onto main after #661 lands, 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

@FujitsuPolycom
FujitsuPolycom force-pushed the fix/helios-cohort-mean-coalescing branch from 04887ed to e15b836 Compare December 2, 2026 05:01
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
FujitsuPolycom force-pushed the fix/helios-cohort-mean-coalescing branch from e15b836 to 975f825 Compare December 2, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant