Skip to content
jax-linear-attention: fast linear attention, SSM and attention kernels for JAX on NVIDIA Hopper. 72.3% MFU on one H100 (1.3B transformer, FP8), 68.2% MFU per GPU on 8 H100s, kernels up to 5.37x faster (Mamba-3 MIMO against the official recurrence kernels), 1.04-1.67x flame end to end in bf16jax-linear-attention: fast linear attention, SSM and attention kernels for JAX on NVIDIA Hopper. 72.3% MFU on one H100 (1.3B transformer, FP8), 68.2% MFU per GPU on 8 H100s, kernels up to 5.37x faster (Mamba-3 MIMO against the official recurrence kernels), 1.04-1.67x flame end to end in bf16
Measured on H100 GPUs on 20 October 2026 with no other jobs on the GPUs, unless noted. Kernel ratios are forward + backward, the other implementation's time over ours. Every result
Quick start

One op, or one TOML file.

JLA installs from PyPI as jax-linear-attention. Call a kernel from your own JAX model with jla.ops.linear_attention(..., impl="auto"): it runs the Mosaic GPU kernel on an H100 and the chunked JAX op anywhere else. Or train a model from one TOML file with jla train.

Python 3.12 or newer and JAX 0.11.2 (the version is pinned). The kernels need an NVIDIA Hopper GPU (H100 or H200) and a CUDA 13 driver; on any other device every op falls back to its plain-JAX implementation. Quick start

pip install "jax-linear-attention[cuda]"

CPU only (reference and chunked ops, small models):

pip install jax-linear-attention
Why JLA

Kernels for the layers new models use.

The layers behind newer language models (Mamba, Gated DeltaNet, KDA, RWKV-7, GLA) are recurrences, and they need dedicated kernels to train fast. PyTorch has them in Flash Linear Attention's Triton kernels; in JAX they have mostly run as plain JAX ops, which XLA cannot fuse into one efficient pass.

Exact

Three implementations of every recurrence.

A token-by-token reference (the oracle), a chunk-parallel JAX op that runs on any JAX backend, and a Pallas Mosaic GPU kernel for Hopper. The tests hold each kernel to the reference on dense inputs, packed documents, initial and final states and every gradient.

Fail-closed

Slower, never wrong.

impl="auto" runs a kernel only for the shapes, dtypes and options its GPU tests cover; every other call runs the chunked JAX op, so an unsupported call is slower, never wrong.

Packed documents

Every kernel, every document.

segment_ids reset the state at document boundaries inside every kernel, so a packed batch trains exactly as its documents would one by one.

Training stack

One TOML file per experiment.

Data, FSDP, tensor, expert and pipeline parallelism; FP8 with delayed scaling; dropless MoE on grouped-GEMM kernels; crash-consistent checkpoints with exact resume; SFT and DPO; Hugging Face import and export; perplexity and lm-evaluation-harness. Every option

Kernels

Measured against the latest upstream code.

On one H100, forward + backward: the Mamba-2 scan 1.20–1.96× the official Triton kernels and the whole Mamba-2 layer 1.17–1.41× the official fused training path, Mamba-3 SISO 1.58–2.32× and MIMO 2.70–5.37× the official recurrence kernels, GLA 1.52–1.77× FLA (dense), KDA 1.47–1.78× FLA, RWKV-7 1.06–1.46× FLA, and Gated DeltaNet 1.71–2.68× FLA's Triton kernels and 0.73–1.26× FlashQLA. Every shape and version

Kernel speed against the strongest latest upstream code, forward + backward, on one H100Kernel speed against the strongest latest upstream code, forward + backward, on one H100
Forward + backward on one H100 against the latest upstream code named on each row: bars are medians over the benchmark shapes, whiskers the range, and right of 1× ours is faster.
End to end

Training at 1.3B.

On one H100 and the same tokens, the transformer, sliding-window, Gated DeltaNet, KDA and Mamba-2 presets train 1.04–1.67× faster than flame (FLA's trainer, with torch.compile where it works) in bf16 and 1.10–1.77× in FP8, and Mamba-3 1.55× in bf16. Results

1.3B training throughput against flame on one H100, bf16 and FP8, for the 1.3B presets1.3B training throughput against flame on one H100, bf16 and FP8, for the 1.3B presets

transformer-1p3b reaches 72.3% MFU in FP8 on one H100 and 68.2% per GPU on eight, and gdn-hd128-1p3b 55.0% and 52.3% against flame's 36.1% and 33.4%. MFU is model FLOPs over the 989 TFLOP/s bf16 spec; a power-capped H100 sustains about 681 TFLOP/s in bf16. Eight GPUs

MFU of the 1.3B transformer and Gated DeltaNet presets against flame: one H100 in bf16 and FP8, eight H100s in FP8MFU of the 1.3B transformer and Gated DeltaNet presets against flame: one H100 in bf16 and FP8, eight H100s in FP8
A paper's own setting

In the Gated DeltaNet-2 paper's setting.

The paper's Figure 2 times 1.3B hybrids on one H100 at 16,384 tokens per step. In that setting, every model of the figure trains 1.14–1.41× faster than the paper's numbers with a 32,000-token vocabulary, and 0.99–1.23× with Llama-3's 128,256. The Gated DeltaNet-2 hybrid runs at 52.1 and 49.1 thousand tokens/s at 2K × 8 and 16K × 1, against the paper's 38.0 and 36.1. The settings and the caveats

Training throughput in the Gated DeltaNet-2 paper's setting: every 1.3B model of the paper's Figure 2 at 4K x 4 tokens on one H100, the paper's numbers against ours with a 32K and a 128K vocabularyTraining throughput in the Gated DeltaNet-2 paper's setting: every 1.3B model of the paper's Figure 2 at 4K x 4 tokens on one H100, the paper's numbers against ours with a 32K and a 128K vocabulary
Sequence length

From 2K to 64K tokens.

Forward + backward against the fastest upstream code that runs each shape: Mamba-2 and GLA lead at every length and head layout, Gated DeltaNet trails FlashQLA on long single rows of 8 heads of dim 128, and causal attention stays below FA3 (0.73–0.90× with the default backward). Attention results

Forward + backward speedup across sequence lengths from 2K to 64K tokens for Mamba-2, Gated DeltaNet, GLA and causal softmax attention, against the fastest upstream code at each shapeForward + backward speedup across sequence lengths from 2K to 64K tokens for Mamba-2, Gated DeltaNet, GLA and causal softmax attention, against the fastest upstream code at each shape
Where we lose

As plainly as where we win.

The cases where JLA is slower than the alternatives, with their numbers. Every case and the reason

  • Softmax attention against FA3

    The forward is 0.90–0.92× FA3 on causal attention, short of the 0.95× target, and forward + backward 0.77–0.92× with the default backward (0.87–1.00× with the opt-in fused one); impl="auto" keeps cuDNN for dense causal and windowed calls.

  • Gated DeltaNet against FlashQLA

    On long single sequences (one row of 16K–64K tokens: 0.69–0.78× forward + backward at 8 heads, 0.68–0.73× at 16) and with packed documents at small B × H (one row of 8 heads with 16 documents: 0.74–0.77× from 16K tokens, 0.58–0.60× at 2K–8K). FlashQLA starts each sequence piece a few chunks early, from zero (an approximation); our split is exact, and its backward is two passes against FlashQLA's one fused kernel. At head dim 64, which FlashQLA does not support, packed documents in short rows also trail FLA (0.83–0.93× forward + backward at 2K–8K tokens).

  • KDA inference against FlashKDA

    At large B × H (0.57× at (8, 2048, 32)): FlashKDA keeps a bf16 state and approximate exp, and fuses its per-chunk preparation into one kernel.

  • Hopper only, one JAX version

    The kernels need an H100 or H200 (everything else runs plain JAX), and JAX is pinned to 0.11.2 because Mosaic GPU's API changes with every JAX release. A few kernels (the Mamba-2 row kernels, the Gated DeltaNet piece scan, fp8_swiglu) are Pallas Triton, which JAX 0.11.2 deprecates; they move to Mosaic GPU before the pin does.

Our linear-attention kernels port the Triton kernels of Flash Linear Attention and follow its layer definitions, and its trainer, flame, is our end-to-end baseline. FlashAttention-3 shaped our attention kernel, our Mamba kernels port Mamba's, FlashQLA and FlashKDA showed the way for the Gated DeltaNet and KDA kernels, and Tokamax and JAX's Pallas examples are where our attention and GEMM kernels began. Acknowledgements

JLA is an independent project. It is not affiliated with or endorsed by Google or the JAX team; “JAX” names the framework it is built on.

Open source

Built in
the open.

JLA is free and open source under Apache-2.0. Version 0.1.0 is early development, and its APIs will change. Contributions are welcome, with a DCO sign-off on every commit.