Skip to main content

jax-graft: run JAX on your Apple GPU

A custom backend for JAX adding support for Apple GPUs.

Under the hood it treats Metal as an XLA:GPU platform (called "mtl"), next to CUDA and ROCm. XLA's own GPU compiler fuses your program and generates the kernels, which the plugin translates to Metal Shading Language.

This project isn't affiliated with or endorsed by Apple or Google.

Status

jax-graft has wide coverage of the JAX test suite (with the notable exception of float64 support), but you should expect some sharp edges. The performance is broadly comparable to MLX and PyTorch's MPS backend on the workloads we've tried. Please report issues.

Install

pip install jax-graft

Quick start

import jax
import jax.numpy as jnp

x = jnp.arange(4.0)
y = jax.jit(lambda v: v * 2)(x)
print(y, y.devices())  # [0. 2. 4. 6.] {MtlDevice(id=0)}

Just installing jax-graft is enough to set the default backend to "mtl" on Macs with Apple GPUs. To make CPU the default, set the JAX_PLATFORMS=cpu,mtl environment variable, and place work on the GPU explicitly using jax.device_put(x, jax.devices("mtl")[0]).

Some more complete worked examples can be found in the examples directory, and the docs directory has a lot more information.

Contributing

Issues and pull requests are welcome. CONTRIBUTING.md says what makes a useful report, and docs/development.md covers building and testing.

License

Apache-2.0 (LICENSE). The plugin includes third-party code: some kernels ported from MLX (MIT), Apple's metal-cpp headers (Apache-2.0), and a statically linked XLA. Their notices are in THIRD_PARTY_NOTICES, which ships in both wheels.

Metadata

Release files for jax-graft 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for jax-graft 0.0.5
File Interpreter ABI Platform Actions
jax_graft-0.0.5-py3-none-any.whl Python 3 none any Details for jax_graft-0.0.5-py3-none-any.whl

Release files / jax_graft-0.0.5-py3-none-any.whl

Download URL jax_graft-0.0.5-py3-none-any.whl
Size 60.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b156b8040a6bd8b208b1c95b20729039e6df712c9efc74d4204e433ed2196742
BLAKE2b-256 checksum
How to use checksums
f04b3407d33e5eb51b1a8e0eb8203029023ca7908fbceed67d0abef8ece46d5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Security for jax-graft 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

1 file in this release has been uploaded with provenance metadata.

Attestation for jax_graft-0.0.5-py3-none-any.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page