Final review report · NVIDIA/hyperflare-inference #681

Raw Markdown for agents: https://autobot.eidonix.com/p/7642d8e1-591a-4f4c-ad38-fe20a38848f1.md

Recommendation: Changes Requested

The production Rust and Python arithmetic (helios/src/scheduler/policy.rs +11/−10, scripts/scheduling_sim/utility.py +2/−6) is memory-safe, deterministic, ABI-compatible, and fixes a real rem = 1 cohort-collapse defect introduced in #645. However, this PR should not merge onto main as-is: (1) its only standalone (Solo) served benchmarks against main regress 2 of 3 scenarios (including -3.7% tok/s, -9.0 pp SLO, and +54.8% agentic_multiturn TTFT p99 on cold-heavy-mix) while relying on unmerged #661 to keep cold prefills bounded, and head e15b836 has no CI or commit-matched A/B run; and (2) the reported 84-run scripts/scheduling_sim sweep is mathematically inert for this change because every workload uses max_new_tokens = 4096. Rebase/merge after #661, add an end-to-end heterogeneous-budget simulator workload that actually exercises output_budget < 64, confirm green CI on the reviewed head, and clean up the hot-path expected_at recomputation and doc/description attribution.

Merge Risk

Level: Medium

Walkthrough

Pre-merge Checks

Blockers

  1. Standalone main regressions, dependency on unmerged #661, and unverified head commit (helios/src/scheduler/policy.rs:627,636,667-672, docs/design-review.md:109-115, Charter #210).

    • Verified behavior/impact: Because cohort-mean horizon (mean_i min(rem_i, ph)) is strictly >= main's minimum (min_i min(rem_i, ph)), keeping coalescing active near EOS pulls 150K–250K cold prefills ahead of active decoders when #661's chunk shrinking/draining is absent. In the PR's own Solo A/B against main, 2 of 3 scenarios regress: cold-heavy-mix (n=1) drops output 541.8 -> 521.8 tok/s (-3.7%), SLO 88.1% -> 79.1% (-9.0 pp), TTFT p50 1,763 -> 1,834 ms, and agentic_multiturn TTFT p99 3,323 -> 5,144 ms (+54.8%); mixed-c32 (n=2) drops SLO 93.0% -> 91.1% (-1.9 pp), stalls 11.29% -> 11.49%, and output 1,281.7 -> 1,276.8 tok/s. Meanwhile, the positive On #661 and Stack rows rely on unmerged #661 (and #660/#665), served A/B ran on trees df9a8ebd/dbbf65df/38130855 (archive checks on 40596880cc64), and head e15b836 has no CI checks.
    • Fix: Hold merge until #661 lands (then rebase onto main containing #661), ensure GitHub Actions CI is green on the final head commit, and confirm the A/B-measured tree matches the reviewed head (with repeats on the primary target workloads).
  2. Reported 84-run simulator sweep is mathematically inert for this change (scripts/scheduling_sim/utility.py:234-235, scripts/scheduling_sim/model.py:103, scripts/scheduling_sim/simulator.py:26, scripts/scheduling_sim/workloads.py:25-55, docs/design-review.md:195-200,234-251).

    • Verified behavior/impact: docs/design-review.md:195-200,234-251 requires service-pricing / cohort-algorithm changes to update and run an applicable scripts/scheduling_sim/ evaluation covering the changed behavior. In scripts/scheduling_sim/workloads.py:25-55, no workload overrides max_new_tokens, so every Request uses the default max_new_tokens = 4096 (model.py:103). Because State.view() computes output_budget = r.max_new_tokens - self.generated (simulator.py:26), every active decoder in every multi-decoder workload with prefill has output_budget >= 3840 >> 64.0 throughout the run (and continuous_decode has k = 1, where min and mean are identical). Thus "84/84 matched 1fbcc3c9" is true by construction and never tests a heterogeneous rem < 64 cohort in end-to-end simulation (and verification/helios-lifecycle/check.py (not opened) has no coverage of policy.rs).
    • Fix: Add a heterogeneous-budget workload to scripts/scheduling_sim/workloads.py (or a dedicated end-to-end simulation test in tests/test_scheduling_utility.py) that sets small max_new_tokens on near-EOS decoders alongside long decoders and queued prefills under balanced (age_price = 0.1), and report the before/after simulator delta on makespan, TTFT, and max output gap.

Should Fix

  1. Reconcile PR description attribution and design-spec wording (docs/scheduling-runtime-design.md:224-229, scripts/scheduling_sim/utility.py:215-219, helios/src/scheduler/policy.rs:627,636).
    • Verified behavior/impact: (a) scripts/scheduling_sim/utility.py:215-219 was already computing mean_out as a per-decoder average before this PR (untouched by the diff); only the horizon formula at utility.py:234-235 is new to both implementations, so policy.rs:627,636 is a Rust→simulator parity repair rather than a new rule. (b) In the PR Result section, Stack rows combine #660 + #661 + #665 (e.g., prefix-cache hit-rate gains come from #665 and stall reductions primarily from #661), and the On #661 long-context-mixed SLO drop (89.3% -> 82.1%, -7.2 pp) appears in the table without being mentioned in the summary prose. (c) docs/scheduling-runtime-design.md:224-229 still says "over a bounded per-stream decode horizon ... averaged across active decoders", even though the cohort mean can exceed an individual near-EOS stream's remaining budget.
    • Fix: Update the PR description to distinguish the mean_out parity repair from the new horizon rule and explicitly attribute #660/#661/#665 stack effects plus the Solo / On #661 SLO drops; reword docs/scheduling-runtime-design.md:224 from "bounded per-stream decode horizon" to "bounded cohort-mean decode horizon".

Subtract / Simplify

  1. Extract a 3-line mean_capped helper, hoist expected_at, and delete dead .max(1.0) clamps (helios/src/scheduler/policy.rs:627,636,668-672).
    • Currently :627 and :636 evaluate expected_at(...) inside decoder_rems[..decoder_count].iter().map(|&rem| ...), recomputing the loop-invariant mean_curve sum up to REQUEST_LANES (64) times per shape on the select_plan hot path; both lines also carry a provably dead .max(1.0) (rem >= 1 at :550, and expected_at(...) >= 1.0 at :586-598 because powered_curve / speculative_curve probabilities are clamped to [0.0, 1.0] at helios/src/scheduler/rounds.rs:505), and are the only two >150-column lines in the file (166 and 181 chars).
    • Replace all three cohort-mean sites (:627, :636, :668-672) with:
      fn mean_capped(rems: &[usize], cap: f64) -> f64 {
          rems.iter().map(|&rem| (rem as f64).min(cap)).sum::<f64>() / rems.len() as f64
      }
      
      and call mean_capped(&decoder_rems[..decoder_count], expected_at(eff_width)), mean_capped(&decoder_rems[..decoder_count], expected_at(width as f64)), and mean_capped(&decoder_rems[..decoder_count], ph).
  2. Delete the unreachable if horizon > 0.0 guard (helios/src/scheduler/policy.rs:673).
    • Upstream guards already guarantee coalescing_horizon_tokens > 0.0 (:527), rem > 0 (:550), post_prefill > 0 (:561), and decoder_count > 0 (:567), so every summand is strictly positive and horizon > 0.0 always holds; :678 already validates per_token.is_finite() && per_token > 0.0. Removing the branch deletes 2 lines and unindents the amortization block.
  3. Reuse super::rounds::forecast_tokens in the new speculative test (helios/src/scheduler/policy_tests.rs:7002-7011).
    • The 10-line hand-copied expected_at interpolation closure is only called with integral widths (8.0 at :7012, 6.0 at :7044, 4.0 at :7045). Replace it with super::rounds::forecast_tokens(&curve, w) (helios/src/scheduler/rounds.rs:991-993, matching the existing test precedent at policy_tests.rs:7152).

Nits

Dropped on verification