Skip to content

Fix gemma4 parallel tool calling with MTP enabled - #45068

Closed
Raf38 wants to merge 1 commit into
vllm-project:mainfrom
Raf38:gemma4/mtp-parallel-tool-fix
Closed

Fix gemma4 parallel tool calling with MTP enabled#45068
Raf38 wants to merge 1 commit into
vllm-project:mainfrom
Raf38:gemma4/mtp-parallel-tool-fix

Conversation

@Raf38

@Raf38 Raf38 commented Jun 9, 2026

Copy link
Copy Markdown

Purpose

Fixes #41967.
Fix gemma4 tool parser when the model emits end tool and start tool in the same delta due to MTP speculative decoding. Without this fix the first tool call gets prematurely abandoned with out the proper json closures. The second tool call gets emitted correctly. I've added a new test case for the exact scenario we see.

Please can someone comment on this:
This PR removes the buffering of incoming deltas for the case where a start/end tool call token gets split across deltas. Given that Gemma4 has dedicated tokens for start and end of tool call we don't believe this is necessary. Across a few 10,000 tool call's we've never seen Gemma4-31B emit anything other than the special tokens. This buffering code appears to have been in the parser from the start leading us to believe it may have been a hangover from the model that inspired this parser?

Test Plan

Added new test case to pytest for the sequence of chunks that triggers the bug.
I had to modify test_streaming_does_not_duplicate_plain_text_after_tool_call as it was dubiously verifying the internal parser implementation rather than just the externally visible output.

Test Result

All tests pass.

There are a few other proposed PR's for this issue, but I believe this is the smallest in terms of minimal change to the existing implementation.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

👋 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.

PRs do not trigger a full CI run by default. 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 ready label to the PR or enable auto-merge.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

Agent Guidelines

IMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban.

🚀

@Raf38

Raf38 commented Jun 13, 2026

Copy link
Copy Markdown
Author

The issue (and test case I proposed here) has been fixed by #45163

@Raf38 Raf38 closed this Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: Gemma4 + MTP speculative decoding drops first tool-call arguments in streaming multi-tool auto-tool-choice

1 participant