Repository navigation
helios/scheduler: omit open-reasoning prompt-end Endpoint capture and prevent anchor-tail starvation - #68
Draft
FujitsuPolycom wants to merge 1 commit into
Draft
helios/scheduler: omit open-reasoning prompt-end Endpoint capture and prevent anchor-tail starvation#68FujitsuPolycom wants to merge 1 commit into
FujitsuPolycom wants to merge 1 commit into
Conversation
… 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Preserving the interior message boundary
raw_anchorbefore 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 atraw_anchor < prompt_tokens:RetentionRole::Endpointsnapshot:checkpoint_selection_uncached(helios/src/scheduler/checkpoints.rs) still appended(request.prompt_tokens, RetentionRole::Endpoint)wheneverprompt_tokens != anchor. Because the preserved anchor split charges zero extra work (split_ns = 0), that prompt-endEndpointsnapshot fit insidecheckpoint_extra_work_fraction(default0.05) and triggered a second GPUGraphKind::Snapshotlaunch 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 captureprompt_tokensthroughallocate_terminal_capture.raw_anchor(such as a 1-token<think>tail queued behindSnapshot(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 inscripts/scheduling_sim/utility.py) amortized the unlockedK -> K + mdecode-batching surplus acrossinitial_prefilleven 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 only1/1349of the coalescing surplus on the exact launch that enters decode.preserves_first_output_wait(helios/src/scheduler/policy.rs) only preservedfirst_output_wait_nsonGraphKind::Prefillchunks without a checkpoint capture, resettingfirst_output_wait_nswhen an intermediate age-priced chunk on aTERMINAL_PREFILLcore resolved toGraphKind::TerminalPrefillwithinterminal_prefill_windowof an interior anchor without capturing a checkpoint.What
helios/src/scheduler/checkpoints.rs(+10/-1 prod LOC):(request.prompt_tokens, RetentionRole::Endpoint)candidate incheckpoint_selection_uncachedonself.budget_interior_anchor(request)so open-reasoning requests (preserve_message_anchor == trueunder nonzerocheckpoint_extra_work_fraction) retainRetentionRole::Anchoratraw_anchorwithout emitting a prompt-endEndpointsnapshot atprompt_tokens. Non-preserved interior anchors and zero-fraction behavior remain unchanged.allocate_terminal_captureto returnOk(None)when!self.budget_interior_anchor(request),checkpoint_anchor() < prompt_tokens, andconsumed_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):age_priced_chunkinpreserves_first_output_waitfromkind == GraphKind::Prefilltomatches!(kind, GraphKind::Prefill | GraphKind::TerminalPrefill)so intermediateTerminalPrefillchunks without a checkpoint capture on single-graph prompts preservefirst_output_wait_ns.coalescing_prefill_log_bonusandUtilityScheduler.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 overremaininginstead ofinitial_prefillso the single indivisible completing launch receives the full unlocked coalescing surplus while multi-chunk prefill sizing stays unchanged.preserved_message_anchor_retains_interior_boundary_and_respects_zero_fractioninhelios/src/scheduler/checkpoints.rsand added deterministic unit tests inhelios/src/scheduler/policy_tests.rsandtests/test_scheduling_utility.py.docs/core-design.md,docs/scheduling-runtime-design.md, andhelios/README.md.unsafecode, hardcoded capacities, or model-core ABI changes; existing signed cores load and serve unchanged.Result
Eliminates redundant prompt-end
RetentionRole::Endpointsnapshots on open-reasoning prompts while preservingRetentionRole::Anchormulti-turn cache reuse atraw_anchor, and eliminates indivisible anchor-tail starvation under active speculative decoders.Deterministic CPU scheduler traces modeling
PolicyConfig::default()under SM120 TP4 timings (128..=16384Prefill,256..=16384TerminalPrefill,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):9cd0cfad)cee52475)Endpointsnapslen=1349(TerminalPrefill)8dec rounds)0dec rounds)len=1600(TerminalPrefill)6dec rounds)0dec rounds)len=1349(TerminalPrefill)12dec rounds)0dec rounds)len=1600(TerminalPrefill)12dec rounds)0dec rounds)Across all 22 named simulator workloads (including
prefill_storm_gb10,sixteen_prefills,short_arrival, andcontinuous_decode), simulator metrics show zero regressions (0/22diffs).Evidence
Verified on clean
git archive HEADof candidate commitcee524750b4c836034e130db70929b2064ae63fc(base9cd0cfadd167da2474db809bb49081df054583e0, cleangit 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.flare runA/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