triton README

The project's README from github.com/triton-lang/triton. As one markdown file: README.md.

Documentation Nightly Wheels
Documentation Wheels

Triton Conference 2025

Triton Banner

The 3rd Triton Developer Conference took place on October 21, 2025 at the Microsoft Silicon Valley Campus in Mountain View, California.

Conference Materials

Conference recordings and materials are now available online:

For previous conference materials, see:

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.10-3.14.

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 and use LLVM from source.

LLVM does not have a stable API, so the Triton build will not work at an arbitrary LLVM version.

For convenience, use the following command to build LLVM and install Triton with the custom LLVM:

make dev-install-llvm
Alternatively, follow these steps to build LLVM from source manually.
  1. Find the version of LLVM that Triton builds against. Check the llvm_hash field in cmake/llvm-info.json to see the current version. For example, if it says: "llvm_hash": "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;clang" -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 <triton install>
    $ 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

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 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):

[!NOTE] Some of these environment variables don't have a knob in knobs.py-- those are only relevant to the C++ layer(s), hence they don't exist in the python layer.

Kernel Override Steps

export TRITON_ALWAYS_COMPILE=1
export TRITON_KERNEL_DUMP=1
export TRITON_DUMP_DIR=<dump_dir>
export TRITON_KERNEL_OVERRIDE=1
export TRITON_OVERRIDE_DIR=<override_dir>
# Step 1: Run the kernel once to dump kernel's IRs and ptx/amdgcn in $TRITON_DUMP_DIR
# Step 2: Copy $TRITON_DUMP_DIR/<kernel_hash> to $TRITON_OVERRIDE_DIR
# Step 3: Delete the stages that you do not want to override and modify the stage you do want to override
# Step 4: Run the kernel again to see the overridden result

Compiler Pipeline Inspection Steps To introspect the pipeline add_stages, before running your kernels, simply set the add_stages_inspection_hook like so:

def inspect_stages(_self, stages, options, language, capability):
    # inspect or modify add_stages here
triton.knobs.runtime.add_stages_inspection_hook = inspect_stages

Examples of how to use this for out of tree plugin passes is here

Changelog

Version 2.0 is out! New features include:

Contributing

Community contributions are more than welcome, whether it be to fix bugs or to add new features at github. For more detailed instructions, please visit our contributor's guide.

Compatibility

Supported Platforms:

Supported Hardware:

Development Container (Dev Container)

Dev Containers for the Triton project are available from the triton-dev-containers repository.

Key Benefits:

How to Use the Dev Container:

For detailed instructions on how to use the dev containers, please see the dev container user guide.

triton (triton-lang/triton)

Searching Database…

20.4K ·GitHub
这是什么?Triton 是一种语言和编译器,用于编写高效的自定义深度学习 GPU 内核,目标是比 CUDA 开发效率更高,同时比其他现有的领域专用语言(DSL)更灵活。
它是一种编程语言、一个库,还是别的什么?它是一种嵌入在 Python 中的领域专用语言,外加一个编译器:你用类似 Python 的语法编写内核,Triton 基于 MLIR/LLVM 的编译流程会把它们转换为面向 NVIDIA 显卡的 PTX,或面向 AMD 显卡的 AMDGCN。
它实际能在什么硬件和操作系统上运行?官方只支持 Linux。需要 Compute Capability 8.0 或更高版本的 NVIDIA 显卡,或 ROCm 6.2 或更高版本的 AMD 显卡;CPU 执行功能仍在开发中。
为什么要开发 Triton,而不直接写 CUDA?目标是让开发者编写快速的 GPU 内核,比直接写 CUDA 效率更高,同时比其他固定的领域专用语言更灵活。
没有 GPU 也能试用 Triton 内核吗?可以。Triton 有解释器模式(设置 TRITON_INTERPRET=1),让你可以在 CPU 上运行和调试内核,包括第三方的 Triton puzzles 练习题。
Triton 2.0 版本有哪些变化?后端改用 MLIR 重写,并新增了对连续矩阵乘法内核的支持,例如 flash attention;同时修复了许多错误,并改进了性能。
Size
814.6 MB
Stars
20.4K
Age
12y
Commits · 90 Days