Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

TorchNPU

PyTorch Adapter Plugin for Ascend NPU

English · 中文

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

version rust license pypi platform license license GitCode Star download 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

Installation

From Binary

Take installing TorchNPU 2.10.0.post2 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.0.0. For detailed steps, please refer to the CANN Installation Guide.

Install PyTorch

Run the following command to install PyTorch 2.10.0:

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

Install TorchNPU

Run the following command to install TorchNPU 2.10.0.post2:

pip install torch-npu==2.10.0.post2

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/ascend-toolkit/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 consists of multiple Special Interest Groups (SIGs), each responsible for development, maintenance, and community collaboration in specific technical areas. Below is a list of all current SIGs. Click the corresponding links for detailed descriptions.

SIG Name Description Link
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!

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

torch_npu-2.13.0rc1-cp314-cp314-manylinux_2_28_x86_64.whl (42.7 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

torch_npu-2.13.0rc1-cp314-cp314-manylinux_2_28_aarch64.whl (39.0 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ ARM64

torch_npu-2.13.0rc1-cp313-cp313-manylinux_2_28_x86_64.whl (42.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

torch_npu-2.13.0rc1-cp313-cp313-manylinux_2_28_aarch64.whl (39.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

torch_npu-2.13.0rc1-cp312-cp312-manylinux_2_28_x86_64.whl (42.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

torch_npu-2.13.0rc1-cp312-cp312-manylinux_2_28_aarch64.whl (39.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

torch_npu-2.13.0rc1-cp311-cp311-manylinux_2_28_x86_64.whl (42.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

torch_npu-2.13.0rc1-cp311-cp311-manylinux_2_28_aarch64.whl (39.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

torch_npu-2.13.0rc1-cp310-cp310-manylinux_2_28_x86_64.whl (42.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

torch_npu-2.13.0rc1-cp310-cp310-manylinux_2_28_aarch64.whl (39.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

File details

Details for the file torch_npu-2.13.0rc1-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for torch_npu-2.13.0rc1-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 96781e173a30fb022be95eed87794f0518bda571989eb8fbd1086cff7dae78e1
MD5 44c1084224123b80b0ec33e012abfb31
BLAKE2b-256 459b705c0baa113c31d40236bf06fa16b0312090487cd318f9d0a622f6b65f49

See more details on using hashes here.

File details

Details for the file torch_npu-2.13.0rc1-cp314-cp314-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for torch_npu-2.13.0rc1-cp314-cp314-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 79ea298ce2170ed697ef2af0a59ea9f6bbe0064a15d379095952c18d976842fb
MD5 c4b905860d5b31864e8475fc2eb27b10
BLAKE2b-256 00565b099a76be03978843da4ccd8e840b075c02bdca047f357759469c5529ea

See more details on using hashes here.

File details

Details for the file torch_npu-2.13.0rc1-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for torch_npu-2.13.0rc1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e9228900a6b3ec4d9371e0cda7d87ab5aa5bb9a086a8915ae4362847313852d5
MD5 2c33413464f9a42e309ce6e960717a45
BLAKE2b-256 e9b9618d7c1c070c04dc621743bd447703e776802b3dbb5d6213e4cefe4faaf4

See more details on using hashes here.

File details

Details for the file torch_npu-2.13.0rc1-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for torch_npu-2.13.0rc1-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7d3f4999b6621486ed228724996e6af3e249af74e1890d781f7d535a3b63de17
MD5 b21cd2e7aea713de51da9463ffa65cfb
BLAKE2b-256 69afa080f30beae16fa01ee53c7dfba8c41b14594e8b0e63bba1e95bc0ca01e9

See more details on using hashes here.

File details

Details for the file torch_npu-2.13.0rc1-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for torch_npu-2.13.0rc1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0172eee67088daf1426ef382e3556176f81ca52a90a40f5fec62bcc874100611
MD5 da954344b77dedc85c3ce6f84e41c7d8
BLAKE2b-256 4c26565810ae519c1dc5e67d12eca718111a0d4ac4e085d7234b2098a9f8753b

See more details on using hashes here.

File details

Details for the file torch_npu-2.13.0rc1-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for torch_npu-2.13.0rc1-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6f7da48ba3db796b06ded6087e1a9a1827af4cada0fb298be76451e5947f10a8
MD5 021ef945102a206fddd48a05c31d1437
BLAKE2b-256 cf74cfc6bc7d3b251b8e0942ad27e966ac8131e286da73c987a0ff63db451bbe

See more details on using hashes here.

File details

Details for the file torch_npu-2.13.0rc1-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for torch_npu-2.13.0rc1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f6ec8b90c07957714504ee61013a6a8daf938024722112d76ed355b8b4dcb558
MD5 d1ac3fb1f66075a689330eb277c82dcc
BLAKE2b-256 13a7bdbddad4bbf67580b44af85efe80522027b698798a15fc041b6bf2e8da50

See more details on using hashes here.

File details

Details for the file torch_npu-2.13.0rc1-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for torch_npu-2.13.0rc1-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0f3d394418157f7642a4aa9592e27be5f4648dada9d8a27240f7d8cdb756cccb
MD5 cbc455823f114560a71c224df5fa7b8b
BLAKE2b-256 cac8d55bbf5150b39d54943e37bf55836040a3a579d1228d7cf3fd922794854b

See more details on using hashes here.

File details

Details for the file torch_npu-2.13.0rc1-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for torch_npu-2.13.0rc1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 744dff9deb501254270a9bc70ba43e50565e7ef282899bf52da6634be0b09b69
MD5 5cb343a9235170e11544b6c50fd8cc1e
BLAKE2b-256 eef1dd221ca7d6ea2329296370ff3f07c00f701bd15ad53f7abfefeaceb7cf15

See more details on using hashes here.

File details

Details for the file torch_npu-2.13.0rc1-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for torch_npu-2.13.0rc1-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 32f1421a8538fbd57f59e8993bda814020ca9345588201036a13554fc5b08754
MD5 00cd04c308759901f213cb738d0e2122
BLAKE2b-256 7856e3587fa47e17660ec4457185e3767b76a94e4af6687d2c6b329ef2e2b715

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page