Repository navigation
helios/scheduler: preserve interior anchor for open-reasoning prompts - #697
Conversation
Why Commit 4cc6f2f budgets every interior conversation anchor (`raw_anchor < prompt_tokens`) against `scheduler_checkpoint_extra_work_fraction` (default 0.05), falling back to `prompt_tokens` whenever splitting prefill at `raw_anchor` exceeds the request's extra-work allowance. When a chat template opens a reasoning block after the last complete-message boundary (`output.content.start == OutputStart::Reasoning`, such as `<think>\n` on reasoning-enabled Qwen, Nemotron, or DeepSeek models), OpenAI-compatible clients strip reasoning text from subsequent assistant history. Turn k+1 therefore diverges from Turn k inside `[raw_anchor, prompt_tokens)`. Because `PrefixCheckpointCache::lookup` matches exact published checkpoints across all core types, falling back to `prompt_tokens` leaves Turn k with no checkpoint that is a prefix of Turn k+1 and forces full re-prefill on subsequent turns. Requests that do not open a reasoning block (`OutputStart::Content`, `OutputStart::RecipientHeader`, `OutputStart::RecipientFrame`, `OutputStart::ToolBody`, and raw completions) do not suffer this stripped-suffix divergence: Turn k's prompt-end and terminal checkpoints remain exact prefixes of Turn k+1. Interior-anchor budgeting should therefore remain active for all non-reasoning-open requests (including multi-turn continuations with `admission_reused_tokens > 0`), while retaining `raw_anchor` specifically when `output.content.start == OutputStart::Reasoning` under a nonzero extra-work fraction. What - Added `pub preserve_message_anchor: bool` to `Prompt` (`helios/src/server/runtime.rs`), `RequestSpec`, and `LiveRequest` (`helios/src/scheduler.rs`), populated in `prepare_validated_inference` (`helios/src/server/request.rs`) as `output.as_ref().is_some_and(|o| o.content.start == OutputStart::Reasoning)` and propagated across admission and preemption readmission via `Incoming::spec`. - Added one shared predicate `RequestScheduler::budget_interior_anchor` in `helios/src/scheduler/checkpoints.rs` returning `self.policy.checkpoint_extra_work_fraction == 0.0 || !request.preserve_message_anchor`, consumed by `request_anchor_endpoint`, `checkpoint_selection_uncached`, and `promote_request_anchor`. - When `!budget_interior_anchor(request)` (`fraction > 0.0` and `preserve_message_anchor == true`), `request_anchor_endpoint` returns `Some(raw_anchor)` immediately, `checkpoint_selection_uncached` retains `(raw_anchor, 0)` without debiting `split_ns` and clears `accounting.budgeted_anchor = None`, and `promote_request_anchor` skips latching `budgeted_anchor`. - When `budget_interior_anchor(request)` is true (`fraction == 0.0`, or `preserve_message_anchor == false`), the existing interior-anchor budgeting logic runs unchanged, including when `admission_reused_tokens > 0`. - Synchronized present-state documentation (`docs/scheduling-runtime-design.md`, `helios/README.md`, `docs/core-design.md`, `docs/cli-design.md`) and added unit tests in `helios/src/scheduler/checkpoints.rs` and `helios/src/server/runtime/phase_tests.rs` covering preserved interior anchors at 0.05, strict zero-fraction fallback, non-preserved continuations with reused prefixes, `OutputStart::Reasoning` vs `OutputStart::Content`, `OutputStart::RecipientHeader`, `OutputStart::RecipientFrame` (ATEM and TMLv0), and raw completions preparation, plus readmission propagation. No CLI, Protobuf, model-core ABI, or `unsafe` changes; existing signed cores load and serve unchanged. Result Restores Turn k -> k+1 exact message-anchor prefix reuse for open-reasoning conversations under the default `scheduler_checkpoint_extra_work_fraction = 0.05` while keeping interior-anchor split budgeting active for `OutputStart::Content`, `OutputStart::RecipientHeader`, `OutputStart::RecipientFrame`, `OutputStart::ToolBody`, and raw completions, and preserving strict zero-split opt-out at `fraction == 0.0`. Evidence Verified on clean `git archive` via release `cargo check` and `cargo test` across `eos`, `selene`, `selene-manager`, `helios` (`--features runtime-core,server`), `flare`, and `flare-cli`, TLA+ lifecycle models and mutation verification (`verification/helios-lifecycle/check.py --mutations`), core-boundary and design-review hook pytest suites, and scratch fault-mutation checks reverting `budget_interior_anchor` and widening the `OutputStart::Reasoning` predicate. Live 3-model GB10 `flare run` A/B results comparing `07e666e6` against `298d3e68` (prior to rebasing onto `cc0a49d2`, which kept all production code and documentation byte-identical and only initialized `preserve_message_anchor: false` on four additional test `RequestSpec` literals on `main`) are reported in the PR description. Limitations: chat templates that inject a self-closed empty reasoning suffix when `enable_thinking=false` (such as `<think>\n\n</think>\n\n`, which resolves to `OutputStart::Content`) remain budgeted with `preserve_message_anchor = false`; `scripts/scheduling_sim` and `cargo kani` do not model checkpoint anchor selection. Discord: Dooner Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
|
A case file has been opened for 697. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedThe scheduler change (
Walkthrough
Merge Risk: Medium · up to
|
Why
Commit
4cc6f2fd(#660) budgets every interior conversation anchor (raw_anchor < prompt_tokens) againstscheduler_checkpoint_extra_work_fraction(default0.05), falling back toprompt_tokenswhenever splitting prefill atraw_anchorexceeds the request's extra-work allowance.When a chat template opens a reasoning block after the last complete-message boundary (
output.content.start == OutputStart::Reasoning, such as<think>\non reasoning-enabled Qwen3.8, Nemotron, or DeepSeek models), OpenAI-compatible clients strip reasoning text from subsequent assistant history. Turnk+1therefore diverges from Turnkinside[raw_anchor, prompt_tokens). BecausePrefixCheckpointCache::lookupmatches exact published checkpoints across bothCONTINUATION_STATEandPAGED_KEY_VALUEcores, falling back toprompt_tokensleaves Turnkwith no checkpoint that is a prefix of Turnk+1, collapsing multi-turn prefix reuse and forcing full re-prefill on subsequent turns.Requests that do not open a reasoning block (
OutputStart::Content,OutputStart::RecipientHeader,OutputStart::RecipientFrame,OutputStart::ToolBody, and raw completions) do not have this stripped-suffix divergence: Turnk's prompt-end and terminal checkpoints remain exact prefixes of Turnk+1. Interior-anchor budgeting should therefore remain active for all non-reasoning-open requests (including multi-turn continuations withadmission_reused_tokens > 0, preserving#660's non-thinking multi-turn and mixed-workload gains), while retainingraw_anchorspecifically whenoutput.content.start == OutputStart::Reasoningunder a nonzero extra-work fraction.What
Net non-test production diff:
+29LOC (+37/-8across 4 Rust files; zerounsafe, zero CLI, Protobuf, or model-core ABI changes, zero model-name branches). Existing signed cores load and serve unchanged.helios/src/server/runtime.rs(+4/-0prod),helios/src/server/request.rs(+4/-0prod),helios/src/scheduler.rs(+5/-0prod):pub preserve_message_anchor: booltoPrompt,RequestSpec, andLiveRequest.preserve_message_anchorinprepare_validated_inferencetooutput.as_ref().is_some_and(|o| o.content.start == crate::output::tagged::OutputStart::Reasoning)and propagated it throughIncoming::spec()across initial admission and preemption readmission.helios/src/scheduler/checkpoints.rs(+24/-8prod):RequestScheduler::budget_interior_anchor(&self, request: &LiveRequest) -> boolreturningself.policy.checkpoint_extra_work_fraction == 0.0 || !request.preserve_message_anchor, called byrequest_anchor_endpoint,checkpoint_selection_uncached, andpromote_request_anchorso all anchor-selection paths stay consistent.!self.budget_interior_anchor(request)(fraction > 0.0andpreserve_message_anchor == true):request_anchor_endpointreturnsSome(raw_anchor)immediately,checkpoint_selection_uncachedretains(raw_anchor, 0)without debitingsplit_nsand clearsaccounting.budgeted_anchor = None, andpromote_request_anchorskips latchingbudgeted_anchor.self.budget_interior_anchor(request)istrue(fraction == 0.0, orpreserve_message_anchor == falseregardless ofadmission_reused_tokens): the existing interior-anchor budgeting logic runs unchanged.docs/scheduling-runtime-design.md,helios/README.md,docs/core-design.md, anddocs/cli-design.md.helios/src/scheduler/checkpoints.rsandhelios/src/server/runtime/phase_tests.rscovering preserved interior anchors at0.05(with agreement betweenrequest_anchor_endpointandcheckpoint_selection_uncachedand stale latches), strict zero-split fallback atfraction == 0.0, non-preserved continuations withadmission_reused_tokens > 0remaining budgeted identically to#660,OutputStart::Reasoning(true) vsOutputStart::Content,OutputStart::RecipientHeader(ATEM),OutputStart::RecipientFrame(ATEMadd_generation_prompt: falseand TMLv0), andProtocol::Completions(false), plus readmission preservation acrossworker.park().Result
Single-boot-per-arm (
Arm A -> Arm B) serving A/B measurements on one NVIDIA GB10 (SM121,121 GiBunified memory,aarch64) comparingNVIDIA/hyperflare-inferencemain(07e666e6) against298d3e68across three signedlocal-inference-labgb10-tp1cores with identical runtime flags (--gpus 0 --host 127.0.0.1 --port 8051 --scheduler-policy balanced --kv-cache-limit memory --memory-limit=-12G --prefix-cache-memory 0, defaultscheduler_checkpoint_extra_work_fraction = 0.05, OS page caches dropped before every boot). Rebasing298d3e68ontocc0a49d2(bfae28a6) kept all+29net production lines and all documentation byte-identical, adding onlypreserve_message_anchor: falseto four additionalRequestSpectest literals introduced onmainatcc0a49d2. All 6 boots passedGET /v1/models(HTTP 200),37 * 41 -> 1517with finite logprobs (0non-finite),flare_requests_failed_total == 0, and0server log errors.Multi-Turn Prefix Reuse (
C=6 x 4 turns,n=2, OpenAI content-only history)gb10-tp1)[T0, T1][T0, T1]msg_ckpts∥ckpt_caps(anchor/msg/end)prefillLaunches ∥work_budgetSkipsQwen3.8-27B-FLARE(nvidia/Qwen3.8-27B-NVFP4)07e666e6(base)56.61%[51.28, 61.94]9 / 3642.70[37.81, 47.60]3,140.5∥6,659.6∥2,465.7112,51724∥48 / 11 / 60103∥30298d3e68(fix)83.78%[83.82, 83.75](+27.17 pp)0 / 3652.34[48.45, 56.23](+22.6%)2,078.4∥8,199.9∥1,772.9(-28.1%)66,148(-41.2%)48∥48 / 0 / 9696∥35NVIDIA-Nemotron-3.5-Bolt-74B-A9B-24GB-FLARE07e666e6(base)74.07%[74.96, 73.19]0 / 3642.25[40.47, 44.02]5,475.9∥8,976.9∥4,231.386,25635∥48 / 21 / 6190∥44298d3e68(fix)83.81%[83.82, 83.80](+9.74 pp)0 / 3643.19[41.38, 44.99](+2.2%)4,966.9∥9,250.8∥4,571.5(+8.0%)68,925(-20.1%)60∥48 / 12 / 96229∥25Qwen3.8-Flash-Next-FLARE07e666e6(base)52.16%[48.38, 55.93]14 / 3642.09[38.37, 45.81]3,828.3∥5,828.0∥2,218.2121,33618∥48 / 2 / 6487∥42298d3e68(fix)83.94%[83.97, 83.90](+31.78 pp)0 / 3651.17[50.89, 51.46](+21.6%)1,910.9∥7,540.4∥1,744.7(-21.3%)66,652(-45.1%)48∥48 / 0 / 9696∥46Warm-Catalog Concurrent Cold-Prefill Burst on
Qwen3.8-27B-FLARE(4 decoders ~1K->160+2 staggered 12K/16K cold prefills,n=2)[T0, T1](ms)>500ms∥>1sStalls12K∥16KTTFT med (ms)prefillLaunches ∥msg_ckpts07e666e6(base)469.2[469.7, 468.8]984.4∥1,234.7[1,234.7, 734.2]6∥121,835∥21,95223.84103∥5298d3e68(fix)374.0[425.3, 322.6](-20.3%)1,009.5∥1,521.3[1,521.3, 497.6]6∥520,410∥22,29524.35108∥12Trade-offs and Scope
5.83–8.98 sto7.54–9.25 s), which is repaid across Turns 2–4 with-20.1%to-45.1%fewer total prefill tokens,0 / 108Turn 2+ zero-hit misses across all three models (+9.74 ppto+31.78 ppTurn 2+ cache hit), and+2.2%to+22.6%higher multi-turn output throughput. OnNVIDIA-Nemotron-3.5-Bolt-74B-A9B-24GB-FLARE(max_active = 4), retaining all interior anchors underC = 6queueing increased Turn 2–4 prefill launches (90 -> 229) and Turn 2+ median TTFT (+8.0%) while still reducing all-turn median TTFT (-9.3%) and total prefill tokens (-20.1%).Qwen3.8-27B-FLAREwarm-catalogprefill_burst,298d3e68reduced median decode ITL p99 by-20.3%(469.2 -> 374.0 ms) and restored complete message-checkpoint capture (5 -> 12), with0>500 msstalls in Trial 1 (497.6 mspeak vs734.2 msbase) and one Trial 0 chunk spike (1,521.3 mspeak,5>1 sdecoder gaps vs1,234.7 ms/1on base).OutputStart::Content,OutputStart::RecipientHeader,OutputStart::RecipientFrame,OutputStart::ToolBody, and raw completions), including multi-turn continuations withadmission_reused_tokens > 0, remain budgeted identically to#660.--scheduler-checkpoint-extra-work-fraction 0.0retain strict zero-split fallback even for open-reasoning requests.Evidence
All software checks ran on clean
git archive bfae28a601b5a1ba66e2cea114e8472a8a5247db(treed744981f37736a5a497f3f524ffb42852f6c8c1e;git merge-tree --write-tree cc0a49d2 bfae28a6producedd744981f37736a5a497f3f524ffb42852f6c8c1ewith0conflicts):rustc 1.94.1,x86_64):RUSTFLAGS="-D warnings" cargo check --locked --releasepassed with0warnings across all six crates (eos --tests,selene --features test-support --tests,selene-manager --features test-support --tests,helios --features runtime-core,server --tests,flare --tests, andflare-cli --tests).cargo test --locked --release,FLARE_TEST_TEMPLATE_DIRpopulated viatests/frontend/prepare_templates.py):eos:12passed,0failed.selene --features test-support:553passed (552lib +1integration),0failed.selene-manager --features test-support -- --test-threads=1:426passed (187lib +239integration, including11inpool_store),0failed (1scale test ignored).helios --features runtime-core,server:1,900passed (1,838lib +62integration, including all 3 new/expanded unit tests and the 4 updatedRequestSpectest literals fromcc0a49d2),0failed (47lib +37integration checkpoint-gated ignored).flare:254passed (246lib +8integration),0failed (4ignored).flare-cli -- --test-threads=1:245passed (219lib +26integration),0failed (3ignored).budget_interior_anchortotrueinhelios/src/scheduler/checkpoints.rsfailedpreserved_message_anchor_retains_interior_boundary_and_respects_zero_fractionwith exit code101.== OutputStart::Reasoningback to!= OutputStart::Contentinhelios/src/server/request.rsfailedprepare_inference_sets_preserve_message_anchor_and_preserves_across_readmissiononOutputStart::RecipientHeaderwith exit code101.pytest):tests/preparation/test_core_boundary.pyandtests/test_design_review_hook.py—22passed,0failed.python3 verification/helios-lifecycle/check.py --mutations): All 8 TLA+ models (Lifecycle,RankProtocol,DispatchRing,OffloadTransfer,CacheOwnership,Speculation,ResponseLifecycle,CheckpointReservation), observed Rust trace conformance, and all source/model mutation guards passed.flareaarch64release binaries built from cleangit archive, prior to the test-only rebase ontocc0a49d2):Arm A(07e666e6): binary SHA-256eccdaa0fcdae7cc0acbd60643a7420492b9a7b3509b1ca6600ab4ec0db0c7273.Arm B(298d3e68): binary SHA-2568892aa6f0f2e1abe04f858ecbf49ff79a3e46d6eaa695517020f3c536778355b.Limitations
enable_thinking=false(such as<think>\n\n</think>\n\n, which resolves toOutputStart::Contentbecause the template closes the reasoning block before generation starts) are not distinguished byOutputStartand remain budgeted withpreserve_message_anchor = false.scripts/scheduling_sim/andcargo kanido not model checkpoint anchor selection and are not applicable.gb10-tp1(SM121) reasoning-enabled cores measured on07e666e6vs298d3e68(before rebasing ontocc0a49d2, which left all+29production lines and all documentation byte-identical and only initializedpreserve_message_anchor: falseon four additionalRequestSpectest literals onmain);SM120TP4DeepSeek-V4.1-Flashnon-thinking workloads were not re-benchmarked here becausepreserve_message_anchorevaluates tofalseonOutputStart::Contentrequests and leaves their#660code path unchanged (verified by thenon_preserved_continuation_with_reused_prefix_still_budgets_interior_anchorunit test).Discord: Dooner