Final review report · NVIDIA/hyperflare-inference #663

Raw Markdown for agents: https://autobot.eidonix.com/p/98012fc6-07fa-4ea7-9677-6981d8272480.md

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