jax-ml/jax

Composable transformations of Python+NumPy programs: differentiate, vectorize, JIT to GPU/TPU, and more

What is JAX?

JAX is an open‑source Python library that lets you write NumPy‑style code that can run fast on CPUs, GPUs, TPUs and other accelerators. It does this by compiling your functions with XLA and by providing function transformations such as automatic differentiation, just‑in‑time compilation, and vectorisation.

Core features

Feature What it does
jax.grad Computes exact derivatives of Python/NumPy code (reverse‑mode, forward‑mode, higher‑order).
jax.jit Compiles a pure function with XLA so it runs much faster and can be executed on accelerators.
jax.vmap Auto‑vectorises a function over a batch dimension, turning Python loops into parallel XLA ops.
Parallelism APIs Global‑view automatic sharding, explicit sharding, and manual per‑device programming for scaling to thousands of devices.

Typical workflow (example from the README)

import jax, jax.numpy as jnp

def predict(params, inputs):
    for W, b in params:
        outputs = jnp.dot(inputs, W) + b
        inputs = jnp.tanh(outputs)
    return outputs

def loss(params, inputs, targets):
    preds = predict(params, inputs)
    return jnp.sum((preds - targets) ** 2)

# compiled gradient function
grad_loss = jax.jit(jax.grad(loss))
# per‑example gradients, vectorised over a batch
per_example_grads = jax.jit(jax.vmap(grad_loss, in_axes=(None, 0, 0)))

The code shows how you can combine grad, jit, and vmap to get fast, differentiable training loops.

Scaling

JAX lets you write code as if you have a single machine, then:

  • Auto: the compiler decides how to shard data across devices.
  • Explicit: you annotate arrays with sharding specs (jax.sharding.PartitionSpec).
  • Manual: you work with per‑device arrays and collective ops. The README includes a short snippet showing how to set up an explicit mesh and shard parameters.

Installation

Platform Install command
CPU only pip install -U jax
NVIDIA GPU (CUDA 13) pip install -U "jax[cuda13]"
Google TPU pip install -U "jax[tpu]"
AMD GPU (ROCm) pip install -U "jax[rocm7-device-gfx942]" --extra-index-url https://repo.amd.com/rocm/whl-multi-arch/
Intel GPU (oneAPI) pip install -U "jax[oneapi]"

Who uses it?

Researchers and engineers building large‑scale machine‑learning models, scientific simulations, and reinforcement‑learning agents often choose JAX because its transformations make it easy to write clean, differentiable code that still runs at GPU/TPU speed.


All information above is taken directly from the repository’s README.

Related

  • Project
  • Project
  • Project
  • Project
  • Project