Repository navigation
Preserve row parity in Metal batched decode - #6
Closed
ronaldmannak wants to merge 2 commits into
Closed
ronaldmannak wants to merge 2 commits into
ronaldmannak wants to merge 2 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. |
This was referenced Nov 12, 2026
1 task done
Owner
Author
|
superseded by #8 |
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.
What changes
left_paddingcounts to fast SDPA. With single-query BF16 Metal decode at head dimension 128, GQA ratio 4, and a physical KV length of at least 4,096, pass one starts its K/V reads at each row’s first valid key. It writes partials in logical block order, so left padding no longer rotates the inputs to the second reduction. The second pass and existing calls are unchanged. Other shapes and backends use a boolean mask.MLX_DISABLE_QMV_WIDE=1to route eligible Metal quantized projections through ordinaryqmv. This is an opt-in workaround for the different rounding inqmv_wide, which remains enabled by default.The attention change addresses a separate issue from quantized projection. Exact parity is scoped to comparisons that select the same attention kernel and block count. Adopting the padding input in mlx-swift-lm requires separate C and Swift bindings.
Validation
left_padding.qmvfallback matched every value in both tests.qmv_widetest also passed. Ran the stream argument check andgit diff --check.The earlier Swift replay used a local prototype of the attention change with both fixed join schedules. With
qmv_widedisabled, it matched the solo choices for all 4,096 tokens and both index-172 logit vectors exactly. Those end-to-end results are from the prototype.