Repository navigation
Update native MLX upstream and preserve macOS 14 compatibility - #14
Conversation
Co-authored-by: Ankit Gala <204639277+ankitgala007@users.noreply.github.com>
…e#4907) Co-authored-by: Mahimn Patel <mahimn.patel.k@gmail.com>
Co-authored-by: Yunt1 <Yunt1@users.noreply.github.com> Co-authored-by: Cheng <git@zcbenz.com>
ml-explore#4947) Co-authored-by: Yunt1 <Yunt1@users.noreply.github.com> Co-authored-by: Cheng <git@zcbenz.com>
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. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 93a9c5727f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Addressed the SIMD scale finding in @codex review Please verify the numerical fix and new regression at the latest head. |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Fix register spilling and performance regressions in the 2-pass vector SDPA kernel at head dim 512. The TK=4 prefetch setting introduced in ml-explore#4596 (tuned exclusively for float16, head dim 128 on M1 Pro) caused severe register pressure and spilling at head dim 512, disproportionately impacting bfloat16 and float32 workloads. Changes: - Update `mlx/backend/metal/kernels/sdpa_vector.h` to dynamically adjust tile size: `TK = (D + V > 512 ? 2 : 4)` - Caps the per-thread K/V tile at 64 elements for head dimensions > 256, matching the behavior of D=256 while keeping head dims up to 256 unchanged. Benchmarks (M5 Max, end-to-end decode, 60k context): - bfloat16: 14.8 ms → 1.46 ms (10× speedup) - float32: 10.1 ms → 4.25 ms (2.4× speedup) - float16: 1.71 ms → 1.47 ms (1.16× speedup) Validated against the full Python test suite and pre-commit hooks. (cherry picked from commit 7208596)
|
Included upstream ml-explore/mlx#4941 as cherry-pick @codex review |
|
ml-explore#4941 validation completed: native Metal build succeeded; focused GPU tests passed (8 tests, 48 subtests). Twelve supplemental fused GPU cases passed against explicit CPU float32 attention, spanning D256/D512, 8192/8201 keys, float32/float16/bfloat16, four query tokens and GQA=8. All outputs were finite. These are correctness checks; the speedups in the original cherry-picked commit message are the upstream author's measurements, not new local measurements. |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
What changed
5598dfa0aeb94bb9f4ac462e2b02a1ff35f56c13into Pico's integration branch, retaining left-padding/per-row KV attention, Metal argpartition and ring source-IP support.720859602efef9242b7105268976958957764c29) to reduce register pressure in the generic two-pass Metal attention kernel for head dimensions above 256; retain the original author and commit attribution.0.32.5; downstream revisions identify these newer sources precisely.Evidence
The merged source was also built with Metal enabled in an isolated Python 3.12 environment. Before the legacy-SIMD compatibility follow-up, genuine CPU/GPU attention and partitioning checks produced:
For the ml-explore#4941 follow-up, the native Metal/Python build succeeded. Focused GPU attention checks passed 8 tests and 48 subtests, covering D512, the D256 threadgroup boundary, padding, KV offsets and block overrides. Twelve additional fused GPU cases (D256/D512 × 8192/8201 keys × float32/float16/bfloat16, four query tokens and GQA=8) matched an explicit CPU float32 attention reference, with finite outputs in every case. No local before/after performance claim is made.
gh-actions-lock --verify-local, stream checks and whitespace checks passed. Independent review found no actionable issues. The initial Swift consumer build exposed the legacy-FP16 width issue; its original compiler invocation with a macOS 14 target passes after the fix.Test changes
Add
test fp8 to float64 all encodings on cputo existingtests/ops_tests.cpp. It checks all 256 E4M3FN encodings, including NaNs and signed zero, against an independent scalar reference. Other existing test changes arrive with the imported upstream commits; no test was weakened or disabled.Not done on purpose
pico/integration; this PR is the review boundary.