fix(serving): resolve rust tokenizer from ProcessorMixin in streaming generation#45368
Merged
zucchini-nlp merged 1 commit intohuggingface:mainfrom Apr 13, 2026
Conversation
… generation ProcessorMixin subclasses (e.g. Qwen3VLProcessor) expose the fast tokenizer at .tokenizer, not ._tokenizer. Use getattr() to handle both ProcessorMixin and PreTrainedTokenizerFast when extracting the rust tokenizer backend for DirectStreamer and CBStreamer. Fixes huggingface#45362 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
|
cc @zucchini-nlp for processors and @LysandreJik for |
zucchini-nlp
approved these changes
Apr 13, 2026
Member
zucchini-nlp
left a comment
There was a problem hiding this comment.
Yep, processor can't have a private _tokenizer attr
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
4 tasks
Member
|
I'll merge since it seems quite straightforward, and users reporting they cannot run Gemma4 |
4 tasks
sirzechs66
pushed a commit
to sirzechs66/transformers
that referenced
this pull request
Apr 18, 2026
… generation (huggingface#45368) ProcessorMixin subclasses (e.g. Qwen3VLProcessor) expose the fast tokenizer at .tokenizer, not ._tokenizer. Use getattr() to handle both ProcessorMixin and PreTrainedTokenizerFast when extracting the rust tokenizer backend for DirectStreamer and CBStreamer. Fixes huggingface#45362 Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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
Fixes #45362 —
transformers chatcrashes withAttributeError: 'Qwen3VLProcessor' object has no attribute '_tokenizer'when streaming responses from Qwen models.Root cause:
GenerateManager.generate_streaming()andCBGenerateManager.generate_streaming()accessprocessor._tokenizerto get the Rust tokenizer backend. This works forPreTrainedTokenizerFast(which stores the Rust backend at._tokenizer), butProcessorMixinsubclasses likeQwen3VLProcessorexpose the fast tokenizer at the public.tokenizerattribute instead.Fix: Use
getattr(processor, "tokenizer", processor)._tokenizerto first resolve the fast tokenizer (which isprocessor.tokenizerfor ProcessorMixin, orprocessoritself for PreTrainedTokenizerFast), then access._tokenizerfor the Rust backend.Two locations updated:
GenerateManager.generate_streaming()(line 565)CBGenerateManager.generate_streaming()(line 664)Coordination
Test plan
transformers chat Qwen/Qwen3.5-35B-A3Bno longer crashes on first promptruff check src/transformers/cli/serving/utils.pypasses🤖 Generated with Claude Code