Repository navigation
Match solo Metal decode across attention and quantized dispatch boundaries - #7
Closed
ronaldmannak wants to merge 4 commits into
Closed
ronaldmannak wants to merge 4 commits into
ronaldmannak wants to merge 4 commits into
Conversation
Codex Review Summary: ✅ CompletedThis 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. |
1 task done
This was referenced Nov 13, 2026
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 #6.
A left-padded decode row can cross the Metal single-pass/two-pass cutoff when it joins a batch, even though its own keys and values have stayed the same. Single-pass attention also groups keys by physical position. This change uses logical key positions in both kernels and selects the same path each row would use at its unpadded length. Mixed batches use GPU-side row selection. If the padded single-pass pipeline cannot launch a 1,024-thread group, the padded call uses two-pass attention. The optimized path covers single-query BF16 attention with head dimension 128 and a GQA ratio of four. Other shapes and backends continue to use the mask path.
For transposed affine quantized matmul,
MLX_QUANTIZED_MATMUL_MATCH_SINGLE_ROW=1preserves the singleton Metal kernel’s arithmetic. For eligible aligned affine 4-bit BF16 and FP16 projections at four or more rows, it shares packed weight loads across pairs of activation rows. Other exact projections use the singleton vector path. The option is off by default and can cost throughput at wider batch sizes, so it can be scoped to decode evaluation. This provides a reference for the batch-invariance discussion inml-explore/mlx#4819.The TF32 test failures in the report reproduced on both the parent of #6 and #6 with identical failing cases. The standard pytest configuration disables TF32 for these comparisons.
Validation
The updated quantized path passed 63 Metal tests with one skip. The previous and updated builds produced identical bits over 6,271,984 projection outputs in each of stock and exact mode.
The native tiled kernel was also tested on the two published Qwen3-8B-4bit fixed-join schedules using the Swift ml-explore#785 replay at
e46c414on M5 Max. Exact mode was scoped to decode. All 4,096 greedy tokens and both full BF16 logit vectors at index 172 matched solo. For the diverging schedule with fixed histories, two warmed A/B pairs with order reversed gave:Published prompt and schedule fixtures