PR #663: helios/scheduler: price first-output waiting age on incumbent decode rounds

Raw Markdown for agents: https://autobot.eidonix.com/api/v1/cases/a850621c-948f-4a37-a2da-8d16fded71da

Opened by a workflow run, Dec 1, 2026 2:42 PM EST.

Classify draft

Selected: performance, enhancement, area:scheduling

Threshold: 65%

Priority

Type

Area

Model

explore

Author: yatesdr (COLLABORATOR, Discord D-Rock) Motivation: Prompts waiting for their first token earn no waiting-age credit while decoding streams do, so behind 8–16 active decoders a returning prompt can wait seconds for its token-service price to climb; an interior checkpoint cut then re-queues the 2-token tail at zero age, a "double stall". The PR gives waiting prompts a credit scaled by the incumbent decoders' served batch round time, reusing the existing decode_age_price, with no new knob. Scale: +511 / −40 lines in 11 files (~105 net production Rust) Proposal:

Full report · Notes

Value Proposition

Value Proposition — PR #663 (helios/scheduler: price first-output waiting age on incumbent decode rounds)

Charter alignment

Serves the runtime with a small footprint: no per-model branch (#267/#334), no new graph kind, no Protobuf/ABI change, no new PolicyConfig field, ≈105 net production Rust lines, one extra return value from an existing single pass (#404 satisfied). Three conflicts:

  1. Contradicts an unchanged documented invariant. docs/scheduling-theory.md:850-853 still says first-token waiting has no independent age penalty — exactly the term #663 adds — and #654's review treated that sentence as a blocking item. #663 amends neither it nor helios/README.md or docs/cli-design.md:683.
  2. Silent default change. The credit is gated on decode_age_price = 0.1 in PolicyConfig::default(), i.e. the documented default balanced policy, with no knob and first_output_wait_ns exposed nowhere. That sits against "be explicit … no magic defaults" (#215).
  3. Matrix gap. Only SM121 (DGX Spark GB10) was run; SM120 (4× RTX PRO 6000), multi-host, and alternate cache/parallel layouts were not, although sibling PRs #660/#661 did run SM120.

Novelty & status

Genuinely additive, not obsolete: no mainline commit implements first-output waiting age (search_history returns only a5c36978), and no issue reports the exact symptom. Not superseded: #654 is a competing opt-in design of the same term, #660/#661 are complementary (both sides say so), and #662 was closed as a duplicate of this same work. The live risk is that #654 and #663 are alternative designs for one term — only one should land.

Value vs maintenance cost

Beneficiary: anyone serving returning-agent or bursty traffic against active decode cohorts under the default policy. Evidence is unusually strong for this area — paired served A/B vs a3c80e19 on DeepSeek-V4.1-Flash TP4 (returning TTFT p50 −63.5 %/−83.0 %, turns/min +64.8 %/+105.7 %) and Qwen3.8-Flash-Next TP2 (p50 −79.9 %), throughput parity, 21/21 simulator trace identity at age_price = 0, green Rust/Python suites, disclosed limitations. Costs are contained but real: disclosed background decode p99 regressions (+95 ms DeepSeek K=16; +76 ms/+151 ms max on Qwen); the anchor-cut/readmission half is Rust-only (the simulator models no checkpoints), so no measurement isolates it from the credit term; no oracle (prefill_wait_price/F) comparison; two coalescing regression tests loosened from relative to absolute assertions; TLA+ figures re-verify unmodified models.

Required changes

Amend the theory-doc invariant with maintainer sign-off and update the balanced prose; expose the new clock; separate anchor/readmission contribution from the credit contribution; run SM120; justify or restore the loosened assertions; choose #654 vs #663 and rebase over #655.

Verdict

Worth it with changes.

Full report Decide Value: yes (99%): This change is worth reviewing: it provides value to the project in line with its charter.

Classify intake

Selected: triage:design-review, performance, duplicate, area:scheduling

Threshold: 65%

Triage

Priority

Type

Area

Model

Apply Labels (Intake)

Applied: +triage:design-review, +duplicate

Subtraction and simplicity

Reviewed PR #663 through the subtraction/simplicity lens: read the full diff (11 files, +511/−40) and checked each new piece of logic against existing helpers.

Verdict: the production surface is honest — no new knob, flag, graph kind, crate or dead field — and mostly lean. Six concrete simplifications remain; three are worth asking for before merge:

  1. helios/src/scheduler.rs:2677-2702 — the preserve_first_output_wait predicate contains a dead conjunct (record.status != 3 && !finished), an unnecessary saturating_sub, and re-derives finished/prefill/output that the same loop body defines again at :2742-2745. Hoist the locals once; ~10 lines gone.
  2. helios/src/scheduler/service.rs:150-181 — b_served * T_dec is tracked per slot from best[slot] then un-derived by squaring (served * served * per_delivery_ms). consider (:111-122) already has nanos/served; moving the comparison there returns served * duration directly, once per candidate instead of once per candidate × slot.
  3. helios/src/scheduler/policy.rs:442-464 — fits_single_prefill_from re-implements the catalog choice already in prefill_catalog(kind) (:357-363) and duplicates natural_fit_prefill_capacity (:413-438) body-for-body. The repo already has _from variants for work/kind resolution; a _from fit search collapses ~20 lines and removes the drift risk in the area #660 also edits.

Lower value: policy.rs:259-281 (set_first_output_wait repeats set_arrival's validation for one caller pair — merge into one setter); utility.rs:93-111 (the #[cfg(test)]-only prefill shim passes consumed.max(1), so the surviving tail test never hits the partial-chunk path; plus two unreachable clamps); docs/scheduling-utility.md:287-318 vs docs/scheduling-runtime-design.md:266-284 (the new contract stated twice, already drifted — keep formula + pointer, per AGENTS.md:188-193).

Positives to say in review: initial_prefill_tokens() is a net simplification, delivery_references's thin wrapper is justified, and the Python mirror's cache shape matches the file's existing idiom.

Open questions: whether prefill_entry(...).is_some() vs duration(...).is_none() is a deliberate "measured vs registered" distinction; whether first_output_wait_ns must be public; when to cut the doc duplication given four docs PRs are open on the same file.

Full report · Notes

Correctness and contracts

PR #663 is mechanically careful — no race, panic, lock-contention, allocation or unbounded-buffering hazard — but its contract and evidence obligations are not met.

  1. Blocker: docs/scheduling-theory.md:850-853 still says "First-token waiting has no independent age penalty" while the credit is gated on decode_age_price = 0.1 in PolicyConfig::default() and balanced is the CLI/docs default (docs/cli-design.md:683, flare-cli/src/cli.rs:859-861) — a shipped default change with no knob and a stale normative doc (the same sentence was a blocker against #654).
  2. Major: first_output_wait_ns (policy.rs:59) is never published in RequestDetail (metrics/scheduler.rs:55-70 (not opened), runtime.rs:1231-1240), so operators cannot see the clock that now reorders the default policy.
  3. Major: service.rs:150-181 feeds Mixed (prefill+decode) shapes into the per-lane best[] and promotes that into best_decode, so b_served * T_dec can include prefill work, contradicting docs/scheduling-runtime-design.md:272-274 and the PR text; live on the Qwen3.8 Flash mixed-capture core used in the PR's own A/B.
  4. Major: tests/test_scheduling_utility.py:388-395 and policy_tests.rs:6843-6862 replaced relative coalescing guarantees (coal_ttft < base*0.85, end_ms < base*0.95, sub <= base_sub//2) with absolute ceilings; the description only says "updated the burst-coalescing isolation tests".
  5. Major: scripts/scheduling_sim/utility.py:251-259 is not a mirror — it uses now_ms - last_service_ms with no first_output_wait_ns, no anchor preservation, no readmission clamp, plus a view.weight Rust lacks. The 21/21 trace-identity and "zero regressions" claims cover the credit term only, not the double-stall fix that motivates the PR.
  6. Minor: ignition/direct/policy.py:114-142 mirrors RequestAccounting/LaneValue and gained neither field; the credit stacks with coalescing_prefill_log_bonus (policy.rs:635-650, 729-752) with no test bounding the combination; no lifecycle fixture for the new clock (check.py (not opened) unchanged); no oracle prefill_wait_price comparison; SM120 not run.

Open: will a maintainer accept inverting scheduling-theory.md:850 for a non-default-free change; is a silent default acceptable without an observable clock; how much of the 5.9× gain is credit vs anchor preservation (no artifact separates them); merge-order collisions with #654/#661/#655.

Full report · Notes

Final review

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

Walkthrough

Pre-merge Checks

Blockers

  1. 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 ms to +95 ms background decode p99 trade-off at K=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-853 and docs/scheduling-runtime-design.md:234 (and helios/README.md:362-364 if keeping it in sync) to reflect the new first-output waiting-age term, and obtain explicit maintainer sign-off on enabling this under the shipped balanced default (versus opt-in gating as in #654) before merge.

Should Fix

  1. b_served * T_dec can be sourced from GraphKind::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, when kind is Decode | Speculative, all measured self.mixed_catalog shapes are fed into the same per-slot best[] array that :168-173 then promotes into best_decode. scripts/scheduling_sim/utility.py:153-162 has the same behavior (for graph in measured if decoding and graph.decode_capacity, unlike line :200 which explicitly filters not g.prefill_capacity for coalescing).
    • Both docs/scheduling-runtime-design.md:272-274 ("the fastest incumbent Decode or Speculative round's work-time") and docs/scheduling-utility.md:292-295 ("the decode or speculative graph minimizing T_dec / b_served") state that T_dec is a pure decode/speculative graph. On mixed-capture cores (qwen3.8-flash with --mixed-prefill), if a mixed shape wins T / 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_dec includes prefill execution time and inflates the waiting-age credit.
    • Fix: Compute best_decode strictly over the pure Decode/Speculative loops (service.rs:123-149, before the Mixed loop at :150-160), and filter not graph.prefill_capacity when computing incumbent_decode_batch_ms in scripts/scheduling_sim/utility.py:153-162 (which also resolves Subtract/Simplify #2 cleanly).
  2. Existing balanced burst-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.py removed the relative coalescing guarantees under balanced (coal_ttft < base_ttft * 0.85, end_ms < base * 0.95, coal_sub <= base_sub // 2, and burst_eight_low relative TTFT/sub-batch checks), replacing them with loose absolute ceilings (coal_ttft <= 600.0, coal_sub <= 2) and softening the moved age_price = 0.0 checks to strict < with no burst_eight_low comparison. Similarly, policy_tests.rs:6855-6859 dropped the simultaneous-arrival base comparison under balanced.
    • With first-output waiting age active alongside coalescing_prefill_log_bonus, nothing in the suite now verifies that enabling coalescing under balanced does 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_low under balanced, asserting makespan and max TTFT do not regress) and keep the stronger margin checks on the age_price = 0.0 isolation case.
  3. 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_dec scaling, partial-chunk work / initial_prefill linearity, output_budget == 0 inertness, and two adversarial simulator checks (32 dec / B=4 / 16 prompts holding consec_pre = 1, and 4 dec / B=1 / 24 prompts exact parity), but tests/test_scheduling_utility.py:404-425 only asserts ret_row["ttft_ms"] < 400.0 and tp_sched._first_output_value == {} at age_price = 0.0.
    • Fix: Add deterministic pytest coverage in tests/test_scheduling_utility.py asserting exact incumbent_decode_batch_ms scaling, partial vs completing frac, output_budget == 0 inertness, 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, per docs/design-review.md:195-208) was run or why it is N/A.

Subtract / Simplify

  1. Deduplicate preserve_first_output_wait and drop dead checks (helios/src/scheduler.rs:2681-2702, :2742-2789)
    • record.status != 3 && !finished (:2691-2692) is redundant because finished's first disjunct is record.status == 3 (:2684).
    • .saturating_sub(request.consumed_tokens) (:2688-2689) is unnecessary because line :2624 already rejects record.consumed_tokens < request.consumed_tokens as i64 (and :2785 uses plain subtraction).
    • record, finished, prefill, and output are computed twice in the same loop body. Computing the record-derived fields once (or extracting a small &self helper is_forced_anchor_cut(&self, request, record) called before self.request_mut(lane.request)) removes ~10 lines and the duplicated 3-disjunct finished expression.
  2. Track best_decode directly inside consider instead of per-slot squaring (helios/src/scheduler/service.rs:111-181)
    • best_decode.1 * best_decode.1 * best_decode.0 (:178) recovers served * T_dec by squaring served to undo the division in consider (:116), after comparing once per (candidate × slot) in the references loop (:168-173).
    • Tracking best_decode: (f64, f64, u64) ((cost, served, nanos)) once per candidate inside the pure Decode/Speculative path returns served * nanos as f64 / 1e6 directly, removes ~8 lines, avoids per-slot redundant comparisons, and solves Should Fix #1 in one edit.
  3. Collapse fits_single_prefill_from onto a _from variant of natural_fit_prefill_capacity and prefill_catalog (helios/src/scheduler/policy.rs:357-363, :413-464)
    • fits_single_prefill_from (:442-464) repeats the 3-way catalog selection already in prefill_catalog (:357-363) and repeats the scan body of natural_fit_prefill_capacity (:413-438). Verified in helios/src/scheduler/cost.rs:639-670 and :761-771 that costs.prefill_entry(resolved, capacity).is_some() and costs.duration(resolved, 1, capacity).is_some() are behaviorally identical.
    • Generalizing natural_fit_prefill_capacity to natural_fit_prefill_capacity_from(request, start, catalog, cut) (matching the existing prefill_work_from / resolve_prefill_kind_from / prefill_requires_terminal_completion_from pattern) removes ~20 lines of parallel logic in the exact area PR #660 also modifies.
  4. Fold set_first_output_wait into set_arrival (helios/src/scheduler/policy.rs:259-281, helios/src/server/runtime.rs:1574-1577)
    • set_first_output_wait has one production caller (runtime.rs:1576), always invoked immediately after set_arrival, duplicating the validation guard and slot lookup while introducing an implicit call-order trap (calling set_first_output_wait before set_arrival would silently clobber first_output_wait_ns). Accepting first_output_wait_ns: Option<u64> (or a single set_arrival_and_wait) deletes a public method and removes the ordering hazard.
  5. 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., omitting prompt_logprobs). Keep the added formula line at :268, fix :234, and point to scheduling-utility.md for the detailed definition of A_first, frac, and inertness rules, matching neighboring paragraphs (:235).

Nits

Dropped on verification

Full report

Classify triage

Selected: triage:design-review

Threshold: 65%

Triage

Apply labels

No label changes Decision to Test: no (100%): Testing will not add significant value as the code stands today. The code is either not yet ready to merge, or adequate testing has already been done to validate the contents of the code, or the available hardware is not suitable to test with.