Review — PR #661 helios/scheduler: explore smaller prefill chunks under active age-priced streams
Lens: Correctness, Contracts & System-Level Consequences. Head 29f2b5b, base 5d53040e, author FujitsuPolycom, draft, no CI, no reviews.
Key findings
- Major —
throughput(decode_age_price = 0.0) does not keep two-frame pipelining when a terminal-cleanup stream is resident. The PR text says it does, and the PR's own new test asserts the opposite.policy.rs:50-52zeroes onlydelivery_fairnessanddecode_age_price;terminal_age_pricestays1.0(policy.rs:37), andhas_active_age_priced_streamconsultsterminal_age_pricefor cleanup streams (scheduler.rs:989-998), feeding an unconditional early return (scheduler.rs:1180-1183). Unintended reach to--scheduler-policy throughputusers with checkpoint/snapshot streams; the description's28/24/19launch-count evidence does not cover that case. - Major — the feedback barrier is scheduler-global, not plan-scoped: every
Prefillplan drains whenever any age-priced stream is resident, with no reference to the plan's own lanes.scheduler.rs:1180-1183returnstruebefore any lane inspection. Under the shippedbalanceddefault (policy.rs:35-37) every non-terminal prefill chunk becomes a full GPU round-trip, reversing #645's just-merged two-framePrefillpipelining; no measurement exists at head for it. - Major — undeclared
GraphKindresolution contract change.scheduler.rs:896-902now maps every capacity outsideterminal_prefill_catalogtoTerminalPrefillwhendeferred_prefillis set (needs_terminal, computed at:894-895, becomes dead on that branch), not just the tail. This tightens #613's invariant but is described only as a parenthetical ("excludes non-terminal-catalog shapes underdeferred_prefill") and is covered only by synthetic fixtures. - Minor — the
check.pymutation now asserts a stronger claim than its own failure message (check.py:529-535source vs:605message), so a re-run of--mutationswill misdirect whoever chases a survivor. - Minor — the interpolation's floor endpoint ignores
work/start_positionand its decode floor is unfiltered across batches, so a checkpoint-cut-limited small chunk gets priced as if it did a full-capacity forward pass — biasingValueRateagainst precisely the small shapes this PR wants to explore (cost.rs:715-726,:775-777,:782-784). - Minor —
docs/scheduling-theory.mdis untouched and states the opposite of the new shipped default, with no opt-in (policy.rs:35-37), against the charter's "be explicit" line.
Verified sound: terminal_prefill_window caching, PrefillSlotPlan hoisting, the interpolation's overflow/clamp arithmetic, and the service_rates rescan gating. No unsafe, no new GraphKind, no wire/ABI change, no CLI flag — the "0 flags" claim is factually true.
1. Correctness, safety & platform parity
Finding 2 (Major) — the feedback barrier is scheduler-global, not plan-scoped
helios/src/scheduler.rs:1180-1201:
fn prefill_step_requires_feedback(&self, plan: &ScheduledPlan) -> bool {
if self.has_active_age_priced_stream() {
return true;
}
if plan
.checkpoint_plans
.iter()
.any(checkpoints::CapturePlan::requires_feedback)
and helios/src/scheduler.rs:989-998:
pub(super) fn has_active_age_priced_stream(&self) -> bool {
self.slots.iter().filter_map(|s| s.request.as_ref()).any(|r| {
if policy::terminal_cleanup(r) {
self.policy.terminal_age_price > 0.0
} else {
self.policy.decode_age_price > 0.0
&& matches!(r.phase, RequestPhase::Decode | RequestPhase::Resume)
}
})
}
The early return fires before the per-lane predicate at :1191-1200 is ever consulted, and has_active_age_priced_stream scans all slots (self.slots.iter()), not plan.lanes. Two consequences that are objectively not plan-scoped:
- A
Prefillplan carrying only prefill lanes drains because an unrelated resident slot happens to be decoding, resuming, or in terminal cleanup — including a decoder that has no lane in this plan and cannot be co-scheduled with it anyway. - The scan includes the planned request itself: a request in
RequestPhase::Resume(age-priced viadecode_age_price > 0.0,scheduler.rs:994-995) satisfies the predicate from its own slot, so its own prefill chunks drain even when it is the only resident stream. That is the specific case the description calls out as unaffected: "solo prefill andthroughput(0.0) keep two-frame pipelining."
Combined with helios/src/scheduler/policy.rs:1763-1766:
if self.checkpoint_anchor_waiting(&plan.checkpoint_plans)
|| (self.plan_requires_feedback(&plan) && !self.submissions.is_empty()) {
return None;
}
the plan is discarded whenever anything is in flight, so each non-terminal chunk costs a full host round-trip. plan_requires_feedback reaches this via scheduler.rs:1207 (GraphKind::Prefill => self.prefill_step_requires_feedback(plan)).
Impact: under the default balanced policy this removes #645's Prefill two-frame pipelining for the whole population of prefill chunks, on the hottest path in the scheduler, whenever one decoder is resident. It is the mechanism behind the claimed -21.6% peak gap, but it also produces the -2.0% output regression, and it is a global default change with no per-request or per-plan escape.
Fix: scope the barrier to the plan: return true only when a lane in plan.lanes belongs to a request in an age-priced decode/resume/cleanup phase, or when an age-priced stream exists outside plan.lanes. Keep the existing plan.lanes predicate for the non-age-priced path.
Finding 5 (Minor) — the interpolated floor endpoint discards work and start_position
helios/src/scheduler/cost.rs:716-726 builds the decode floor from any measured decode-ish entry, with no batch filter and no relation to the shape being priced:
if matches!(
key.kind,
GraphKind::Decode | GraphKind::Speculative | GraphKind::Resume
) {
decode_floor = Some(decode_floor.map_or(estimate.nanos, |f| f.min(estimate.nanos)));
continue;
}
and helios/src/scheduler/cost.rs:774-784 then interpolates purely in token capacity from that floor:
let (c_hi, _, t_hi) = hi?;
let (c_lo, t_lo) = match lo {
Some((c, _, t)) => (c, t),
None => (0, decode_floor?.min(t_hi)),
};
if t_hi <= t_lo {
return Some(t_hi.max(1));
}
let span = (c_hi - c_lo) as u128;
let offset = (capacity - c_lo) as u128;
let interp = u128::from(t_lo) + (u128::from(t_hi - t_lo) * offset) / span;
Note that measured peers do go through their predictor (:745-755, pred.predict(key.tokens, start_position)), but the floor is a raw nanos treated as the value at capacity == 0. So an interpolated price is t_hi * capacity / c_hi regardless of how many tokens the chunk actually moves or how deep the start position is. A 128-token chunk bounded by a checkpoint cut at a deep scheduled_consumed is priced as if it did a full 128-token forward at position 0; the interpolated value can sit far above or below the true cost, and the error is largest exactly in the cut-limited / deep-context regime the PR targets.
Impact: the exploration is admitted or rejected on a mis-priced ValueRate (policy.rs:999-1030 feeds interp straight into lane_value_for_tokens at :1038-1039). Because the mis-price is systematic in (work, start_position) rather than random, it biases selection rather than merely adding noise.
Fix: scale the floor endpoint by work, e.g. price the floor as t_lo * work / capacity (or route it through PrefillPredictor::constant and predict(work, start_position) like the peers), and restrict decode_floor to key.batch == 1 measurements so a wide-batch decode step cannot become a narrow-shape floor.
Verified sound in this area
terminal_prefill_windowcaching (scheduler.rs:657,:842-853). Recomputed from bothprefill_graphs(:803) andterminal_prefill_graphs(:838), and both setters are guarded against post-admission mutation (:789-791,:823-825), so the cached window cannot go stale relative to the catalogs it derives from.PrefillSlotPlanhoisting (policy.rs:79-86).ready/nat_fit_readyguards per plan iteration;last_interpis memoised on(work, scheduled_consumed)(policy.rs:1006-1021), so it can only produce a conservative cache miss, never a cross-slot stale hit.- Interpolation arithmetic.
t_hi <= t_lois clamped before subtraction (cost.rs:779-781), interpolation is inu128withu64::MAXsaturation and a.max(1)floor (:782-785); no underflow or overflow path. This is the guard the dossier notes #654 lacked. - No
unsafe, no newGraphKind, no wire/ABI change, no CLI flag anywhere in the diff.
2. Unintended system-level consequences
Finding 1 (Major) — throughput loses pipelining when a terminal-cleanup stream is resident; the PR text says otherwise and its own test proves otherwise
helios/src/scheduler/policy.rs:35-37 and :50-52:
decode_age_price: 0.1,
terminal_value: 256.0,
terminal_age_price: 1.0,
...
pub fn throughput() -> Self {
Self { delivery_fairness: 0.0, decode_age_price: 0.0, ..Self::default() }
}
terminal_age_price keeps its 1.0 default, and has_active_age_priced_stream tests it for cleanup streams (scheduler.rs:991-992), so prefill_step_requires_feedback returns true for a non-terminal Prefill under throughput whenever a request is in Snapshot/terminal cleanup (policy::terminal_cleanup, policy.rs:1957-1965).
The PR's own test documents exactly this — helios/src/scheduler/policy_tests.rs:7784-7826:
// 2. policy::terminal_cleanup(r) with terminal_age_price > 0 drains nonterminal Prefill even
// when decode_age_price == 0; zeroing terminal_age_price restores pipelining.
let mut t = interactive_engine(2, false);
t.configure_policy(PolicyConfig::throughput()).unwrap();
assert_eq!(t.policy.decode_age_price, 0.0);
assert!(t.policy.terminal_age_price > 0.0);
...
assert!(
t.plan_requires_feedback(&plan_t),
"nonterminal Prefill must drain when a terminal-cleanup stream is age-priced"
);
against the PR description's claim: "solo prefill and throughput (0.0) keep two-frame pipelining."
Impact: operators who selected throughput precisely to avoid age pricing still pay a per-chunk round-trip whenever a checkpoint capture or snapshot stream is resident — the common shape for long interactive sessions with checkpointing. The PR's throughput-parity evidence (28/24/19 launches, wall +0.3%) was measured on solo/prefill-only workloads and cannot cover it. This is a reach the description explicitly denies, so an operator reading the PR would not look for it.
Fix: either zero terminal_age_price in PolicyConfig::throughput() so 0.0 means "age pricing disabled" as claimed, or state the terminal-cleanup exception in the description and add a throughput launch-count measurement with a resident snapshot stream.
Finding 3 (Major) — undeclared widening of resolve_prefill_kind_from, and it can force TerminalPrefill for shapes the core never intended to serve terminally
helios/src/scheduler.rs:894-902:
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
};
}
needs_terminal is no longer consulted on the deferred branch. Before this PR the deferred guard selected TerminalPrefill only for the tail; now every catalog capacity absent from terminal_prefill_catalog is forced terminal.
Impact: this is a GraphKind selection contract change in the shared scheduler, and it is where #613's deferred-prefill invariant lives. Any core whose TERMINAL_PREFILL catalog is a strict subset of PREFILL (#479 made TERMINAL_PREFILL optional and it starts at 256 while PREFILL starts at 128) silently loses the non-terminal shapes it used to serve under deferred_prefill. Note also that prefill_requires_terminal_completion_from short-circuits on an empty terminal catalog (scheduler.rs:924), while this branch does not — so the two predicates no longer agree about when TerminalPrefill is mandatory. The only coverage is synthetic (policy_tests.rs:7432-7528 per the dossier); no served-core evidence exists.
Fix: state the resolution rule explicitly in the Why/What (it is a real contract change, not a footnote), add a test asserting the two predicates agree for catalogs where TERMINAL_PREFILL ⊂ PREFILL, and confirm from a signed core's graph list whether any shipping configuration is affected.
Cross-cutting evidence gap (Major, claims)
Every headline number was measured on fdb10bb5; head is 29f2b5bc. The two changes most likely to move the numbers land between them: the feedback barrier at scheduler.rs:1180-1183 (findings 1 and 2) and the resize_prefill guard at policy.rs:1789-1797:
let terminal_only =
self.prefill_requires_terminal_completion_for_age(request, cut, age_price);
let catalog = self.prefill_catalog_for_terminal(
request.prefill_kind(),
terminal_only || request.deferred_prefill,
);
resize_prefill now reads the terminal catalog under deferred_prefill and caps capacity under age pricing (:1793-1797), which changes which chunk sizes are legal — i.e. it changes the very set of chunks whose cost the interpolation is exploring. The PR's own Limits bullet concedes the A/B predates both. There is no measurement at head in the repo, in the PR, or in the sibling PRs. For a performance PR under the charter's #210 requirement this is the load-bearing gap: the numbers describe code that is not what would merge.
Fix: re-run the SM120 A/B (and one GB10 arm) at 29f2b5bc before requesting review, and quote the head SHA in the Result table.
Checked and found sound
-
service_ratesrescan (helios/src/scheduler/service.rs:224-231) is correctly and narrowly gated:token_rate = token_rate.max(scan_prefill(terminal_only)); if token_rate == 0.0 && terminal_only && self.has_active_age_priced_stream() && !self.prefill_must_complete_terminally_from(request, start, cut)The fallback only fires when the terminal-only scan already priced the request at 0.0, so it cannot mask a measured terminal cost or inflate the rate of a request that genuinely must finish terminally. No metric-span shrink: the fallback recomputes the same
work/first_outputper-capacity spans (:204-219) as the primary scan. -
No new lock, mutex, allocation or unbounded retention is introduced.
terminal_prefill_windowremoves work (it replaces per-call catalog scans).PrefillSlotPlanisCopyand stack/per-iteration. The interpolation loop isO(entries)over an existing map with no allocation; it runs only on thepredictor == Noneunmeasured path (policy.rs:999-1022), i.e. it does not touch the measured hot path.
3. Architecture, contracts & charter compliance
Finding 6 (Minor) — docs/scheduling-theory.md is untouched and contradicts the new default-on behaviour
docs/scheduling-theory.md:93-97:
All pure prefill, pure decode, and available mixed graphs compete on this score.
No duration ceiling, prefill size preference, or breadth-before-depth rule
precedes it. A graph consuming 64 useful prompt tokens earns 64 prefill units
whether its capacity is 64 or 4096. Inactive rows and rejected drafts earn zero.
Completing prefill emits one first token, counted once in `D_i`.
and docs/scheduling-theory.md:119-120:
- Fully occupied 4096-token prefills win when they have the highest useful
prefill rate. Two long prefills do not need smaller chunks merely to alternate.
The PR updates docs/scheduling-runtime-design.md and helios/README.md, and qualifies scheduling-runtime-design.md:316, but not the theory document — which now records the project's prior explicit position against this direction. This is the same doc-contradiction class the dossier notes was flagged on #550 and #663.
The activation story compounds it: PolicyConfig::default() ships decode_age_price: 0.1, terminal_age_price: 1.0 (policy.rs:35-37), and the only way to avoid the new interpolation and the new barrier is to leave balanced — which also drops delivery_fairness to 0.0 (policy.rs:51). So there is no way to keep delivery fairness without the age-priced prefill chunking. Under the charter's "Be explicit and pin everything. No magic defaults", the 0 flags claim is accurate but reads as a defence where it is actually the problem: the behaviour change is implicit in the existing preset.
Fix: qualify scheduling-theory.md:93-97 and :119-120 the way scheduling-runtime-design.md:316 was qualified (they can be made consistent by pointing at the age-priced exception), and either add a PolicyConfig field for the exploration or say plainly that balanced now carries it.
Contracts checked, no issue
- No captured-graph op added, no new
GraphKind, no re-export, no ABI/wire change, nounsafe— so no owner sign-off is triggered by the graph contract. - No per-model branch: the whole change is inside
helios/src/scheduler; nothing keys on a model. The interpolation path does not depend onterminal_prefill_catalogat all, so cores with only aPrefillcatalog get the interpolated exploration too — worth stating in the description, but not a charter violation. - No
AGENTS.md(not opened)-level contract is touched by the four scheduler files.
4. Tests & claim accuracy
Finding 4 (Minor) — the mutation anchor asserts a stronger claim than its failure message
verification/helios-lifecycle/check.py:529-535 (source) and :605 (unchanged message):
" if self.terminal_prefill_catalog.binary_search(&capacity).is_err() {\n"
" return if request.deferred_prefill {\n"
" GraphKind::TerminalPrefill\n"
" } else {\n"
" GraphKind::Prefill\n"
" };\n"
" }\n"
with :572-579 (" return GraphKind::Prefill;\n") as the mutant and :605 as:
"deferred prefill must schedule TerminalPrefill before capturing a boundary checkpoint"),
The mutated source now removes the terminal-catalog guard for all capacities, whereas the message still describes the older, narrower && needs_terminal mechanism (which the dossier notes was the anchor's previous source string). Layer-3 verification therefore asserts a claim its own description misstates; anyone re-running --mutations and reading a survivor will look for the wrong mechanism.
Fix: update the message to describe the guard as written, e.g. "deferred prefill must never select a capacity outside the terminal prefill catalog".
Other test-quality observations (verified)
- The new barrier and interpolation are tested at real entry points —
phase_plan,plan_requires_feedback,candidates,available_plan,service_rates— which is the right layer.policy_tests.rs:7745-7827in particular is an honest test: it encodes thethroughputexception that contradicts the description rather than hiding it. - The three
cost.rsinterpolation tests (:1280,:1355,:1474per the dossier) cover the inverted, equal, and floor-exceeds-hi cases, matching the clamps atcost.rs:779-781. - No in-repo harness reproduces the reported workloads (
mixed-c32,14K+32K+64K); the only added workload data is synthetic (scripts/scheduling_sim/workloads.py), andtests/test_scheduling_utility.py:421-441asserts a simulated millisecond gap for the pre-existing utility policy, not the interpolation. So the interpolation rule itself has no independent test outside unit tests. - The
docs/design-review.md(not opened) layer-2 gate is unrun: the PR's own Limits concedelearning_policy.py(not opened) andkaniwere not run, and the simulator has no representation of an unmeasured cost, so the new rule has no simulator counterpart to validate against. Not re-verified in code this session (dossier + PR text), but it is a stated gate.
Claim-by-claim accuracy
| Claim (PR text) | Verdict |
|---|---|
"0 flags, unsafe, hardcoded capacities, model branches, or ABI changes" |
Accurate for flags/unsafe/branches/ABI; no production hardcoded capacity added. |
"Drains between non-terminal Prefill steps while an active decode/resume/cleanup stream is age-priced" |
Accurate, and more precise than the description's summary — the code drains for every Prefill plan, not just between consecutive steps (scheduler.rs:1180-1183). |
"solo prefill and throughput (0.0) keep two-frame pipelining" |
Inaccurate for throughput with a terminal-cleanup stream resident; the PR's own test policy_tests.rs:7804-7807 asserts the drain. |
"excludes non-terminal-catalog shapes under deferred_prefill (incl. resize_prefill)" |
Understated — it excludes them from Prefill entirely by forcing TerminalPrefill (scheduler.rs:896-902), and resize_prefill also loses capacity capping under age pricing (policy.rs:1789-1797). |
| All Result-table numbers | Measured at fdb10bb5, not at head 29f2b5bc; single trial, no CI, no independent reproduction. |
"SM120 throughput (0.0) launches identical (28/24/19, wall +0.3%)" |
Does not cover the terminal-cleanup case that finding 1 shows is affected. |
Open questions / what could not be found
- No measurement exists at head
29f2b5bcanywhere — not in the repo, the PR, or siblings #660/#663. Which of the headline deltas survive theresize_prefillguard (policy.rs:1789-1797) and the barrier (scheduler.rs:1180-1183) is unknown, and those are the two changes most likely to move them. - Does the plan-scoping of the barrier (finding 2) actually cost throughput in practice? The
-2.0%mixed output suggests some cost is already visible in thefdb10bb5numbers; a plan-scoped version might recover it, but no arm isolates this. - Does any signed core ship
TERMINAL_PREFILL ⊂ PREFILLand serve deferred-prefill requests? Finding 3 needs a real catalog to be more than synthetic risk; no such evidence was found. - Does the two-predicate disagreement (
prefill_requires_terminal_completion_fromreturningfalseon an empty terminal catalog atscheduler.rs:924vsresolve_prefill_kind_fromforcingTerminalPrefillat:896-902) ever produce an illegal kind request on a core with noTerminalPrefillgraphs? Not tested. - How do #661 and #660 interact (same author, same
mixed-c32baseline, opposite stall direction:215 → 78vs215 → 434)? Only the author's #663 comment measures them together, and onfdb10bb5. - Rebase with #655 (rewrites
ActionCosts/measured_durationin the same file the interpolation reads) is substantive, not cosmetic; untested. learning.py(not opened)'s 64-seed catalog (the layer-2 gate) was not run and cannot represent an unmeasured cost, so it cannot validate the new rule as written.- No independent reviewer of the numbers:
lukealonso(#645, the code being narrowed) andiein(#550, who measured the last regression of exactly this class on GB10) have not engaged.