How triton-lang/triton-ascend works
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: language Triton language · IR/Ops.cpp TritonGPU dialect · compiler.py Python compiler · IR/Ops.cpp Triton IR dialect
Components 17
Python frontend
- Triton language
python/triton/language - JIT interface
python/triton/runtime/jit.py - Math API
python/triton/language/math.py
Compilation and runtime
- Python compiler
python/triton/compiler/compiler.py - Backend driver
python/triton/backends/driver.py
IR and analysis
- Triton IR dialect
lib/Dialect/Triton/IR/Ops.cpp - Axis analysis
lib/Analysis/AxisInfo.cpp - TritonGPU dialect
lib/Dialect/TritonGPU/IR/Ops.cpp - Linear layouts
lib/Tools/LinearLayout.cpp
GPU transformations
- GPU conversion
lib/Conversion/TritonToTritonGPU/TritonToTritonGPUPass.cpp - Software pipeliner
lib/Dialect/TritonGPU/Transforms/Pipeliner/SoftwarePipeliner.cpp - Pipeline expansion
lib/Dialect/TritonGPU/Transforms/Pipeliner/PipelineExpander.cpp
Target and kernels
- GPU to LLVM
lib/Conversion/TritonGPUToLLVM - LLVM IR target
lib/Target/LLVMIR - Triton kernel library
python/triton_kernels/triton_kernels
Other components
- Kernel developer
- Ascend NPU
Connections 17
- Kernel developer → Triton language: writes kernels
README.md - Triton language → JIT interface: JIT decorates
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
lib/Analysis/AxisInfo.cpp - Triton IR dialect → GPU conversion: converts to GPU IR
lib/Conversion/TritonToTritonGPU/TritonToTritonGPUPass.cpp - GPU conversion → TritonGPU dialect: produces GPU IR
- TritonGPU dialect → Linear layouts: uses layout utilities
lib/Tools/LinearLayout.cpp - Software pipeliner → Pipeline expansion: expands loops
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
python/triton_kernels/triton_kernels/matmul_ogs.py - Triton language → Math API: exposes math
python/triton/language/core.py - Math API → Kernel developer: supports operators
README.md