Repository navigation
helios/scheduler: price first-output waiting age on incumbent decode rounds - #663
Conversation
e29725b to
a5c3697
Compare
Additional served GPU A/B:
|
| Workload | Metric | Base (a3c80e19) |
Treatment (a5c36978) |
Delta |
|---|---|---|---|---|
Standalone prefill 8K (2 reps) |
prompt tok/s (ttft) | 3,634.7 / 3,687.2 (2.32 / 2.17 s) |
3,641.0 / 3,690.4 (2.32 / 2.17 s) |
+0.1% (parity) |
Standalone prefill 32K (2 reps) |
prompt tok/s (ttft) | 3,736.3 / 3,731.2 (8.78 / 8.79 s) |
3,738.6 / 3,737.4 (8.77 / 8.78 s) |
+0.1% (parity) |
Batched decode C=1 (256 tok) |
agg wall tok/s (wall) | 55.6 (4.61 s) |
54.3 (4.72 s) |
-2.3% (noise) |
Batched decode C=4 (256 tok) |
agg wall tok/s (wall) | 127.7 (8.02 s) |
129.6 (7.90 s) |
+1.5% |
Batched decode C=8 (256 tok) |
agg wall tok/s (wall) | 186.0 (11.01 s) |
198.1 (10.34 s) |
+6.5% |
Batched decode C=16 (256 tok) |
agg wall tok/s (wall) | 254.0 (16.13 s) |
256.3 (15.98 s) |
+0.9% |
Batched decode C=32 (256 tok) |
agg wall tok/s (wall) | 331.0 (24.75 s) |
345.0 (23.74 s) |
+4.2% |
2. Fixed-window mixed contention & throughput control
All streamed background chunks are counted in real time inside an identical wall-clock window (no end-of-window cancellation truncation):
Workload (policy) |
Metric | Base (a3c80e19) |
Treatment (a5c36978) |
Delta |
|---|---|---|---|---|
45 s fixed-window returning agent + K=16 bg decoders (balanced) |
Ret. TTFT p50 ∥ mean ∥ p95 | 4,324 ∥ 4,440 ∥ 4,789 ms |
868 ∥ 1,011 ∥ 1,576 ms |
-79.9% (5.0×) ∥ -77.2% ∥ -67.1% |
Cold Turn-0 TTFT (~2.5K tok) |
10,048 ms |
5,032 ms |
-49.9% (2.0×) |
|
Agent turns completed (turns/min) |
9 (11.99) |
22 (28.30) |
+136.0% (2.36×) |
|
| Streamed BG decode throughput | 237.1 chunks/s |
234.1 chunks/s |
-1.3% (parity) |
|
| BG decode gap p99 ∥ max | 334.5 ∥ 511.6 ms |
410.5 ∥ 662.6 ms |
+76 ms ∥ +151 ms |
|
Long cold prompts (3× ~14K) + K=12 bg decoders (balanced) |
Cold TTFTs (max) | [37.4, 29.1, 35.9 s] (37.4 s) |
[35.9, 25.2, 34.0 s] (35.9 s) |
-4.2% max (-13.5% min) |
| Streamed BG decode throughput | 150.4 chunks/s |
147.4 chunks/s |
-2.0% (parity) |
|
| BG decode gap p99 ∥ max | 1,192.8 ∥ 1,906.7 ms |
1,190.7 ∥ 2,004.5 ms |
-0.2% p99 (parity) |
|
35 s fixed-window returning agent + K=16 bg decoders (throughput) |
Ret. TTFT p50 ∥ turns | 2,540 ms ∥ 10 (15.93/m) |
2,539 ms ∥ 10 (15.83/m) |
-0.05% (exact parity) |
| Streamed BG throughput ∥ gap p99 | 263.1 ch/s ∥ 345.4 ms |
266.4 ch/s ∥ 355.1 ms |
Parity |
Discord: D-Rock
|
A case file has been opened for 663. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedThe core formulation (
Walkthrough
Merge Risk: Medium · up to
|
Review: comparing #663 against #654 and recommended fixesRecommendation: Use #663 as the basis for first-output wait pricing in Helios, address the fixes below before merge, and split the returning-agent benchmark and paired-visit analyzer from #654 into a separate PR so fixed-work evaluation against Why #663 is the stronger scheduler approach compared to #654
Recommended fixes before merging #663
(Verification scope: inspected PR #663 and PR #654 diffs, PR comments, and |
|
SM120 TP4 ( Setup: Tested PR Results (
Notes & caveats:
|
a5c3697 to
8aa79e3
Compare
|
Thanks @logprobz for the thorough comparison and review (and @FujitsuPolycom for the independent SM120 TP4 +
Discord: D-Rock |
|
Verdict: Changes Requested (reviewed at head This design is cleaner than adding a separate prefill-age knob or dividing by However, the implementation has four concrete bugs, three normative documentation contradictions, a weakened test suite, and an unapproved default-ON policy trade-off that block merging as written. 1. Bugs and Correctness Issues1.1
|
…rounds
Under the balanced scheduler policy (`decode_age_price = 0.1`), active
decoding streams accumulate waiting-age utility scaled by their batch-feasible
excluded wait while prompts waiting for their first output accumulate none.
When a returning or newly arrived prompt competes against a large active
decode cohort on a model without mixed prefill-decode graphs (for example,
8 to 16 concurrent decoders on DeepSeek-V4.1-Flash or Qwen3.8-Flash-Next),
the prompt stalls for multiple seconds waiting for its token-service fairness
price to climb high enough to displace a full-batch decode round. When an
interior conversation-anchor checkpoint splits a single-chunk prompt into a
main chunk, a boundary snapshot, and a short tail, the prompt incurs that
wait twice because progress resets its waiting state while its service price
drops on the first chunk.
This change closes the asymmetry inside the shared Helios scheduler and the
Python utility reference simulator without adding configuration flags, CLI
options, model branches, new graph kinds, or `ServicePrice` exemptions:
- `helios/src/scheduler/service.rs`: Extend delivery-reference selection with
`delivery_references_and_decode_batch`, returning the fastest pure incumbent
`Decode` or `Speculative` round's work-time `b_served * T_dec` (in
stream-ms, excluding `Mixed` graphs and returning `0.0` when no measured
decoder is active). For fixed-width packed speculative rounds, evaluate each
measured packed shape's token budget directly so feasible batch capacity and
per-slot delivery references are exact and slot-order invariant under
heterogeneous verification lengths.
- `helios/src/scheduler/utility.rs` and `helios/src/scheduler/policy.rs`: Add
`LaneValue::first_output_value` and `LaneValue::prefill_within`. When
`decode_age_price > 0.0` and `b_served * T_dec > 0.0`, each waiting prompt
with `max_new_tokens > 0` receives waiting-age credit
`decode_age_price * (b_served * T_dec) * age_ms * frac`, multiplying
`decode_age_price * unit` before scaling by `b_served * T_dec * age_ms` to
avoid premature overflow or `inf * 0 = NaN` under large finite prices.
`frac = 1.0` when the step completes the prompt and
`frac = work / initial_prefill` on partial chunks. The credit flows through
prerequisite and two-stage continuation scoring (`Init`, `Restore`,
`Vision`, `Snapshot`) without adding waiting prompts to the common
`-T/2 * sum c_j` waiting-penalty sum.
- `helios/src/scheduler.rs` and `helios/src/server/runtime.rs`: Track
`RequestAccounting::first_output_wait_ns`. Preserve it across a prefill
stopped at an armed interior `RetentionRole::Anchor` cut when the prompt
otherwise fit in a single eligible prefill graph (including when the anchor
coincides with the chosen chunk capacity or when a `TerminalPrefill` chunk
clears `deferred_prefill` while landing on an interior anchor), while
continuing to charge all measured token service truthfully in
`observe_service`. Fold `readmitted_output_ns: Option<u64>` into
`set_arrival` so admission timestamp assignment has no call-order hazard.
Carry `Carried::last_output_ns` across preemption and forced-reasoning
readmission, recording host-published forced-close timestamps when
`close_reasoning` advances `publications` and taking the latest of graph and
host publication timestamps.
- `scripts/scheduling_sim/utility.py`, tests, and docs: Mirror the pure-decode
zero-knob formula in `UtilityScheduler`, add Rust and Python unit tests for
inertness, `b_served * T_dec` scaling, `Mixed` exclusion, packed speculative
feasibility and slot-order invariance, large finite `decode_age_price`
overflow/NaN safety, anchor-vs-message cut boundaries, multi-chunk
`TerminalPrefill` deferred-state anchor preservation, pipelined prefill
wait projection, forced-reasoning-close readmission (with and without prior
graph publication), balanced burst coalescing, and oversubscribed/small-batch
adversarial bursts, and reconcile `docs/scheduling-theory.md`,
`docs/scheduling-utility.md`, and `docs/scheduling-runtime-design.md`.
Result:
- Paired zero-re-export `flare run` A/B on 4x DGX Spark GB10 (SM121,
DeepSeek-V4.1-Flash-1017 TP4, `--scheduler-policy balanced`, zero errors):
- Returning agent + K=8 decoders: TTFT p50 `2,812 -> 1,025 ms` (-63.5%),
turns/min `13.21 -> 21.77` (+64.8%), bg gap p95/p99 `168.1 -> 151.0` /
`334.1 -> 328.3 ms`.
- Returning agent + K=16 decoders: TTFT p50 `5,265 -> 894 ms` (-83.0%),
turns/min `8.75 -> 18.00` (+105.7%), bg gap p95 `211.1 -> 184.0 ms`,
p99 `368.4 -> 463.5 ms`.
- C=12 simultaneous burst: max TTFT `7,177 -> 5,416 ms` (-24.5%), gap p99
`183.9 -> 158.3 ms`.
- Paired 4-visit ABAB returning-agent suite (closed 8x8, cold, single,
sustained, burst at K=16): `closed` 6/6 gates (`73 -> 127` valid turns,
+74%, TTFT p50 `6,493 -> 1,933 ms`, `step_cost` `0.840 -> 0.611`), `cold`
4/4 parity, `single` TTFT p50 `3,301 -> 590 ms` (-82%), `sustained` 26/26
valid (vs 24/26 on main, completing the 28K long return that main timed
out), `burst` TTFT p50 `6,381 -> 1,668 ms` with higher p99/max gap
(`376 -> 493 ms`, `426 -> 995 ms`).
- `--scheduler-policy throughput` control (K=16): parity.
- Paired zero-re-export `flare run` A/B on 2x DGX Spark GB10 (SM121,
Qwen3.8-Flash-Next TP2, hybrid Mamba/GatedDeltaNet + Attention, zero errors):
- Standalone prefill 8K/32K exact parity (+0.1%); batched decode C=1..32
parity to +6.5%; 45 s fixed-window returning agent + K=16 bg: TTFT p50
`4,324 -> 868 ms` (-79.9%), turns `9 -> 22` (+136%), streamed bg throughput
`237.1 -> 234.1 ch/s` (-1.3% parity), bg gap p99 `334.5 -> 410.5 ms`;
35 s throughput control exact parity (`2,540 vs 2,539 ms`).
Supporting evidence and limitations:
- Rust (`--release`, Linux): `helios` (`runtime-core,server` lib: 1,783 passed),
`flare` (253 passed), `flare-cli` (241 passed), `heliopause` `cargo check`
(0 new warnings).
- Python: `pytest tests/test_scheduling*.py` (830 passed); `scheduling_sim`
matches baseline traces identically across all 21 workloads at
`age_price = 0.0`, while under `balanced` max TTFT and makespan improve on
`burst_eight`, `burst_eight_8k`, and `sixteen_prefills` with modest
increases in `max_output_gap_ms` and `decode_age_area_ms2`.
- TLA+ lifecycle conformance (`verification/helios-lifecycle/check.py`,
TLA+ 1.7.4): 10/10 TLC models, 8/8 observed Rust trace checks (594,065
transitions), 12/12 auxiliary conformance tests passed.
- Limitations: Gated template tests requiring `FLARE_TEST_TEMPLATE_DIR`
(blocked locally by gated Hugging Face repo 401 in `prepare_templates.py`),
`native-serving.yml`, and `kani` proofs were not run locally.
Co-authored-by: logprobz <321553542+logprobz@users.noreply.github.com>
Signed-off-by: yatesdr <6937857+yatesdr@users.noreply.github.com>
Design-Signed-Off-By: yatesdr; design-review=2e5b
8aa79e3 to
5bf9085
Compare
|
Thanks @lukealonso for the thorough review! Several items had just landed in
Re-verified on Ready for re-review and maintainer sign-off on enabling this default-ON under Discord: D-Rock |
…l swap
Why
Under concurrent mixed prefill and decode workloads (multiple long prompts
competing alongside active decoders), prefill valuation in
helios/src/scheduler/policy.rs and scripts/scheduling_sim/utility.py exhibits
two structural bottlenecks:
1. Scalar minimum peer_budget collapse: clamping the decode-batch coalescing
horizon and expected speculative output across all active decoders by
min_i(rem_i) collapses coalescing credit for every queued prefiller whenever
a single active decoder nears completion.
2. Multi-chunk heavy prefill lockstep: ServicePrice::observe credits each
intermediate prefill chunk, dropping the executing multi-chunk prompt's
normalized price below untouched peers so competing long prompts advance in
lockstep rather than finishing sequentially and freeing KV pages.
Averaging the bounded peer horizon across active decoders eliminates
single-stream collapse without inflating credit beyond the cohort's remaining
output. Pairing competing multi-chunk prefills by aged remaining-time urgency
and exchanging dimensionless normalized GPU-time shares at submission conserves
aggregate prefill entitlement against decode while allowing long prompts to
complete sequentially, including across deferred intermediate chunks on
TerminalPrefill cores.
What
- Helios scheduler (helios/src/scheduler.rs, helios/src/scheduler/policy.rs,
helios/src/scheduler/service.rs, helios/src/scheduler/utility.rs; +136/-13,
+123 net non-test Rust production LOC):
- Replaced scalar peer_budget = min_i(rem_i) in coalescing_prefill_log_bonus
with per-decoder remaining budgets averaged across active decoders for both
speculative expected output and the coalescing horizon (bounded by
PolicyConfig::coalescing_horizon_tokens and each prefiller's post-prefill
output budget).
- Added ServicePrice::log_normalized_share and
ServicePrice::swap_normalized_share in utility.rs, best_prefill_chunk and
heavy_prefill_donors in policy.rs, and submit-time share exchange in
service_participants (passing &step from scheduler.rs). When active
non-terminal decoders exist (excluding policy::terminal_cleanup Snapshot
requests), token_fairness > 0, and at least two non-terminal,
non-prompt_logprobs prefills have remaining > c_max (best measured
pure-prefill chunk, including deferred intermediate chunks on
TerminalPrefill cores), pairs descending aged remaining-time urgency
(1 + wait_ms / (1.5 * t_max)) / rem_ms with descending normalized share and
exchanges shares on submit; single-chunk prefills (remaining <= c_max) are
excluded.
- Python scheduling simulator (scripts/scheduling_sim/utility.py; +71/-7, +64
net production LOC): mirrored cohort-mean coalescing and multi-chunk
entitlement share swap (filtering pure-prefill graphs in pref_best, ranking
donors by ascending log_fraction, pricing paired recipients with their own
coefficient and the donor's log_fraction, and swapping log_fraction in
UtilityScheduler::observe).
- Documentation and tests (docs/scheduling-runtime-design.md +27/-9;
helios/src/scheduler/policy_tests.rs +240/-0;
tests/test_scheduling_utility.py +108/-0): updated present-state scheduler
design documentation and added unit tests verifying cohort-mean horizon
behavior, normalized-share conservation across rates, sequential multi-chunk
completion on both Prefill and deferred TerminalPrefill cores, submit/observe
share exchange, single-chunk exclusion, retiring Snapshot exclusion, mixed
graph filtering, and weighted donor parity.
- Compatibility: zero new CLI flags or PolicyConfig fields, zero decode-side
changes, zero Protobuf/ABI/core-format changes, zero unsafe code, and zero
new locks.
Result
Expected behavior (verified in unit tests and Rust/Python policy parity):
- Eliminates single-stream near-EOS coalescing collapse when one decoder has
one remaining output token alongside longer active decoders.
- Serializes competing multi-chunk prompts across both standard Prefill and
deferred TerminalPrefill chunks while conserving aggregate prefill
entitlement relative to active decoders and leaving single-chunk prefills
untouched.
- Offline calibrated simulation on this reduced diff and live SM120/SM121
flare run GPU A/B benchmarks are pending before leaving Draft.
Evidence
Verified on a clean git archive extract of this commit atop
5d53040:
- git merge-tree --write-tree confirms zero conflicts against 5d53040,
a3c80e1, live main, and NVIDIA#663 (a5c3697)
- cargo check --locked --release across helios (--features runtime-core,server
--lib), flare (--lib), flare-cli (--bins), and heliopause with zero warnings
- cargo test --locked --release across helios (--features server --lib and
--features runtime-core,server --lib), flare (--lib), and flare-cli
- pytest on tests/preparation/test_core_boundary.py and tests/test_scheduling*.py
- ruff==0.12.8 check on scripts/scheduling_sim/utility.py and
tests/test_scheduling_utility.py
- All 10 standalone TLA+ TLC models, Rust trace conformance across all 8
modeled protocols, auxiliary conformance tests, and lifecycle mutation checks
- Live fault-injection mutations across all retained Rust and Python code paths
verified 100% killed by unit tests
Material limitations:
- Standalone calibrated discrete-event simulation on this reduced change and
live SM120/SM121 flare run GPU A/B serving measurements are pending prior to
marking ready for review.
- scripts/scheduling_sim/learning.py --preset validate and cargo-kani were not
run because timing estimation, funded refresh, completion-vector validation,
and StateView extent arithmetic are unchanged.
Discord: Dooner
Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
…ced streams Why To keep decode cadence responsive without mixed prefill-decode graphs, Helios interleaves smaller prepared prefill chunks with normal decode steps under the default balanced policy (PolicyConfig::decode_age_price = 0.1 value/ms^2, specified in docs/scheduling-theory.md and docs/scheduling-runtime-design.md). On prepared cores whose TERMINAL_PREFILL catalog covers capacities above the smallest chunk (for example, 256..=16384 alongside PREFILL 128..=16384), long cold prompts contending with active decoding streams still cause multi-second decode stalls for three reasons: 1. Cold-discovery lockout: prompts up to max_terminal measure TerminalPrefill(c) while leaving smaller non-terminal Prefill(c) unmeasured; add_candidate and continuation_candidate skip unmeasured capacities other than natural_fit, and funded refresh only revisits measured keys. 2. Monolithic-tail lockout: prefill_requires_terminal_completion_from excludes non-terminal Prefill whenever remaining tokens fit within max_terminal, forcing any remaining tail up to max_terminal into one TerminalPrefill step. 3. Two-frame prefill pipelining: prefill_step_requires_feedback lets consecutive non-terminal Prefill steps fill both transport frames ahead of active age-priced decoders and updated output ages. Pricing unmeasured smaller prefill capacities from already-measured GPU durations, allowing non-terminal Prefill chunks below max_terminal while active age-priced streams exist, and requiring feedback between non-terminal chunks lets ValueRate choose latency-bounded chunks by default under balanced without new CLI flags, hardcoded capacities, duration ceilings, or per-model branches. What Net non-test production change: +319 LOC (+397/-78) across 4 Rust scheduler files (11 files total, +1,949/-106; zero new CLI/config flags, zero unsafe, zero hardcoded capacities, zero model-name branches, zero Protobuf or ABI changes): - Interpolated GPU-measured prefill estimates and discovery origin (helios/src/scheduler/cost.rs, policy.rs): added ActionCosts::interpolated_prefill_duration, deriving positive durations strictly from measured GPU timings (same-capacity sibling first, else linear interpolation between nearest smaller peer or fastest Decode/Speculative/Resume floor and nearest strictly larger peer, with order-independent same-kind precedence and ScoredPrefill isolation). When age_price > 0.0, unmeasured pure-prefill capacities <= nat_fit compete by ValueRate in add_candidate and continuation_candidate (excluding oversized padded shapes > nat_fit). In select_plan() and phase_plan(), unmeasured interpolated winners return PlanOrigin::Discovery directly (preventing displacement by stale refresh probes and preventing unmeasured interpolated durations from entering PlanOrigin::AcceptanceStart), drain on first run as TimingOrigin::Discovery, and record real GPU timings. Solo prefill (age_price == 0.0), service_rates, and checkpoint planning are unchanged. - Chunkable non-terminal Prefill, resize capping, and hot-path caching (helios/src/scheduler.rs, policy.rs, service.rs): tightened resolve_prefill_kind_from so deferred_prefill never selects non-terminal- catalog shapes when needs_terminal is false; updated resize_prefill to select from terminal_prefill_catalog whenever request.deferred_prefill is active and cap age-priced non-terminal prefill growth at candidate.capacity; added prefill_must_complete_terminally_from and prefill_requires_terminal_completion_for_age; cached terminal_prefill_window and hoisted per-slot prefill planning state across capacities/continuations; kept the token_rate == 0.0 non-terminal Prefill fallback in service_rates. - Active-stream feedback barrier (helios/src/scheduler.rs): prefill_step_requires_feedback drains between non-terminal Prefill steps when an active Decode/Resume (decode_age_price > 0.0) or terminal-cleanup (terminal_age_price > 0.0) stream exists, preserving two-frame pipelining for solo prefill and --scheduler-policy throughput (decode_age_price = 0.0). - Added a GB10 simulator workload (scripts/scheduling_sim/workloads.py), unit and mutation-coverage regression tests, updated the deferred-prefill source mutation pattern in verification/helios-lifecycle/check.py, and reconciled present-state documentation (docs/scheduling-runtime-design.md, docs/scheduling-theory.md, helios/README.md). Existing signed cores load and serve unchanged. Result Live zero-re-export flare run A/B measurements with stock --scheduler-policy balanced (0.1) and --scheduler-policy throughput (0.0) (zero new CLI flags, DeepSeek-V4.1-Flash signed cores, zero errors, zero non-finite logprobs): - 4x RTX PRO 6000 (SM120 TP4, signed core gb202-tp4-202612010626, flare run --gpus 0,1,2,3 --max-concurrency 32 --mtp-draft-tokens 7 --mtp-adaptive-verification --mtp-max-verification-token-budget 128 --mtp-adaptive-verification-alpha 1.0 --scheduler-policy balanced --embedding-table-storage disk --embedding-table-cache-size 84GiB --embedding-table-workers 1 --embedding-table-resident-scales --kv-cache-limit memory --prefix-cache-memory 0): - Standalone pre-NVIDIA#663 (5d53040 vs fdb10bb): on 4 active decoders + staggered 14K+32K+64K prefills (T_50C, n=2), peak decode gap drops 331.9 -> 260.3 ms (-21.6%), mean max gap drops 279.7 -> 246.1 ms (-12.0%), and mean TPOT drops 6.10 -> 5.55 ms (-9.0%) for +1.8% makespan (3.164 -> 3.221 s). On tokbench mixed-c32 (FujitsuPolycom/tokbench d6b74524, C=32, seed 42, temperature 0.0, warmup 15s + measure 60s + drain 30s, n=1), >250 ms stalls drop 215 -> 78 (-63.7%), gap p99 drops 237.2 -> 188.6 ms (-20.5%), and per-user p50 rises 93.9 -> 99.2 tok/s (+5.7%) for -2.0% output (1,072.8 -> 1,050.8 tok/s). Solo 27.5K TTFT stays within +0.7% (540.7 -> 544.2 ms, n=1); solo C=1 short (464 tok, n=2) Trial 0 matches base (58.91 vs 58.58 ms; Trial 1 189.2 ms jitter). - Post-NVIDIA#663 stacked SM120 A/B (a3c80e1 base vs NVIDIA#663 vs NVIDIA#660+NVIDIA#661+NVIDIA#663, mixed-c32, n=1): standalone NVIDIA#663 raises mixed-c32 gap p99 from 227.3 to 286.0 ms and >250 ms stalls from 206 to 431; stacking NVIDIA#661 eliminates that regression, cutting gap p99 by -29.0% (286.0 -> 203.1 ms, -10.6% below pre-NVIDIA#663 base) and >250 ms stalls by -78.9% vs NVIDIA#663 (431 -> 91, -55.8% below pre-NVIDIA#663 base) while sustaining 97.8% SLO and 1,354.9 tok/s output. - 4x DGX Spark GB10 (SM121 TP4, signed core gb10-tp4-202612010243, pre-NVIDIA#656 571a447, n=3 trials, 12 decoders + 3x19.5K prompts): >1 s decode stalls drop 24 -> 0 (-100%), p99 ITL drops 1,670 -> 713 ms (-57.3%), max burst gap drops 1,699 -> 725 ms (-57.4%), trading +2.8% heavy TTFT p50 and -1.3% decode output. - 4x RTX PRO 6000 throughput control (pre-NVIDIA#656 571a447, --scheduler-policy throughput, n=2 across 3 workloads): prefill launches are bit-identical (28/24/19) and makespan stays within +0.3% (3.64 vs 3.65 s). - Host planning & calibrated simulation: 25-bucket dense-catalog plan() is 4.70x-8.65x faster than base 571a447 (55.8-196.0 us mean). All 21 existing workloads remain bit-identical under Python UtilityScheduler. Evidence Verified on a clean git archive of this commit atop 1fbcc3c (post-NVIDIA#663 main) via release cargo check (-D warnings) and cargo test (helios --features server and --features runtime-core,server, flare, flare-cli, and heliopause), pytest (core boundary and scheduling suites), ruff 0.12.8 lint, throttled scripts/scheduling_sim/learning.py smoke and screen presets (known, ttl, retained-refresh), and TLA+ lifecycle models, Rust trace conformance, and full source/model mutation testing (verification/helios-lifecycle/check.py --mutations). Standalone SM120 hardware A/B ran on direct pre-NVIDIA#663 predecessor fdb10bb (atop 5d53040) and stacked post-NVIDIA#663 SM120 A/B ran on 82f68ea8 (NVIDIA#660+NVIDIA#661+NVIDIA#663 atop a3c80e1), both prior to the resize_prefill deferred_prefill guard, select_plan() PlanOrigin::Discovery guard, doc sync, and rebase onto 1fbcc3c. Limitations: live flare run A/B benchmarks were not re-executed on this exact rebased SHA atop 1fbcc3c; gated Hugging Face chat-template tests require FLARE_TEST_TEMPLATE_DIR with gated repo credentials; cargo-kani was not run because completion-vector and StateView validators are unchanged. Discord: Dooner Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
…l swap
Why
Under concurrent mixed prefill and decode load (multiple long cold prompts
competing alongside active decoders), prefill valuation in
helios/src/scheduler/policy.rs and scripts/scheduling_sim/utility.py has two
structural defects:
1. Scalar min_i(rem_i) collapse: clamping the decode-batch coalescing horizon
and expected speculative output across active decoders to min_i(rem_i)
collapses coalescing credit whenever one active decoder nears completion.
2. Multi-chunk prefill lockstep: ServicePrice::observe credits each
intermediate prefill chunk, dropping the executing prompt's normalized
price below untouched peers so long prompts advance in lockstep instead of
completing sequentially and freeing KV pages.
Averaging bounded per-decoder remaining budgets across active decoders prevents
single-stream collapse without inflating credit past the cohort's remaining
output. Recording planned normalized-entitlement swaps among competing
multi-chunk prefills at submission, projecting queued swaps across depth-2
pipelines, and applying the exchange only at validated completion conserves
aggregate prefill entitlement relative to active decoders while preserving
completion-only accounting and rejection safety.
What
- Helios scheduler (helios/src/scheduler.rs, helios/src/scheduler/policy.rs,
helios/src/scheduler/service.rs, helios/src/scheduler/utility.rs; +263/-39,
+224 net non-test Rust production LOC; zero CLI, config, decode, ABI, unsafe,
or lock changes):
- Replaced scalar min_i(rem_i) in coalescing_prefill_log_bonus with the
cohort mean across all active decoders for both speculative expected output
and the coalescing horizon (bounded by coalescing_horizon_tokens and each
prefiller's post-prefill output budget).
- Added ServicePrice::{log_normalized_share, swap_normalized_share},
best_prefill_chunk, stack-allocated heavy_prefill_donors (zero heap Vec
allocations), projected_services, and Submission::prefill_share_swap.
- Multi-chunk pairing activates only when active non-terminal decoders exist
(excluding retiring Snapshot requests), token_fairness > 0,
decode_age_price > 0 (inactive under --scheduler-policy throughput), and at
least two non-terminal, non-prompt_logprobs prefills exceed
prefill_chunk_size (including deferred TerminalPrefill chunks). Single-chunk
prefills (remaining <= prefill_chunk_size) are excluded even when the
highest-throughput chunk c_max is smaller than prefill_chunk_size.
- Submission records any non-self (recipient, donor) handle pair computed
from projected prices without mutating stored prices. Depth-2 projection
(projected_services) applies pending swaps before projecting queued frames.
observe_service executes swap_normalized_share only after
observed_duration_ns returns Some, verifying non-error status, positive
useful_tokens on the recipient, and matching live request handles.
- Python scheduling simulator (scripts/scheduling_sim/utility.py; +105/-7):
mirrored cohort-mean coalescing and weighted-conserving multi-chunk share
exchange (ranking and swapping log_price to conserve aggregate sum q_i across
unequal weights, gated on reference is not None, age_price > 0,
rate_history == "service", and remaining_prefill > max_prefill_cap, using
log-space urgency to avoid overflow on tiny durations, and validating
duration_ms and committed rows before mutating prices or clearing donors).
- Documentation and tests (+127/-35 docs; +784/-0 Rust tests; +245/-0 Python
tests): placed canonical specification and linear-aging preemption limits in
docs/scheduling-utility.md, reconciled docs/scheduling-runtime-design.md,
docs/scheduling-theory.md, and helios/README.md, and added unit tests
covering packed/unpacked speculative cohort-mean, zero-fairness/throughput
opt-out, prompt_logprobs exclusion, single-chunk exclusion below
prefill_chunk_size, arrival-wait aging and tie-breakers, completion-only
depth-2 pipelining, error/zero-timing invariance, Mixed prefill swaps, and
weighted Python conservation.
Result
Measured incrementally atop post-NVIDIA#663 main (1fbcc3c):
- All 21 standard simulator workloads in scripts/scheduling_sim/workloads.py
under both standard and mixed catalogs and both balanced and throughput
policies show zero regressions (0/21 changed).
- --scheduler-policy throughput (decode_age_price == 0) is byte-for-byte
unchanged by share swaps across all tested workloads.
- Under balanced policy on concurrent multi-chunk workloads alongside active
decoders (standard catalog): 2 decoders + 2x16k shifts heavy TTFTs from
[593.1, 678.4] ms to [383.9, 857.2] ms (first -35.3%, mean 320.1 -> 312.5 ms,
max_output_gap_ms unchanged at 217.3 ms, output_tok_s -1.9%, decode_age_area
+6.2%); 4 decoders + 4x16k shifts heavy TTFTs from [1436.0..1637.3] ms to
[788.0, 970.6, 1968.6, 2200.6] ms (first -45.1%, mean 773.5 -> 744.7 ms,
max_output_gap_ms 213.0 -> 226.6 ms, output_tok_s -2.4%, decode_age_area
+7.9%). On mixed catalog: 2 decoders + 2x16k shifts mean TTFT -17.2% (first
-36.9%, gap unchanged 145.0 ms, out -1.8%); 4 decoders + 4x16k shifts mean
TTFT -21.1% (first -57.4%, gap unchanged 114.7 ms, out -1.5%). Live
SM120/SM121 flare run GPU A/B is pending before upstream review.
Evidence
Verified on clean git archive (tree d0c622a) atop 1fbcc3c:
- Merge-tree: 0 conflicts vs upstream/main (1fbcc3c), NVIDIA#660 (9709d49),
NVIDIA#661 (c588d61), NVIDIA#665 (c5b3923), and composed main + NVIDIA#660 + NVIDIA#665.
- Rust builds & tests: RUSTFLAGS="-D warnings" cargo check --locked --release
across helios, flare, flare-cli, and heliopause passed with 0 warnings;
helios --features server --lib 1,284 passed; helios --features
runtime-core,server --lib 1,796 passed (excl. 6 FLARE_TEST_TEMPLATE_DIR
tests); flare --lib 246 passed; flare-cli 245 passed (0 failed).
- Python & simulator: pytest (test_core_boundary.py + test_scheduling*.py) 838
passed; ruff==0.12.8 0 issues; full 21-workload sweep under balanced and
throughput (standard + mixed catalogs).
- Formal & mutations: 10/10 standalone Java TLC configs, 8/8 observed Rust
TLA+ traces (594,065 transitions, 0 errors), 12/12 aux tests, 26/26 check.py
Rust lifecycle mutations + 13/13 TLA+ model mutations + 1/1 DispatchRing
SlotReuseSafe observed-edge check KILLED (0 survivors), plus 13/13 reachable
custom Rust PR mutations and 12/12 custom Python PR mutations KILLED.
- Limits: live SM120/SM121 flare run GPU A/B is pending; learning.py --preset
validate and cargo-kani were not run because their covered code is unchanged.
Discord: Dooner
Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
Why
Under
--scheduler-policy balanced(decode_age_price = 0.1), active decoding streams accumulate waiting-age utility scaled by their batch-feasible excluded wait while prompts waiting for their first output accumulate none. On models without mixed prefill-decode graphs, a newly arrived or returning prompt competing against 8–16 active decoders stalls for multiple seconds until its token-service fairness price climbs high enough to displace a full-batch decode round. When an interior conversation-anchor checkpoint splits a single-chunk prompt into a main chunk, boundary snapshot, and short tail, progress resets waiting state and service price drops on the first chunk, forcing the short tail to wait a second time.This PR derives from and consolidates the returning-prompt investigation in #654 (co-authored with @logprobz) into a zero-knob formulation inside Helios's shared scheduler.
What changed
Before: Waiting prompts competed only through useful token progress, token-service fairness price, and zero-age coalescing surplus; they carried no first-output waiting-age credit, and progress on a forced interior anchor split always reset waiting state.
After (zero new CLI flags, config fields, model branches, graph kinds, Protobuf changes, or
ServicePriceexemptions):helios/src/scheduler/service.rs: Extended delivery-reference selection withdelivery_references_and_decode_batch, returning the fastest pure incumbentDecodeorSpeculativeround's work-timeb_served * T_dec(excludingMixedgraphs;0.0when no measured decoder is active). For fixed-width packed speculative rounds (--mtp-adaptive-verification), each measured packed shape's token budget is evaluated directly so feasible batch capacity and per-slot delivery references are exact and slot-order invariant under heterogeneous verification lengths.helios/src/scheduler/utility.rs,helios/src/scheduler/policy.rs: AddedLaneValue::first_output_valueandLaneValue::prefill_within. Whendecode_age_price > 0.0andb_served * T_dec > 0.0, each waiting prompt withmax_new_tokens > 0receives:frac = 1.0on prompt completion andfrac = work / initial_prefillon non-finishing chunks.decode_age_price * unitis applied after computing the shared log-scale to prevent premature overflow orinf * 0 = NaNunder large finite prices. Waiting prompts are omitted from the common-T/2 * sum c_jpenalty sum, and the credit flows through prerequisite and two-stage continuation scoring (Init,Restore,Vision,Snapshot).helios/src/scheduler.rs,helios/src/server/runtime.rs: TrackedRequestAccounting::first_output_wait_ns. Preserved it across a prefill stopped at an armed interiorRetentionRole::Anchorcut when the prompt otherwise fit in one eligible prefill graph (including when the anchor coincides with the chosen chunk capacity or when aTerminalPrefillchunk clearsdeferred_prefillwhile landing on an interior anchor), while continuing to charge all measured token service truthfully inobserve_service. Foldedreadmitted_output_ns: Option<u64>intoset_arrivalso admission timestamp assignment has no call-order hazard. CarriedCarried::last_output_nsacross preemption and forced-reasoning readmission, recording host-published forced-close timestamps whenclose_reasoningadvancespublicationsand taking the latest of graph and host publication timestamps.scripts/scheduling_sim/utility.py, tests, docs: Mirrored the pure-decode formula inUtilityScheduler, added Rust and Python unit tests covering inertness,b_served * T_decscaling,Mixedexclusion, packed speculative feasibility and slot-order invariance, large finitedecode_age_priceoverflow/NaN safety, anchor-vs-message cut boundaries, multi-chunkTerminalPrefilldeferred-state anchor preservation, pipelined prefill projection, forced-reasoning-close readmission (with and without prior graph publication), balanced burst coalescing, and oversubscribed/small-batch stress bounds, and reconcileddocs/scheduling-theory.md,docs/scheduling-utility.md, anddocs/scheduling-runtime-design.md.Claimed benefit
Eliminates multi-second returning-prompt and prefill stalls behind active decode cohorts under
--scheduler-policy balancedwith zero configuration knobs, exact parity on standalone prefill/decode and--scheduler-policy throughput, and bounded behavior under oversubscribed (K > B) and small-batch (B = 1) bursts.Policy trade-off for maintainer sign-off: Enabling this default-ON under
--scheduler-policy balanced(decode_age_price = 0.1) trades higher background decode p99 gaps under heavy returning-prompt bursts (see tables below) for3–6×lower returning-prompt TTFT and+65%to+136%higher closed-loop agent throughput (with--scheduler-policy throughputremaining 100% inert).Supporting evidence & limitations
1. Paired zero-re-export SM121
flare runA/B —DeepSeek-V4.1-Flash-1017TP4 (4× DGX Spark GB10,0errors)policy,extra_work)a3c80e19)K=8bg (balanced,0.05)2,812∥3,392 ms1,025∥1,197 ms-63.5%∥-64.7%13.21∥168.1 / 334.1 ms21.77∥151.0 / 328.3 ms+64.8%∥ improvedK=16bg (balanced,0.05)5,265∥5,667 ms894∥1,117 ms-83.0%(5.9×) ∥-80.3%8.75∥211.1 / 368.4 ms18.00∥184.0 / 463.5 ms+105.7%∥-12.8%/+25.8%C=12simultaneous burst (balanced,0.05)5,524∥7,177 ms∥14.77 s∥183.9 ms5,018∥5,416 ms∥14.43 s∥158.3 ms-9.2%∥-24.5%∥-2.3%∥-13.9%K=16unsplit (balanced,0.0)4,656 ms∥10.123,427 ms∥11.72-26.4%∥+15.8%K=16throughputcontrol (throughput,0.05)3,659 ms∥10.01∥385.9 ms3,540 ms∥9.82∥378.1 ms2. Paired 4-visit ABAB returning-agent suite from #654 (
DeepSeek-V4.1-Flash-1017TP4,4× DGX Spark GB10,balanced,0invalid steps)K)stock1+2)treat1+2)closed(K=16, 8×8 agents, 60 s)turns/min) ∥ TTFT p50 ∥step_cost73(36.5/m) ∥6,493 ms∥0.840127(63.5/m,+74%) ∥1,933 ms∥0.611matched_p95:9.24 → 5.48 s,-27%bg cost/step)cold(K=0, 5 prompts)7.23 s∥6.86 s6.92 s∥6.55 ssingle(K=16, 1 return)3,301∥3,467 ms590∥602 ms(-82%)9,885vs10,062inc tok, gaps177/266/383vs175/265/368 ms); visit 2 hit a global ~16% ring slowdown across all workloadssustained(K=16, 12 short + 1× 28K)24/26∥12.33 s26/26∥7.64 s(-38%)24/26); #663 completed all26/26(short return TTFTs7.3–11.3 s → 1.6–3.9 s, visit 1 inc tok6,426 → 6,832)burst(K=16, 5 simultaneous returns)6,381∥252∥376∥426 ms1,668∥233∥493∥995 ms-74%TTFT, improvedgap_p95, visit 1 inc tok9,043 → 9,429), raising p99/max single gap3. Paired zero-re-export SM121
flare runA/B —Qwen3.8-Flash-NextTP2 (2× DGX Spark GB10, hybrid Mamba/GatedDeltaNet + Attention,0errors)policy)a3c80e19)8K/32K(balanced)3,635–3,687/3,731–3,7363,641–3,690/3,737–3,739+0.1%(parity)C=1..32(256 tok,balanced)C=1 / 4 / 8 / 16 / 32)55.6 / 127.7 / 186.0 / 254.0 / 331.054.3 / 129.6 / 198.1 / 256.3 / 345.0+6.5%K=16bg (balanced)turns/min)4,324 ms∥9(11.99/m)868 ms∥22(28.30/m)-79.9%(5.0×) ∥+136%237.1 ch/s∥334.5 ms234.1 ch/s∥410.5 ms-1.3%(parity) ∥+76 ms3× ~14K) +K=12bg (balanced)37.4 s∥150.4 ch/s∥1,192.8 ms35.9 s∥147.4 ch/s∥1,190.7 ms-4.2%∥ parity ∥ paritythroughputcontrol (K=16)2,540 ms∥10∥263.1 ch/s2,539 ms∥10∥266.4 ch/sGPU A/B reproduction commands and workload parameters
a3c80e19base vs PR branch):4× DGX Spark GB10, RoCE ring, zero re-export):/v1/chat/completionsstreaming client (temperature=0.0, seed42):K ∈ {8, 16}continuous background decoders (max_tokens=1024, ~300-token unique prompts) paired with a sequential 12-turn returning agent (~2.2K cached prefix + ~204 new tokens per turn,max_tokens=64,0.25sinter-turn pause); plusC=12simultaneous burst (~1Kprompt,max_tokens=128). Unsplit run sets[scheduler] checkpoint_extra_work_fraction = 0.0in config.benchmark_ready_prefill.py+analyze_ready_prefill.py) in alternating ABAB order (stock1 -> treat1 -> stock2 -> treat2):2× DGX Spark GB10, RoCE ring, zero re-export):/v1/chat/completionsstreaming (temperature=0.0): standalone prefill (8K,32K,max_tokens=1, 2 reps), batched decode (C ∈ {1, 4, 8, 16, 32},max_tokens=256), 45 s fixed-window returning agent (~2.5K base + ~200 tok/turn,max_tokens=64) besideK=16continuous background decoders counting streamed chunks live inside[t0, t0+45s],3× ~14Kcold prompts besideK=12decoders, and 35 sthroughputcontrol atK=16.4. Automated verification (
5bf90854)--release, Linux):helios(runtime-core,serverlib:1,783passed),flare(253passed),flare-cli(241passed,--test-threads=1),heliopausecargo check(0new warnings).pytest tests/test_scheduling*.py(830passed). Atage_price = 0.0,scheduling_simproduces21/21identical traces vs baseline. Underbalanced(age_price = 0.1), max TTFT and makespan improve onburst_eight,burst_eight_8k, andsixteen_prefills, with expected increases inmax_output_gap_ms(374 → 440,300 → 440,440 → 572 ms) anddecode_age_area_ms2(+16%to+94%) relative to baseline.verification/helios-lifecycle/check.py, TLA+ 1.7.4):10/10TLC models,8/8observed Rust trace checks (594,065transitions),12/12auxiliary conformance tests passed.FLARE_TEST_TEMPLATE_DIR(blocked locally by HTTP 401 on gated Hugging Face repo inprepare_templates.py),native-serving.yml,lifecycle --mutations, andkaniproofs were not run locally. Independent SM120 (4× RTX PRO 6000 Blackwell,--mtp-adaptive-verification) results solo and stacked with#660 + #661were reported by @FujitsuPolycom in the comments below.Discord: D-Rock