已合并
[docs]v2.7.1文档产品名称更新 #39928
chenzhenxi创建于 7月2日
[docs]v2.7.1文档产品名称更新 #39928
已合并
chenzhenxi创建于 7月2日
9 个文件变更+129-101
MREADME.md+47-47
@@ -1,8 +1,8 @@
1-# Ascend Extension for PyTorch1+# TorchNPU
2 2 
3## Overview3## Overview
4 4 
5-This repository develops the **Ascend Extension for PyTorch** named **torch_npu** to adapt **Ascend NPU** to **PyTorch** so that developers who use the **PyTorch** can obtain powerful compute capabilities of **Ascend AI Processors**.5+**TorchNPU** is a PyTorch adapter plugin that brings **Ascend NPU** support into the **PyTorch** ecosystem, enabling developers to harness the high-performance computing power of Ascend AI processors.
6 6 
7Ascend is a full-stack AI computing infrastructure for industry applications and services based on Huawei Ascend processors and software. For more information about Ascend, see [Ascend Community](https://www.hiascend.com/en/).7Ascend is a full-stack AI computing infrastructure for industry applications and services based on Huawei Ascend processors and software. For more information about Ascend, see [Ascend Community](https://www.hiascend.com/en/).
8 8 
@@ -10,76 +10,75 @@ Ascend is a full-stack AI computing infrastructure for industry applications and
10 10 
11### From Binary11### From Binary
12 12 
13-Provide users with wheel package to quickly install **torch_npu**. Before installing **torch_npu**, complete the installation of **CANN** according to [Ascend Auxiliary Software](#ascend-auxiliary-software). To obtain the **CANN** installation package, refer to the [CANN Installation](https://www.hiascend.com/cann).13+Provide users with wheel package to quickly install **TorchNPU**. Before installing **TorchNPU**, complete the installation of **CANN** according to [Ascend Auxiliary Software](#ascend-auxiliary-software). To obtain the **CANN** installation package, refer to the [CANN Installation](https://www.hiascend.com/cann).
14 14 
151. **Install PyTorch**151. **Install PyTorch**
16 16 
17-Install **PyTorch** through pip.17+ Install **PyTorch** through pip.
18 18 
19-**For Aarch64:**19+ **For Aarch64:**
20 20 
21-```bash21+ ```bash
22-pip3 install torch==2.7.122+ pip3 install torch==2.7.1
23-```23+ ```
24 24 
25-**For x86:**25+ **For x86:**
26 26 
27-```bash27+ ```bash
28-pip3 install torch==2.7.1+cpu --index-url https://download.pytorch.org/whl/cpu28+ pip3 install torch==2.7.1+cpu --index-url https://download.pytorch.org/whl/cpu
29-```29+ ```
30 30 
31-2. **Install torch-npu dependencies**31+2. **Install TorchNPU dependencies**
32 32 
33-Run the following command to install dependencies.33+ Run the following command to install dependencies.
34 34 
35-```bash35+ ```bash
36-pip3 install pyyaml36+ pip3 install pyyaml
37-pip3 install setuptools37+ pip3 install setuptools
38-```38+ ```
39 39 
40-If the installation fails, use the download link or visit the [PyTorch official website](https://pytorch.org/) to download the installation package of the corresponding version.40+ If the installation fails, use the download link or visit the [PyTorch official website](https://pytorch.org/) to download the installation package of the corresponding version.
41 41 
42-| OS arch | Python version | link |42+ | OS arch | Python version | link |
43-|---------|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|43+ |---------|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
44-| x86 | Python3.9 | [link](https://download.pytorch.org/whl/cpu/torch-2.7.1%2Bcpu-cp39-cp39-manylinux_2_28_x86_64.whl#sha256=d205cac087d60bc176bdc0b63a1d00dc7a4ee5ac76fd20a2ca318ac65674167e) |44+ | x86 | Python3.9 | [link](https://download.pytorch.org/whl/cpu/torch-2.7.1%2Bcpu-cp39-cp39-manylinux_2_28_x86_64.whl#sha256=d205cac087d60bc176bdc0b63a1d00dc7a4ee5ac76fd20a2ca318ac65674167e) |
45-| x86 | Python3.10 | [link](https://download.pytorch.org/whl/cpu/torch-2.7.1%2Bcpu-cp310-cp310-manylinux_2_28_x86_64.whl#sha256=1f04a373a3f643821f721da9898ef77dce73b5b6bfc64486f0976f7fb5f90e83) |45+ | x86 | Python3.10 | [link](https://download.pytorch.org/whl/cpu/torch-2.7.1%2Bcpu-cp310-cp310-manylinux_2_28_x86_64.whl#sha256=1f04a373a3f643821f721da9898ef77dce73b5b6bfc64486f0976f7fb5f90e83) |
46-| x86 | Python3.11 | [link](https://download.pytorch.org/whl/cpu/torch-2.7.1%2Bcpu-cp311-cp311-manylinux_2_28_x86_64.whl#sha256=a1684793e352f03fa14f78857e55d65de4ada8405ded1da2bf4f452179c4b779) |46+ | x86 | Python3.11 | [link](https://download.pytorch.org/whl/cpu/torch-2.7.1%2Bcpu-cp311-cp311-manylinux_2_28_x86_64.whl#sha256=a1684793e352f03fa14f78857e55d65de4ada8405ded1da2bf4f452179c4b779) |
47-| aarch64 | Python3.9 | [link](https://download.pytorch.org/whl/cpu/torch-2.7.1%2Bcpu-cp39-cp39-manylinux_2_28_aarch64.whl#sha256=a4551cb97b83df5f93fc0d7538332535828581e1db2f179afc287027afbdd6e8) |47+ | aarch64 | Python3.9 | [link](https://download.pytorch.org/whl/cpu/torch-2.7.1%2Bcpu-cp39-cp39-manylinux_2_28_aarch64.whl#sha256=a4551cb97b83df5f93fc0d7538332535828581e1db2f179afc287027afbdd6e8) |
48-| aarch64 | Python3.10 | [link](https://download.pytorch.org/whl/cpu/torch-2.7.1%2Bcpu-cp310-cp310-manylinux_2_28_aarch64.whl#sha256=c0df17cee97653d09a4e84488a33d21217f9b24208583c55cf28f0045aab0766) |48+ | aarch64 | Python3.10 | [link](https://download.pytorch.org/whl/cpu/torch-2.7.1%2Bcpu-cp310-cp310-manylinux_2_28_aarch64.whl#sha256=c0df17cee97653d09a4e84488a33d21217f9b24208583c55cf28f0045aab0766) |
49-| aarch64 | Python3.11 | [link](https://download.pytorch.org/whl/cpu/torch-2.7.1%2Bcpu-cp311-cp311-manylinux_2_28_aarch64.whl#sha256=5fe6045b8f426bf2d0426e4fe009f1667a954ec2aeb82f1bd0bf60c6d7a85445) |49+ | aarch64 | Python3.11 | [link](https://download.pytorch.org/whl/cpu/torch-2.7.1%2Bcpu-cp311-cp311-manylinux_2_28_aarch64.whl#sha256=5fe6045b8f426bf2d0426e4fe009f1667a954ec2aeb82f1bd0bf60c6d7a85445) |
50 50 
51-3. **Install torch-npu**51+3. **Install TorchNPU**
52 52 
53-```53+ ```bash
54-pip3 install torch-npu==2.7.154+ pip3 install torch-npu==2.7.1
55- 55+ ```
56-```
57 56 
58### From Source57### From Source
59 58 
60-In some special scenarios, users may need to compile **torch-npu** by themselves.Select a branch in table [Ascend Auxiliary Software](#ascend-auxiliary-software) and a Python version in table [PyTorch and Python Version Matching Table](#pytorch-and-python-version-matching-table) first. The docker image is recommended for compiling torch-npu through the following steps(It is recommended to mount the working path only and avoid the system path to reduce security risks.), the generated .whl file path is ./dist/. Note that gcc version has the following constraints if you try to compile without using docker image: we recommend to use gcc 11.2 for both ARM and X86.59+In some special scenarios, users may need to compile **TorchNPU** by themselves. Select a branch in table [Ascend Auxiliary Software](#ascend-auxiliary-software) and a Python version in table [PyTorch and Python Version Matching Table](#pytorch-and-python-version-matching-table) first. The docker image is recommended for compiling TorchNPU through the following steps (It is recommended to mount the working path only and avoid the system path to reduce security risks.), the generated .whl file path is ./dist/. Note that gcc version has the following constraints if you try to compile without using docker image: we recommend to use gcc 11.2 for both ARM and X86.
61 60 
62-1. **Clone torch-npu**61+1. **Clone TorchNPU**
63 62 
64- ```63+ ```bash
65 git clone https://github.com/ascend/pytorch.git -b 2.7.1-7.2.0 --depth 164 git clone https://github.com/ascend/pytorch.git -b 2.7.1-7.2.0 --depth 1
66 ```65 ```
67 66 
682. **Build Docker Image**672. **Build Docker Image**
69 68 
70- ```69+ ```bash
71 cd pytorch/ci/docker/{arch} # {arch} for X86 or ARM70 cd pytorch/ci/docker/{arch} # {arch} for X86 or ARM
72 docker build -t manylinux-builder:v1 .71 docker build -t manylinux-builder:v1 .
73 ```72 ```
74 73 
753. **Enter Docker Container**743. **Enter Docker Container**
76 75 
77- ```76+ ```bash
78 docker run -it -v /{code_path}/pytorch:/home/pytorch manylinux-builder:v1 bash77 docker run -it -v /{code_path}/pytorch:/home/pytorch manylinux-builder:v1 bash
79- # {code_path} is the torch_npu source code path78+ # {code_path} is the TorchNPU source code path
80 ```79 ```
81 80 
82-4. **Compile torch-npu**81+4. **Compile TorchNPU**
83 82 
84 Take **Python 3.9** as an example.83 Take **Python 3.9** as an example.
85 84 
@@ -92,13 +91,13 @@ In some special scenarios, users may need to compile **torch-npu** by themselves
92 91 
93 If you would like to compile with new C++ ABI, then first run this command, at this point, the recommended compilation environment is same to community torch package: glibc 2.28, gcc 11.2.192 If you would like to compile with new C++ ABI, then first run this command, at this point, the recommended compilation environment is same to community torch package: glibc 2.28, gcc 11.2.1
94 93
95- ```94+ ```bash
96 export _GLIBCXX_USE_CXX11_ABI=195 export _GLIBCXX_USE_CXX11_ABI=1
97 ```96 ```
98 97 
99 Meanwhile, we support configuring -fabi-version using the following variables,require consistency with the community torch package98 Meanwhile, we support configuring -fabi-version using the following variables,require consistency with the community torch package
100 99 
101- ```100+ ```bash
102 export _ABI_VERSION=16101 export _ABI_VERSION=16
103 ```102 ```
104 103 
@@ -130,7 +129,7 @@ print(z)
130 129 
131## User Manual130## User Manual
132 131 
133-Refer to [API of Ascend Extension for PyTorch](docs/api/torch_npu_apis.md) for more detailed information.132+Refer to [API of TorchNPU](docs/zh/native_apis/menu_pt_native_apis.md) for more detailed information.
134 133 
135## PyTorch and Python Version Matching Table134## PyTorch and Python Version Matching Table
136 135 
@@ -146,7 +145,6 @@ Refer to [API of Ascend Extension for PyTorch](docs/api/torch_npu_apis.md) for m
146| PyTorch2.7.1 | Python3.9.x,Python3.10.x,Python3.11.x |145| PyTorch2.7.1 | Python3.9.x,Python3.10.x,Python3.11.x |
147| PyTorch2.8.0 | Python3.9.x,Python3.10.x,Python3.11.x |146| PyTorch2.8.0 | Python3.9.x,Python3.10.x,Python3.11.x |
148 147 
149- 
150## Ascend Auxiliary Software148## Ascend Auxiliary Software
151 149 
152**PyTorch Extension** versions follow the naming convention `{PyTorch version}-{Ascend version}`, where the former represents the PyTorch version compatible with the **PyTorch Extension**, and the latter is used to match the CANN version. The detailed matching is as follows:150**PyTorch Extension** versions follow the naming convention `{PyTorch version}-{Ascend version}`, where the former represents the PyTorch version compatible with the **PyTorch Extension**, and the latter is used to match the CANN version. The detailed matching is as follows:
@@ -212,6 +210,7 @@ Refer to [API of Ascend Extension for PyTorch](docs/api/torch_npu_apis.md) for m
212## Hardware support210## Hardware support
213 211 
214The Ascend training device includes the following models, all of which can be used as training environments for PyTorch models212The Ascend training device includes the following models, all of which can be used as training environments for PyTorch models
213+ 
215| Product series | Product model |214| Product series | Product model |
216|-----------------------|----------------------------------|215|-----------------------|----------------------------------|
217| Atlas Training series products | Atlas 800(model: 9000) |216| Atlas Training series products | Atlas 800(model: 9000) |
@@ -225,13 +224,14 @@ The Ascend training device includes the following models, all of which can be us
225| | Atlas 300T A2 |224| | Atlas 300T A2 |
226 225 
227The Ascend inference device includes the following models, all of which can be used as inference environments for large models226The Ascend inference device includes the following models, all of which can be used as inference environments for large models
227+ 
228| Product series | Product model |228| Product series | Product model |
229|-----------------------|----------------------------------|229|-----------------------|----------------------------------|
230| Atlas 800I A2 Inference product | Atlas 800I A2 |230| Atlas 800I A2 Inference product | Atlas 800I A2 |
231 231 
232## Pipeline Status232## Pipeline Status
233 233 
234-Due to the asynchronous development mechanism of upstream and downstream, incompatible modifications in upstream may cause some functions of **torch_npu** to be unavailable (only upstream and downstream development branches are involved, excluding stable branches). Therefore, we built a set of daily tasks that make it easy to detect relevant issues in time and fix them within 48 hours (under normal circumstances), providing users with the latest features and stable quality.234+Due to the asynchronous development mechanism of upstream and downstream, incompatible modifications in upstream may cause some functions of **TorchNPU** to be unavailable (only upstream and downstream development branches are involved, excluding stable branches). Therefore, we built a set of daily tasks that make it easy to detect relevant issues in time and fix them within 48 hours (under normal circumstances), providing users with the latest features and stable quality.
235 235 
236| **OS** | **CANN Version(Docker Image)** | **Upstream Branch** | **Downstream Branch** | **Period** | **Status** |236| **OS** | **CANN Version(Docker Image)** | **Upstream Branch** | **Downstream Branch** | **Period** | **Status** |
237| :---: | :---: | :---: | :---: | :---: | :---: |237| :---: | :---: | :---: | :---: | :---: | :---: |
@@ -252,7 +252,7 @@ The version branches of AscendPyTorch have the following maintenance phases:
252| Maintained | 1 year/3.5 years | Regular Release branch for 1 year, Long Term Support branch maintenance for 3.5 years. Fix major issues, do not incorporate new features, and release patch versions based on the impact of fixed bugs. |252| Maintained | 1 year/3.5 years | Regular Release branch for 1 year, Long Term Support branch maintenance for 3.5 years. Fix major issues, do not incorporate new features, and release patch versions based on the impact of fixed bugs. |
253| End Of Life (EOL) | N/A | Do not accept any modification to a branch. |253| End Of Life (EOL) | N/A | Do not accept any modification to a branch. |
254 254 
255-## PyTorch Maintenance Policies255+## PyTorch Maintenance Policies
256 256 
257| **PyTorch** | **Maintenance Policies** | **Status** | **Launch Date** | **Subsequent Status** | **EOL Date** |257| **PyTorch** | **Maintenance Policies** | **Status** | **Launch Date** | **Subsequent Status** | **EOL Date** |
258|-------------|--------------------------|-------------|-----------------|-------------------------------------------------------------------|--------------|258|-------------|--------------------------|-------------|-----------------|-------------------------------------------------------------------|--------------|
@@ -272,7 +272,7 @@ The version branches of AscendPyTorch have the following maintenance phases:
272 272 
273## Reference Documents273## Reference Documents
274 274 
275-For more detailed information on installation guides, model migration, training/inference tutorials, and API lists, please refer to the [Ascend Extension for PyTorch on the HiAI Community](https://www.hiascend.com/software/ai-frameworks?framework=pytorch).275+For more detailed information on installation guides, model migration, training/inference tutorials, and API lists, please refer to the [TorchNPU on the HiAI Community](https://www.hiascend.com/software/ai-frameworks?framework=pytorch).
276 276 
277| Document Name | Document Link |277| Document Name | Document Link |
278|------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|278|------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|
@@ -283,4 +283,4 @@ For more detailed information on installation guides, model migration, training/
283 283 
284## License284## License
285 285 
286-Ascend Extension for PyTorch has a BSD-style license, as found in the [LICENSE](LICENSE) file.286+TorchNPU has a BSD-style license, as found in the [LICENSE](LICENSE) file.
MREADME.zh.md+13-13
@@ -1,8 +1,8 @@
1-# Ascend Extension for PyTorch插件1+# TorchNPU
2 2 
3## 简介3## 简介
4 4 
5-本项目开发了名为**torch_npu**的**Ascend Extension for PyTorch**插件,使昇腾NPU可以适配PyTorch框架,为使用PyTorch框架的开发者提供昇腾AI处理器的超强算力。5+**TorchNPU**是为PyTorch框架开发的适配插件,旨在将昇腾NPU接入PyTorch生态,为使用PyTorch框架的开发者提供昇腾AI处理器的超强算力。
6 6 
7昇腾为基于华为昇腾处理器和软件的行业应用及服务提供全栈AI计算基础设施。您可以通过访问[昇腾社区](https://www.hiascend.com/zh/),了解关于昇腾的更多信息。7昇腾为基于华为昇腾处理器和软件的行业应用及服务提供全栈AI计算基础设施。您可以通过访问[昇腾社区](https://www.hiascend.com/zh/),了解关于昇腾的更多信息。
8 8 
@@ -26,28 +26,28 @@
26 26 
27## 版本说明27## 版本说明
28 28 
29-Ascend Extension for PyTorch的版本说明包含版本配套说明、版本兼容性说明和更新说明等,具体请参见《[Ascend Extension for PyTorch 版本说明](docs/zh/release_notes/release_notes.md)》。29+TorchNPU的版本说明包含版本配套说明、版本兼容性说明和更新说明等,具体请参见《[TorchNPU 版本说明](docs/zh/release_notes/release_notes.md)》。
30 30 
31## 环境部署31## 环境部署
32 32 
33-Ascend Extension for PyTorch插件的安装操作,具体请参见《[Ascend Extension for PyTorch 软件安装](docs/zh/installation_guide/menu_installation_guide.md)》。33+TorchNPU插件的安装操作,具体请参见《[TorchNPU 软件安装](docs/zh/installation_guide/menu_installation_guide.md)》。
34 34 
35## 快速入门35## 快速入门
36 36 
37-以CNN模型为例,介绍将其迁移至昇腾NPU上进行训练的方法,具体操作请参见《[Ascend Extension for PyTorch 快速入门](docs/zh/quick_start/quick_start.md)》。37+以CNN模型为例,介绍将其迁移至昇腾NPU上进行训练的方法,具体操作请参见《[TorchNPU 快速入门](docs/zh/quick_start/quick_start.md)》。
38 38 
39## 特性介绍39## 特性介绍
40 40 
41-Ascend Extension for PyTorch插件从内存资源优化、通信性能优化、计算性能优化、辅助报错定位等方面精心打造了一系列独特的特性,具体特性指导请参见《[PyTorch 框架特性指南](docs/zh/framework_feature_guide_pytorch/menu_framework_feature.md)》。41+TorchNPU插件从内存资源优化、通信性能优化、计算性能优化、辅助报错定位等方面精心打造了一系列独特的特性,具体特性指导请参见《[PyTorch 框架特性指南](docs/zh/framework_feature_guide_pytorch/menu_framework_feature.md)》。
42 42 
43## API参考43## API参考
44 44 
45- 原生PyTorch API在昇腾NPU设备上的支持情况请参见《[PyTorch 原生API支持度](docs/zh/native_apis/menu_pt_native_apis.md)》。45- 原生PyTorch API在昇腾NPU设备上的支持情况请参见《[PyTorch 原生API支持度](docs/zh/native_apis/menu_pt_native_apis.md)》。
46-- Ascend Extension for PyTorch插件提供了部分自定义API接口,具体使用请参见《[Ascend Extension for PyTorch自定义API](https://gitcode.com/Ascend/op-plugin/blob/master/docs/zh/custom_APIs/menu_Pytorch_API.md)》。46+- TorchNPU插件提供了部分自定义API接口,具体使用请参见《[TorchNPU自定义API](https://gitcode.com/Ascend/op-plugin/blob/master/docs/zh/custom_APIs/menu_Pytorch_API.md)》。
47 47 
48## 分支维护策略48## 分支维护策略
49 49 
50-Ascend Extension for PyTorch版本分支的维护阶段如下:50+TorchNPU版本分支的维护阶段如下:
51 51 
52| **状态** | **时间** | **说明** |52| **状态** | **时间** | **说明** |
53| ------------------- | -------- | ------------------------------------------------ |53| ------------------- | -------- | ------------------------------------------------ |
@@ -77,7 +77,7 @@ Ascend Extension for PyTorch版本分支的维护阶段如下:
77 77 
78## 贡献指导78## 贡献指导
79 79 
80-介绍如何向Ascend Extension for PyTorch插件库贡献代码,具体请参见[Ascend Extension for PyTorch插件 贡献指南](docs/zh/CONTRIBUTING.md)。80+介绍如何向TorchNPU插件库贡献代码,具体请参见[TorchNPU插件 贡献指南](docs/zh/CONTRIBUTING.md)。
81 81 
82## 联系我们82## 联系我们
83 83 
@@ -85,11 +85,11 @@ Ascend Extension for PyTorch版本分支的维护阶段如下:
85 85 
86## 安全声明86## 安全声明
87 87 
88-Ascend Extension for PyTorch的系统安全加固、运行用户建议和文件权限控制等内容,请参见[Ascend Extension for PyTorch插件 安全声明](docs/zh/SECURITYNOTE.md)。88+TorchNPU的系统安全加固、运行用户建议和文件权限控制等内容,请参见[TorchNPU插件 安全声明](docs/zh/SECURITYNOTE.md)。
89 89 
90## 免责声明90## 免责声明
91 91 
92-Ascend Extension for PyTorch插件使用者92+TorchNPU插件使用者
93 93 
94- 本插件仅供调试和开发使用,使用者需自行承担使用风险,并理解以下内容:94- 本插件仅供调试和开发使用,使用者需自行承担使用风险,并理解以下内容:
95 - 数据处理及删除:用户在使用本插件过程中产生的数据属于用户责任范畴。建议用户在使用完毕后及时删除相关数据,以防信息泄露。95 - 数据处理及删除:用户在使用本插件过程中产生的数据属于用户责任范畴。建议用户在使用完毕后及时删除相关数据,以防信息泄露。
@@ -100,8 +100,8 @@ Ascend Extension for PyTorch的系统安全加固、运行用户建议和文件
100 100 
101## License101## License
102 102 
103-Ascend Extension for PyTorch插件的使用许可证,具体请参见[LICENSE](LICENSE)文件。103+TorchNPU插件的使用许可证,具体请参见[LICENSE](LICENSE)文件。
104 104 
105## 致谢105## 致谢
106 106 
107-感谢来自社区的每一个PR,欢迎贡献Ascend Extension for PyTorch插件!107+感谢来自社区的每一个PR,欢迎贡献TorchNPU插件!
Mbenchmarks/v1sparsedrive/README.md+1-1
@@ -1,4 +1,4 @@
1-# SimpleV1SparseDrive (torch-npu / Ascend)1+# SimpleV1SparseDrive (TorchNPU / Ascend)
2 2 
3---3---
4 4 
Mci/docker/README.md+8-4
@@ -1,10 +1,10 @@
1-## Ascend Pytorch Dockerfile Repository1+# Ascend Pytorch Dockerfile Repository
2 2 
3This folder hosts the `Dockerfile` to build docker images with various platforms.3This folder hosts the `Dockerfile` to build docker images with various platforms.
4 4 
5-### Build torch_npu from Docker container5+## Build TorchNPU from Docker container
6 6 
7-**Clone torch-npu**7+**Clone TorchNPU**
8 8 
9```Shell9```Shell
10git clone https://gitcode.com/ascend/pytorch.git --depth 110git clone https://gitcode.com/ascend/pytorch.git --depth 1
@@ -16,7 +16,9 @@ git clone https://gitcode.com/ascend/pytorch.git --depth 1
16cd pytorch/ci/docker/{arch} # {arch} for X86 or ARM16cd pytorch/ci/docker/{arch} # {arch} for X86 or ARM
17docker build -t manylinux-builder:v1 .17docker build -t manylinux-builder:v1 .
18```18```
19+ 
19If you want to configure the environment of LCOV, please build docker image like this:20If you want to configure the environment of LCOV, please build docker image like this:
21+ 
20```Shell22```Shell
21cd pytorch/ci/docker/{arch} # {arch} for X86 or ARM23cd pytorch/ci/docker/{arch} # {arch} for X86 or ARM
22docker build -t manylinux-builder:v1 --build-arg CONFIG_FOR_LCOV=1 .24docker build -t manylinux-builder:v1 --build-arg CONFIG_FOR_LCOV=1 .
@@ -28,9 +30,11 @@ docker build -t manylinux-builder:v1 --build-arg CONFIG_FOR_LCOV=1 .
28docker run -it -v /{code_path}/pytorch:/home/pytorch manylinux-builder:v1 bash30docker run -it -v /{code_path}/pytorch:/home/pytorch manylinux-builder:v1 bash
29# {code_path} is the torch_npu source code path31# {code_path} is the torch_npu source code path
30```32```
31-**Compile torch_npu**33+ 
34+**Compile TorchNPU**
32 35 
33Take Python 3.9 as an example36Take Python 3.9 as an example
37+ 
34```Shell38```Shell
35cd /home/pytorch39cd /home/pytorch
36bash ci/build.sh --python=3.940bash ci/build.sh --python=3.9
Mdocker/devel/README.md+3-3
@@ -1,6 +1,6 @@
1# TorchNPU 开发镜像1# TorchNPU 开发镜像
2 2 
3-本目录提供 Dockerfile 及构建脚本,用于生成 TorchNPU 的构建与开发镜像:`builder` 镜像提供 torch_npu 编译环境(不含 CANN),`dev` 镜像在此基础上叠加 CANN 运行环境。3+本目录提供 Dockerfile 及构建脚本,用于生成 TorchNPU 的构建与开发镜像:`builder` 镜像提供 TorchNPU 编译环境(不含 CANN),`dev` 镜像在此基础上叠加 CANN 运行环境。
4 4 
5## 1 镜像介绍5## 1 镜像介绍
6 6 
@@ -12,7 +12,7 @@ base manylinux + Python 软链接 + pip 源 + 基础系统包(curl/wget
12 └── dev builder + CANN(Toolkit + Ops + NNAL 可选) ← 运行环境12 └── dev builder + CANN(Toolkit + Ops + NNAL 可选) ← 运行环境
13```13```
14 14 
15-- **builder**(默认):用于编译 torch_npu wheel,不含 CANN15+- **builder**(默认):用于编译 TorchNPU wheel,不含 CANN
16- **dev**:基于 builder,叠加 CANN 运行环境;继承全部编译工具链,可在容器内直接重新编译16- **dev**:基于 builder,叠加 CANN 运行环境;继承全部编译工具链,可在容器内直接重新编译
17 17 
18> Dockerfile会自动根据当前架构(ARM/X86)拉取对应镜像。18> Dockerfile会自动根据当前架构(ARM/X86)拉取对应镜像。
@@ -111,7 +111,7 @@ bash builder.sh --cann --no-cache # 含 CANN 且不使用
111 111 
112## 3 启动容器112## 3 启动容器
113 113 
114-> torch_npu **编译**无需 CANN/驱动;CANN 与 NPU 驱动仅在**运行时**(`import torch_npu`、调用 NPU 算子)需要。因此根据镜像类型选择不同的启动方式。114+> TorchNPU **编译**无需 CANN/驱动;CANN 与 NPU 驱动仅在**运行时**(`import torch_npu`、调用 NPU 算子)需要。因此根据镜像类型选择不同的启动方式。
115>115>
116> 若已通过 `builder.sh` 构建,脚本会自动构建镜像并启动容器,可直接执行下方的 `docker exec` 命令进入容器;本节其余命令仅适用于手动执行 `docker build` 后需自行启动容器的场景。116> 若已通过 `builder.sh` 构建,脚本会自动构建镜像并启动容器,可直接执行下方的 `docker exec` 命令进入容器;本节其余命令仅适用于手动执行 `docker build` 后需自行启动容器的场景。
117 117 
Mexamples/libtorch_triton_ascend/README.md+2-2
@@ -2,9 +2,9 @@
2 2 
3## 环境约束3## 环境约束
4 4 
5-1)**torch_npu 和 CANN 环境**5+1)**TorchNPU 和 CANN 环境**
6 6 
7-本样例依赖 torch_npu 运行环境,推荐 torch_npu 26.1.0 及配套 CANN 9.1.0 版本。7+本样例依赖 TorchNPU 运行环境,推荐 TorchNPU 26.1.0 及配套 CANN 9.1.0 版本。
8 8 
92)**triton-ascend >= 3.2.2**92)**triton-ascend >= 3.2.2**
10 10 
Mtest/README.md+19-7
@@ -1,29 +1,38 @@
1-## 简介1+# 简介
2-test目录为PTA相关的测试用例。2+ 
3+test目录为TorchNPU相关的测试用例。
4+ 
3## 安装依赖5## 安装依赖
4 6 
5`pip3 install -r requirements.txt`7`pip3 install -r requirements.txt`
6 8 
7## 补全脚本9## 补全脚本
10+ 
8该操作需要联网11该操作需要联网
9-```12+ 
13+```bash
10cd test14cd test
11bash get_synchronized_files.sh15bash get_synchronized_files.sh
12```16```
17+ 
13通过以上操作,会自动补齐testfiles_synchronized.txt和testfolder_synchronized.txt中的文件或文件夹。18通过以上操作,会自动补齐testfiles_synchronized.txt和testfolder_synchronized.txt中的文件或文件夹。
19+ 
14## 跳过失败用例20## 跳过失败用例
21+ 
15`export DISABLED_TESTS_FILE=./unsupported_test_cases/.pytorch-disabled-tests.json`22`export DISABLED_TESTS_FILE=./unsupported_test_cases/.pytorch-disabled-tests.json`
16 23 
17如果不是在test目录下运行测试用例,需要传入.pytorch-disabled-tests.json的绝对路径。24如果不是在test目录下运行测试用例,需要传入.pytorch-disabled-tests.json的绝对路径。
25+ 
18## 执行方式26## 执行方式
27+ 
19### 执行单个测试脚本28### 执行单个测试脚本
29+ 
20运行以test开头的文件。以test_autocast.py为例:30运行以test开头的文件。以test_autocast.py为例:
21 31 
22方式一:32方式一:
23 33 
24`python test_autocast.py`34`python test_autocast.py`
25 35 
26- 
27方式二:36方式二:
28 37 
29`python run_test.py -i test_autocast`38`python run_test.py -i test_autocast`
@@ -31,6 +40,7 @@ bash get_synchronized_files.sh
31说明:部分以test开头的脚本不是直接运行的脚本,比如jit中的测试脚本是通过test_jit.py执行的。40说明:部分以test开头的脚本不是直接运行的脚本,比如jit中的测试脚本是通过test_jit.py执行的。
32 41 
33### 执行具体的用例42### 执行具体的用例
43+ 
34通过-k参数传入具体的用例名。以test_autocast.py为例:44通过-k参数传入具体的用例名。以test_autocast.py为例:
35 45 
36方式一:46方式一:
@@ -42,24 +52,26 @@ bash get_synchronized_files.sh
42`python run_test.py -v -i test_autocast -- -k test_autocast_nn_fp32`52`python run_test.py -v -i test_autocast -- -k test_autocast_nn_fp32`
43 53 
44### 执行全量UT的方式54### 执行全量UT的方式
45-```55+ 
56+```bash
46# 进入到test目录的上一级57# 进入到test目录的上一级
47cd ../58cd ../
48```59```
49 60 
50运行非分布式全量用例:61运行非分布式全量用例:
51 62 
52-```63+```bash
53python ci/access_control_test.py --all64python ci/access_control_test.py --all
54```65```
55 66 
56运行分布式全量用例:67运行分布式全量用例:
57 68 
58-```69+```bash
59python ci/access_control_test.py --distributed70python ci/access_control_test.py --distributed
60```71```
61 72 
62## FAQ73## FAQ
74+ 
631. 报错:"dictionary changed size during interation". 751. 报错:"dictionary changed size during interation".
64 76 
65 如果python 环境是3.8.1版本,报错在unitest/case.py中,可考虑是sys.modules被修改导致的。第三方包可能会有对sys.modules的修改,比如beartype。 77 如果python 环境是3.8.1版本,报错在unitest/case.py中,可考虑是sys.modules被修改导致的。第三方包可能会有对sys.modules的修改,比如beartype。
Mtorch_npu/_inductor/ascend_npu_ir/README.md+34-22
@@ -1,41 +1,49 @@
1# 简介1# 简介
2+ 
2Torch 的 Inductor-MLIR 编译优化是基于 torch.compile 接口、融合 MLIR(Multi-Level Intermediate Representation)技术的新一代后端优化方案。Inductor-MLIR 是 PyTorch 编译体系对原生 Inductor 后端的扩展升级,在保留 torch.compile 动态图捕获 + 静态图优化 + 高效代码生成的核心逻辑的基础上,借助 MLIR 的多层级、跨架构编译能力,适配多类硬件架构的深度优化需求,显著提升不同算力平台下模型训练与推理的编译灵活性和性能上限。3Torch 的 Inductor-MLIR 编译优化是基于 torch.compile 接口、融合 MLIR(Multi-Level Intermediate Representation)技术的新一代后端优化方案。Inductor-MLIR 是 PyTorch 编译体系对原生 Inductor 后端的扩展升级,在保留 torch.compile 动态图捕获 + 静态图优化 + 高效代码生成的核心逻辑的基础上,借助 MLIR 的多层级、跨架构编译能力,适配多类硬件架构的深度优化需求,显著提升不同算力平台下模型训练与推理的编译灵活性和性能上限。
3Inductor-MLIR 包含如下核心组件:4Inductor-MLIR 包含如下核心组件:
4-|组件| 定位 |作用|
5-|-|-|-|
6-|Dynamo |前端编译器(代码转换器) |延续 TorchDynamo 的核心能力,JIT 将用户的 eager(动态图)代码编译为 FX Graph,完成动态图到静态中间表示的捕获,为 Inductor-MLIR 后端提供统一的输入,保证前端编译逻辑的一致性|
7-|Inductor-MLIR |核心编译器(多层级 IR 优化器) |作为 Inductor-MLIR 的核心层,将 FX Graph 转换为 MLIR 多层级中间表示(IR);通过跨层级的优化策略(如算子拆分与融合、数据类型优化、计算图化简),兼顾编译灵活性与优化深度,适配不同硬件的编译特性|
8-|MLIR CodeGen |代码生成器(硬件感知代码生成器) |接收优化后的 MLIR IR,针对目标硬件生成专属的高性能底层代码|
9 5 
10-# 使指导6+| 组件 | 定位 | 作 |
7+| -------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------ |
8+| Dynamo | 前端编译器(代码转换器) | 延续 TorchDynamo 的核心能力,JIT 将用户的 eager(动态图)代码编译为 FX Graph,完成动态图到静态中间表示的捕获,为 Inductor-MLIR 后端提供统一的输入,保证前端编译逻辑的一致性 |
9+| Inductor-MLIR | 核心编译器(多层级 IR 优化器) | 作为 Inductor-MLIR 的核心层,将 FX Graph 转换为 MLIR 多层级中间表示(IR);通过跨层级的优化策略(如算子拆分与融合、数据类型优化、计算图化简),兼顾编译灵活性与优化深度,适配不同硬件的编译特性 |
10+| MLIR CodeGen | 代码生成器(硬件感知代码生成器) | 接收优化后的 MLIR IR,针对目标硬件生成专属的高性能底层代码 |
11+ 
12+## 使用指导
13+ 
11## 环境配置14## 环境配置
12 15 
13-* torch_npu:2.6.0或之后版本的torch_npu支持torch.compile接口;16+* TorchNPU:2.6.0或之后版本的TorchNPU支持torch.compile接口;
14* torch-mlir:Inductor后端的MLIR模式依赖torch-mlir。用户可以从[LINK](https://repo.oepkgs.net/ascend/pytorch/vllm/torch/)获取torch-mlir软件包;17* torch-mlir:Inductor后端的MLIR模式依赖torch-mlir。用户可以从[LINK](https://repo.oepkgs.net/ascend/pytorch/vllm/torch/)获取torch-mlir软件包;
15 18 
16## 使用方式19## 使用方式
20+ 
17MLIR使用方式有三种, 任选一种即可调用21MLIR使用方式有三种, 任选一种即可调用
18 22 
191. config导入(torch.compile之前导入)231. config导入(torch.compile之前导入)
20-```24+ 
21-torch._inductor.config.npu_backend == "mlir"25+ ```python
22-torch.compile(op_calc)(x)26+ torch._inductor.config.npu_backend == "mlir"
23-```27+ torch.compile(op_calc)(x)
28+ ```
24 29 
252. 环境变量导入(npu初始化之前导入)302. 环境变量导入(npu初始化之前导入)
26 31 
27-```32+ ```python
28-import os33+ import os
29-os.environ['TORCHINDUCTOR_NPU_BACKEND'] = 'mlir'34+ os.environ['TORCHINDUCTOR_NPU_BACKEND'] = 'mlir'
30-torch.compile(op_calc)(x)35+ torch.compile(op_calc)(x)
31-```36+ ```
37+ 
323. options导入383. options导入
33-```39+ 
34-torch.compile(op_calc,options={"npu_backend":"mlir"})(x)40+ ```python
35-```41+ torch.compile(op_calc,options={"npu_backend":"mlir"})(x)
42+ ```
43+ 
36## 示例44## 示例
37 45 
38-```46+```python
39import os47import os
40# 环境变量调用需要在torch_npu初始化之前48# 环境变量调用需要在torch_npu初始化之前
41os.environ['TORCHINDUCTOR_NPU_BACKEND'] = 'mlir'49os.environ['TORCHINDUCTOR_NPU_BACKEND'] = 'mlir'
@@ -62,9 +70,12 @@ compile_func = torch.compile(op_calc, options={"npu_backend": "mlir"})
62compile_out, codes = run_and_get_code(compile_func,x,y)70compile_out, codes = run_and_get_code(compile_func,x,y)
63print(codes[0])71print(codes[0])
64```72```
73+ 
65## 输出mlir融合算子74## 输出mlir融合算子
75+ 
66codes 为捕获到的 MLIR 输出代码片段,该代码中包含 call 函数与 benchmark_compiled_model 函数,其中 call 函数内部封装了 MLIR 编译生成的算子逻辑。76codes 为捕获到的 MLIR 输出代码片段,该代码中包含 call 函数与 benchmark_compiled_model 函数,其中 call 函数内部封装了 MLIR 编译生成的算子逻辑。
67-```77+ 
78+```python
68def call(args):79def call(args):
69 arg0_1, arg1_1 = args80 arg0_1, arg1_1 = args
70 args.clear()81 args.clear()
@@ -77,4 +88,5 @@ def call(args):
77 del arg1_188 del arg1_1
78 return (buf0, )89 return (buf0, )
79```90```
80-其中mlir_fused_mul_0.run 是 MLIR 编译生成的核心执行接口,用于在指定 NPU 设备和计算流上执行融合乘法算子计算,接收输入张量并将计算结果写入输出张量,是 MLIR 对原始乘法逻辑优化后的底层实现。91+ 
92+其中mlir_fused_mul_0.run 是 MLIR 编译生成的核心执行接口,用于在指定 NPU 设备和计算流上执行融合乘法算子计算,接收输入张量并将计算结果写入输出张量,是 MLIR 对原始乘法逻辑优化后的底层实现。
Mtorch_npu/_inductor/mfusion/README.md+2-2
@@ -11,12 +11,12 @@ MFusion 包含如下核心组件:
11| subgraph_registry | 子图注册表 | 管理融合子图的元数据,包括 FX GraphModule 和动态/静态标记 |11| subgraph_registry | 子图注册表 | 管理融合子图的元数据,包括 FX GraphModule 和动态/静态标记 |
12| decomp | 算子分解 | 提供 Inductor 融合前的算子预处理,确保融合路径的正确性 |12| decomp | 算子分解 | 提供 Inductor 融合前的算子预处理,确保融合路径的正确性 |
13 13 
14-# 使用指导14+## 使用指导
15 15 
16## 环境配置16## 环境配置
17 17 
18* mfusion:MFusion 组件的 Python wheel 包18* mfusion:MFusion 组件的 Python wheel 包
19-* torch_npu:2.7.1 和 2.9.0 支持 MFusion 功能19+* TorchNPU:2.7.1 和 2.9.0 支持 MFusion 功能
20* torch-mlir:MFusion 依赖 torch-mlir 进行 MLIR 代码生成,用户可从 [LINK](https://repo.oepkgs.net/ascend/pytorch/vllm/torch/) 获取20* torch-mlir:MFusion 依赖 torch-mlir 进行 MLIR 代码生成,用户可从 [LINK](https://repo.oepkgs.net/ascend/pytorch/vllm/torch/) 获取
21 21 
22## 环境变量22## 环境变量