Skip to content

helios/scheduler: price first-output waiting age on incumbent decode rounds - #662

Closed
flare-autobot wants to merge 1 commit into
NVIDIA:mainfrom
flare-autobot:feat/knob-free-first-output-scheduling
Closed

flare-autobot wants to merge 1 commit into
NVIDIA:mainfrom
flare-autobot:feat/knob-free-first-output-scheduling

Conversation

@flare-autobot

Copy link
Copy Markdown
Collaborator

Draft PR for early design feedback — opened immediately after writing the prototype and before running Linux Rust tests, Python simulator regression suites, TLA+ checks, or served GPU A/B benchmarks. See Open items before marking ready for review below.

Why

Under --scheduler-policy balanced (decode_age_price = 0.1), active decoding streams accumulate waiting-age utility scaled by their batch-feasible excluded wait (decode_age_price * reference_delivery_ms * (age_ms + horizon_ms)), while prompts waiting for their first output accumulate no waiting-age utility.

When a returning prompt or newly arrived prompt competes against a large active decode cohort on a model without mixed prefill-decode graphs (for example, 8 to 31 active decoders on DeepSeek-V4.1-Flash), the prompt must wait multiple seconds for its token-service fairness price (ServicePrice) to ramp high enough to displace a full-batch decode round. When an interior conversation-anchor checkpoint splits a single-chunk prompt (for example, 204 uncached tokens cut at 202 into a main chunk, a boundary Snapshot, and a 2-token tail), the prompt suffers a double stall: the main chunk charges ServicePrice, then resets progress so the Snapshot and 2-token tail stall again behind the decode cohort.

This problem is complementary to two other open scheduler changes:

Why this formulation (decode_age_price * (b_served * T_dec) * age_ms * frac)

One fastest incumbent decode round advances b_served = min(B, K_dec) active decoding streams in duration T_dec ms (b_served * T_dec stream-ms of decode progress). Scaling a waiting prompt's first-output age credit by the existing decode_age_price coefficient and b_served * T_dec:

first_output_credit = decode_age_price * (b_served * T_dec) * age_ms * frac
  1. Zero new knobs: Reuses PolicyConfig::decode_age_price (0.1 in balanced, 0.0 in throughput). Remains 100% inert under --scheduler-policy throughput, when no measured decoder is active (K_dec == 0), and on score-only prompt_logprobs requests (max_new_tokens == 0).
  2. Bounded under oversubscription and small-batch bursts: Depends strictly on incumbent decoders' served batch b_served = min(B, K_dec) rather than total resident concurrency K_total or K_total / b. Queued prompts never amplify each other, and K > B or B = 1 bursts cannot trigger runaway consecutive prefills.
  3. Chunk-size neutral and free of harmonic amplification: Uses pure waiting age age_ms (not age_ms + horizon_ms, so dividing by duration prefers faster graphs and never distorts zero-age chunk choice), frac = 1.0 on steps that finish the prompt, and fixed-denominator frac = work / initial_prefill on non-finishing chunks (linear in work, matching coalescing amortization so non-finishing chunks never favor smaller inefficient capacities). Omitted from the common waiting-cost penalty sum T / 2 * sum(age_price) so waiting prompts never artificially shorten prefill or decode chunks.
  4. No ServicePrice exemption: All measured token service remains charged truthfully in observe_service. To eliminate the double stall across a forced interior anchor cut without leaking into throughput or zero-decoder schedules, only first_output_wait_ns is preserved when a prefill stops strictly at an armed RetentionRole::Anchor boundary on a prompt that otherwise fit in a single eligible prefill graph.

What changed (before / after)

Total prototype diff: 7 files (+374 / -16, ~105 net production Rust lines across helios, 0 new CLI/config flags, 0 new graph kinds, 0 Protobuf/ABI changes).

  • helios/src/scheduler/service.rs
    • Before: delivery_references returned only per-slot DeliveryReference.
    • After: Added delivery_references_and_decode_batch, returning the same per-slot references plus the incumbent decode cohort's fastest round work-time b_served * T_dec (in stream-ms, or 0.0 when no measured Decode/Speculative stream is active). Reuses the existing single pass with no extra cost scans.
  • helios/src/scheduler/utility.rs & helios/src/scheduler/policy.rs
    • Before: LaneValue::prefill scored prefill lanes solely from token service value, intrinsic token value, and coalescing bonus; waiting prompts received no waiting-age credit.
    • After: Added LaneValue::first_output_value and LaneValue::prefill_within. In lane_values, non-terminal prompts with consumed_tokens < prompt_tokens, max_new_tokens > 0, decode_age_price > 0.0, and incumbent_decode_batch_ms > 0.0 compute age_ms from first_output_wait_ns (projected across any pipelined in-flight prefill submission's expected_finish_ns) and receive unit * decode_age_price * incumbent_decode_batch_ms * age_ms. Applied in lane_value_for_tokens_within and next_progress so prerequisites (Init, Restore, Vision, Snapshot) and two-stage continuations carry first-output urgency automatically without adding to the common waiting-cost sum.
  • helios/src/scheduler.rs & helios/src/server/runtime.rs
    • Before: RequestAccounting tracked arrival_ns and last_progress_ns; any prefill completion advanced last_progress_ns, and readmitted requests only carried arrival_ns.
    • After: Added RequestAccounting::first_output_wait_ns and RequestScheduler::set_first_output_wait. On completion of a prefill stopped strictly at an armed RetentionRole::Anchor cut when fits_single_prefill_from(request, start) holds, first_output_wait_ns is preserved while last_progress_ns and ServicePrice update normally. runtime.rs carries Carried::last_output_ns across preemption and forced-reasoning readmission so readmitted streams age from their most recent output publication rather than stale original arrival time.
  • scripts/scheduling_sim/utility.py & helios/src/scheduler/policy_tests.rs
    • Mirrored the same zero-knob formula in UtilityScheduler and added four unit tests covering policy/zero-decoder/score-only inertness, b_served * T_dec scaling and chunk fraction behavior, anchor-cut wait-clock preservation without ServicePrice exemption, and readmission wait clamping.

Model core compatibility: No Protobuf, ABI, or prepared-graph changes. Previously exported model cores load and serve without re-export.

Expected benefit (offline simulator projections)

Projected behavior from an offline Python simulator calibrated to origin/main prefill-rebase semantics (decode_age_price = 0.1, DeepSeek-V4.1-Flash timing table plus adversarial oversubscribed and small-batch stress cases). These are offline simulator projections, not yet measured on the compiled Rust prototype or GPU hardware:

Scenario Baseline (origin/main model) Projected with this formula Notes
Returning prompt (202+2 anchor split), K=8 decoders 1,204 ms TTFT (max_gap 66.8 ms) 432 ms TTFT (max_gap 60.1 ms) 2.8× lower TTFT
Returning prompt (202+2 anchor split), K=16 decoders 2,132 ms TTFT (18,117 dec tok) 482 ms TTFT (18,169 dec tok) 4.4× lower TTFT
Returning prompt (202+2 anchor split), K=31 decoders 3,377 ms TTFT 528 ms TTFT 6.4× lower TTFT
Oversubscribed burst (32 dec / B=4 / 16 prompts) p99 147 ms, max 158 ms, TTFT 3,026 ms p99 158 ms, max 169 ms, TTFT 2,747 ms consec_pre = 1, no runaway starvation
Small-batch burst (4 dec / B=1 / 24 prompts) p99 305 ms, max 307 ms, consec_pre 7 p99 305 ms, max 307 ms, consec_pre 7 Exact parity
--scheduler-policy throughput (decode_age_price = 0.0) Baseline Identical Formula evaluates to 0.0

Supporting evidence and limitations

  • Completed so far: Prototype implementation committed cleanly (05d6b602) on origin/main (a3c80e19) with design review and DCO trailers.
  • Not yet run (disclosed explicitly): No Linux Rust build or unit tests, no Python simulator regression suite, no TLA+ conformance checks, and no served GPU A/B benchmarks have been executed on this branch yet.

Open items before marking ready for review

  1. Design feedback requested from reviewers:
  2. CPU verification (Linux): Run cargo test --locked --release across helios (--features runtime-core,server), flare, flare-cli, and heliopause check; fix any warnings or edge cases.
  3. Python simulator & regression suite: Run pytest tests/test_scheduling*.py and scripts/scheduling_sim/workloads.py across all workloads, including throughput parity (0.0) and oversubscribed/small-batch stress cases.
  4. Served GPU A/B benchmarks: Run paired flare run A/B benchmarks against origin/main (returning-agent + concurrent decode workload on exported cores, plus interaction check with helios/scheduler: budget interior conversation-anchor splits against checkpoint_extra_work_fraction #660/helios/scheduler: explore smaller prefill chunks under active age-priced streams #661 if merged).
  5. Release gate: Update docs/scheduling-theory.md, docs/scheduling-utility.md, and docs/scheduling-runtime-design.md, and run verification/helios-lifecycle/check.py (TLA+ TLC + observed Rust traces + auxiliary conformance tests) before converting from draft to ready.

Discord: flare-autobot

…rounds

Under the balanced scheduler policy (`decode_age_price = 0.1`), active
decoding streams accumulate waiting-age utility scaled by their batch-feasible
reference wait while waiting prompts accumulate none. When a returning or
newly arrived prompt competes against a large active decode cohort (for
example, 8 to 31 concurrent decoders on models without mixed prefill-decode
graphs), the prompt must wait for its token-service fairness price to ramp up
over multiple seconds before winning a prefill slot. If 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, or `ServicePrice` exemptions:

- `helios/src/scheduler/service.rs`: Extend delivery-reference selection with
  `delivery_references_and_decode_batch`, returning the incumbent decode
  cohort's fastest round work-time `b_served * T_dec` (in stream-ms, or `0.0`
  when no measured decoder is active). Using `b_served = min(B, K_dec)` from
  incumbent decoders only keeps waiting prompts from amplifying each other
  under oversubscribed bursts (`K > B`) or small-batch catalogs.
- `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`, where `frac = 1.0`
  when the step finishes the prompt and `frac = work / initial_prefill` on
  non-finishing chunks. The credit is carried through prerequisite and
  two-stage continuation scoring (`Init`, `Restore`, `Vision`, `Snapshot`)
  without adding waiting prompts to the common waiting-cost penalty sum.
- `helios/src/scheduler.rs` and `helios/src/server/runtime.rs`: Track
  `RequestAccounting::first_output_wait_ns`. Preserve it across a prefill
  chunk stopped strictly by an armed `RetentionRole::Anchor` cut when the
  prompt otherwise fit in a single eligible prefill graph, while continuing
  to charge all measured token service truthfully in `observe_service`. Carry
  `last_output_ns` across preemption and forced-reasoning readmission so
  readmitted streams age from their most recent output rather than stale
  original arrival time.
- `scripts/scheduling_sim/utility.py` and `helios/src/scheduler/policy_tests.rs`:
  Mirror the zero-knob formula in `UtilityScheduler` and add unit tests for
  policy/zero-decoder/score-only inertness, `b_served * T_dec` scaling,
  anchor-cut wait-clock preservation, and readmission wait clamping.

Expected benefit:
- Under `--scheduler-policy balanced`, reduce returning-prompt TTFT behind
  8 to 31 active decoders from multi-second stalls to sub-second latency while
  keeping incumbent decode gap distributions bounded under oversubscribed and
  small-batch bursts.
- Under `--scheduler-policy throughput` (`decode_age_price = 0.0`), zero-decoder
  workloads, and score-only `prompt_logprobs` (`max_new_tokens = 0`), remain
  completely inert. All previously exported model cores load and serve
  unchanged.

Supporting evidence and limitations:
- Prototype commit prepared for early design review prior to running the
  Linux Rust test suite, Python simulator regression suite, TLA+ conformance
  checks, and served GPU A/B benchmarks. All offline simulator projections
  and full verification runs remain to be executed and reported before
  marking ready for review.

Signed-off-by: yatesdr <6937857+yatesdr@users.noreply.github.com>
Design-Signed-Off-By: yatesdr; design-review=2e5b
@flare-autobot flare-autobot added area:scheduling Request scheduling, fairness, batching, and speculative-width selection. enhancement New feature or request performance Performance, latency, throughput, or memory-efficiency investigation or improvement. labels Dec 1, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator Author

Closing duplicate draft opened under the wrong account; reopening under yatesdr.

@flare-autobot
flare-autobot deleted the feat/knob-free-first-output-scheduling branch December 1, 2026 19:41
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. enhancement New feature or request performance Performance, latency, throughput, or memory-efficiency investigation or improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants