Repository navigation
helios: preserve KV across grammar transitions, fix KV codec batching/locking, and stratify Mixed graph costs - #729
Conversation
…/locking, and stratify Mixed graph costs
Three Helios runtime paths discard live GPU state, disable batched GPU
offload restores, or misprice mixed prefill-and-decode graphs:
1. Structured-output reasoning transitions (`</think>` close and
`allow_reasoning_reentry`) previously routed every transition through
`park_with_tokens(..., publish_terminal: false)` -> `scheduler.cancel(handle)`,
which invokes `retire(handle, false)` without publishing a terminal
checkpoint. Every transition therefore discarded all live KV and recurrent
state and forced full prompt-plus-reasoning re-prefill, even when zero
speculative overshoot occurred (`skipped == 0`). Non-speculative models also
set `grammar_constrained = false` during reasoning, enabling two-frame
pipelining for zero speculative width gain while guaranteeing an in-flight
second frame at `</think>`. Existing prepared cores bind
`ValueSource::GrammarEnabled` only on `Init` and `Restore` graphs, and
speculative verification kernels gate width > 1 on `!grammar_enabled`, so
non-speculative cores can keep device `grammar_enabled = 1` with a cached
all-ones mask and toggle masks in place, speculative cores whose sampling
graphs bind `ValueSource::GrammarEnabled` can toggle both in place when
`pending == 0 && extra == 0`, and speculative cores without per-step
`GrammarEnabled` bindings (or with `pending == 1` or `extra > 0`) can retain
live state by publishing a terminal checkpoint and restoring it.
2. In `helios/src/offload/transfer/codec.rs`, `restore_window` previously
stopped GPU batching on the first `Literal` or CPU-routed page (`else { break; }`),
disabling GPU batching for all subsequent `GpuOnDevice` pages in the window.
In `capture_window`, background capture threads previously locked `gpu.codec`
before waiting on `CopyEngineGate::enter_offload_batch()`, holding the codec
mutex while blocked on active peer-copy graphs and forcing foreground
restores calling `try_lock()` onto CPU decoding (and creating a lock-order
inversion if capture and restore acquired the gate and mutex in opposite
orders).
3. In `helios/src/scheduler/cost.rs`, stratified `(fill, kv_context)` NNLS
pricing applied only to pure prefill graphs while `GraphKind::Mixed` stayed
on a single nine-sample median, allowing decode-only or short-tail mixed
steps to distort full-chunk and deep-context mixed pricing.
Changes:
- Grammar transitions (`helios/src/model/{admission,packing}.rs`,
`helios/src/scheduler.rs`, `helios/src/scheduler/policy.rs`,
`helios/src/server/runtime.rs`):
- Add `Admission::grammar_enabled` and update `ValueSource::GrammarEnabled`
packing to emit `grammar_enabled || grammar_mask.is_some()`.
- Add `RequestScheduler::{set_grammar_constrained, pause_for_park,
finish_for_park}` and `LiveRequest::{pending, deferred_prefill,
paused_for_park}`. `paused_for_park` excludes a draining request from
scheduling, starvation, reservation refill, and preemption until its
in-flight frame completes.
- Keep `grammar_constrained = true` and initialize `grammar_enabled = true`
with `grammar_mask = None` (cached all-ones) on non-speculative models so
two-frame pipelining is disabled and reasoning transitions toggle
`grammar_mask` in place with zero cancel or re-prefill.
- On speculative models, inspect `PreparedContract` (`ValueSource::GrammarEnabled`
on sampling graphs) to toggle in place when `skipped == 0 && pending == 0
&& extra == 0`. Otherwise, when `skipped == 0`, publish a terminal
checkpoint (`finish_for_park` -> `Snapshot` -> `finish` -> `Restore`, or
`pause_for_park` while a single in-flight frame drains and `consumed_tokens
<= exact_len`) so KV and recurrent state are reused via `Restore` ->
`Prefill(1)` or `Resume`, propagating device errors and falling back to
cancel-and-rollback only on overshoot (`skipped > 0` or `consumed_tokens >
exact_len`). Existing prepared cores remain compatible without re-export.
- KV offload codec (`helios/src/offload/transfer/codec.rs`):
- Replace the single-prefix loop in `restore_window` with
`partition_restore_pages` (`GpuBatch`, `CpuBatch`, `Single`) and
`restore_single_unit` so leading or interleaved `Literal`/CPU/singleton
pages never abort GPU batching for later `GpuOnDevice` runs; avoid
recording CPU transform time on pure-`Literal` batches.
- Route all five GPU codec lock sites (three in `capture_window`, two in
`restore_window`/`restore_single_unit`) through `with_gpu_codec_locked` and
`try_with_gpu_codec_locked`, which always acquire
`CopyEngineGate::enter_offload_batch` before `gpu.codec.lock()`/`try_lock()`.
- Mixed graph cost model (`helios/src/scheduler/{cost,policy,service}.rs`,
`docs/scheduling-runtime-design.md`):
- Enable `PrefillCostModel` for `GraphKind::Mixed` with an additional
`zero_fill` bucket for decode-only steps (`work == 0`), safe fallback to
`t_at_umin` when NNLS clamps `theta_0` to zero, `u_min > 0` gating on
`upward_extrapolation_floor`, and same-`(batch, width)` peer KV-context
slope borrowing.
- Price `GraphKind::Mixed` with live `(work, start_position)` and `(0, 0)`
decode-only durations across `next_progress`, `continuation_candidate`,
`mixed_candidates`, `resize_prefill`, `delivery_references`, and
`service_rates`, and update the cost-model specification in
`docs/scheduling-runtime-design.md`.
Result:
- Expected runtime impact: eliminates 2K-32K KV/recurrent cache wipes across
structured-output reasoning transitions on both non-speculative (in-place
toggle) and speculative (in-place toggle or terminal-checkpoint restore)
models, preserves GPU batching across heterogeneous restore windows without
codec-mutex lock inversion under `CopyEngineGate`, and keeps `MIXED`
scheduler pricing responsive to prompt fill ratio and KV-context depth.
No end-to-end exported-core `flare run` latency benchmark was measured here.
- Verified behavioral results: all new unit and runtime phase tests pass, live
SM120 GPU codec capture/restore and `CopyEngineGate` tests pass, and all TLA+
lifecycle conformance checks pass without invariant violations.
Evidence and limitations:
- Rust crate suites (`--locked --release --target-dir flare-cli/target`, 0
rustc warnings, 0 clippy warnings on modified lines):
- `eos` (12 passed), `selene --features test-support` (585 passed),
`selene-manager --features test-support` (passed), `flare` (255 passed,
4 ignored), `flare-cli` (250 passed, 3 ignored), `helios --features
runtime-core,server --lib` excluding the 6 HF-template tests (1917 passed,
0 failed, 49 ignored), and `helios --features runtime-core,server --test '*'`
with `FLARE_TEST_TEMPLATE_DIR=/tmp/flare-test-templates` (62 passed,
0 failed, 37 ignored).
- Live SM120 GPU codec tests (`CUDA_VISIBLE_DEVICES=2`, compiled
`kv_codec_gpu-sm_120a.cubin`): all 4 `#[ignore]` tests in
`offload::transfer::codec::tests` passed (`cpu_vram_capture_and_restore`,
`gpu_vram_capture_and_restore`, `gated_cpu_and_gpu_codec_capture_and_restore`,
`mixed_cpu_and_gpu_modes`).
- Python suites (`.venv/bin/python -m pytest`):
- `tests/test_scheduling_*.py` and `tests/test_design_review_hook.py`: 855 passed.
- `tests/cli`, `tests/test_kv_codec.py` (with `FLARE_RUN_CUDA_TESTS=1`), and
`tests/direct/test_scheduler.py`: 260 passed.
- Formal lifecycle conformance (`python3 verification/helios-lifecycle/check.py`
with `tla2tools-1.7.4.jar`): all 10 TLA+ models and 9 Rust observed-edge
suites passed (621,749 observed transitions across `Lifecycle`,
`RankProtocol`, `DispatchRing`, `OffloadTransfer`, `CacheOwnership`,
`Speculation`, `ResponseLifecycle`, `CheckpointReservation`, and
`AsyncTransfer`).
- Limitations and unrun checks:
- Six `helios --lib` chat-template tests require templates fetched by
`tests/frontend/prepare_templates.py` (local `/tmp/flare-test-templates`
lacks several entries) and were not run.
- `cargo-kani` is not installed locally; Kani-covered `StateView` and
completion-vector validators were not modified.
- `scripts/scheduling_sim/` models scalar per-graph durations and does not
represent per-fill/per-context NNLS strata; whole-model `flare run` serving
benchmarks with exported cores were not run.
Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b
Signed-off-by: Luke Alonso <lalonso@gmail.com>
|
A case file has been opened for 729. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedThis PR makes genuinely additive, model-agnostic changes with sound core
Walkthrough
Merge Risk: High · up to
|
… cost bounds, and lifecycle verification
Why:
Under page pressure, `RequestScheduler::complete_inner` can preempt the
newest growable decoding request in the same step where that request closes
reasoning with `reasoning_cut.after > 0`. In `Worker::publish`, running
`park_if_preempted` before applying `pending_grammar_park` silently parked
the request in stale open-reasoning mode and dropped its reasoning-cut
budget expansion. In `offload/transfer/codec.rs`, acquiring the blocking
`CopyEngineGate::enter_offload_batch` inside `try_with_gpu_codec_locked`
stalled foreground restores behind active peer-copy graphs instead of
falling back immediately to CPU decode. In `scheduler/cost.rs`, recording a
zero-fill `GraphKind::Mixed` sample set `u_min = 0.0`, disabling the 4x
upward extrapolation floor for narrow positive fills, while barely
sub-linear positive-fill pairs let `predict(0, 0)` extrapolate toward 1 ns.
Finally, `Lifecycle.tla`, its Rust conformance suite, and the mutation
suite did not cover `pause_for_park`, `finish_for_park`, or
`set_grammar_constrained`, and the runtime design docs still described the
pre-change rollback-only behavior.
What changed:
- `helios/src/server/runtime.rs`, `helios/src/scheduler.rs`,
`helios/src/model/{mod,admission,packing}.rs`: ordered `Worker::publish`
to apply `pending_grammar_park` before `park_if_preempted` (and guarded
`park_if_preempted` against overwriting `pending_grammar_park`); unified
`PendingGrammarPark` and `GrammarTransition` into `GrammarPark` backed
by `LiveRequest::paused_for_park()`; extracted `decide_grammar_transition`
and cached `can_toggle_grammar_in_place` on `Worker`; applied
`scheduler.set_grammar_constrained` before mutating request/admission
state; and replaced `Admission::{grammar_mask, grammar_enabled}` with the
three-state `AdmissionGrammar::{Disabled, UnmaskedEnabled, Masked}` enum.
- `helios/src/offload/{copy_gate.rs,transfer/codec.rs}`: added
`CopyEngineGate::try_enter_offload_batch` returning `None` immediately
without blocking or consuming wave tokens when peer-copy graphs block
entry; updated `try_with_gpu_codec_locked` to acquire `codec.try_lock()`
and `gate.try_enter_offload_batch()` non-blockingly; and removed
per-page `Vec` clones in `restore_window` via `partition_restore_pages_by`
and borrowed slice transfers.
- `helios/src/scheduler/{cost.rs,policy.rs}`: tracked `pos_u_min`,
`pos_u_max`, `pos_t_at_umax`, and `has_zero_fill` strictly over
positive-fill strata so zero-fill observations keep the 4x upward floor
intact and `predict(0, 0)` only uses `theta[0]` when anchored by a
`zero_fill` sample; deduplicated `mixed_candidates` scoring loops and
extracted `clamp_nanos` / `MixedContextSlope`.
- `verification/helios-lifecycle/{Lifecycle.tla,check.py,README.md}` and
`helios/src/scheduler/lifecycle_tests.rs`: added `Paused`, `PauseForPark`,
`FinishForPark`, and `ToggleGrammar` to `Lifecycle.tla`, explored and
checked rejections in Rust conformance, and added six Rust mutation
checks under `check.py --mutations`.
- `docs/{api,core-design,mtp-design,prefix-cache-offload,scheduling-runtime-design}.md`:
updated present-state specifications for in-place/checkpoint-preserving
grammar transitions, non-blocking `CopyEngineGate` fallback, and
positive-fill `GraphKind::Mixed` cost floors.
Claimed benefit and result:
Coincident preemption no longer drops grammar-mode transitions or
thinking-budget expansion; foreground GPU KV restores never block on active
peer-copy graphs and avoid per-page restore allocations; `GraphKind::Mixed`
keeps bounded upward extrapolation and positive decode-only estimates across
zero-fill and narrow positive-fill regimes; and the new scheduler lifecycle
transitions are formally checked against `Lifecycle.tla` and mutation
guards. On a live SM120 RTX PRO 6000 `flare run` A/B test serving signed
`Qwen4-35B-A3B` (`--mtp-draft-tokens 0`), in-place grammar toggling
eliminated 100% of reasoning re-prefill tokens (84,638 -> 81,832 across 7
requests; 0 transition parks vs 7) and cut median `</think>`-to-content
transition latency by 3.32x at 6,382 prompt tokens (41.2 ms -> 12.4 ms) and
4.53x at 20,648 prompt tokens (58.5 ms -> 12.9 ms) with 6/6 valid JSON
schema outputs.
Supporting evidence:
- `python3 verification/helios-lifecycle/check.py --mutations`: all 10 TLA+
models passed (`Lifecycle.tla`: 18,790 states generated, 2,896 distinct),
623,904 observed Rust transitions verified (3,865 against `Lifecycle.tla`
with all 7 new coverage flags true), and 56/56 mutations detected (17
TLA+, 39 Rust including all 6 new Rust mutations).
- Rust release test suites: `eos` (12 passed), `selene` (586 passed),
`selene-manager` (443 passed, 1 ignored), `helios --lib` (1,919 passed;
6 HF template tests require `prepare_templates.py` downloads; 49
ignored), `helios --test '*'` (59 passed; 3 Gemma template tests require
downloads; 39 checkpoint-gated ignored), `flare` (255 passed, 4 ignored),
`flare-cli` (250 passed, 3 ignored), and 4/4 live SM120 GPU codec tests.
- Python pytest (`tests/test_scheduling_*.py`, `tests/test_design_review_hook.py`,
`tests/cli`, `tests/direct/test_scheduler.py`, `tests/test_kv_codec.py`
with `FLARE_RUN_CUDA_TESTS=1` on SM120): 1,115 passed.
- Unrun / limitations: `cargo-kani` is not installed locally (CI runs
`kani`); the 9 HF chat-template tests require `prepare_templates.py`
downloads; `scripts/scheduling_sim/` models scalar per-graph costs rather
than `(fill, kv_context)` NNLS curves; and under default MTP 5 on this
existing core without `ValueSource::GrammarEnabled`, speculative
`</think>\n\n{` bursts overshoot in Frame 1 or Frame 2 and fall back to
rollback on both builds (6/6 valid JSON; 6,382 prompt tokens 39.1 vs
39.0 ms; 20,648 prompt tokens 40.9 vs 54.1 ms, reflecting a 1-frame wait
when draining Frame 2 before overshoot rollback).
Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b
Signed-off-by: Luke Alonso <lalonso@gmail.com>
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedAll five Round-1 blockers from
Walkthrough
Merge Risk: Medium · up to
|
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>
Why
Three Helios runtime mechanisms leave performance or concurrency on the table across structured-output reasoning, GPU KV prefix-cache offload, and mixed prefill-plus-decode scheduling (building on #530, #626, #628, and #645):
</think>) or re-enters reasoning,Worker::completeinhelios/src/server/runtime.rsalways cancels the live slot viaRequestScheduler::cancel(handle)(publish_terminal = false), parks the request, and readmits it. Cancelling discards every generated reasoning token's KV and recurrent state—forcing re-prefill of the entire reasoning trace (or the full prompt plus reasoning if the prompt checkpoint was evicted)—even when there is no burst overshoot (skipped == 0) and no second frame in flight (live.pending() == 0). For non-speculative models, running open reasoning with two-frame pipelining also guarantees an in-flight second frame at the reasoning boundary for zero speculative gain.CopyEngineGate. Inhelios/src/offload/transfer/codec.rs,restore_windowterminates GPU batching (else { break; }) upon encountering aLiteralor CPU-routed page, forcing every subsequentGKV1page in the window onto singleton decode. On the capture path,capture_with_codeclocksgpu.codecbefore blocking onCopyEngineGate::enter_offload_batch(), so a background capture parked behind an active peer-copy graph holds the codec mutex and stalls or forces foreground restores onto CPU decode.GraphKind::Mixeduses flat median cost pricing.ActionCostsinhelios/src/scheduler/cost.rsfits a 6-stratum(fill, kv_context)nonnegative least-squares (NNLS) curve only forGraphKind::Prefill, leavingGraphKind::Mixedon a flat 9-sample median that cannot distinguish decode-only steps (work == 0), partial fills, full chunks, or deep-context attention cost.What changed
1. In-place and checkpoint-preserving grammar transitions (
helios/src/scheduler.rs,helios/src/scheduler/policy.rs,helios/src/model/{mod,admission,packing}.rs,helios/src/server/runtime.rs,verification/helios-lifecycle/)Admissionrepresented grammar state with two independent fields (grammar_mask: Option<Vec<i32>>andgrammar_enabled: bool).Admission::{grammar_mask, grammar_enabled}with a three-state enumAdmissionGrammar::{Disabled, UnmaskedEnabled, Masked(Vec<i32>)}so disabled-but-masked states are unrepresentable.RequestScheduler:set_grammar_constrained(handle, constrained)(requires a live non-finishing slot withpending == 0),pause_for_park(handle)(requires an active slot withpending > 0and blockspolicy.rsfrom scheduling additional frames), andfinish_for_park(handle)(requirespending == 0and transitions to terminal checkpoint publication).can_toggle_grammar_in_placeonWorkerfrom whether every sampling graph inPreparedContractbindsValueSource::GrammarEnabled(structural contract check, preserving Principle 13 compatibility with cores lacking that binding).pending == 0on completion) withAdmissionGrammar::UnmaskedEnabled(GrammarEnabled = 1, cached all-ones mask) during open reasoning, then switch toAdmissionGrammar::Masked(mask)in place on the live slot when reasoning closes or re-opens without thinking-budget expansion (nocancel, noSnapshot, noRestore, no re-prefill).decide_grammar_transition:ToggleInPlacewhenskipped == 0,live.pending() == 0,extra == 0, andcan_toggle_grammar_in_placeholds (set_grammar_constrainedruns before mutating request/admission state).CheckpointParkwhenskipped == 0andlive.error_code.is_none()and!live.deferred_prefill()(eithercan_toggle_grammar_in_placeis false,extra > 0, orlive.pending() == 1): drains any single in-flight frame underpause_for_park; ifconsumed_tokens <= exact_len, callsfinish_for_parksoWorker::publishpublishes a terminal checkpoint and readmits viaRestorewith the updated grammar mode and preservedreasoning_cut.after.Rollbackon burst overshoot (skipped > 0), draining-frame overshoot (consumed_tokens > exact_len), or grammar rejection.Worker::publish, appliedpending_grammar_parkbeforepark_if_preempted(and guardedpark_if_preemptedwhenpending_grammar_park.is_some()), preventing coincident page-pressure preemption from discarding the grammar-mode transition orreasoning_cut.afterexpansion.verification/helios-lifecycle/Lifecycle.tlawithPaused,PauseForPark,FinishForPark, andToggleGrammar, extendedhelios/src/scheduler/lifecycle_tests.rsto explore and check rejections for all three operations, and added six Rust mutation guards inverification/helios-lifecycle/check.py.2. Restore window partitioning and non-blocking
CopyEngineGateacquisition (helios/src/offload/{copy_gate.rs,transfer/codec.rs})restore_windowaborted GPU batching on the firstLiteralor CPU page and cloned per-pageDeviceSpanvectors;capture_with_codeclockedgpu.codecbeforeCopyEngineGate::enter_offload_batch(); foreground restores had no non-blockingCopyEngineGatetry-entry.CopyEngineGate::try_enter_offload_batch(&self) -> Option<OffloadBatchGuard<'_>>, which returnsNoneimmediately without blocking or mutating waiting/wave-token state when peer-copy graphs block offload entry.with_gpu_codec_locked, acquiringCopyEngineGate::enter_offload_batchbeforegpu.codec.lock(). Foreground GPU restore paths usetry_with_gpu_codec_locked, acquiringgpu.codec.try_lock()andCopyEngineGate::try_enter_offload_batch()non-blockingly and falling back immediately to CPU decode when either is contended (deadlock-free withwith_gpu_codec_lockedbecause both acquisitions are non-blocking).breakloop withpartition_restore_pages_by, partitioning restore windows into maximalGpuBatch,CpuBatch, andSingleruns without allocating a routeVecor cloning per-pageDeviceSpanvectors.3.
(fill, kv_context)NNLS pricing forGraphKind::Mixed(helios/src/scheduler/{cost.rs,policy.rs})ActionCostspricedGraphKind::Mixedwith a flat 9-sample median and duplicated scoring loops inmixed_candidates.ActionCostswith per-GraphKind::Mixed(fill, kv_context)6-stratum NNLS models plus azero_fillstratum for decode-only mixed steps (work == 0), sharingpredict_prefill_with_peer_slopeacrossPrefillandMixed.pos_u_min,pos_u_max,pos_t_at_umax, andhas_zero_fillover positive-fill strata: observing azero_fillsample keeps the 4x upward extrapolation floor intact on narrow positive fills,predict(0, 0)usestheta[0]only when anchored by azero_fillobservation (t_at_uminfallback otherwise), and azero_fill-only model (pos_u_max == 0,!has_positive_fill()) never emitsconstant_nanos, leaving positive-fill queries (work > 0) unmeasured (0) until a positive-fill step executes so decode-only observations cannot under-price full-chunk prefills or inflateservice_rates.mixed_candidates_with_curvesscoring loops inhelios/src/scheduler/policy.rswhile preserving helios/scheduler: cache per-lane powered survival curves across candidate pricing #693's per-laneCurveCachereuse, and updated present-state design specifications indocs/{api,core-design,mtp-design,prefix-cache-offload,scheduling-runtime-design}.md.Claimed benefit and result
flare runA/B on SM120 RTX PRO 6000 serving signedQwen4-35B-A3B-FLARE-gb202-tp1-202612032159-signed,--mtp-draft-tokens 0):flare_cache_lookups_total14 -> 7,flare_prefill_tokens_total84,638 -> 81,832 (-2,806 wasted prefill tokens),flare_sampling_graph_launches_total{kind="prefill"}62 -> 54 (-8 launches),flare_snapshot_publications_total30 -> 22, andflare_snapshot_backing_pages2,880 -> 2,112 (-26.7%).</think>-to-first-content latency gap by 3.32x at 6,382 prompt tokens (41.2 ms -> 12.4 ms) and 4.53x at 20,648 prompt tokens (58.5 ms -> 12.9 ms, flat at two 6.1–6.2 ms decode steps), with 6/6 schema-valid JSON responses on an existing core lackingValueSource::GrammarEnabled.Qwen4-35B-A3Bcore under default MTP 5, noValueSource::GrammarEnabledbinding):</think>\n\n{, speculative bursts overshoot</think>in Frame 1 or Frame 2 and fall back to rollback on both builds (6,382 prompt tokens: median gap 39.1 ms vs 39.0 ms; 20,648 prompt tokens: 40.9 ms vs 54.1 ms, where the ~13 ms delta reflects waiting one speculative frame underpause_for_parkbefore Frame 2 overshoots and rolls back). Cores exportingValueSource::GrammarEnabledtoggle in place whenskipped == 0 && pending == 0.reasoning_cut.after.GKV1runs past leading or interleavedLiteral/CPU pages without per-page span clones, and foreground GPU restores fall back to CPU immediately under peer-copy gate or codec contention.GraphKind::Mixedcost estimation differentiates zero-fill, partial-fill, full-chunk, and deep-context steps while retaining the 4x narrow-fill upward floor, anchored decode-only intercept, and unmeasured positive-fill protection onzero_fill-only models.Supporting evidence
flare runA/B benchmark (origin/mainf705086bvs commit68fe22fd, RTX PRO 6000 Blackwell SM120 GPU 2,/data/flare-runtime/Qwen4-35B-A3B-FLARE-gb202-tp1-202612032159-signed,temperature=0.7,top_p=0.8,max_tokens=2048, identical seeds and unique-prefix prompts per trial, 3 trials x 2 prompt lengths, strict JSON schemaresponse_format):--mtp-draft-tokens 0, 6,382 prompt tokens:mainmedianthink->content41.2 ms (35.2 / 41.2 / 43.5 ms) vs PR 12.4 ms (12.4 / 12.4 / 12.8 ms); valid JSON 3/3 vs 3/3.--mtp-draft-tokens 0, 20,648 prompt tokens:mainmedianthink->content58.5 ms (58.2 / 58.5 / 61.6 ms) vs PR 12.9 ms (12.6 / 12.9 / 22.1 ms); valid JSON 3/3 vs 3/3.main39.1 ms (37.7 / 39.1 / 39.6 ms) vs PR 39.0 ms (37.6 / 39.0 / 46.6 ms); valid JSON 3/3 vs 3/3.main40.9 ms (40.6 / 40.9 / 63.9 ms) vs PR 54.1 ms (50.0 / 54.1 / 56.7 ms); valid JSON 3/3 vs 3/3.2fa4e83e(prlimit --memlock=unlimited python3 verification/helios-lifecycle/check.py --tlc-jar ... --target-dir flare-cli/target --mutations):Lifecycle.tla: 18,790 states generated, 2,896 distinct states, depth 14, 0 errors).Lifecycle.tla, confirmingpaused_for_park,finished_for_park,cancelled_while_paused,toggled_grammar,rejected_pause_idle,rejected_toggle_pending, andrejected_finish_pending; 431 againstAsyncTransfer.tla).set_grammar_constrained,pause_for_park,finish_for_park,paused_for_parkscheduling,publishpreemption ordering, andCopyEngineGate::try_enter_offload_batch).2fa4e83e(cargo test --locked --release):helios(--features runtime-core,server):--lib1,966 passed, 0 failed (49 ignored; 6 HF chat-template tests requiretests/frontend/prepare_templates.pydownloads);--test '*'59 passed, 0 failed (39 checkpoint-gated ignored; 3 Gemma template tests requireprepare_templates.pydownloads).helioslive SM120 GPU KV codec tests (CUDA_VISIBLE_DEVICES=5 FLARE_TEST_KV_CODEC_CUBIN=... --ignored offload::transfer::codec::tests:: --test-threads=1): 4 passed, 0 failed.flare: 255 passed, 0 failed, 4 ignored.flare-cli: 254 passed, 0 failed, 3 ignored.68fe22fd:eos12 passed,selene586 passed,selene-manager443 passed (1 ignored).2fa4e83e(CUDA_VISIBLE_DEVICES=3 FLARE_RUN_CUDA_TESTS=1):tests/test_scheduling_*.py,tests/test_design_review_hook.py,tests/cli,tests/direct/test_scheduler.py,tests/test_kv_codec.py: 1,120 passed, 0 failed.cargo-kaniis not installed locally (covered by the repository'skaniCI job).tests/frontend/prepare_templates.py, and 39 checkpoint-gatedheliosintegration tests require external model snapshots.scripts/scheduling_sim/) models scalar per-graph costs rather than(fill, kv_context)NNLS curves, so theGraphKind::MixedNNLS fit is verified throughhelioscost and policy unit tests rather than a simulator curve sweep.GraphKind::Mixedgraphs orcodec_layoutwas available locally for whole-modelflare runthroughput benchmarks of items 2 and 3; item 2 was validated on live SM120 GPU hardware via the 4 ignoredoffload::transfer::codec::tests::GPU tests andtests/test_kv_codec.py.Discord: lukealonso