Triton (programming language)

Triton
ParadigmDomain-specific, tile-based
Designed byPhilippe Tillet
DeveloperOpenAI and contributors
First appeared28 July 2021
Stable release
3.8.0 / 28 August 2026
PlatformNvidia GPUs (CUDA), AMD GPUs (ROCm), Intel GPUs.
OSLinux
LicenseMIT License
Websitetriton-lang.org

Triton is an open-source domain-specific language and compiler for writing compute kernels for graphics processing units (GPUs). Triton is used in deep learning frameworks including vLLM.

Kernels are written as decorated Python functions that operate on blocks ("tiles") of data, and it differs from lower level languages like CUDA in that much of the scheduling within a block is handled automatically.

Triton began as the doctoral research of Philippe Tillet at Harvard University and was further developed at OpenAI, which released version 1.0 in 2021. It is now the default GPU code-generation target for PyTorch's torch.compile, and is the subject of a book by Harshwardhan Fartale published by Manning.

Triton supports Nvidia and AMD GPUs, and Intel maintains an out-of-tree backend for its own GPUs. CPU support is under development.

Example

The code below illustrates how a softmax kernel could be written in Triton.

import torch
import triton
import triton.language as tl

@triton.jit
def softmax_kernel(out_ptr, in_ptr, in_stride, out_stride, n_cols,
                   BLOCK: tl.constexpr):
    row = tl.program_id(0)
    cols = tl.arange(0, BLOCK)
    mask = cols < n_cols
    # Padding lanes load -inf, so exp() maps them to 0
    x = tl.load(in_ptr + row * in_stride + cols, mask=mask, other=-float("inf"))
    x = x - tl.max(x, axis=0)          # subtract row max for numerical stability
    num = tl.exp(x)
    y = num / tl.sum(num, axis=0)
    tl.store(out_ptr + row * out_stride + cols, y, mask=mask)

def softmax(x: torch.Tensor) -> torch.Tensor:
    n_rows, n_cols = x.shape
    out = torch.empty_like(x)
    BLOCK = triton.next_power_of_2(n_cols)
    softmax_kernel[(n_rows,)](out, x, x.stride(0), out.stride(0), n_cols,
                              BLOCK=BLOCK)
    return out

Writing the kernel this way produces a single GPU kernel that computes the maximum, exponentials, sum and division in one pass, reading the input from memory once. A naive PyTorch implementation built from separate tensor operations launches each step as its own kernel, reading and writing intermediate results to memory between them. In practice, PyTorch's built-in torch.softmax avoids this by calling a dedicated hand-written CUDA kernel.

In CUDA, a row-wise softmax requires explicit synchronisation between the threads that cooperatively compute each row's maximum and sum; in Triton the compiler handles the synchronisation and shared-memory management.

References

  1. ↑ Li, Jianling; et al. (2025). TritonBench: Benchmarking Large Language Model Capabilities for Generating Triton Operators. Findings of the Association for Computational Linguistics: ACL 2025. arXiv:2502.14752.
  2. 1 2 3 Tillet, Philippe (28 July 2021). "Introducing Triton: Open-source GPU programming for neural networks". OpenAI.
  3. ↑ Tillet, Philippe; Kung, H. T.; Cox, David (22 June 2019). Triton: an intermediate language and compiler for tiled neural network computations (PDF). 3rd ACM SIGPLAN International Workshop on Machine Learning and Programming Languages (MAPL 2019). Phoenix, AZ: ACM. pp. 10–19. doi:10.1145/3315508.3329973.
  4. ↑ Ansel, Jason; et al. (2024). PyTorch 2: Faster Machine Learning Through Dynamic Python Bytecode Transformation and Graph Compilation. ASPLOS '24. ACM. doi:10.1145/3620665.3640366.
  5. ↑ Fartale, Harshwardhan (2027). GPU Programming with Triton: Accelerate AI training and inference (Early access ed.). Manning Publications. ISBN 978-1-63343-423-3.
  6. ↑ "triton-lang/triton: Compatibility". GitHub. Retrieved 16 October 2026.
  7. ↑ "Learn How to Build and Run the Open Source OpenAI Triton Backend for Intel GPUs". Intel Developer. Intel. Retrieved 16 October 2026.
  8. ↑ "Fused Softmax". Triton documentation. Retrieved 16 October 2026.
  9. ↑ "aten/src/ATen/native/cuda/SoftMax.cu". GitHub. PyTorch. Retrieved 16 October 2026.