[Bugfix] Stop XGrammar at terminal tokens - #2
chubby-cutie wants to merge 1 commit into
Conversation
Avoid advancing XGrammar matchers past a terminal token in accepted and speculative validation batches. Reset the cached termination state alongside the matcher. Co-authored-by: OpenAI Codex <noreply@openai.com> Signed-off-by: chubby-cutie <chubby-cutie@users.noreply.github.com>
|
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run You ask your reviewers to trigger select CI tests on top of Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can either: Add If you have any questions, please reach out to us on Slack at https://slack.vllm.ai. 🚀 |
|
@wangyxbh Could you please review this follow-up fix and merge it into The focused tests, Ruff checks, and a 10-minute DSpark + tool-calling stress test have passed. The remaining workflow requires maintainer approval. |
|
@chubby-cutie I think this is fixed by vllm-project#52805 |
|
Thanks for pointing this out. I confirmed that vllm-project#52805 covers the same termination-state synchronization and speculative token-batch handling. I'll close this PR as superseded. |
Summary
This is a follow-up to vllm-project#37506 and is based on commit
9228d56.Why
A speculative batch may contain EOS followed by trailing draft tokens. Once XGrammar accepts EOS, its matcher is terminal and must not receive another token. Continuing past EOS emits matcher warnings and can leave vLLM's cached state inconsistent.
Validation
tests/v1/spec_decode/test_mtp_structured_output.py: 18 passedgit diff --checkpassed