fix(verl): preserve multi-turn tool-call prefix extension for math tool agent for Qwen 3 models#516
Draft
JasonWei05 wants to merge 2 commits into
Draft
fix(verl): preserve multi-turn tool-call prefix extension for math tool agent for Qwen 3 models#516JasonWei05 wants to merge 2 commits into
JasonWei05 wants to merge 2 commits into
Conversation
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
This PR adds
rllm.multi_turn_extensionsupport for Qwen 3 multi-turn tool-calling rollouts through the verl gateway path. When enabled, the gateway renders chat prompts with rLLM's chat template parser and forwards raw text to vLLM's/v1/completions, avoiding vLLM chat-template canonicalization that breaks prefix-extension checks. Qwen 3 and Deepseek-Qwen parsers now preserve model-emitted assistant whitespace around tool calls so replayed turns remain byte-identical. This is not an issue for Qwen 3.5 and Qwen 3 coder models, which useqwen3_coderandqwen3_xmlparsers. This is an issue with thehermesparser.Type of change
What changed
multi_turn_extension=true, converting chat-completions requests to raw-text completions while preserving trace token ids and logprobs.multi_turn_extension, tokenizer name, thinking mode, and accumulated reasoning config through the gateway and verl rollout setup.cookbooks/math_tool_agent/train_verl.shdefault toMULTI_TURN_EXTENSION=truewith legacy vLLM tool parsing only when disabled.Validation
pre-commit run --all-filespytest ...Validation details:
PYTHONPATH=. uv run --no-project --with pytest python -m pytest tests/parser/test_multi_turn_extension.py -qpassed:4 passed.PYTHONPATH=src uv run --no-project --with pytest --with pytest-asyncio --with fastapi --with uvicorn --with httpx --with 'pydantic>=2' --with aiosqlite --with PyYAML python -m pytest tests/unit/test_parser_transport.py tests/unit/test_server.py -qpassed:60 passed, 2 warnings.PYTHONPATH=src uv run --no-project --with pytest --with pytest-asyncio --with fastapi --with uvicorn --with httpx --with 'pydantic>=2' --with aiosqlite --with PyYAML python -m pytest tests/unit/ -qpassed:186 passed, 2 warnings.uv run --no-project --with ruff ruff check ...passed on changed Python files.python -m compileall -q ...,bash -n cookbooks/math_tool_agent/train_verl.sh, andgit diff --checkpassed.Breaking changes / migration notes
rllm.multi_turn_extension, defaulting toFalsein base config.multi_turn_extension=true, gateway parser transport requires a tokenizer/model path and eitherrllm.disable_thinking=trueorrllm.accumulate_reasoning=true.n>1, multimodal chat content, and required tool-choice enforcement are not supported by the v1 parser transport path.Docs / examples
Related issues / PRs
Screenshots / logs
N/A