Repository navigation
perf: enable NAX Metal dispatch — 2.3x prefill speedup - #2
Merged
ekryski merged 1 commit intoApr 14, 2026
Merged
Conversation
TheTom
added a commit
to TheTom/mlx-swift-lm
that referenced
this pull request
Apr 14, 2026
Switch Gemma prefill bridge from SPM static linking to dlopen/dlsym. SPM's link-time optimizer miscompiles quantized_matmul → matmul, causing shape errors. dlopen prevents cross-module optimization. - Gemma4.swift: dlopen bridge with function pointer dispatch - build-prefill-bridge.sh: compile bridge dylib with clang++ -O3 using -undefined dynamic_lookup (shares host MLX allocator) - benchmark.sh: add --bridge flag to pass NATIVE_PREFILL=1 With NAX enabled in mlx-swift (ekryski/mlx-swift#2): 512 tok: 19,583 tok/s (was 8,342) 1024 tok: 18,780 tok/s (was 8,683) Co-Authored-By: tturney@psyguard.ai Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
TheTom
force-pushed
the
ek/speed-improvements-2
branch
from
April 14, 2026 21:24
80f7034 to
0dfbc2c
Compare
Remove MLX_METAL_NO_NAX flag. NAX (Non-Atomic eXecution) allows Metal command buffers to execute without serialization barriers, giving 2.3x prefill throughput on Gemma 4 E2B (8K → 19K tok/s at 512 context). Guard NAX SDPA for BD<=128 only — BD=256 NAXTile has zero-length array bug that crashes JIT compilation. Co-Authored-By: tturney1@gmail.com Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
TheTom
force-pushed
the
ek/speed-improvements-2
branch
from
April 14, 2026 21:24
0dfbc2c to
923e61d
Compare
TheTom
added a commit
to TheTom/mlx-swift-lm
that referenced
this pull request
Apr 14, 2026
Switch Gemma prefill bridge from SPM static linking to dlopen/dlsym. SPM's link-time optimizer miscompiles quantized_matmul → matmul, causing shape errors. dlopen prevents cross-module optimization. - Gemma4.swift: dlopen bridge with function pointer dispatch - build-prefill-bridge.sh: compile bridge dylib with clang++ -O3 using -undefined dynamic_lookup (shares host MLX allocator) - benchmark.sh: add --bridge flag to pass NATIVE_PREFILL=1 With NAX enabled in mlx-swift (ekryski/mlx-swift#2): 512 tok: 19,583 tok/s (was 8,342) 1024 tok: 18,780 tok/s (was 8,683) Co-Authored-By: tturney1@gmail.com Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
TheTom
added a commit
to TheTom/mlx-swift-lm
that referenced
this pull request
Apr 14, 2026
Switch Gemma prefill bridge from SPM static linking to dlopen/dlsym. SPM's link-time optimizer miscompiles quantized_matmul → matmul, causing shape errors. dlopen prevents cross-module optimization. - Gemma4.swift: dlopen bridge with function pointer dispatch - build-prefill-bridge.sh: compile bridge dylib with clang++ -O3 using -undefined dynamic_lookup (shares host MLX allocator) - benchmark.sh: add --bridge flag to pass NATIVE_PREFILL=1 With NAX enabled in mlx-swift (ekryski/mlx-swift#2): 512 tok: 19,583 tok/s (was 8,342) 1024 tok: 18,780 tok/s (was 8,683) Co-Authored-By: tturney1@gmail.com Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4 of 6 tasks
TheTom
added a commit
to TheTom/mlx-swift-lm
that referenced
this pull request
Apr 14, 2026
Switch Gemma prefill bridge from SPM static linking to dlopen/dlsym. SPM's link-time optimizer miscompiles quantized_matmul → matmul, causing shape errors. dlopen prevents cross-module optimization. - Gemma4.swift: dlopen bridge with function pointer dispatch - build-prefill-bridge.sh: compile bridge dylib with clang++ -O3 using -undefined dynamic_lookup (shares host MLX allocator) - benchmark.sh: add --bridge flag to pass NATIVE_PREFILL=1 With NAX enabled in mlx-swift (ekryski/mlx-swift#2): 512 tok: 19,583 tok/s (was 8,342) 1024 tok: 18,780 tok/s (was 8,683) Co-Authored-By: tturney1@gmail.com Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Apr 14, 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.
Summary
MLX_METAL_NO_NAXflag — enables non-atomic Metal command buffer executionTest plan
🤖 Generated with Claude Code