Repository navigation
Require transformers>=5.8.0 to fix DeepSeek-R1-Distill-Qwen tokenization - #411
Merged
Merged
Conversation
transformers 5.6 and 5.7 load deepseek-ai/DeepSeek-R1-Distill-Qwen-* with LlamaTokenizer because the checkpoint's tokenizer_config.json names LlamaTokenizerFast. That tokenizer drops the byte-level pre-tokenizer and decoder. Prompts lose all whitespace on encode, and decoded output keeps the byte-level markers (Ġ for space, Ċ for newline). transformers 5.8.0 fixes the class mapping (huggingface/transformers#45741). The lock has held 5.7.0 since the transformers 5 bump. Beaker jobs began using it for vLLM on 2026-06-15, when the isolated vLLM venv started following uv.lock (81f6a7d), which matches when the bug appeared. Raise the floor to 5.8.0 in the hf and vllm extras and move the lock to 5.8.1. Tokenizer output for the other preset models is unchanged between 5.7.0 and 5.8.1. The new test builds an offline checkpoint with the same qwen2 plus LlamaTokenizerFast mismatch and fails on 5.7.0. Fixes #241. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
mgmorgan23
approved these changes
Sep 25, 2026
gregorybchris
enabled auto-merge (squash)
September 25, 2026 17:30
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.
Fixes #241.
DeepSeek-R1-Distill-Qwen models produce output full of byte-level markers (
Ġfor space,Ċfor newline) because we lock transformers 5.7.0. This PR requires transformers 5.8.0, which fixes the bug upstream, and locks 5.8.1.Cause
deepseek-ai/DeepSeek-R1-Distill-Qwen-*checkpoints have aqwen2model config, but theirtokenizer_config.jsonnamesLlamaTokenizerFast. transformers 5.6 and 5.7 trust that class name and loadLlamaTokenizer, which drops the checkpoint's byte-level pre-tokenizer and decoder:'ĊOkay,ĠsoĠIĠhaveĠthisĠquestion.''Okay,soIhavethisquestion.', so these evals were also scoring garbled prompts.transformers 5.8.0 fixed the class mapping for
qwen2(huggingface/transformers#45741).decodeof"\nOkay, so I have this question."LlamaTokenizer'ĊOkay,ĠsoĠIĠhaveĠthisĠquestion.'Qwen2TokenizerThe lock has held 5.7.0 since the transformers 5 bump in April. The bug reached Beaker runs on 2026-06-15, when the isolated vLLM venv started installing against
uv.lock(81f6a7d). Before that, it resolved the latest transformers, which already had the fix. This matches the report of correct output around June 5 and broken output by June 17.Changes
pyproject.toml: raise the transformers floor to>=5.8.0in thehfandvllmextras. The<5.13cap for vLLM 0.19.1 stays.uv.lock: transformers 5.7.0 → 5.8.1. No other package versions change. uv also rewrote some resolution markers for pandas and rich; main's lock was up to date before this change.tests/inference/test_tokenizer_loading.py: builds a small offline checkpoint with the same mismatch (qwen2config,LlamaTokenizerFasttokenizer class) and checks that encode and decode round-trip. It fails on 5.7.0 and passes on 5.8.1. It needs no network.Testing
The new test fails on transformers 5.7.0 with the issue's symptom and passes on 5.8.1.
Unit suite as CI runs it: 2711 passed, 32 skipped.
I compared tokenizers on 5.7.0 and 5.8.1 for the HF models in our presets plus a few common ones: OLMo-2-1124-7B, Olmo-3-1025-7B, Olmo-3-7B-Instruct, Molmo2-4B, DeepSeek-R1-Distill-Llama-8B, Mistral-7B-v0.3, Qwen2.5-7B, Qwen3-8B, Qwen3-Coder-30B-A3B-Instruct, and phi-4. Tokenizer class, encode ids, decode, per-token decode, special tokens, and chat template output are identical. Only DeepSeek-R1-Distill-Qwen-1.5B and -7B change, and they now decode correctly. The Llama 3.1 and Gemma repos are gated and were not checked. DeepSeek-R1-Distill-Llama-8B uses the Llama 3 tokenizer and is unchanged.
End to end on Beaker with the command from [BUG] Deepseek Model Output Processing #241 (
vllm_server, DeepSeek-R1-Distill-Qwen-1.5B,ifeval_ood,--inspect): https://beaker.org/ex/01M3B7F3JK32DWW8MDNF4Y9CRW. The job exited 0 with 300/300 predictions, and none of the 300 rows inpredictions.jsonlcontainĠorĊ. Output text has normal spaces and newlines and answers the prompts, so prompts are also reaching the model intact. The job logs show the isolated vLLM venv installed transformers 5.8.1 from the lock.Sample output (doc 0):
"\n\nThe world is a kaleidoscope of complexity, where patterns emerge from chaos, and the unknown begins to surface. ..."🤖 Generated with Claude Code