Correctness, Contracts & System-Level Consequences review — PR #681 (helios/scheduler: use active cohort mean in coalescing horizon)
Head 975f825 (single squash commit on main 1fbcc3c9), draft, no CI checks on head, no human review. Diff +331/−27 in 5 files: docs/scheduling-runtime-design.md +6/−3, helios/src/scheduler/policy.rs +16/−18, helios/src/scheduler/policy_tests.rs +217/−0, scripts/scheduling_sim/utility.py +2/−6, tests/test_scheduling_utility.py +90/−0.
Key findings
| # | Severity | Finding |
|---|---|---|
| M1 | Blocker | The cohort mean is provably >= main's minimum in every state, so this is a default-on, workload-independent increase in queued-prefill priority with no operator off-switch — and the PR's own standalone numbers regress 2 of 3 scenarios. |
| M2 | Blocker | No evidence covers the head, and the 84/84 simulator parity sweep is mathematically inert (every workload keeps output_budget >= 3840 >> 64). The PR also introduces a new declared Rust/simulator divergence (KV-headroom clamp). |
| M3 | Major | The horizon gain is proportional to each queued prefiller's total credit, and one scalar surplus is shared by all prefillers, so near EOS aggregate prefill priority can rise up to 64× — the head-of-line blocking the PR itself measures (p99 TTFT +54.8%) but does not bound. |
| M4 | Major | Head unrun; the new Python end-to-end test cannot distinguish mean from min; the PR body is stale against its own diff. |
| M5 | Minor | The metric's span widened from min-over-cohort to mean-over-all-active decoders while the rate still multiplies by served; shared with the simulator, so an approximation rather than a new divergence. |
M1 — BLOCKER: one-directional, default-on credit increase; standalone main regressions; no off-switch
Area 3 (charter/contracts) and area 2 (system-level).
Proof that credit only rises
fn mean_capped(rems: &[usize], cap: f64) -> f64 {
rems.iter().map(|&rem| (rem as f64).min(cap)).sum::<f64>() / rems.len() as f64
}
helios/src/scheduler/policy.rs:599-601
mean_capped is used for mean_out at policy.rs:630 and :639, and for the horizon at:
for &(slot, initial_prefill, post_prefill) in &prefillers[..prefiller_count] {
let ph = self.policy.coalescing_horizon_tokens.min(post_prefill as f64);
let horizon = mean_capped(&decoder_rems[..decoder_count], ph);
helios/src/scheduler/policy.rs:669-671
Because rem >= 1 (enforced by if rem > 0 at policy.rs:550) and expected_at >= 1.0:
if eff_width <= 1.0 || mean_curve.is_empty() {
return 1.0;
}
helios/src/scheduler/policy.rs:586-589 — it follows that mean_i min(rem_i, cap) >= min_i min(rem_i, cap) pointwise. Therefore per_token (:675) and its log bonus (:677) are >= main's for every state, config, and workload. The change is a one-directional relaxation of prefill-vs-decode preference applied by default, not a repair that cuts both ways.
The PR's own standalone (attributable) measurements regress
Only the Solo rows are measured on main 1fbcc3c9 without #661/#660/#665:
| Solo scenario | Out tok/s | TTFT p50 | SLO |
|---|---|---|---|
mixed-c32 (2) |
1,281.7 → 1,276.8 | 1,425 → 1,390 | 93.0 → 91.1% |
long-context-mixed (1) |
655.4 → 667.3 | 1,510 → 1,449 | 89.8 → 92.6% |
cold-heavy-mix (1) |
541.8 → 521.8 (−3.7%) | 1,763 → 1,834 | 88.1 → 79.1% |
Two of three regress; the body's own trade-off paragraph concedes the worst case: "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" (+54.8%). Charter #210 and docs/design-review.md:106-115 ("Performance claims require equivalent baselines… Correctness failures block performance claims") require a speedup over main on a served workload; this PR's attributable measurement is a net regression on 2 of 3.
No operator control
pub fn throughput() -> Self {
Self { delivery_fairness: 0.0, decode_age_price: 0.0, ..Self::default() }
}
helios/src/scheduler/policy.rs:50-52 — keeps coalescing_horizon_tokens: 64.0; the only other early exit is if self.policy.coalescing_horizon_tokens <= 0.0 (:527), which no config path can reach. helios/src/server/config.rs:305-325 accepts only scheduler_policy, scheduler_terminal_value, scheduler_terminal_age_price, scheduler_checkpoint_extra_work_fraction, mtp_adaptive_verification_alpha; there is no flare run key for the horizon. The config table row is still generic — "| coalescing_horizon_tokens | 64 | Output-token horizon for decode-batch coalescing bonus on queued prefills |" (docs/scheduling-runtime-design.md:713) — so an operator cannot turn this off after it bites, contradicting the charter's "No magic defaults".
Fix: gate the cohort mean behind an explicit scheduler_coalescing_horizon_tokens config key (default 0 = old min_i, or keep min_i under balanced), publish the standalone numbers against the head, and separate them from #661.
M2 — BLOCKER: evidence does not cover the head, and the 84/84 sweep is inert
Area 4 (tests & claim accuracy).
(a) Head is not the tested revision
Body: "Served A/B tests ran on trees df9a8ebd, dbbf65df, and 38130855"; archive checks on 40596880cc64. Head is 975f825, whose parent is main 1fbcc3c9. policy.rs is +16/−18 at head while the body claims +11/-10, so the body describes an older revision. Nothing in the body re-runs A/B or the archive checks on the head.
(b) The parity sweep cannot discriminate min from mean
scripts/scheduling_sim/workloads.py:25-55 never passes max_new_tokens; the default is:
max_new_tokens: int = 4096
scripts/scheduling_sim/model.py:103, and the view exposes
return View(r.name, self.remaining_prefill, r.max_new_tokens - self.generated,
scripts/scheduling_sim/simulator.py:26
So output_budget >= 3840 for the whole run in every multi-decoder workload, and min(v.output_budget, ph) == ph == coalescing_horizon_tokens for every decoder; mean and min are identical. continuous_decode (workloads.py:49) is a single decoder, where mean == min by definition. The claim "84/84 matched 1fbcc3c9 with 3/3 reachable .min() mutations killed" is true by construction and proves nothing about the new rule.
(c) A new declared Rust/simulator divergence
// Note: KV-headroom clamping is Rust-specific (`scripts/scheduling_sim/simulator.py` tracks
// `max_new_tokens - generated` only).
helios/src/scheduler/policy_tests.rs:6931-6932
Rust computes rem with a KV term:
let rem = ((r.max_new_tokens - r.generated_tokens) as usize)
.min(self.limits.max_sequence_tokens.saturating_sub(r.scheduled_consumed as usize));
helios/src/scheduler/policy.rs:548-549, while the simulator has only max_new_tokens - self.generated (simulator.py:26). This is precisely what docs/design-review.md:205-206 forbids: "Do not diverge Helios from the simulator's qualified policy without updating and validating the rule across that catalog."
Fix: add simulator workloads with explicit small/heterogeneous max_new_tokens (the PR's own [1, 100] shape), mirror the KV clamp in View/State.view(), run the simulator catalog plus the 64-seed learning.py (not opened) validation, and re-run served A/B on 975f825 (or its rebase after #661).
M3 — MAJOR: the gain is in total credit, and it accrues to every queued prefiller
Area 2 (unintended system-level consequences: head-of-line blocking).
let per_token = (best_surplus_per_horizon * horizon) / initial_prefill as f64;
if per_token.is_finite() && per_token > 0.0 {
bonus_log[slot] = per_token.ln();
}
helios/src/scheduler/policy.rs:675-677
initial_prefill is the prefiller's whole uncached prompt (r.initial_prefill_tokens(), :557; prompt_tokens - admission_reused_tokens, .max(1) at helios/src/scheduler.rs:351-355), and a prefiller's credited value per candidate is prefill_token * consumed (helios/src/scheduler/utility.rs:94-96). Summed over the prompt, the total coalescing credit per queued prefiller is best_surplus_per_horizon * horizon — independent of prompt length and strictly proportional to horizon. Under main, one near-EOS decoder (rem = 1) capped that total at 1/64 of the configured horizon; at head the horizon stays near ph while any long decoder is resident, so aggregate queued-prefill priority can rise up to 64× in exactly the near-EOS state.
It is not split among beneficiaries: best_surplus_per_horizon is a single scalar shared by all prefillers (:653-665), and the loop at :669 awards the identical per-token bonus to each. There is no 1/q share and no gating on whether a prefiller can actually be absorbed.
Impact: 150K–250K cold prefills hold the GPU ahead of live decoders, which is the mechanism behind the PR's own measured agentic_multiturn TTFT p99 3,323 → 5,144 ms (+54.8%) and cold-heavy-mix SLO 88.1 → 79.1%. The PR reports this as an aside ("Trade-off: …") rather than a gated, bounded limit, and there is no off-switch (M1).
Fix: divide the surplus by the number of prefillers competing for the next wave, cap aggregate coalescing credit per unit time, and/or require positive packing/KV headroom; at minimum ship it behind an off-switch and document the p99 trade-off as a known limit.
M4 — MAJOR: head unrun; the Python test cannot distinguish mean from min; body is stale
Area 4.
-
No run on the head. No CI checks on
975f825; the body'scargo check/cargo test/pytest/check.pyresults are attached to archive hash40596880cc64.docs/design-review.md:247-251: "Disclosure does not excuse skipping runnable CPU checks… Leaving an applicable crate test, simulator sweep, TLA+ conformance run, or Kani proof unrun blocks commit and PR acceptance." -
The Rust tests are genuinely good — say so.
policy_tests.rs:6888-6963covers the mean horizon (n=2 n=3, KV-clamped, single-decoder, zero cases), andpolicy_tests.rs:6966-7079covers the speculativemean_out, including the one true mean-vs-min discriminator:
// 2. When B=4 width-1 is slower than cohort-mean B=2 width-8 even at K=3, surplus vanishes;
// clamping mean_out to min_i(rem_i) = 1 would erroneously report a positive bonus.
helios/src/scheduler/policy_tests.rs:7054-7055
- The new Python end-to-end test does not discriminate. Every assertion is coalescing-ON vs OFF plus an absolute ceiling:
assert dec_coal.summary["elapsed_ms"] < dec_off.summary["elapsed_ms"]
assert dec_coal.summary["elapsed_ms"] <= 7740.0
assert sum(dec_coal_ttfts) / len(dec_coal_ttfts) < sum(dec_off_ttfts) / len(dec_off_ttfts)
assert max(dec_coal_ttfts) < max(dec_off_ttfts) and max(dec_coal_ttfts) <= 330.0
assert dec_coal.summary["max_output_gap_ms"] < dec_off.summary["max_output_gap_ms"]
assert dec_coal.summary["max_output_gap_ms"] <= 190.0
tests/test_scheduling_utility.py:557-562 (same pattern at :585-593). None contrasts mean_i min(rem_i, ph) with main's min_i min(rem_i, ph), so reverting utility.py:235 to a minimum would still pass. The hard-coded ceilings are also brittle against workloads.py/catalog() changes.
-
Body is stale against its own head. Body: "
policy.rs::coalescing_prefill_log_bonus(+11/-10,+1net production LOC)" — head is+16/−18(net −2). Body:mean_out"averagesexpected_at(width).min(rem).max(1.0)" — the.max(1.0)no longer exists (policy.rs:630,:639), and it was always redundant sinceexpected_atreturns>= 1.0(:586-589). The body never mentions the newtests/test_scheduling_utility.py:529-593test or the KV-clamp divergence its own test comment documents. -
Claim verified true: "Single-decoder and homogeneous-remaining cohorts are unchanged" — confirmed for both
mean_outandhorizon(K=1 and equalremmake mean == min).
Fix: add a mean-vs-min delta assertion (Python or Rust) that fails under min_i for the [1, 100]-shaped cohort, rewrite the body against head's diff and semantics, and paste a head-SHA test run.
M5 — MINOR: the sampled span widened from min-over-cohort to mean-over-all-active
Area 1/3 (metric-span check).
let served = n_streams.min(shape.batch);
...
let mean_out = mean_capped(&decoder_rems[..decoder_count], expected_at(eff_width));
helios/src/scheduler/policy.rs:622, :630 (and :638-639)
mean_capped always averages over all active decoders (&decoder_rems[..decoder_count]), including streams the scored shape cannot serve in this wave, while the rate is multiplied by served (:632, :641). Under the old min_i clamp an unserved long decoder could not inflate anything; now it can. The simulator has the identical shape — served = min(n_streams, graph.decode_capacity) and mean_out = sum(...) / k over all decoders (scripts/scheduling_sim/utility.py:214-218) — so this is a shared approximation, not a new Rust/sim divergence. Impact is confined to sub-batch graph choices and is bounded because served still scales the rate; downstream consumers are continuous, threshold-free comparisons (policy.rs:795).
Fix (cheap): average over the served streams, or document explicitly in both docs/scheduling-runtime-design.md and utility.py that mean_out is a whole-cohort statistic.
Verified sound — no finding
- Array bounds / panics:
decoder_remsis[usize; REQUEST_LANES](policy.rs:531) written only atdecoder_count, in the same slot loop that fillsdecoder_slots(:551-553);mean_cappedonly sees&decoder_rems[..decoder_count]withdecoder_count >= 1guaranteed byif decoder_count == 0 || prefiller_count == 0 { return bonus_log; }(:567-569). No index can exceed the array. - Div-by-zero / NaN:
rems.len() == decoder_count >= 1;initial_prefillis.max(1)(scheduler.rs:354); theper_token.is_finite() && per_token > 0.0guard atpolicy.rs:676still gatesln(). Removing the oldif horizon > 0.0wrapper cannot produceln(0). - Hot path cost: allocation-free (slice fold;
expected_athoisted out of the numeric loops by this PR). O(K) per scored shape inbest_decode_rate(:602-648) and O(K) per prefiller (:669-679). No new lock, no new I/O, no unbounded buffering, no state retained across resets — all locals. - Determinism:
decoder_remsfilled in slot order; floating-point summation order is stable run to run. - Contracts: no wire/proto,
GraphDescriptor, or manifest change;PolicyConfigis internal and reachable only via--scheduler-policy balanced|throughput(server/config.rs:305-310). No captured-graph op contract is triggered, so no owner sign-off gate applies. - Interaction with
#661:coalescing_prefill_log_bonusreads none of the state#661changes (first_output_wait_ns, reconciled interior-cutfirst_output_value— cf.policy.rs:773), so there is no code-level conflict, only the merge-order/dependency issue in M1/M2. - Docs accuracy: the spec sentence at
docs/scheduling-runtime-design.md:225-229("averaged across active decoders after clamping each decoder's remaining output budget to the prefiller's post-prefill output budget and the configured horizon") is accurate againstpolicy.rs:670-671andutility.py:234-235. An earlier draft claim that it misdescribed the clamp was withdrawn. The only surviving docs gap is operator-facing staleness folded into M1 (helios/README.md:482-483still says "a 64-token decode-batch coalescing horizon" with no mention of cohort averaging;docs/scheduling-runtime-design.md:713is generic).
Other verification & observability notes
- Sole applicable gate is unrun:
verification/helios-lifecycle/check.py's 26 Rust mutations targetscheduler.rs,execution/threaded*/protocol.rs(not opened),cache.rs(not opened),scheduler/checkpoints.rs(not opened),offload/transfer.rs(not opened),server/runtime.rs(not opened) — neverpolicy.rs— so thecheck.pypass cannot detect a regression here. That leaves the simulator catalog and the 64-seedscripts/scheduling_sim/learning.py(not opened) validation (docs/design-review.md:195-206) as the only applicable gates, and the sweep that was run is inert (M2). - No new metric/observability surface is added to observe the effect in production: the coalescing bonus feeds
prefill_tokenonly throughunit + (token_log - scale).exp() + (coalesce_log - scale).exp()(policy.rs:794-795), which is unexported. Given M3, a counter or log of granted coalescing credit per prefiller would make the pull-ahead auditable. - Platform parity: the change is pure scalar arithmetic in the scheduler with no OS-specific path, so there is no Unix/Windows divergence to report.
Open questions / could not be found
- Whether
975f825has passed CI — no checks are reported on the head, and the author has not stated one. - Whether any A/B has been re-run on
975f825— no; all numbers come fromdf9a8ebd/dbbf65df/38130855and archive40596880cc64. - The magnitude of the risk under the 64-seed
learning.py(not opened) catalog — the run is absent from the PR, so only the fact that this gate is unrun is established, not its outcome. - The isolated size of the cohort-mean credit increase in a served run — the PR provides no experiment separating it from
#661; "up to 64×" here is an upper bound on the horizon ratio derived from the code, not a measurement. - Whether the author intends a rebase after
#661(3d868f84) lands — the branch is a single squash commit on amainthat predates it, so a rebase is required and will re-touch the same overlapping files.