SuperAPI AI Directory

triton-operator-env-config

Coding & development

View repository

Updated 10-16 05:01

About this skill

Triton Operator Development Environment Configuration

Core Principles

Environment checks must be performed in order, and each step depends on the success of the previous step.

Prerequisite Step: Obtain the Latest Compatibility Requirements (MANDATORY)

Compatible versions may be updated, so the latest official documentation must be obtained first.

MANDATORY - READ ENTIRE PAGE: Visit and fully read the official online documentation https://triton-ascend.readthedocs.io/zh-cn/latest/quick_start.html and https://triton-ascend.readthedocs.io/zh-cn/latest/installation_guide.html,获取最新的:

  • Python version requirements
  • torch / torch_npu version requirements
  • triton-ascend version requirements
  • CANN version requirements
  • Version correspondence of each component

Use the version requirements in the documentation as the standard, and update the version numbers in subsequent steps.

The following version correspondence is for reference only (as of 2026-03-26), and the online documentation shall prevail:

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 (for reference only): 2.7.1

⚠️ If the versions in the online documentation are inconsistent with the table above,the online documentation must prevail。

Environment Check and Configuration Process

1. CANN Environment Configuration (First Step)

The CANN environment must be checked first

  1. Executenpu-smi info, and check whether the driver is loaded successfully
  2. Then executewhich bisheng, and check whether the CANN environment is loaded successfully and the npuir compiler is obtained; a path should be output
  3. If there is no output, try to load the CANN environment:
    • Preferred:source /usr/local/Ascend/cann/set_env.sh
    • Alternative:source /usr/local/Ascend/ascend-toolkit/set_env.sh
  4. Execute the checks in step 1 and step 2 again. If they are not successful, you need to wait for the user to check and resolve the CANN environment configuration. You can remind them to go tohttps://www.hiascend.com/cann/download to download and install CANN

2. Python Version Check

If you encounter Python issues, the highest priority is to use miniconda to create an environment to resolve them

  1. Check the path of the current python:which python3
  2. If it fails, try executing:export PATH="/usr/bin:$PATH"
  3. Execute the check in step 1 again. If it is not successful, you need to remind the user to install python. For the installation method, prioritize the miniconda method below
  4. If python3 exists, check the python version:python3 --version, subject to the requirements in the official quick_start.md documentation

3. Python Environment Installation (as needed)

  1. If the user needs to install a python environment, first useconda init bashto check whether there is a conda environment. If there is, skip to step 5; if not, execute step 2 to install
  2. Executeuname -mto 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
  3. Execute the installation script:bash Miniconda3-latest-Linux-x86_64.shorbash Miniconda3-latest-Linux-aarch64.sh, and after installing according to the prompts, activate the miniconda environment
  4. Check whether the miniconda environment is installed successfully:conda init bash
  5. Create a python environment and execute:conda create -n triton python=<官方要求版本>
  6. Activate the python environment and execute:conda activate triton

4. torch Configuration

All previous steps must be successful

  1. Execute:pip list | grep "torch"
  2. Check the torch / torch_npu versions, subject to the requirements in the official documentation
  3. If the versions do not meet the requirements, install the versions specified in the documentation:
    • First install torch:pip install torch==<官方要求版本>
    • If an error occurs ERROR: No matching distribution found for torch==2.7.1+cpu, try:
      pip install torch==2.7.1+cpu --index-url https://download.pytorch.org/whl/cpu
      
    • Then install torch_npu:pip install torch_npu==<官方要求版本>
  4. Check whether the torch environment is configured successfully:python3 -c "import torch; print(torch.__version__)"
  5. Run a simple torch code snippet to check whether the npu device is loaded successfully:python3 -c "import torch; a = torch.randn(2, 3); print(a)", and it should output a result similar to:tensor([[2.86, 1.0406, 1.5811], [0.8329, 1.0024, 1.3639]])

5. triton-ascend configuration

  1. Run:pip list | grep "triton"
  2. Community Triton and Triton-Ascend cannot coexist:
    • If native triton is installed, it must be uninstalled first:pip uninstall triton
    • If triton-ascend is also installed, it also needs to be uninstalled first, and then reinstalled
  3. Install the latest triton-ascend package:pip install triton-ascend
  4. To install the nightly version, refer to:https://triton-ascend.readthedocs.io/zh-cn/latest/installation_guide.html#nightly-build

Environment verification (MANDATORY)

Used to confirm that the current terminal environment can execute triton operators normally.

MANDATORY - READ ENTIRE FILE: Before performing verification, you must read it in full scripts/01-vector-add.py。

Perform verification:

python3 <skill-dir>/scripts/01-vector-add.py

After running this operator example, if a result similar to this appears, it indicates that its computation meets expectations, and if difference is 0.0, it is considered verification 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
Native triton and triton-ascend are installed at the same time First uninstall native triton:pip uninstall triton, then reinstall triton-ascend
C++ compiler not found Install the compiler:apt-get install g++
Missing dependencies when compiling from source Install system libraries:sudo apt install zlib1g-dev clang-15 lld-15(clang >= 15, lld >= 15 recommended)
Retried according to the table above but still failed Keep the complete terminal error and the sequence of executed commands, to facilitate local or subsequent troubleshooting

Anti-pattern checklist (NEVER)

  • ❌ Skip reading the official online documentation to obtain the latest compatibility requirements
  • ❌ Skip the CANN environment check and directly configure Python
  • ❌ Use a Python / torch version that does not meet the official requirements
  • ❌ Install native triton and triton-ascend at the same time
  • ❌ Start development without performing environment verification
  • ❌ Execute step by step in different terminal sessions (must be in the same terminal)

Checklist

  • Have you read the official online documentation to obtain the latest compatibility requirements?
  • Is the CANN environment loaded successfully (npu-smi info and which bisheng have output)?
  • Does the Python version meet the official requirements?
  • Do the torch / torch_npu versions meet the official requirements?
  • Is triton-ascend installed (native triton uninstalled)?
  • Has environment verification passed (01-vector-add.py runs successfully)?

Notes