Skip to content

Pin tokenizers in Gemma4 install template to defend against Colab updates - #264

Merged
danielhanchen merged 1 commit into
mainfrom
fix/gemma4-tokenizers-pin
May 5, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/gemma4-tokenizers-pin

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Latent fragility bug in installation_gemma4_content. The current install cell does:

!pip install --no-deps transformers==5.5.0

The --no-deps flag 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.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 that range. The moment Colab updates its preinstalled tokenizers past 0.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-deps line so pip resolves it explicitly:

!pip install --no-deps transformers==5.5.0 "tokenizers>=0.22.0,<=0.23.0"

tokenizers itself only declares huggingface-hub<2.0,>=0.16.4 as a real runtime dependency, which Colab already satisfies (1.11.0), so --no-deps here 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)_GRPO

Plus their python_scripts/*.py mirrors. 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

  • On a fresh Colab runtime, install cell of Gemma4_(E2B)-Vision.ipynb succeeds and import tokenizers; tokenizers.__version__ reports a value <=0.23.0.
  • Forced-stale repro: on a Colab runtime where tokenizers has been bumped to 0.23.1, the install cell now downgrades it to 0.23.0 (a value transformers 5.5.0 supports).

…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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread update_all_notebooks.py
!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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

@danielhanchen
danielhanchen merged commit 7af0ac0 into main May 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant