Repository navigation
deps: move mlx-lm to upstream ml-explore/mlx-lm - #2509
Merged
Merged
Conversation
This was referenced Oct 30, 2026
Merged
Merged
Merged
Merged
AlexCheema
force-pushed
the
deps/mlx-0.32.4
branch
from
November 1, 2026 15:56
064b61d to
694f3db
Compare
Landing commit: this PR's change on top of main, with conflicts with the PRs landed before it resolved as in the tested integration build. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
AlexCheema
force-pushed
the
deps/mlx-lm-upstream
branch
from
November 1, 2026 16:02
d5eb3a5 to
66ea418
Compare
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.
Stacked on #2508 (MLX 0.32.4), which sits on #2507 (the per-family folder refactor).
Why
exo has followed an mlx-lm fork branch: upstream as of 2026-04-22 plus DeepSeek V4 and three fixes. It is 169
commits behind upstream, and the models we want next (GLM-5.2 indexer sharing, DeepSeek V3.2 sparse attention,
flint, Kimi K3, Muse Spark, MiniMax M3, Laguna) are upstream. This PR pins upstream main at
6b572ab(2026-10-30) byrev, souv lock --upgradecannot move it silently.What exo relied on from the fork, and where it went
models/deepseek_v4/model.pyand loaded through the family'sModelClasses; its stub moves next to it[batch, vocab]log-prob array per decode step (exo's batched top-k)GenerationBatch.extendOther upstream changes this follows
statenow holds the whole cache (anArraysCachereturns its arrays, left padding and lengths). Theprefix cache's trim fallback and the prefill transfer adapter now use the arrays directly; both broke otherwise.
TokenizerWrapperbuilds the streaming detokenizer once and hands out copies, which is what exo'sreuse_detokenizerpatch did. The patch goes; its tests now check mlx-lm's behaviour.enable_thinkingunset, upstream's wrapper turns on the template's thinking switch. ForDeepSeek V3.1 that switch is
thinking, whose template default is off. exo keeps rendering such requests as before(separate commit).
(hidden state, top-k). Pipeline parallelism sent the whole tupleand failed. It now sends the hidden state and hands the rest back (separate commit, with a test).
newest that keeps huggingface-hub 1.8 and tokenizers 0.22. The copied DeepSeek V4 file registered a stand-in
transformers config that now shadows transformers' own and breaks the tokenizer; it only registers when
transformers has none.
mlx_lm/_version.py, andimport mlx_lmfailed in the nix environment. The nix build now provides setuptools-scmand the locked version.
Fixed along the way
beyond
index_topk(2048 tokens) it selected the wrong keys. On 4 layers of DeepSeek-V3.2 withindex_topkset to64, KL to Hugging Face transformers drops from 4.1e-2 (top-1 74%) to 4.9e-7 (top-1 99.94%).
2+2?" lost the space before "2", and decoding dropped every space and all non-ASCII text. They now match their
tokenizer.json.Verification
Teacher-forced float32 log-probs from exo's own loading and sharding code (single device, 2x tensor parallel,
2x pipeline parallel, prefill plus 16 decode steps) against Hugging Face transformers (PyTorch, CPU, float32) on the
same weights. Large models are truncated to their first 3 to 6 layers with real weights. "Identical" means
bit-identical to
main. KL is KL(reference || exo) per position.index_topk64index_topk64"Within noise": the paired difference in per-position KL to the reference has a 95% interval that contains zero.
The Gated DeltaNet families differ because upstream computes the gate in bfloat16; against the float32 reference that
is not measurable, even on the full Qwen3.5-9B. GLM-5 with the sparse indexer forced on moves by about 1e-6 KL (the
indexer sums its heads in a different order upstream), a tenth of its distance to the reference and far below bfloat16
noise. Every other family is identical to
mainor closer to the reference.Also checked:
V3.1/V3.2 (fixed, above). Kimi K2.x and GLM-4.7-Flash gain one more stop token from their tokenizer config;
Nemotron-Nano-9B-v2's
<think>tokens are now recognised; Llama 3 decoding no longer removes spaces beforepunctuation.
lengths) on nine checkpoints, including DeepSeek V4 and DeepSeek V3.2 / GLM-5 with the sparse indexer: no errors,
and batched output departs from solo at the same steps as on
main. Log-probs are now float32.tensor, 2-node pipeline): the same greedy tokens as
mainfor every request.basedpyright,ruff check,nix fmt,pytest(1919 passed),nix build .#exo-test-env,uv sync --extra mlx, and PyInstaller's module collection for mlx-lm.Hardware: two Mac Studio (M3 Ultra, 96 GB) and two Mac mini (M4 Pro, 64 GB); the references ran on their CPUs.
Not changed here (pre-existing on main)
nemotron_handgemma4(E2B) are further from transformers than bfloat16 noise (KL 1e-2 and 5e-2).truncate: false(gpt-oss).Follow-up suggestion: computing the Gated DeltaNet gate and beta in float32 (two casts before
gated_delta_update) brought Qwen3.5-9B 7.5% closer to the reference (95% interval 2% to 12%), and was neutral onsmaller checkpoints. It belongs in the qwen3_5 family with the Qwen model work.
MLX
Upstream mlx-lm needs MLX >= 0.32.3: its quantised MoE layers pass
global_scaletomx.gather_qmm. That is whythis PR sits on the MLX 0.32.4 bump, which moves Linux off the 0.32.0 wheels. On an aarch64 Linux CPU,
a 4-bit quantised MoE runs with this PR on MLX 0.32.4 and fails with a
TypeErroron MLX 0.32.0. On macOS theper-family results above are unchanged on 0.32.4 (Llama, Qwen3.5 and gpt-oss rechecked in all three modes).
🤖 Generated with Claude Code