[WIP] Add Ascend NPU entry#2080
Draft
KarhouTam wants to merge 7 commits into
Draft
Conversation
✅ Deploy Preview for pytorch-dot-org-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
can-gaa-hou
reviewed
Jun 10, 2026
can-gaa-hou
reviewed
Jul 8, 2026
Comment on lines
+25
to
+30
| After installation, source the CANN environment: | ||
|
|
||
| ```bash | ||
| source <ASCEND_INSTALL_DIR>/Ascend/cann/set_env.sh | ||
| source <ASCEND_INSTALL_DIR>/Ascend/nnal/atb/set_env.sh | ||
| ``` |
Contributor
There was a problem hiding this comment.
This is CANN installation steps, not for torch-npu. Should be pip install torch-npu here. Please refer to https://www.hiascend.com/developer/software/ai-frameworks/pytorch/download?versionId=167&ids=26958bcc909e4cd48fa56d4c4a43ebec%2C98%2C106%2C1%2C6%2C3%2C
can-gaa-hou
suggested changes
Jul 8, 2026
Comment on lines
+29
to
+49
| ```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. |
Contributor
There was a problem hiding this comment.
Suggested change
| ```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. | |
| ```python | |
| import torch | |
| import torch_npu | |
| x = torch.randn(2, 2).npu() | |
| y = torch.randn(2, 2).npu() | |
| z = x.mm(y) | |
| print(z) | |
| ``` | |
| The following similar output indicates successful installation: | |
| ```bash | |
| tensor([[-0.0515, 0.3664], | |
| [-0.1258, -0.5425]], device='npu:0') | |
| ``` |
can-gaa-hou
suggested changes
Jul 8, 2026
| @@ -0,0 +1,58 @@ | |||
| # 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. | |||
Contributor
There was a problem hiding this comment.
Suggested change
| 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. |
can-gaa-hou
suggested changes
Jul 8, 2026
| "name": "Ascend NPU", | ||
| "support_channel": "https://github.com/Ascend/pytorch/issues", | ||
| "stable": { | ||
| "linux": "pip3 install torch torchvision && pip3 install torch-npu" |
Contributor
There was a problem hiding this comment.
Suggested change
| "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" |
can-gaa-hou
reviewed
Jul 8, 2026
|
|
||
| ### Hardware Requirements | ||
|
|
||
| * Huawei Ascend NPU(s), for example, 910B, 910C, or 310P processor |
Contributor
There was a problem hiding this comment.
Suggested change
| * 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add Ascend NPU as an additional platform
cc @fffrog @can-gaa-hou @zeshengzong