Installation Guide

This document describes how to quickly install MindSpeed Ops, the custom operator library for Ascend training workloads.

Hardware and Supported Operating Systems

Table 1 Supported hardware

Product Supported
Ascend 950PR&950DT products √
Atlas A3 training products √
Atlas A3 inference products x
Atlas A2 training products √
Atlas A2 inference products x
Atlas 200I/500 A2 inference products x
Atlas inference products x
Atlas training products x

Note

In the preceding table, "√" indicates supported and "x" indicates not supported.

  • For operating systems supported for physical-machine deployment with each product, see the Compatibility Checker.
  • For operating systems supported for VM and container deployment with each product, see "Operating system compatibility" in the CANN Software Installation.

Before You Begin

See Related Product Versions in the release notes, and download and install the required software versions.

Go to Firmware and Drivers, and follow the instructions to install the firmware and driver.

[!NOTICE]

Use a non-root user to install and run the software. Apply strict permissions to installation directories and files: set directories to 750 and files to 640. You can control the permissions of generated files with umask, for example by setting umask to 0027.

For more security information, see the "File permission control" section for each component in the Security Statement.

Installing MindSpeed Ops

MindSpeed Ops supports image installation and source installation.

The following sections describe the applicable scenarios. Choose the installation mode that best suits your environment.

Image installation: This is the simpler option. Download a prebuilt image from the Ascend community. The image contains required dependencies and software such as CANN, TorchNPU, and MindSpeed Ops. Pull the image and start a container.

Source installation: To try the latest features or modify and enhance the source code, download the MindSpeed Ops source for the required branch and install it yourself.

Option 1: Image Installation

Note

  • The matching image preinstalls CANN 9.2.0 and the TorchNPU 26.2.0 plug-in. Use them as needed.
  • If the current environment is incompatible with the provided images, use Option 2: Source Installation.
  • New images will be released for the 26.2.0 branch. To build a custom image, see Image Overview.
  • To enable ACLNN (AscendC) operators in an image, specify --soc-version when building on a machine with an NPU, for example: bash image_build.sh -t A3 --soc-version ascend910_9391.
  1. Obtain the image.

    The latest images correspond to the MindSpeed OPs 26.2.0 branch. Select a tag to obtain the image as needed.

    • Ascend 950PR&950DT products: 26.2.0-cann9.2.0-torch_npu2.10.0.post7-950-openeuler24.03-py3.12

    • Ascend 950PR&950DT products: 26.2.0-cann9.2.0-torch_npu2.10.0.post7-950-ubuntu22.04-py3.12

    • Atlas A3 training products: 26.2.0-cann9.2.0-torch_npu2.10.0.post7-a3-openeuler24.03-py3.12

    • Atlas A3 training products: 26.2.0-cann9.2.0-torch_npu2.10.0.post7-a3-ubuntu22.04-py3.12

    • Atlas A2 training products: 26.2.0-cann9.2.0-torch_npu2.10.0.post7-910b-openeuler24.03-py3.12

    • Atlas A2 training products: 26.2.0-cann9.2.0-torch_npu2.10.0.post7-910b-ubuntu22.04-py3.12

    # Verify that the image was obtained successfully
    docker image list
    
  2. Start a container.

    Run the following command to start a container. This command is for reference only and can be modified as needed. For descriptions of these command-line options, see Table 2.

    docker run -it -d \
      --ipc=host \
      --network=host \
      --pid=host \
      --name MindSpeed-Ops \
      --privileged \
      --shm-size=512g \
      --device=/dev/davinci0 \
      --device=/dev/davinci_manager \
      --device=/dev/devmm_svm \
      --device=/dev/hisi_hdc \
      -v /usr/local/Ascend/driver:/usr/local/Ascend/driver \
      -v /usr/local/Ascend/firmware:/usr/local/Ascend/firmware \
      -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
      -v /usr/local/dcmi:/usr/local/dcmi \
      -v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \
      -v /etc/ascend_install.info:/etc/ascend_install.info \
      -v /data:/data \
      mindspeed-ops:26.2.0-cann9.2.0-torch_npu2.10.0.post7-950-openeuler24.03-py3.12 \
      /bin/bash
    

    Note

    • The default configuration assumes that the driver and firmware are installed in /usr/local/Ascend. Change the paths if they differ.
    • Before copying the startup command, replace /data in the -v options with actual local directories on the host; otherwise, the container cannot start.
    • The container initializes NPU driver and CANN environment information by default. To install a different version, replace it or run source manually. For details, see ~/.bashrc in the container.
    • "mindspeed-ops:26.2.0-cann9.2.0-torch_npu2.10.0.post7-950-openeuler24.03-py3.12" specifies the image name and tag. Change it as needed. Run docker images on the host to list available local images.

    Table 2 Command-line options

    Option Description
    -it Starts an interactive terminal (-i) and attaches it to the container's standard input/output (-t), allowing you to interact with the container and run command-line operations.
    -d Runs the container in the background without blocking the current terminal, so you can continue other operations after it starts.
    --ipc Uses the host IPC (interprocess communication) namespace.
    --network Uses the host network stack.
    --pid Uses the host PID namespace. Processes in the container can view all process IDs on the host.
    --name Assigns a name to the container. mindspeed_llm in the example is a container identifier that you can change. It must be unique on the current system. If omitted, Docker assigns a random name.
    --privileged Removes the default container permission restrictions and grants nearly host-level permissions so that Ascend driver calls, npu-smi, and other tools can interact with hardware devices.
    --shm-size Specifies the size of shared memory (/dev/shm) for the container. Set this value as needed; 512g is an example.
    The value cannot exceed the host's remaining physical memory. Run free -h to check.
    --device Maps host devices into the container. Each --device option shares a host device, such as an accelerator, with the container so that the container can access it directly.
    • /dev/davinci_manager: davinci management device.
    • /dev/hisi_hdc: hdc management device.
    • /dev/devmm_svm: memory management device.
    • /dev/davinci*X*: NPU device, where X is the ID, such as davinci0.
    Run ll /dev/ | grep davinci to query the number and names of devices. Bind the required devices and update --device=**** in the command accordingly.
    -v Maps a host directory to the corresponding directory in the container. Modify the following paths according to the actual environment.
    • /usr/local/Ascend/driver: hardware driver files. The driver is installed on the host and mapped into the container so that it can be used there.
    • /usr/local/Ascend/firmware: hardware firmware files. The firmware is installed on the host and mapped into the container so that it can be used there.
    • /usr/local/bin/npu-smi: NPU status commands such as npu-smi. Change this path according to the actual location.
    • /usr/local/dcmi: directory used to mount the dcmi tool.
    • /usr/local/Ascend/driver/version.info: driver version information.
    • /etc/ascend_install.info: installation version information.
    • /data: dataset mount path. It points to the directory that stores the dataset so that the container can access the dataset.
  3. Enter the container and confirm the environment status.

    # Query the ID or name of the local running container
    docker ps -a
    # Enter the container
    docker exec -it CONTAINER_ID_OR_NAME bash
    # Check whether the NPU is available
    npu-smi info
    

Option 2: Source Installation

Perform the following steps to obtain the source, install dependencies, and complete the MindSpeed Ops installation.

  1. (Optional) Create a virtual environment.

    Python 3.12 is recommended. For details, see the Release Notes. To avoid affecting the global Python environment, create an isolated environment with a common tool such as venv, conda, or uv.

    The following example uses conda:

    conda create -n test python=3.12
    conda activate test
    
  2. Install CANN.

    Install the matching NPU driver and firmware, CANN software (Toolkit, Kernel, and NNAL), and configure the CANN environment variables. For details, see CANN Quick Installation.

    CANN provides a process-level environment setup script. You must run it before executing service code with an NPU; otherwise, the service code cannot run.

    # Default installation path for a non-root user
    source ${HOME}/Ascend/ascend-toolkit/latest/set_env.sh
    
    # Default installation path for the root user
    source /usr/local/Ascend/ascend-toolkit/latest/set_env.sh
    

    The preceding commands use the default paths when no installation path is specified during an offline CANN installation and set the environment variables for different users. If you specify an installation path or use another installation method, see CANN Software Installation for the corresponding environment setup command.

  3. Install PyTorch and TorchNPU.

    Follow the instructions to install matching versions of PyTorch 2.10.0 and TorchNPU 26.2.0. For details, see TorchNPU Quick Installation.

    Note

  4. Install Triton-Ascend.

    For the installation instructions for the matching Triton-Ascend version, see the Triton-Ascend Installation Guide.

    The following command is an example:

    pip install triton-ascend==3.6.0 --extra-index-url=https://mirrors.huaweicloud.com/ascend/repos/pypi
    

    Note

    For Triton-Ascend 3.2.0 and earlier, Triton-Ascend and Triton cannot coexist. Uninstall community Triton before installing Triton-Ascend.

  5. Obtain and install MindSpeed Ops.

    git clone https://gitcode.com/Ascend/MindSpeed-Ops.git
    
    cd MindSpeed-Ops
    # Uninstall any existing mindspeed_ops installation before reinstalling
    pip install -e . --extra-index-url=https://triton-ascend.osinfra.cn/pypi/simple --no-build-isolation --no-deps
    

    Note

    • The preceding command installs in editable mode, so changes to the source take effect without reinstalling.

    • During installation, MindSpeed Ops detects the chip model automatically. If an NPU is detected or SOC_VERSION is set, it also compiles the C++ extension and ACLNN custom operators. Otherwise, ACLNN compilation is skipped and only Triton/TileLang operators are installed. To specify the target chip manually, use the following commands:

      # arch32 chip (Atlas A2 training products)
      export SOC_VERSION="ascend910b1"
      # arch32 chip (Atlas A3 training products)
      export SOC_VERSION="ascend910_9391"
      # arch35 chip (Ascend 950PR&950DT products)
      export SOC_VERSION="<value starting with ascend950>"
      

(Optional) Building and Running CATLASS Operators

MindSpeed Ops does not compile CATLASS operators by default. Currently, CATLASS operators support only Atlas A2 training products and Atlas A3 training products; Ascend 950PR&950DT products are not supported. In an environment with CANN, PyTorch, and TorchNPU installed, enable CATLASS compilation as follows:

source /usr/local/Ascend/ascend-toolkit/latest/set_env.sh
export MINDSPEED_BUILD_CATLASS=1

pip install -e . --no-build-isolation --no-deps

setup.py uses npu-smi to detect the chip automatically by default. If npu-smi cannot be used in a container, set the chip explicitly:

# Atlas A3 example. Use the corresponding SOC_VERSION for ascend910b* series
export SOC_VERSION=ascend910_9391

If CATLASS_SOURCE_DIR is not set, the build system automatically pulls a verified fixed CATLASS version from GitCode. For offline builds or local CATLASS development, specify existing source:

export CATLASS_SOURCE_DIR=/path/to/catlass

After a successful build, you can run the private BF16 BasicMatmul smoke operator to verify compilation, dynamic linking, and the NPU execution path:

python3 - <<'PY'
import torch
import torch_npu
import mindspeed_ops

torch.npu.set_device(0)
torch.manual_seed(42)
a = (torch.rand((128, 128), device="npu") - 0.5).to(torch.bfloat16)
b = (torch.rand((128, 128), device="npu") - 0.5).to(torch.bfloat16)

output = torch.ops.mindspeed_ops._catlass_basic_matmul(a, b)
reference = torch.matmul(a.float(), b.float()).to(torch.bfloat16)
torch.npu.synchronize()

print("output shape:", output.shape)
print("max error:", (output - reference).abs().max().cpu().item())
PY

_catlass_basic_matmul verifies only CATLASS infrastructure. It is not a formal public operator API. It currently supports BF16 and two-dimensional contiguous inputs, and M, N, and K must all be aligned to 16.

For compilation, API, and input constraints of the CATLASS chunk_loss, see chunk_loss.

(Optional) Installing TileLang-Ascend to Use TileLang Operators

The default MindSpeed Ops installation does not compile or install TileLang-Ascend automatically. To use operators under mindspeed_ops.api.tilelang, install TileLang-Ascend separately in an Ascend environment with CANN, PyTorch, and TorchNPU installed.

Build and install a TileLang-Ascend wheel from source:

git clone --recursive https://github.com/tile-ai/tilelang-ascend.git
cd tilelang-ascend

source /usr/local/Ascend/ascend-toolkit/latest/set_env.sh
export ASCEND_HOME_PATH=/usr/local/Ascend/ascend-toolkit/latest

./build_wheel_ascend.sh --enable-llvm
pip install -U dist/tilelang-*.whl

After installation, verify that TileLang-Ascend and MindSpeed Ops can both be imported:

python -c "import tilelang; print(tilelang.__version__)"
python -c "from mindspeed_ops.api.tilelang.sinkhorn import sinkhorn; print(sinkhorn)"

Verifying Installation

After installation, use the following steps to verify that MindSpeed Ops is installed successfully.

  1. Check that the NPU is available:

    npu-smi info
    
  2. Check that mindspeed_ops can be imported. In an environment where ACLNN operators have been compiled, the import automatically loads shared libraries and registers operators.

    python -c "import mindspeed_ops; print('MindSpeed Ops loaded successfully')"
    
  3. Check that a Triton operator API can be invoked:

    python -c "from mindspeed_ops.api.triton.fused_cross_entropy_loss import FusedCrossEntropyLossFunction; print(FusedCrossEntropyLossFunction)"
    

For more usage instructions, see Quick Start. For common installation issues, see FAQs.