[tokenizer] Qwen3.5+ Thai/Hindi text mis-tokenized under pinned transformers==5.12.1 (transformers#49066)
System Info
- verl
main@6093e007cc—pyproject.tomlpinstransformers==5.12.1(andsglang==0.5.20, which itself hard-pinstransformers==5.12.1), from #7973. - Repro below run on CPU with
transformers==5.8.1/tokenizersfrom the same env; the upstream report (huggingface/transformers#49066) lists 5.8.1 through 5.17.0 as affected, which includes the pinned 5.12.1. We also checked 5.12.1 internally with the same result.
Information
- The official example scripts
- My own modified scripts
Tasks
- An officially supported task in the
examplesfolder (such as GLUE/SQuAD, ...) - My own task or dataset (give details below)
Reproduction
This is a transformers bug, not a verl bug, but verl's pin makes every Qwen3.5+ run inherit it with no way to avoid it by version choice, so filing here for visibility.
In transformers v5, Qwen2Tokenizer overwrites the pre-tokenizer from the checkpoint's tokenizer.json with a built-in regex that lacks \p{M} (combining marks). Qwen3.5+ checkpoints ship a pre-tokenizer that includes \p{M}, so text in scripts that rely on combining marks (Thai, Hindi/Devanagari, ...) is split into more, different token ids than the model was trained with. There is no error or warning. Upstream: huggingface/transformers#49066, fix huggingface/transformers#49077 (open, not in a release yet).
from transformers import AutoTokenizer
from tokenizers import Tokenizer
p = "<local Qwen3.5 checkpoint dir>"
hf = AutoTokenizer.from_pretrained(p) # Qwen2Tokenizer
raw = Tokenizer.from_file(p + "/tokenizer.json") # checkpoint's own pre-tokenizer
for s in ["สวัสดีครับ", "नमस्ते दुनिया", "مرحبا بالعالم", "hello world"]:
a = hf.encode(s, add_special_tokens=False)
b = raw.encode(s, add_special_tokens=False).ids
print(repr(s), a == b, len(a), len(b))Output (transformers 5.8.1, Qwen3.5-35B-A3B tokenizer):
'สวัสดีครับ' False 7 3
'नमस्ते दुनिया' False 10 6
'مرحبا بالعالم' True 5 5
'hello world' True 2 2Impact on verl: the actor side (hf_tokenizer / hf_processor) and the rollout side (SGLang/vLLM tokenizer processes) all go through the same Qwen2Tokenizer, so they agree with each other — rollout and training stay self-consistent — but prompts and rewards in affected languages are tokenized differently from pretraining, silently degrading multilingual RL/distillation. Qwen3 (pre-3.5) checkpoints whose regex lacks \p{M} are unaffected.
Possible mitigations until #49077 is released: (a) document the known issue next to the pin; (b) optionally restore the checkpoint pre-tokenizer after load (e.g. tokenizer._tokenizer.pre_tokenizer = Tokenizer.from_file(<tokenizer.json>).pre_tokenizer) in verl.utils.tokenizer.hf_tokenizer — note that rollout engines spawn their own tokenizer processes, so a verl-side patch alone does not reach them; (c) bump the pin once a fixed transformers release is compatible with the pinned SGLang/vLLM.
Expected behavior
AutoTokenizer.from_pretrained(<Qwen3.5 checkpoint>) produces the same ids as the checkpoint's tokenizer.json for all scripts.
(AI-assisted report.)
Source: verl-project/verl