From 74be3085944d76af8c52d304f44b210e841c3dc8 Mon Sep 17 00:00:00 2001 From: KarhouTam Date: Wed, 10 Jun 2026 02:12:23 +0000 Subject: [PATCH 1/7] Add Ascend NPU entry --- _additional_platforms/ascend_npu.json | 7 ++ .../additional_platforms/ascend_npu.md | 65 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 _additional_platforms/ascend_npu.json create mode 100644 _get_started/additional_platforms/ascend_npu.md diff --git a/_additional_platforms/ascend_npu.json b/_additional_platforms/ascend_npu.json new file mode 100644 index 000000000000..b649d0f7907d --- /dev/null +++ b/_additional_platforms/ascend_npu.json @@ -0,0 +1,7 @@ +{ + "name": "Ascend NPU", + "support_channel": "https://github.com/Ascend/pytorch/issues", + "stable": { + "linux": "pip3 install torch torchvision && pip3 install torch-npu" + } +} diff --git a/_get_started/additional_platforms/ascend_npu.md b/_get_started/additional_platforms/ascend_npu.md new file mode 100644 index 000000000000..a0e704d1ee55 --- /dev/null +++ b/_get_started/additional_platforms/ascend_npu.md @@ -0,0 +1,65 @@ +# Installing on Ascend NPU + +Ascend NPU is Huawei's AI processor series (including Ascend 910B, 910C, and 310P). The Ascend Extension for PyTorch (`torch_npu`) enables PyTorch to run on Ascend NPUs, supporting eager-mode execution, distributed training, and mixed precision via the `PrivateUse1` backend. + +## Prerequisites + +### Hardware Requirements + +* Ascend 910B, 910C, or 310P processor + +### Software Requirements + +* Python >= 3.10 +* CANN (Compute Architecture for Neural Networks) toolkit installed >= 8.0 +* Ascend driver and firmware installed + +Before installing PyTorch with Ascend NPU support, you must install the CANN toolkit. Download it from the [Ascend Community](https://www.hiascend.com/) and follow the [CANN Installation Guide](https://www.hiascend.com/cann/download?versionId=735&ids=d806%2Ch0501%2Ch0601%2Ch0702). + +## Installation + +### pip + +Use the pip package manager to install PyTorch with Ascend NPU support. Select your preferred options in the selector above to get the installation command. + +After installation, source the CANN environment: + +```bash +source /Ascend/cann/set_env.sh +source /Ascend/nnal/atb/set_env.sh +``` + +## Verification + +To ensure that PyTorch was installed correctly with Ascend NPU support, run the following code: + +```python +import torch +import torch_npu + +print(torch.__version__) +print("torch_npu version:", torch_npu.__version__) + +if torch.npu.is_available(): + print("Ascend NPU is available!") + print(f"NPU count: {torch_npu.npu.device_count()}") + print(f"NPU name: {torch_npu.npu.get_device_name(0)}") + + # Test basic computation + a = torch.randn(3, 4).npu() + b = torch.randn(3, 4).npu() + print("NPU computation result:", a + b) +else: + print("Ascend NPU is not available.") +``` + +Expected output should show the PyTorch and torch_npu versions, NPU count, device name, and the result of a tensor addition without errors. + +## Documentation + +For more information, please visit: + +* [Ascend Extension for PyTorch Official Documentation](https://www.hiascend.com/document/detail/zh/Pytorch/2600/index/index.html) +* [Ascend Community Portal](https://www.hiascend.com/) +* [Ascend/pytorch GitHub Repository](https://github.com/Ascend/pytorch) +* [PyPI: torch-npu](https://pypi.org/project/torch-npu/) From ad4d5ced4fe7fce990847227e29b71bced4de399 Mon Sep 17 00:00:00 2001 From: KarhouTam Date: Wed, 8 Jul 2026 06:33:05 +0000 Subject: [PATCH 2/7] update --- _get_started/additional_platforms/ascend_npu.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/_get_started/additional_platforms/ascend_npu.md b/_get_started/additional_platforms/ascend_npu.md index a0e704d1ee55..7166c01b0456 100644 --- a/_get_started/additional_platforms/ascend_npu.md +++ b/_get_started/additional_platforms/ascend_npu.md @@ -20,14 +20,7 @@ Before installing PyTorch with Ascend NPU support, you must install the CANN too ### pip -Use the pip package manager to install PyTorch with Ascend NPU support. Select your preferred options in the selector above to get the installation command. - -After installation, source the CANN environment: - -```bash -source /Ascend/cann/set_env.sh -source /Ascend/nnal/atb/set_env.sh -``` +Use the pip package manager to install PyTorch with Ascend NPU support. Please refer to the [installation page](https://www.hiascend.com/developer/software/ai-frameworks/pytorch/download?versionId=167&ids=26958bcc909e4cd48fa56d4c4a43ebec%2C98%2C106%2C1%2C6%2C3%2C) and select your preferred options in the selector above to get the installation command. ## Verification From a127807a8c7f5cb9033acc4f0426d94e3a19943d Mon Sep 17 00:00:00 2001 From: KarhouTam Date: Wed, 8 Jul 2026 06:36:22 +0000 Subject: [PATCH 3/7] update --- _get_started/additional_platforms/ascend_npu.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_get_started/additional_platforms/ascend_npu.md b/_get_started/additional_platforms/ascend_npu.md index 7166c01b0456..ee9922616189 100644 --- a/_get_started/additional_platforms/ascend_npu.md +++ b/_get_started/additional_platforms/ascend_npu.md @@ -1,12 +1,12 @@ # Installing on Ascend NPU -Ascend NPU is Huawei's AI processor series (including Ascend 910B, 910C, and 310P). The Ascend Extension for PyTorch (`torch_npu`) enables PyTorch to run on Ascend NPUs, supporting eager-mode execution, distributed training, and mixed precision via the `PrivateUse1` backend. +Ascend NPU is Huawei's AI processor series. The Ascend Extension for PyTorch (`torch_npu`) enables PyTorch to run on Ascend NPUs, supporting eager-mode execution, distributed training, and mixed precision via the `PrivateUse1` backend. ## Prerequisites ### Hardware Requirements -* Ascend 910B, 910C, or 310P processor +* Huawei Ascend NPU(s), for example, 910B, 910C, or 310P processor ### Software Requirements From b9986d1506da00fec99be70ea73a553b77e4f3c2 Mon Sep 17 00:00:00 2001 From: KarhouTam Date: Wed, 8 Jul 2026 07:47:18 +0000 Subject: [PATCH 4/7] update --- _additional_platforms/ascend_npu.json | 2 +- .../additional_platforms/ascend_npu.md | 28 ++++++++----------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/_additional_platforms/ascend_npu.json b/_additional_platforms/ascend_npu.json index b649d0f7907d..d15bea9072ef 100644 --- a/_additional_platforms/ascend_npu.json +++ b/_additional_platforms/ascend_npu.json @@ -2,6 +2,6 @@ "name": "Ascend NPU", "support_channel": "https://github.com/Ascend/pytorch/issues", "stable": { - "linux": "pip3 install torch torchvision && pip3 install torch-npu" + "linux": "pip3 install torch==2.10.0 --index-url https://download.pytorch.org/whl/cpu && pip3 install torch-npu==2.10.0" } } diff --git a/_get_started/additional_platforms/ascend_npu.md b/_get_started/additional_platforms/ascend_npu.md index ee9922616189..005529e671d2 100644 --- a/_get_started/additional_platforms/ascend_npu.md +++ b/_get_started/additional_platforms/ascend_npu.md @@ -1,12 +1,12 @@ # Installing on Ascend NPU -Ascend NPU is Huawei's AI processor series. The Ascend Extension for PyTorch (`torch_npu`) enables PyTorch to run on Ascend NPUs, supporting eager-mode execution, distributed training, and mixed precision via the `PrivateUse1` backend. +**Ascend for PyTorch (`torch-npu`)** is a deep learning adaptation framework built on Ascend. It enables Ascend NPUs to support the PyTorch framework, delivering the powerful computing capabilities of Ascend AI processors to PyTorch developers and users. ## Prerequisites ### Hardware Requirements -* Huawei Ascend NPU(s), for example, 910B, 910C, or 310P processor +* Ascend for PyTorch supports most Ascend platforms. Please check the [hardware compatibility](https://www.hiascend.com/hardware/compatibility) before installing. ### Software Requirements @@ -30,23 +30,19 @@ To ensure that PyTorch was installed correctly with Ascend NPU support, run the import torch import torch_npu -print(torch.__version__) -print("torch_npu version:", torch_npu.__version__) +x = torch.randn(2, 2).npu() +y = torch.randn(2, 2).npu() +z = x.mm(y) -if torch.npu.is_available(): - print("Ascend NPU is available!") - print(f"NPU count: {torch_npu.npu.device_count()}") - print(f"NPU name: {torch_npu.npu.get_device_name(0)}") - - # Test basic computation - a = torch.randn(3, 4).npu() - b = torch.randn(3, 4).npu() - print("NPU computation result:", a + b) -else: - print("Ascend NPU is not available.") +print(z) ``` -Expected output should show the PyTorch and torch_npu versions, NPU count, device name, and the result of a tensor addition without errors. +The following similar output indicates successful installation: + +```bash +tensor([[-0.0515, 0.3664], + [-0.1258, -0.5425]], device='npu:0') +``` ## Documentation From 3b43b796a10e47fa446bb1f4713b05b0471d36ab Mon Sep 17 00:00:00 2001 From: KarhouTam Date: Wed, 8 Jul 2026 07:51:03 +0000 Subject: [PATCH 5/7] update --- _get_started/additional_platforms/ascend_npu.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_get_started/additional_platforms/ascend_npu.md b/_get_started/additional_platforms/ascend_npu.md index 005529e671d2..1a42427ece6f 100644 --- a/_get_started/additional_platforms/ascend_npu.md +++ b/_get_started/additional_platforms/ascend_npu.md @@ -48,7 +48,7 @@ tensor([[-0.0515, 0.3664], For more information, please visit: -* [Ascend Extension for PyTorch Official Documentation](https://www.hiascend.com/document/detail/zh/Pytorch/2600/index/index.html) +* [Ascend for PyTorch Official Documentation](https://www.hiascend.com/document/detail/zh/Pytorch/2600/index/index.html) * [Ascend Community Portal](https://www.hiascend.com/) * [Ascend/pytorch GitHub Repository](https://github.com/Ascend/pytorch) * [PyPI: torch-npu](https://pypi.org/project/torch-npu/) From e0c9ae3a0b9e4f1c93b829f54d7dc18cd4ef5b0a Mon Sep 17 00:00:00 2001 From: KarhouTam Date: Wed, 8 Jul 2026 07:57:47 +0000 Subject: [PATCH 6/7] update --- _get_started/additional_platforms/ascend_npu.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/_get_started/additional_platforms/ascend_npu.md b/_get_started/additional_platforms/ascend_npu.md index 1a42427ece6f..1e91ac1f3d36 100644 --- a/_get_started/additional_platforms/ascend_npu.md +++ b/_get_started/additional_platforms/ascend_npu.md @@ -20,6 +20,10 @@ Before installing PyTorch with Ascend NPU support, you must install the CANN too ### pip +```bash +pip3 install torch==2.10.0 --index-url https://download.pytorch.org/whl/cpu && pip3 install torch-npu==2.10.0 +``` + Use the pip package manager to install PyTorch with Ascend NPU support. Please refer to the [installation page](https://www.hiascend.com/developer/software/ai-frameworks/pytorch/download?versionId=167&ids=26958bcc909e4cd48fa56d4c4a43ebec%2C98%2C106%2C1%2C6%2C3%2C) and select your preferred options in the selector above to get the installation command. ## Verification From a747ff603435149f9e6c671fc315963327185ae1 Mon Sep 17 00:00:00 2001 From: KarhouTam Date: Wed, 8 Jul 2026 09:57:27 +0000 Subject: [PATCH 7/7] update --- _get_started/additional_platforms/ascend_npu.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_get_started/additional_platforms/ascend_npu.md b/_get_started/additional_platforms/ascend_npu.md index 1e91ac1f3d36..2496d3b5026d 100644 --- a/_get_started/additional_platforms/ascend_npu.md +++ b/_get_started/additional_platforms/ascend_npu.md @@ -1,6 +1,6 @@ # Installing on Ascend NPU -**Ascend for PyTorch (`torch-npu`)** is a deep learning adaptation framework built on Ascend. It enables Ascend NPUs to support the PyTorch framework, delivering the powerful computing capabilities of Ascend AI processors to PyTorch developers and users. +**Ascend for PyTorch (`TorchNPU`)** is a deep learning adaptation framework built on Ascend. It enables Ascend NPUs to support the PyTorch framework, delivering the powerful computing capabilities of Ascend AI processors to PyTorch developers and users. ## Prerequisites