Recommendation: Changes Requested
The production Rust and Python arithmetic (helios/src/scheduler/policy.rs +11/−10, scripts/scheduling_sim/utility.py +2/−6) is memory-safe, deterministic, ABI-compatible, and fixes a real rem = 1 cohort-collapse defect introduced in #645. However, this PR should not merge onto main as-is: (1) its only standalone (Solo) served benchmarks against main regress 2 of 3 scenarios (including -3.7% tok/s, -9.0 pp SLO, and +54.8% agentic_multiturn TTFT p99 on cold-heavy-mix) while relying on unmerged #661 to keep cold prefills bounded, and head e15b836 has no CI or commit-matched A/B run; and (2) the reported 84-run scripts/scheduling_sim sweep is mathematically inert for this change because every workload uses max_new_tokens = 4096. Rebase/merge after #661, add an end-to-end heterogeneous-budget simulator workload that actually exercises output_budget < 64, confirm green CI on the reviewed head, and clean up the hot-path expected_at recomputation and doc/description attribution.
Merge Risk
Level: Medium
- Default-on hot-path scheduler behavior change: Alters
coalescing_prefill_log_bonus(helios/src/scheduler/policy.rs:627,636,667-672) for every prefill-capable core under bothbalancedandthroughputpresets whenever any active decoder has remaining output< 64. Because the cohort mean is strictly>=the previous minimum, it monotonically raises queued-prefill credit near EOS—causing the PR's own disclosedcold-heavy-mixhead-of-line regression onmainwithout#661's chunk shrinking/draining. - Clean safety, concurrency, and compatibility profile: Single-threaded
RequestSchedulerarithmetic with zerounsafe, no new heap allocations (decoder_remsis a fixed[usize; REQUEST_LANES]stack array withREQUEST_LANES = 64), no Protobuf/core-format/CUDA-graph/ABI changes, and deterministic slot-index iteration. - Stack dependency and file overlap: Operational benefit depends on unmerged
#661(andStackrows also include open#660and#665), with 4 overlapping files against#661(policy.rs,policy_tests.rs,tests/test_scheduling_utility.py,docs/scheduling-runtime-design.md).
Walkthrough
helios/src/scheduler/policy.rs(:530-569, 627, 636, 667-672): Replaces the single scalarpeer_budget = min_i rem_iwith per-decoderdecoder_rems: [usize; REQUEST_LANES], removes the unreachablepeer_budget == usize::MAXearly-return clause at:567, switches speculativemean_out(:627,:636) to averageexpected_at(w).min(rem).max(1.0)across active decoders, and switcheshorizon(:667-672) to averagemin(rem, min(coalescing_horizon_tokens, post_prefill))across active decoders.scripts/scheduling_sim/utility.py(:233-235): Removespeer_budget = min(...)and updateshorizontosum(min(float(v.output_budget), ph) for v in decoders) / k(note:mean_outat:215-219was already a per-decoder cohort mean prior to this PR).helios/src/scheduler/policy_tests.rs(:6866-7059): Adds isolated unit testscoalescing_horizon_averages_active_decoder_budgets_across_cohortandcoalescing_speculative_mean_output_averages_per_decoder_budgets(withcoalescing_bonus/add_active_decoderhelpers) asserting exact cohort-mean values on[1, 100]mixed cohorts, single-decoder parity, zero-bonus boundary cases, and packed/speculative width cases.tests/test_scheduling_utility.py(:506-526): Addstest_coalescing_horizon_averages_active_decoder_budgetsmirroring the[1, 100](32.5-token horizon) and single-decoder (10.0) assertions onUtilityScheduler.prepare.docs/scheduling-runtime-design.md(:224-229): Updates the coalescing-term specification prose from minimum active-decoder budget to per-decoder clamped cohort averages for both horizon and speculative expected output.
Pre-merge Checks
- [PASS] Security / malicious screen: Pure scheduler arithmetic, isolated tests, and design docs; no
unsafe, I/O, FFI, parsing, privilege, untrusted-input, or prompt-injection surface. - [WARN] Charter & value fit: Right model-agnostic Helios runtime layer with zero new flags/ABI, but standalone (
Solo) benchmarks againstmainregress 2 of 3 workloads (missing Charter#210/docs/design-review.md:109-115speedup overmainwithout unmerged#661). - [WARN] Related / duplicate / conflict check: Genuinely additive refinement of merged
#645(non-duplicate), but operationally depends on unmerged#661and overlaps 4 files with#661. - [WARN] Tests & verification evidence: New Rust and Python unit tests are isolated and call real production entry points (
lane_values,UtilityScheduler.prepare), but GitHub Actions CI has not run on heade15b836, served A/B and archive checks ran on other commits (df9a8ebd/dbbf65df/38130855/40596880cc64), and the 84-runscripts/scheduling_simsweep cannot exerciseoutput_budget < 64.
Blockers
-
Standalone
mainregressions, dependency on unmerged#661, and unverified head commit (helios/src/scheduler/policy.rs:627,636,667-672,docs/design-review.md:109-115, Charter#210).- Verified behavior/impact: Because cohort-mean horizon (
mean_i min(rem_i, ph)) is strictly>=main's minimum (min_i min(rem_i, ph)), keeping coalescing active near EOS pulls 150K–250K cold prefills ahead of active decoders when#661's chunk shrinking/draining is absent. In the PR's ownSoloA/B againstmain, 2 of 3 scenarios regress:cold-heavy-mix(n=1) drops output541.8 -> 521.8 tok/s(-3.7%), SLO88.1% -> 79.1%(-9.0 pp), TTFT p501,763 -> 1,834 ms, andagentic_multiturnTTFT p993,323 -> 5,144 ms(+54.8%);mixed-c32(n=2) drops SLO93.0% -> 91.1%(-1.9 pp), stalls11.29% -> 11.49%, and output1,281.7 -> 1,276.8 tok/s. Meanwhile, the positiveOn #661andStackrows rely on unmerged#661(and#660/#665), served A/B ran on treesdf9a8ebd/dbbf65df/38130855(archive checks on40596880cc64), and heade15b836has no CI checks. - Fix: Hold merge until
#661lands (then rebase ontomaincontaining#661), ensure GitHub Actions CI is green on the final head commit, and confirm the A/B-measured tree matches the reviewed head (with repeats on the primary target workloads).
- Verified behavior/impact: Because cohort-mean horizon (
-
Reported 84-run simulator sweep is mathematically inert for this change (
scripts/scheduling_sim/utility.py:234-235,scripts/scheduling_sim/model.py:103,scripts/scheduling_sim/simulator.py:26,scripts/scheduling_sim/workloads.py:25-55,docs/design-review.md:195-200,234-251).- Verified behavior/impact:
docs/design-review.md:195-200,234-251requires service-pricing / cohort-algorithm changes to update and run an applicablescripts/scheduling_sim/evaluation covering the changed behavior. Inscripts/scheduling_sim/workloads.py:25-55, no workload overridesmax_new_tokens, so everyRequestuses the defaultmax_new_tokens = 4096(model.py:103). BecauseState.view()computesoutput_budget = r.max_new_tokens - self.generated(simulator.py:26), every active decoder in every multi-decoder workload with prefill hasoutput_budget >= 3840 >> 64.0throughout the run (andcontinuous_decodehask = 1, whereminandmeanare identical). Thus"84/84 matched 1fbcc3c9"is true by construction and never tests a heterogeneousrem < 64cohort in end-to-end simulation (andverification/helios-lifecycle/check.py(not opened) has no coverage ofpolicy.rs). - Fix: Add a heterogeneous-budget workload to
scripts/scheduling_sim/workloads.py(or a dedicated end-to-end simulation test intests/test_scheduling_utility.py) that sets smallmax_new_tokenson near-EOS decoders alongside long decoders and queued prefills underbalanced(age_price = 0.1), and report the before/after simulator delta on makespan, TTFT, and max output gap.
- Verified behavior/impact:
Should Fix
- 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).- Verified behavior/impact: (a)
scripts/scheduling_sim/utility.py:215-219was already computingmean_outas a per-decoder average before this PR (untouched by the diff); only thehorizonformula atutility.py:234-235is new to both implementations, sopolicy.rs:627,636is a Rust→simulator parity repair rather than a new rule. (b) In the PRResultsection,Stackrows combine#660 + #661 + #665(e.g., prefix-cache hit-rate gains come from#665and stall reductions primarily from#661), and theOn #661long-context-mixedSLO drop (89.3% -> 82.1%,-7.2 pp) appears in the table without being mentioned in the summary prose. (c)docs/scheduling-runtime-design.md:224-229still 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: Update the PR description to distinguish the
mean_outparity repair from the newhorizonrule and explicitly attribute#660/#661/#665stack effects plus theSolo/On #661SLO drops; reworddocs/scheduling-runtime-design.md:224from "bounded per-stream decode horizon" to "bounded cohort-mean decode horizon".
- Verified behavior/impact: (a)
Subtract / Simplify
- Extract a 3-line
mean_cappedhelper, hoistexpected_at, and delete dead.max(1.0)clamps (helios/src/scheduler/policy.rs:627,636,668-672).- Currently
:627and:636evaluateexpected_at(...)insidedecoder_rems[..decoder_count].iter().map(|&rem| ...), recomputing the loop-invariantmean_curvesum up toREQUEST_LANES(64) times per shape on theselect_planhot path; both lines also carry a provably dead.max(1.0)(rem >= 1at:550, andexpected_at(...) >= 1.0at:586-598becausepowered_curve/speculative_curveprobabilities are clamped to[0.0, 1.0]athelios/src/scheduler/rounds.rs:505), and are the only two >150-column lines in the file (166 and 181 chars). - Replace all three cohort-mean sites (
:627,:636,:668-672) with:
and callfn mean_capped(rems: &[usize], cap: f64) -> f64 { rems.iter().map(|&rem| (rem as f64).min(cap)).sum::<f64>() / rems.len() as f64 }mean_capped(&decoder_rems[..decoder_count], expected_at(eff_width)),mean_capped(&decoder_rems[..decoder_count], expected_at(width as f64)), andmean_capped(&decoder_rems[..decoder_count], ph).
- Currently
- Delete the unreachable
if horizon > 0.0guard (helios/src/scheduler/policy.rs:673).- Upstream guards already guarantee
coalescing_horizon_tokens > 0.0(:527),rem > 0(:550),post_prefill > 0(:561), anddecoder_count > 0(:567), so every summand is strictly positive andhorizon > 0.0always holds;:678already validatesper_token.is_finite() && per_token > 0.0. Removing the branch deletes 2 lines and unindents the amortization block.
- Upstream guards already guarantee
- Reuse
super::rounds::forecast_tokensin the new speculative test (helios/src/scheduler/policy_tests.rs:7002-7011).- The 10-line hand-copied
expected_atinterpolation closure is only called with integral widths (8.0at:7012,6.0at:7044,4.0at:7045). Replace it withsuper::rounds::forecast_tokens(&curve, w)(helios/src/scheduler/rounds.rs:991-993, matching the existing test precedent atpolicy_tests.rs:7152).
- The 10-line hand-copied
Nits
- Consider adding a unit-test subcase in
helios/src/scheduler/policy_tests.rscovering a KV-headroom-clamped decoder (max_sequence_tokens - scheduled_consumedatpolicy.rs:548-549) and ann >= 3cohort, and briefly noting that the KV-headroom clamp is Rust-specific (scripts/scheduling_sim/simulator.py:26tracksmax_new_tokens - generatedonly).
Dropped on verification
- Mandatory 64-seed
scripts/scheduling_sim/learning.pyvalidation gate (Discovery Dossier & Value Proposition): Dropped.docs/design-review.md:201-205specifically scopeslearning.pyto timing estimation and funded refresh, not coalescing horizon pricing;#663was not gated onlearning.py, andlearning_scenarios.pyalso defaultsmax_new_tokens = 4096(solearning.pywould be inert here). The actual applicable simulator gap is captured in Blocker 2. - "Cohort mean is not a realisable horizon; replace with
Σ_{t=0}^{ph-1} count(rem_i > t) / decoder_countor clamp bymax_i rem_i.min(ph)" (Correctness lens Finding A / 1.2): Dropped. Both proposed fixes are mathematically invalid: by the tail-sum identity for non-negative integers,Σ_{t=0}^{ph-1} count(rem_i > t) / nis algebraically identical to(1/n) Σ min(rem_i, ph), and clamping a mean bymax_iis a no-op (mean <= max). The diagnosis of[1, 100]also overlooked thatd1 + p0continue coalescing (1 -> 2) afterd0retires. The verified system-level issue—monotone credit increase causing cold-prefill head-of-line blocking onmainwithout#661—is captured in Blocker 1. - "Expose
scheduler_coalescing_horizon_tokensinconfig.rs/ CLI and zero it inPolicyConfig::throughput()" (Correctness Finding E & Value Proposition): Dropped. Adding an unrequested knob contradictsAGENTS.md:188-190and#645's design (whereoutput_token_value,token_fairness,delivery_fairness,decode_age_price, andcoalescing_horizon_tokensare internalPolicyConfigconstants), and zeroing coalescing inPolicyConfig::throughput()would contradict its purpose of maximizing token throughput (policy.rs:48-52). - "New unit tests are tautological and would pass identically if mean were replaced by the old min" (Correctness Finding G / 4.3): Dropped as factually false.
policy_tests.rs:6909-6913,policy_tests.rs:7034-7039, andtests/test_scheduling_utility.py:518-519assert exact32.5horizon and zero-surplus results that fail immediately under the oldmin. - "Collapse
decoder_slotsanddecoder_remsinto a tuple array to save 2×4 KiB on a 512-lane build" (Subtraction lens E): Dropped.REQUEST_LANESis64(helios/src/execution/manifest.rs:18(not opened), i.e., 512 B, not 4 KiB), and the two arrays are never read together (decoder_slotsonly at:574,decoder_remsat:627,636,668), so keepingdecoder_remscontiguous is cleaner formean_capped. - "Add a coalescing observability counter" and "re-tune
#663first-output credit ratio" (Correctness 2.2 & 2.3): Dropped as speculative scope expansion (AGENTS.md:188-193);#681leaves steady-staterem >= 64pricing unchanged, and combinedage_price = 0.1behavior will be exercised by the heterogeneous-budget simulator check in Blocker 2.