Repository navigation
Pin tokenizers in Gemma4 install template to defend against Colab updates - #264
Conversation
…ates
installation_gemma4_content installs transformers with --no-deps:
!pip install --no-deps transformers==5.5.0
That skips dependency resolution, so the Gemma4 install cell never
installs tokenizers itself and relies on whatever Colab preinstalls.
transformers 5.5.0 declares tokenizers<=0.23.0,>=0.22.0. Colab today
ships tokenizers 0.22.2, which is in range, so the cell currently
works. But PyPI's current latest tokenizers is 0.23.1, which is
outside the range. The day Colab bumps its preinstalled tokenizers
to 0.23.1 (or anything past 0.23.0), every Gemma4 vision/text/audio
notebook breaks the same way the qwen3_5 / nemotron / gpt_oss
notebooks would have without #261's pin.
Fix the same way: add the tokenizers constraint to the same
--no-deps line so pip resolves it explicitly:
!pip install --no-deps transformers==5.5.0 "tokenizers>=0.22.0,<=0.23.0"
11 Gemma4 notebooks and their python_scripts mirrors regenerate
cleanly via update_all_notebooks.py.
There was a problem hiding this comment.
Code Review
This pull request updates multiple Gemma4 notebooks and their corresponding Python scripts to include a version constraint for the tokenizers package during installation. A review comment identifies a discrepancy between the pull request description and the actual changes, noting that the .ipynb files for the Audio variants are missing from the commit and should be included to maintain consistency with the updated Python scripts.
| !pip install --no-deps unsloth_zoo bitsandbytes accelerate {xformers} peft trl triton unsloth | ||
| !pip install --no-deps --upgrade "torchao>=0.16.0" | ||
| !pip install --no-deps transformers==5.5.0 | ||
| !pip install --no-deps transformers==5.5.0 "tokenizers>=0.22.0,<=0.23.0" |
There was a problem hiding this comment.
The pull request description mentions that 23 files were updated, including 11 Gemma4 notebooks and their corresponding Python scripts. However, the current diff only includes 21 files. Specifically, the .ipynb files for the Audio variants (Gemma4_(E2B)-Audio.ipynb and Gemma4_(E4B)-Audio.ipynb) appear to be missing from the commit, even though their .py mirrors were updated. Please ensure these notebooks are regenerated and included to maintain consistency across the repository.
Summary
Latent fragility bug in
installation_gemma4_content. The current install cell does:The
--no-depsflag means transformers' own pinning of tokenizers is not enforced, so the cell never installs tokenizers itself and silently relies on whatever Colab preinstalls.transformers==5.5.0declarestokenizers<=0.23.0,>=0.22.0. Colab today shipstokenizers==0.22.2, which is in range, so the cell currently works. But PyPI's current latest tokenizers is0.23.1, which is outside that range. The moment Colab updates its preinstalled tokenizers past0.23.0(or anything that breaks the constraint), every Gemma4 notebook breaks the same way the qwen3_5 / nemotron / gpt_oss notebooks would have without #261.Fix is the same shape as #261: add the tokenizers constraint to the same
--no-depsline so pip resolves it explicitly:tokenizersitself only declareshuggingface-hub<2.0,>=0.16.4as a real runtime dependency, which Colab already satisfies (1.11.0), so--no-depshere is harmless.Templates updated
installation_gemma4_content:--no-deps transformers==5.5.0->--no-deps transformers==5.5.0 "tokenizers>=0.22.0,<=0.23.0"Notebooks regenerated via the updater
11 Gemma4 notebooks (qwen3_5 / nemotron / gpt_oss already had this fix from #261):
Gemma4_(E2B)-{Vision,Text,Audio}Gemma4_(E4B)-{Vision,Text,Audio}Gemma4_(26B_A4B)-{Vision,Text}Gemma4_(31B)-{Vision,Text}Gemma4_(E2B)_GRPOPlus their
python_scripts/*.pymirrors. 23-file diff total, +23 / -23 lines.The updater also wanted to apply an unrelated double-
!-> single-!cleanup on a number of AMD-prefixed notebooks; I excluded those from this PR to keep scope tight. They can be picked up in a separate generator-driven cleanup if desired.Test plan
Gemma4_(E2B)-Vision.ipynbsucceeds andimport tokenizers; tokenizers.__version__reports a value<=0.23.0.0.23.1, the install cell now downgrades it to0.23.0(a value transformers 5.5.0 supports).