Repository navigation
fix: take the fused MLA decode kernel only where it evaluates - #3407
Merged
Merged
Conversation
The fused absorbed-MLA partial pass always launches 1024 threads (its output exchange needs 32 simdgroups), and Metal fixes each pipeline's thread limit per chip from the kernel's register use. On an M1 Ultra the pipeline at latent rank 512 is capped at 768 (640 for the int8 variant), so MLX threw at eval and every DeepSeek-V2 and Youtu-LLM decode step failed with "Thread group size (1024) is greater than the maximum allowed threads per threadgroup (768)". The kernel had only been measured on chips where it fits. Both variants now launch the real kernel once on a one-key window at the caller's geometry, evaluate it, and cache the answer per geometry. The Rust gates check it before each launch and take the composed path where it fails, and the DeepSeek-V2 layout default probes rank 512 / rope 64, so it stays decompressed where the kernel cannot run. Also fixes two tests that failed on main: FAMILY_ORDER lacked the "Tencent" family Hy4 reports, and the xla cache_dir test compared against an uncanonicalized macOS tempdir path.
inureyes
added a commit
that referenced
this pull request
Nov 28, 2026
Bumps every version-tracking workspace crate (mlxcel, mlxcel-core, mlxcel-mlx-pin, mlxcel-surgery, mlxcel-xla) to 0.9.0-beta.3 through `make bump-version` and syncs Cargo.lock. `make verify-versions` passes. Renames the Unreleased changelog section to v0.9.0-beta.3 and covers the 58 commits since v0.9.0-beta.2. The existing entries are kept, and the commits that had none gain entries: the OpenXLA hybrids (Falcon-H1, Jamba, PLaMo 2, Mamba1, Falcon-Mamba) and sigmoid MoE routing, the speculative exactness work, the vision resize and parser parity fixes, ERNIE-4.5 and Nemotron 3 Nano loading, and the CLI and Responses validation fixes. Dependencies, CI/CD, Docs and Known Issues sections and the compare link are added. The chrono to jiff entry that #3462 wrote into the beta.2 section moves here. Known Issues drop #2975 and #3407, which are closed, and add the open Raon-1 mini follow-ups. Regenerates `recipes/registry/` from a release build and repoints CURRENT. It adds `raon1_mini` and the `llava_onevision2` model type on Mage-VL, and removes nothing. Updates the release pointers: the README main-branch line and a Raon-1 mini highlight, CITATION.cff, the bug report placeholder, the cluster note in `docs/distributed.md` and `cluster_handshake.rs`, and the version example in `TECHNICAL_REPORTS/README.md`. The reports index is unchanged because 0.9 is still the line under development; `make verify-reports-index` passes.
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.
Why
On an M1 Ultra,
mlxcel generateon DeepSeek-V2-Lite and Youtu-LLM failed at the first decode step:Thread group size (1024) is greater than the maximum allowed threads per threadgroup (768). The fused absorbed-MLA partial pass (#3121, int8 variant #3156) always launches 1024 threads, because its output exchange is a 32 x 32 transpose across simdgroups. Metal derives each pipeline's thread limit per chip from register use. At latent rank 512 this M1 caps the dense pipeline at 768 and the int8 one at 640. The kernel was measured on chips where it fits, and the default from #3131 sends DeepSeek-V2 through it on every Metal host.What changed
mla_absorbed_decode_supportedand..._quantized_supportedlaunch the real kernel once on a one-key window at the caller's template geometry, evaluate it, and cache the result per geometry. MLX throws before the dispatch is encoded, so the stream stays usable afterward, and a test checks that.fused_absorbed_decodeandfused_absorbed_decode_quantizeddecline where the probe fails, so the step takes the composed path.FAMILY_ORDERwas missing theTencentfamily that Hy4 reports (feat(models): add Hy4 (hy_v4) support #3281), and the xlacache_dirtest compared against a macOS/vartempdir thatensure_private_dirdeliberately respells as/private/var.I did not shrink the threadgroup. That would change the reduction order and would need a fresh logit-trace and performance measurement on the chips where the kernel runs today.
Validation (M1 Ultra)
fused_decode_capacity_testsat H=16, R=512, P=64 for f16/bf16/f32 and int8. With the probe gates removed they fail with the production error (768 dense, 640 int8). With the fix they pass.deepseek_v2_greedy_parity(token match against mlx-lm) passes. It aborted on main.MLXCEL_MLA_ABSORBED=1(97 tok/s, composed) and with--kv-cache-mode int8. Youtu-LLM-2B went from the error above to coherent output. GLM-4.7-Flash and MiniCPM3 output is identical to the previous binary.make verifypasses: 16957 tests, 0 failed. On main the same gate had 3 failures, the ones fixed here.