jax-ml/jax-triton

jax-triton contains integrations between JAX and OpenAI Triton

What it is

jax-triton is a small library that lets you call Triton GPU kernels from JAX code. It bridges the two projects so you can write high‑performance custom kernels in Triton’s Python‑like language and use them inside normal JAX functions – even inside jax.jit‑compiled code.

Why it matters

JAX is great for automatic differentiation and large‑scale array programming, but its built‑in ops run on generic XLA kernels. Triton lets developers write hand‑tuned kernels that can be faster for specific workloads (e.g., vector adds, flash attention). jax‑triton gives you the best of both worlds: the productivity of JAX with the speed of custom Triton kernels, all while staying inside the JAX compilation pipeline.

How you use it

  1. Write a Triton kernel with the @triton.jit decorator.
  2. Call it from JAX via jax_triton.triton_call, passing JAX arrays (or mutable Refs) and the kernel’s compile‑time arguments.
  3. Optionally wrap the call in jax.jit so the whole pipeline is compiled together.

The README shows a simple vector‑add example and an in‑place variant using a mutable Ref. More complex demos (e.g., fused/flash attention) live in the examples folder.

Who it’s for

  • Researchers or engineers who already use JAX and need a custom GPU kernel for a hot‑spot.
  • Anyone wanting to experiment with Triton kernels without leaving the JAX ecosystem.
  • Developers who want to keep the JAX‑style functional API while still getting hand‑optimized performance.

Getting started

pip install jax-triton           # install the library
pip install "jax[cuda13]"       # make sure you have a CUDA‑compatible JAX build

Then write a kernel and call jax_triton.triton_call as shown in the quick‑start.

Where to learn more

  • Full docs: https://jax-ml.github.io/jax-triton
  • Example notebooks: examples/fused_attention.py and the Flash Attention ipynb.
  • Test suite under tests/ for additional usage patterns.

In a nutshell: jax-triton is a thin integration layer that lets you run Triton‑written GPU kernels directly on JAX arrays, enabling custom‑high‑performance operations inside JAX programs.

Related

  • Project
  • Dispatch
  • Project
  • Project
  • Project