Repository navigation
helios/scheduler: preserve interior anchor for open-reasoning prompts - #66
Draft
FujitsuPolycom wants to merge 1 commit into
Draft
FujitsuPolycom wants to merge 1 commit into
FujitsuPolycom wants to merge 1 commit into
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`) from a hoisted `opens_reasoning` check (`output.as_ref().is_some_and(|out| out.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` enters the existing unbudgeted fallback returning `(raw_anchor, 0)` without debiting `split_ns` and clearing `accounting.budgeted_anchor = None`, and `promote_request_anchor` skips latching `budgeted_anchor`. Retaining `raw_anchor < prompt_tokens` with `anchor_split_ns = 0` keeps the distinct prompt-end `RetentionRole::Endpoint` snapshot at `prompt_tokens` eligible under the request's extra-work allowance (bounded by `protected_budget`, matching pre-4cc6f2fd exact-prompt replay behavior). - 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, end-to-end Turn 1 publication to divergent Turn 2 prefix reuse (`896` vs `0` reused tokens), strict zero-fraction fallback, non-preserved continuations with reused prefixes, `OutputStart::Reasoning` vs `OutputStart::Content`, `OutputStart::RecipientHeader`, `OutputStart::RecipientFrame` (ATEM and TMLv0), `OutputStart::ToolBody`, 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 `95050ffb` and applying behavior-preserving cleanups that fold the duplicate fallback branch in `checkpoint_selection_uncached` and hoist `opens_reasoning` in `prepare_validated_inference`) 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>
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
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:
+28LOC (+37/-9across 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(+5/-1prod),helios/src/scheduler.rs(+5/-0prod):pub preserve_message_anchor: booltoPrompt,RequestSpec, andLiveRequest.opens_reasoning(output.as_ref().is_some_and(|out| out.content.start == crate::output::tagged::OutputStart::Reasoning)) inprepare_validated_inferencefor bothgrammar_reasoningandPrompt::preserve_message_anchor, and propagated it throughIncoming::spec()across initial admission and preemption readmission.helios/src/scheduler/checkpoints.rs(+23/-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_uncachedenters its existing unbudgeted fallback returning(raw_anchor, 0)without debitingsplit_nsand clearsaccounting.budgeted_anchor = None, andpromote_request_anchorskips latchingbudgeted_anchor.anchor = raw_anchor < request.prompt_tokenswithanchor_split_ns = 0, the distinct prompt-endRetentionRole::Endpointcut atrequest.prompt_tokensremains eligible as an optional capture under the request's extra-work allowance (matching pre-#660exact-prompt replay behavior and bounded byprotected_budgetunder tight snapshot capacity).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(clarifying that budgeted extra-work accountingflare_checkpoint_extra_work_nanoseconds_totalcovers budgeted interior anchor splits and optional captures while excluding uncharged anchor copies and preserved open-reasoning anchor splits).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), end-to-end Turn 1 publication (Anchor(896)andEndpoint(1024)) to divergent Turn 2 prefix reuse (admission_reused_tokens == 896preserved vs0unpreserved), 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),OutputStart::ToolBody(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). Rebasing298d3e68onto95050ffb(29968abd) made only behavior-preserving simplifications in production code (folding the duplicate unbudgeted fallback branch incheckpoint_selection_uncachedintoif raw_anchor < request.prompt_tokens && self.budget_interior_anchor(request)and hoistingopens_reasoninginprepare_validated_inference), plus test and documentation updates. 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 ~1.7K->160+2 staggered heavy cold prefills,n=2)[T0, T1](ms)>500ms∥>1sStalls0∥1TTFT 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%).anchor = raw_anchor < prompt_tokenswithanchor_split_ns = 0,checkpoint_selection_uncachedretains the distinct prompt-endRetentionRole::Endpointsnapshot atprompt_tokenswhenever its snapshot copy fits the request's extra-work allowance (ckpt_capsendrose from60/61/64to96across 48 turns in the 3-model GB10 runs, i.e., one prompt-end snapshot plus one terminal snapshot per turn). This preserves pre-#660exact-prompt replay / retry behavior and remains bounded byprotected_budget(prompt_tokens - raw_anchor) under tight snapshot capacity, without displacing earlierMessagecuts (which are evaluated ahead of prompt-endEndpoint).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 29968abd88068a91c25a5d3fb350bc05dca228a3(tree230f195d39248f08043dba84d5cb4354fac13c35;git merge-tree --write-tree 95050ffb 29968abdproduced230f195d39248f08043dba84d5cb4354fac13c35with0conflicts):rustc 1.100.0,x86_64):RUSTFLAGS="-D warnings -A deprecated" cargo check --locked --release --testspassed with0warnings across all six crates (eos,selene --features test-support,selene-manager --features test-support,helios --features runtime-core,server,flare, andflare-cli).cargo test --locked --release,FLARE_TEST_TEMPLATE_DIRpopulated viatests/frontend/prepare_templates.py):eos:12passed,0failed.selene --features test-support:553passed (552lib +1integration),0failed.helios --features runtime-core,server:1,901passed (1,839lib +62integration, including all 4 new/expanded unit tests),0failed (47lib +37integration checkpoint-gated ignored).flare:255passed (247lib +8integration),0failed (4ignored).flare-cli -- --test-threads=1:245passed (219lib +26integration),0failed (3ignored).budget_interior_anchortotrueinhelios/src/scheduler/checkpoints.rsfailed bothpreserved_message_anchor_reuses_interior_prefix_across_divergent_turn_two(rc=101) andpreserved_message_anchor_retains_interior_boundary_and_respects_zero_fraction(rc=101).== OutputStart::Reasoningback to!= OutputStart::Contentinhelios/src/server/request.rsfailedprepare_inference_sets_preserve_message_anchor_and_preserves_across_readmissiononOutputStart::RecipientHeader(rc=101).pytest):tests/preparation/test_core_boundary.pyandtests/test_design_review_hook.py—22passed,0failed (1.39 s).python3 verification/helios-lifecycle/check.py --mutations --jobs 6): All 8 TLA+ models (Lifecycle,RankProtocol,DispatchRing,OffloadTransfer,CacheOwnership,Speculation,ResponseLifecycle,CheckpointReservation), observed Rust trace conformance, and all source/model mutation guards (includingdropped multi-chunk budgeted-anchor fallbackinhelios/src/scheduler/checkpoints.rs) passed.flareaarch64release binaries built from cleangit archive, measured prior to the rebase onto95050ffband behavior-preserving cleanups):Arm A(07e666e6, SHA-256eccdaa0fcdae7cc0acbd60643a7420492b9a7b3509b1ca6600ab4ec0db0c7273) vsArm B(298d3e68, SHA-2568892aa6f0f2e1abe04f858ecbf49ff79a3e46d6eaa695517020f3c536778355b).SM121,121 GiBunified RAM, plain local NVMeext4,sync && echo 3 > /proc/sys/vm/drop_cachesbefore each boot):local-inference-lab/{Qwen3.8-27B-FLARE,NVIDIA-Nemotron-3.5-Bolt-74B-A9B-24GB-FLARE,Qwen3.8-Flash-Next-FLARE}atrevision="gb10"launched via:C=6 x 4 turns,n=2repeats per arm, 48 requests/arm): Streaming OpenAI/v1/chat/completionsclient (stream=true,temperature=0,max_tokens=64) running 6 concurrent 4-turn conversations that append only assistantcontent(strippingreasoning_content) between turns (Turn 1 prompts3,199–3,383tokens growing to5,492–5,773tokens by Turn 4), capturing Prometheus/metricsdeltas around each repeat.prefill_burstworkload (Qwen3.8-27B-FLARE,n=2repeats per arm): Catalog warmup exercising128..4096prefill buckets, followed by 4 concurrent streaming decoders (1,667–1,714prompt tokens,max_tokens=160,temperature=0) overlapped with 2 staggered cold heavy prefills (18,731–18,738and24,985–25,013prompt tokens,stream=true,temperature=0), recording per-decoder ITL p99, peak gap,>500 ms/>1 sstalls, heavy TTFT, makespan, and/metricsdeltas.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(prior to rebasing onto95050ffband applying the two behavior-preserving production cleanups incheckpoint_selection_uncachedandprepare_validated_inference);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