PR #693: perf(scheduler): cache per-lane powered survival curves across candidate pricing

Raw Markdown for agents: https://autobot.eidonix.com/api/v1/cases/eb10aba4-e81e-43d1-878e-c39344aea45b

Opened by a workflow run, Dec 2, 2026 4:25 PM EST. decide malicious: all_clear (100%): No malicious content found

explore

Author: jcartu (CONTRIBUTOR; 3 merged / 3 closed / 10 open in 180 days, mostly docs and small Helios fixes; Discord jcartu) Motivation: Every time the scheduler prices a candidate shape it rebuilds each decoding lane's speculative survival curve — including a powf per depth even at the default exponent of 1.0 — and planning runs on the model worker thread that cannot poll completions while it plans. Because request and forecast state do not change during a pass, one curve per lane can be computed once and reused, which removes redundant allocations and powf calls without changing any score. Scale: +502 / −51 lines in 3 files (policy.rs +177/−46, policy_tests.rs +294, rounds.rs +31/−5) Proposal:

Full report · Notes

Classify intake

Selected: triage:review, performance, area:scheduling

Threshold: 65%

Triage

Priority

Type

Area

Model

Apply Labels (Intake)

Applied: +triage:review, +performance, +area:scheduling

Value Proposition

Value Proposition — PR #693

Charter alignment. The change sits in exactly the layer the charter protects: Helios scheduling, model-agnostic, no per-model branch, no new flag, config, or default (adaptive_verification_alpha stays 1.0). It is a genuine "smallest footprint in shared code" fix to the thread #188 already documented as unable to poll completions while planning. The description has the charter's four required parts and honestly discloses unrun checks. The mismatch is evidential: the charter (#210) and design-review rule 12 require a served-workload speedup, and this PR supplies host-CPU microbenchmarks with no published harness, measured against c513e46a before the rebase onto cc0a49d2. The 5.48% pow figure is inherited from #547, which itself says the binary was stripped, from a downstream tree, with no call graph — it cannot be attributed to powered_curve.

Novelty & status. Not obsolete: #188 covered packed_round_candidates/next_progress/service_rates, but mixed_candidates, continuation_candidate, prerequisite_value and the alpha-1 shortcut are still uncached on main, and neither CURVE_EVALUATIONS nor the #540 zero-duration reuse survives. Not superseded: no open PR competes on this optimization (#571, #621, #334, #306 only collide textually). So it is additive — but it reimplements, without credit, the complete patch shieldstar already published in open issue #547. That conflicts with "Respect contributors" and leaves #547 open with triage:validation.

Value vs maintenance cost. Beneficiaries are speculative-serving users on the scheduler hot path; the strongest evidence is the fixture-level equality test (cached_lane_pricing_matches_uncached…, exact score.to_bits() equality across alpha 1.0/0.6, widths 0–8, waiting Init, Mixed, packed, ties, and plan() winners), which is credible but weaker than #188's ~210k-plan trace comparison. Costs are real: +502/−51 in the highest-churn scheduler file (seven same-file merges in weeks, #681 merged the same day), an undeclared next_progress restructure that now hard-codes decode(1.0, …) and early-returns, a latent CurveCache::new(false) tag bug in the optimistic mixed_candidates path, a re-introduced CURVE_EVALUATIONS counter a prior review asked to delete, partial coverage (prefill paths still uncached), and zero reviews, labels, or CI checks.

Worth it with changes: credit and coordinate with #547 before proceeding; delete the counter; fix the optimistic tag; disclose the next_progress restructure explicitly; and either publish a re-runnable benchmark re-measured on cc0a49d2 or reframe the PR as a behaviour-identical cleanup without a speedup claim. The engineering is sound; the packaging is not yet up to the project's bar.

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

Subtraction and simplicity

PR #693 is a sound optimization but not a lean diff: the same computation is expressed twice, dead state was added, and a test-only counter returns that a prior review asked to delete.

  1. Option<&mut CurveCache> plus its None => expected_speculative_tokens fallback (policy.rs:1387-1404) is marshalled through four functions for exactly one production site — the mixed resized-candidate decode leg at policy.rs:1997. Corrected from my Working notes: the None arm is reachable, but only there. Make the parameter unconditional, build one cache per resize_prefill/add_prefill_candidate, and the None arm, the expected_speculative_tokens residual and three of the six lane_value* wrappers disappear (~40 lines).
  2. CurveCache.optimistic + its debug_assert_eq! (policy.rs:98-130) is dead state that nothing reads — the optimistic mixed branch bypasses the cache (policy.rs:1770) — and it is already inconsistent (CurveCache::new(false) at policy.rs:1714 vs new(optimistic) at rounds.rs:844). Delete the tag; do not patch 1714.
  3. The tokens <= 1 → f64::from(tokens != 0) guard is written twice, in policy.rs:1393-1395 and rounds.rs:626-631, and duplicates what forecast_tokens already returns (rounds.rs:1016-1019). State it once.
  4. CURVE_EVALUATIONS (rounds.rs:10-14, :634-636) plus is_cached and three call-count tests re-add what #540's review asked to delete; after this PR's alpha-1 shortcut the counter counts clones, not powf. Keep the bit-equality test (policy_tests.rs:9567-9781) only (~100 test lines saved).
  5. Minor: a restated comment (policy.rs:1641 vs :98-99) and inconsistent pub(super) vs private across the _with_curves wrapper pair.

Already lean: the alpha-1 fast path, the limit <= 1 skip, the slot-indexed fixed array; no AGENTS.md structural violation.

Open: rounds.rs lines taken from the dossier rather than re-read; whether expected_speculative_tokens has other callers; whether the next_progress restructure (policy.rs:946-1012) is needed at all — reverting it would be the biggest subtraction.

Full report · Notes

Correctness and contracts

The optimization is arithmetically sound — both short-circuits and the alpha==1.0 fast path are exact, cache indexing cannot panic, and no locking, I/O, metric-span or platform parity surface is touched — but the PR has one Major contract gap and five Minor correctness/claim issues.

Findings, most important first:

  1. Major — charter/design-review rule 12 evidence gap: the 2.61x/5.40x/4.54x table is host-CPU only, pre-rebase (c513e46a), with no harness or fixtures, while the repo already ships the required served measurement (scripts/benchmark_scheduler.py:4) which the PR did not run. docs/design-review.md:106-115 explicitly requires "actual Helios service measurements"; the PR concedes "No standalone GPU serving throughput or latency improvement is claimed."
  2. Minor — mixed_candidates builds the cache with the wrong mode tag: CurveCache::new(false) (policy.rs:1714) while packed_round_candidates uses CurveCache::new(optimistic) (rounds.rs:844). Since the only lookup also hardcodes false (policy.rs:1399), the advertised debug_assert_eq! guard (policy.rs:117-122) provably never fires.
  3. Minor — undeclared next_progress restructure: the non-empty-speculation branch now returns early (policy.rs:980) and the residual Mixed decode arm hardcodes value.decode(1.0, …) (policy.rs:1009) where main computed a conditional curve forecast (main policy.rs:959-968). Correct today only because of an invariant documented nowhere.
  4. Minor — new per-call allocation reversed: next_progress now allocates a fresh [Option<Vec<f64>>; 64] (≈1.5 KB) via CurveCache::new(false) (policy.rs:958) on every uncached prerequisite_value path, where main lazily allocated two Option<Vec<f64>> (main policy.rs:908, 932).
  5. Minor — CURVE_EVALUATIONS re-added after the #540 review asked for its deletion, and it counts curve construction, not powf (rounds.rs:635-636, incremented before the alpha fast path at :638), so at default alpha an "evaluation" is a Vec clone with no powf.
  6. Minor — scope-of-claim gap: the new "evaluate each lane curve at most once" comment (policy.rs:1641) covers only candidates; coalescing_prefill_log_bonus still builds one curve per decoding lane per lane_values call (policy.rs:663) and resize_prefill still prices uncached (policy.rs:1993-1999), neither disclosed.

Verified sound: forecast_tokens algebra (rounds.rs:1017-1019) makes the tokens<=1/width<=1 returns exact; powf(p,1.0)==p makes the alpha fast path (rounds.rs:638-640) bit-identical; the packed limit <= 1 { continue; } (rounds.rs:892-894) drops no ranking entry; one cache per &self pass cannot go stale and slot indices are bounded by REQUEST_LANES.

Open: whether shieldstar (#547's author, whose patch this reimplements) endorses it — no comment and no credit; whether the 21-workload simulator run satisfies docs/design-review.md:195-203, which asks for the learning.py (not opened)/64-seed catalog; and the re-added counter's rationale.

Full report · Notes

Final review

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

Full report

Classify triage

Selected: triage: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. decide malicious: all_clear (100%): No malicious content found

explore

Author: jcartu (CONTRIBUTOR; Discord jcartu) Motivation: When the scheduler prices a possible batch shape it recomputes each decoding lane's speculative "survival curve", and a single planning pass can price the same lane many times — wasted CPU on the worker thread that is not polling the GPU. The PR caches each lane's curve once per pass, so scoring is identical but less work. Scale: +562 / −68 lines in 4 files Proposal:

Full report · Notes

Classify intake

Selected: triage:review, performance, area:scheduling

Threshold: 65%

Triage

Priority

Type

Area

Model

Apply Labels (Intake)

No label changes

Subtraction and simplicity

Subtraction/simplicity lens on PR #693 (head 000a6ac8). The diff is materially leaner than the version the posted review saw — the Option<&mut CurveCache> wrappers, duplicated mixed_catalog loop, stack fallback cache and mislabelled CurveCache::new(false) are genuinely gone, verified in code. What remains is duplication around the new abstraction, not bloat.

Findings, high value first:

  1. F1 (high) — adaptive_verification_alpha == 1.0 identity written four times in rounds.rs: :571-577, :599-605, :645-656 (all three new in this PR) and the pre-existing :882-885. One fn powered(&self, p: f64) -> f64 helper collapses all four, ~−15 lines.
  2. F2 (high) — the PR adds a curve cache but leaves three hand-rolled/uncached rebuild sites: service.rs:322/337 and service.rs:352/386-387 (let mut curve = None; + get_or_insert_with), and the inline uncached expansion at policy.rs:1999-2007 in resize_prefill. Replacing them with CurveCache::new(false) + cached_expected_tokens / cached_lane_value is shorter than today's code and would close three of the four gaps the description discloses as limitations.
  3. F3 (med) — width <= 1 ⇒ f64::from(width != 0) stated three times, though forecast_tokens (rounds.rs:1027-1030) already yields it by construction; new copies at rounds.rs:637-642 and policy.rs:1389-1398.
  4. F4 (med) — test-only CURVE_EVALUATIONS thread-local (rounds.rs:10-14, increment at :646-647 inside the optimized function) plus three count-only tests and CurveCache::is_cached; the bit-exactness parity test (policy_tests.rs:9568-9804) needs none of it. AGENTS.md:194-199.
  5. F6 (low) — cached_lane_value (policy.rs:1436-1446) is a one-line forwarder supplying a literal 0; F5 (mode passed twice) is recommended to stay because the debug_assert_eq! caught a real bug.

Positives: main's local [Option<Vec<f64>>; REQUEST_LANES] cache deleted; ignored duration_ns arguments dropped via prefill_lane_value.

Open: are F2's sites deliberately excluded (no reason given)? Does the performance label stay? No CI on the head; baseline c513e46a unreadable in this checkout.

Full report · Notes

Correctness and contracts

Correctness/contracts review of #693 @ 000a6ac8: no correctness defect found in the caching refactor itself. Every substitution I traced is an exact identity, and the change is pure &self pricing — no locks, I/O, threads, unsafe, wire/protobuf, captured-graph, config-default or sampled-span changes.

Findings that stand:

  1. Major — charter #210 / docs/design-review.md:106-115 rule 12 (served-workload evidence) unmet while the PR keeps the performance label and still opens on the inherited pow@@GLIBC_2.29 5.48% sample that #547 says cannot be attributed to this path.
  2. Major — Layer 2 simulator obligation (docs/design-review.md:195-206, learning.py (not opened) screening + 64-seed catalog) unmet; only eight pytest suites (837 tests) were run.
  3. Major — the "at most one curve per lane" claim is unobservable for two real configurations: with speculative_fixed_width set the packed path bypasses CurveCache/powered_curve entirely (rounds.rs:874-892), and the GPU-allocation path calls speculative_curve directly (rounds.rs:566-577, 599-605); CURVE_EVALUATIONS only increments inside powered_curve (rounds.rs:646-647). The scope note names only lane_values() and resize_prefill.
  4. Minor — the optimistic mode guard is debug_assert_eq! (policy.rs:119-122), compiled out in release, while cached_lane_value_for_tokens_within hardcodes false at policy.rs:1506; a future optimistic leak would silently mis-price.
  5. Minor — CURVE_EVALUATIONS re-adds what a #540 review asked to delete (rounds.rs:10-14), now with no stated rationale beyond these four tests.

Open: whether CI will ever run on 000a6ac8; who closes #547 and whether shieldstar endorses; whether the performance label should stay.

Full report · Notes

Re-review

Recommendation: Ready To Merge

Commit 000a6ac cleanly resolves all four Should Fix findings, the Subtract / Simplify wrapper/loop collapse, and the Nits from the previous review on a9f7dd7: @shieldstar (#547) is properly credited, the unreproducible pre-rebase CPU speedup table is removed in favor of an honest behavior-preserving framing with #547's profile caveat and explicit scope note, mixed_candidates now constructs CurveCache::new(optimistic) and routes optimistic decoders through cached_expected_tokens(..., true, curves), and next_progress / lane-value helpers now take &mut CurveCache directly with no local stack fallback or duplicated mixed_catalog loop. Every substitution (tokens <= 1, width <= 1, limit <= 1, adaptive_verification_alpha == 1.0, prefill_lane_value, and resize_prefill) is a verified bit-exact identity with no concurrency, memory, or hot-path regressions; ensure CI passes on 000a6ac before merging since all reported Layer 1/2/3 runs are currently self-reported.

Merge Risk

Level: Low

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

None.

Subtract / Simplify

Nits

Dropped on verification

Full report

Classify triage

Selected: triage:review

Threshold: 65%

Triage

Apply labels

No label changes Decision to Test: no (65%): 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.