Deep Learning examples using the Jax ecosystem of libraries
Important
Ensure that you've uv installed.
The base install is CPU-only. Accelerator backends live in separate uv dependency groups; pick the one that matches your hardware. The groups are mutually exclusive, and uv sync removes whichever backend you had before, so switching is just another uv sync --group <backend>.
| backend | command | notes |
|---|---|---|
| cpu | uv sync |
works everywhere |
| nvidia cuda | uv sync --group cuda |
linux only; cuda and cudnn come bundled as pip wheels, you only need the nvidia driver |
| amd rocm | uv sync --group rocm |
linux x86_64 only; expects a system-wide ROCm 7 install, the plugin does not bundle it |
| apple mps | uv sync --group mps |
macos on apple silicon |
Then activate the environment:
source .venv/bin/activateSelecting a group on the wrong platform is a no-op, e.g. --group cuda on macos installs nothing extra and jax falls back to cpu.
# inside the project root
uv run jupyter labAfter uv sync --group cuda, jax picks the gpu automatically. Verify with:
uv run utils/device.pywhich should log XLA DEVICE: gpu.
Install ROCm 7 first (see the ROCm install guide), then uv sync --group rocm. The rocm group uses jax's rocm7-local extra, which links against the system ROCm libraries rather than shipping its own. Verify the same way as cuda; the device also reports as gpu.
jax-metal has long been unmaintained and the subsequent updates to the jax project have made it incompatible. This project uses a community developed extension called jax-mps, installed via the mps group.
uv sync --group mpsjax-mps does not register itself as the default backend, so set JAX_PLATFORMS=mps when running a script:
JAX_PLATFORMS=mps uv run utils/device.pyInside jupyter notebooks, either set the env var before starting the kernel or call setup_backend() from utils/device.py before importing anything that initialises jax. The mps backend is still experimental upstream, so not every jax op is supported yet.
The site at https://shawonashraf.github.io/annotated-jax/ is built from the notebooks in notebooks/ only; playground/ and everything else is left out. Pages show the outputs saved in each notebook; nothing is executed at build time, so save notebooks with their outputs. A page's title comes from its file name with the number prefix dropped: 07_autodiff_and_linear_regression.ipynb → "Autodiff And Linear Regression".
Preview locally:
website/build.sh && python3 -m http.server -d website/_build 8000then open http://localhost:8000/. The site's build dependencies live in the site dependency group, which is all the deploy workflow installs. Tests: uv run --only-group site pytest website/tests.
Every push to main builds and deploys the site with GitHub Actions. One-time setup: in the repo's Settings › Pages, set Source to "GitHub Actions".