# triton-lang/triton-ascend architecture

> Architecture diagram of the GitHub repository triton-lang/triton-ascend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/triton-lang/triton-ascend
- Repository: https://github.com/triton-lang/triton-ascend

## Overview

Triton-Ascend is a Python-accessible GPU programming and compiler stack targeting Ascend NPUs. The principal workflow is to express a kernel with Triton’s Python language and JIT interface, compile it through Triton/MLIR transformations and code generation, then launch it on an Ascend device. The tree contains substantial Triton IR, layout, analysis, and pipeline infrastructure, but no clearly identifiable Ascend-specific backend implementation; therefore the device boundary and some compiler handoffs are shown as unverified. README capabilities such as API coverage and operator kernels are retained as separate branches.

Main entry points: [`python/triton/language`](https://github.com/triton-lang/triton-ascend/tree/main/python/triton/language) (Triton language), [`lib/Dialect/TritonGPU/IR/Ops.cpp`](https://github.com/triton-lang/triton-ascend/blob/main/lib/Dialect/TritonGPU/IR/Ops.cpp) (TritonGPU dialect), [`python/triton/compiler/compiler.py`](https://github.com/triton-lang/triton-ascend/blob/main/python/triton/compiler/compiler.py) (Python compiler), [`lib/Dialect/Triton/IR/Ops.cpp`](https://github.com/triton-lang/triton-ascend/blob/main/lib/Dialect/Triton/IR/Ops.cpp) (Triton IR dialect)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Python frontend"]
  node_language["Triton language"]
  node_jit["JIT interface<br/>[jit.py]"]
  node_math_api["Math API<br/>[math.py]"]
end

subgraph group_runtime["Compilation and runtime"]
  node_compiler["Python compiler<br/>[compiler.py]"]
  node_driver["Backend driver<br/>[driver.py]"]
end

subgraph group_ir["IR and analysis"]
  node_triton_ir["Triton IR dialect<br/>[Ops.cpp]"]
  node_axis["Axis analysis<br/>[AxisInfo.cpp]"]
  node_gpu_ir["TritonGPU dialect<br/>[Ops.cpp]"]
  node_layout["Linear layouts<br/>[LinearLayout.cpp]"]
end

subgraph group_transforms["GPU transformations"]
  node_to_gpu["GPU conversion"]
  node_pipeline["Software pipeliner"]
  node_pipeline_expand["Pipeline expansion"]
end

subgraph group_target["Target and kernels"]
  node_gpu_llvm["GPU to LLVM"]
  node_llvm_ir["LLVM IR target"]
  node_kernels["Triton kernel library"]
end

node_developer(("Kernel developer"))
node_ascend(("Ascend NPU"))

node_developer -.->|"writes kernels"| node_language
node_language -->|"JIT decorates"| node_jit
node_jit -.->|"compiles kernels"| node_compiler
node_compiler -.->|"lowers to IR"| node_triton_ir
node_triton_ir -->|"analyzed by"| node_axis
node_triton_ir -->|"converts to GPU IR"| node_to_gpu
node_to_gpu -.->|"produces GPU IR"| node_gpu_ir
node_gpu_ir -->|"uses layout utilities"| node_layout
node_pipeline -->|"expands loops"| node_pipeline_expand
node_pipeline -.->|"rewrites GPU IR"| node_gpu_ir
node_gpu_ir -.->|"lowers to LLVM"| node_gpu_llvm
node_gpu_llvm -.->|"emits target IR"| node_llvm_ir
node_compiler -.->|"selects backend"| node_driver
node_driver -.->|"launches kernels"| node_ascend
node_kernels -->|"uses API"| node_language
node_language -->|"exposes math"| node_math_api
node_math_api -.->|"supports operators"| node_developer

click node_language "https://github.com/triton-lang/triton-ascend/tree/main/python/triton/language"
click node_jit "https://github.com/triton-lang/triton-ascend/blob/main/python/triton/runtime/jit.py"
click node_compiler "https://github.com/triton-lang/triton-ascend/blob/main/python/triton/compiler/compiler.py"
click node_driver "https://github.com/triton-lang/triton-ascend/blob/main/python/triton/backends/driver.py"
click node_triton_ir "https://github.com/triton-lang/triton-ascend/blob/main/lib/Dialect/Triton/IR/Ops.cpp"
click node_axis "https://github.com/triton-lang/triton-ascend/blob/main/lib/Analysis/AxisInfo.cpp"
click node_gpu_ir "https://github.com/triton-lang/triton-ascend/blob/main/lib/Dialect/TritonGPU/IR/Ops.cpp"
click node_layout "https://github.com/triton-lang/triton-ascend/blob/main/lib/Tools/LinearLayout.cpp"
click node_to_gpu "https://github.com/triton-lang/triton-ascend/blob/main/lib/Conversion/TritonToTritonGPU/TritonToTritonGPUPass.cpp"
click node_pipeline "https://github.com/triton-lang/triton-ascend/blob/main/lib/Dialect/TritonGPU/Transforms/Pipeliner/SoftwarePipeliner.cpp"
click node_pipeline_expand "https://github.com/triton-lang/triton-ascend/blob/main/lib/Dialect/TritonGPU/Transforms/Pipeliner/PipelineExpander.cpp"
click node_gpu_llvm "https://github.com/triton-lang/triton-ascend/tree/main/lib/Conversion/TritonGPUToLLVM"
click node_llvm_ir "https://github.com/triton-lang/triton-ascend/tree/main/lib/Target/LLVMIR"
click node_kernels "https://github.com/triton-lang/triton-ascend/tree/main/python/triton_kernels/triton_kernels"
click node_math_api "https://github.com/triton-lang/triton-ascend/blob/main/python/triton/language/math.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_language,node_jit,node_math_api toneBlue
class node_compiler,node_driver toneAmber
class node_triton_ir,node_axis,node_gpu_ir,node_layout toneMint
class node_to_gpu,node_pipeline,node_pipeline_expand toneRose
class node_gpu_llvm,node_llvm_ir,node_kernels,node_developer,node_ascend toneIndigo
```

## Components

### Python frontend

- [Triton language](https://github.com/triton-lang/triton-ascend/tree/main/python/triton/language): `python/triton/language`
- [JIT interface](https://github.com/triton-lang/triton-ascend/blob/main/python/triton/runtime/jit.py): `python/triton/runtime/jit.py`
- [Math API](https://github.com/triton-lang/triton-ascend/blob/main/python/triton/language/math.py): `python/triton/language/math.py`

### Compilation and runtime

- [Python compiler](https://github.com/triton-lang/triton-ascend/blob/main/python/triton/compiler/compiler.py): `python/triton/compiler/compiler.py`
- [Backend driver](https://github.com/triton-lang/triton-ascend/blob/main/python/triton/backends/driver.py): `python/triton/backends/driver.py`

### IR and analysis

- [Triton IR dialect](https://github.com/triton-lang/triton-ascend/blob/main/lib/Dialect/Triton/IR/Ops.cpp): `lib/Dialect/Triton/IR/Ops.cpp`
- [Axis analysis](https://github.com/triton-lang/triton-ascend/blob/main/lib/Analysis/AxisInfo.cpp): `lib/Analysis/AxisInfo.cpp`
- [TritonGPU dialect](https://github.com/triton-lang/triton-ascend/blob/main/lib/Dialect/TritonGPU/IR/Ops.cpp): `lib/Dialect/TritonGPU/IR/Ops.cpp`
- [Linear layouts](https://github.com/triton-lang/triton-ascend/blob/main/lib/Tools/LinearLayout.cpp): `lib/Tools/LinearLayout.cpp`

### GPU transformations

- [GPU conversion](https://github.com/triton-lang/triton-ascend/blob/main/lib/Conversion/TritonToTritonGPU/TritonToTritonGPUPass.cpp): `lib/Conversion/TritonToTritonGPU/TritonToTritonGPUPass.cpp`
- [Software pipeliner](https://github.com/triton-lang/triton-ascend/blob/main/lib/Dialect/TritonGPU/Transforms/Pipeliner/SoftwarePipeliner.cpp): `lib/Dialect/TritonGPU/Transforms/Pipeliner/SoftwarePipeliner.cpp`
- [Pipeline expansion](https://github.com/triton-lang/triton-ascend/blob/main/lib/Dialect/TritonGPU/Transforms/Pipeliner/PipelineExpander.cpp): `lib/Dialect/TritonGPU/Transforms/Pipeliner/PipelineExpander.cpp`

### Target and kernels

- [GPU to LLVM](https://github.com/triton-lang/triton-ascend/tree/main/lib/Conversion/TritonGPUToLLVM): `lib/Conversion/TritonGPUToLLVM`
- [LLVM IR target](https://github.com/triton-lang/triton-ascend/tree/main/lib/Target/LLVMIR): `lib/Target/LLVMIR`
- [Triton kernel library](https://github.com/triton-lang/triton-ascend/tree/main/python/triton_kernels/triton_kernels): `python/triton_kernels/triton_kernels`

### Other components

- **Kernel developer**
- **Ascend NPU**

## Connections

- Kernel developer → Triton language: writes kernels (evidence: `README.md`)
- Triton language → JIT interface: JIT decorates (evidence: `python/triton/language/core.py`)
- JIT interface → Python compiler: compiles kernels
- Python compiler → Triton IR dialect: lowers to IR
- Triton IR dialect → Axis analysis: analyzed by (evidence: `lib/Analysis/AxisInfo.cpp`)
- Triton IR dialect → GPU conversion: converts to GPU IR (evidence: `lib/Conversion/TritonToTritonGPU/TritonToTritonGPUPass.cpp`)
- GPU conversion → TritonGPU dialect: produces GPU IR
- TritonGPU dialect → Linear layouts: uses layout utilities (evidence: `lib/Tools/LinearLayout.cpp`)
- Software pipeliner → Pipeline expansion: expands loops (evidence: `lib/Dialect/TritonGPU/Transforms/Pipeliner/SoftwarePipeliner.cpp`)
- Software pipeliner → TritonGPU dialect: rewrites GPU IR
- TritonGPU dialect → GPU to LLVM: lowers to LLVM
- GPU to LLVM → LLVM IR target: emits target IR
- Python compiler → Backend driver: selects backend
- Backend driver → Ascend NPU: launches kernels
- Triton kernel library → Triton language: uses API (evidence: `python/triton_kernels/triton_kernels/matmul_ogs.py`)
- Triton language → Math API: exposes math (evidence: `python/triton/language/core.py`)
- Math API → Kernel developer: supports operators (evidence: `README.md`)
