Repository navigation
Fix nemotron torchcodec version (0.5 not 0.6) and pin tokenizers in uv-pip templates - #261
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates numerous Jupyter notebooks and Python scripts to include a version constraint for the tokenizers package (>=0.22.0,<=0.23.0) and downgrades torchcodec to version 0.5 in specific templates. Feedback suggests defining the tokenizers version constraint as a constant variable within update_all_notebooks.py to improve maintainability and ensure consistency across the various installation strings.
| elif importlib.util.find_spec("unsloth") is None: | ||
| !uv pip install -qqq unsloth | ||
| !uv pip install --upgrade --no-deps transformers==4.56.2 tokenizers trl==0.22.2 unsloth unsloth_zoo | ||
| !uv pip install --upgrade --no-deps transformers==4.56.2 "tokenizers>=0.22.0,<=0.23.0" trl==0.22.2 unsloth unsloth_zoo |
There was a problem hiding this comment.
The constraint string "tokenizers>=0.22.0,<=0.23.0" is used consistently across the updated templates. To improve maintainability and reduce the risk of future drift, consider defining this version constraint as a constant variable at the top of the script and referencing it in the installation strings.
Two leftover bugs after #259 / #260: 1. installation_nemotron_nano_content pins torch==2.7.1 but #259 set torchcodec==0.6.0. Per pytorch/torchcodec's compatibility table 0.6 targets torch 2.8, not 2.7; the right pin for torch 2.7 is torchcodec==0.5 (also covered by 0.4 / 0.3). The 0.6 wheel still ABI-mismatches against torch 2.7.1 the same way 0.10 did, so the nemotron and granite4 notebooks would still hit the libtorchcodec undefined-symbol error on Colab. Switch to torchcodec==0.5 (cp312 manylinux wheel exists). 2. installation_qwen3_5_content, installation_nemotron_nano_content and installation_gpt_oss_content all install bare "tokenizers" (no constraint), but the transformers versions they pair with declare a hard tokenizers<=0.23.0,>=0.22.0: transformers 4.56.2: tokenizers<=0.23.0,>=0.22.0 transformers 5.2.0: tokenizers<=0.23.0,>=0.22.0 PyPI's current latest tokenizers is 0.23.1, which is outside that range. Bare "tokenizers" pulls 0.23.1 into a transformers install that was never tested against it. The live notebooks already carry the constraint string "tokenizers>=0.22.0,<=0.23.0"; the templates were the drifted side. Sync templates to match. Generated artifacts updated via update_all_notebooks.py.
2278ad3 to
d985352
Compare
…ates (unslothai#264) 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 unslothai#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.
Summary
Two leftover bugs after #259 / #260:
Nemotron torchcodec is the wrong version.
installation_nemotron_nano_contentpinstorch==2.7.1, but Pin torchcodec to match downgraded torch in qwen3_5 / nemotron_nano templates #259 paired it withtorchcodec==0.6.0. The pytorch/torchcodec compatibility table actually says torchcodec0.6targets torch2.8, not2.7. Torch2.7pairs with torchcodec0.5(or earlier0.4/0.3). The0.6wheel still ABI-mismatches against torch2.7.1the same way the preinstalled0.10did, so the nemotron and granite4 notebooks would still hit the libtorchcodec undefined-symbol error on Colab. Switch the pin totorchcodec==0.5. cp312 manylinux wheel exists.Tokenizers template/notebook drift is broken right now. Three uv-pip templates install bare
tokenizerswith no version constraint:installation_qwen3_5_content(alongsidetransformers==5.2.0)installation_nemotron_nano_content(alongsidetransformers==4.56.2)installation_gpt_oss_content(alongsidetransformers==4.56.2)Both
transformers==4.56.2andtransformers==5.2.0declare a hardtokenizers<=0.23.0,>=0.22.0in their PyPI metadata. Latest tokenizers on PyPI today is0.23.1, which is outside that range. So the baretokenizersline pulls0.23.1into a transformers install that was never tested against it. The livenb/*.ipynbfiles already carry the correct"tokenizers>=0.22.0,<=0.23.0"constraint string; the templates were the drifted side. The next updater run would otherwise have overwritten the working notebook constraint with the broken bare name. Sync the templates to match the notebooks.Templates updated in
update_all_notebooks.pyinstallation_nemotron_nano_content:torchcodec==0.6.0->torchcodec==0.5, plustokenizers->"tokenizers>=0.22.0,<=0.23.0"installation_qwen3_5_content:tokenizers->"tokenizers>=0.22.0,<=0.23.0"installation_gpt_oss_content:tokenizers->"tokenizers>=0.22.0,<=0.23.0"Diff shape
67 files: template (10 lines), 33
nb/*.ipynb, 33python_scripts/*.pymirrors.Test plan
Nemotron-3-Nano-30B-A3B_A100.ipynbruns the install cell andfrom unsloth import FastLanguageModelsucceeds (no torchcodec ABI error).Granite4.0.ipynb(which reusesinstallation_nemotron_nano_content) runs the install cell cleanly.import torchcodec; torchcodec.__version__reports0.5after the install cell.import tokenizers; tokenizers.__version__reports0.23.0(not0.23.1) after the install cell on a qwen3_5 / gpt_oss / nemotron notebook.