Skip to content

Fix JIT compilation error caused by metal::remove_addrspace_t - #4833

Merged
zcbenz merged 1 commit into
ml-explore:mainfrom
aleroot:remove_addrspace_t
Nov 20, 2026
Merged

zcbenz merged 1 commit into
ml-explore:mainfrom
aleroot:remove_addrspace_t

Conversation

@aleroot

@aleroot aleroot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Fixes a Metal compilation failure on iOS 17 by deriving the integral constant result type from the operation directly, avoiding the unavailable metal::remove_addrspace_t trait while preserving the result’s const qualifier.

  • ☑️ I understand it is strictly prohibited to use AI to write PR description
  • AI usage disclosure:

@zcbenz zcbenz changed the title Fix iOS 17 GPU crash from metal::remove_addrspace_t Fix JIT compilation error caused by metal::remove_addrspace_t Nov 20, 2026
@zcbenz
zcbenz merged commit 07e7bda into ml-explore:main Nov 20, 2026
24 checks passed
rcfa pushed a commit to cubiculum-ai/mlx that referenced this pull request Nov 26, 2026
mergennachin added a commit to pytorch/executorch that referenced this pull request Nov 30, 2026
### Summary

Fixes #25602

Pin MLX to the stable v0.32.5 release
(`cfc675e9e59cb6ee29a647cf8fe87ef844eff879`), replacing the development
snapshot `14dc9c673bce9a51dca4e58f5b2ccae80736431d`. The release
includes an upstream integral-constant implementation that supersedes
our Metal address-space compatibility workaround, so remove that patch
and its CMake entry. Keep the platform SDK patch and update the recorded
metallib baseline comment; the size limits are unchanged.

The replacement is upstream
[ml-explore/mlx#4833](ml-explore/mlx#4833)
(`07e7bdae8c1e680ef8fe6bfbb89965712ba53fe0`), included in v0.32.5. It
fixes the same unavailable-trait error on older Metal environments by
deriving the type from the arithmetic expression and preserving `const`,
without using `metal::remove_addrspace_t` in this header.

Based on main at `aeeeb202cd3ac0f741b43dc1ba8b11ab17dc22b2`, including
#25333, #25334 and #25335. Authored with AI assistance using OpenAI
Codex.

### Test plan

Validated on an M5 Max Mac with macOS 27.2, Xcode 27.1 and main's Torch
2.15.0 pin. Built the MLX shared Python runtime with deployment target
macOS 14 and the native `mlx-release` runtime with deployment target
26.2. Built all Muse Glimmer runners, workers and native tests. All
three MLX artifacts remain below their existing CI size limits.

| Coverage | Result |
| --- | --- |
| MLX lowering/export/model Python tests | 239 unique tests passed |
| Native MLX CTests | 10/10 passed, including 50 threads × 100
predictions and speculative primitives in TF32/FP32 modes |
| Custom kernels | 197 passed across six modules, including GGUF
empty-context cases |
| Generic model suite | 37 passed, 5 skipped |
| Native operator sweep | 971 passed, 20 TF32 numerical failures;
baseline comparison described below |
| Generic operator suite | 403 passed, 64 skipped, 2 undefined
duplicate-index failures described below |
| Muse Glimmer native CTests | 3/3 passed, including serialized DFlash2
proposals 1–15, sliding windows, sampling and cache lifecycle |
| Full cached Muse Glimmer 30B DFlash2 model | Both 7- and 15-proposal
runs passed: 17 completed requests each, concurrency 4, plus an aborted
stream and recovery; exercised streaming, tool turns, prefix reuse and
session isolation |

The 20 native TF32 failures also occur with the previous MLX pin. Built
both pins against the same main and ran identical saved PTEs/inputs:
outputs were exactly identical between pins, and all 20 cases passed on
both pins with `MLX_ENABLE_TF32=0`. The generic operator failures are
the same `index_put` cases recorded in #25333: duplicate indices with
`accumulate=False`, whose result is undefined by PyTorch. No tolerances
or defaults were changed. The live smoke client skips reversed tool
results due to known issue #25299.

Representative reproduction commands, using the standard MLX development
dependencies:

```sh
cmake --preset mlx-release -DEXECUTORCH_BUILD_TESTS=ON -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON -DEXECUTORCH_MLX_ENABLE_SANITIZERS=OFF
cmake --build cmake-out --parallel 12
python -m executorch.backends.mlx.test.run_all_tests -j4 --max-tasks-per-worker 10 --clean-after
python -m pytest -c /dev/null backends/test/suite/operators -m flow_mlx -n4 --timeout=180
python -m pytest -c /dev/null backends/test/suite/models -m flow_mlx -n2 --timeout=300
python backends/mlx/test/export_multi_thread_test_model.py /tmp/multi-thread.pte
ET_TESTING_MODEL_PATH=/tmp/multi-thread.pte ET_TESTING_NUM_THREADS=50 ET_PREDICTIONS_PER_THREAD=100 ctest --test-dir cmake-out/backends/mlx/test --output-on-failure --no-tests=error
```

The remaining Python/custom-kernel and Muse Glimmer fixture/build/CTest
commands follow `.github/workflows/mlx.yml`. For live testing, served
the cached `SocialLocalMobile/Muse-Glimmer-30B-ExecuTorch-PTE` DFlash2
model with the newly built batching worker, `--dflash --dflash-n-draft
7` and then `15`, and ran the Muse Glimmer repository's
`scripts/smoke_test.py --requests 8 --concurrency 4`. This validates the
existing full-model PTE on the new runtime; the serialized fixtures
separately validate fresh export.


Additional patch-removal check: compiled all 12 integral-constant binary
operators plus mixed-type/chained-value cases against both the old
patched header and the stable upstream header. Both passed Metal 3.1
targeting macOS 14, Metal 4.1 targeting macOS 26.2, and Metal 3.1
targeting iOS 17. These probes used Xcode 27.1; Xcode 15.4 itself is not
installed here and was not tested.

The remaining `mlx_metal_sdk_per_platform.patch` is still required:
unpatched v0.32.5 hard-codes `-sdk macosx` and `-mmacosx-version-min`
for both Metal compile and link commands. Compared generated commands
for macOS, iOS device and iOS simulator with both short SDK names and
absolute SDK paths. Unpatched upstream selects the wrong platform for
all iOS cases; the patch selects the correct SDK and deployment flag in
all six configurations. Also successfully compiled and linked the
bundled JIT-mode metallib for macOS 14, iOS 17 device and iOS 17
simulator using the patched CMake file (Xcode 27.1). This is Metal
kernel cross-compilation coverage, not on-device iOS runtime testing.
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.

2 participants