Skip to content

Fix nemotron torchcodec version (0.5 not 0.6) and pin tokenizers in uv-pip templates - #261

Merged
danielhanchen merged 1 commit into
mainfrom
fix/nemotron-torchcodec-tokenizers-pin
Apr 29, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/nemotron-torchcodec-tokenizers-pin

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Two leftover bugs after #259 / #260:

  1. Nemotron torchcodec is the wrong version. installation_nemotron_nano_content pins torch==2.7.1, but Pin torchcodec to match downgraded torch in qwen3_5 / nemotron_nano templates #259 paired it with torchcodec==0.6.0. The pytorch/torchcodec compatibility table actually says torchcodec 0.6 targets torch 2.8, not 2.7. Torch 2.7 pairs with torchcodec 0.5 (or earlier 0.4 / 0.3). The 0.6 wheel still ABI-mismatches against torch 2.7.1 the same way the preinstalled 0.10 did, so the nemotron and granite4 notebooks would still hit the libtorchcodec undefined-symbol error on Colab. Switch the pin to torchcodec==0.5. cp312 manylinux wheel exists.

  2. Tokenizers template/notebook drift is broken right now. Three uv-pip templates install bare tokenizers with no version constraint:

    • installation_qwen3_5_content (alongside transformers==5.2.0)
    • installation_nemotron_nano_content (alongside transformers==4.56.2)
    • installation_gpt_oss_content (alongside transformers==4.56.2)

    Both transformers==4.56.2 and transformers==5.2.0 declare a hard tokenizers<=0.23.0,>=0.22.0 in their PyPI metadata. Latest tokenizers on PyPI today is 0.23.1, which is outside that range. So the bare tokenizers line pulls 0.23.1 into a transformers install that was never tested against it. The live nb/*.ipynb files 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.py

  • installation_nemotron_nano_content: torchcodec==0.6.0 -> torchcodec==0.5, plus tokenizers -> "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, 33 python_scripts/*.py mirrors.

Test plan

  • On a fresh Colab runtime, Nemotron-3-Nano-30B-A3B_A100.ipynb runs the install cell and from unsloth import FastLanguageModel succeeds (no torchcodec ABI error).
  • On a fresh Colab runtime, Granite4.0.ipynb (which reuses installation_nemotron_nano_content) runs the install cell cleanly.
  • Confirm import torchcodec; torchcodec.__version__ reports 0.5 after the install cell.
  • Confirm import tokenizers; tokenizers.__version__ reports 0.23.0 (not 0.23.1) after the install cell on a qwen3_5 / gpt_oss / nemotron notebook.

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

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

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.

medium

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.
@danielhanchen
danielhanchen force-pushed the fix/nemotron-torchcodec-tokenizers-pin branch from 2278ad3 to d985352 Compare April 29, 2026 21:30
@danielhanchen
danielhanchen merged commit efe20c9 into main Apr 29, 2026
2 checks passed
pull Bot pushed a commit to earyantLe/unslothai_notebooks that referenced this pull request May 5, 2026
…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.
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