Repository navigation
scheduler: let tool-grammar sequences ride the batched MTP verify (agent traffic verified one request at a time) - #203
Merged
Conversation
The batched pick already runs the same per-sequence fast/slow selection as the serial path, with per-row grammar masks keeping picks legal, so the routing filters were the only things keeping grammar sequences on the ~40 ms serial step. Non-strict grammar sequences now land in plan.batch; strict grammars and grammarless sequences are unchanged. ATLAS_GRAMMAR_SERIAL_VERIFY=1 restores the old routing for A/B. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… injectable kill switch Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…C cap) Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This was referenced Oct 27, 2026
Merged
7 tasks done
AzeezIsh
pushed a commit
that referenced
this pull request
Nov 11, 2026
…LAS_STRICT_SPEC A speculating strict (response_format) sequence still took a verify forward of its own every step: plan_verify kept every strict grammar on the per-sequence path. N concurrent structured requests ran N verify forwards a step, and a lone one was cut to 3 drafts because the deep window (ATLAS_MTP_DYNAMIC_DEPTH) only runs through the batched verify. On a full-logits MTP verify the batched pick already runs the same host pipeline per member as the per-sequence verify (the non-strict grammars of #203 ride it), so strict sequences now join the batch, as decode rows too, where strict_spec::rides_batch holds. The argmax-only head and the DFlash batch keep the per-sequence verify. ATLAS_GRAMMAR_SERIAL_VERIFY restores it for every grammar, which is the A/B arm. No new variable. Tests: routing, two strict members in one forward (one sampled, with an illegal draft and an illegal raw top), a window crossing </think>, and a lone deep window. Not run on hardware. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@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.
Summary
Requests that send
toolsget the tool-call grammar for their whole response (compiled at prefill).mtp_step/one_forward.rs::plan_verifykept every sequence withgrammar_state.is_some()off the batched verify (plan.serial, and out ofdecode_rows). Any agent client that sends tools on every request (OpenClaw, opencode) therefore verified one request at a time. Rob Skillet measured it on 2×GB10 Flash-Next TP=EP=2: 4 concurrent tool requests at 41.0 tok/s total vs 96.5 with--disable-tool-grammar, with each step costing ~40 ms per request.Nothing in the batched path actually needs grammar sequences excluded:
verify_pipeline_helper/batch.rs::verify_pick_batchalready runs the serial path's per-sequence selection on each member's own rows: greedy-under-grammar fast path, then the masked host pipeline.fast()admits grammar under theLegacyFallbackpolicy the batch uses, so picks stay grammar-legal and the matcher only advances inemit_token.verify_k4_batch_step.rs,mtp_grammar_masks_for).Change: non-strict grammar sequences now ride the batched verify, including as decode rows. Strict (
response_format) grammars keep the serial path.ATLAS_GRAMMAR_SERIAL_VERIFY=1restores today's routing.Evidence
nvidia/Qwen3.8-Flash-Next-FP4-Local, recipe profile (exact verify and batching lanes, MTP 3 drafts, prefix caching).--max-num-seqs 4, tool grammar ON, 24 requests (16 tool calls, 8 prose) at T=0 throughgrammar_bench.py.f251cfdb582e7994, one binary for all arms.cargo test --bins one_forward9/9,grammar111/111.ATLAS_GRAMMAR_SERIAL_VERIFY=1(today)--disable-tool-grammar truespec_step::effective_drafts_under_grammar). Giving every draft position its own mask, so grammar sequences can propose at full width, is the follow-up.Test plan
decode_rows-p spark-server --tests--disable-tool-grammar true; seedocs/notes/HANDOFF_PR388.mditem 13)Generated with Devin