[rollout] Continuous Token: DeepSeek-R1 distills cannot construct a builder since #6804 (Qwen builder requires <|im_end|>)
Describe the bug
Since #6804 the agent loop builds a Continuous Token builder for every rollout and picks the builder family by the root config.json model_type. The DeepSeek-R1 distills have Qwen architectures (model_type: qwen2 / qwen3) but DeepSeek's chat template and tokenizer, in which <|im_end|> was renamed to <|end▁of▁sentence|>. QwenContinuousTokenBuilder.__init__ requires <|im_end|>, so AgentLoopBase.__init__ raises before any rollout starts:
ValueError: Tokenizer does not define required token '<|im_end|>'
| model | model_type |
family picked | result |
|---|---|---|---|
| deepseek-ai/DeepSeek-R1-0528-Qwen3-8B | qwen3 | qwen3 | construction fails |
| deepseek-ai/DeepSeek-R1-Distill-Qwen-7B | qwen2 | qwen | construction fails |
| deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B | qwen2 | qwen | construction fails |
Reproduction with tokenizer files only (verl main @9c76436, transformers 5.16.1):
from transformers import AutoConfig, AutoTokenizer
from verl.utils.tokenizer.continuous_token_wiring import create_continuous_token_builder
model = "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B"
create_continuous_token_builder(AutoTokenizer.from_pretrained(model), hf_model_type=AutoConfig.from_pretrained(model).model_type)
This is main only: v0.9.0 was cut just before #6804, and before #6804 Continuous Token was opt-in and the name-based inference sent the DeepSeek-R1-Distill-Qwen-* checkpoints to the default builder (R1-0528-Qwen3-8B already matched the qwen3 rule, but the path was off by default). DeepSeek-R1-Distill-Llama-8B has model_type: llama, so it gets the default builder and constructs.
What renders these templates correctly
Tool appends on the first and third tool turn, compared with the template's full-conversation render (script and raw output: https://github.com/ruiling-smartbear/verl-experiments/blob/main/verl_distill_builder_probe_results.txt):
DeepSeekContinuousTokenBuilderrenders all four distills. R1-0528-Qwen3-8B matches the template on every turn; the older distills match on the first tool turn and then differ by theis_output_firstform (#7636).- The default builder renders the three older distills identically, but hits the #7630
TypeErroron R1-0528-Qwen3-8B: the base_synthetic_assistant_for_toolsstill carries"arguments": {}and that template concatenates arguments as a string. With"arguments": "{}"in the base class it matches the template on every turn.
Possible fixes
Keeping #6804's rules (no toggle, nothing guessed from names):
- When the builder resolved from
model_typecannot be constructed because the tokenizer lacks its required token, fall back to the default builder with a warning — the treatment an unknownmodel_typealready gets — and carry the base synthetic tool-call arguments as a JSON string so the default builder also renders concatenating templates. Smallest change; the distills then behave exactly like the DeepSeek builder onmain. - Resolve the family from the tokenizer's special tokens as an exact secondary key (
<|end▁of▁sentence|>and<|Assistant|>defined,<|im_end|>not): these checkpoints then get the DeepSeek builder and #7630 / #7636 apply to them directly. - Bring back an explicit family override — least in the spirit of #6804.
Known limitations either way: from the second tool turn on, the older distills' is_output_first form needs #7636 (or its logic in whichever builder serves them); and DeepSeek-R1-0528-Qwen3-8B's tokenizer encodes and decodes incorrectly under transformers 5 (decoded text loses spaces and the |/▁ marker characters) unless loaded as Qwen2TokenizerFast — its tokenizer_config.json declares LlamaTokenizerFast; outside verl, fix proposed upstream in https://huggingface.co/deepseek-ai/DeepSeek-R1-0528-Qwen3-8B/discussions/28.
Happy to send a PR for whichever you prefer.
@gxlvera this is the selection-layer piece next to #7630 / #7635 / #7636: since #6804 these checkpoints cannot construct a builder at all. Whichever of the two fixes you prefer, I can send it.
Sent both options: #7638 (option 1, default-builder fallback) and #7639 (option 2, tokenizer special-token key). Same trigger — under auto, the builder inferred from model_type raises for a missing required token — so they are alternatives; either one restores the distills on main, and the two render identically there today. Option 2 additionally puts these checkpoints on the DeepSeek builder, so #7636 would cover their later tool turns once merged.
One correction to option 1 as sketched above: the JSON-string synthetic arguments cannot move into the base class — the Qwen3.5 / MiniMax-M2 / GLM-4.7 templates render them as a mapping (.items()), and the 13-model harness fails all their cases with the base-class variant. #7638 therefore scopes the string form to a dedicated fallback builder; #7639 needs no arguments change at all.
Validation for both (13-model identity harness, factory selection, template-reference renders, and the special-token key inputs on real tokenizers): https://github.com/ruiling-smartbear/verl-experiments/blob/main/verl_distill_fix_check_results.txt
@wuxibin89 flagging for continuity since you merged #7630 yesterday: this issue is in the same subsystem, and #7638 / #7639 above are the two candidate fixes, validated with the same harness against current main. They are alternatives, so merging either one closes this. #7635 and #7636 from the same line of work are open as well.
Also sent #7640: the explicit override, option 3 above — data.continuous_token.model_family (restored without #6804's enable toggle), plus a construction error that names the override and the family these checkpoints need. No automatic routing: under auto the distills still fail, now self-explainingly, and model_family=deepseek selects the builder matching their chat template.
The three PRs are one-of. #7640 asks for configuration, #7638 / #7639 route automatically; the override also composes with either if both layers are wanted. Validation for this one (13-model identity, error text, explicit-selection renders): https://github.com/ruiling-smartbear/verl-experiments/blob/main/verl_family_config_check_results.txt