Skip to content

helios/scheduler: omit open-reasoning prompt-end Endpoint capture and prevent anchor-tail starvation - #68

Draft
FujitsuPolycom wants to merge 1 commit into
mainfrom
perf/helios-open-reasoning-endpoint-tail
Draft

FujitsuPolycom wants to merge 1 commit into
mainfrom
perf/helios-open-reasoning-endpoint-tail

Conversation

@FujitsuPolycom

Copy link
Copy Markdown
Owner

Why

Preserving the interior message boundary raw_anchor before an open-reasoning prompt suffix (output.content.start == OutputStart::Reasoning, such as <think>\n) keeps multi-turn prefix reuse intact when clients strip reasoning text from assistant history, but leaves two scheduling overheads on requests split at raw_anchor < prompt_tokens:

  1. Redundant prompt-end RetentionRole::Endpoint snapshot: checkpoint_selection_uncached (helios/src/scheduler/checkpoints.rs) still appended (request.prompt_tokens, RetentionRole::Endpoint) whenever prompt_tokens != anchor. Because the preserved anchor split charges zero extra work (split_ns = 0), that prompt-end Endpoint snapshot fit inside checkpoint_extra_work_fraction (default 0.05) and triggered a second GPU GraphKind::Snapshot launch immediately after the short reasoning-opening tail—even though OpenAI-compatible clients strip that suffix on subsequent turns so it cannot serve multi-turn reuse. A single-token generation (max_new_tokens == 1) could similarly capture prompt_tokens through allocate_terminal_capture.
  2. Indivisible anchor-tail starvation under active speculative decoders: Under active decoders, the remaining indivisible completing tail after raw_anchor (such as a 1-token <think> tail queued behind Snapshot(raw_anchor)) stalled behind 6 to 13 consecutive decode rounds before emitting first output due to two mechanisms:
    • coalescing_prefill_log_bonus (helios/src/scheduler/policy.rs, mirrored in scripts/scheduling_sim/utility.py) amortized the unlocked K -> K + m decode-batching surplus across initial_prefill even when the remaining prompt suffix was an indivisible completing tail (remaining <= min_cap, with no remaining interior cut or prefill limit), leaving a 1-token tail of a 1,349-token prompt with only 1/1349 of the coalescing surplus on the exact launch that enters decode.
    • preserves_first_output_wait (helios/src/scheduler/policy.rs) only preserved first_output_wait_ns on GraphKind::Prefill chunks without a checkpoint capture, resetting first_output_wait_ns when an intermediate age-priced chunk on a TERMINAL_PREFILL core resolved to GraphKind::TerminalPrefill within terminal_prefill_window of an interior anchor without capturing a checkpoint.

What

  • helios/src/scheduler/checkpoints.rs (+10/-1 prod LOC):
    • Gated the optional (request.prompt_tokens, RetentionRole::Endpoint) candidate in checkpoint_selection_uncached on self.budget_interior_anchor(request) so open-reasoning requests (preserve_message_anchor == true under nonzero checkpoint_extra_work_fraction) retain RetentionRole::Anchor at raw_anchor without emitting a prompt-end Endpoint snapshot at prompt_tokens. Non-preserved interior anchors and zero-fraction behavior remain unchanged.
    • Guarded allocate_terminal_capture to return Ok(None) when !self.budget_interior_anchor(request), checkpoint_anchor() < prompt_tokens, and consumed_tokens == prompt_tokens, while retaining terminal EOS capture once decoded tokens are consumed (consumed_tokens > prompt_tokens).
  • helios/src/scheduler/policy.rs (+27/-8 prod LOC) & scripts/scheduling_sim/utility.py (+10/-1 prod LOC):
    • Widened age_priced_chunk in preserves_first_output_wait from kind == GraphKind::Prefill to matches!(kind, GraphKind::Prefill | GraphKind::TerminalPrefill) so intermediate TerminalPrefill chunks without a checkpoint capture on single-graph prompts preserve first_output_wait_ns.
    • In coalescing_prefill_log_bonus and UtilityScheduler.prepare, when a queued prefiller's remaining prompt fits in the smallest eligible prepared prefill capacity (enumerated from loaded core metadata, including mixed prefill capacities when eligible) with no remaining interior checkpoint cut or prefill limit, amortize the coalescing surplus over remaining instead of initial_prefill so the single indivisible completing launch receives the full unlocked coalescing surplus while multi-chunk prefill sizing stays unchanged.
  • Tests & Docs:
    • Updated preserved_message_anchor_retains_interior_boundary_and_respects_zero_fraction in helios/src/scheduler/checkpoints.rs and added deterministic unit tests in helios/src/scheduler/policy_tests.rs and tests/test_scheduling_utility.py.
    • Synchronized present-state documentation in docs/core-design.md, docs/scheduling-runtime-design.md, and helios/README.md.
    • No CLI flags, Protobuf fields, unsafe code, hardcoded capacities, or model-core ABI changes; existing signed cores load and serve unchanged.

Result

Eliminates redundant prompt-end RetentionRole::Endpoint snapshots on open-reasoning prompts while preserving RetentionRole::Anchor multi-turn cache reuse at raw_anchor, and eliminates indivisible anchor-tail starvation under active speculative decoders.

Deterministic CPU scheduler traces modeling PolicyConfig::default() under SM120 TP4 timings (128..=16384 Prefill, 256..=16384 TerminalPrefill, Snapshot(1) = 1 ms, Speculative(B=1, W=4) = 9 ms, Speculative(B=2, W=4) = 10 ms, Speculative(B=4, W=4) = 12 ms):

Scenario Before (9cd0cfad) After (cee52475) Delta Prompt-end Endpoint snaps
1 active decoder, len=1349 (TerminalPrefill) 138.0 ms (8 dec rounds) 66.0 ms (0 dec rounds) -72.0 ms 1 -> 0
1 active decoder, len=1600 (TerminalPrefill) 108.0 ms (6 dec rounds) 54.0 ms (0 dec rounds) -54.0 ms 1 -> 0
2 active decoders, len=1349 (TerminalPrefill) 178.0 ms (12 dec rounds) 58.0 ms (0 dec rounds) -120.0 ms 1 -> 0
2 active decoders, len=1600 (TerminalPrefill) 174.0 ms (12 dec rounds) 54.0 ms (0 dec rounds) -120.0 ms 1 -> 0

Across all 22 named simulator workloads (including prefill_storm_gb10, sixteen_prefills, short_arrival, and continuous_decode), simulator metrics show zero regressions (0/22 diffs).

Evidence

Verified on clean git archive HEAD of candidate commit cee524750b4c836034e130db70929b2064ae63fc (base 9cd0cfadd167da2474db809bb49081df054583e0, clean git merge-tree):

  • 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::: 451 passed, 0 failed, 4 ignored.
  • python3 -m pytest -q tests/test_scheduling_utility.py tests/test_scheduling_sim.py tests/test_scheduling_learning_policy.py tests/preparation/test_core_boundary.py tests/test_design_review_hook.py: 477 passed.
  • python3 -m scripts.scheduling_sim.learning --preset screen --reference ttl --workers 4: completed 7 scenarios x 12 configurations x 16 seeds (1,344 runs) cleanly.
  • python3 verification/helios-lifecycle/check.py --jobs 4 --mutations: all 8 TLA+ models, observed-edge Rust conformance suites, and fault mutations passed.
  • Limitations: Live multi-GPU flare run A/B serving measurements on SM120 TP4 and GB10 TP4 are not included in this local CPU/simulator verification and remain required before opening or marking an upstream performance PR ready.

Discord: Dooner

… prevent anchor-tail starvation

Why

Preserving the interior message boundary `raw_anchor` before an open-reasoning
prompt suffix (`output.content.start == OutputStart::Reasoning`, such as
`<think>\n`) keeps multi-turn prefix reuse intact when clients strip reasoning
text from assistant history, but leaves two scheduling overheads on requests
split at `raw_anchor < prompt_tokens`:

1. `checkpoint_selection_uncached` in `helios/src/scheduler/checkpoints.rs`
   still appended `(request.prompt_tokens, RetentionRole::Endpoint)` whenever
   `prompt_tokens != anchor`. Because the preserved anchor split charges zero
   extra work (`split_ns = 0`), that prompt-end `Endpoint` snapshot almost
   always fit inside `checkpoint_extra_work_fraction` (default `0.05`) and
   triggered a second GPU `GraphKind::Snapshot` launch immediately after the
   short reasoning-opening tail—even though OpenAI-compatible clients strip
   that suffix on subsequent turns so it cannot serve multi-turn reuse. A
   single-token generation (`max_new_tokens == 1`) could similarly capture
   `prompt_tokens` through `allocate_terminal_capture`.
2. Under active speculative decoders, the remaining indivisible completing tail
   after `raw_anchor` (such as a 1-token `<think>` tail queued behind
   `Snapshot(raw_anchor)`) stalled behind 6 to 13 consecutive decode rounds
   before emitting first output. Two scheduler mechanisms caused that stall:
   - `coalescing_prefill_log_bonus` (`helios/src/scheduler/policy.rs`, mirrored
     in `scripts/scheduling_sim/utility.py`) amortized the unlocked `K -> K + m`
     decode-batching surplus across `initial_prefill` even when the remaining
     prompt suffix was an indivisible completing tail (`remaining <= min_cap`,
     no remaining interior cut or prefill limit), leaving a 1-token tail of a
     1,349-token prompt with only `1/1349` of the coalescing surplus on the
     exact launch that enters decode.
   - `preserves_first_output_wait` (`helios/src/scheduler/policy.rs`) only
     preserved `first_output_wait_ns` on `GraphKind::Prefill` chunks without a
     checkpoint capture, resetting `first_output_wait_ns` when an intermediate
     age-priced chunk on a `TERMINAL_PREFILL` core resolved to
     `GraphKind::TerminalPrefill` within `terminal_prefill_window` of an
     interior anchor without capturing a checkpoint.

What

- `helios/src/scheduler/checkpoints.rs`:
  - Gated the optional `(request.prompt_tokens, RetentionRole::Endpoint)`
    candidate in `checkpoint_selection_uncached` on
    `self.budget_interior_anchor(request)` so open-reasoning requests
    (`preserve_message_anchor == true` under nonzero
    `checkpoint_extra_work_fraction`) retain `RetentionRole::Anchor` at
    `raw_anchor` without emitting a prompt-end `Endpoint` snapshot at
    `prompt_tokens`. Non-preserved interior anchors and zero-fraction behavior
    remain unchanged.
  - Guarded `allocate_terminal_capture` to return `Ok(None)` when
    `!self.budget_interior_anchor(request)`, `checkpoint_anchor() < prompt_tokens`,
    and `consumed_tokens == prompt_tokens`, while retaining terminal EOS
    capture once decoded tokens are consumed (`consumed_tokens > prompt_tokens`).
- `helios/src/scheduler/policy.rs` and `scripts/scheduling_sim/utility.py`:
  - Widened `age_priced_chunk` in `preserves_first_output_wait` from
    `kind == GraphKind::Prefill` to
    `matches!(kind, GraphKind::Prefill | GraphKind::TerminalPrefill)` so
    intermediate `TerminalPrefill` chunks without a checkpoint capture on
    single-graph prompts preserve `first_output_wait_ns`.
  - In `coalescing_prefill_log_bonus` and `UtilityScheduler.prepare`, when a
    queued prefiller's remaining prompt fits in the smallest eligible prepared
    prefill capacity (enumerated from loaded core metadata, including mixed
    prefill capacities when eligible) with no remaining interior checkpoint cut
    or prefill limit, amortize the coalescing surplus over `remaining` instead
    of `initial_prefill` so the single indivisible completing launch receives
    the full unlocked coalescing surplus while multi-chunk prefill sizing stays
    unchanged.
- Tests and present-state docs:
  - Updated `preserved_message_anchor_retains_interior_boundary_and_respects_zero_fraction`
    in `helios/src/scheduler/checkpoints.rs` and added deterministic unit tests
    in `helios/src/scheduler/policy_tests.rs` and
    `tests/test_scheduling_utility.py`.
  - Synchronized `docs/core-design.md`, `docs/scheduling-runtime-design.md`, and
    `helios/README.md`.
  - No CLI flags, Protobuf fields, `unsafe` code, hardcoded capacities, or
    model-core ABI changes; existing signed cores load and serve unchanged.

Result

Eliminates redundant prompt-end `RetentionRole::Endpoint` snapshots on
open-reasoning prompts while preserving `RetentionRole::Anchor` multi-turn
cache reuse at `raw_anchor`, and removes indivisible anchor-tail starvation
under active speculative decoders. In deterministic CPU scheduler traces
modeling a 1,349-token prompt with `raw_anchor = 1348` and `PolicyConfig::default()`
under realistic SM120 TP4 timings (`128..=16384` `Prefill` / `256..=16384`
`TerminalPrefill`, `Snapshot(1) = 1 ms`, `Speculative(B=1, W=4) = 9 ms`,
`Speculative(B=2, W=4) = 10 ms`):

| Scenario | Before (`NVIDIA#697`) | After | Delta | Prompt-end `Endpoint` snaps |
|---|---:|---:|---:|---:|
| 1 active decoder, `len=1349` (`TerminalPrefill`) | 138.0 ms (`8` dec rounds) | 66.0 ms (`0` dec rounds) | -72.0 ms | 1 -> 0 |
| 1 active decoder, `len=1600` (`TerminalPrefill`) | 108.0 ms (`6` dec rounds) | 54.0 ms (`0` dec rounds) | -54.0 ms | 1 -> 0 |
| 2 active decoders, `len=1349` (`TerminalPrefill`) | 178.0 ms (`12` dec rounds) | 58.0 ms (`0` dec rounds) | -120.0 ms | 1 -> 0 |
| 2 active decoders, `len=1600` (`TerminalPrefill`) | 174.0 ms (`12` dec rounds) | 54.0 ms (`0` dec rounds) | -120.0 ms | 1 -> 0 |

Across all 22 named simulator workloads (including `prefill_storm_gb10`,
`sixteen_prefills`, `short_arrival`, and `continuous_decode`), simulator metrics
show zero regressions (`0/22` diffs).

Evidence

Verified on clean `git archive HEAD` of this commit:
- `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::`: 451 passed, 0 failed, 4 ignored.
- `python3 -m pytest -q tests/test_scheduling_utility.py tests/test_scheduling_sim.py tests/test_scheduling_learning_policy.py tests/preparation/test_core_boundary.py tests/test_design_review_hook.py`: 477 passed.
- `python3 -m scripts.scheduling_sim.learning --preset screen --reference ttl --workers 4`: completed 7 scenarios x 12 configurations x 16 seeds (1,344 runs) cleanly.
- `python3 verification/helios-lifecycle/check.py --jobs 4 --mutations`: all 8 TLA+ models, observed-edge Rust conformance suites, and fault mutations passed.
- Limitations: live multi-GPU `flare run` A/B serving measurements on SM120 TP4 and GB10 TP4 are not included in this local CPU/simulator verification and remain required before marking an upstream performance PR ready.

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