#1 [high] PR #661 head/base/scale and changed-file map
PR #661 helios/scheduler "explore smaller prefill chunks under active age-priced streams", head c588d610, base main 1fbcc3c9. +1,949/-106 in 11 files; production +397/-78 in 4 files (scheduler.rs +86/-10, scheduler/cost.rs +400 (all 3 new fns are prod, 3 unit tests), scheduler/policy.rs +196/-54, scheduler/service.rs +29/-17).
Key verified locations (head):
- cost.rs:688-786
interpolated_prefill_duration(sibling passthrough ~:702-712; peer scan loop; decode floor min over Decode|Speculative|Resume at any batch (BEFORE thekey.batch != 1filter);hi?requirement ~:774;lofallback to decode floor;if t_hi <= t_lo { Some(t_hi.max(1)) }; u128 interpolation). - policy.rs:79-86 PrefillSlotPlan; :371-379 prefill_catalog_for_terminal; :414-439 natural_fit_prefill_capacity_for_terminal; :501-537 prefill_slot_state/prefill_slot_nat_fit (per-pass cache arrays); :1045-1140 prefill_continuation (new interp branch,
for slot in bits(mask)+.unwrap()); :1433-1500 add_candidate (new interp branch); :1784-1792 select_plan ordinary_unmeasured → PlanOrigin::Discovery short-circuit; :1906-1920 resize_prefill age cap; :2071-2081 phase_plan origin (cfg(test)). - scheduler.rs:660 terminal_prefill_window field; :847-858 recompute (called from prefill_graphs :808 and terminal_prefill_graphs :843); :899-906 resolve_prefill_kind_from: non-terminal-catalog capacity returns TerminalPrefill whenever request.deferred_prefill (needs_terminal no longer required); :964-994 prefill_must_complete_terminally_from; :996-1005 has_active_age_priced_stream; :1007-1022 prefill_requires_terminal_completion_for_age; :1187-1190 prefill_step_requires_feedback early
true. - service.rs:262-328 service_rates: new
scan_prefill(skip_nonterminal)closure +token_rate == 0.0 && terminal_only && has_active_age_priced_stream() && !prefill_must_complete_terminally_fromrescan. - PolicyConfig::default balanced = decode_age_price 0.1 (:35-37); throughput() = delivery_fairness 0.0, decode_age_price 0.0 only, terminal_age_price stays 1.0 (:50-52).
#2 [high] interpolated_prefill_duration numeric/heuristic defects (verified)
Verified in cost.rs:695-786:
- The decode floor loop at :716-725 runs BEFORE the
key.batch != 1filter at :727, so a large-batch Decode/Speculative/Resume entry sets the floor. E.g. a measured Decode(batch=32, 1 token) wastes ~all rows but is fastest per row; min over all measured decode entries is taken (decode_floor.min), so the floor can be small. - Classic (torch) attention charge: PrefillDiscreteFlow adds sum(seqlens) work, so a chunk's cost is ~quadratic in start position. The
lofallback at :775-778 is(0, decode_floor.min(t_hi)), i.e. capacity 0 → full-attention floor. In long-context serving (start_position >= 4096) the interpolated estimate understates real cost by the whole decode floor + slope term; PrefillPredictor::predict on peers usespred.predict(key.tokens, start_position)and borrowed theta2, but the floor rung uses a raw decode nanos with no context term. lomay be a measured peer that is a worse predictor than the floor: any measured smaller Prefill at a shallow context (typical after TTL reset / cold measurement at start_position≈0) yields full_ns small → t_lo small → treating the smaller capacity as an absolute floor rather than per-token rate. No per-token normalization: interpolation is in absolute nanos between c_lo and c_hi, which is a fixed-cost-dominated, convex-ish curve; Prefill time is affine (theta0 + theta1*u), so linear interpolation between two peer times is exact only if the constant term is the same at the two capacities. Since theta0 differs, this is systematically wrong for widely separated peers (128 vs 16384). Note the test only checks 4096 between 2048 and 16384, i.e. adjacent-ish.- No freshness/age check on peers: unlike
stale_keys/borrowed slope logic (which requiresnow - observed_at < ttl), interpolated_prefill_duration accepts arbitrarily stale measurements (estimate.nanos != 0 only). Consequence: a single old measurement of one big Prefill keeps smaller unmeasured shapes "measured" indefinitely for ValueRate competition, contradicting the natural-fit/newer discovery philosophy. Its output is 0 for cost freshness purposes; ordinary_unmeasured at policy.rs:1784 forces Discovery origin, so execution always drains — but see next. - Graceful degradation asymmetry:
hiis required (hi?). So for capacities above every measured peer (e.g. the largest terminal shape) no interpolation happens and the old behaviour (only nat_fit discovery) applies. That is consistent with intent but means the top-of-catalog unmeasured shape remains zero-duration; combined with the newage_price > 0gate natural fit no longer dominates... check whether a zero-duration nat_fit candidate can win by optimistic compare (ValueRate::new with 0 duration). In add_candidate :1488, nat_fit == Some(capacity) gives slot_ns=0 → duration 0 → optimistic. Fine. - Off-by-one/consistency:
key.tokens == capacityskip at :727 means same-capacity entries of the other kind only enter through the sibling branch; ok. loaccepting a TerminalPrefill peer when kind==Prefill (Some(key.kind) == sibling at :730) mixes kinds: Prefill(128..) vs TerminalPrefill(16384) have different durations; interpolation across kinds is a heuristic; documented as such ("smaller measured peer"), but the "same-capacity sibling" fast path can return a worse estimate than interpolation from same-kind peers: :708-712 returns the sibling prediction regardless of context (predict(work, start_position) applies sibling's own theta, not Prefill's). Minor/heuristic.- Non-monotonic clamp
if t_hi <= t_lo { return Some(t_hi.max(1)) }is safe. - u128 arithmetic safe: (c_hi - c_lo) computed as usize subtraction AFTER the t_hi<=t_lo check but c_hi > c_lo guaranteed by construction (hi is strictly > capacity >= lo). offset = capacity - c_lo: c_lo <= capacity? lo entries have key.tokens < capacity (since == capacity skipped and > goes to hi), or the None-fallback c_lo=0. So no underflow. OK.
- When hi exists but is from the sibling kind only, and lo from kind... fine.
#3 [high] Final findings F1-F7 for PR #661 correctness lens
F1 (Blocker, claim accuracy / charter #210): PR body "Result" rows are not from the head. Body Limits: "SM120 A/B ran on fdb10bb5/82f68ea8 before resize_prefill/Discovery guards and 1fbcc3c9 rebase". Only the archive-tree claim ties c588d610 to any verification. Also body says drain applies to (throughput pipelines)": false — policy.rs:50-52 throughput() zeroes only decode_age_price; terminal_age_price stays 1.0 (policy.rs:37), and scheduler.rs:1187-1190 returns true unconditionally when has_active_age_priced_stream(), which includes terminal_cleanup streams (scheduler.rs:998-999). The PR's own test policy_tests.rs:8291-8314 asserts non-terminal Prefill must drain for a terminal-cleanup stream and :8316-8333 asserts throughput pipelines again only when terminal_age_price is zeroed.
F2 (Major, system-level / reverses #645): prefill_step_requires_feedback (scheduler.rs:1187-1190) is plan-agnostic: ANY Prefill plan drains whenever ANY resident stream is age-priced, including a Snapshot-phase terminal-cleanup request and including prefills that belong to no age-priced stream. Under throughput (decode_age_price 0.0, delivery_fairness 0.0) a single resident terminal-cleanup stream therefore disables #645's two-frame prefill pipeline entirely — a throughput regression on the policy whose purpose is throughput, with no flag/opt-out.
Also inconsistent definition of "age-priced": scheduler.rs:996-1005 uses raw policy coefficients, while policy.rs:1849-1865 / :1906-1907 use the scaled aggregate age_price (policy.rs:834-848, unit = exp(-scale)).
F3 (Major, pricing span): service.rs:321-328 — the non-terminal rescan only fires when token_rate == 0.0, i.e. only when NO terminal shape is measured. As soon as one terminal prefill is measured, the request's feasible token rate is computed over terminal kinds only, even though (post-#661) the scheduler may legally run non-terminal Prefill chunks (policy.rs:1462-1492, :1110-1141). That rate is the basis for ServicePrice::initial(rate/count) and for rebase(previous, rate) (service.rs:475-489; policy.rs:775-786), so the stored prefill price jumps when the fallback flips on/off (i.e. when the last age-priced stream leaves or a terminal shape gets measured), breaking the doc invariant "Individually feasible prefill service rates price each request from the prefill catalog and operation it can execute" (docs/scheduling-runtime-design.md:247-251). Fix: scan the full feasible set unconditionally when has_active_age_priced_stream() && !prefill_must_complete_terminally_from(...).
F4 (Major, estimate correctness): cost.rs:695-786. (a) decode floor branch at :720-726 runs before the key.batch != 1 filter at :727 and takes the min over Decode/Speculative/Resume at any batch; (b) that floor becomes the c_lo rung at capacity 0 (:775-778) and carries no KV-context term, whereas peers get with_borrowed_context_slope (:750-754) and predict(key.tokens, start_position) (:755). Interpolating absolute nanoseconds from a decode step's cost to a prefill peer's cost assumes both graphs share the same fixed intercept, which they don't. Quantified against the PR's own GB10 catalog (policy_tests.rs:7488-7505; decode batch1 = 18/28 ms): est(128) = 18 + (1302-18)*128/16384 = 28.0 ms vs measured 45 ms (-38%); est(256) = 38.0 vs 65 ms (-41%); est(4096) = 339 vs 380 ms (-11%). The same arithmetic is asserted as ground truth in cost.rs test expected_4k = 18_000_000 + (1_302_000_000 - 18_000_000) / 4. Since this value is the ValueRate denominator and gates capacity <= nat_fit (policy.rs:1467-1468), selection is biased toward the smallest chunk by up to ~40% beyond measured cost. Fix: interpolate per-token time or add the peers' fitted intercept θ0; do not use an arbitrary decode step as the c=0 rung without a same-graph intercept.
F5 (Major, cross-kind cache aliasing): PrefillSlotPlan has one nat_fit field (policy.rs:79-86) and prefill_slot_nat_fit (policy.rs:518-537) caches on plan.nat_fit_ready only, though the value depends on kind via prefill_catalog_for_terminal(kind, ...) (:527). candidates() allocates ONE array (:1599) and reuses it across the Prefill and TerminalPrefill add_candidate loops (:1601-1633), and the TerminalPrefill mask is built from requests whose request_kind == Prefill (:1611-1615), i.e. the same slots. So the TerminalPrefill loop inherits the natural fit computed over prefill_catalog. Same aliasing in continuation_candidate (:1082-1114, Prefill and TerminalPrefill both match promoted_kind == Prefill). Impact: the capacity <= nat_fit exploration gate for TERMINAL_PREFILL uses the wrong catalog's natural fit (e.g. terminal [256,...] vs prefill [128,...]: gate 128 excludes the true terminal natural fit 256; reverse catalogs let oversized terminal shapes through). Fix: key the cache by (slot, kind) or keep per-kind fields.
F6 (Major, contract doc contradiction): scheduler.rs:899-906 — for a capacity absent from terminal_prefill_catalog, the kind is now TerminalPrefill whenever request.deferred_prefill, dropping needs_terminal. That contradicts helios/model-contract.md:184-186 ("When a model declares no TERMINAL_PREFILL graphs, or omits a capacity from the terminal catalog, Helios falls back to PREFILL with no contract version change") and helios/model-contract.md:182-186 ("those smaller PREFILL graphs execute complete continuation state"), and the PR does not touch model-contract.md. Net effect: while deferred, the complete-state tail-window PREFILL (128 in the shipped catalog) becomes unreachable, so the minimum chunk quantum doubles to the smallest terminal capacity and every mid-prompt chunk pays terminal cost. Also enshrined in the mutation guard verification/helios-lifecycle/check.py:528-535, so the lifecycle check no longer protects the documented fallback.
F7 (Minor, docs): docs/scheduling-theory.md:74-76 and :93-97 still assert "Prefill has no externally visible per-chunk cadence" and "No duration ceiling, prefill size preference, or breadth-before-depth rule precedes it"; the new paragraph at :558-565 only admits the simulator divergence. Docs to update: theory doc + the service-rate paragraph at docs/scheduling-runtime-design.md:247-251.
Verified sound (do not report as issues): scheduler single-threaded, no unsafe/new locks; terminal_prefill_window caching correct (recomputed by both setters, scheduler.rs:808, :843, :847-858); u128 interpolation cannot underflow (hi strictly > capacity >= lo; c_lo=0 fallback) and the non-monotonic clamp is safe (:779-781); resize_prefill age cap at policy.rs:1912-1916 fails safe (returns None when the required lookup is missing); interpolated candidates still commit as PlanOrigin::Discovery (policy.rs:1784-1792, :2071-2081) and still drain via !costs.is_fresh(Key::from_step(plan)) in plan_requires_feedback (scheduler.rs:1222).
#4 [high] Quantification of F4 understatement using PR's own GB10 table
Quantified F4 with the PR's own GB10 numbers (policy_tests.rs:7488-7505 Prefill table; policy_tests.rs:7507-7518 decode table, batch1=28 ms):
interp = decode_floor + (t_hi - decode_floor)(cap - 0)/(16384 - 0), peers: hi = Prefill(16384)=1302 ms, lo = none -> floor = min over all measured Decode/Speculative/Resume = Decode(1)=28 ms.
est(128) = 28 + 1274128/16384 = 37.95 ms vs measured 45 ms (-15.7%)
est(256) = 28 + 1274256/16384 = 47.92 ms vs measured 65 ms (-26.3%)
est(512) = 28 + 1274512/16384 = 67.84 ms vs measured 98 ms (-30.8%)
est(1024)= 28 + 1274*1024/16384 = 107.6 ms vs measured 150 ms (-28.2%)
est(2048)= 28 + 159.3 = 187.3 vs 227 (-17.5%)
est(4096)= 28 + 318.5 = 346.5 vs 380 (-8.8%)
With the cost.rs unit-test figures (decode floor 18 ms, Prefill(16384)=1302 ms) the same formula gives 28.0 ms vs "45", i.e. the test itself encodes the -38% figure: cost.rs test let expected_4k = 18_000_000 + (1_302_000_000 - 18_000_000) / 4;
Mechanism: because the denominator of ValueRate is understated most for the smallest chunks, the rule systematically prefers the smallest unmeasured chunk beyond what measured cost justifies -> over-fragmentation, more drain barriers per prompt (scheduler.rs:1187-1190), buying the body's own reported "+1.8% makespan" while decoders wait for chunks priced too cheap.
Also: peers carry a KV-context term (cost.rs:750-755 uses with_borrowed_context_slope and predict(key.tokens, start_position)); the floor rung (cost.rs:775-778) does not, so at start_position >= 4096 the gap widens further.
#5 [high] Research summary
Reviewed PR #661 (head c588d61) with the Correctness, Contracts & System-Level Consequences lens: all four production files, their callers (commit, materialize, plan_requires_feedback, service_participants), the contract/doc files they touch, and the new tests. Findings, with full citations and quotes, are in scratchpad entries 3 and 4 (F1–F7 plus the verified-sound list).
Highest-impact results:
- Contract reversal, undeclared (Major→Blocker for the model contract):
scheduler.rs:899-906now maps every capacity absent fromterminal_prefill_catalogtoTerminalPrefillwheneverdeferred_prefillis set, dropping theneeds_terminalcondition. That directly contradictshelios/model-contract.md:182-186("Helios derives the tail-protection window … those smallerPREFILLgraphs execute complete continuation state … omits a capacity from the terminal catalog, Helios falls back toPREFILLwith no contract version change"), which this PR does not edit. Practical effect on shipped catalogs: while deferred, the complete-state tail-windowPREFILLbecomes unreachable, so the minimum chunk quantum doubles to the smallest terminal capacity. The rule is also now baked into the mutation guard (verification/helios-lifecycle/check.py:528-535). throughputregression and a false PR claim (Major):scheduler.rs:1187-1190returnstrueunconditionally whenhas_active_age_priced_stream(), which counts Snapshot-phase terminal-cleanup streams (:996-1005) against raw policy coefficients.PolicyConfig::throughput()zeroes onlydecode_age_price(policy.rs:50-52), leavingterminal_age_price: 1.0(:37), so one resident cleanup stream disables #645's two-frame prefill pipeline under the throughput preset itself. The PR body's "(throughputpipelines)" is therefore false, and the PR's own testpolicy_tests.rs:8291-8333documents the exception.- New pricing defect introduced in
service.rs:321-328(Major): the non-terminal rescan fires only whentoken_rate == 0.0, i.e. only while no terminal shape is measured — yet post-#661 the scheduler can legally run non-terminal chunks whenever an age-priced stream exists. That rate feedsServicePrice::initial/rebase(service.rs:475-489,policy.rs:775-786), so the stored prefill price steps whenever the fallback flips, violatingdocs/scheduling-runtime-design.md:247-251. - Interpolated estimate is systematically optimistic (Major):
cost.rs:695-786uses the min decode-step cost over any batch as the capacity-0 rung and interpolates absolute nanoseconds, ignoring the differing fixed intercept and the KV-context term that peers get at:750-755. Against the PR's own GB10 table the estimate is 15–31% low (e.g. 47.9 ms vs measured 65 ms at 256), biasingValueRateand thecapacity <= nat_fitgate toward smaller chunks — consistent with the body's own "+1.8% makespan". - Cross-kind cache aliasing (Major): one
nat_fitfield per slot (policy.rs:79-86,:518-537) is reused across thePrefillandTerminalPrefillpasses ofcandidates()(:1599-1633) andcontinuation_candidate(:1082-1114), so the terminal exploration gate is evaluated against the ordinary prefill catalog's natural fit. - Evidence gap (Blocker, unchanged in substance): every headline number predates the head (body Limits: A/B ran on
fdb10bb5/82f68ea8"beforeresize_prefill/Discoveryguards and1fbcc3c9rebase"), and the mandatory 64-seed simulator gate (docs/design-review.md:195-208;HELDOUT_SEEDSinlearning_analysis.py:12) remains unrun.
Verified sound and not reported as issues: single-threaded scheduler with no new locks/unsafe; terminal_prefill_window caching (recomputed by both setters); u128 interpolation cannot underflow and the non-monotonic clamp is safe; resize_prefill's age cap fails safe; interpolated candidates still commit as PlanOrigin::Discovery and still drain via !is_fresh.
#6 [high] Verbatim quotes + line citations backing F1-F7
Verbatim quotes for the report (all read directly from head files).
F1 — PR body (Limits + What): "SM120 A/B ran on fdb10bb5/82f68ea8 before resize_prefill/Discovery guards and 1fbcc3c9 rebase; template tests & kani unrun." and "drains active-stream non-terminal Prefill (throughput pipelines)". Contradicted by policy.rs:50-52 pub fn throughput() -> Self { Self { delivery_fairness: 0.0, decode_age_price: 0.0, ..Self::default() } } with policy.rs:37 terminal_age_price: 1.0,.
F2 — scheduler.rs:1187-1190:
fn prefill_step_requires_feedback(&self, plan: &ScheduledPlan) -> bool {
if self.has_active_age_priced_stream() {
return true;
}
scheduler.rs:996-1005 (has_active_age_priced_stream): 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) }.
PR's own test: policy_tests.rs:8311-8314 assert!( t.plan_requires_feedback(&plan_t), "nonterminal Prefill must drain when a terminal-cleanup stream is age-priced" ); and :8316-8318 let mut t_zero = interactive_engine(2, false); t_zero.configure_policy(PolicyConfig { terminal_age_price: 0.0, ..PolicyConfig::throughput() }).
F3 — service.rs:321-328:
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)
{
token_rate = token_rate.max(scan_prefill(false));
}
service.rs:475-483 if let Some(rate) = participant.token_rate { ... if prefill { if let Some(previous) = service.prefill_rate { price.rebase(previous, rate); } }.
Doc contract violated: docs/scheduling-runtime-design.md:247-251 "Individually feasible prefill service rates price each request from the prefill catalog and operation it can execute (PREFILL, TERMINAL_PREFILL, or SCORED_PREFILL)".
Existing test only covers the token_rate==0.0 branch: policy_tests.rs:8240-8243 "measured Prefill(2048) must provide fallback token_rate when TerminalPrefill is unmeasured".
F4 — cost.rs:720-727 (floor taken before the batch filter):
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;
}
if key.batch != 1 || key.tokens == capacity {
continue;
}
cost.rs:774-778: 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)), };
cost.rs test encodes the 0-rung assumption: let expected_4k = 18_000_000 + (1_302_000_000 - 18_000_000) / 4;
F5 — policy.rs:79-86 struct PrefillSlotPlan { ready: bool, cut: Option<usize>, terminal_only: bool, nat_fit_ready: bool, nat_fit: Option<usize> } (no kind); policy.rs:526-535 if !plan.nat_fit_ready { let catalog = self.prefill_catalog_for_terminal(kind, plan.terminal_only); plan.nat_fit = self.natural_fit_prefill_capacity_for_terminal(request, catalog, plan.cut, plan.terminal_only); plan.nat_fit_ready = true; }; single array reused: policy.rs:1599 let mut prefill_plans = [PrefillSlotPlan::default(); REQUEST_LANES]; then :1631-1633 loop over [Prefill, TerminalPrefill, ScoredPrefill, ...], and :1611-1615 let expected = if kind == GraphKind::TerminalPrefill { GraphKind::Prefill } else { kind }; (same slot mask).
F6 — scheduler.rs:899-906:
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
};
}
vs helios/model-contract.md:182-186 "Helios derives the tail-protection window from the prepared catalog as the largest PREFILL capacity absent from the TERMINAL_PREFILL catalog; those smaller PREFILL graphs execute complete continuation state. When a model declares no TERMINAL_PREFILL graphs, or omits a capacity from the terminal catalog, Helios falls back to PREFILL with no contract version change."
Mutation guard enshrining it: verification/helios-lifecycle/check.py:527-535 ("deferred prefill small cut bypass") now expects " return if request.deferred_prefill {\n".
F7 — docs/scheduling-theory.md:93-96 "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." and :74-76 "Prefill has no externally visible per-chunk cadence." New admission only at :558-565.
Extra system-level note (not a separate finding, supports F2): the drain requirement is plan-agnostic, so a resident terminal-cleanup request also drains prefills for unrelated cold prompts, and every drain costs a full round-trip before the next submission (nodes: plan_requires_feedback scheduler.rs:1210-1224 and commit window check scheduler.rs:2422-2431). This is the mechanism by which the body's own table shows "+1.8% makespan" under T_50C.
Could not verify: no CI run readable for c588d610 (only the author's local archive claim at tree 74625efe6837); the Autobot Changes-Requested review targets 29f2b5b, not head; the 15.3 s GB10 regression figure comes from #550's description.