Skip to main content

TorchNPU

PyTorch Adapter Plugin for Ascend NPU

English | 简体中文

Supported Versions · Installation · Quick Start · Compatibility · Support · Contributing · Docs · Community

Python C++ license pypi platform GitCode repository GitHub mirror GitCode Star download PyTorch Upstream CI


Overview

As the core component of the Ascend for PyTorch community, TorchNPU is a deep learning adapter plugin built by Ascend for PyTorch, enabling the PyTorch framework to directly invoke Ascend NPU and providing developers with the powerful compute capabilities of Ascend AI processors.

Ascend is a full-stack AI computing infrastructure for industry applications and services based on Huawei Ascend AI processors and software. For more information about Ascend, see Ascend Community.

Key Features

TorchNPU fully inherits and reuses extensive mature capabilities from upstream PyTorch, and on this foundation provides deep adaptation and optimization for Ascend NPU. The diagram below illustrates the main functional modules of TorchNPU:

TorchNPU Architecture

Key Modules:

  • Basic Compute: Extensive support for PyTorch native APIs and custom APIs, covering mainstream AI scenarios with a consistent experience, enabling rapid model and algorithm implementation.
  • Distributed: Supports accelerating distributed training via FSDP2. Core compute APIs support DTensor, along with collective communication primitives such as AllGather, AllReduce, and AllToAll, as well as point-to-point primitives like Send and Recv.
  • Graph Mode: Significantly accelerates model training and inference through "dynamic graph capture + static graph optimization + efficient code generation," and supports offloading execution via NPUGraph. Supported in v2.6.0 and above.
  • Debug & Tuning: Supports profiling analysis of compute, communication, and memory usage, with real-time communication anomaly monitoring via WatchDog.
  • TorchNPU Core: Supports virtual memory management to reduce memory fragmentation, cross-stream memory reuse optimization in distributed scenarios, and integrates operators and device resources into PyTorch via PrivateUse1.

Latest News

  • 📢 [2026-06-30] Advance notice on standardized naming conventions for Ascend for PyTorch community components. 🔗 Learn more
  • 📢 [2026-04-30] TorchNPU 26.0.0 released, adding support for PyTorch 2.10.0, Python 3.13, P2P communication group dispatch, DTensor strategy extensions, and more. 🔗 Learn more

Supported PyTorch Versions

This branch adapts to multiple PyTorch versions from a single source tree. The PyTorch versions it currently supports are declared in version.txt, which is the single source of truth and is updated as new versions are adapted.

For the compatibility matrix of released packages (TorchNPU / PyTorch / CANN / Python), please refer to Compatibility.

Installation

From Binary

Take installing TorchNPU 2.12.0 as an example. Run the following commands for installation. For other versions, please refer to the community download page: TorchNPU Download.

Install CANN

Install CANN 9.1.0 and the NPU driver and firmware matching your hardware. Use a compatible Python version from the compatibility matrix. For detailed steps, please refer to the CANN Installation Guide.

Install PyTorch

Run the following command to install PyTorch 2.12.0:

pip install torch==2.12.0 --index-url https://download.pytorch.org/whl/cpu

Install TorchNPU

Run the following command to install TorchNPU 2.12.0:

pip install torch-npu==2.12.0

From Source

For detailed steps on compiling TorchNPU, please refer to the Source Installation Guide.

Quick Start

Initialize Environment

# Default path, modify according to your actual installation location
source /usr/local/Ascend/cann/set_env.sh

Run Example

import torch
import torch_npu

x = torch.randn(2, 2).npu()
y = torch.randn(2, 2).npu()
z = x.mm(y)
print(z)

Starting from TorchNPU 2.5.1, import torch_npu is no longer mandatory (auto-registration occurs), but explicit import is still recommended to ensure device initialization.

If the following output appears, the execution is successful:

tensor([[-0.0515,  0.3664],
        [-0.1258, -0.5425]], device='npu:0')

For complete model migration and training tutorials, please refer to the Quick Start Guide.

Community

The Ascend for PyTorch community is coordinated by the Technical Committee (TC), with Special Interest Groups (SIGs) responsible for development, maintenance, and community collaboration in specific technical areas. The table below introduces the TC and current SIGs. Click the corresponding links for details.

TC / SIG Name Description Link
TC Oversees technical direction and major technical decisions, SIG governance, and release reviews for Ascend for PyTorch. 🔗 Learn more
Core SIG Focuses on the development of the PyTorch core adaptation layer on the Ascend NPU platform, responsible for the design, implementation, and maintenance of the TorchNPU extension library and its operator plugin OpPlugin. 🔗 Learn more
Distributed SIG Dedicated to building efficient, easy-to-use, and scalable parallel training capabilities based on the PyTorch distributed training framework (torch.distributed) on the Ascend NPU hardware foundation, delivering extreme performance for LLM, multimodal, and reinforcement learning scenarios. 🔗 Learn more
Graph Mode SIG Focuses on core technologies such as Dynamo, Inductor, and NPUGraph, aiming to bridge the gap between "ease of use" and "high performance" through automated graph capture and compilation optimization. 🔗 Learn more
Usability SIG Dedicated to improving the usability experience of Ascend for PyTorch, including documentation, tutorials, examples, and more. 🔗 Learn more

Each SIG holds regular meetings, mailing lists, and contribution guides. Click the corresponding SIG links to view detailed contact information, goals, and participation guidelines. Everyone is welcome to contribute to the community. If you have any questions or suggestions, please submit GitHub Issues. We will reply as soon as possible. Thank you for your support.

Security Note

For system security hardening, recommended user configurations, and file permission controls for TorchNPU, please refer to the Security Note.

Disclaimer

This plugin is for debugging and development purposes only. Users are responsible for ensuring the security of input commands and properly controlling access to data generated during use. By using this plugin, you agree to and accept the above statement.

License

For the license of TorchNPU, please refer to the LICENSE file. For the license of TorchNPU documentation, please refer to the LICENSE file.

Acknowledgments

Thanks for every PR from the community! We welcome developers to contribute code to the TorchNPU plugin!

Metadata

Release files for torch-npu 2.14.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for torch-npu 2.14.0
File
torch_npu-2.14.0-cp314-cp314-manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ x86-64 Details
torch_npu-2.14.0-cp314-cp314-manylinux_2_28_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ ARM64 Details
torch_npu-2.14.0-cp313-cp313-manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64 Details
torch_npu-2.14.0-cp313-cp313-manylinux_2_28_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ ARM64 Details
torch_npu-2.14.0-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details
torch_npu-2.14.0-cp312-cp312-manylinux_2_28_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ ARM64 Details
torch_npu-2.14.0-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details
torch_npu-2.14.0-cp311-cp311-manylinux_2_28_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ ARM64 Details
torch_npu-2.14.0-cp310-cp310-manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64 Details
torch_npu-2.14.0-cp310-cp310-manylinux_2_28_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ ARM64 Details

Total release size: 418.0 MB

Release files / torch_npu-2.14.0-cp314-cp314-manylinux_2_28_x86_64.whl

Download URL torch_npu-2.14.0-cp314-cp314-manylinux_2_28_x86_64.whl
Size 43.7 MB
Tags CPython 3.14 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
ecce6be9b356a53da6362762def458a4b8615cf860573c33c4a1fc1bfde2e1a1
BLAKE2b-256 checksum
How to use checksums
d9faf5f09e0752828bf2fb04535602b18fa54d1e2c8709232ff38ba45981f240
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / torch_npu-2.14.0-cp314-cp314-manylinux_2_28_aarch64.whl

Download URL torch_npu-2.14.0-cp314-cp314-manylinux_2_28_aarch64.whl
Size 39.9 MB
Tags CPython 3.14 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
86a6f17b4fbdc88c63aa8206a16cabfb9897c8dde707ae7be43b1c0998059661
BLAKE2b-256 checksum
How to use checksums
655af4b1495a689b3247244077427f9ee71bcf94aa16748e95d3004ca20951ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / torch_npu-2.14.0-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL torch_npu-2.14.0-cp313-cp313-manylinux_2_28_x86_64.whl
Size 43.7 MB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
e577c4990e3757cdad322f5be48e725b81b594dd8f26787336fac6cc5bd10a2a
BLAKE2b-256 checksum
How to use checksums
0a1ecc8f652dfe9806f258f55c0b7b2f411b7b1676c7cbd68d2c949173cfa104
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / torch_npu-2.14.0-cp313-cp313-manylinux_2_28_aarch64.whl

Download URL torch_npu-2.14.0-cp313-cp313-manylinux_2_28_aarch64.whl
Size 39.9 MB
Tags CPython 3.13 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
025eafbb24652bbc53eec0383fad95acb560abe016a6f033a9d871ebc551d50d
BLAKE2b-256 checksum
How to use checksums
9b508478b599c440ddd758fb250221f83c0d0ba59eae078696e471cd28d6a012
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / torch_npu-2.14.0-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL torch_npu-2.14.0-cp312-cp312-manylinux_2_28_x86_64.whl
Size 43.7 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
e920a8cdd1aec09baaacba428144aff38cef889e09746360a4fed00b5de9c077
BLAKE2b-256 checksum
How to use checksums
ab550ecef6a00f33c9f88d5b22e3cd3b37d127a4d1a391131a4ef2ce99bc9cbf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / torch_npu-2.14.0-cp312-cp312-manylinux_2_28_aarch64.whl

Download URL torch_npu-2.14.0-cp312-cp312-manylinux_2_28_aarch64.whl
Size 39.9 MB
Tags CPython 3.12 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
67c47e96a8fe83e299b3ef0bcd4310321901433b6970ad377e2aef37416d6db3
BLAKE2b-256 checksum
How to use checksums
9362d8eb3567abf002c86ec88c8d01969125c229c3ce4a71d91476c5044e6196
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / torch_npu-2.14.0-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL torch_npu-2.14.0-cp311-cp311-manylinux_2_28_x86_64.whl
Size 43.7 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
7736f7d82cf9f16c7dfc4537f7e7c638153da760273a193455e70857f912189e
BLAKE2b-256 checksum
How to use checksums
48cde0aa75f418ff943f228f096f341a0b3353258bac80880d08ea58c68efc16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / torch_npu-2.14.0-cp311-cp311-manylinux_2_28_aarch64.whl

Download URL torch_npu-2.14.0-cp311-cp311-manylinux_2_28_aarch64.whl
Size 39.9 MB
Tags CPython 3.11 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
fa4c9782c003938dc70f073597b18539a170026cacc4645e33af7433f73e406b
BLAKE2b-256 checksum
How to use checksums
bc13d7547aaf38a9da085f803d32465c8f3b33fe52d76fd94a5745479b09c9cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / torch_npu-2.14.0-cp310-cp310-manylinux_2_28_x86_64.whl

Download URL torch_npu-2.14.0-cp310-cp310-manylinux_2_28_x86_64.whl
Size 43.7 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
e6348fe7e16c6f91e5b758bb1f80f471220cadaab8f79495a62ae50dedd29e75
BLAKE2b-256 checksum
How to use checksums
f2a194476ef9541f7a7ef73bb18cf2fffdadfa94c5a883ed7cca4ffa842bf2d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / torch_npu-2.14.0-cp310-cp310-manylinux_2_28_aarch64.whl

Download URL torch_npu-2.14.0-cp310-cp310-manylinux_2_28_aarch64.whl
Size 39.9 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
2eb6358345efb1294d753a05a5ed99794060ac989cd8dae4b6836a1e831eabd9
BLAKE2b-256 checksum
How to use checksums
553e20905da0aeaf658c68cd8a7b07070ed76b4c22574883ae588b4b97973378
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

2.14.0 This release

10 release files

2.12.0

8 release files

2.11.0

8 release files

2.9.1

8 release files

2.9.0

6 release files

2.8.0

6 release files

2.7.1

6 release files

2.6.0

6 release files

2.5.1

6 release files

2.4.0

8 release files

2.3.1

6 release files

2.2.0

6 release files

2.1.0

7 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page