tokamax
A Pallas Custom Kernel Library.
What it is and what it does
Tokamax is a JAX library that wraps hand-tuned accelerator kernels for common deep-learning operations, built on top of JAX's Pallas framework. It provides optimized implementations of dot-product attention (FlashAttention), gated linear units, layer and RMS normalization, mixture-of-experts routing, and linear softmax cross-entropy loss, with support for both NVIDIA GPUs and Google TPUs. The library also exposes an autotuning system to discover optimal kernel configurations for your hardware and input shapes, and utilities for benchmarking kernel execution time separately from Python overhead.
Tokamax is designed for researchers and practitioners building large-scale models who need fine-grained control over kernel selection and performance. It lets you choose between multiple implementations (e.g., Triton, Mosaic, XLA) for each operation, or allow automatic selection. The package is young—still in active development with API changes expected—but offers a path to both use pre-optimized kernels and build custom ones by inheriting from the Op class.
Use it for:
- Accelerate transformer attention layers on H100 or TPU hardware by swapping standard JAX attention with tokamax.dot_product_attention
- Optimize layer normalization and RMS norm in deep networks using tokamax.layer_norm with hardware-specific implementations
- Build mixture-of-experts models with efficient ragged tensor routing via tokamax.ragged_dot on GPU or TPU
- Autotune kernel configurations for your specific hardware and input shapes to maximize throughput
- Benchmark actual kernel execution time (excluding Python overhead) using tokamax.benchmark with CUPTI or default profiling
- Export JAX functions containing custom kernels to StableHLO with device-specific guarantees via tokamax.DISABLE_JAX_EXPORT_CHECKS
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Tokamax provides custom accelerator kernels for JAX, including optimized implementations of attention, normalization, and mixture-of-experts operations for NVIDIA GPUs and Google TPUs, plus tooling to build and autotune custom kernels.
Yes, if you are training or serving large models on NVIDIA GPUs or TPUs and want to use pre-optimized kernels for attention, normalization, and mixture-of-experts without rewriting core operations. The low install friction and permissive license make adoption straightforward. However, expect API changes and incomplete features—suitable for research and experimentation, less so for production systems requiring stability guarantees. No known vulnerabilities.
Install
tokamax on PyPI
pip
pip install tokamaxuv
uv add tokamaxpoetry
poetry add tokamaxInstalling tokamax
Before you install
Low install friction with a pure Python wheel. Active maintenance status as of 148 days since latest release. However, the package declares itself still heavily under development with incomplete features and expected API changes.
License in practice
Apache License 2.0 is permissive and allows commercial use, modification, and distribution with minimal restrictions—primarily requiring license and copyright notice preservation.
Quickstart
pip install tokamax
import jax
import jax.numpy as jnp
import tokamax
def loss(x, scale):
x = tokamax.layer_norm(x, scale=scale, offset=None)
x = tokamax.dot_product_attention(x, x, x)
return jnp.sum(x)
f_grad = jax.jit(jax.grad(loss))
Requires Python >=3.11 and JAX with jaxlib installed; GPU or TPU hardware needed for actual acceleration.
Verify before relying
- Stability and API compatibility guarantees beyond the stated 'heavily under development' warning
- Performance benchmarks comparing implementations against standard JAX operations
- Supported GPU models and compute capabilities beyond the H100 example
Package facts
| License | Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 12 — absl-py, einshape, jax, jaxlib, jaxtyping, pydantic, qwix, tqdm, typing_extensions, typeguard, immutabledict, tensorboardx |
| Maintenance | actively maintained — 148 days since the last release |
| First released | |
| Downloads | 241,972/month — #8,865 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tokamax-0.0.12-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
jax-cuda12-pjrtProvides NVIDIA GPU acceleration for JAX…
permissive · top 15,000 on PyPI
jax-cuda13-pjrtProvides NVIDIA GPU acceleration for JAX…
permissive · top 15,000 on PyPI
jax-cuda13-pluginProvides NVIDIA GPU support for JAX by enabling…
permissive · top 15,000 on PyPI
jax-cuda12-pluginEnables JAX to run numerical computations and…
permissive · top 15,000 on PyPI
jaxlibjaxlib is the compiled XLA backend that enables…
permissive · top 5,000 on PyPI
torchaxtorchax is a PyTorch backend that runs PyTorch…
permissive · top 15,000 on PyPI
pathwaysutilsProvides cloud-specific integrations and…
permissive · top 15,000 on PyPI
google-tunixTunix is a JAX-based library for post-training…
permissive · top 15,000 on PyPI
augmaxAugmax is a JAX-based image data augmentation…
permissive · top 15,000 on PyPI
libtpulibtpu is the runtime library that enables JAX,…
unclear · top 5,000 on PyPI