Skip to content

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

Merged
lukealonso merged 1 commit into
NVIDIA:mainfrom
FujitsuPolycom:fix/helios-cohort-mean-coalescing
Dec 2, 2026
Merged

lukealonso merged 1 commit into
NVIDIA:mainfrom
FujitsuPolycom:fix/helios-cohort-mean-coalescing

Conversation

@FujitsuPolycom

@FujitsuPolycom FujitsuPolycom commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Stacking and merge order (recommended after #661): This +1 net Rust production LOC change merges cleanly onto main (1fbcc3c9, zero merge conflicts with #660, #661, or #665). Merging #661 (3d868f84) first gives the largest latency and smoothness gains: #661 unlocks smaller non-terminal prefill chunks and draining under active age-priced streams so cohort-averaged coalescing can pack queued prefills without blocking decoders (cutting SM120 mixed-c32 >250 ms stalls -74.9% vs main, from 538 to 135). The four-PR Stack rows also include #660 (budgeted interior conversation-anchor splits) and #665 (scan-resistant prefix-cache eviction); this PR contributes only the cohort-mean coalescing change in coalescing_prefill_log_bonus and scripts/scheduling_sim/utility.py.

Why

coalescing_prefill_log_bonus (helios/src/scheduler/policy.rs) prices decode-batch gain when queued prefills join active decoders over coalescing_horizon_tokens (64.0). Previously, Helios and scripts/scheduling_sim/utility.py took a single minimum (peer_budget.min(rem)), so a single active decoder with rem = 1 remaining output token collapsed mean_out and horizon to 1 (over 98% 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, +1 net production LOC): Replaces peer_budget with decoder_rems (rem: each active decoder's remaining output tokens), averages expected_at(width).min(rem).max(1.0) across active decoders for mean_out, and averages min(rem, coalescing_horizon_tokens, post_prefill) (post_prefill: the prefilling request's remaining output budget after its first generated token) for horizon.
  • Simulator, tests, and design specification (scripts/scheduling_sim/utility.py +2/-6, docs/scheduling-runtime-design.md, policy_tests.rs, tests/test_scheduling_utility.py): Updates utility.py to match the cohort-mean horizon formula, 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 a 32.5-token coalescing horizon. Measured on DeepSeek-V4.1-Flash (main 1fbcc3c9), 4x RTX PRO 6000 (SM120) and 4x GB10 (SM121, gb10-tp4-202612010547), TP4:

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): Representative mixed-c32 output moved 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 prefix cache hit rate 48.6% -> 52.5%; long-context-mixed output stayed +1.0% over main (661.3) with stalls 503 -> 244 (-71.7% vs main 863); cold-heavy-mix output was +2.4% over main (534.8) with stalls 2,732 -> 2,452 (7 client-side 45 s drain cutoffs, 0 server errors); in a cold-burst probe (4 active decoders plus staggered 14K, 32K, and 64K prefills, n=2), peak gap dropped 433.7 -> 224.1 ms (-19.2% vs main 277.4 ms) and mean max gap 243.8 -> 190.6 ms.
  • [2] Stack (#660 + #661 + #665) & trade-off: SM120 mixed-c32 burst gap p99 improved 230.2 -> 183.0 ms, long-context-mixed moved 707.8 -> 692.1 (6.0% -> 4.0%), and cold-heavy-mix moved 579.1 -> 574.0 (14.9% -> 17.9%); GB10 agentic-coding burst gap p99 dropped 1,354 -> 725 ms and >1 s stalls dropped 35 -> 12. Trade-off: on solo cold-heavy-mix, keeping coalescing active near EOS pulls 150K–250K cold prefills ahead of decoders without chunk shrinking, raising agentic_multiturn TTFT p99 3,323 -> 5,144 ms.

Evidence

  • Archive checks (40596880cc64): cargo check --locked --release and cargo test --locked --release passed across 6 crates (helios 1,283 / 1,795, flare 246, flare-cli 245); pytest 853 passed; verification/helios-lifecycle/check.py passed (10/10 TLC configs, 8/8 trace models / 594,065 transitions plus negative model, 12/12 auxiliary models, 13/13 TLA+ mutations, and 26/26 Rust mutations); scripts/scheduling_sim (84 runs) matched 1fbcc3c9 84/84 with 3/3 reachable .min() mutations killed; git merge-tree is clean against main, #660, #661, and #665.
  • Tested trees, configuration, and limits: Served A/B tests ran on trees df9a8ebd, dbbf65df, and 38130855; 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. Standalone GB10 and other GPUs or recipes are untested.

Discord: Dooner

@flare-autobot flare-autobot added area:scheduling Request scheduling, fairness, batching, and speculative-width selection. performance Performance, latency, throughput, or memory-efficiency investigation or improvement. labels Dec 2, 2026
@FujitsuPolycom
FujitsuPolycom marked this pull request as ready for review December 2, 2026 16:12
@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 681.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot flare-autobot added the triage:review Proposed change needs code review; this does not imply merge readiness. label Dec 2, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The arithmetic change is memory-safe, deterministic, and fixes a real rem = 1 cohort-collapse defect from #645, but it should not merge onto main as-is: its own standalone Solo A/B regresses 2 of 3 scenarios (-3.7% tok/s, -9.0 pp SLO, +54.8% TTFT p99) and relies on unmerged #661, while the reported 84-run simulator sweep is mathematically inert because every workload uses max_new_tokens = 4096.
Rebase after #661, confirm green CI on the reviewed head, add a heterogeneous-budget (output_budget < 64) end-to-end sim workload, and clean up the hot-path expected_at recomputation plus doc/description attribution.

  • Blockers: 2 · Should fix: 1 · Subtract/Simplify: 3 · Nits: 1
Walkthrough
  • helios/src/scheduler/policy.rs (:530-569, 627, 636, 667-672): replaces scalar peer_budget = min_i rem_i with per-decoder decoder_rems: [usize; REQUEST_LANES], drops the unreachable peer_budget == usize::MAX early return at :567, and switches speculative mean_out (:627, :636) and horizon (:667-672) to per-decoder clamped cohort averages.
  • scripts/scheduling_sim/utility.py (:233-235): removes peer_budget; horizon becomes sum(min(output_budget, ph)) / k (mean_out at :215-219 was already a cohort mean pre-PR).
  • helios/src/scheduler/policy_tests.rs (:6866-7059): adds two isolated unit tests asserting exact cohort-mean values on [1, 100] cohorts, single-decoder parity, zero-bonus boundaries, and packed/speculative widths.
  • tests/test_scheduling_utility.py (:506-526): adds test_coalescing_horizon_averages_active_decoder_budgets (32.5-token horizon, 10.0 single-decoder) mirroring the Rust assertions on UtilityScheduler.prepare.
  • docs/scheduling-runtime-design.md (:224-229): updates coalescing spec prose from minimum active-decoder budget to per-decoder clamped cohort averages for both horizon and speculative expected output.
Merge Risk: Medium · up to e15b836
  • Default-on hot-path change: alters coalescing_prefill_log_bonus (policy.rs:627,636,667-672) for every prefill-capable core under balanced and throughput whenever an active decoder has rem < 64; because the cohort mean is >= the old minimum, queued-prefill credit rises monotonically near EOS — the disclosed cold-heavy-mix head-of-line regression on main without #661.
  • Clean safety/concurrency/ABI profile: single-threaded RequestScheduler arithmetic, no unsafe, no new heap allocation (decoder_rems is a fixed [usize; 64] stack array), no Protobuf/core-format/CUDA-graph/ABI changes, deterministic slot-index iteration.
  • Stack dependency and overlap: benefit depends on unmerged #661 (Stack rows also include #660, #665), with 4 overlapping files against #661 (policy.rs, policy_tests.rs, tests/test_scheduling_utility.py, docs/scheduling-runtime-design.md).
Pre-merge checks: ✅ 1 passed · ⚠️ 3 warnings
  • ✅ Security / malicious screen: pure scheduler arithmetic, isolated tests, and design docs; no unsafe, I/O, FFI, parsing, privilege, untrusted-input, or prompt-injection surface.
  • ⚠️ Charter & value fit: right model-agnostic Helios runtime layer with no new flags/ABI, but standalone (Solo) benchmarks against main regress 2 of 3 workloads (missing Charter #210 / docs/design-review.md:109-115 speedup over main without unmerged #661).
  • ⚠️ Related / duplicate / conflict check: genuinely additive refinement of merged #645 (non-duplicate), but operationally depends on unmerged #661 and overlaps 4 files with it.
  • ⚠️ Tests & verification evidence: new Rust/Python tests are isolated and call real production entry points (lane_values, UtilityScheduler.prepare), but CI has not run on head e15b836, served A/B and archive checks ran on other commits (df9a8ebd/dbbf65df/38130855/40596880cc64), and the 84-run scripts/scheduling_sim sweep cannot exercise output_budget < 64.
Blockers (2)
  1. Standalone main regressions, dependency on unmerged #661, unverified head (helios/src/scheduler/policy.rs:627,636,667-672, docs/design-review.md:109-115, Charter #210)

    • Cohort-mean horizon (mean_i min(rem_i, ph)) is strictly >= main's minimum, so keeping coalescing active near EOS pulls 150K–250K cold prefills ahead of active decoders without #661's chunk shrinking/draining.
    • Solo A/B vs main, 2 of 3 scenarios regress: cold-heavy-mix (n=1) output 541.8 -> 521.8 tok/s (-3.7%), SLO 88.1% -> 79.1% (-9.0 pp), TTFT p50 1,763 -> 1,834 ms, agentic_multiturn TTFT p99 3,323 -> 5,144 ms (+54.8%); mixed-c32 (n=2) SLO 93.0% -> 91.1% (-1.9 pp), stalls 11.29% -> 11.49%, output 1,281.7 -> 1,276.8 tok/s.
    • Positive On #661 / Stack rows rely on unmerged #661 (#660/#665); served A/B ran on df9a8ebd/dbbf65df/38130855 (archive checks 40596880cc64); head e15b836 has no CI checks.
    • Fix: hold merge until #661 lands, rebase onto a main containing it, get green GitHub Actions CI on the final head, and confirm the A/B-measured tree matches the reviewed head (with repeats on primary target workloads).
  2. The reported 84-run simulator sweep is mathematically inert for this change (scripts/scheduling_sim/utility.py:234-235, model.py:103, simulator.py:26, workloads.py:25-55, docs/design-review.md:195-200,234-251)

    • docs/design-review.md:195-200,234-251 requires an applicable scripts/scheduling_sim/ evaluation for service-pricing / cohort-algorithm changes; no workload in workloads.py:25-55 overrides max_new_tokens, so every Request uses the default 4096 (model.py:103).
    • With output_budget = r.max_new_tokens - self.generated (simulator.py:26), every multi-decoder workload with prefill stays at >= 3840 >> 64.0 for the whole run, and continuous_decode has k = 1 where min and mean coincide — so "84/84 matched 1fbcc3c9" is true by construction and never tests a heterogeneous rem < 64 cohort end-to-end.
    • verification/helios-lifecycle/check.py (not opened) has no coverage of policy.rs.
    • Fix: add a heterogeneous-budget workload (or a dedicated end-to-end sim test in tests/test_scheduling_utility.py) with small-max_new_tokens near-EOS decoders alongside long decoders and queued prefills under balanced (age_price = 0.1), and report the before/after delta on makespan, TTFT, and max output gap.
Should fix (1)
  1. Reconcile PR description attribution and design-spec wording (docs/scheduling-runtime-design.md:224-229, scripts/scheduling_sim/utility.py:215-219, helios/src/scheduler/policy.rs:627,636)
    • utility.py:215-219 already computed mean_out per-decoder before this PR (untouched by the diff); only horizon at utility.py:234-235 is new to both implementations, so policy.rs:627,636 is a Rust→simulator parity repair rather than a new rule.
    • In the PR Result section, Stack rows combine #660 + #661 + #665 (prefix-cache hit-rate gains come from #665, stall reductions primarily from #661), and the On #661 long-context-mixed SLO drop (89.3% -> 82.1%, -7.2 pp) appears in the table but not in the summary prose.
    • docs/scheduling-runtime-design.md:224-229 still says "over a bounded per-stream decode horizon ... averaged across active decoders", even though the cohort mean can exceed an individual near-EOS stream's remaining budget.
    • Fix: distinguish the mean_out parity repair from the new horizon rule, explicitly attribute #660/#661/#665 stack effects and the Solo / On #661 SLO drops, and reword :224 to "bounded cohort-mean decode horizon".
Subtract / Simplify (3)
  1. Extract a mean_capped helper, hoist expected_at, delete dead .max(1.0) clamps (helios/src/scheduler/policy.rs:627,636,668-672)
    • :627 and :636 evaluate expected_at(...) inside the decoder_rems[..decoder_count].iter().map(|&rem| ...) closure, recomputing the loop-invariant mean_curve sum up to REQUEST_LANES (64) times per shape on the select_plan hot path; both also carry a provably dead .max(1.0) (rem >= 1 at :550, and expected_at(...) >= 1.0 at :586-598 because curves are clamped to [0.0, 1.0] at helios/src/scheduler/rounds.rs:505), and are the file's only >150-column lines (166 and 181 chars).
    • Replace all three cohort-mean sites with:
      fn mean_capped(rems: &[usize], cap: f64) -> f64 {
          rems.iter().map(|&rem| (rem as f64).min(cap)).sum::<f64>() / rems.len() as f64
      }
      called as mean_capped(&decoder_rems[..decoder_count], expected_at(eff_width)), mean_capped(&decoder_rems[..decoder_count], expected_at(width as f64)), and mean_capped(&decoder_rems[..decoder_count], ph).
  2. Delete the unreachable if horizon > 0.0 guard (helios/src/scheduler/policy.rs:673)
    • Upstream guards already guarantee coalescing_horizon_tokens > 0.0 (:527), rem > 0 (:550), post_prefill > 0 (:561), and decoder_count > 0 (:567), so every summand is strictly positive; :678 already validates per_token.is_finite() && per_token > 0.0. Removing the branch deletes 2 lines and unindents the amortization block.
  3. Reuse super::rounds::forecast_tokens in the new speculative test (helios/src/scheduler/policy_tests.rs:7002-7011)
    • The 10-line hand-copied expected_at interpolation closure is only called with integral widths (8.0 at :7012, 6.0 at :7044, 4.0 at :7045); replace it with super::rounds::forecast_tokens(&curve, w) (rounds.rs:991-993), matching the existing precedent at policy_tests.rs:7152.
Nits (1)
  • Consider a unit-test subcase in helios/src/scheduler/policy_tests.rs covering a KV-headroom-clamped decoder (max_sequence_tokens - scheduled_consumed at policy.rs:548-549) and an n >= 3 cohort, briefly noting the clamp is Rust-specific (scripts/scheduling_sim/simulator.py:26 tracks max_new_tokens - generated only).

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

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
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

Head 975f825 cleanly resolves all Round 1 Subtract / Simplify items, the Round 1 nit, the design-spec wording, and the code side of Round 1 Blocker 2 with a new end-to-end heterogeneous-budget simulator test. The Rust/Python arithmetic is memory-safe, allocation-free, and deterministic, but Round 1 Blocker 1 remains open: the branch still sits on main without #661, its standalone Solo benchmarks regress 2 of 3 workloads, no CI has run on 975f825, and the PR description is stale.

  • Blockers: 1 · Should fix: 1 · Subtract/Simplify: 1 · Nits: 0
Walkthrough
  • helios/src/scheduler/policy.rs (+16/-18, :530-569, 599-601, 630, 639, 669-679): Replaces scalar peer_budget with per-decoder decoder_rems: [usize; REQUEST_LANES], drops the unreachable peer_budget == usize::MAX check and dead if horizon > 0.0 wrapper, extracts mean_capped, hoists expected_at(...) out of per-decoder iteration, removes redundant .max(1.0) clamps, and switches speculative mean_out (:630, :639) and horizon (:671) to cohort averages.
  • scripts/scheduling_sim/utility.py (+2/-6, :233-235): Removes peer_budget and updates horizon to sum(min(float(v.output_budget), ph) for v in decoders) / k (mean_out at :215-218 was already cohort-averaged pre-PR).
  • helios/src/scheduler/policy_tests.rs (+217/-0, :6866-7079): Adds two isolated unit tests exercising real RequestScheduler::lane_values(0) over [1, 100], [1, 20, 100], KV-headroom-clamped [2, 100, 100], single-decoder, zero-bonus, and speculative/packed cohorts (reusing super::rounds::forecast_tokens, with a mean-vs-min discriminator at :7054-7059).
  • tests/test_scheduling_utility.py (+90/-0, :506-593): Adds test_coalescing_horizon_averages_active_decoder_budgets (UtilityScheduler.prepare) and test_coalescing_heterogeneous_budget_end_to_end_balanced (simulator.run end-to-end with max_new_tokens=8 non-speculative and max_new_tokens=32 speculative cohorts under age_price=0.1).
  • docs/scheduling-runtime-design.md (+6/-3, :224-229): Updates coalescing documentation to describe the bounded cohort-mean decode horizon and per-decoder clamped speculative expected output.
Merge Risk: Medium · up to 975f825
  • Monotonic default-on prefill priority increase on main: mean_capped(&decoder_rems[..decoder_count], cap) (helios/src/scheduler/policy.rs:599-601, 630, 639, 671) is pointwise >= main's minimum (since rem >= 1 at :550 and expected_at(...) >= 1.0 at :586-598, with curve entries clamped to [0.0, 1.0] at helios/src/scheduler/rounds.rs:505 and helios/src/scheduler/speculation.rs:134). Without #661's smaller prefill chunking and draining, this stacks with #663's first-output waiting-age credit (policy.rs:758-784) to pull monolithic 150K–250K cold prefills ahead of active decoders near EOS, reproducing the PR's own Solo cold-heavy-mix regression.
  • Clean safety, concurrency, and compatibility profile: Single-threaded RequestScheduler arithmetic, zero unsafe, zero heap allocation (decoder_rems: [usize; REQUEST_LANES] at policy.rs:531), deterministic slot-index iteration, no division-by-zero (decoder_count >= 1 at :567, initial_prefill >= 1 via helios/src/scheduler.rs:351-355), and no CLI, Protobuf, core-format, or CUDA-graph contract changes.
  • Stack dependency and overlap: Positive served results (On #661 and Stack) depend on open #661 (currently awaiting lukealonso's review fixes on GraphKind::Resume in decode_floor and native-serving CI) plus #660/#665, with 4 overlapping files against #661 (docs/scheduling-runtime-design.md, helios/src/scheduler/policy.rs, helios/src/scheduler/policy_tests.rs, tests/test_scheduling_utility.py).
Pre-merge checks: ✅ 1 passed · ⚠️ 3 warnings
  • ✅ Security / malicious screen: Pure scheduler arithmetic, isolated tests, and design docs; no unsafe, I/O, FFI, parsing, privilege, untrusted-input, or prompt-injection surface.
  • ⚠️ Charter & value fit: Right model-agnostic Helios runtime layer with no new flags or ABI changes, but standalone Solo benchmarks against main regress 2 of 3 workloads without unmerged #661 (Charter #210 / docs/design-review.md:109-115).
  • ⚠️ Related / duplicate / conflict check: Genuinely additive refinement of merged #645, but operationally depends on open #661 (still unmerged) and overlaps 4 files with it.
  • ⚠️ Tests & verification evidence: All new Rust and Python tests are isolated and call real production entry points, and tests/test_scheduling_utility.py:529-593 now exercises heterogeneous output_budget < 64 cohorts end-to-end; however, no CI checks have run on 975f825, served A/B and archive checks cite older commits (df9a8ebd/dbbf65df/38130855/40596880cc64), and the PR body still reports only the inert 84-run workloads() sweep (max_new_tokens = 4096).

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

@lukealonso
lukealonso merged commit cc0a49d into NVIDIA:main Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:scheduling Request scheduling, fairness, batching, and speculative-width selection. performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants