Repository navigation
Pin tokenizers with transformers so Apple Silicon keeps Train and Export - #10431
Conversation
transformers declares a tokenizers window and enforces it at import, so a venv holding a transformers that rejects its tokenizers cannot 'import transformers' at all. mlx_lm imports transformers, so mlx_stack_blockers() reports a blocker and Studio settles chat-only with Train and Export disabled. A fresh 'install.sh --local' on macOS arm64 produced exactly that pair. The core phase resolves with UV_OVERRIDE=overrides-darwin-arm64.txt and without constraints.txt, and a uv override replaces every requirement on a package, so that file's unbounded 'transformers>=5.5.0' also replaced pyproject's <=5.5.0 cap. Since transformers 5.16.0 (2026-08-26), the first release wanting tokenizers>=0.23.1, that resolve lands transformers 5.16.1 + tokenizers 0.23.2; step 3b of install_python_stack.py then installs extras-no-deps.txt with --no-deps, which pins transformers back to 5.5.0 and leaves tokenizers stranded. No commit here caused it: a third-party release walked into an unbounded override, which is why the new gate checks the resolved pair rather than a version number a diff would show. extras-no-deps.txt now names both halves, which is the file that decides the final versions on every platform and on both fresh install and update. constraints.txt carries the same window globally, for the reason the anyio cap gives: a later with-deps step must not re-resolve it up. no-torch-runtime.txt spells its existing cap as the same full window so one canonical pair exists. setup.sh gets a sibling of the anyio repair probe: an already-broken venv whose unsloth is current takes the fast update path, which never reaches the step that repairs the pair, so 'unsloth studio update' would report 'up to date' and fix nothing. It reads metadata rather than importing transformers, since importing is what is broken. tests/studio/install/test_transformers_tokenizers_pair.py locks the shape: every installing requirements file that pins transformers must bound tokenizers to the window that release declares, no file may admit 0.23.2, and a sequential resolve of the real macOS arm64 install (core phase, then the --no-deps overlay) must end with a pair transformers accepts. On the tree before this commit, four of its six checks fail.
Both named a tokenizers pin no-torch-runtime.txt was missing; #5359 added it and both tests pass now. They were redundant regardless: the -m filter on the same command already excludes their e2e class marker.
…ainst The override existed to raise mlx-vlm/mlx-lm's transformers floor, but an override replaces every requirement on the package, so the bare floor also replaced unsloth's own transformers<=5.5.0 cap on the one uv command that does not pass constraints.txt: install.sh's core install. From transformers 5.16.0 that resolve started landing 5.16.1 with tokenizers 0.23.2 on Apple Silicon, which the later --no-deps pin turned into a stranded pair. Capping at the version constraints.txt already pins makes the core phase resolve consistently on its own rather than being repaired a step later. Verified with uv pip compile for aarch64-apple-darwin / py3.13: transformers 5.5.0, tokenizers 0.22.2, and mlx 0.32.1 / mlx-lm 0.31.3 / mlx-vlm 0.6.17 unchanged from the uncapped resolve. This cannot go unsatisfiable the way the huggingface_hub override once did: that one replaced other packages' requirements on hub while a direct requirement still had to be satisfied, whereas no requirement on transformers survives this override to contradict it. A new test keeps the override and constraints.txt in lockstep.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…control setup.ps1 is what Windows updates run and it already carries the anyio repair probe this one is modelled on, so the tokenizers probe belongs beside it rather than only in setup.sh. Exercised against real venvs through pwsh: a stranded pair forces the dependency pass, a healthy pair and an unreadable one do not, matching the bash sibling case for case. tests/python/test_tokenizers_and_torch_constraint.py's negative control dropped the tokenizers line by comparing the whole line against "tokenizers". That matched the bare entry #4748 added and matched nothing once #5359 gave it a version bound, so the control installed tokenizers and then asserted an import failure that could not happen. It has been failing on every tree since, unnoticed because the class carries the e2e marker the CI lane filters out. Match by package name instead, which survives the next bound too. The class passes 7/7.
VerificationEverything below was run before and after the change, so each line says what it rules out rather than only that it passed. On a real Apple Silicon runner, before the fixTwo macOS-26 jobs on a staging repo, both with So the issue is real, it is what the shipped installer produces, and it is exactly the state that turns Train and Export off. The same two jobs on this branch are the after half. Does it break anything else
The 59 failures are identical on both trees and pre-existing: py3.9 is below unsloth's floor, and macOS x86_64 has no mlx wheels. No other package moves by a single version anywhere in the matrix, which is the answer to "does the global cap disturb a working resolve". Wheel coverage for the version the pin resolves to, from PyPI: tokenizers 0.22.2 ships Real installs on Linux, with this branchTwo full
The second one is the answer to whether the global cap can disturb the torch index: the CUDA build survives untouched, because Old installsReal venvs on Linux, seeded into the states users are actually in:
The Forwards compatibilityThe next transformers bump is the thing that caused this, so the new test was checked against it. Bumping the pin to 5.16.1 without moving tokenizers fails two checks, and adding the new window to the table while leaving the tokenizers line alone still fails: Suites
Two things found while testing, fixed in the last commit
|
|
The Apple Silicon half is finished. Same branch, same two macOS-26 jobs, same assertion script, one variable changed between them:
Both jobs must pass for the run to conclude success, and the For the record, the failing half printed this before the fix, from the real installer's venv: The staging PR is closed and its branch deleted; the workflow it carried was disposable and is deliberately not part of this PR. |
|
Reproduced this end to end on an Apple Silicon Mac (macOS 26.3, Python 3.13): replayed the installer steps with
Also checked: the Pushed 1a1e9f9: the override test hardcoded 5.16.1 as an excess candidate without excluding the pinned version, so bumping the pin to 5.16.1 in lockstep made it fail on a correct change. Only candidates above the pin count now; an unbounded override still fails. |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Confirmed on main that extras-no-deps.txt pins transformers with no tokenizers line and overrides-darwin-arm64.txt is still an unbounded floor, which is exactly the pair that leaves Apple Silicon chat-only after a fresh install. Will get this reviewed. |
Building on the previous commit, which was right that the pinned release must not count as excess. The remaining half is that a fixed pair of releases goes vacuous once the pin passes them: with 5.16.1 pinned, neither 5.16.1 nor 5.15.1 is above it and the check tests nothing. Derive the next minor and the next major from the pin, keep the two named releases since they are the ones that shipped the tokenizers window change, and the assertion keeps asking its question after every future bump. Verified both ways: passes on this branch, and against an unbounded override it reports ['5.15.1', '5.16.1', '5.6.0', '6.0.0'].
|
Re-checked after the review round. 1a1e9f9 is right and I kept it. The pinned release must not count as excess, or the check fails against its own pin the day the pin moves. I pushed one follow-up on top. The remaining half of that problem is that a fixed pair of releases goes vacuous once the pin passes them: with 5.16.1 pinned, neither 5.16.1 nor 5.15.1 is above it, so the assertion tests nothing at all. The candidates are now derived from the pin (next minor, next major) with the two named releases kept, since those are the ones that actually shipped the tokenizers window change. Verified both ways: 7 of 7 pass on this branch, and against an unbounded override it reports The red check is not this PR. The same job fails identically on |
|
@codex security review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Codex is right that this test runs in the ordinary CPU lane and reaches the index twice plus a urlopen, so it had two ways to turn someone else's PR red for reasons that say nothing about our pins: subprocess.TimeoutExpired was not caught at all, and any uv failure whose stderr missed a four-word list became a hard failure, which a 429 or an index 500 would. Inverted instead of marked. Marking it e2e would take it out of the lane the regression it guards actually reaches, and the e2e marker is registered in tests/python/conftest.py, which does not cover this directory. Now the test fails only when uv returns a resolution verdict (no solution found, unsatisfiable, because, conflict) and skips on everything else, including a timeout, a missing uv, an OSError, and a PyPI reply that is slow, throttled or not JSON. The compile budget drops from 600s to 180s so a hung index cannot hold a job for ten minutes. Verified all three ways against a live uv: an unreachable index skips, an unsatisfiable pair still fails with 'No solution found when resolving dependencies: Because transformers==5.5.0 depends on tokenizers>=0.22.0,<=0.23.0', and a healthy resolve returns.
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Problem
On macOS arm64 a fresh
install.sh --localcan leavetransformers==5.5.0besidetokenizers==0.23.2in the same venv. transformers declares a tokenizers window and enforces it at import, so that venv cannotimport transformersat all. The error it raises is the familiar one:mlx_lmimports transformers, somlx_stack_blockers()reports a blocker and Studio settles chat-only with Train and Export disabled. The install itself exits 0, because the MLX health report at the end ofinstall_python_stack.pyis advisory by design.How the pair comes apart
Reproduced with
uv pip compile --python-platform aarch64-apple-darwin --python-version 3.13against the requirement files in this repo:install.sh:5472uv pip install unsloth "unsloth-zoo>=2026.9.1"withUV_OVERRIDE=single-env/overrides-darwin-arm64.txtand no-c constraints.txtinstall_python_stack.py:7225uv pip install --no-deps -r extras-no-deps.txtTwo things make it fire:
overrides-darwin-arm64.txtcarriedtransformers>=5.5.0with no upper bound. A uv override replaces every requirement on a package, including this repo's owntransformers ... <=5.5.0cap inpyproject.toml, andinstall.sh's core install is the one uv command that does not also passsingle-env/constraints.txt. macOS arm64 is the only platform that setsUV_OVERRIDE.extras-no-deps.txtpinnedtransformers==5.5.0under--no-deps, which skips transformers' own tokenizers requirement. Pinning one half of the pair leaves whatever the earlier resolve picked.Why it started now
No commit here caused it. A third-party release walked into an unbounded override:
transformers>=4.57.6, unboundedtransformers>=5.5.0, still unboundedtokenizers>=0.23.1,<0.24rather than>=0.22.0,<=0.23.0Bisected at the resolver: with the override forced to
<5.16.0the core phase resolves transformers 5.15.1 and tokenizers 0.22.2, which the later downgrade to 5.5.0 leaves consistent. Notetokenizers 0.23.0was never published, so the newest release satisfying<=0.23.0is 0.22.2, whose cp39-abi3 wheels cover every platform and interpreter these files reach.Why CI stayed green
clean-machine-install-ci.ymlruns the realinstall.sh --localonmacos-15andmacos-26, is triggered bystudio/backend/requirements/**, and then assertsimport numpy, safetensors, tokenizers, torch.import tokenizerson its own succeeds at 0.23.2;transformersis not in that list.studio-mac-install-matrix.ymlandstudio-mac-ui-smoke.ymlinstall--no-torch, the one mode that already pins tokenizers (no-torch-runtime.txt, from fix: unblock 4 tests deselected/skipped in #5312 (real bugs) #5359).mlx-ci.ymlbuilds its own venv fromstudio.txtin a single clean resolve and never runsinstall.sh; itspaths:filter does not match the requirements files.interrupted-install-ci.ymlruns--localon mac and checks that/api/healthanswers 200. A chat-only Studio answers 200.Fix
extras-no-deps.txtnames both halves of the pair. This is the file that decides the final versions, on every platform, on fresh install and on update alike.single-env/constraints.txtcarries the same window as a global cap, for the reason the anyio cap above it gives: a later with-deps step must not re-resolve it up.single-env/overrides-darwin-arm64.txtis bounded to the versionconstraints.txtalready pins, so the core phase resolves consistently on its own instead of being repaired one step later. This cannot go unsatisfiable the way thehuggingface_huboverride once did: that one replaced other packages' requirements on hub while a direct requirement still had to be satisfied, whereas no requirement on transformers survives this override to contradict it. A future mlx-vlm wanting a newer transformers gets this one installed, which is what an override is for.no-torch-runtime.txtspells its existing cap as the same full window, so one canonical pair exists repo-wide.studio/setup.shgains a sibling of the anyio repair probe. An already-broken venv whose unsloth is current takes the fast update path, which never reaches the step that repairs the pair, sounsloth studio updatewould report "up to date" and fix nothing. The probe reads metadata rather than importing transformers, since importing is what is broken.tests/studio/install/test_transformers_tokenizers_pair.pylocks the shape.Verification
Core phase resolve,
aarch64-apple-darwin/ py3.13, before and after the override bound, same command and same inputs:The MLX trio is unchanged, and
huggingface-hubstays at 1.30.0.The new test models the installer in order rather than as one joint compile, because a joint compile finds a consistent environment the installer never produces. On the tree before this PR, four of its seven checks fail:
On this branch all seven pass, in 0.23s with a warm uv cache. It skips rather than fails when uv is absent or the index is unreachable, so a network flake cannot read as a dependency regression.
Also verified:
tests/sh/test_torch_constraint.sh: 49 passed, 0 failed, with the widenedno-torch-runtime.txtline (its regression grep for fix: unblock 4 tests deselected/skipped in #5312 (real bugs) #5359 still matches).TestE2ETokenizersFix::test_autoconfig_works_with_no_torch_runtimeandTestE2EFullNoTorchSandbox::test_autoconfig_succeeds: 3 passed. Both were carrying a--deselectinstudio-backend-ci.ymlwhose stated reason (no tokenizers pin inno-torch-runtime.txt) was fixed by fix: unblock 4 tests deselected/skipped in #5312 (real bugs) #5359, and both were redundant with the-m 'not server and not e2e'filter on the same command. Removed, with the comment corrected.install.sh --localend to end, both assertingimport transformers,import mlx_lm,import mlx_vlmandmlx_stack_blockers() == [], withUNSLOTH_DISABLE_MLX_AUTOREPAIR=1so the self-heal cannot repair the pair mid-job). I will post the before and after results here.Not in this PR
--no-torchinstall, and this is a torch install.transformersto the import assertion inclean-machine-install-ci.ymlis a one-word permanent Mac gate for this class of break. Worth doing, but it belongs in its own PR rather than riding along with the fix it would have caught.-c single-env/constraints.txtoninstall.sh's core install is the architecturally right single source of truth, and would also stop pandas, av, anyio and cryptography leaking on that command. It changes the core resolve on every platform, so it wants its own change and its own CI pass.