Skip to content

Update native MLX upstream and preserve macOS 14 compatibility - #14

Merged
ronaldmannak merged 67 commits into
pico/integrationfrom
claude/update-engines-20261124
Nov 24, 2026
Merged

ronaldmannak merged 67 commits into
pico/integrationfrom
claude/update-engines-20261124

Conversation

@ronaldmannak

@ronaldmannak ronaldmannak commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

What changed

  • Merge upstream MLX 5598dfa0aeb94bb9f4ac462e2b02a1ff35f56c13 into Pico's integration branch, retaining left-padding/per-row KV attention, Metal argpartition and ring source-IP support.
  • Cherry-pick upstream #4941 (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.
  • Preserve the supported macOS 14 deployment target by using the existing scalar FP8 conversion fallback for vector widths unavailable in legacy NEON. Modern SIMD remains unchanged.
  • Add an exhaustive CPU FP8→float64 regression and a fork CI lane that really runs on this repository, including native C++ tests at the macOS 14 target and Python attention/partitioning checks.
  • Keep the upstream version number 0.32.5; downstream revisions identify these newer sources precisely.

Evidence

cmake -S . -B build/pico-cpu -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 -DMLX_BUILD_METAL=OFF -DMLX_BUILD_TESTS=ON -DMLX_BUILD_EXAMPLES=OFF -DMLX_BUILD_PYTHON_BINDINGS=OFF
cmake --build build/pico-cpu --target tests --parallel 3
DEVICE=cpu ./build/pico-cpu/tests/tests
[doctest] test cases:  290 |  290 passed | 0 failed | 0 skipped
[doctest] assertions: 4785 | 4785 passed | 0 failed |
[doctest] Status: SUCCESS!

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:

DEVICE=gpu .venv312/bin/python -m pytest -q python/tests/test_fast_sdpa.py -k 'left_padding or kv_offsets'
13 passed, 41 deselected, 40 subtests passed in 0.90s
DEVICE=cpu .venv312/bin/python -m pytest -q python/tests/test_fast_sdpa.py -k '(left_padding or kv_offsets) and not _gpu'
12 passed, 42 deselected, 16 subtests passed in 1.89s
DEVICE=cpu .venv312/bin/python -m pytest -q python/tests/test_ops.py -k argpartition
2 passed, 177 deselected, 18 subtests passed in 0.63s
DEVICE=gpu .venv312/bin/python -m pytest -q python/tests/test_ops.py -k argpartition
2 passed, 177 deselected, 18 subtests passed in 0.17s

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 cpu to existing tests/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

  • Do not push to or merge into pico/integration; this PR is the review boundary.
  • Do not claim a new upstream release number or model throughput result. This is an exact upstream source update with Pico's extensions preserved.
  • The Swift wrapper and application dependency updates are separate dependent PRs.

ipazarbasi and others added 30 commits November 18, 2026 19:31
…#4890)

Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
padwowen and others added 16 commits November 23, 2026 16:11
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>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T22:35:37.149035Z c85ccee Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread mlx/backend/cpu/quantized.cpp Resolved

Copy link
Copy Markdown
Owner Author

Addressed the SIMD scale finding in 8ce225e090834095de37f508cf4cf273e00dac0f: decoded scales and the global-scale product stay float32, matching the scalar path. New coverage uses float16 activations and float32 source weights to isolate the matmul, with exact ±0.015625 expectations unchanged. Quantized CPU coverage passed (6 tests, 69 subtests; 3 platform skips); full native CPU suite passed (290 cases, 4,785 assertions). The initial half-weight fixture also exposed an earlier, separate quantizer underflow, so it is not claimed as an isolated before-fix check.

@codex review

Please verify the numerical fix and new regression at the latest head.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 8ce225e090

ℹ️ 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".

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)

Copy link
Copy Markdown
Owner Author

Included upstream ml-explore/mlx#4941 as cherry-pick c85ccee5, retaining -x attribution. The change lowers the default tile size only when D+V > 512; explicit TK=1 and the specialized GQA/reduction kernels are unchanged. Metal rebuild and focused GPU correctness checks are in progress; Swift's bundled shader header is being updated in the dependent PR.

@codex review

Copy link
Copy Markdown
Owner Author

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: c85ccee516

ℹ️ 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".

@ronaldmannak
ronaldmannak merged commit 9b9fab0 into pico/integration Nov 24, 2026
9 checks passed
@ronaldmannak
ronaldmannak deleted the claude/update-engines-20261124 branch November 24, 2026 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.