Cap transformers <5.13 to keep mlx-lm importable on macOS (v0.3.19)#316
Merged
Conversation
transformers 5.13.0 tightened AutoModel/AutoTokenizer.register() to require a
class (it does key.__module__). mlx-lm 0.31.3 registers a custom tokenizer by
string name (tokenizer_utils.py: AutoTokenizer.register("NewlineTokenizer", ...)),
so `import mlx_lm` — and therefore `import optillm` — crashes with
"AttributeError: 'str' object has no attribute '__module__'".
This only affects Apple silicon, where optillm installs mlx-lm
(platform_machine=="arm64" and sys_platform=="darwin"); Linux CI never installs
mlx-lm so it was unaffected. The transformers 5.13.0 HF path itself is fine
(dhara loads and generates); the incompatibility is purely mlx-lm's.
Pin transformers>=5.0.0,<5.13.0 (resolves to 5.12.1) until mlx-lm ships a
transformers-5.13-compatible release, then lift the cap.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Apple silicon,
import optillmcrashes with:Root cause: transformers 5.13.0 tightened
AutoTokenizer.register()to require a class (it doeskey.__module__).mlx-lm0.31.3 (latest) registers a custom tokenizer by string name:transformers ≤5.12.1 tolerated the string; 5.13.0 raises. Since optillm declares
transformers>=5.0.0with no ceiling, a fresh install pulls 5.13.0.macOS-only: optillm installs
mlx-lmonly underplatform_machine=="arm64" and sys_platform=="darwin". Linux CI never installs mlx-lm, so it silently ran 5.13.0 fine — which is why CI stayed green while local Mac installs broke.Fix
Pin
transformers>=5.0.0,<5.13.0(resolves to 5.12.1). Verified: mlx-lm then imports cleanly.The transformers 5.13.0 HF path itself is fine — I confirmed dhara-250m loads and generates on 5.13.0. The incompatibility is purely mlx-lm's; lift the cap once mlx-lm ships a 5.13-compatible release.
Testing
transformers==5.13.0+mlx-lmin a clean venv.transformers>=5.0.0,<5.13.0resolves to 5.12.1 andimport mlx_lmsucceeds.