JAX is a high-performance numerical computing library from Google that combines NumPy-like APIs with automatic differentiation, JIT compilation via XLA, and hardware acceleration across CPUs, GPUs, and TPUs. JAX adopts a functional programming paradigm with pure functions and immutable arrays, enabling powerful transformations like grad, vmap, pmap, and jit for building scalable machine learning and scientific computing pipelines. A key design principle: JAX doesn't impose a framework—it provides composable transformations that can be combined with neural network libraries like Flax, Haiku, or Equinox to build research-grade models with complete control over the training loop, making it especially popular in ML research where flexibility and performance are paramount.
What This Cheat Sheet Covers
This topic spans 20 focused tables and 141 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Core Concepts and Functional Programming
Everything else in JAX rests on the ideas here. Functions must be pure and arrays immutable so that JAX can trace, compile, and differentiate them safely — which is why you update with .at[], thread state through explicitly, and split PRNG keys by hand rather than relying on hidden mutation. Get comfortable with tracers and the static-versus-traced distinction early; most beginner confusion in later tables traces directly back to these rules.
| Concept | Example | Description |
|---|---|---|
def f(x): return x**2 | • Functions with no side effects that return the same output for the same input • required for JAX transformations | |
y = x.at[0].set(10) | • JAX arrays cannot be modified in-place • use .at[] indexing syntax for updates that return new arrays | |
import jax.numpy as jnpx = jnp.array([1, 2, 3]) | • NumPy-compatible API with same functions and syntax • automatically hardware-accelerated | |
x = jnp.ones(1000)type(x) | • JAX's array type residing on accelerators (GPU/TPU) • transparently handles device placement | |
params, opt_state = update(params, grads, opt_state) | State passed explicitly as function parameters and return values rather than mutated in-place |