Registry / ai-ml / tokamax

tokamax

JSON →
library0.0.12pypypiunverified

Tokamax is an OpenXLA library providing high-performance custom accelerator kernels for NVIDIA GPUs and Google TPUs. It offers state-of-the-art implementations built on top of JAX and Pallas, along with tooling for users to build and autotune their own custom kernels. As of version 0.0.12, it is still under heavy development, and users should anticipate API changes.

pip install -U tokamax
INSTALL
IMPORT
SIG · TOKAMAX
T
tokamax
ai-mlpythonv0.0.12
Install
—
Import
—
Disk
—
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.0.12 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✕ build_error
py 3.11
✕ build_error
4/8 runs
py 3.12
✕ build_error
4/8 runs
py 3.13
✕ build_error
4/8 runs
py 3.9
✕ build_error
✕ build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tokamax
✓ import tokamax
jax
✓ import jax
jax.numpy
✓ import jax.numpy as jnp
layer_norm
✓ tokamax.layer_norm
dot_product_attention
✓ tokamax.dot_product_attention
autotune
✓ tokamax.autotune
standardize_function
✓ tokamax.standardize_function
benchmark
✓ tokamax.benchmark

This quickstart demonstrates the application of `tokamax` custom kernels (e.g., `layer_norm`, `dot_product_attention`) within a JAX computation graph. It shows how to specify kernel implementations or allow `tokamax` to select the best one. It also highlights the pattern for integrating with JAX's `jit` and `grad` transformations.

import jax import jax.numpy as jnp import tokamax def loss_function(x, scale): # Apply layer normalization with a Triton implementation x = tokamax.layer_norm( x, scale=scale, offset=None, implementation="triton" ) # Apply dot product attention, allowing Tokamax to select the best implementation x = tokamax.dot_product_attention(x, x, x, implementation=None) return jnp.sum(x) # Example usage with JAX JIT and Grad key = jax.random.PRNGKey(0) x = jax.random.normal(key, (32, 2048, 64), dtype=jnp.bfloat16) scale = jax.random.normal(key, (64,), dtype=jnp.bfloat16) f_grad = jax.jit(jax.grad(loss_function)) output_grad = f_grad(x, scale) print("Computed gradient successfully.") # Example of autotuning (requires compatible hardware) # autotune_result = tokamax.autotune(loss_function, x, scale) # with autotune_result: # out_autotuned = f_grad(x, scale) # print("Autotuned output successfully.")
Debug
Known issues
breakingTokamax is still heavily under development. Incomplete features and API changes are to be expected, especially given its pre-1.0 version number.
fix
Refer to the latest GitHub README and documentation for current API usage. Pin specific versions to avoid unexpected breakage in production environments.
affects: <1.0.0
gotchaAutotuning kernels with `tokamax.autotune` is fundamentally non-deterministic due to noisy kernel execution time measurements. Different configurations chosen during autotuning can lead to numerical non-determinism.
fix
To ensure consistent numerics across sessions, serialize and explicitly reuse autotuning results using `autotune_result.dumps()` and `tokamax.AutotuningResult.loads()`.
affects: All
gotchaWhen exporting JAX functions containing Tokamax kernels using `jax.export`, you must disable export checks by passing `disabled_checks=tokamax.DISABLE_JAX_EXPORT_CHECKS`. Without this, JAX will prevent custom calls from being exported. Functions serialized this way also lose the device-independence of standard StableHLO.
fix
Add `disabled_checks=tokamax.DISABLE_JAX_EXPORT_CHECKS` to your `jax.export` call. Be aware that the exported function will be specific to the device it was serialized on.
affects: All
gotchaSpecifying a particular `implementation` for a kernel (e.g., `implementation="mosaic"`) can lead to exceptions if that implementation is unsupported for the given inputs (e.g., FP64 inputs) or hardware (e.g., older GPUs).
fix
If encountering `UnsupportedImplementationError` or similar, try `implementation=None` to let Tokamax select the best available implementation, which can fall back to XLA. Alternatively, consult the documentation for supported hardware and data types for the chosen implementation.
affects: All
Upgrade
Version history
0.0.12latest on PyPI · released Mar 19, 2026
Audit
Dependencies
jaxtypingrequiredType annotations for JAX arrays
einshaperequiredArray manipulation
tqdmrequiredProgress bars
immutabledictrequiredImmutable dictionary types
typing-extensionsrequiredBackports of new typing features
jaxrequiredCore dependency for JAX-based computation
typeguardrequiredRuntime type checking
jaxlibrequiredJAX's compiled XLA operations
qwixrequiredLikely internal or specific utility
absl-pyrequiredAbseil Python Common Libraries
pydanticrequiredData validation and settings management
tensorboardxrequiredTensorBoard logging utilities
Agent activity
49 hits · last 30 days
node
42
OpenAI (training)
1
Resources
tokamax — pip install tokamax · libregistry