Skip to content

helios/scheduler: cache per-lane powered survival curves across candidate pricing - #693

Merged
lukealonso merged 1 commit into
NVIDIA:mainfrom
jcartu:perf/scheduler-cache-lane-curves
Dec 4, 2026
Merged

lukealonso merged 1 commit into
NVIDIA:mainfrom
jcartu:perf/scheduler-cache-lane-curves

Conversation

@jcartu

@jcartu jcartu commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #547

Based on the diagnosis, patch design, and bounded-evaluation tests by @shieldstar (Discord: shieldstarx) in #547.

Why

During a single RequestScheduler::candidates or RequestScheduler::acceptance_probe pass, request state and speculative forecasts remain immutable (&self), yet candidate pricing previously rebuilt each decoding lane's powered survival curve (powered_curve) on every priced shape:

  • Waiting maintenance steps (Init, Restore, Snapshot, Vision) evaluated lane_value for every decoding lane across every continuation shape in continuation_candidate, and next_progress built separate curve and mixed_curve locals for each maintenance batch capacity.
  • mixed_candidates rebuilt each decoding lane's curve on every mixed shape in mixed_catalog, and acceptance_probe built optimistic curves separately in packed_round_candidates and mixed_candidates.
  • Non-speculative Decode pricing built curves for 1-token lanes even though a lane of width 0 or 1 always has expected tokens equal to f64::from(tokens != 0).
  • powered_curve, prefix_lengths_with_values, and host_prefix_ranking evaluated f64::powf(p, alpha) for every survival entry even at the default adaptive_verification_alpha == 1.0, where finite survival probabilities in [0.0, 1.0] satisfy p.powf(1.0) == p.

In #547, pow@@GLIBC_2.29 appeared at 5.48% of samples on the flare-model worker thread while serving DeepSeek-V4.1-Flash with MTP at alpha == 1.0 on a GB300 host. As noted in #547, that sample came from a stripped binary on a downstream tree without a call graph, so it does not separate powered_curve from the scheduler's other powf call sites. Because candidates and acceptance_probe borrow &self without mutating slot or forecast state, each slot's powered survival curve can be computed once per pricing pass and reused across all priced shapes without changing any candidate score or scheduling decision.

What changed

  • Added a pass-scoped CurveCache struct in helios/src/scheduler/policy.rs wrapping [Option<Vec<f64>>; REQUEST_LANES] and an optimistic: bool mode tag checked by debug_assert_eq! so ordinary and optimistic curves cannot mix in one cache.
  • Allocated one ordinary CurveCache in RequestScheduler::candidates and threaded &mut CurveCache through mixed_candidates_with_curves, packed_round_candidates_with_curves, add_candidate, continuation_candidate, prerequisite_value, and next_progress (replacing next_progress's separate curve and mixed_curve locals, and allocating a per-call cache in test helper phase_plan).
  • Replaced uncached lane_value, lane_value_within, and lane_value_for_tokens with prefill_lane_value (for prefill-only callers), cached_expected_tokens (taking optimistic: bool and &mut CurveCache, returning f64::from(tokens != 0) when tokens <= 1), cached_lane_value, cached_lane_value_within, and cached_lane_value_for_tokens_within, while retaining #[cfg(test)] lane_value_for_tokens_within for existing unit tests and expected_speculative_tokens for submitted-step accounting (helios/src/scheduler.rs) and resize_prefill.
  • Updated RequestScheduler::acceptance_probe in helios/src/scheduler/learning.rs to allocate one optimistic CurveCache::new(true) shared across packed_round_candidates_with_curves and mixed_candidates_with_curves, and gated standalone mixed_candidates, packed_round_candidates, and optimistic_tokens under #[cfg(test)].
  • In helios/src/scheduler/rounds.rs:
    • Short-circuited width <= 1 in proposal_forecast_tokens (used by expected_speculative_tokens and #[cfg(test)] optimistic_tokens) and limit <= 1 in packed_round_candidates_with_curves.
    • Added the adaptive_verification_alpha == 1.0 fast path to powered_curve (avoiding a redundant Vec<f64> allocation), prefix_lengths_with_values, and host_prefix_ranking.
  • Added a test-only thread-local CURVE_EVALUATIONS counter in helios/src/scheduler/rounds.rs and four unit tests in helios/src/scheduler/policy_tests.rs.

Claimed result

Behavior-preserving curve-evaluation deduplication refactor. Within a candidates() pass (ordinary mode) or an acceptance_probe() pass (optimistic mode), powered survival curve evaluations are bounded to at most one per eligible lane priced for speculative decoding (active decoding lanes and non-terminal prompt-endpoint Snapshot lanes resuming into Decode) whose speculative width exceeds 1, and zero for non-speculative Decode passes and 1-token lanes, while preserving bit-identical lane values, candidate scores, and scheduling decisions for finite survival probabilities in [0.0, 1.0].

Scope note: outside candidates() and acceptance_probe(), select_plan() still evaluates per-lane curves in lane_values() (service_rates in helios/src/scheduler/service.rs and coalescing_prefill_log_bonus in helios/src/scheduler/policy.rs) and on resize_prefill (helios/src/scheduler/policy.rs). No standalone GPU serving latency or throughput improvement is claimed from this change.

Supporting evidence and limitations

Verified on head ddf3be86 over origin/main (f705086b) on Linux x86_64 CPU:

  • Layer 1 (Rust crate tests & clippy):
    • cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server (with frontend templates prepared via tests/frontend/prepare_templates.py): 1918 library and 62 integration tests passed, 0 failed (86 ignored: 49 lib, 37 integration), including:
      • waiting_init_prices_each_decoding_lane_curve_once_per_candidate_pass
      • mixed_candidates_price_each_decoding_lane_curve_once_per_call (ordinary and optimistic)
      • decode_only_candidate_pass_builds_no_forecast_curve
      • cached_lane_pricing_matches_uncached_for_unit_and_fractional_alpha (checks bit-identical score.to_bits() parity against uncached speculative_curve + powf(alpha) and optimistic_tokens at alpha = 1.0 and alpha = 0.6, covering widths 0, 1, 2, 4, 8, a 1-remaining-token lane, waiting Init, ordinary and optimistic Mixed, packed Speculative, shared optimistic CurveCache reuse in acceptance_probe, tie-breaking between identical decoding lanes, and selected plan() winners)
    • Debug-mode run of the four new scheduler tests (cargo test --locked --manifest-path helios/Cargo.toml --lib ...): 4 passed, 0 failed with CurveCache debug_assert_eq! enabled.
    • cargo clippy --locked --manifest-path helios/Cargo.toml --features runtime-core,server --lib --tests: 0 warnings on modified scheduler code.
    • cargo test --locked --release --manifest-path flare/Cargo.toml: 247 library and 8 integration tests passed, 0 failed (4 ignored).
    • cargo test --locked --release --manifest-path flare-cli/Cargo.toml: 224 unit and 26 integration tests passed, 0 failed (3 ignored).
  • Layer 2 (Python scheduling simulator):
    • pytest over tests/test_scheduling_sim.py, tests/test_scheduling_oracle.py, tests/test_scheduling_utility.py, tests/test_scheduling_continuation.py, tests/test_scheduling_timing.py, tests/test_scheduling_learning_policy.py, tests/test_scheduling_learning_run.py, and tests/test_scheduling_learning_experiments.py: 837 passed, 0 failed.
  • Layer 3 (Formal lifecycle verification):
    • python3 verification/helios-lifecycle/check.py (TLC2 2.19): all TLA+ models, all 9 Rust trace-conformance suites, and all 12 guard tests passed.
  • Limitations:
    • No standalone GPU serving benchmark on an exported core was run, and no checked-in CPU benchmark harness is included.
    • Kani sequential proofs were not run because cargo-kani is not installed on the test host (existing Kani harnesses do not cover helios/src/scheduler/).

Discord: jcartu

@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 693.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot flare-autobot added area:scheduling Request scheduling, fairness, batching, and speculative-width selection. performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness. labels Dec 2, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

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. Four issues should be addressed first: missing contributor attribution to @shieldstar (who published this design and patch in #547), performance-claim and CI evidence gaps against docs/design-review.md rules 12 and 16, a mismatched CurveCache::new(false) mode tag in mixed_candidates, and an avoidable next_progress restructure that unconditionally builds a 1,544-byte stack CurveCache on every speculative call.

  • Blockers: 0 · Should fix: 4 · Subtract/Simplify: 2 · Nits: 3
Walkthrough
  • helios/src/scheduler/policy.rs: Adds CurveCache (:98-130) wrapping [Option<Vec<f64>>; REQUEST_LANES] plus an optimistic: bool debug_assert_eq! guard; creates one pass-scoped cache in candidates (:1642) shared across mixed_candidates_with_curves, packed_round_candidates_with_curves, add_candidate, continuation_candidate, prerequisite_value, and next_progress (and a per-call cache in mixed_candidates and #[cfg(test)] phase_plan); adds cached_expected_tokens (:1387-1404) with a tokens <= 1 short-circuit and cached_lane_value* wrappers (:1425-1524); restructures next_progress (:896-1013) around a local fallback CurveCache.
  • helios/src/scheduler/rounds.rs: Short-circuits width <= 1 in proposal_forecast_tokens (:626-631) and adaptive_verification_alpha == 1.0 in powered_curve (:634-645); adds #[cfg(test)] thread-local CURVE_EVALUATIONS (:10-14, :635-636); splits packed_round_candidates_with_curves (:842-850) to accept a shared CurveCache and skips limit <= 1 lanes (:892-894).
  • helios/src/scheduler/policy_tests.rs: Adds three CURVE_EVALUATIONS call-count tests (:9488-9564) and one exact-equality test (cached_lane_pricing_matches_uncached_for_unit_and_fractional_alpha, :9566-9780) checking score.to_bits() parity at alpha = 1.0 and 0.6, widths 0..=8, 1-remaining-token lanes, waiting Init, Mixed, packed Speculative, tie-breaking, optimistic probes, and plan() winners.
Merge Risk: Low · up to a9f7dd7
  • Changes are confined to pure &self scheduler candidate pricing in helios/src/scheduler/{policy,rounds}.rs (plus unit tests); no locks, I/O, channels, unsafe, wire/protobuf schemas, captured-graph contracts, exported-core formats, or config defaults change (adaptive_verification_alpha remains 1.0 at helios/src/scheduler/policy.rs:41).
  • Both width short-circuits (policy.rs:1393-1395, rounds.rs:627-629, rounds.rs:892-894) and the alpha == 1.0 fast path (rounds.rs:638-640) are exact identities of forecast_tokens (rounds.rs:1017-1019) and f64::powf(p, 1.0), and CurveCache indexing (r.handle.slot as usize into [Option<Vec<f64>>; REQUEST_LANES] with REQUEST_LANES == 64 at helios/src/execution/manifest.rs:18) matches existing per-slot arrays.
  • Main operational caveats are the absence of CI checks on head a9f7dd7 and heavy churn in policy.rs / policy_tests.rs (textually overlapping open PRs #571, #621, #334, #306).
Pre-merge checks: ✅ 1 passed · ⚠️ 3 warnings

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

@jcartu
jcartu force-pushed the perf/scheduler-cache-lane-curves branch from a9f7dd7 to 000a6ac Compare December 2, 2026 22:49
@jcartu jcartu changed the title perf(scheduler): cache per-lane powered survival curves across candidate pricing helios/scheduler: cache per-lane powered survival curves across candidate pricing Dec 2, 2026
@jcartu

jcartu commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

@flare-autobot Addressed all review findings in 000a6ac8:

  • Should Fix Congratulations! #1 (Attribution): Added explicit attribution to @shieldstar (Discord: shieldstarx) for the #547 diagnosis, patch design, and bounded-evaluation tests in both the commit message and PR description.
  • Should Fix flare run fails at "Prepare execution": cuGraphAddKernelNode_v2 CUDA_ERROR_INVALID_VALUE (qwen3.8-flash TP2, RTX PRO 5000 Blackwell 48 GB) #2 (Honest framing & scope): Reframed the commit and PR description as a behavior-preserving curve-evaluation deduplication refactor, removed the pre-rebase CPU speedup table, added #547's stripped-binary / no-call-graph caveat on the 5.48% pow@@GLIBC_2.29 sample, and explicitly scoped the per-lane bound to candidates() / mixed_candidates / packed_round_candidates (noting lane_values() and resize_prefill remain outside candidates()).
  • Should Fix Message prefix checkpoint skipped at a conditioned window boundary #3 (mixed_candidates optimistic mode): Updated mixed_candidates to construct CurveCache::new(optimistic) and routed the optimistic decoder branch in mixed_candidates_with_curves through cached_expected_tokens(r, tokens, true, curves), with tests checking both the evaluation bound and bit-identical score.to_bits() parity against uncached optimistic_tokens (including in debug mode with debug_assert_eq! active).
  • Should Fix Vision cost estimate drops a following window's first patch #4 + Subtract/Simplify Congratulations! #1 (next_progress & lane-value wrappers): Changed prerequisite_value, next_progress, cached_expected_tokens, and cached_lane_value_for_tokens_within to take &mut CurveCache directly, removed the unconditional stack local_curves and duplicated mixed_catalog loop in next_progress, extracted prefill_lane_value for prefill-only callers, and removed the redundant Option<&mut CurveCache> wrappers (retaining #[cfg(test)] lane_value_for_tokens_within for existing tests and expected_speculative_tokens for submitted-step accounting and resize_prefill).
  • Nits: Added the adaptive_verification_alpha == 1.0 fast path to prefix_lengths_with_values and host_prefix_ranking in helios/src/scheduler/rounds.rs, and routed #[cfg(test)] optimistic_tokens in helios/src/scheduler/learning.rs through proposal_forecast_tokens(request, width, true).

Re-verified on 000a6ac8 (Linux x86_64 CPU):

  • Layer 1: helios (--features runtime-core,server) 1839 lib + 62 integration passed (84 ignored) + 4 new tests passed in debug mode; flare 246 lib + 8 integration passed (4 ignored); flare-cli 219 unit + 26 integration passed (3 ignored).
  • Layer 2: pytest scheduling simulator suite 837 passed.
  • Layer 3: verification/helios-lifecycle/check.py (TLC2 2.19) passed all TLA+ models, all 8 Rust trace-conformance suites, and all 12 guard tests.

@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Ready To Merge

Commit 000a6ac cleanly resolves all four Should Fix findings, the Subtract / Simplify wrapper/loop collapse, and the Nits from the prior review on a9f7dd7. Every substitution (tokens <= 1, width <= 1, limit <= 1, adaptive_verification_alpha == 1.0, prefill_lane_value, resize_prefill) is a verified bit-exact identity with no concurrency, memory, or hot-path regressions — just ensure CI passes on 000a6ac, since all Layer 1/2/3 runs are currently self-reported.

  • Blockers: 0 · Should fix: 0 · Subtract/Simplify: 1 · Nits: 2
Walkthrough
  • helios/src/scheduler/policy.rs: Adds pass-scoped CurveCache (:100-130) with an optimistic: bool debug_assert_eq! guard; allocates one ordinary cache in candidates (:1633) shared across mixed_candidates_with_curves, packed_round_candidates_with_curves, add_candidate, continuation_candidate, prerequisite_value, and next_progress (plus a per-call cache in mixed_candidates at :1705 and #[cfg(test)] phase_plan at :2126). Extracts prefill_lane_value (:1407-1434), adds cached_expected_tokens (:1389-1405, short-circuiting tokens <= 1) and cached_lane_value* (:1436-1515), updates mixed_candidates_with_curves (:1760-1775) to reuse the mode-matched cache for ordinary and optimistic decoders, and keeps resize_prefill (:1997-2008) equivalent via prefill_lane_value and expected_speculative_tokens.
  • helios/src/scheduler/rounds.rs: Adds #[cfg(test)] thread-local CURVE_EVALUATIONS (:10-14, :646-647, following cost::ENTRY_LOOKUPS at cost.rs:15-19); adds width <= 1 short-circuit to proposal_forecast_tokens (:637-642) and adaptive_verification_alpha == 1.0 fast paths to powered_curve (:645-656), prefix_lengths_with_values (:571-576), and host_prefix_ranking (:599-605); threads &mut CurveCache into packed_round_candidates_with_curves (:860-906) and skips limit <= 1 lanes (:903-905).
  • helios/src/scheduler/learning.rs: Marks optimistic_tokens #[cfg(test)] and routes it through proposal_forecast_tokens(request, width, true) (:11-14).
  • helios/src/scheduler/policy_tests.rs: Adds three thread-isolated call-count tests (:9489-9566) and one bit-exactness parity test (cached_lane_pricing_matches_uncached_for_unit_and_fractional_alpha, :9569-9803) exercising score.to_bits() parity across alpha = 1.0 and 0.6, widths 0..=8, 1-remaining-token lanes, waiting Init, ordinary and optimistic Mixed, packed Speculative, tie-breaking, and plan() selection.
Merge Risk: Low · up to 000a6ac
  • Pure &self arithmetic deduplication confined to helios/src/scheduler/{policy,rounds,learning,policy_tests}.rs; introduces no locks, channels, I/O, unsafe, wire/protobuf changes, captured-graph op contracts, exported-core format changes, or config default changes (adaptive_verification_alpha remains 1.0 at policy.rs:41).
  • CurveCache (policy.rs:100-130, [Option<Vec<f64>>; REQUEST_LANES] with REQUEST_LANES == 64 at helios/src/execution/manifest.rs:18, ~1,544 bytes) is stack-scoped per pricing pass (matching the stack array previously allocated in packed_round_candidates), cannot retain stale state across passes, and strictly reduces per-pass Vec<f64> allocations and powf calls while preserving score.to_bits() parity.
  • Main operational caveats: zero CI checks have run on head 000a6ac yet, and policy.rs / policy_tests.rs overlap textually with open PRs #571, #621, #334, and #306.
Pre-merge checks: ✅ 3 passed · ⚠️ 2 warnings
  • ✅ Security / malicious screen: Pure arithmetic memoization with no unsafe, external input handling, or prompt-injection content in the PR description or comments.
  • ✅ Charter & value fit: Right model-agnostic Helios scheduling layer, credits @shieldstar (#547), withdraws the unsupported speedup claim, and discloses profile caveats and out-of-scope call sites per docs/design-review.md:106-115, 147-162 (maintainers can optionally remove the performance label if desired).
  • ⚠️ Related / duplicate / conflict check: Additive over #188 and #540 and fixes #547 with credit, but touches high-churn files shared by open PRs #571, #621, #334, and #306.
  • ⚠️ Tests & verification evidence: All four new tests exercise real RequestScheduler paths and reset thread-local CURVE_EVALUATIONS per call (thread-isolated, order-independent), and the PR reports full Layer 1 (--release + debug), Layer 2 (837 simulator pytest cases), and Layer 3 (TLC2 lifecycle conformance) runs; however, zero CI checks have run on head 000a6ac yet.

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

…date pricing

Fixes NVIDIA#547

Based on the diagnosis, patch design, and bounded-evaluation tests by
@shieldstar (Discord: shieldstarx) in NVIDIA#547.

Why:
During a single `RequestScheduler::candidates` or
`RequestScheduler::acceptance_probe` pass, request state and speculative
forecasts remain immutable (`&self`), yet candidate pricing previously
rebuilt each decoding lane's powered survival curve (`powered_curve`) on
every priced shape: waiting maintenance steps (`Init`, `Restore`,
`Snapshot`, `Vision`) called `lane_value` per decoding lane across every
continuation shape and rebuilt separate `curve` and `mixed_curve` locals
in `next_progress` for each maintenance batch capacity; `mixed_candidates`
rebuilt each decoding lane's curve on every mixed shape;
`acceptance_probe` built optimistic curves separately in
`packed_round_candidates` and `mixed_candidates`; non-speculative `Decode`
pricing built unused curves for 1-token lanes; and `powered_curve`,
`prefix_lengths_with_values`, and `host_prefix_ranking` evaluated
`f64::powf(p, alpha)` even at the default exponent
`adaptive_verification_alpha == 1.0`. In NVIDIA#547, `pow@@GLIBC_2.29` appeared
at 5.48% of samples on the `flare-model` worker thread while serving
DeepSeek-V4.1-Flash with MTP at `alpha == 1.0` on a GB300 host; as noted
in NVIDIA#547, that sample came from a stripped binary on a downstream tree
without a call graph, so it does not separate `powered_curve` from other
`powf` call sites. Caching each slot's powered survival curve for the
duration of a pricing pass and short-circuiting unit widths and unit
exponents deduplicates these evaluations without altering any candidate
score or scheduling decision.

What changed:
- Added `CurveCache` in `helios/src/scheduler/policy.rs`, wrapping
  `[Option<Vec<f64>>; REQUEST_LANES]` with an `optimistic: bool` mode tag
  checked by `debug_assert_eq!` so ordinary and optimistic survival curves
  cannot mix in one cache.
- Allocated one ordinary `CurveCache` in `RequestScheduler::candidates`
  and threaded `&mut CurveCache` through `mixed_candidates_with_curves`,
  `packed_round_candidates_with_curves`, `add_candidate`,
  `continuation_candidate`, `prerequisite_value`, and `next_progress`
  (replacing `next_progress`'s separate `curve` and `mixed_curve` locals,
  and allocating a per-call cache in test helper `phase_plan`).
- Replaced uncached `lane_value`, `lane_value_within`, and
  `lane_value_for_tokens` with `prefill_lane_value` for prefill-only
  callers, `cached_expected_tokens` (taking `optimistic: bool` and
  `&mut CurveCache`, returning `f64::from(tokens != 0)` when
  `tokens <= 1`), `cached_lane_value`, `cached_lane_value_within`, and
  `cached_lane_value_for_tokens_within` (retaining `#[cfg(test)]
  lane_value_for_tokens_within` for existing tests and
  `expected_speculative_tokens` for submitted-step accounting in
  `helios/src/scheduler.rs` and `resize_prefill`).
- Updated `RequestScheduler::acceptance_probe` in
  `helios/src/scheduler/learning.rs` to allocate one optimistic
  `CurveCache::new(true)` and share it across
  `packed_round_candidates_with_curves` and
  `mixed_candidates_with_curves`; gated standalone `mixed_candidates`,
  `packed_round_candidates`, and `optimistic_tokens` under `#[cfg(test)]`.
- In `helios/src/scheduler/rounds.rs`, short-circuited `width <= 1` in
  `proposal_forecast_tokens` (used by `expected_speculative_tokens` and
  `#[cfg(test)] optimistic_tokens`) and `limit <= 1` in
  `packed_round_candidates_with_curves`, and added the `alpha == 1.0` fast
  path to `powered_curve` (avoiding a second `Vec<f64>` allocation),
  `prefix_lengths_with_values`, and `host_prefix_ranking`.
- Added a test-only thread-local `CURVE_EVALUATIONS` counter in
  `helios/src/scheduler/rounds.rs` and four unit tests in
  `helios/src/scheduler/policy_tests.rs` checking evaluation bounds
  (including `candidates`, ordinary and optimistic `mixed_candidates`,
  optimistic `packed_round_candidates`, and `acceptance_probe`) and
  bit-identical lane values, candidate scores, and plans against uncached
  `speculative_curve` + `powf(alpha)` at `alpha = 1.0` and `0.6`.

Claimed result:
Behavior-preserving curve-evaluation deduplication refactor. Within a
`candidates()` pass (ordinary mode) or an `acceptance_probe()` pass
(optimistic mode), powered survival curve evaluations are bounded to at
most one per eligible lane priced for speculative decoding (active
decoding lanes and non-terminal prompt-endpoint `Snapshot` lanes resuming
into `Decode`) whose speculative width exceeds 1, and zero for
non-speculative `Decode` passes and 1-token lanes, while preserving
bit-identical lane values, candidate scores, and scheduling decisions for
finite survival probabilities in `[0.0, 1.0]`. Outside `candidates()` and
`acceptance_probe()`, `select_plan()` still evaluates per-lane curves in
`lane_values()` (`service_rates` in `helios/src/scheduler/service.rs` and
`coalescing_prefill_log_bonus` in `helios/src/scheduler/policy.rs`) and on
`resize_prefill` (`helios/src/scheduler/policy.rs`). No standalone GPU
serving latency or throughput improvement is claimed.

Supporting evidence and limitations (Linux x86_64 CPU, rebased on `origin/main` `f705086b`):
- `cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server`
  (with frontend templates prepared via `tests/frontend/prepare_templates.py`):
  1918 library and 62 integration tests passed, 0 failed (86 ignored: 49
  lib, 37 integration), plus the 4 new scheduler tests passed in debug
  mode with `CurveCache` `debug_assert_eq!` enabled.
- `cargo clippy --locked --manifest-path helios/Cargo.toml --features runtime-core,server --lib --tests`:
  0 warnings on modified scheduler code.
- `cargo test --locked --release --manifest-path flare/Cargo.toml`:
  247 library and 8 integration tests passed, 0 failed (4 ignored).
- `cargo test --locked --release --manifest-path flare-cli/Cargo.toml`:
  224 unit and 26 integration tests passed, 0 failed (3 ignored).
- Scheduling simulator (`pytest` over `tests/test_scheduling_sim.py`,
  `test_scheduling_oracle.py`, `test_scheduling_utility.py`,
  `test_scheduling_continuation.py`, `test_scheduling_timing.py`,
  `test_scheduling_learning_policy.py`, `test_scheduling_learning_run.py`,
  and `test_scheduling_learning_experiments.py`): 837 passed, 0 failed.
- Formal lifecycle verification (`python3 verification/helios-lifecycle/check.py`,
  TLC2 2.19): all TLA+ models, all 9 Rust trace-conformance suites, and
  all 12 guard tests passed.
- Limitations: no standalone GPU serving benchmark on an exported core was
  run, no checked-in CPU microbenchmark harness is included, and Kani
  sequential proofs were not run (`cargo-kani` is not installed on the
  test host; existing Kani harnesses do not cover `helios/src/scheduler/`).

Signed-off-by: Joshua Cartu <jcartu@users.noreply.github.com>
Signed-off-by: Luke Alonso <lalonso@gmail.com>
Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
@lukealonso
lukealonso force-pushed the perf/scheduler-cache-lane-curves branch from 000a6ac to ddf3be8 Compare December 4, 2026 23:48
@lukealonso
lukealonso merged commit 524aa31 into NVIDIA:main Dec 4, 2026
lukealonso added a commit that referenced this pull request Dec 5, 2026
Why:
Upstream `main` (`be4092d7`) introduced per-lane survival-curve caching
(`CurveCache` and `prefill_lane_value`, #693) and core-parameter admission
validation (`plan_admission_with_core_parameters` without an explicit
definition slice, #621), conflicting with this branch in `policy.rs`,
`policy_tests.rs`, and `runtime.rs`. Separately, in `PrefillCostModel::fit`
(`helios/src/scheduler/cost.rs`), treating `pos_u_max == 0.0` as
`wide_or_full_positive` caused a `GraphKind::Mixed` model that had observed
only `zero_fill` (`work == 0`) samples to emit `constant_nanos =
Some(decode_ns)`, under-pricing full-chunk prefills and inflating
`service_rates` until a positive-fill step ran.

What changed:
- `helios/src/scheduler/cost.rs`, `docs/scheduling-runtime-design.md`:
  removed `pos_u_max == 0.0` from `wide_or_full_positive` so a
  `zero_fill`-only model never emits `constant_nanos`; added
  `PrefillPredictor::has_positive_fill()`; returned `0` (unmeasured) from
  `PrefillPredictor::predict(work > 0, _)` and `full_chunk_affine()` when
  `pos_u_max <= 0.0`; gated `with_borrowed_context_slope` on
  `pos_u_max > 0.0`; retained positive `decode_ns` in `Estimate::nanos`
  from `PrefillCostModel::observe` when only `zero_fill` samples exist; and
  added unit coverage in `cost.rs` and `policy_tests.rs`.
- `helios/src/scheduler/{policy.rs,policy_tests.rs}`: resolved conflicts
  against #693 by threading `curves: &mut CurveCache` through
  `add_candidate`'s `eval_mixed` and `mixed_candidates_with_curves`'s
  `score_decoders`, switching prefill scoring to `prefill_lane_value`,
  gating oversized unmeasured-prefill pruning on `!has_positive_fill()`,
  and retaining both test suites.
- `helios/src/server/runtime.rs`: resolved the #621 admission-plan conflict
  in `begin_pool_lookup` using `incoming.spec(false)` with the two-argument
  `plan_admission_with_core_parameters` signature.

Claimed benefit and result:
PR #729 merges cleanly onto `origin/main` (`be4092d7`) while preserving
#693's per-lane `CurveCache` reuse across `GraphKind::Mixed` candidates,
and a `zero_fill`-only `GraphKind::Mixed` entry accurately prices
decode-only steps (`work == 0`) without under-pricing positive-fill chunks
or inflating prefill `service_rates` (verified by
`zero_fill_only_mixed_model_does_not_inflate_prefill_service_rates` and
`mixed_cost_model_tracks_zero_fill_partial_fill_deep_context_and_peer_slope`).

Supporting evidence:
- `python3 verification/helios-lifecycle/check.py --mutations`: 10/10 TLA+
  models passed, 623,976 observed Rust transitions verified (3,865 against
  `Lifecycle.tla`, 431 against `AsyncTransfer.tla`), and 60/60 mutations
  detected (19 TLA+, 41 Rust).
- Rust release test suites: `helios --lib` 1,966 passed (49 ignored; 6 HF
  template tests require `prepare_templates.py` downloads), `helios --test
  '*'` 59 passed (39 checkpoint-gated ignored; 3 Gemma template tests
  require downloads), `flare` 255 passed (4 ignored), `flare-cli` 254
  passed (3 ignored), and 4/4 live SM120 GPU KV codec tests on idle GPU 5.
- Python pytest (`CUDA_VISIBLE_DEVICES=3 FLARE_RUN_CUDA_TESTS=1`): 1,120
  passed (`tests/test_scheduling_*.py`, `tests/test_design_review_hook.py`,
  `tests/cli`, `tests/direct/test_scheduler.py`, `tests/test_kv_codec.py`).
- Unrun locally: `cargo-kani` (running in CI) and the 9 HF chat-template
  tests requiring `prepare_templates.py` downloads.

Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b
Signed-off-by: Luke Alonso <lalonso@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:scheduling Request scheduling, fairness, batching, and speculative-width selection. performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scheduler: candidate pricing rebuilds each decoding lane's speculative curve for every shape it prices

3 participants