Case file: PR #645 — Overhaul Helios prefill scheduling, cost modeling, and two-frame pipelining
Author lukealonso (COLLABORATOR), open, "ready for review", head 05cccb6, base main, opened and last updated 2026-11-30, 0 reviews, 0 comments, no labels, CI passed on head. 20 files, +1417/−127. It closes #485. Single commit 05cccb65 (no review-driven fixups).
Key findings (what the description does not tell you)
- A new always-on scheduling coefficient is not documented where operators look.
PolicyConfig::coalescing_horizon_tokens(default64.0;helios/src/scheduler/policy.rs:26,42, validated non-negative atpolicy.rs:225-230) is missing from the canonical PolicyConfig table (docs/scheduling-runtime-design.md:651-661, which lists 10 fields and stops atadaptive_verification_alpha) and fromhelios/README.md:478-488, which enumerates the same defaults and is untouched by this PR. There is no CLI flag and no server-config key:flare-cli/src/cli.rs:634-647(not opened) exposes only--scheduler-policy,--scheduler-terminal-value,--scheduler-terminal-age-price,--scheduler-checkpoint-extra-work-fraction, andhelios/src/server/config.rs:305-330parses the equivalentscheduler_*keys plusmtp_adaptive_verification_alpha. The bonus is therefore unreachable and un-disableable forflare runoperators except through in-processconfigure_policy(policy.rs:206). - The checkpoint-pricing O(1) stride fast path is silently lost as soon as fills are non-constant — not mentioned in the description.
interval_prefill_nsbuilds its stride only fromentry.non_terminal?.constant_ns()?(helios/src/scheduler/checkpoints.rs:222-232, changed line 225), andPrefillPredictor::constant_nanosisSomeonly when the NNLS fit yieldstheta1 == theta2 == 0andu_max >= 0.75(helios/src/scheduler/cost.rs:298-302). As soon as any partial-fill (u <= 0.5) sample lands in a stratum, the stride disappears and pricing falls back to the per-position walk over every catalog capacity (checkpoints.rs:270-338). The description's claim that constant predictors "preserve … the O(1) stride path" is true only for the constant case; the budget tests (checkpoints.rs:1292-1312,2375-2378) do not cover the new non-constant regime. - An undeclared behaviour change in the mixed branch of
policy.rs.else if r.generated_tokens > 0becameelse if r.consumed_tokens >= r.prompt_tokens as u64 && r.generated_tokens > 0(helios/src/scheduler/policy.rs~812-820), so prefilling lanes that already hold generated tokens no longer take the mixed decode branch. Not in the description. - The headline burst gains are simulator-only, and one of them is not reproducible from the tree.
+14.6%/−42.6%TTFT forburst_eightcome fromscripts/scheduling_simwith a synthetic catalog (scripts/scheduling_sim/workloads.py:9-22) and are pinned as an exact test assertion (max TTFT ≤ 528.0 ms, every batch == 8) intests/test_scheduling_utility.py:334-345. The 8 × 8,192 multi-chunk burst (+12.8%, TTFT 1492→1056 ms) has no checked-in workload —workloads.py:50-53only adds 4096-token bursts, so those numbers rest on an ad-hoc run. - The #485 fix is verified only by unit-test inputs, not by a live long-context measurement. The
100 × 128-token tails / 3,584-token graph / 7.81 s vs 1.76 snumbers are hand-set inputs incost.rstests andpolicy_tests.rs:6547-6581; #485's own DS4.1 TP4 64k–128k scenario is never re-run. The PR's only live measurement of the mechanism is a 46,509-token prompt TTFT (2655 ms), single-arm with nomaincontrol. - A test that asserted the opposite behaviour was renamed and inverted.
prefill_frames_drain_even_when_the_next_request_is_independent→nonterminal_prefill_frames_pipeline_two_deep_and_terminal_chunks_drain(helios/src/scheduler/policy_tests.rs:1420-1480); the corresponding doc paragraph was rewritten (docs/scheduling-runtime-design.md:567-577). Existing production estimate expectation also moved: a 13-token tail in a 64-capacity graph went from600ns to195..=210ns (helios/src/server/runtime/phase_tests.rs:1311-1318), a 2.9× shift in planned prefill durations on a real path. - Same-author, same-day overlap with open PR #644 on 7 of these files, including
utility.rs/service.rs/policy.rsregions this PR edits. Not stacked; whoever merges second rebases. #644 rewritesLaneValue(decode_within,finish) while #645 addsprefill_finishto it.
The change
Four coupled changes in one commit:
- Completion-attributed burst coalescing (
policy.rs:440-620,utility.rs:88-95, plus the Python mirrorscripts/scheduling_sim/utility.py). A finishing prefill chunk (scheduled_consumed + work == prompt_tokens) receivessurplus * horizon, wheresurplusis the max over added decodersmof((K+m)/m) * (1 - R(K)/R(K+m))times a steady-state token valueoutput_token_value + token_fairness/x_ss + delivery_fairness/(z_ss*E), andhorizon = min(coalescing_horizon_tokens, prefiller budget, min active-decoder remaining budget). Preconditions: at least one active under-batched decoder and a prefiller withoutprompt_logprobswhose post-prefill budget > 1 (policy.rs:446-620).LaneValue::prefill(consumed, first_output)addsprefill_finishonce onfirst_output; thefirst_outputflag was repointed fromconsumed_tokens + work == prompt_tokenstoscheduled_consumed + work == prompt_tokens(policy.rs:752, 804, 1227) because a pipelined chunk is planned before the previous one completes. Python mirror:COALESCING_HORIZON_TOKENS = 64.0(scripts/scheduling_sim/utility.py:22,183,222) and new workloadsburst_four/burst_eight/burst_four_low/burst_eight_low(workloads.py:50-53). - Stratified prefill
ActionCosts(helios/src/scheduler/cost.rs, +497/−1):PrefillCostModelwith 6 strata (fillu <= 0.5vs> 0.5× start< 4096/4096..32768/>= 32768), each a 9-sample rolling median, fitted astheta_0 + theta_1*u + theta_2*u*(start/4096)by exact 7-subset relative-error-weighted non-negative least squares (cost.rs:298-302); narrow-regime upward boundt_at_umax * u/u_maxwhenu_max < 0.75and spread< 0.15.ActionCosts::getnow routes every single-lane prefill step throughprefill_duration(work, start_position)(cost.rs:529-590, 679-691), so planned prefill durations andexpected_finish_nsdepend on live work and KV depth — which feeds queue windowing (policy.rs:423-438) for every prefill-capable core with no flag.observerecords onlystep.lanes.first()(cost.rs:709-723), so a multi-lane prefill step contributes one lane's(work, start). Callers switched inpolicy.rs(add_candidate, natural-fit,continuation_candidate,resize_prefill),service.rs::service_rates,checkpoints.rs(prefill_catalog_costs,interval_prefill_ns). - Two-frame pipelining for consecutive nonterminal
GraphKind::Prefill. Three "non-barrier kind" lists widened fromDecode | SpeculativetoDecode | Speculative | Prefill: scheduler gatescheduler.rs:1132-1143plus the newprefill_step_requires_feedback(scheduler.rs:1109-1130); eligibilitypolicy.rs:311-322; and the four executor layershelios/src/execution/transport.rs:968,1021,threaded.rs:874-876,threaded/protocol.rs:32-37,parallel.rs:262-264. Completion-input guard widened inhelios/src/model.rs:350-354. Cursor plumbing:prefill_cursor = max(scheduled_consumed, consumed_tokens)(scheduler.rs:854-856) with_fromvariants inscheduler.rs:858-944,checkpoints.rs:487-495, 681-700,policy.rs:741-760,service.rs:167-200. Bounds retained: in-flight frames< 2and grammar-bearing frames serialized (transport.rs:1028-1040); terminal/scored/mixed/checkpoint-cut chunks still barriers. - Mixed-graph and catalog fixes:
learning::optimistic_tokensnow usesforecast_tokens(&powered_curve(request, true), width)instead ofspeculative_curve(helios/src/scheduler/learning.rs:11-13); Mixed decode rate/continuation paths gained a!prefillguard pluspowered_curve/forecast_tokens(service.rs:232-260,policy.rs~791-806); unmeasured prefill discovery useseffective_prefill_catalog(policy.rs:341-352, 741-745, 966, 1270). Test:policy_tests.rs:6583-6635.
Supporting files: verification/helios-lifecycle/check.py:544-610 embeds verbatim source text of prefill_requires_terminal_completion_from for the Rust↔TLA trace harness, so later edits to that function must be mirrored there. No Protobuf or core ABI change; no .proto/ignition change in the file list.
The why
- Closes #485 (voipmonitor, COLLABORATOR, open since 2026-11-23; labels area:scheduling, bug, performance, triage:design-review), which reports
flare_graph_launches_total{kind="prefill"}drifting 18 → 29 → 31 launches across consecutive 128k requests on DeepSeek-V4.1-Flash TP4 (3942 → 4012 ms GPU), root-caused tocost.rs's single 9-sampleReplayTimesmedian keyed only on static capacity. - #485 supplies a prototype branch (
voipmonitor/flare,experiment/prefill-history-banded-costs, commit 95ba044, +252/−18, 338 scheduler tests passing) using 6 logarithmic KV bands ([0,16k) … [256k,∞)) with nearest-band slowdown scaling, measured +0.2% … +1.3% end-to-end on DS4.1 (128k chat: 31 → 24 launches, −52.3 ms GPU). It explicitly offers to convert to a PR or "adjust to a simpler affine/lineara + b * historymodel". PR #645 chooses the affine design instead (3 fill/ctx buckets at 4096/32768 × 2 fill strata, weighted NNLS), so it closes #485 with a different design than the issue's prototype and without reproducing #485's 64k–128k live scenario. - #485 has zero comments; #645 is its only referrer.
- Defects 1–4 of the PR description (burst fragmentation, tail poisoning, serialized nonterminal chunks, mixed-graph curve bugs) have no filed issues of their own; only defect 2 has an issue (#485).
Related work
- #644 (lukealonso, open, same day, +649/−230) — closest overlap: 7 shared files (
docs/scheduling-runtime-design.md,policy.rs,policy_tests.rs,service.rs,utility.rs,scripts/scheduling_sim/utility.py,tests/test_scheduling_utility.py). RewritesLaneValue(addsdecode_within, changesfinish) and delivery accounting (delivered = duration_ms,maximum_rate = 1.0), where #645 addsprefill_finishtoLaneValueand editsservice_rates. Neither PR mentions the other; second-to-merge must rebase. #644 also reports live numbers on 4× DGX Spark TP4 while #645's live run is SM120. - #619 (merged 2026-11-29, one day earlier) — direct predecessor: it rewrote
plan_requires_feedbackand the docs paragraph at 567-577 forDecode|Speculativetwo-frame pipelining; #645 extends exactly that predicate/paragraph toPrefill. #645's description does not cite #619. - #538 (FujitsuPolycom, merged 2026-11-26) introduced
natural_fit_prefill_capacityand restricted cold unmeasured prefill discovery (#645 builds on it and fixes the catalog viaeffective_prefill_catalog); its follow-up #550 restored prefix checkpoints on prefill catalogs without terminal prefill — the sameinterval_prefill_nscode this PR rewrites for predictors, so the stride regression (Key finding 2) lands directly on that history. - #459 (yatesdr, merged 2026-11-22) created the
stride/STRIDE_RUNS/ENTRY_LOOKUPSO(1) budget #645 now conditions onconstant_ns(). Also #426 (original-el8) rebased prefill service prices and checkpoint interval pricing; #479 optional TerminalPrefill; #582 zero-budget checkpoint anchors; #555 intermediate batch capacities; #510 positive packed round durations; #540 timing refresh/acceptance credit across idle. - #42 (closed issue) / #43 — "Final prefill can starve behind a two-frame ordinary-decode pipeline"; established that a feedback-requiring final prefill waits for an empty window (
available_plan,policy.rs:1320-1327). #645 deliberately keeps that rule and is the reasonprefill_step_requires_feedbackexists at all; the new predicate is the #42/#43 safeguard. - #632 (original-el8, open, same day) touches
policy_tests.rsanddocs/scheduling-runtime-design.md:113-152but onrounds.rs(not opened) calibration — additive, not conflicting. #621 (model.rs/scheduler.rs), #542/#408/#410/#334 (execution files) share files on unrelated concerns.
Recent activity
The change builds on a dense 10-day merge run in the same files rather than reversing it: #459 (2026-11-22), #510 (11-24), #538 (11-26), #555 (11-27), #540/#582/#608/#613/#619/#620/#626 (all 2026-11-29). Two behaviour reversals are worth flagging: the inverted test named above, and the changing meaning of Estimate::nanos for prefill keys (now a fitted full-fill, zero-context value, not the last raw median), which #540's staleness/refresh logic (costs.is_fresh, costs.stale_keys) consumes — freshness semantics are unchanged but the refreshed number differs. Single commit, so no review-driven history yet.
People
- lukealonso is a charter-designated priority contributor ("Priority contributors (@voipmonitor, @original-el8, @lukealonso) carry extra weight") and the dominant author of exactly these files: 229 of the last 180 days'
helios/srccommits and 384 ofdocs/, including #613, #619, #620, #626, #510, #608, #614. 26 merged PRs in 180 days; #644 and #643 also open. Discord handle given in the PR: lukealonso. - Others active in the area: Martin Vit (52 commits in
helios/src), yatesdr (47), voipmonitor (author of #485 and of the competing prototype), original-el8 (#426, #479, #632), FujitsuPolycom (#538, #542, #582), javieratomic (#334), jcartu (#621). cost.rshistory is nearly all lukealonso (b9ad16b7, 18cb0efc, 8c117854, d7938c98, fd6c0f3b, 9a054b49) with yatesdr (#459) and Martin Vit (#555) interspersed.
Community
Nothing found: no comments, no reviews, no reactions, no labels, no third-party engagement of any kind (pr_comments returns "No comments."). By contrast #619, #538 and #632 each drew an autobot case file and an autobot "Changes Requested" review within ~30–90 minutes, with blockers about missing live A/B evidence. #645 is ~0 days old at time of write, so the absence may simply be recency.
Project fit (as facts, not verdicts)
- "Bring real evidence. Performance PRs need benchmarks showing an actual speedup over main on a served workload (#210)." The only genuine A/B-against-baseline evidence here is the Python simulator with a synthetic catalog; the live-GPU numbers are single-arm with no
maincontrol, and the SM121 2-Spark A/B is declared "expected but unmeasured". The #485 fix likewise has no live before/after, although #485 itself supplied DS4.1 TP4 A/B tables. - "Keep the runtime small and model-agnostic … shouldn't accumulate per-model branches." Satisfied: no model names in code (only in prose/test comments such as the "Kimi K3.1 #485 scenario").
- "Be explicit and pin everything. No magic defaults." The new horizon 64.0, the
PREFILL_CTX_SCALEof 4096, the 0.75/0.15 narrow-regime thresholds, and the 6-stratum layout are rationale-documented constants but unconfigurable, and the table of defaults that would expose the new one is stale (Key finding 1). - PR description structure ("why / what changed / claimed result / evidence") is satisfied unusually well, including explicit "Expected but unmeasured" and "Unrun checks and limitations" sections.
- Docs are treated as part of the deliverable and were updated in three places (
docs/scheduling-runtime-design.md:198-207coalescing,403-423stratified estimator,567-577two-frame rule) — but not the PolicyConfig table at 646-677.
Claims and evidence
| Claim | Backing |
|---|---|
burst_eight 923.4 → 1057.9 tok/s (+14.6%), max TTFT 920.0 → 528.0 ms (−42.6%), 32/32 full B=8 rounds |
Simulator only, synthetic catalog (workloads.py:9-22), rate_history="service"; pinned as exact assertion in tests/test_scheduling_utility.py:334-345. Rust counterpart policy_tests.rs:6489-6545 uses hand-set decode costs (27/30/37/48.5 ms) and only asserts no sub-batch decode, ≥120 full B=4 rounds, lower makespan |
| 8 × 8,192 burst 737.2 → 831.2 tok/s (+12.8%), TTFT 1492 → 1056 ms | Not reproducible from the tree — no 8192-token workload is checked in (workloads.py:50-53 adds 4096 only) |
| #485 fixed: 100 × 128-token tails (1.51 s) in a 3,584 graph don't undercut 7.81 s full estimate over 1.76 s at 4,096; scales with depth | Unit tests only (cost.rs test module, policy_tests.rs:6547-6581); the numbers are inputs, borrowed from #485's narrative, not GPU measurements |
| 46,509-token prompt, ~12 nonterminal chunks over TP2, 2655.0 ms TTFT (~17,518 tok/s), clean SIGTERM rc=0 | Only live evidence that the pipelining works end-to-end; single arm, no baseline, no metric isolating the pipelining gain |
| Live bursts 307.8 tok/s (B=4, 1121.2 ms) / 363.4 tok/s (B=8, 2056.1 ms) | No baseline; SM120 host while the motivating SM121 2-Spark Nemotron-3.5-Super-VL scenario is unmeasured |
| Interactive contention gap < 300 ms | One simulator scenario |
Test suites: eos 2; selene 548; selene-manager 188; helios 1742 passed / 46 ignored (one engram test needed --test-threads=4); lifecycle check --mutations exit 0 across 8 TLA+ models; pytest 644 |
Reported, not independently re-run here; CI on head passed |
Not run: 6 chat-template tests (tests/frontend/prepare_templates.py (not opened) HTTP 403 on gated repo meta-models/Muse-Spark-Open-816B-A42B-NVFP4 — infrastructure, unrelated to the diff), the 64-seed learning.py (not opened) --preset validate sweep, and the live SM121 A/B. Companion local-inference-lab/hyperflare-recipes PR splits Qwen3.8 TERMINAL_PREFILL capacities > 128; both are stated to be independently mergeable.
Reach
- Effect is global and unflagged for every prefill-capable core.
ActionCosts::getre-routes all single-lane prefill steps through the fitted predictor, so prefill durations,expected_finish_ns, admission timing and pipelining depth all change together. The phase test atphase_tests.rs:1311-1318(600 → 195..210 ns) shows the magnitude can be large for short tails. - Operators get a new always-on value coefficient with no flag, no server-config key, and no documentation in the defaults table/README.
- Checkpoint pricing cost rises whenever fills are non-constant (stride path lost) — impacts the O(1) budget #459 introduced.
- Compatibility: no Protobuf or core ABI change; existing exported cores load and serve without re-export.
- Verification harness must be kept in sync by hand (
check.py:544-610duplicates scheduler source text). - Observers: multi-rank TP2 paths (executor kind lists), and any core whose completion inputs use
ConsumedTokens | SnapshotConsumedTokens(now withPrefill).
Process
Open and marked ready for review, 20 files, one commit, CI green on the head commit, no labels, no reviewers requested, no discussion, same-day age. Closing issue #485 is claimed but the issue's design intent (logarithmic KV bands + a measured prototype) differs from what is implemented (affine NNLS over 3 ctx bands), and #485's own benchmark scenario is not re-run — worth checking with voipmonitor before merge rather than after.
Open questions / not found
- 8 × 8,192 burst numbers: no checked-in workload reproduces them.
- Whether the loss of the checkpoint stride path in the non-constant regime is intended (and budgeted) or an oversight — the description implies the fast path survives.
- Why the coalescing coefficient has no
--scheduler-*knob or server-config key while every sibling coefficient does. - Merge order with #644: overlapping edits in
utility.rs/service.rs/policy.rsand a changedLaneValue. - No confirmation from voipmonitor that the affine design satisfies #485's reported symptom.