PR #697: helios/scheduler: preserve interior anchor for open-reasoning prompts

Raw Markdown for agents: https://autobot.eidonix.com/api/v1/cases/14a2eaa6-9511-4749-8afb-25183da12fff

Opened by a workflow run, Dec 2, 2026 6:47 PM EST. decide malicious: all_clear (100%): No malicious content found

explore

Author: FujitsuPolycom (CONTRIBUTOR; 19 merged PRs in 180 days; Discord "Dooner") Motivation: An earlier change (#660) budgets interior conversation-message checkpoints against a small extra-work allowance (default 5%) and drops them when splitting prefill there costs too much. When a chat template opens a reasoning block (<think>), OpenAI-style clients strip that reasoning from later turns, so the dropped checkpoint is the only one that could still be a prefix of the next turn — multi-turn prefix reuse collapses and every turn re-prefills. This PR keeps that interior checkpoint for open-reasoning prompts. Scale: +510 / −35 lines in 16 files (net production diff claimed and verified as +37/−8 across 4 Rust files; the rest is tests and 4 docs) Proposal:

Full report · Notes

Classify intake

Selected: triage:review, bug, performance, area:scheduling

Threshold: 65%

Triage

Priority

Type

Area

Model

Value Proposition

Value Proposition — PR #697 "helios/scheduler: preserve interior anchor for open-reasoning prompts"

Charter alignment — good, with one style hit. The change sits in the right layer: helios scheduler anchor selection, exactly the sites #660 touched. It respects "keep the runtime small and model-agnostic": the predicate keys on OutputStart::Reasoning, a shared parser concept set per dialect, with zero model-name branches, no CLI/Protobuf/ABI changes, and existing signed cores loading unchanged. It fits "What gets merged: … a measured performance/memory issue." The tension is preserve_message_anchor — a default-false boolean opt-in threaded through Prompt/RequestSpec/LiveRequest, which docs/design-review.md:56-61 says to reject in the letter (the spirit is met, since it's derived from shared parser state, not a model name). The Design-Signed-Off-By: trailer requirement is also unaddressed.

Novelty & status — genuinely additive; neither superseded nor obsolete. No other PR or issue special-cases reasoning-open anchor selection, and #655/#674/#694 overlap in files but not in this rule. It is also not obsolete: it repairs a regression #660 merged the same day and self-disclosed in its trade-offs (<think>-stripping skips Turn-1→2 reuse). The underlying mechanism is real — cache.rs:552-579 matches exact published prefixes — and affects the common reasoning-enabled path, not an edge case.

Value vs cost. The benefit is large and well-targeted on paper: Turn 2+ cache hit +9.7 to +31.8 pp, 0/108 zero-hit misses, prefill tokens −20 to −45%, output throughput +2.2 to +22.6% across three signed gb10-tp1 cores, with honest disclosure of the Turn-1 TTFT cost and the Nemotron Turn 2+ TTFT regression (+8.0%, launches 90→229). Production maintenance cost is low (+29 net lines, one predicate, three call sites). But the evidence package has gaps a reviewer must close: no CI at head bfae28a6; the live A/B ran on 298d3e68, not the reviewed head; no harness or raw logs, unlike #660/#661 which name FujitsuPolycom/tokbench; no test drives a second turn that actually hits the retained checkpoint; ToolBody is claimed but untested. Undisclosed: preserved turns emit a second charged prompt-end Endpoint (visible in the PR's own ckpt_caps end 60/64/61→96 and msg 11/2/21→0/0/12), whose snapshot-capacity cost is never discussed, and #655 rewrites the adjacent gate in the same function.

Verdict: Worth it with changes. Conditions: CI green at head; a reproducer for both benchmark tables; a merge-order decision with #655; a two-turn test asserting real reuse of the retained anchor; ToolBody coverage; explicit treatment of the extra charged Endpoint row; derive the flag inside the scheduler or justify the opt-in against design-review principle 3; add the design sign-off trailer.

Full report

Apply Labels (Intake)

Applied: +triage:review, +bug, +performance, +area:scheduling Decide Value: yes (100%): This change is worth reviewing: it provides value to the project in line with its charter.

Subtraction and simplicity

Reviewed PR #697 at head bfae28a through the subtraction/simplicity lens. The production diff is lean (net +29 lines, 4 files) and reuses the existing anchor-pricing machinery rather than forking it; two of the five subtractions found are worth doing before merge.

  1. F1 (high) — checkpoints.rs:620–624 (new preserved arm) is semantically identical to the pre-existing else at :662–665: both do accounting.budgeted_anchor = None; (raw_anchor, 0). Folding the condition into if raw_anchor < request.prompt_tokens && self.budget_interior_anchor(request) deletes the branch, one of three call sites, and a duplicate budgeted_anchor = None next to the TLA mutation needle at :649. Verified behaviour-preserving across all four reachable paths.
  2. F2 (high) — phase_tests.rs:8358–8377 duplicates the first 18 lines of the existing prepared_budget_request helper (:871–888); extract one fn prepare(...) -> PreparedInference and call it from both. ~−18 lines.
  3. F3 (medium) — budget_interior_anchor (checkpoints.rs:469–471) is a double negative used both ways (!self.budget_interior_anchor at :480, self.budget_interior_anchor at :621) and re-reads self.policy.checkpoint_extra_work_fraction although fraction is already bound at :609 and re-tested at :675. Replace with a positive preserved_interior_anchor(fraction, request).
  4. F4 (low) — request.rs:413–414 and :427–429 write the same OutputStart::Reasoning test twice; hoist one let opens_reasoning.
  5. F5 (low) — the 10-line scheduler-cost fixture repeats at checkpoints.rs:4791–4802, :4843–4854, :4869–4880; one local fn budgeted(fraction) removes ~20 lines.

Convention: preserve_message_anchor is a default-false boolean opt-in, which docs/design-review.md:58–61 and AGENTS.md:180–181 disfavour. I checked the candidate carriers — Prompt.reasoning_cut is Some only with thinking_budget (request.rs:368), grammar_reasoning only with grammar (:408–410) — so it is not derivable scheduler-side and should stay; the description merely owes the argument. The field also cost ~40 mechanical test-literal edits (25 in policy_tests.rs (not opened)), worth naming in the description.

Already lean: no duplicated pricing, promote_request_anchor gains only a disjunct, docs are required synchronization, no dead code.

Open: #655 touches the adjacent :681 snapshot-cost gate, so merge order decides F1's cost; OutputStart::ToolBody is untested; no benchmark reproducer exists to weigh the extra charged Endpoint copy per preserved turn.

Full report · Notes

Correctness and contracts

Reviewed PR #697 at head bfae28a across all 16 changed files plus direct callers, contracts and tests. The core mechanism is correct and repairs a real regression (helios/src/cache.rs:552-579 requires exact prefix identity; #660 disclosed the loss). I report two Major undisclosed system-level consequences and one Major test-evidence gap.

Major — the extra-work allowance and exported counter stop spanning the interior split (checkpoints.rs:620-623, :944-949): the preserved anchor is recorded with split_ns: 0, and the only charge site is cut.split_ns, which feeds checkpoint_extra_work_ns → flare_checkpoint_extra_work_nanoseconds_total (metrics.rs:852). The GPU still stops prefill at raw_anchor and runs the tail prefill — the PR's own disclosed Turn-1 TTFT cost — yet that work is neither charged to the request's allowance nor counted, while docs/cli-design.md:712-713 still says "Extra work includes … additional prefill caused by splitting chunks."

Major — every preserved turn publishes a second, charged snapshot row (checkpoints.rs:695-697, :784-790): the preserved branch only skips the split decision, so the loop still appends a prompt-end Endpoint (cuts.len() == 2, pinned at checkpoints.rs:4819). On main's unaffordable path the anchor sat at prompt_tokens and no second row existed, so per-turn rows double for the exact workload this PR targets — visible in its own ckpt_caps end 60→96 / 64→96 / 61→96 and undisclosed, with no snapshot-capacity measurement.

Major — no in-repo test drives the claimed causal path: the new tests pin anchor selection and split_ns == 0 only (checkpoints.rs:4789-4925); none publishes a preserved Turn-k checkpoint at 896 and looks it up from a stripped-reasoning Turn k+1.

Minor: preserve_message_anchor is a default-false bool threaded through Prompt/RequestSpec/LiveRequest against docs/design-review.md:58-61, with no Design-Signed-Off-By trailer in a body that omits it; OutputStart::ToolBody is listed but untested; A/B evidence has no harness and its binaries predate head; the Nemotron 90→229 prefill-launch regression is disclosed but unattributed.

Verified sound: predicate consistency across all three anchor sites, readmission preservation, stale-latch clearing, zero-fraction strict fallback, no hot-path or ABI/wire/CLI change.

Open: merge order vs open #655/#674/#694, snapshot-capacity cost, and whether the sign-off trailer exists on the commits.

Full report · Notes

Final review

Recommendation: Changes Requested

The core scheduler change (+29 net production LOC across 4 Rust files, zero unsafe, zero model-name branches or ABI/wire changes) cleanly and safely fixes the <think>-stripping multi-turn prefix-reuse regression disclosed by #660, with strong single-GPU gb10-tp1 A/B gains (+9.74 to +31.78 pp Turn 2+ cache hit, 0 / 108 zero-hit misses, -20.1% to -45.1% total prefill tokens). No merge blockers exist, but three concrete issues should be addressed before merge: an internal documentation contradiction in docs/cli-design.md:709-713, the lack of an end-to-end two-turn divergent-suffix reuse test in helios/src/scheduler/checkpoints.rs, and the undisclosed extra prompt-end Endpoint snapshot published on every preserved open-reasoning turn (ckpt_caps end 60/61/64 → 96) alongside missing benchmark harness command lines in ## Evidence.

Merge Risk

Level: Medium

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

  1. Fix internal contradiction in docs/cli-design.md:709-713: Lines 699-702 state that under a nonzero fraction an interior message endpoint is "retained without charging its split when the generation prompt opens a reasoning block", but lines 709-711 immediately below still state "Any retained interior anchor split, earlier messages, and a distinct prompt end share the fraction of estimated uncached prefill work" (whereas docs/core-design.md:1449-1451 was properly updated to "when such a budgeted interior anchor is retained").
    • Fix: Change docs/cli-design.md:709 to "Any budgeted interior anchor split..." and clarify at :712-713 that uncharged anchor copies and preserved open-reasoning anchor splits are excluded from budgeted extra-work accounting (flare_checkpoint_extra_work_nanoseconds_total).
  2. Add an end-to-end two-turn divergent-suffix reuse test (helios/src/scheduler/checkpoints.rs:4789-4926): Neither new scheduler test executes a preserve_message_anchor: true Turn 1 through plan() -> commit() -> complete_test_step() to publish Anchor(896) and then admits a divergent Turn 2 (matching 0..896 and diverging in 896..1024, modeling stripped reasoning history). Right now :4790-4865 only inspects checkpoint_selection() / request_anchor_endpoint() without stepping, and :4868-4926 only executes a 512-token Turn 1 with preserve_message_anchor: false and no interior boundary.
    • Fix: Add an isolated test (following #660's Case 1 pattern at checkpoints.rs:4270-4332) that runs Turn 1 (prompt_tokens = 1024, message_boundaries = [896], preserve_message_anchor = true) through prefill publication and asserts that a Turn 2 matching 0..896 with a modified 896..1024 suffix admits with admission_reused_tokens == 896 (and that the same sequence with preserve_message_anchor = false falls back to 1024 and admits with admission_reused_tokens == 0).
  3. Resolve/document the extra prompt-end Endpoint snapshot on preserved open-reasoning turns (helios/src/scheduler/checkpoints.rs:695-697) and add benchmark reproducer commands (## Evidence):
    • Because preserved turns keep anchor = raw_anchor < request.prompt_tokens with anchor_split_ns = 0, checkpoints.rs:695-697 pushes (request.prompt_tokens, RetentionRole::Endpoint) with split_ns = 0 and full prefill allowance intact, publishing an extra GraphKind::Snapshot copy and snapshot row at prompt_tokens on every open-reasoning turn (visible in the PR's own tables: ckpt_caps end rose 60→96, 61→96, 64→96 across 48 turns, i.e., +32 to +36 extra prompt-end snapshots for the exact <think> suffix that Turn k+1 strips; also pinned at checkpoints.rs:4819-4822). While protected_budget (prompt_tokens - raw_anchor, :769-773) bounds eviction under tight snapshot capacity and this matches pre-#660 behavior, it is never mentioned in ## What or ## Trade-offs.
    • Fix: Either confirm whether that prompt-end Endpoint capture is intentionally kept (for exact-prompt replay / pre-#660 parity) and disclose the extra per-turn Endpoint snapshot copy/row in ## What / ## Trade-offs, or skip pushing request.prompt_tokens at :695-697 when !self.budget_interior_anchor(request) if the extra copy is unnecessary. Also add the workload harness repo/commit and exact invocation commands for C=6 x 4 turns and prefill_burst to ## Evidence (matching #660).

Subtract / Simplify

  1. Fold the duplicate fallback arm in checkpoint_selection_uncached (helios/src/scheduler/checkpoints.rs:620-624,662-665): The new if !self.budget_interior_anchor(request) arm at :621-623 executes accounting.budgeted_anchor = None; (raw_anchor, 0) — byte-identical to the pre-existing else arm at :662-665. Changing :620 to if raw_anchor < request.prompt_tokens && self.budget_interior_anchor(request) deletes 4 lines, one nesting level, and the duplicate budgeted_anchor = None above the TLA+ mutation target at :649 with identical behavior across all four reachability cases.
  2. Extract a shared prepare helper in helios/src/server/runtime/phase_tests.rs:8358-8377,871-888: The 18-line let prepare = |...| { ... } closure at :8358-8377 is a verbatim duplicate of the first 18 lines of prepared_budget_request at :871-888. Extracting fn prepare(fixture: &Fixture, protocol: Protocol, body: serde_json::Value) -> PreparedInference removes ~18 duplicated lines and keeps the prepare_inference call site in one place.
  3. Optional — extract a local stepped-cost scheduler helper in helios/src/scheduler/checkpoints.rs:4791-4802,4843-4854,4869-4880: The 10-line [(128, 100), (256, 110), (512, 200)] + Snapshot(1, 5) + configure_policy(fraction) fixture setup is repeated verbatim 3 times in the new tests (and 5 other times earlier in the module); a small fn budgeted_scheduler(fraction: f64) helper cuts ~20 lines.

Nits

Dropped on verification

Full report

Classify triage

Selected: triage:review

Threshold: 65%

Triage

Apply labels

No label changes Decision to Test: no (95%): Testing will not add significant value as the code stands today. The code is either not yet ready to merge, or adequate testing has already been done to validate the contents of the code, or the available hardware is not suitable to test with.