Ahead of Time (AOT) Triton Math Library
pip install -r requirements.txt
# Preferred since 0.12; build inside a container if possible to avoid https://github.com/ROCm/aotriton/issues/166
pip wheel third_party/triton -w /tmp/triton_wheel/
mkdir build
cd build
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${CONDA_PREFIX}/lib/pkgconfig"
cmake .. -DCMAKE_INSTALL_PREFIX=./install_dir -DCMAKE_BUILD_TYPE=Release -DAOTRITON_GPU_BUILD_TIMEOUT=0 -DAOTRITON_USE_LOCAL_TRITON_WHEEL=/tmp/triton_wheel/.whl -G Ninja
# Use ccmake to tweak options
ninja install/strip # Use `ninja install` to keep symbolsThe library and the header file can be found under build/install_dir afterwards.
You may ignore the export PKG_CONFIG_PATH part if you're not building with conda
Note: do not run ninja separately, due to the limit of the current build
system, ninja install will run the whole build process unconditionally.
python >= 3.10python >= 3.14, Triton needs patch https://github.com/triton-lang/triton/commit/c44b870bdd9e1ea8933fd4057b6b59a5e6e5407b
to fix ast.Num error.gcc >= 8 or clang >= 10cmake >= 3.26cmake >= 3.30 is testedninjaninja >= 1.11 is testedninja >= 1.13.1 on Windows due to https://github.com/ninja-build/ninja/issues/2616liblzmaliblzma-dev or xz-devel.pkg-configliblzma.xz-devel.pkgconf
or pkg-config in older releases.The kernel definition for generation is done in rules.py. Edits to this file are needed for each new kernel, but it is extensible and generic.
Include files can be added in this directory.
The final build output is an archive object file any new project may link against.
The archive file and header files are installed in the path specified by
CMAKE_INSTALL_PREFIX.
Set AOTRITON_DEBUG_LEVEL= to enable runtime logging: 1=ERROR,
2=WARNING, 3=INFO, 4=DEBUG, 5=EXTRA_DEBUG (default: 0, silent).
Windows limitation: log messages that include file paths (e.g. at
LOG_DEBUG level) use UTF-8 encoding. If your kernel package path contains
non-ASCII characters, ensure your terminal and console code page support UTF-8
(e.g. chcp 65001) to avoid garbled output.
Currently the first kernel supported is FlashAttention as based on the algorithm from Tri Dao.
AOTriton is consumed in PyTorch through the SDPA kernels. The precompiled binaries will be downloaded and shipped with PyTorch during builds.
CAVEAT: As a fast moving target, AOTriton's FlashAttention API changes over time. Hence, a specific PyTorch release is only compatible with a few versions of AOTriton. The compatibility matrix is shown below
| PyTorch Upstream | AOTriton Feature Release |
|---|---|
| 2.9 (upcoming) | 0.11b, 0.10b(1) |
| 2.8 | 0.10b(2), 0.9b(2) |
| 2.7 | 0.9b(4), 0.10bdrop-in only(3) |
| 2.6 | 0.8b(5) |
| 2.5 | 0.7b, 0.8b(6) |
| 2.4 | 0.6b |
| 2.3 | 0.4b |
| 2.2 and earlier | N/A, no support |
libaotriton_v2.so.0.9.2 to libaotriton_v2.so.0.10.0. However, 0.10b
cannot be built with PyTorch 2.7 due to the integrity check in the
integration code.ROCm's PyTorch release/\ branch is slightly different from PyTorch upstream and may support more recent version of AOTriton
| PyTorch ROCm Fork | AOTriton Feature Release |
|---|---|
| 2.9 (upcoming) | 0.11b |
| 2.8 | 0.10b (backported) |
| 2.7 | 0.9b (backported) |
| 2.6 | 0.9b (backported) |
| 2.5 | 0.9b (backported) |
| 2.4 | 0.10b (backported) |
| 2.3 | 0.4b |
| 2.2 and earlier | N/A, no support |
AOTriton's point releases maintain ABI compatibility and can be used as drop-in replacement of their corresponding feature releases.
aotriton.images
folder from a Linux build.No open issues yet, or sync has not completed.