[feat][JAX] Add Apple Silicon MPS support - #1979
Draft
bvolpato wants to merge 1 commit into
Draft
Conversation
Signed-off-by: bvolpato <brunocvcunha@gmail.com>
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
Add opt-in Apple Silicon GPU support for the JAX backend through the open-source
jax-mpsPJRT plugin.Apple's closed-source
jax-metalplugin cannot consume StableHLO from SkyRL'scurrent JAX 0.10.x stack.
jax-mpstargets JAX/JAXLIB 0.10.x and executes JAXprograms through MLX on Metal. This refreshes the approach from #1332 against
current
mainandjax-mps0.10.10.Changes
mpsextra for Apple Silicon on macOS 14+transformersandml_dtypesresolution on macOSTesting
Validated on an M4 Max MacBook Pro with 64 GB unified memory.
uv lock --checkpassedRepro Command
JAX_PLATFORMS=mps uv run --isolated --extra jax --extra mps --extra tinker \ -m skyrl.tinker.api \ --base-model trl-internal-testing/tiny-Qwen3ForCausalLM \ --backend jax \ --backend-config '{"max_lora_adapters": 2, "max_lora_rank": 8, "train_micro_batch_size": 1, "sample_max_num_sequences": 1}'Downsides
jax-mpsis experimental, supports one Apple GPU, does not support every JAXoperation, and currently emits warnings because buffer donation is unavailable.
Causal attention uses the XLA implementation instead of fused SDPA on MPS.
Until tillahoffmann/jax-mps#223 is released, MPS decoding uses a dense mask/einsum KV-cache
update instead of batched
dynamic_update_slice; this can increase decode memorytraffic for long contexts. CPU, CUDA, and TPU paths retain their existing
implementations.