#1 [high] Finding 1: resolve_prefill_kind widening to non-existent TerminalPrefill graphs (Major)
FILE: helios/src/scheduler.rs:899-907 (pr head 3d868f84)
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 { // <- was `&& needs_terminal`
GraphKind::TerminalPrefill
} else {
GraphKind::Prefill
};
}
needs_terminal is now computed and unused in that branch.
Consequences (all verified):
- On a subset core (PREFILL strict superset of TERMINAL_PREFILL — e.g. PREFILL 128..=16384, TERMINAL 256..=16384) every capacity absent from the terminal catalog (128 here) is classified
TerminalPrefillwhiledeferred_prefillis set. No such graph exists, soadd_prefill_candidate(policy.rs:1433-1435if work == 0 || self.resolve_prefill_kind(...) != kind { continue; }) drops the PREFILL(128) candidate, andcosts.prefill_entry(TerminalPrefill,128)is None so no TerminalPrefill(128) candidate appears either. The complete-state small PREFILL graphs become unusable for the remaining chunks of a deferred prompt. - helios/model-contract.md:182-186 says: "Helios derives the tail-protection window from the prepared catalog as the largest
PREFILLcapacity absent from theTERMINAL_PREFILLcatalog; those smallerPREFILLgraphs execute complete continuation state." Those graphs are contractually complete-state (safe to run, and to finish, while continuation state is deferred), so denying them is a contract-level change, not a scheduling detail. - service.rs:302-319 prices a request from
resolve_prefill_kind_from; for capacity 128 it now yieldsTerminalPrefill,prefill_durationreturns None (cost.rs:654-667->self.entry(key)?), so the measured Prefill(128) contributes no token rate toServicePrice, where previously it did. Service price feedstoken_log/rebasefairness (policy.rs:786-797), so cross-request fairness normalizers change silently. - Policy-independent: no policy field gates it, so
--scheduler-policy throughput(PolicyConfig { delivery_fairness: 0.0, decode_age_price: 0.0, ..default } policy.rs:50-52) is not an escape hatch for (1)-(3). - Only synthetic catalogs exercise it (policy_tests.rs:8268-8280, 8734-8820); verification/helios-lifecycle/check.py:527-535 now enshrines the widened rule as a mutation target.
Fix: keep needs_terminal in that branch, or exclude only capacities where the PREFILL graph is not complete-state (i.e. where a TerminalPrefill shape exists), and add a subset-catalog test (PREFILL 128..2048 / TERMINAL 256..2048) asserting the deferred tail still has a legal chunk.
#2 [high] Finding 2: interpolated estimate displaces natural-fit zero-duration discovery (Major risk)
FILE: helios/src/scheduler/policy.rs:518-543 (prefill_candidate_ns)
if age_price > 0.0 && plan.nat_fit.is_some_and(|nat| capacity <= nat) {
let interp = match *last_interp { ... self.costs.interpolated_prefill_duration(kind, capacity, work, request.scheduled_consumed) ... };
if let Some(ns) = interp { return Some(ns); }
}
(plan.nat_fit == Some(capacity)).then_some(0)
The interp branch is evaluated before the natural-fit Some(0) marker, and the condition capacity <= nat includes capacity == nat. Before this PR, when predictor was None the code required natural_fit_prefill_capacity(...) == Some(capacity), i.e. exactly the nat-fit capacity kept duration_ns == 0.
ValueRate::compare (utility.rs:167-172) ranks by (duration_ns == 0).cmp(&(other.duration_ns == 0)).then(score) — a zero-duration candidate strictly outranks every measured candidate. Returning a positive interpolated ns for the nat-fit capacity removes that precedence precisely in the situation this PR targets (age-priced streams active). Consequences:
- The natural-fit prefill graph is only executed — and therefore only ever measured — if its interpolated
ValueRatebeats a measured decoder. If it does not (e.g. nat-fit is a small capacity whose interpolation starts from a slow decode floor, orfirst_output_valueis still small), the shape stays unmeasured indefinitely and the estimate stays interpolated. #538's invariant ("unmeasured pure prefill graphs only participate in cold discovery at this capacity", policy.rs:405-408) no longer holds under age pricing. - Combined with the new global drain (
scheduler.rs:1187-1190: non-terminalPrefillplan requires feedback while any age-priced stream is resident) the prefill chunk can only be submitted into an empty queue, so failure to outbid a decoder delays the prompt further;is_unmeasured_candidate(policy.rs:545-548) then tags itPlanOrigin::Discovery, which earns no refresh credit and, per scheduler.rs:2422-2428, keeps it out of any two-frame window. The PR's own cost test only asserts the zero-age direction ("Strictly lower throughput than 16384 so solo zero-age prefill still prefers 16384", cost.rs testinterpolated_prefill_duration_uses_sibling_or_measured_peers), and no policy test asserts nat-fit precedence withage_price > 0.
Fix: test capacity == nat_fit first and keep Some(0) for it, interpolating only capacities strictly below nat-fit; or add a test that with an active age-priced decoder the nat-fit shape is still the first candidate executed (measured) within N planning passes.
#3 [high] Research summary
Reviewed PR #661 (head 3d868f84) through the correctness/contracts/system-consequences lens, opening every Rust production change (scheduler.rs, scheduler/cost.rs, scheduler/policy.rs, scheduler/service.rs) plus their direct callers (cost.rs lookup/observe paths, refresh.rs, checkpoints.rs cost/cut selection, utility.rs ValueRate/prefill_within), the new tests in policy_tests.rs and cost.rs, and the doc/contract files the change touches (docs/scheduling-runtime-design.md, docs/scheduling-theory.md, helios/README.md, helios/model-contract.md, verification/helios-lifecycle/check.py).
Two substantive findings, both saved to the scratchpad with verbatim quotes and line citations:
-
resolve_prefill_kind_fromwidening (Major).scheduler.rs:899-907now returnsTerminalPrefillfor every capacity absent fromterminal_prefill_catalogwheneverdeferred_prefillis set (needs_terminalis computed and then unused in that branch). On any subset catalog this classifies complete-state smallPREFILLshapes as a non-existentTerminalPrefill:add_prefill_candidatedrops the legal candidate andservice_rates(service.rs:302-319) drops that capacity's measured rate, silently shifting ServicePrice fairness normalizers. It contradictshelios/model-contract.md:182-186, is policy-independent (so--scheduler-policy throughputis not an escape hatch), is covered only by synthetic catalogs, and is now enshrined incheck.py:527-535. -
Interpolated estimates displace natural-fit zero-duration discovery (Major risk).
policy.rs:526-542evaluates the interpolation branch before thenat_fit == capacitySome(0)marker and the guard iscapacity <= nat, so exactly the nat-fit capacity loses theduration_ns == 0precedence ofValueRate::compare(utility.rs:167-172) whenever age pricing is active — i.e. the case the PR targets. The graph may never be executed, so it never becomes measured, breaking #538's discovery invariant; combined with the new global prefill drain (scheduler.rs:1187-1190) a suboptimalDiscoveryplan now also cannot pipeline. The PR's own cost test only asserts the zero-age direction, and no policy test covers nat-fit precedence underage_price > 0.
Areas I checked and found sound: the u128 interpolation arithmetic and non-monotonic clamp (cost.rs:695-776), last_interp memo keying and per-capacity reset, is_unmeasured_candidate never mis-tagging a measured candidate as Discovery, the age-priced resize_prefill cap that can only shrink (policy.rs:1838-1853), the cached terminal_prefill_window (recomputed on both catalog setters, so no stale-state path), preserves_first_output_wait's new branches, and the reconciled interior-cut credit (guarded by end == prompt_tokens, deferred_prefill, positive first_output_value, and fits_single_prefill_from). Platform parity is a non-issue: the change is single-threaded scheduler math with no new unsafe, I/O, or OS-specific path.
#4 [medium] Areas verified sound in PR #661 (no finding)
Verified at head 3d868f84 and found sound (do not report as issues):
ActionCosts::interpolated_prefill_duration(cost.rs:695-776): pure in(entries, now_ns, ttl_ns, capacity, work, start_position)(all&self),u128-widened interpolationu128::from(t_lo) + (u128::from(t_hi - t_lo) * offset) / spanwitht_hi_t_lopreceded by theif t_hi <= t_lo { return Some(t_hi.max(1)) }clamp at :769-771, so no underflow and no overflow;(interp.min(u64::MAX as u128) as u64).max(1)at :775.hi?at :764 makes itNonewithout a larger measured peer.last_interpmemo (policy.rs:1429, reset at :1092 per capacity; key(work, scheduled_consumed)) matches exactly the inputs that matter for a fixed capacity;policy.rs:531-540forwardsresolvedas it is.is_unmeasured_candidate(policy.rs:545-548):candidate.rate.duration_ns == 0 || costs.observation(cost_key()).and_then(|(_, observed, _)| observed).is_none()— the second clause can never call a measured candidate unmeasured, soPlanOrigin::Discoverytagging stays sound whererate.duration_ns != 0.- Age-priced
resize_prefillcap (policy.rs:1837-1852):candidate.capacity.min(*catalog.last()?)only ever shrinks growth; reached only via theactual_work != work || kind_changedbranch, so no new unchecked growth path. terminal_prefill_windowcache (scheduler.rs:847-858) is recomputed by both catalog setters (prefill_graphs:808,terminal_prefill_graphs:843); the constructor seeds 0. No stale-state path even though catalog order matters (prefill_catalogcan be set before or afterterminal_prefill_catalog).preserves_first_output_wait(policy.rs:479-506): the newage_priced_chunkarm is gated oncheckpoint_capture.is_none() && kind == Prefill && decode_age_price > 0.0 && has_active_age_priced_stream() && fits_single_prefill_from(admission_reused_tokens), andRequestAccounting::credit(policy.rs:71-86) still advanceslast_progress_ns— only the wait clock is retained.- Reconciled interior-cut credit (policy.rs:1388-1408): guarded by
!first_output,TerminalPrefill,deferred_prefill,first_output_value > 0.0,tokens > 0,estimated_checkpoint_cut(r) == Some(end)andfits_single_prefill_from(admission_reused_tokens);(new_frac - old_frac).max(0.0)prevents any negative credit; token-work credit is untouched. - Platform parity: pure single-threaded scheduler arithmetic; no new
unsafe, syscalls, filesystem/GPU I/O, or OS-conditional code, so Unix/Windows parity is a non-issue. No wire/proto, captured-graph contract, or ABI change (no newGraphKind, noGraphDescriptor/PolicyConfigfield, no CLI flag).
#5 [medium] Contracts/docs/tests touched by #661 (citations)
Citations the final report needs:
CONTRACT
helios/model-contract.md:171-186"Optional terminal prefill": TERMINAL_PREFILL is optional "alongsidePREFILLfor a subset of aligned prefill token capacities"; :176-180 "Models with asymmetric encoder and decoder prefill usePREFILLat those capacities to skip trailing continuation layers on intermediate chunks and useTERMINAL_PREFILLto rebuild complete continuation state at prompt ends, prefix-checkpoint boundaries, ..."; :182-186 "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."
CODE UNDER REVIEW
helios/src/scheduler.rs:882-913resolve_prefill_kind_from; the widened branch is :901-907.helios/src/scheduler.rs:923-958prefill_requires_terminal_completion_from(unchanged); :964-994 newprefill_must_complete_terminally_from; :996-1005 newhas_active_age_priced_stream; :1007-1022prefill_requires_terminal_completion_for_age.helios/src/scheduler.rs:1187-1190new global drain.helios/src/scheduler.rs:847-858recompute_terminal_prefill_window.helios/src/scheduler/service.rs:297-319age-awareterminal_only+ per-capacity pricing.helios/src/scheduler/policy.rs:508-548prefill_slot_state/prefill_candidate_ns/is_unmeasured_candidate; :1378-1420lane_value_for_tokens_within; :1422-1458add_prefill_candidate; :1829-1881resize_prefill.helios/src/scheduler/cost.rs:688-776interpolated_prefill_duration.helios/src/scheduler/utility.rs:94-106prefill_within; :154-172ValueRate::new/compare.helios/src/scheduler/refresh.rs:72-96—PlanOrigin::Discovery => {}earns no credit; :24-31is_probe.
TESTS
- New cost tests:
cost.rsinterpolated_prefill_duration_uses_sibling_or_measured_peers,..._is_order_independent_for_same_kind_and_sibling,..._isolates_scored_prefill_and_clamps_non_monotonic_timings(in themod testsblock added by the diff). - New policy tests:
policy_tests.rs:8734-8929(first_output_wait_preserved_across_age_priced_non_terminal_prefill_chunks),:8931-9199(deferred_terminal_prefill_at_checkpoint_cut_credits_reconciled_segment_wait),:8420-8475(has_active_age_priced_stream_covers_resume_and_terminal_cleanup_branches),:8526-8613(add_candidate_excludes_oversized_unmeasured_terminal_prefill_above_prefill_nat_fit). - No test asserts natural-fit precedence (
Some(0)) withage_price > 0.0; no test uses a PREFILL-strict-superset catalog withdeferred_prefillto check that a chunk remains legal. verification/helios-lifecycle/check.py:527-535now mutatesif request.deferred_prefill {(the widened line) and its message still says "deferred prefill small cut bypass".
DOCS
docs/scheduling-runtime-design.md+52/-20 (diff hunks at the first_output_value paragraph, the resize paragraph, the discovery paragraph, the terminal-prefill paragraph, the two-frame window paragraph, and the pricing paragraph).docs/scheduling-theory.md+18/-3: :93-96 now defers discovery to runtime-design#duration-estimates; :562-573 documentsinitial_discovery = "interpolated". Still contradicting the change: :74-76 ("Prefill has no externally visible per-chunk cadence") and :121-122 ("Two long prefills do not need smaller chunks merely to alternate").helios/README.md: :282-289 and :423-433 updated for interpolated discovery / window sharing.docs/scheduling-utility.md:290-322documentsfrac = work / initial_prefilland the anchor-split wait-clock preservation only; it was NOT updated for the two new credit rules (age-priced chunk wait retention and reconciled interior-cut credit), which now live in runtime-design.md:277-289. That is a docs-split inconsistency worth mentioning as a Minor if the report has room.