#1 [high] Change: size and shape of the diff
PR #626 "Allow speculative reasoning for grammar-constrained requests" by lukealonso (COLLABORATOR), open, ready for review, opened 2026-11-30, head f7907a2, base main, base commit at branch c146d7b. NO comments, NO reviews yet. CI on head commit: FAILED.
Files (from pr_files):
- docs/api.md +8/-4
- docs/core-design.md +11/-5
- docs/mtp-design.md +15/-2
- helios/src/grammar.rs +156/-0
- helios/src/model/admission.rs +4/-4
- helios/src/server/request.rs +20/-0
- helios/src/server/runtime.rs +327/-19
- helios/src/server/runtime/phase_tests.rs +863/-4
- helios/src/server/runtime/prompt_tests.rs +1/-1
Core code changes (verified by reading diffs):
- helios/src/grammar.rs: new
mask_dirtyfield on RequestGrammar:666-670;sync_mask():703-712;try_advance_unmasked(token):714-780;mask()andallows()get debug_assert!(!mask_dirty) (:677-693) — i.e. reading the mask while deferred panics in debug builds.advance()now calls sync_mask if dirty (:785). - helios/src/model/admission.rs:110-125:
Admission::from_prompttakes newgrammar_constrained: boolparam; grammar_mask only populated when true. - helios/src/server/request.rs:405-425: new
Prompt::grammar_reasoning: Option<OutputConfig>, set when grammar is some AND (content.start == OutputStart::Reasoning OR (envelope.recipient.is_some() AND start ∈ {RecipientHeader, RecipientFrame})). - helios/src/server/runtime.rs:
Incoming::speculative_grammar_reasoning():253-262 andallow_reasoning_reentry():264-274;Incoming::spec()sets grammar_constrained = grammar.is_some() && !speculative_grammar_reasoning(); newIncoming::grammar_reasoning_mode: Option<bool>; new struct GrammarTransition; newpark_grammar_transition/park_with_tokens.
No GPU graph, kernel ABI, or protobuf changes (claim in description; diff confirms — only docs + helios/src Rust).
#2 [high] Why: open issue #530 is the direct motivation
Open issue #530 ("Structured output (json_schema / json_object) decodes ~2-3x slower than unconstrained on DeepSeek-V4.1-Flash-1017 gb202 TP4 (MTP drops to width one)"), by devinkuhn, opened 2026-11-25, updated 2026-11-30 01:39. Labels: area:scheduling, bug, performance, triage:investigate. No comments yet on issue itself (Discussion: 0).
Measured on 4x RTX PRO 6000 Blackwell Max-Q TP4, release-e091689 / e30d55d images, DeepSeek-V4.1-Flash-1017 FLARE package:
- json_schema: 55 tok/s vs 176 unconstrained (first measurement); newer: 35-39 vs 59-70 (~1.8x penalty under load).
- json_object: 57 tok/s (same penalty).
- Production: vLLM median 21.5s / 1 of 203 timeouts vs Flare 54.8s / 85 of 450 timeouts with json_schema; unconstrained chat was faster on Flare. Regression is specific to constrained decoding.
- Asks: (1) MTP with per-draft-position grammar masks roadmap? (2) could the one-step-in-flight rule apply per request, not per batch? (3) docs note in model card / docs/api.md until fixed.
- Cites docs/mtp-design.md "grammar-constrained MTP requests use width one" and docs/core-design.md "While any constrained request is in the decode batch, the loop runs one step in flight". Referred to by: #619 (merged).
This issue is the direct motivation for #626's "why" (issue is not mentioned in the PR #626 description, though — need to verify: PR 626 text has no issue reference). PR #626 addresses ask (1)-ish for reasoning phase and ask (2,3) indirectly.
#3 [high] Related work: #619 (merged) explicitly left grammar requests width-1; #626 lifts that
PR #619 "Unlock multi-token speculation and two-frame pipelining for host stops in Helios", lukealonso, merged 2026-11-29 21:40 (+282/-107, 16 files). Same author, immediately preceding day, same core files (helios/src/server/runtime.rs, phase_tests.rs, docs/{core,mtp}-design.md).
Key: #619 explicitly KEPT grammar-constrained requests at width-1 with step-level single-frame feedback barrier: "Grammar-constrained requests (json_schema, json_object, Lark, strict tools; related to #530) still require host-computed vocabulary masks between steps and remain on the step-level single-frame feedback barrier and width-1 MTP path". Its "Scope boundary" reiterates grammar requests "remain unchanged on width-1 MTP with a step-level single-frame feedback barrier." So #626 is a direct follow-up: it removes that remaining scope boundary for the reasoning phase. The #619 Autobot review had "Changes Requested" (per-request feedback barrier concerns) and lukealonso restored the step-level barrier for grammar in d9e3e15 — the design #626 now partially reverses for reasoning tokens. #626 reuses the #619 pattern of cancel/retire rather than finish, and the "burst_counts / skipped" accounting introduced in #619. #619 also noted pre-existing CI Python failures (tests/preparation) and unmeasured GPU perf — same class of evidence gap as #626. #619's evidence bar: TLA+ lifecycle check, helios release tests 1724 passed, docs updated. #626 cites 1806 passed.
#4 [high] Change: four things the description does not say
All verified by reading the diff/code at PR head.
(a) NEW debug-only panic path: RequestGrammar::mask() (helios/src/grammar.rs:676-683) and allows() (:685-693) now carry debug_assert!(!self.mask_dirty, "sync_mask must run before reading a deferred grammar mask"). In main these accessors had no assertion. So any code path that reads the mask/allows after an unmasked advance but before sync_mask panics in debug builds (and is silently wrong in release). Note: every test run cited in the PR description uses --release, where debug_assert! is compiled out (debug_assertions off by default) — so the invariant guard is never exercised by the claimed evidence.
(b) Undeclared new per-token work: Active.reasoning decoder is now constructed for every eligible grammar request, not only for thinking_token_budget requests. runtime.rs:1639-1658: reasoning: incoming.prompt.reasoning_cut.as_mut().map(|cut| Decoder::new(..., cut.output.take().or_else(|| incoming.prompt.grammar_reasoning.clone()))).or_else(|| incoming.prompt.grammar_reasoning.as_ref().map(|output| Decoder::new(..., Some(output.clone())))). In main the worker-side OutputPipeline decoder existed only when a reasoning cut (thinking_token_budget) was configured. Now it runs on every accepted token (reasoning.push(token), runtime.rs:1971-1978) plus reasoning_open() twice per token (:1967-1970, :1979-1982) for every grammar+reasoning request, in parallel with the client-side decoder ("client decoder runs on another thread", runtime.rs:415). The PR description does not mention this added host cost (it only claims savings: no per-step mask compute/upload).
(c) Undeclared new terminal failure mode: in speculative reasoning, if a sampled token is rejected by the grammar AND remaining == 0 or the sequence is at the context limit, the request fails with Error::execution(ExecutionError::Completion, "grammar rejected token with no remaining output capacity") (runtime.rs:1955-1961) rather than completing. In main a grammar-forbidden token could not be sampled (device mask), so this failure path is new. It maps to an execution error (500 / terminal SSE error) for the client.
(d) Sampling continuity change: every transition goes through park_with_tokens, which re-derives the seed: incoming.prompt.sampling.seed = continuation_seed(seed, generated_tokens) (runtime.rs:2469-2471). Grammar-constrained reasoning requests therefore sample with a different seed sequence than on main for the same request/seed, so outputs are not reproducible across this change. Same mechanism preemption/budget cuts already use.
(e) Admission::from_prompt signature is public and gained a 4th parameter grammar_constrained: bool (helios/src/model/admission.rs:109-125); call sites: runtime.rs:1613 and phase_tests.rs:6139 only. Prompt (runtime.rs:29-61) gained public field grammar_reasoning — both are in-crate, no other crate constructs Prompt (checked: helios/src/server/runtime/phase_tests.rs:199-219, prompt_tests.rs:47, response_lifecycle_tests.rs via Fixture::prompt_for).
#5 [high] Related work: #418 authored the docs contract that #626 rewrites
The user-facing contract that #626 rewrites was introduced/ratified in #418 (merged 2026-11-22, jcartu, +6048/-128, closes #417 "Support strict: true function tools").
- #418 established: "An active strict function tool attaches a composed request grammar for the entire generation (reasoning, prose, and tool calls...). For as long as that request decodes, its lane uses single-token MTP proposals and any decode batch containing it keeps one replay step in flight rather than two" (docs/core-design.md#native-replay-loop).
- Reviewer yatesdr asked in review round 2 (2026-11-21 12:30): "The cost we asked about is what a constrained request does to the decode batch: one step in flight while it is decoding (docs/core-design.md:1239-1243)"; and point 3 of CHANGES_REQUESTED (2026-11-21 17:24): "A request with an active strict tool is grammar-constrained for its whole generation, not only during the call, so the one-step-in-flight window lasts as long as that request decodes."
- #418 measured the penalty on SM120 TP4 DeepSeek-V4.1-Flash DSML: strict call latency 3.49 s median vs 1.09 s non-strict at C8 (3.2x), 8.59 s vs 2.43 s at C32 (3.5x); ordinary-decode throughput during overlap essentially unchanged (987 vs 981 tok/s C8; 1917 vs 1949 C32). So the per-request cost was documented as measured, and #626 changes the documented duration of that cost.
CROSS-REFERENCE: #626 modifies docs/api.md:645-655 and docs/core-design.md:1692-1709 — the exact paragraphs written for #418. This is the strongest "reverses prior documented contract" signal, but it widens rather than removes the constraint (reasoning becomes unconstrained; prose/tool-call decoding stays width-1).
#7 [high] Docs: #626 leaves three contradicting statements of the same rule
VERIFIED (read docs at PR head): docs/core-design.md:1242-1248 ("A grammar-constrained request needs a vocabulary mask for step k+1... While any constrained request is in the decode batch, the loop runs one step in flight...") is UNCHANGED by #626, but the PR rewrote docs/core-design.md:1692-1709 to say the one-step-in-flight rule applies only "while device grammar masking is active (outside open reasoning...)". The two statements in the same file now contradict each other for a grammar request in speculative reasoning. Similarly unchanged and now stale:
- docs/scheduling-runtime-design.md:548-552 — "Unknown or stale costs, grammar, copy-only proposals, host-fed pending tokens ... also require completion feedback."
- helios/model-contract.md:236-238 — "Host-fed pending tokens, grammar, host stops, history inputs, unknown or stale costs, and operations that change phase require completion feedback." (this one is the wire contract, and behaviourally still true since grammar_constrained lanes still require feedback; but the sentence is now per-request-mode dependent.)
- docs/mtp-design.md:597-599 — "Unsupported speculative grammar or custom-stop cases exercise the declared one-token path and remain in the workload."
So docs/api.md + core-design.md#native-replay-loop + mtp-design.md were updated; three sibling places that describe the same rule were not.
Also: helios/README.md:314 documents
grammar_constrained=Falsein the Python executor submit signature — unaffected (unchanged).
#8 [high] Claim vs issue: #626 does not cover #530's measured case (thinking disabled, answer JSON)
VERIFIED: the change does NOT apply to the case measured in #530. #530 reports "chat_template_kwargs: {enable_thinking: false}" and penalise json_schema requests; also json_object. #626's eligibility (helios/src/server/request.rs:408-426) requires a grammar AND (OutputStart::Reasoning, or an envelope with a recipient at RecipientHeader/RecipientFrame). A request whose output starts in OutputStart::Content or ToolBody, or a raw Completions request, stays device-constrained from token 0 (PR description says so; asserted in phase_tests.rs:8037-8068). For non-thinking models, or thinking models with thinking disabled, the whole generation is answer JSON and remains width-1 MTP + step-level feedback barrier.
Consequence: #626 addresses only the reasoning-token portion. The answer-JSON portion (which in #530's ~1.5K-token JSON outputs is most of the decode) keeps the 2-3x penalty. #530's asks 1 (per-draft-position masks), 2 (per-request rather than per-batch barrier) and 3 (documented note) are not delivered for that case; #626's docs changes do not add the operator note #530 asked for.
Also of note: #626 does not cite #530 anywhere in its description (verified: no issue references in PR text). It also does not update docs/TODO.txt.
The affected surface is instead: thinking models with json_schema/Lark/strict tools that reason first — the DeepSeek/TML-content-header and Atem recipes (grammar_reasoning at RecipientHeader/RecipientFrame), plus any model starting at OutputStart::Reasoning.
#9 [high] Community and process: no engagement, unexplained CI failure, author standing
Community: zero engagement. pr_comments on #626 returns "No comments." — no human review, no Autobot case-file/review bot post (contrast #619, which received an Autobot case file 20 min after opening and a full review at 40 min, plus a follow-up from the author). #626's description ends with "Discord: lukealonso" (the project's usual review channel note). No reactions recorded. No labels on the PR (orientation packet: labels: none), whereas #619 carried area:api, area:scheduling, enhancement, performance, triage:review.
People:
- Author lukealonso is a named priority contributor in the charter ("Priority contributors (@voipmonitor, @original-el8, @lukealonso) carry extra weight"), GitHub association COLLABORATOR. 25 merged PRs in the last 180 days, 0 closed, 0 open; areas: helios/src (19), docs (15), ignition/preparation (8), flare-cli/src (6), tests/preparation (6). Dominant committer in helios/src (228 of the last 180 days' commits) and docs (383).
- Same area, other regulars: Martin Vit (52 commits helios/src), yatesdr (47). yatesdr was the reviewer that shaped the #418 grammar contract and yatesdr authored #167 (thinking_token_budget), which #626 also integrates with. joshua Cartu (jcartu) authored #418/#505 (admission.rs, request.rs). newjordan authored #615 (ContentHeaders thinking budget) — the ContentHeaders path #626's Atem/TmlJson re-entry branch touches.
- Nobody else has engaged on #626 yet.
Process: state "open, ready for review", base main, head f7907a2, opened and last updated 2026-11-30 (same day), 9 files +1405/-39. CI on head commit: FAILED. The PR reports local release test runs (helios 1806 passed/0 failed/83 ignored; flare 237; flare-cli 211; heliopause 216; TLA+ 8 models) and lists unrun checks (live CUDA serving + benchmarks, cargo-kani, 83 checkpoint-gated tests), but does not explain the CI failure — the same gap the #619 review flagged ("Unreconciled CI ... on head 22a1dee"). CI workflows that run on this PR: native-serving.yml (ubuntu+windows: build, eos/selene/selene-manager, helios release tests with --features runtime-core,server, flare-cli, flare), python-cpu.yml (pytest tests/), helios-lifecycle.yml (lifecycle TLA+ + kani). None of these runs debug builds, and all use --release.
#10 [high] Project fit: charter lines up on layering, conflicts on measured evidence
Charter (read in full) mapping, as facts: LINES UP:
- "Keep the runtime small and model-agnostic"; "No per-model special cases or flags": #626 adds no model-name branch and no flag. Eligibility is computed from output-envelope shape (OutputStart, envelope.recipient) in helios/src/server/request.rs:408-426 and ToolParserKind in runtime.rs:264-274 (Atem/TmlJson). ToolParserKind is a contract-level enum, not a model name.
- "PR descriptions: Expect four parts (why / what changed / claimed result / evidence)": #626 has all four, plus an explicit "Unrun checks" list and a "Discord:" line.
- "Don't silently ignore API fields": no API fields added or dropped. TENSIONS:
- "Bring real evidence. Performance PRs need benchmarks showing an actual speedup over main on a served workload (#210)." #626's own text: "Expected performance improvement (not yet measured on a live GPU)"; "Live CUDA serving and throughput benchmarks on exported model cores (not run in this environment; performance claims above are expectations, not measured GPU numbers)." No measured number at all. Note the same Autobot review of #619 called this out as a charter violation ("violates the charter requirement that performance PRs include live served-workload benchmarks over main (#210)").
- "Supported matrix & compatibility: Check interactions across every supported model, cache scheme, parallel layout... Check state and CUDA-graph transitions": the new transition path depends on Restore + chunked Prefill reconstructing exact KV and non-invertible recurrent state "across every supported cache scheme" (PR text). Only CPU-side mocked-graph tests exercise it; the 83 ignored checkpoint/GPU-gated helios tests and all live serving were not run. The PR asserts "existing exported model cores work without re-export" (no core-format/ABI change; verified — no proto/kernel files in the diff).
- Charter Values: "Solve the right problem in the right place" — the change stays in Helios host logic, no per-model rollback kernels (PR explicitly argues this), which matches the layering rule.
#12 [high] Reach: automatic for thinking+grammar requests, no flag, no ABI change
Reach, as facts:
- Users affected: any client sending
response_formatjson_schema/json_object, a Larkgrammar, or a strict function tool, on a model whose output starts in reasoning or a recipient/content header (DeepSeek DSML/TML, Atem, ContentHeaders recipes). Those requests get faster reasoning decode and stop stalling concurrent unconstrained peers — the exact complaint in #530. - Operators/configuration: NO new flag, setting, metric, or CLI option.
Prompt/Incomingfields are internal. The behaviour change is automatic and cannot be disabled: there is no way to keep the old whole-generation width-1 path (contrast #620, which removed a flag; and #619, whoseflare_constrained_max_inflightcontract stays "must remain one", helios/model-contract.md:438-441). - Compatibility: no protobuf, kernel ABI, core-format, or CUDA-graph changes; existing exported cores load without re-export (diff contains no proto/graph/kernel files; the proto file is not in pr_files). Metrics semantics unchanged.
- Output/compatibility risk: seed re-derivation at each transition (
continuation_seed(seed, generated_tokens), runtime.rs:2469-2471) means identical requests with the same seed will not produce the same tokens as on main. - New observable error: a grammar-rejected token with no remaining budget/context fails the request with
ExecutionError::Completion"grammar rejected token with no remaining output capacity" (runtime.rs:1955-1961) → 500 / terminal SSE error, where main simply could not sample such a token. - Documentation reach: docs/api.md:645-655, docs/core-design.md:1692-1709, docs/mtp-design.md:410-431 updated; docs/core-design.md:1242-1248, docs/scheduling-runtime-design.md:548-552, helios/model-contract.md:236-238, docs/mtp-design.md:597-599 not updated.
- Cross-repo: no recipe/export changes needed (unlike #620, which required local-inference-lab/hyperflare-recipes#94).
#13 [high] Claims and evidence: each claim, what backs it, what does not
CLAIM-BY-CLAIM status (from PR text vs what the repo/diff shows):
- "expected to decode the reasoning phase at full speculative widths and two-frame pipelining without per-step CPU mask generation or H2D mask uploads" → mechanism verified in code (#619 idioms; scheduler.rs:2257, policy.rs:308-311, scheduler.rs:1085-1094, packing.rs:803). NO measured GPU number. PR says so explicitly.
- "without forcing concurrent unconstrained requests in the same batch down to one step in flight" → true only while the constrained request is in its reasoning phase; once reasoning closes the request is device-constrained again and
plan_requires_feedbackputs the whole submitted batch back on one frame (scheduler.rs:1088-1091). For a typical JSON-answer workload the constrained request spends most output tokens in that state. - Unit test
unmasked_advancement_matches_masked_decisions_and_defers_mask_sync(grammar.rs ~1854-1920) → verified present, compares masks bit-for-bit and checks premature EOS, padded OOV IDs, post-close constrained continuation. Good but CPU-only, release build (debug_asserts compiled out). speculative_grammar_reasoning_runs_pipelined_and_transitions_on_close_with_overshoot(phase_tests.rs:7300-7455) → verified present and asserts exactly what is claimed: width 8, two frames, requires_feedback false, grammar_mask None during reasoning, mid-burst close with 2 overshootxtokens suppressed from observed/tokens/Finished count (6), Restore on readmission, width-1 constrained continuation to EOS. Uses a mocked/fixture graph harness (speculative_burst_frame,advance), not real GPU...._rolls_back_forbidden_token_including_premature_eos→ verified; covers both mid-burst and token-0 (first_token_forbidden) rejection and the Init-vs-Restore readmission split...._integrates_with_thinking_budget_and_logprobs→ verified; covers natural early close (merges after=6 into remaining=8, suppresses overshoot logprob) and budget-exhaustion forced close (injects</think>, 5 answer tokens remain,plain_tokens == [think_end])...._preserves_mode_on_preemption_and_stays_constrained_without_reasoning→ verified; Content-start stays width-1/feedback, and preemption park preserves speculative mode.content_header_envelope_enters_speculative_reasoning_after_header_and_returns_to_constrained→ verified (TmlJson/ContentHeaders fixture).prepare_inference_enables_speculative_grammar_reasoning_only_for_eligible_envelopes→ verified (phase_tests.rs:8015-8071, three cases).- Test suite counts: helios 1806 passed/0 failed/83 ignored; flare 237; flare-cli 211; heliopause 216; TLA+ 8 models. Not independently verifiable here; CI on the head commit FAILED and the PR gives no CI explanation.
- NOT run (stated): live CUDA serving/benchmarks, cargo-kani, 83 checkpoint/GPU-gated tests. So the claim "reconstructs KV and non-invertible recurrent state across every supported cache scheme" is unverified on any real cache scheme.
- Description overstates one thing: "For Atem and TmlJson envelopes starting in a constrained header, a rising edge into reasoning_open() transitions into speculative reasoning" — actually
allow_reasoning_reentry()only requires the envelope to exist ingrammar_reasoningand its ToolParserKind to be Atem|TmlJson (runtime.rs:264-274); the description's precondition "starting in a constrained header" is how grammar_reasoning gets set in request.rs, so this is consistent, but the branch fires whenever reasoning reopens at any point in the generation, not only the first header.
#16 [high] Research summary
Case file for PR #626 "Allow speculative reasoning for grammar-constrained requests" (lukealonso, open, head f7907a2, 9 files, +1405/−39, no comments/reviews, CI failed). Sixteen scratchpad entries cover all eight angles.
Key findings a reader could not get from the description:
- Undeclared new work:
Active.reasoning(the worker-side OutputPipeline decoder) is now built for every eligible grammar request, not onlythinking_token_budgetones (runtime.rs:1639-1658), and pushes/reasoning_open() runs per accepted token in parallel with the client decoder — added host cost the description does not mention. - New debug-only panic:
RequestGrammar::mask()/allows()gaineddebug_assert!(!mask_dirty)(grammar.rs:676-693); every test cited in the PR runs--release, so the guard is never exercised by the claimed evidence. - New terminal failure mode: a grammar-rejected token with no remaining budget/context fails the request with
ExecutionError::Completion(runtime.rs:1955-1961) — impossible on main, where the device mask prevented it. - Sampling reproducibility changed: every transition re-derives the seed via
continuation_seed(runtime.rs:2469-2471). - The behaviour change is automatic and unconfigurable — no flag to keep the old path (contrast #619, whose
flare_constrained_max_inflightcontract is untouched and now undercounts reasoning-phase frames). - Docs are only half-updated: docs/core-design.md:1242-1248, docs/scheduling-runtime-design.md:548-552, helios/model-contract.md:236-238 and docs/mtp-design.md:597-599 still state the old unconditional rule, contradicting the new paragraphs at core-design.md:1692-1709.
- Scope gap vs the motivating issue: #530's measurement was
enable_thinking: falsejson_schema, which stays fully device-constrained under #626's eligibility rule; the PR never cites #530. Likewise the answer-JSON phase keeps width-1 and the batch-wide barrier (scheduler.rs:1085-1094).
Related/process facts: #626 directly follows #619 (same author, previous day) which explicitly left grammar at width-1, and amends the contract written for #418 (where reviewer yatesdr required the whole-generation one-step-in-flight cost to be documented); it reuses #615's ReasoningCut/close-tail/UTF-8-trim plumbing and builds on #620's grammar.rs rewrite. Charter fits on layering/no-flags, conflicts on "performance PRs need measured benchmarks (#210)". Author is a named priority contributor and the dominant committer in these files; zero community engagement on this PR.
#6 [medium] Recent activity: #620 rewrote grammar.rs immediately before #626
#620 "Remove copy drafts and history drafts while keeping legacy cores loadable" (lukealonso, merged 2026-11-29 22:51, +584/-2014, 50 files) is the immediately preceding commit on main (c146d7be) and is #626's base.
- #620 removed
RequestGrammar::copy_masksand "copy-specific grammar mask cloning" from helios/src/grammar.rs (+20/-174 in that file), i.e. grammar.rs was heavily rewritten one commit before #626 buildsmask_dirty/sync_mask/try_advance_unmaskedinto it. - #620 also removed
COPY_GRAMMAR_MASK/COPY_GRAMMAR_COUNTcolumn uploads for legacy cores (neutral sentinels). Relevant because #626's claim "avoiding per-step mask uploads" is adjacent to upload-path work that just changed. - #620 has no discussion (0 comments) and merged same day, ~2h before #626's base. No conflicts: nothing on main since c146d7b touches #626's files (per orientation packet, "Commits on the default branch since this pull request branched (c146d7b), touching its changed files: none").
#11 [medium] Change: verified mechanism and reuse of #619 idioms
MECHANISM (verified in code, useful for reviewers):
- Eligibility (helios/src/server/request.rs:408-426, runtime.rs:253-262): grammar present AND output starts at OutputStart::Reasoning, or envelope has a recipient and start is RecipientHeader/RecipientFrame.
- While active:
Incoming::spec()setsgrammar_constrained=false(runtime.rs:279-283) → scheduler.speculative_tokens no longer clamps to 1 (scheduler.rs:2253-2259), policy.rs:301-314 lets a lane with pending<2 queue again, and plan_requires_feedback no longer forces a barrier (scheduler.rs:1085-1094). Hence full width + two frames. - Admission uploads no mask: Admission::from_prompt(grammar_constrained=false) → grammar_mask None (admission.rs:109-125) → packing GrammarEnabled = 0 (helios/src/model/packing.rs:803) and no sampling_grammar_mask upload.
- Boundary: Worker::complete validates each accepted token with try_advance_unmasked (runtime.rs:1900-1963); when reasoning closes (is_open false, :2060-2120) or a token is rejected (:1921-1962) it records a GrammarTransition, then parks: park_grammar_transition (:2407-2428) → park_with_tokens(publish_terminal=false) → scheduler.cancel (:2448) → slot marked
retiringand pages retained until the queued frame drains (scheduler.rs:2973-2975, 3091), same Cancel→Retiring→Complete→Free lifecycle #619 documented and TLA+ Lifecycle.tla covers. - Overshoot suppression:
skipped = burst_counts[slot] - positionsubtracted from live.generated_tokens (:1941, :2068, :2133), the accounting idiom introduced in #619. - Runtime no longer advances grammar per token for these lanes (:1983) and no longer calls grammar_updated/mask upload per token (:1997-2000 is skipped) — this is the claimed saving and it is real for the reasoning phase.
- thinking_token_budget interplay: sync_mask() before
grammar.allows(cut.close[0])(:2217-2238), andgrammar_reasoning_mode = Some(false)on the continuation pass when a cut is configured (:2280-2282). - Transition entry for Atem/TmlJson headers: rising edge !was_open→is_open with
allow_reasoning_reentry()(runtime.rs:2121-2152), requiring grammar not stopped/accepting, remaining>1. - Restore: readmission goes through the normal parked/readmit path (:2454-2487) so the prefix-cache lookup picks the longest cached checkpoint (GraphKind::Restore) then Prefill replay of the suffix; the phase test asserts Restore is used when a prompt checkpoint existed and falls back to Init when the forbidden token arrived on token 0 (phase_tests.rs:~7560 "Token 0 failed during Prefill before any prompt checkpoint was captured").
#14 [medium] Related work: #615 built the reasoning-cut plumbing #626 reuses
#615 (newjordan, merged 2026-11-29 21:22, +614/-50) added thinking_token_budget support for ContentHeaders/TMLv0 and, in the same files, introduced the machinery #626 now routes through:
ReasoningCut { close: Vec<u32>, after: u32, output: Option<OutputConfig> }(helios/src/server/runtime.rs:53-61) — #626 mergescut.afterintoremainingon natural early close and reusescut.outputas the decoder config.OutputConfig::reasoning_close_tail()(helios/src/output/pipeline.rs) andtml::text_frame_opener().trim_incomplete_utf8_tail()called fromWorker::park()(runtime.rs:2395-2404) for non-empty appended tokens only.Active::close_reasoning()(runtime.rs:499-512) which advances the grammar viagrammar.advance(close)— #626 addedsync_mask()beforegrammar.allows(cut.close[0])at runtime.rs:2217-2238 precisely because that call site would otherwise read a deferred mask (and hit the new debug_assert / use a stale mask). Note: #626's newpark_with_tokenspath used bypark_grammar_transitiondoes NOT calltrim_incomplete_utf8_tail(it sliceslive.tokens()[..exact_len]). Truncation always lands on a whole generated token, so it can leave an incomplete multi-byte UTF-8 tail in the re-prefilled continuation only if the dropped overshoot tokens completed a character started by the last kept token. Preemption'spark(&[], ...)path also skips trimming, so this matches existing behaviour rather than introducing a new class; worth flagging as a low-severity edge. #615's Autobot review recommended "Ready To Merge" with live GB10/SM121 Inkling-2-Mini serving evidence — i.e. the bar applied to a neighbouring PR in the same files included live serving.
#15 [medium] Why: how long and how widely the problem has been reported
Chronology of the want (all verifiable from item numbers/dates):
- #167 (yatesdr, merged 2026-11-02) added
thinking_token_budget; its description notes "No injection when ... a grammar disallows the close" — grammar × reasoning-budget interaction has existed since then. - #417 (closed) → #418 (merged 2026-11-22) introduced strict function tools and ratified the whole-generation grammar / width-1 / one-step-in-flight contract, with measured latency cost (3.49 s vs 1.09 s at C8).
- #530 opened 2026-11-25 by devinkuhn: structured output 2-3x slower, MTP width one; explicit ask "Is MTP with per-draft-position grammar masks on the roadmap?" and "Could the one-step-in-flight rule apply per request rather than per batch?"; states vLLM serves the same model with MTP + json_schema without the penalty. No maintainer reply in the issue (0 comments).
- #619 (merged 2026-11-29 21:40) unlocked host stops but explicitly kept grammar requests at width-1, naming #530 as related.
- #626 (2026-11-30) is the first change to give grammar-constrained requests any speculative width. So: asked for 5 days before this PR; the design constraint has been documented since #418 (8 days) and #619 (1 day). No duplicate or competing PR exists (searched "grammar", "speculative reasoning", "per-draft-position grammar masks", "one step in flight constrained batch").
#17 [medium] Related work: packet leads followed vs dismissed
Orientation-packet leads, followed or dismissed: FOLLOWED: #530 (open issue, direct motivation — entry 2), #619 (merged predecessor, same author — entry 3), #620 (merged 2h before, rewrote grammar.rs — entry 6), #418 (merged, wrote the docs contract #626 rewrites — entry 5), #615 (merged, ReasoningCut/close-tail/UTF-8-trim plumbing #626 reuses — entry 14), #167 (merged, thinking_token_budget, yatesdr — the budget path #626 integrates with; see entries 14/15). JUDGED NOT RELEVANT (checked by name/file overlap only):
- #457 (open, brandonmmusic-max) "Fail untyped TML model headers at EOS and align TMLv0 content-header and strict-tool grammars" — same TmlJson envelope area but different behaviour (EOS handling, grammar alignment); no file conflict with #626's changed files inside request.rs grammar paths. Worth a reviewer glance for shared
OutputConfig/TmlJson envelope usage, not a dependency. - #548 / #560 (open, WynnD) per-request metrics — share helios/src/server/runtime.rs and docs/api.md but touch request-instant metrics, not grammar/speculation; no conflict.
- #621 (open, jcartu) scheduler admission vs core parameters — different code path.
- #554 (open DRAFT, ateska) Engram RDMA — unrelated.
- #483 (open, rickybrent) Gemma 4 image prep — unrelated.
- #458 (open, brandonmmusic-max) Responses SSE sequence_number — unrelated; its description notes tool grammars validated post-hoc, an aside.
- #461 (open, jcartu) docs for strict tool selection — docs only.
- #500 (open, voipmonitor) ERNIE 5.5 parsers incl. grammar.rs — adds parsers, no conflict, but will need rebasing against #626's grammar.rs changes if both land.
- #167, #94 (mark-yong, single-token reasoning delimiters), #228 (XTML closure) — background only. No competing or superseded PR found for the specific change: searches for "grammar speculative reasoning", "grammar mask device per position draft", "grammar constrained decoding slower speculative width", "per-draft-position grammar masks MTP width", "one step in flight constrained batch" returned only #626, #530, #619 and unrelated grammar/parser items.
#18 [medium] Change: test inventory and description-vs-code checks
Navigation aid for reviewers (all at PR head f7907a2): NEW TESTS and where they live
- helios/src/grammar.rs ~1854-1920:
unmasked_advancement_matches_masked_decisions_and_defers_mask_sync(mask bit-for-bit equality, premature EOS 256, padded OOV, post-close constrained JSON). - helios/src/server/runtime/phase_tests.rs:
- :7300-7455
speculative_grammar_reasoning_runs_pipelined_and_transitions_on_close_with_overshoot(width 8, two frames,!requires_feedback,grammar_mask.is_none(), overshootxsuppression, Restore, width-1 to EOS) - :7457-~7595
..._rolls_back_forbidden_token_including_premature_eos(loop overfirst_token_forbidden, Init vs Restore readmission) - :7598-7735
..._integrates_with_thinking_budget_and_logprobs(natural early close merging cut.after; forced close injection; logprob suppression) - :7736-7815
..._preserves_mode_on_preemption_and_stays_constrained_without_reasoning - :7820-8012
content_header_envelope_enters_speculative_reasoning_after_header_and_returns_to_constrained(TmlJson + ContentHeaders fixture,<|content_thinking|>→ width 8,<|end_message|>→ rollback into constrained) - :8015-8071
prepare_inference_enables_speculative_grammar_reasoning_only_for_eligible_envelopes(Reasoning→Some, Content→None, raw completions→None) - Helper:
enable_speculative_worker(:7290-7298) sets fixed width 8 and enables speculation; frames are built withspeculative_burst_frame/advance/plannedhelpers on a fixture model config — i.e. synthetic graph scheduling, no CUDA.
- :7300-7455
- helios/src/server/runtime/prompt_tests.rs:52 — one-line fixture update (
grammar_reasoning: None). AREAS THE DIFF TOUCHES but with no test change: helios/src/model/admission.rs (mask gating, covered indirectly by phase tests assertinggrammar_mask.is_some()/is_none()at phase_tests.rs:7321, 7386, 7526, 7710, 7755, 7809, 7908, 7920, 7954); helios/src/scheduler.rs and policy.rs are NOT modified (the width/pipelining change comes purely fromgrammar_constrained=falseinIncoming::spec(), runtime.rs:279-283). PR-description statement NOT matched by code diff: "No GPU graphs, kernel ABI bindings, or Protobuf schemas changed" — confirmed by the diff (docs + helios/src Rust only; no helios/proto, ignition, or kernel files). PR-description claim that could mislead: "For Atem and TmlJson envelopes ... a rising edge into reasoning_open() transitions into speculative reasoning" — the branch (runtime.rs:2121-2152) fires on any false→true reasoning_open transition for such envelopes, not only the first header, and requires the grammar to be neither stopped nor accepting plus remaining>1.