Skip to content

[Frontend] Add the Beam reasoning and tool parsers - #62052

Merged
WoosukKwon merged 2 commits into
mainfrom
woosuk/beam-parser
Oct 16, 2026
Merged

WoosukKwon merged 2 commits into
mainfrom
woosuk/beam-parser

Conversation

@WoosukKwon

@WoosukKwon WoosukKwon commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Overview

Second slice of #61978 (Reflection Beam), after #62042: the beam reasoning and tool parsers, in Python and in the Rust frontend. They take effect only with --reasoning-parser beam or --tool-call-parser beam. This does not enable the model end to end.

Claims

  • New parsers: --reasoning-parser beam and --tool-call-parser beam parse output with the checkpoint's response_template metadata, as hf does. They also derive a structural-tag grammar from the template, which constrains:
    • strict tools;
    • required and named tool choice;
    • structured outputs;
    • by default, every other request, so output follows the template's format. VLLM_BEAM_ALWAYS_CONSTRAIN_OUTPUT=0 turns this off.
  • Docs: docs/features/tool_calling.md documents the parser.

Validation

Results on this branch next to upstream main (fa75d34), on the same machine:

Command This PR main
pytest tests/parser tests/reasoning tests/tool_parsers --ignore=tests/parser/cohere 8267 passed 8064 passed
cargo test -p vllm-parser 578 passed 561 passed
cargo test -p vllm-chat --lib 357 passed 356 passed
  • Same failures on both trees, all from this machine's setup:
    • Python: 10 failed and 117 errors in tests/parser/mistral and the Step-3.5 parser tests, because their tokenizers can't be downloaded into the read-only shared HF cache.
    • Rust: the vllm-chat roundtrip and grammar_replay tests, because they need write access to a lock file or that same HF cache.
  • Not run: tests/parser/cohere needs the optional cohere_melody package, which isn't installed here.

Details

  • Shared code touched:
    • ParserManager now picks any response-template parser, not just hf. A parser opts in through unified_parser_cls(). The hf behavior is unchanged except for error messages, which now name the selected flags.
    • OnlineRenderer passes the prompt token IDs to the parser before adjust_request. Beam needs this to see whether the prompt already opened reasoning or an answer. Only the response-template parsers (hf, beam) override set_prompt_token_ids; for all other parsers the base class method does nothing.
    • ResponsesRequest gets two private attributes, so a parser-built grammar can replace text.format without changing the request's public fields.
  • Response-template parser fixes, which also apply to hf:
    • When output stops inside a closer whose last part is the next message's start anchor, the parser completes the closer instead of reporting it as malformed.
    • Reasoning tokens are counted incrementally from the template.
  • Size: about 2.3k non-test lines. Most of it is the grammar builder (vllm/parser/response_template_grammar.py) and the Rust beam parser.
  • Not a duplicate: no open PR adds a Beam parser.

Pull Request Checklist
  • I used vLLM's /pr-checklist skill. (Mandatory for agents, optional for humans).

  • AI assistance was used during the creation of this PR.

  • Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.

  • Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.

  • Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.

  • Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.

🤖 Generated with Claude Code

Preparation for Reflection Beam (#61978). Adds `--reasoning-parser beam`
and `--tool-call-parser beam` in Python and the Rust frontend. Like `hf`,
they parse with the checkpoint's `response_template` metadata; unlike
`hf`, they derive a structural-tag grammar from the template to constrain
tool calls, tool choice and structured outputs.

ParserManager now selects any response-template parser, not only `hf`.
The renderer gives the parser the prompt token IDs before
`adjust_request`.

Co-authored-by: Bugen Zhao <i@bugenzhao.com>
Co-authored-by: Yoni Gozlan <74535834+yonigozlan@users.noreply.github.com>
Co-authored-by: neilkg <33635204+neilkg@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Woosuk Kwon <woosuk@inferact.ai>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@mergify

mergify Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Documentation preview: https://vllm--62052.org.readthedocs.build/en/62052/

@mergify mergify Bot added documentation Improvements or additions to documentation frontend rust tool-calling labels Oct 16, 2026
@github-project-automation github-project-automation Bot moved this to Unsorted queue in Tool Calling (arpera) Oct 16, 2026
@WoosukKwon WoosukKwon added the ready ONLY add when PR is ready to merge/full CI is needed label Oct 16, 2026
@WoosukKwon

Copy link
Copy Markdown
Collaborator Author

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #95456 for commit 43a4cf47789d.

@WoosukKwon WoosukKwon mentioned this pull request Oct 16, 2026
6 tasks done
@WoosukKwon WoosukKwon added the beam Reflection Beam model support label Oct 16, 2026
WoosukKwon added a commit that referenced this pull request Oct 16, 2026
Adds Beam-1.0 (BeamForCausalLM, 501B total / 23B active, NVFP4) and its
DFlash2 drafter (DFlash2BeamDraftModel), with model-local Blackwell
kernels under vllm/models/beam/nvidia: attention, fused
all-reduce + norms, and DFlash2 context ops.

FusedMoEConfig.defer_moe_finalize gains allow_ep so that a consumer that
reduces across a replicated-token EP group can take the TRTLLM-Gen
top-k finalize under TP=1, EP>1.

Builds on #62042 (router GEMMs, BF16 ll_bf16_gemm output), whose commit
is included below this one. The beam reasoning/tool parsers are in
#62052; MegaMoE support follows in #62073.

Co-authored-by: Lain <fusiyuan2000@gmail.com>
Co-authored-by: kaiwu-reflection <kai@reflection.ai>
Co-authored-by: Yoni Gozlan <74535834+yonigozlan@users.noreply.github.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Woosuk Kwon <woosuk@inferact.ai>
@WoosukKwon
WoosukKwon merged commit 153a171 into main Oct 16, 2026
169 of 170 checks passed
@WoosukKwon
WoosukKwon deleted the woosuk/beam-parser branch October 16, 2026 21:08
WoosukKwon added a commit that referenced this pull request Oct 16, 2026
Adds Beam-1.0 (BeamForCausalLM, 501B total / 23B active, NVFP4) and its
DFlash2 drafter (DFlash2BeamDraftModel), with model-local Blackwell
kernels under vllm/models/beam/nvidia: attention, fused
all-reduce + norms, and DFlash2 context ops.

FusedMoEConfig.defer_moe_finalize gains allow_ep so that a consumer that
reduces across a replicated-token EP group can take the TRTLLM-Gen
top-k finalize under TP=1, EP>1.

Builds on #62042 (router GEMMs, BF16 ll_bf16_gemm output), whose commit
is included below this one. The beam reasoning/tool parsers are in
#62052; MegaMoE support follows in #62073.

Co-authored-by: Lain <fusiyuan2000@gmail.com>
Co-authored-by: kaiwu-reflection <kai@reflection.ai>
Co-authored-by: Yoni Gozlan <74535834+yonigozlan@users.noreply.github.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Woosuk Kwon <woosuk@inferact.ai>
kotwal-itpro added a commit to kotwal-itpro/vllm that referenced this pull request Oct 17, 2026
vllm-project#62052 replaced ResponseTemplateParser.count_reasoning_tokens, which
used to return 0 for --reasoning-parser hf. Add unit tests for the
four cases usage depends on: a closed thinking region, a region opened
by the prompt, an unclosed region, and no thinking at all. Delimiters
are not counted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011ZBQVsXRmKT8WXDr2qSfbd
Signed-off-by: Ankur Kotwal <kotwal.itpro@gmail.com>
michael-gpu pushed a commit to practical-inference/vllm-ampere-extended that referenced this pull request Oct 20, 2026
Signed-off-by: Woosuk Kwon <woosuk@inferact.ai>
Co-authored-by: Bugen Zhao <i@bugenzhao.com>
Co-authored-by: Yoni Gozlan <74535834+yonigozlan@users.noreply.github.com>
Co-authored-by: neilkg <33635204+neilkg@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@arpera arpera removed this from Tool Calling Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beam Reflection Beam model support documentation Improvements or additions to documentation frontend ready ONLY add when PR is ready to merge/full CI is needed rust tool-calling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant