Triton Operator Development Environment Configuration
Core Principles
Environment checks must be performed in order, as each step depends on the success of the previous one.
Prerequisite: Obtain the Latest Matching Requirements (MANDATORY)
Matching versions may be updated, so you must obtain the latest official documentation first.
- Python version requirements
- torch / torch_npu version requirements
- triton-ascend version requirements
- CANN version requirements
- Version correspondence of each component
Follow the version requirements in the documentation to update the version numbers in subsequent steps.
Currently known version correspondence (as of 2026-03-26):
| Triton-Ascend Version | CANN Version | Release Date |
|---|
| 3.2.0 | 8.5.0 (Recommended) | 2026/01/16 |
| 3.2.0rc4 | 8.3.RC2 | 2025/11/20 |
torch_npu Version: 2.7.1
Environment Check and Configuration Process
1. CANN Environment Configuration (Step 1)
CANN environment check must be done first
- Execute to check if the driver is loaded successfully
- Execute to check if the CANN environment is loaded and the npuir compiler is obtained, a path should be output
- If there is no output, try loading the CANN environment:
- Priority:
source /usr/local/Ascend/cann/set_env.sh
- Alternative:
source /usr/local/Ascend/ascend-toolkit/set_env.sh
- Perform step 1 and step 2 checks again. If unsuccessful, remind the user to check and resolve the CANN environment configuration, and suggest downloading and installing CANN from https://www.hiascend.com/cann/download
2. Python Version Check
If encountering Python issues, use miniconda to create an environment as the first solution
- Check the current Python path:
- If failed, try executing:
export PATH="/usr/bin:$PATH"
- Perform step 1 check again. If unsuccessful, remind the user to install Python, preferring the miniconda method below
- If Python3 exists, check the Python version: , which must comply with the requirements in the official quick_start.md documentation
3. Python Environment Installation (On-Demand)
- If the user needs to install a Python environment, first execute to check if a conda environment exists. If yes, jump to step 5; if no, execute step 2 to install
- Execute to confirm the current system architecture
If the system architecture is aarch64, execute:
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh
If the system architecture is x86_64, execute: wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
- Execute the installation script:
bash Miniconda3-latest-Linux-x86_64.sh
or bash Miniconda3-latest-Linux-aarch64.sh
, activate the miniconda environment after installation as prompted
- Check if miniconda is installed successfully:
- Create a Python environment:
conda create -n triton python=<official required version>
- Activate the Python environment:
4. torch Configuration
Ensure all previous steps are successful
- Execute:
- Check the torch / torch_npu versions, which must comply with the requirements in the official documentation
- If versions do not meet requirements, install according to the documentation:
- First install torch:
pip install torch==<official required version>
- If encountering the error
ERROR: No matching distribution found for torch==2.7.1+cpu
, try:
bash
pip install torch==2.7.1+cpu --index-url https://download.pytorch.org/whl/cpu
- Then install torch_npu:
pip install torch_npu==<official required version>
- Check if the torch environment is configured successfully:
python3 -c "import torch; print(torch.__version__)"
- Run a simple torch code to check if the NPU device is loaded successfully:
python3 -c "import torch; a = torch.randn(2, 3); print(a)"
, which should output results similar to: tensor([[2.86, 1.0406, 1.5811], [0.8329, 1.0024, 1.3639]])
5. triton-ascend Configuration
- Execute:
- Community Triton and Triton-Ascend cannot coexist:
- If native triton is installed, uninstall it first:
- If triton-ascend is also installed, uninstall it first, then reinstall
- Install the latest triton-ascend package:
pip install triton-ascend
- For installing the nightly version, refer to: https://triton-ascend.readthedocs.io/zh-cn/latest/installation_guide.html#nightly-build
Environment Validation (MANDATORY)
Used to confirm that the current terminal environment can execute Triton operators normally.
MANDATORY - READ ENTIRE FILE: Before performing the validation, you must fully read
.
Perform validation:
bash
python3 <skill-dir>/scripts/01-vector-add.py
After executing this operator sample, if results similar to the following appear, it indicates that the calculation meets expectations; a difference of 0.0 means the validation is passed:
tensor([0.8329, 1.0024, 1.3639, ..., 1.0796, 1.0406, 1.5811], device='npu:0')
tensor([0.8329, 1.0024, 1.3639, ..., 1.0796, 1.0406, 1.5811], device='npu:0')
The maximum difference between torch and triton is 0.0
Troubleshooting
| Symptom | Action |
|---|
| torch installation failed: No matching distribution found for torch==2.7.1+cpu | Try installing from the official PyTorch source: pip install torch==2.7.1+cpu --index-url https://download.pytorch.org/whl/cpu
|
| Both native triton and triton-ascend are installed | Uninstall native triton first: , then reinstall triton-ascend |
| C++ compiler not found | Install the compiler: |
| Missing dependencies when compiling from source | Install system libraries: sudo apt install zlib1g-dev clang-15 lld-15
(clang >= 15, lld >= 15 is recommended) |
| Still failed after retrying according to the above table | Keep complete terminal error messages and the sequence of executed commands for local or subsequent troubleshooting |
Anti-Pattern List (NEVER)
- ❌ Skip reading the official online documentation to obtain the latest matching requirements
- ❌ Skip CANN environment check and directly configure Python
- ❌ Use Python / torch versions that do not meet official requirements
- ❌ Install both native triton and triton-ascend at the same time
- ❌ Start development without environment validation
- ❌ Execute steps in different terminal sessions (must be in the same terminal)
Checklist
Notes
- If there are still problems after following the above process, you can check the official online documentation for new matching requirements: https://triton-ascend.readthedocs.io/zh-cn/latest/quick_start.html