Final review report · NVIDIA/hyperflare-inference #693

Raw Markdown for agents: https://autobot.eidonix.com/p/74706fbd-861d-4be3-885d-3ddf59caa46f.md

Recommendation: Changes Requested

The core optimization is mathematically exact, low-risk, and well-placed in the model-agnostic Helios scheduling layer: caching per-slot powered survival curves across RequestScheduler::candidates, short-circuiting tokens <= 1 / limit <= 1, and returning early at adaptive_verification_alpha == 1.0 preserve bit-identical candidate scores and scheduling decisions. However, four verified issues should be addressed before merging: missing contributor attribution to @shieldstar (who published this design and patch in #547), performance-claim and CI evidence gaps relative to docs/design-review.md rules 12 and 16 (pre-rebase unreproducible microbenchmarks, omitted profile caveats, and no CI run on a9f7dd7), a mismatched CurveCache::new(false) mode tag in mixed_candidates, and an avoidable next_progress restructure that unconditionally constructs a 1,544-byte stack CurveCache on every speculative call to work around Option<&mut CurveCache>.

Merge Risk

Level: Low

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

  1. Credit @shieldstar for the original #547 diagnosis, patch design, and tests (Charter: "Respect contributors").

    • Issue #547 (opened by shieldstar / Discord shieldstarx) includes a complete, ready-to-apply patch implementing this exact architecture (cached_lane_value, per-pass cache in candidates/phase_plan, per-call cache in mixed_candidates, powered_curve alpha == 1.0 fast path, CURVE_EVALUATIONS, and the exact same three test names in policy_tests.rs). PR #693 only writes Fixes #547 with no attribution.
    • Fix: Add explicit credit (e.g., Co-authored-by: or an attribution note in the PR description and commit message) acknowledging @shieldstar's #547 patch and tests.
  2. Align performance claims and verification evidence with docs/design-review.md:106-115, 147-162 (and run CI on a9f7dd7).

    • The PR leads with a 3-fixture CPU speedup table (2.61x, 5.40x, 4.54x) measured against a pre-rebase baseline (c513e46a, not the rebased base cc0a49d2), with no benchmark harness, fixture script, or command in the PR (helios/benches/ contains only template.rs) and no served-workload measurement (scripts/benchmark_scheduler.py was not run).
    • The "Why" section cites #547's 5.48% pow@@GLIBC_2.29 sample without #547's explicit caveat that the binary was stripped, from a downstream tree, and lacked a call graph so pow could not be split between powered_curve and other powf sites (such as helios/src/scheduler/rounds.rs:571, 594, 873).
    • No GitHub Actions CI checks have run on head a9f7dd7.
    • Fix: Either (a) re-measure on the current base with a reproducible command/harness and add a served-workload A/B run via scripts/benchmark_scheduler.py if keeping a performance speedup claim, or (b) reframe the PR honestly as a behaviour-preserving de-duplication cleanup (dropping the pre-rebase speedup table as a headline claim) and include #547's stripped-binary / no-call-graph caveat on the 5.48% profile figure. Ensure CI passes on the head commit.
  3. Fix mismatched CurveCache::new(false) mode tag in mixed_candidates (helios/src/scheduler/policy.rs:1707-1716).

    • mixed_candidates(..., optimistic: bool) constructs CurveCache::new(false) at policy.rs:1714, unlike packed_round_candidates (helios/src/scheduler/rounds.rs:844, CurveCache::new(optimistic)). Production does call mixed_candidates(..., true) from acceptance_probe (helios/src/scheduler/learning.rs:19).
    • Today it avoids tripping CurveCache::get_or_insert_with's debug_assert_eq! (policy.rs:119-122) only because mixed_candidates_with_curves bypasses curves when optimistic is true (policy.rs:1770, calling self.optimistic_tokens(...) uncached on every mixed shape), which also wastes a 1,544-byte stack CurveCache construction on every optimistic call and leaves a latent assertion trap if that branch ever uses curves.
    • Fix: Construct CurveCache::new(optimistic) at policy.rs:1714 (and consider caching the optimistic branch through curves or sharing one optimistic cache in learning.rs:17-19 if desired, or only creating the cache when !optimistic).
  4. Remove the unnecessary next_progress restructure and unconditional 1,544-byte stack CurveCache workaround (helios/src/scheduler/policy.rs:896-1013).

    • Every production caller of prerequisite_value (policy.rs:1015) -> next_progress (policy.rs:896) arrives from cached_lane_value (:1587) or cached_lane_value_within (:1274) with curves == Some(...); all None callers (:1171, 1545, 1756, 1993, 1997) pass prefill or decode/speculative kinds and never reach _ => self.prerequisite_value(...) at :1522.
    • Because next_progress takes Option<&mut CurveCache> instead of &mut CurveCache, :958-959 unconditionally constructs let mut local_curves = CurveCache::new(false); (64 * 24 + 8 = 1,544 bytes zero-initialized on the stack and dropped via a 64-slot loop) even when curves is Some(...), duplicates the mixed_catalog loop (:969-979 vs :982-1011), adds an early return at :980, and leaves :1008-1009 hardcoding value.decode(1.0, ...) via an undocumented control-flow coupling to :946 (omitted from the PR description).
    • Fix: Change prerequisite_value (:1021) and next_progress (:900) to take curves: &mut CurveCache directly (or unwrap/pass &mut CurveCache from the _ => arm if keeping Option on cached_lane_value_for_tokens_within), delete local_curves, delete the duplicated mixed_catalog loop and early return (:969-980), and keep main's single mixed_catalog loop with if self.speculative_widths.is_empty() { 1.0 } else { self.cached_expected_tokens(r, self.speculative_tokens(r, width), Some(curves)) }.

Subtract / Simplify

  1. Eliminate Option<&mut CurveCache> and collapse the six lane-value wrappers (helios/src/scheduler/policy.rs:1387-1524).
    • The Option plumbing across cached_expected_tokens, cached_lane_value_for_tokens_within, prerequisite_value, and next_progress (and the None => self.expected_speculative_tokens(...) arm at :1402) serves only one production decode site: resize_prefill at policy.rs:1997 (all other uncached callers at :1171, 1545, 1756, 1993 are prefill-only and never touch curves).
    • Threading a &mut CurveCache (or a local cache in resize_prefill) removes Option<&mut CurveCache>, removes local_curves in next_progress, and lets the six-wrapper family (lane_value, cached_lane_value, cached_lane_value_within, lane_value_for_tokens, lane_value_for_tokens_within, cached_lane_value_for_tokens_within) collapse to the minimal cached pair + prefill helper (~35-45 lines deleted, while keeping expected_speculative_tokens in rounds.rs:622 for its real production caller at helios/src/scheduler.rs:2483).
  2. Trim redundant call-count test scaffolding (helios/src/scheduler/policy_tests.rs:9488-9564, policy.rs:126-129).
    • cached_lane_pricing_matches_uncached_for_unit_and_fractional_alpha (policy_tests.rs:9655-9662) already asserts CURVE_EVALUATIONS == wide_decoders.len() on a superset fixture (waiting Init, Mixed, packed Speculative, and a 1-remaining-token lane). While cost::ENTRY_LOOKUPS (helios/src/scheduler/cost.rs:18 (not opened)) provides an in-repo precedent for #[cfg(test)] counters, note that a prior Autobot review of #540 flagged CURVE_EVALUATIONS for removal and the three standalone counting tests (:9488-9564) largely overlap the fourth test; consolidating or justifying them keeps test surface leaner.

Nits

Dropped on verification