You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
transformers serve crashes with AttributeError: 'Gemma4Processor' object has no attribute '_tokenizer' #45406
File ".../transformers/cli/serving/utils.py", line 565, in generate_streaming
streamer = DirectStreamer(processor._tokenizer, loop, queue, skip_special_tokens=True)
^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Gemma4Processor' object has no attribute '_tokenizer'. Did you mean: 'tokenizer'?
The same error also occurs on line 664 for the continuous batching code path:
streamer = CBStreamer(self._cb, request_id, processor._tokenizer, loop, text_queue)
Expected behavior
Expected Behavior
Chat completions should work without error. DirectStreamer and CBStreamer require the raw Rust tokenizers.Tokenizer object, which is available at processor.tokenizer._tokenizer for Gemma4Processor.
Actual Behavior
Every request crashes with AttributeError immediately after the model loads.
Fix
Two lines in src/transformers/cli/serving/utils.py need updating:
Line 565 (standard streaming path):
# Before
streamer = DirectStreamer(processor._tokenizer, loop, queue, skip_special_tokens=True)
# After
streamer = DirectStreamer(processor.tokenizer._tokenizer, loop, queue, skip_special_tokens=True)
Line 664 (continuous batching path):
# Before
streamer = CBStreamer(self._cb, request_id, processor._tokenizer, loop, text_queue)
# After
streamer = CBStreamer(self._cb, request_id, processor.tokenizer._tokenizer, loop, text_queue)
Alternatively, a more robust fix would be to make both call sites handle both cases:
pythonrust_tokenizer = getattr(processor, "_tokenizer", None) or processor.tokenizer._tokenizer
This would be defensive against other processor types that may also use the public .tokenizer attribute.
Notes
Affects all Gemma 4 models (google/gemma-4-*) since Gemma4Processor uses the public .tokenizer attribute rather than ._tokenizer
Gemma 4 support was added in v5.5.0 (#45192) and transformers serve was not tested against it
No existing GitHub issues or public reports found for this specific error as of April 2026 — this appears to be a gap in integration testing between the new serving CLI and Gemma4's processor design
Activity
zucchini-nlp commentedon Apr 13, 2026
Fixed by #45368 I believe
zucchini-nlp commentedon Apr 13, 2026
Merged! Please check
asdat3 commentedon Apr 13, 2026
oh, I think you are correct. Will check in a second if the merge "fixed it".
Thank you very much for your super fast answer and all your work.
asdat3 commentedon Apr 13, 2026
working 🫡