ByteDance-Seed/triton
forked from triton-lang/triton
Captured source
source ↗ByteDance-Seed/triton
Description: Development repository for the Triton language and compiler
Language: MLIR
License: MIT
Stars: 0
Forks: 9
Open issues: 4
Created: 2025-08-28T11:41:54Z
Pushed: 2026-05-25T17:46:27Z
Default branch: dist
Fork: yes
Parent repository: triton-lang/triton
Archived: no
README:
| `Documentation` | `Nightly Wheels` | |-------------------- | -------------------- | |  |  |
Triton
This is the development repository of Triton, a language and compiler for writing highly efficient custom Deep-Learning primitives. The aim of Triton is to provide an open-source environment to write fast code at higher productivity than CUDA, but also with higher flexibility than other existing DSLs.
The foundations of this project are described in the following MAPL2019 publication: Triton: An Intermediate Language and Compiler for Tiled Neural Network Computations. Please consider citing this work if you use Triton!
The official documentation contains installation instructions and tutorials. See also these third-party Triton puzzles, which can all be run using the Triton interpreter -- no GPU required.
Quick Installation
You can install the latest stable release of Triton from pip:
pip install triton
Binary wheels are available for CPython 3.9-3.13.
Install from source
git clone https://github.com/triton-lang/triton.git cd triton pip install -r python/requirements.txt # build-time dependencies pip install -e .
Or with a virtualenv:
git clone https://github.com/triton-lang/triton.git cd triton python -m venv .venv --prompt triton source .venv/bin/activate pip install -r python/requirements.txt # build-time dependencies pip install -e .
Building with a custom LLVM
Triton uses LLVM to generate code for GPUs and CPUs. Normally, the Triton build downloads a prebuilt LLVM, but you can also build LLVM from source and use that.
LLVM does not have a stable API, so the Triton build will not work at an arbitrary LLVM version.
1. Find the version of LLVM that Triton builds against. Check cmake/llvm-hash.txt to see the current version. For example, if it says: 49af6502c6dcb4a7f7520178bd14df396f78240c
This means that the version of Triton you have builds against LLVM 49af6502.
2. git checkout LLVM at this revision. Optionally, make additional modifications to LLVM.
3. Build LLVM. For example, you might run
$ cd $HOME/llvm-project # your clone of LLVM. $ mkdir build $ cd build $ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON ../llvm -DLLVM_ENABLE_PROJECTS="mlir;llvm;lld" -DLLVM_TARGETS_TO_BUILD="host;NVPTX;AMDGPU" $ ninja
4. Grab a snack, this will take a while.
5. Build Triton as above, but set the following environment variables.
Modify as appropriate to point to your LLVM build.
$ export LLVM_BUILD_DIR=$HOME/llvm-project/build
$ cd $ LLVM_INCLUDE_DIRS=$LLVM_BUILD_DIR/include \ LLVM_LIBRARY_DIR=$LLVM_BUILD_DIR/lib \ LLVM_SYSPATH=$LLVM_BUILD_DIR \ pip install -e .
Tips for building
- Set
TRITON_BUILD_WITH_CLANG_LLD=trueas an environment variable to use clang
and lld. lld in particular results in faster builds.
- Set
TRITON_BUILD_WITH_CCACHE=trueto build with ccache.
- Set
TRITON_HOME=/some/pathto change the location of the.triton
directory where Triton's cache is located and downloads are stored during the build. By default, this is the user's home directory. It can be changed anytime.
- If you're running out of memory when building Triton, specify the
MAX_JOBS
environment variable (to the pip install -e . command) to limit the number of jobs.
- Pass
--no-build-isolationtopip installto make nop builds faster.
Without this, every invocation of pip install uses a different symlink to cmake, and this forces ninja to rebuild most of the .a files.
- vscode intellisense has some difficulty figuring out how to build Triton's C++
(probably because, in our build, users don't invoke cmake directly, but instead use setup.py). Teach vscode how to compile Triton as follows.
- Do a local build. Run command
pip install -e . - Get the full path to the
compile_commands.jsonfile produced by the build:
find ./build -name 'compile_commands.json' | xargs readlink -f. You might get a full path similar to /Users/{username}/triton/build/cmake.macosx-11.1-arm64-cpython-3.12/compile_commands.json
- In vscode, install the
C/C++ extension, then open the command palette (Shift + Command + P on Mac, or Shift + Ctrl + P on Windows/Linux) and open C/C++: Edit Configurations (UI).
- Open "Advanced Settings" and paste the full path to
compile_commands.json into the "Compile Commands" textbox.
Running tests
There currently isn't a turnkey way to run all the Triton tests, but you can follow the following recipe.
# One-time setup. Note this will reinstall local Triton because torch # overwrites it with the public version. $ make dev-install # To run all tests (requires a GPU) $ make test # Or, to run tests without a gpu $ make test-nogpu
Tips for hacking
For detailed instructions on how to debug Triton's frontend, please refer to this tutorial. The following includes additional tips for hacking on Triton's backend.
Configuration knobs
See [python/triton/knobs.py](python/triton/knobs.py) for the full list of configuration knobs. You can set those knobs directly in python or use environment variables to control them. Below are some of the environment variables you can specify (see knobs.py for the full list):
MLIR_ENABLE_DUMP=1dumps the IR before every MLIR pass Triton runs, for all
kernels. Use MLIR_ENABLE_DUMP=kernelName to dump for a specific kernel only.
- Triton cache can interfere with the dump. In cases where
MLIR_ENABLE_DUMP=1does not work, try…
Excerpt shown — open the source for the full document.
Notability
notability 2.0/10Routine fork, no traction