verl icon indicating copy to clipboard operation
verl copied to clipboard

Qwen3.5/6-35B-A3B tool call format unstable in vLLM token-in-token-out rollout with `enable_thinking=False`, while Qwen3.5-9B works

Open Junxiao-Zhao opened this issue 7 months ago • 1 comments

System Info

----------Python Info----------
Version      : 3.11.2
Compiler     : GCC 12.2.0
Build        : ('main', 'Apr 28 2025 14:11:48')
Arch         : ('64bit', '')
------------Pip Info-----------
Version      : 25.2
Directory    : /home/tiger/.local/lib/python3.11/site-packages/pip
vllm         : 0.20.0+cu129
sglang       : not found.
ray          : 2.46.0.14
torch        : 2.11.0
----------verl Info-----------
/usr/local/lib/python3.11/dist-packages/requests/__init__.py:113: RequestsDependencyWarning: urllib3 (1.26.20) or chardet (7.4.3)/charset_normalizer (3.4.4) doesn't match a supported version!
  warnings.warn(
Version      : 0.8.0.dev
Directory    : /opt/tiger/it_verl/verl
Commit Hash  : 91e9c3dc175226f9c99f62ac391b93c67adc4161
----------Platform Info----------
Platform     : Linux-5.10.135.bsk.6-amd64-x86_64-with-glibc2.36
system       : Linux
node         : g340-cd51-4900-be53-88e1-be50-d075
release      : 5.10.135.bsk.6-amd64
version      : #5.10.135.bsk.6 SMP Debian 5.10.135.bsk.6 Fri Aug 18 06:18:48 UT
----------Environment----------
OMP_NUM_THREADS="20"
CUDA Runtime : 12.9
CUDA Compiler : Cuda compilation tools, release 12.9, V12.9.86
----------System Info----------
CPU Memory      : 1928.46 GB
GPU Count       : 8
GPU 1   Type    : NVIDIA H20
GPU 1   Memory  : 95.58 GB
GPU 2   Type    : NVIDIA H20
GPU 2   Memory  : 95.58 GB
GPU 3   Type    : NVIDIA H20
GPU 3   Memory  : 95.58 GB
GPU 4   Type    : NVIDIA H20
GPU 4   Memory  : 95.58 GB
GPU 5   Type    : NVIDIA H20
GPU 5   Memory  : 95.58 GB
GPU 6   Type    : NVIDIA H20
GPU 6   Memory  : 95.58 GB
GPU 7   Type    : NVIDIA H20
GPU 7   Memory  : 95.58 GB
GPU 8   Type    : NVIDIA H20
GPU 8   Memory  : 95.58 GB

Information

  • [ ] The official example scripts
  • [x] My own modified scripts

Tasks

  • [ ] An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • [x] My own task or dataset (give details below)

Reproduction

Training Qwen3.5 or 3.6-35B-A3B with tools provided and disable thinking. During the val_before_train stage, the model didn't produce any tool call in valid xml format; instead, it produced the tool in python, in json, etc. For example:

{ "skill": "device_accessory_borrow", "asset_type": "asset", "asset_name": "windows 笔记本电脑", "need_knowledge_qa": true } 

it_knowledge_qa(rewrite_user_query="用户申请豆包", need_knowledge_qa=true)

I've tested on vllm 0.18.0, 0.19.0 and 0.20.0, but the problem persists. However, Qwen3.5-9B and previous Qwen3 series doen't have this problem.

How to reproduce

This is the same serve command verl used, reconstructed from the log file:

vllm serve \
    /dev/shm/verl-cache/fbf9dfd9b841bfa3f927427914b4092a/Qwen3.6-35B-A3B \
    --dtype bfloat16 \
    --load_format safetensors \
    --distributed_executor_backend mp \
    --worker_extension_cls verl.workers.rollout.vllm_rollout.utils.vLLMColocateWorkerExtension \
    --trust_remote_code \
    --max_model_len 28000 \
    --max_num_seqs 512 \
    --enable_chunked_prefill \
    --max_num_batched_tokens 32768 \
    --enable_prefix_caching \
    --enable_sleep_mode \
    --logprobs_mode processed_logprobs \
    --gpu_memory_utilization 0.5 \
    --tensor_parallel_size 4 \
    --seed 0 \
    --override_generation_config '{"temperature": 1.0, "top_k": -1, "top_p": 1, "repetition_penalty": 1.0, "max_new_tokens": 2048}' \
    --hf_overrides '{}' \
    --scheduling_policy fcfs \
    --compilation_config '{"cudagraph_mode": "FULL_AND_PIECEWISE"}' \
    --moe_backend triton \
    --distributed_timeout_seconds 1800 \
    --enable-auto-tool-choice \  # I add the last two lines to enable tool call in chat completions api for testing
    --tool-call-parser qwen3_coder

And then call the chat completion api with this payload:

payload = {
    "messages": [{"role": "user", "content": message}],
    "tools": tools,
    # "tool_choice": "auto",
    "chat_template_kwargs":{
        "enable_thinking": False,
    }
}
  • If the "tool_choice": "auto" is commented, then we can reproduce the same erratic output as in the verl agent loop rollout. But when "tool_choice": "auto" is enabled, then the model can produce valid tool calls.
  • Besides that, I tried to append YOU MUST CALL A TOOL to the end of the user prompt, which increased the probability of producing a valid tool call when "tool_choice": "auto" is commented.
  • Or, if we enable thinking and keep "tool_choice": "auto" commented, the model could also produce valid tool calls.

In the Chat Completions API, explicitly setting "tool_choice": "auto" seems to trigger a different tool-calling behavior for Qwen3.5/3.6-35B-A3B. With this field enabled, the model can reliably produce valid qwen3-coder XML tool calls even when enable_thinking=False.

Ideas

I suspect that because the agent loop adopts the strategy Token in token out. The agent loop uses self.server_manager.generate(prompt_ids, sampling_params) so chat completion fields like tool_choice cannot be passed. The model only sees the rendered prompt with tool definitions, but does not receive the same auto tool-calling signal.

Expected behavior

Qwen3.5/3.6-35B-A3B should produce valid xml tool calls during rollout.

Junxiao-Zhao avatar Apr 30 '26 06:04 Junxiao-Zhao

Thank you for this detailed bug report.

Your root cause analysis is spot-on. The issue is that the agent loop uses token-in-token-out mode (self.server_manager.generate(prompt_ids, sampling_params)), which cannot pass the tool_choice: auto field that would trigger the correct tool-calling behavior in Qwen3.5/3.6-35B-A3B.

Root cause:

When tool_choice: auto is set in the Chat Completions API, the model uses a different decoding strategy that more reliably produces valid XML tool calls. However, in token-in-token-out mode, verl's rollout engine only sees the rendered prompt (with tool definitions) but does not receive the tool_choice signal — the model must infer tool-calling intent purely from the prompt structure.

Qwen3.5-9B does not exhibit this issue because its tool-calling behavior is more stable without the explicit tool_choice signal. The 35B-A3B variants apparently require the explicit signal to reliably trigger the XML format.

Potential fix:

A workaround would be to inject a brief helper prompt at the end of the user message when tool calling is expected, e.g.:

Remember: you MUST call a function when available. Use the format:
<tool_call>
<function=...>
<parameter name=...>
...
</function>
</tool_call>

However, for a proper fix, verl's rollout engine would need to pass tool_choice through to the inference backend (vLLM/SGLang). This may require changes to how the rollout request is constructed in agent_loop.py.

Would you be interested in contributing a PR for this? I can help review the design. The fix would likely involve adding tool_choice to the rollout request structure and propagating it to vLLM's chat completion call.

Kirrito-k423 avatar May 19 '26 03:05 Kirrito-k423