Skip to content

helios/scheduler: multi-chunk heavy prefill entitlement share exchange - #67

Draft
FujitsuPolycom wants to merge 1 commit into
mainfrom
perf/helios-heavy-prefill-swap
Draft

FujitsuPolycom wants to merge 1 commit into
mainfrom
perf/helios-heavy-prefill-swap

Conversation

@FujitsuPolycom

Copy link
Copy Markdown
Owner

Why

Under concurrent decode and multi-chunk prefill load with positive decode-age pricing (--scheduler-policy balanced), ServicePrice::observe credits each intermediate prefill chunk, dropping the executing prompt's normalized token price below untouched peers. Competing multi-chunk prompts therefore advance in lockstep instead of finishing sequentially and freeing KV pages earlier.

Recording planned entitlement share swaps at submission without mutating stored prices, projecting them across queued submissions, and applying the exchange only at validated completion serializes multi-chunk prompts by aged remaining time while conserving aggregate normalized prefill entitlement relative to active decoders and leaving stored prices unchanged on rejected commits, error completions, or zero-duration completions.

What

  • Completion-only share swap (helios/src/scheduler.rs, policy.rs, service.rs, utility.rs; +230 net Rust prod LOC, +258/-28; zero CLI, config, ABI, unsafe, or lock changes; coalescing_prefill_log_bonus untouched from 9cd0cfad):
    • Added ServicePrice::{log_normalized_share, swap_normalized_share} in utility.rs.
    • Added best_prefill_chunk and stack-allocated heavy_prefill_donors in policy.rs, active only when non-terminal active decoders exist (excluding retiring Snapshot requests), token_fairness > 0, decode_age_price > 0 (inactive under --scheduler-policy throughput), and >= 2 non-terminal, non-prompt_logprobs prefills exceed single-step pure-prefill capacity (remaining > prefill_chunk_size, including deferred intermediate chunks on TerminalPrefill cores; single-chunk prefills excluded even when c_max < prefill_chunk_size).
    • Wired projected_services in service.rs and lane_values in policy.rs so planning prices paired recipients at their donor's normalized share rebased to the recipient's feasible token rate and projects queued swaps before queued observations.
    • Added Submission::prefill_share_swap: Option<(RequestHandle, RequestHandle)> in scheduler.rs; service_participants records non-self pairs read-only at commit, and observe_service applies swap_normalized_share only after positive observed GPU duration, non-error status, positive committed recipient tokens, and matching live handles.
  • Simulator, docs & tests:
    • Mirrored multi-chunk share exchange in scripts/scheduling_sim/utility.py (+101 net Python prod LOC, +102/-1) with log-space aged urgency, weighted log_price conservation, pure-prefill pref_best filtering, reference is not None / age_price > 0 / rate_history == "service" guards, and validated observe().
    • Added 7 Rust scheduler tests in helios/src/scheduler/policy_tests.rs (+663 LOC) and 3 Python tests in tests/test_scheduling_utility.py (+228/-3 LOC; updated test_gb10_prefill_storm_decode_age_pricing_avoids_one_second_stalls so non-terminal contended chunks assert <= 4096 and serialized finishing chunks assert <= 8192).
    • Updated present-state docs in docs/scheduling-runtime-design.md, docs/scheduling-theory.md, docs/scheduling-utility.md, and helios/README.md (+109/-25 LOC).

Result

Measured in scripts/scheduling_sim (Value(64), UtilityConfig(16, 4, 100, 0.1, "service")) incrementally atop 9cd0cfad:

Workload (balanced ∥ throughput) Before (9cd0cfad) After (4fd94213) Trade-off ∥ Notes
21 standard (std ∥ mixed) Baseline 0/21 changed 0 regressions; throughput unchanged
2 dec + 2x16k (std) [593.1, 678.4] ms [383.9, 857.2] ms 1st -35.3%; mean -2.4%; gap 217.3 ms; out -0.9%; age +5.4%
2 dec + 2x16k (mixed) [703.1, 726.7] ms [443.5, 743.1] ms 1st -36.9%; mean -17.0%; gap 145.0 ms; out -1.8%; age +8.8%
4 dec + 4x16k (std) [1436.0..1637.3] ms [788.0..2200.6] ms 1st -45.1%; mean -3.7%; gap 213.0->226.6 ms; out -2.4%; age +7.9%
4 dec + 4x16k (mixed) [1155.0..1418.4] ms [491.5..1587.8] ms 1st -57.4%; mean -21.2%; gap 114.7 ms; out -1.5%; age +7.7%
prefill_storm_gb10 (gb10_catalog) [20733..24518] ms [13758..25214] ms 1st -33.6%; mean -11.9%; gap 642.0->795.0 ms (< 800 ms); non-terminal <= 4096

SM120/SM121 flare run GPU A/B serving measurements are pending before marking Ready or opening upstream.

Evidence

Verified on clean git archive of 4fd94213facffa123911ee69702cc8b95548dfce (tree 1b61240da3ce714d089a245764b06cbc7b14c9de) atop 9cd0cfadd167da2474db809bb49081df054583e0:

  • Merge-tree: git merge-tree --write-tree 9cd0cfad 4fd94213 passed with 0 conflicts.
  • Rust check & tests: RUSTFLAGS="-D warnings" cargo +1.97.1 check --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --tests passed with 0 warnings; cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib scheduler:: passed (456 passed, 0 failed, 4 ignored).
  • Python suite: python3 -m pytest tests/test_scheduling_utility.py tests/test_scheduling_sim.py tests/test_scheduling_learning_policy.py tests/test_scheduling_learning_experiments.py tests/preparation/test_core_boundary.py -q passed (515 passed).
  • Formal & mutations: python3 verification/helios-lifecycle/check.py --tlc-jar /home/cody/tools/tlaplus-1.7.4/tla2tools.jar --jobs 4 --mutations passed all TLC models, 8/8 observed Rust trace conformance models (621,389 edges), 26/26 Rust mutations, and 13/13 TLA+ mutations.
  • Limits: Target-hardware SM120/SM121 flare run GPU A/B pending; cargo-kani and learning.py --preset validate unrun (cost.rs and learning_policy.py unchanged).

Discord: Dooner

Why

Under concurrent decode and multi-chunk prefill load with positive decode-age
pricing (`--scheduler-policy balanced`), `ServicePrice::observe` credits each
intermediate prefill chunk, dropping the executing prompt's normalized token
price below untouched peers. Competing multi-chunk prompts therefore advance in
lockstep instead of finishing sequentially and freeing KV pages earlier.

Recording planned entitlement share swaps at submission without mutating stored
prices, projecting them across queued submissions, and applying the exchange
only at validated completion serializes multi-chunk prompts by aged remaining
time while conserving aggregate normalized prefill entitlement relative to
active decoders and leaving stored prices unchanged on rejected commits, error
completions, or zero-duration completions.

What

- Native scheduler (`helios/src/scheduler.rs`, `policy.rs`, `service.rs`,
  `utility.rs`; `+230` net Rust prod LOC, `+258/-28`; zero CLI, config, ABI,
  `unsafe`, or lock changes; `coalescing_prefill_log_bonus` untouched):
  - Added `ServicePrice::log_normalized_share` and
    `ServicePrice::swap_normalized_share` in `utility.rs`.
  - Added `best_prefill_chunk` and stack-allocated `heavy_prefill_donors` in
    `policy.rs`, active only when non-terminal active 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 single-step pure-prefill
    capacity (`remaining > prefill_chunk_size`, including deferred intermediate
    chunks on `TerminalPrefill` cores; single-chunk prefills excluded even when
    the peak-throughput chunk `c_max < prefill_chunk_size`).
  - Wired `projected_services` in `service.rs` and `lane_values` in `policy.rs`
    so planning prices paired recipients at their donor's normalized share
    rebased to the recipient's feasible token rate and projects queued swaps
    before queued frame observations.
  - Added `Submission::prefill_share_swap: Option<(RequestHandle, RequestHandle)>`
    in `scheduler.rs`; `service_participants` records non-self pairs read-only
    at commit, and `observe_service` applies `swap_normalized_share` only after
    positive observed GPU duration, non-error status, positive committed
    recipient tokens, and matching live handles.
- Simulator, tests, and documentation:
  - Mirrored multi-chunk share exchange in `scripts/scheduling_sim/utility.py`
    (`+101` net Python prod LOC, `+102/-1`) with log-space aged urgency,
    weighted `log_price` conservation, pure-prefill `pref_best` filtering,
    `reference is not None` / `age_price > 0` / `rate_history == "service"`
    guards, and validated `observe()`.
  - Added 7 Rust scheduler unit tests in `helios/src/scheduler/policy_tests.rs`
    and 3 Python simulator/parity tests in `tests/test_scheduling_utility.py`;
    updated `test_gb10_prefill_storm_decode_age_pricing_avoids_one_second_stalls`
    to verify non-terminal contended chunks stay `<= 4096` and terminal
    finishing chunks stay `<= 8192` now that serialized heavy prompts complete
    prefill before the first interactive request finishes.
  - Updated present-state specifications in `docs/scheduling-runtime-design.md`,
    `docs/scheduling-theory.md`, `docs/scheduling-utility.md`, and
    `helios/README.md`.

Result

Measured in `scripts/scheduling_sim` (`Value(64)`, `UtilityConfig(16, 4, 100,
0.1, "service")` vs `9cd0cfad` baseline):

- 21 standard workloads (`std` and `mixed`, `balanced` and `throughput`):
  `0/21` diffs (`0` regressions; `throughput` unchanged).
- `2 dec + 2x16k` (`std`): heavy TTFT `[593.1, 678.4]` -> `[383.9, 857.2]` ms
  (first `-35.3%`, mean `-2.4%`, max output gap `217.3 -> 217.3` ms, output
  `-0.9%`, decode age `+5.4%`).
- `2 dec + 2x16k` (`mixed`): heavy TTFT `[703.1, 726.7]` -> `[443.5, 743.1]` ms
  (first `-36.9%`, mean `-17.0%`, max output gap `145.0 -> 145.0` ms, output
  `-1.8%`, decode age `+8.8%`).
- `4 dec + 4x16k` (`std`): heavy TTFT `[1436.0..1637.3]` -> `[788.0..2200.6]` ms
  (first `-45.1%`, mean `-3.7%`, max output gap `213.0 -> 226.6` ms, output
  `-2.4%`, decode age `+7.9%`).
- `4 dec + 4x16k` (`mixed`): heavy TTFT `[1155.0..1418.4]` -> `[491.5..1587.8]`
  ms (first `-57.4%`, mean `-21.2%`, max output gap `114.7 -> 114.7` ms, output
  `-1.5%`, decode age `+7.7%`).
- `prefill_storm_gb10` (`gb10_catalog`, 12 interactive + 4x24k..30k heavy):
  heavy TTFT `[20733..24518]` (mean `23566`) -> `[13758..25214]` ms (first
  `-33.6%`, mean `-11.9%`), max output gap `642.0 -> 795.0` ms (`< 800` ms vs
  `> 1000` ms throughput), all non-terminal contended prefill chunks `<= 4096`.

Evidence

- `RUSTFLAGS="-D warnings" cargo +1.97.1 check --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --tests`: passed with `0` warnings.
- `cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib scheduler::`: `456 passed, 0 failed, 4 ignored`.
- `python3 -m pytest tests/test_scheduling_utility.py tests/test_scheduling_sim.py tests/test_scheduling_learning_policy.py tests/test_scheduling_learning_experiments.py tests/preparation/test_core_boundary.py -q`: `515 passed`.
- `python3 verification/helios-lifecycle/check.py --tlc-jar /home/cody/tools/tlaplus-1.7.4/tla2tools.jar --jobs 4 --mutations`: passed all TLC models, `8/8` observed Rust trace conformance models (`621,389` edges), `26/26` Rust mutations, and `13/13` TLA+ mutations.
- Limitations: target-hardware `flare run` GPU A/B serving measurements on SM120/SM121 have not yet been run on this commit; `cargo-kani` and `learning.py --preset validate` were not run (`cost.rs` and `learning_policy.py` unchanged).

Discord: Dooner

Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant