Skip to content

Use mx.fast.gated_delta_update on GPUs without Metal, including Apple Silicon under Mesa/Vulkan. - #1961

Open
joshuaswarren wants to merge 1 commit into
ml-explore:mainfrom
joshuaswarren:gdn-native-backend-route
Open

joshuaswarren wants to merge 1 commit into
ml-explore:mainfrom
joshuaswarren:gdn-native-backend-route

Conversation

@joshuaswarren

Copy link
Copy Markdown

Problem: On GPUs without Metal (including Apple Silicon running via Mesa/Vulkan), gated_delta_update always uses gated_delta_ops, which loops over tokens in Python. MLX already provides mx.fast.gated_delta_update, which backends can implement natively. The Vulkan backend for Apple Silicon on Linux does, but mlx-lm doesn't it on non-Metal GPUs.

Change: When the default device is a GPU and Metal is unavailable, call mx.fast.gated_delta_update if it exists. Otherwise, keep the existing fallback. The Metal code path and its head-dimension check remain unchanged.

Result: Qwen3.5-9B, 4-bit quantization, 512-token prefill, M1 Max running Linux sees substantial speed improvements.

Tests: Added test_non_metal_gpu_uses_native_op, which fails before the change and passes afterward. The full suite has no new failures, and test_gated_delta.py passes on macOS.

AI usage disclosure: I understand it is strictly prohibited to use AI to write PR description. I drafted this by hand. Opus 5.5 assisted in the diagnosis of the performance issues I was seeing that led to this change.

This branch has not been deployed

No deployments
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.

1 participant