Correctness, Contracts & System-Level Consequences review — PR #661 (helios/scheduler: explore smaller prefill chunks under active age-priced streams, head 3d868f84)
Key findings
- Major —
resolve_prefill_kind_fromnow mapsPREFILL-only capacities to a non-existentTerminalPrefillwheneverdeferred_prefillis set (helios/src/scheduler.rs:901-907).needs_terminalis computed and then unused in that branch. On any subset catalog the complete-state smallPREFILLshapes become unschedulable for a deferred tail, andservice_ratessilently loses their measured token rate, shifting cross-request fairness normalizers. This directly contradictshelios/model-contract.md:182-186and diverges from the Python reference scheduler (ignition/direct/scheduler.py:300-312), which still requires the capacity to be in the terminal catalog. Policy-independent, so--scheduler-policy throughputis not an escape hatch. - Major (risk) — interpolation is evaluated before the natural-fit zero-duration marker (
helios/src/scheduler/policy.rs:531-542) with the guardcapacity <= nat, so exactly the natural-fit capacity loses theduration_ns == 0precedence ofValueRate::compare(helios/src/scheduler/utility.rs:167-172) precisely when age pricing is active. If the interpolated estimate cannot outbid a decoder, the nat-fit shape is never executed and therefore never measured — the #538 discovery invariant no longer holds underbalanced, and (with the new global drain athelios/src/scheduler.rs:1187-1190) the unselectedDiscoveryplan also cannot pipeline. No test covers nat-fit precedence underage_price > 0.0. - Minor — doc/simulator/claim residue:
docs/scheduling-theory.md:74-76and:121-122still assert the opposite of the change;docs/scheduling-utility.mdwas not updated for the two new credit rules; the body's "Opt-out:--scheduler-policy throughput" overstates the escape hatch because finding 1 is policy-independent.
1. Correctness, Safety & Platform Parity
Finding 1 (Major): deferred-prefill kind resolution now fabricates a TerminalPrefill request for shapes that do not exist.
helios/src/scheduler.rs:899-907:
let needs_terminal =
end >= next_stop || (window > 0 && next_stop.saturating_sub(end) <= window);
if self.terminal_prefill_catalog.binary_search(&capacity).is_err() {
return if request.deferred_prefill {
GraphKind::TerminalPrefill
} else {
GraphKind::Prefill
};
}
if needs_terminal {
Before this PR the condition was request.deferred_prefill && needs_terminal. The removal makes needs_terminal dead in that branch and makes the result depend only on deferred_prefill.
Verified consequences:
- Contract violation.
helios/model-contract.md:182-186states: "Helios derives the tail-protection window from the prepared catalog as the largestPREFILLcapacity absent from theTERMINAL_PREFILLcatalog; those smallerPREFILLgraphs execute complete continuation state. When a model declares noTERMINAL_PREFILLgraphs, or omits a capacity from the terminal catalog, Helios falls back toPREFILLwith no contract version change." The PR does the opposite: an omitted capacity is now refused rather than used as the complete-state fallback. - Candidate loss.
helios/src/scheduler/policy.rs:1427requiresself.costs.prefill_entry(kind, capacity)to exist (let Some(predictor) = self.costs.prefill_entry(kind, capacity) else { return; };) and:1435re-checksself.resolve_prefill_kind(r, capacity, work, cut) != kind. For a capacity absent from the terminal catalog underdeferred_prefill,Prefill(cap)is now rejected by:1435andTerminalPrefill(cap)has no cost entry, so no candidate at that capacity can ever be produced — the shape is unreachable for the remaining chunks of a deferred prompt. - Service-pricing shift (metric span check).
helios/src/scheduler/service.rs:307-319:
let kind = self.resolve_prefill_kind_from(request, start, capacity, work, cut);
if terminal_only && kind == GraphKind::Prefill {
continue;
}
if let Some(ns) = self
.costs
.prefill_duration(kind, capacity, work, request.consumed_tokens)
With kind == TerminalPrefill at a capacity that has no terminal shape, prefill_duration returns None (helios/src/scheduler/cost.rs:650-651: self.prefill_entry(kind, capacity).map(...), and prefill_entry returns None when self.entry(key)? is absent, :667), so that capacity's measured Prefill throughput contributes nothing to ServicePrice/token_rate, where previously it did. Service price feeds token_log/rebase fairness normalizers, so the admission-fairness metric changes scope silently — the PR body never mentions it.
- Policy-independent. No
PolicyConfigfield gates the branch, so the documented opt-out (--scheduler-policy throughput,helios/src/scheduler/policy.rs:50-52zeroes onlydelivery_fairnessanddecode_age_price) does not restore the old classification. - Mirror divergence. The Python reference scheduler still implements the old rule (
ignition/direct/scheduler.py:300-312):if capacity is None or capacity not in terminal: return "prefill". So the Rust runtime and its in-repo reference model now disagree on the same catalog, which is exactly the artifact the verification harness compares against. - Test coverage / enshrinement. Only synthetic catalogs exercise it (
helios/src/scheduler/policy_tests.rs:8257-8280,:8360-8390), andverification/helios-lifecycle/check.py:527-535now mutates this exact widened line under the message "deferred prefill small cut bypass", which describes the older&& needs_terminalrule. The harness therefore locks in a change it does not describe.
Concrete fix: restore request.deferred_prefill && needs_terminal, or gate only on capacities whose terminal shape actually exists (i.e. keep Prefill for capacities absent from terminal_prefill_catalog, which the contract calls complete-state), then add a subset-catalog test (e.g. PREFILL 128..=2048, TERMINAL_PREFILL 256..=2048) asserting that a deferred tail still has a legal chunk and that ServicePrice at 128 is nonzero. Update check.py:527-535 and the Python prefill_kind in the same change if the widening is intentional.
2. Unintended System-Level Consequences
Finding 2 (Major, risk): the new interpolation displaces the natural-fit discovery precedence under load.
helios/src/scheduler/policy.rs:531-542:
if age_price > 0.0 && plan.nat_fit.is_some_and(|nat| capacity <= nat) {
...
if let Some(ns) = interp { return Some(ns); }
}
(plan.nat_fit == Some(capacity)).then_some(0)
The interpolation branch is tested first and its guard includes capacity == nat, so the Some(0) marker at :542 is only reached when no interpolated estimate exists. helios/src/scheduler/utility.rs:167-172 makes that marker load-bearing:
pub fn compare(self, other: Self) -> std::cmp::Ordering {
(self.duration_ns == 0)
.cmp(&(other.duration_ns == 0))
.then_with(|| self.score.total_cmp(&other.score))
.then_with(|| other.duration_ns.cmp(&self.duration_ns))
}
A zero-duration candidate outranks every measured candidate regardless of score. Giving the nat-fit capacity a positive interpolated duration removes that precedence in exactly the regime the PR targets. If the estimate loses to a measured decoder, the shape is never dispatched, so it is never observed — the estimate stays interpolated forever, and the Discovery tagging (helios/src/scheduler/policy.rs:545-548) grants no refresh credit (helios/src/scheduler/refresh.rs:72-96). Compounding it, helios/src/scheduler.rs:1187-1190 now forces feedback on any prefill plan while an age-priced stream is resident:
fn prefill_step_requires_feedback(&self, plan: &ScheduledPlan) -> bool {
if self.has_active_age_priced_stream() {
return true;
}
so a losing Discovery prefill cannot ride the two-frame window either. The PR's own cost test only checks the zero-age direction (it asserts a strictly lower throughput than 16384 "so solo zero-age prefill still prefers 16384"), and no policy test asserts nat-fit precedence with age_price > 0.0.
Impact: plausible extra latency and a self-reinforcing "never measured" state for the natural-fit shape under balanced with cold prompts beside active decoders — the workload class the PR's cold-heavy-mix row already shows regressing (SLO 89.0 % → 81.6 %, drain cutoffs 4 → 7).
Concrete fix: test plan.nat_fit == Some(capacity) before the interpolation branch (or change the guard to capacity < nat) so the natural-fit grap
h keeps duration_ns == 0; add a policy test that with an active age-priced decoder the nat-fit shape is the first prefill candidate dispatched within N passes.
Finding (Minor): the drain is an intended serialization but costs prefill throughput. helios/src/scheduler.rs:1187-1190 collapses two-frame prefill pipelining to single-frame whenever any age-priced stream is resident. That is deliberate, but combined with terminal_age_price staying 1.0 under throughput, any resident terminal_cleanup stream (helios/src/scheduler.rs:996-1005: if policy::terminal_cleanup(r) { self.policy.terminal_age_price > 0.0 }) also disables pipelining there. The PR body acknowledges this, so this is not a defect — only a note that the "Opt-out" line must not be read as a full revert.
No contention/memory findings. has_active_age_priced_stream is O(active slots) and is called from three hot paths (service.rs:297, policy.rs:503, scheduler.rs:1188); it allocates nothing, takes no lock (the scheduler is single-threaded), and terminal_prefill_window is now cached and recomputed by both catalog setters (scheduler.rs:808, :843, :847-858), removing the previous O(catalog) recompute with no stale-state path. No unbounded buffering, no new I/O, no failure-propagation widening; nothing in this PR touches a shared waiter that a bad record could poison.
3. Architecture, Contracts & Charter Compliance
Finding (Minor): the change is default-ON under the shipped balanced preset with no opt-in, and it changes a documented contract. It adds no CLI flag and no PolicyConfig field, so every balanced deployment picks up the classification and drain changes. Charter-wise the served-workload evidence bar (#210) is met in form (SM120 TP4 flare run A/B on the head; 0 server errors), but the headline rows are mixed: stalls improve (−32 % / −42 %) while SLO falls on all three workloads (91.1 % → 89.4 %, 94.8 % → 89.3 %, 89.0 % → 81.6 %) and two workloads are n=1. The duration-estimate interpolation is sound and keeps ScoredPrefill isolated (helios/src/scheduler/cost.rs:688-776: u128-widened interpolation, t_hi <= t_lo clamp, .max(1)), and there is no wire/proto, GraphKind, GraphDescriptor, or ABI change. The concrete contract defect is finding 1, not the architecture.
Finding (Minor, docs): docs/scheduling-theory.md:74-76 ("Prefill has no externally visible per-chunk cadence") and :121-122 ("Two long prefills do not need smaller chunks merely to alternate") still state the opposite of what this PR now does; the file was touched (+18/−3) but not at those lines. docs/scheduling-utility.md documents frac = work / initial_prefill and the anchor-split wait clock but was not updated for the two new credit rules. Fix: reconcile those four sentences in the same PR.
4. Tests & Claim Accuracy
- Uncovered new paths (Major, part of findings 1–2): no test uses a
PREFILL-strict-superset catalog withdeferred_prefillto assert a chunk remains legal, and no test asserts natural-fitSome(0)precedence underage_price > 0.0. Everything else new is covered:policy_tests.rs:8734-8929(first_output_wait_preserved_across_age_priced_non_terminal_prefill_chunks),:8931-9199(reconciled interior-cut credit),:8420-8475(has_active_age_priced_streambranches),:8526-8613(oversized unmeasured terminal prefill), plus the three newcost.rsinterpolation tests. - Claim accuracy (Minor): "Opt-out:
--scheduler-policy throughput" is inaccurate for thedeferred_prefillwidening (policy-independent, finding 1). Thethroughputpipelining statement is now accurate. Residual: the simulator's single prefill family validates only the interpolation rule, not the drain, wait-clock carry, or reconciled credit, and the--preset validate --configsfile is not committed, so the 64-seed gate is not reproducible from the tree.
Verified sound (no finding)
Interpolation arithmetic and non-monotonic clamp (cost.rs:695-776); the last_interp memo keyed on (work, scheduled_consumed) and reset per capacity (policy.rs:1429, :1092); is_unmeasured_candidate cannot mis-tag a measured candidate (policy.rs:545-548); the age-priced resize_prefill cap only shrinks (policy.rs:1837-1852); the cached terminal_prefill_window has no stale path (scheduler.rs:808, :843, :847-858); preserves_first_output_wait's new arm is correctly gated (policy.rs:500-505); the reconciled interior-cut credit is guarded and uses (new_frac - old_frac).max(0.0) (policy.rs:1388-1408); platform parity is a non-issue (single-threaded scheduler math, no new unsafe, syscall, or OS-conditional code).
Open questions
- Is the
resolve_prefill_kind_fromwidening deliberate, and if so, which real signed core has aTERMINAL_PREFILLcatalog that is a strict subset ofPREFILL? Only synthetic catalogs test it. - Should
ignition/direct/scheduler.py:300-312andverification/helios-lifecycle/check.py:527-535be updated to match, or is the Rust side the regression? - Why does SLO fall while stalls drop (
cold-heavy-mix,long-context-mixed, bothn=1)? No explanation in the body. - Where is the
--configsfile for the reported 64-seed ACCEPTED run?
Could not verify
cargo-kani was not run (not installed on the build host); no independent reproduction of any headline A/B number exists; GB10 was not re-measured on 3d868f84; scripts/scheduling_sim/*.py and the three Python test files were reviewed only via the dossier, not opened at this head.