Recommendation: Changes Requested
The core formulation (decode_age_price * (b_served * T_dec) * age_ms * frac) is clean, well-bounded, single-threaded, and avoids the zero-age discontinuity and F > A monotonicity inversion seen in competing PR #654, backed by strong paired GPU A/B results on two model architectures (DeepSeek-V4.1-Flash TP4 and Qwen3.8-Flash-Next TP2). However, it cannot merge as-is: it ships a behavior change into the default --scheduler-policy balanced while leaving explicit normative invariants in docs/scheduling-theory.md:850-851 and docs/scheduling-runtime-design.md:234 directly contradicted (and without maintainer sign-off resolving #663 vs competing opt-in #654), silently allows GraphKind::Mixed shapes to populate the documented pure Decode/Speculative reference b_served * T_dec, and weakens existing burst-coalescing regression tests under balanced.
Merge Risk
Level: Medium
- Default-policy blast radius: Because the new credit is gated on
PolicyConfig::default().decode_age_price(0.1,helios/src/scheduler/policy.rs:35), every default--scheduler-policy balanceddeployment changes prefill-vs-decode ordering with no opt-out short of switching to--scheduler-policy throughput(which also disables decodedelivery_fairnessanddecode_age_price), trading large returning-prompt TTFT wins for disclosed background decode tail-latency increases (+95 msp99 atK=16on DeepSeek-V4.1-Flash;+76 msp99 /+151 msmax atK=16on Qwen3.8-Flash-Next). - Low runtime/safety risk: Production changes are compact (~105 net Rust lines), single-threaded (
&mut self), allocation-free on the hot path, and preserve Protobuf/ABI/prepared-graph compatibility and--scheduler-policy throughputidentity by construction; cancellation,status == 3errors, two-frame pipelining, and preemption/requeue readmission (Carried::last_output_ns) were verified sound. - High branch-conflict / design-fork risk: Competes directly with open opt-in PR #654 across all 11 touched files, overlaps
complete_innerinhelios/src/scheduler.rsanddocs/scheduling-runtime-design.mdwith same-author PR #655 (Ready To Merge), and overlapspolicy.rs/ docs with complementary PRs #660 and #661.
Walkthrough
helios/src/scheduler/service.rs: Extendeddelivery_referencesintodelivery_references_and_decode_batch(:69-183), retainingdelivery_referencesas a.0wrapper (:59-64) and returning the fastest decode cohort work-timeb_served * T_decin stream-ms (0.0when no measured decoder is active).helios/src/scheduler/utility.rs&helios/src/scheduler/policy.rs: AddedRequestAccounting::first_output_wait_ns(policy.rs:59),RequestScheduler::set_first_output_wait(:271-281),fits_single_prefill_from(:442-464), andLaneValue::first_output_value/prefill_within(utility.rs:90-111). Inlane_values(policy.rs:729-752), waiting prompts withconsumed_tokens < prompt_tokens,max_new_tokens > 0,decode_age_price > 0.0, andincumbent_decode_batch_ms > 0.0earn scaleddecode_age_price * incumbent_decode_batch_ms * age_ms(projected across queued prefill submissions, excluded from the common-T/2 * sum(age_price)sum, and threaded throughnext_progressandlane_value_for_tokens_within).helios/src/scheduler.rs&helios/src/server/runtime.rs: ExtractedLiveRequest::initial_prefill_tokens()(scheduler.rs:351-355, replacing inline expressions); preservedfirst_output_wait_nsacross forced interiorRetentionRole::Anchorsplits on single-graph-fitting prompts (scheduler.rs:2681-2702,:2791-2793) while still chargingServicePricetruthfully; carriedCarried::last_output_nsacross parking and readmission (runtime.rs:429,:1575-1577,:2456-2498).scripts/scheduling_sim/utility.py, tests & docs: Added the credit formula toUtilityScheduler(utility.py:158-162,:251-270), added four Rust unit tests (policy_tests.rs:6957-7138) and one Python test (tests/test_scheduling_utility.py:404-424), reworked burst-coalescing isolation tests (policy_tests.rs:6794-6860,test_scheduling_utility.py:363-401), and documented the new term indocs/scheduling-utility.md:287-318anddocs/scheduling-runtime-design.md:266-284.
Pre-merge Checks
- [PASS] Security / malicious screen: Pure scheduler arithmetic, request-accounting timestamps, tests, and docs; no I/O, parsing, FFI, privilege, or untrusted-input surface introduced.
- [WARN] Charter & value fit: Model-agnostic and compact in the right runtime layer with strong served A/B evidence on two architectures, but silently alters the shipped
balanceddefault while contradicting unchanged normative text indocs/scheduling-theory.md:850-851anddocs/scheduling-runtime-design.md:234; hardware validation covers SM121 only (SM120 and oracle reference comparison not run). - [WARN] Related / duplicate / conflict check: Directly competes with open PR #654 (opt-in design for the same term across all 11 files) — maintainers must choose one design; overlaps
helios/src/scheduler.rsanddocs/scheduling-runtime-design.mdwith #655 (Ready To Merge), and sharespolicy.rs/docs with complementary #660/#661. - [WARN] Tests & verification evidence: All new Rust/Python tests are isolated and exercise real production entry points, CI is green, and TLA+ lifecycle conformance passed on head; however, existing
balancedburst-coalescing relative assertions were weakened, and the PR's claimed adversarial stress checks and Python formula-scaling invariants lack committed tests.
Blockers
- Unresolved normative contract contradiction on a shipped default policy (
docs/scheduling-theory.md:850-853,docs/scheduling-runtime-design.md:234,helios/src/scheduler/policy.rs:35)docs/scheduling-theory.md:850-851(untouched by this PR) explicitly states: "First-token waiting has no independent age penalty: prompt work competes by its useful progress and token-service price." Similarly,docs/scheduling-runtime-design.md:234(34 lines above this PR's own edit at:268) still states: "Only decoding requests have a delivery coordinate or output-age cost."- Because the new credit is activated by
PolicyConfig::default().decode_age_price = 0.1(policy.rs:35) — the default--scheduler-policy balanced(docs/cli-design.md:683) — this PR changes default scheduling behavior for every user (including the disclosed+76 msto+95 msbackground decode p99 trade-off atK=16) while leaving normative docs contradicting the runtime and while competing opt-in PR #654 is open for the same term. - Fix: Update
docs/scheduling-theory.md:850-853anddocs/scheduling-runtime-design.md:234(andhelios/README.md:362-364if keeping it in sync) to reflect the new first-output waiting-age term, and obtain explicit maintainer sign-off on enabling this under the shippedbalanceddefault (versus opt-in gating as in #654) before merge.
Should Fix
b_served * T_deccan be sourced fromGraphKind::Mixed, contradicting both docs and inflating credit with prefill duration (helios/src/scheduler/service.rs:150-181,scripts/scheduling_sim/utility.py:153-162)- In
service.rs:150-160, whenkindisDecode | Speculative, all measuredself.mixed_catalogshapes are fed into the same per-slotbest[]array that:168-173then promotes intobest_decode.scripts/scheduling_sim/utility.py:153-162has the same behavior (for graph in measured if decoding and graph.decode_capacity, unlike line:200which explicitly filtersnot g.prefill_capacityfor coalescing). - Both
docs/scheduling-runtime-design.md:272-274("the fastest incumbentDecodeorSpeculativeround's work-time") anddocs/scheduling-utility.md:292-295("the decode or speculative graph minimizingT_dec / b_served") state thatT_decis a pure decode/speculative graph. On mixed-capture cores (qwen3.8-flashwith--mixed-prefill), if a mixed shape winsT / served(e.g. during cold warm-up when pure decode batches are unmeasured, or if mixed declares a larger decode batch capacity),b_served * T_decincludes prefill execution time and inflates the waiting-age credit. - Fix: Compute
best_decodestrictly over the pureDecode/Speculativeloops (service.rs:123-149, before theMixedloop at:150-160), and filternot graph.prefill_capacitywhen computingincumbent_decode_batch_msinscripts/scheduling_sim/utility.py:153-162(which also resolves Subtract/Simplify #2 cleanly).
- In
- Existing
balancedburst-coalescing regression guarantees were dropped instead of preserved (tests/test_scheduling_utility.py:363-402,helios/src/scheduler/policy_tests.rs:6840-6860)tests/test_scheduling_utility.pyremoved the relative coalescing guarantees underbalanced(coal_ttft < base_ttft * 0.85,end_ms < base * 0.95,coal_sub <= base_sub // 2, andburst_eight_lowrelative TTFT/sub-batch checks), replacing them with loose absolute ceilings (coal_ttft <= 600.0,coal_sub <= 2) and softening the movedage_price = 0.0checks to strict<with noburst_eight_lowcomparison. Similarly,policy_tests.rs:6855-6859dropped the simultaneous-arrivalbasecomparison underbalanced.- With first-output waiting age active alongside
coalescing_prefill_log_bonus, nothing in the suite now verifies that enabling coalescing underbalanceddoes not regress TTFT or makespan when stacked with the new credit. - Fix: Restore a non-regression comparison (coalescing-on vs coalescing-off on
burst_eight/burst_eight_lowunderbalanced, asserting makespan and max TTFT do not regress) and keep the stronger margin checks on theage_price = 0.0isolation case.
- Commit simulator tests for the claimed formula properties and adversarial bounds (
tests/test_scheduling_utility.py:404-425)- The PR description reports exact
b_served * T_decscaling, partial-chunkwork / initial_prefilllinearity,output_budget == 0inertness, and two adversarial simulator checks (32 dec / B=4 / 16 promptsholdingconsec_pre = 1, and4 dec / B=1 / 24 promptsexact parity), buttests/test_scheduling_utility.py:404-425only assertsret_row["ttft_ms"] < 400.0andtp_sched._first_output_value == {}atage_price = 0.0. - Fix: Add deterministic pytest coverage in
tests/test_scheduling_utility.pyasserting exactincumbent_decode_batch_msscaling, partial vs completingfrac,output_budget == 0inertness, and the two adversarial stress invariants; also note whether an evaluation against the reference oracle (scripts/scheduling_sim/oracle_sweep.py (not opened) --prefill-wait-price, perdocs/design-review.md:195-208) was run or why it is N/A.
- The PR description reports exact
Subtract / Simplify
- Deduplicate
preserve_first_output_waitand drop dead checks (helios/src/scheduler.rs:2681-2702,:2742-2789)record.status != 3 && !finished(:2691-2692) is redundant becausefinished's first disjunct isrecord.status == 3(:2684)..saturating_sub(request.consumed_tokens)(:2688-2689) is unnecessary because line:2624already rejectsrecord.consumed_tokens < request.consumed_tokens as i64(and:2785uses plain subtraction).record,finished,prefill, andoutputare computed twice in the same loop body. Computing the record-derived fields once (or extracting a small&selfhelperis_forced_anchor_cut(&self, request, record)called beforeself.request_mut(lane.request)) removes ~10 lines and the duplicated 3-disjunctfinishedexpression.
- Track
best_decodedirectly insideconsiderinstead of per-slot squaring (helios/src/scheduler/service.rs:111-181)best_decode.1 * best_decode.1 * best_decode.0(:178) recoversserved * T_decby squaringservedto undo the division inconsider(:116), after comparing once per(candidate × slot)in thereferencesloop (:168-173).- Tracking
best_decode: (f64, f64, u64)((cost, served, nanos)) once per candidate inside the pureDecode/Speculativepath returnsserved * nanos as f64 / 1e6directly, removes ~8 lines, avoids per-slot redundant comparisons, and solves Should Fix #1 in one edit.
- Collapse
fits_single_prefill_fromonto a_fromvariant ofnatural_fit_prefill_capacityandprefill_catalog(helios/src/scheduler/policy.rs:357-363,:413-464)fits_single_prefill_from(:442-464) repeats the 3-way catalog selection already inprefill_catalog(:357-363) and repeats the scan body ofnatural_fit_prefill_capacity(:413-438). Verified inhelios/src/scheduler/cost.rs:639-670and:761-771thatcosts.prefill_entry(resolved, capacity).is_some()andcosts.duration(resolved, 1, capacity).is_some()are behaviorally identical.- Generalizing
natural_fit_prefill_capacitytonatural_fit_prefill_capacity_from(request, start, catalog, cut)(matching the existingprefill_work_from/resolve_prefill_kind_from/prefill_requires_terminal_completion_frompattern) removes ~20 lines of parallel logic in the exact area PR #660 also modifies.
- Fold
set_first_output_waitintoset_arrival(helios/src/scheduler/policy.rs:259-281,helios/src/server/runtime.rs:1574-1577)set_first_output_waithas one production caller (runtime.rs:1576), always invoked immediately afterset_arrival, duplicating the validation guard and slot lookup while introducing an implicit call-order trap (callingset_first_output_waitbeforeset_arrivalwould silently clobberfirst_output_wait_ns). Acceptingfirst_output_wait_ns: Option<u64>(or a singleset_arrival_and_wait) deletes a public method and removes the ordering hazard.
- Trim duplicated contract prose in
docs/scheduling-runtime-design.md:272-284- The 13-line explanation repeats
docs/scheduling-utility.md:287-318(and already diverges slightly in phrasing, e.g., omittingprompt_logprobs). Keep the added formula line at:268, fix:234, and point toscheduling-utility.mdfor the detailed definition ofA_first,frac, and inertness rules, matching neighboring paragraphs (:235).
- The 13-line explanation repeats
Nits
helios/src/scheduler/utility.rs:94-110: Delete the#[cfg(test)] pub fn prefillshim (only called atutility.rs:410-412; callprefill_within(64, 64, true)directly) and drop the redundant outer.min(1.0)at:106(already guaranteed byinitial_prefill.max(consumed).max(1)in the denominator).helios/src/server/metrics/scheduler.rs:55-64&helios/src/server/runtime.rs:1231-1240: Consider exposingfirst_output_wait_nsinRequestDetailalongsidelast_progress_ns/last_output_nsif operators need to inspect anchor-cut wait-clock preservation in the scheduler trace dashboard.
Dropped on verification
- Correctness Finding 3 (
requeue()misseslast_output_nsclamp): False. Both callers ofrequeue()(runtime.rs:2874,:2924) only execute when the current admission hasgenerated_tokens == 0, andrequeue()preservesactive.carried(runtime.rs:2954), so any previously parked request retains itscarried.last_output_nsacross requeues. - Correctness Finding 6 sub-claim (
first_output_valueis outsidescale): False.policy.rs:678includesself.policy.decode_age_price.ln()inscaleand:768scalesvalue.first_output_value *= unit, matchingdecode'sage_price * reference_delivery_ms * age_msidentically. - Correctness Finding 11 sub-claims (
view.weightand_initial_prefilldiverge inscripts/scheduling_sim/utility.py): False. Every term inutility.py(:178,:188,:195,:239,:257,:296) intentionally multiplies byview.weightfor weighted-request simulation, and_initial_prefill(:146-148) capturesview.remaining_prefillon first appearance, which equals Rust's uncachedinitial_prefill_tokens(). - Correctness Finding 2 severity (
RequestDetailmissingfirst_output_wait_nsas Major): Downgraded to Nit.RequestDetailis an internal dashboard trace snapshot that also omitsarrival_nsandterminal_since_ns, not a blocking observability regression. - Correctness Finding 9 (
ignition/direct/policy.pymirror drift): Low-signal.docs/scheduling-runtime-design.md:15-17explicitly scopesignition/direct/to decode rounds only (it already omitsterminal,prefill, and coalescing). - Correctness Finding 12 (missing TLA+ lifecycle fixture for
first_output_wait_ns): Low-signal. The TLA+ lifecycle models verify discrete ownership/fencing/phase safety, not continuous priority timestamps likelast_progress_nsorfirst_output_wait_ns;check.py(not opened) was re-run and passed on head. - Dossier claim (
fits_single_prefill_fromrequires a "measured" graph): Inaccurate. Verified incost.rs:654-670thatprefill_entry().is_some()checks catalog registration (measured or unmeasured), matchingduration().is_some()and the PR's own wording ("eligible prefill graph").