已合并
modify docs #5810
molly123321创建于 5 天前
modify docs #5810
已合并
molly123321创建于 5 天前
11 个文件变更+19-25
@@ -35,12 +35,12 @@ torch_npu.npu.stress_detect(detect_type="aic")
35 - `2`: Online precision detection failed due to a hardware fault.35 - `2`: Online precision detection failed due to a hardware fault.
36 36 
37- The following error indicates a voltage recovery failure, which requires manual voltage restoration (by referring to section "Comprehensive Check" in CANN Troubleshooting) or a system reboot.37- The following error indicates a voltage recovery failure, which requires manual voltage restoration (by referring to section "Comprehensive Check" in CANN Troubleshooting) or a system reboot.
38-<!-- in [CANN Troubleshooting](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/latest/maintenref/troubleshooting/troubleshooting_0505.html)) or a system reboot. -->
39 38 
40 ```shell39 ```shell
41 Stress detect error. Error code is 574007. Error message is Voltage recovery failed.40 Stress detect error. Error code is 574007. Error message is Voltage recovery failed.
42 ```41 ```
43- 42+
43+<!-- in [CANN Troubleshooting](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/latest/maintenref/troubleshooting/troubleshooting_0505.html)) or a system reboot. -->
44## Constraints44## Constraints
45 45 
46- Online precision detection requires modifying the model training script. You are advised to call this API before training starts, after training ends, or between two steps. Reserve 10 GB of memory for the stress test interface.46- Online precision detection requires modifying the model training script. You are advised to call this API before training starts, after training ends, or between two steps. Reserve 10 GB of memory for the stress test interface.
@@ -133,7 +133,7 @@ torch_npu.npu_alltoallv_quant_gmm(gmm_x, gmm_weight, gmm_x_scale, gmm_weight_sca
133 - When the conditions for resetting the values are met, if `gmm_x_scale`, `mm_x_scale`, and `mm_weight_scale` are all 3D tensors, `gmm_weight_scale` is a 4D tensor, and all data types are `float8_e8m0fnu`, the inferred combination of `[groupSizeM, groupSizeN, groupSizeK]` is `[1, 1, 32]`.133 - When the conditions for resetting the values are met, if `gmm_x_scale`, `mm_x_scale`, and `mm_weight_scale` are all 3D tensors, `gmm_weight_scale` is a 4D tensor, and all data types are `float8_e8m0fnu`, the inferred combination of `[groupSizeM, groupSizeN, groupSizeK]` is `[1, 1, 32]`.
134- When all output tensors (`gmm_y`, `mm_y`, and `permute_out`) on a device are empty tensors, `torch.distributed.barrier()` must be called explicitly to ensure that the process on that device synchronizes and waits for other devices to complete communication and computation. If synchronization is not added, `AlltoAllv` communication will be blocked due to process desynchronization.134- When all output tensors (`gmm_y`, `mm_y`, and `permute_out`) on a device are empty tensors, `torch.distributed.barrier()` must be called explicitly to ensure that the process on that device synchronizes and waits for other devices to complete communication and computation. If synchronization is not added, `AlltoAllv` communication will be blocked due to process desynchronization.
135 135 
136-- - Detailed input and output data type constraints for each quantization mode are provided in the following tables.136+- Detailed input and output data type constraints for each quantization mode are provided in the following tables.
137 137 
138 **Table 1** Data type constraints for T-T quantization138 **Table 1** Data type constraints for T-T quantization
139 139 
@@ -70,7 +70,7 @@
70 70 
71 $C_{i,act}, gate_{i} = split(C_{i})$71 $C_{i,act}, gate_{i} = split(C_{i})$
72 72 
73- $S_{i}=Swish(C_{i,act})\odot gate_{i}$,其中$Swish(x)=\frac{x}{1+e^{-x}}$73+ $S_{i}=Swish(C_{i,act})\odot gate_{i}$, where $Swish(x)=\frac{x}{1+e^{-x}}$
74 4. Quantize the output results.74 4. Quantize the output results.
75 75 
76 $Q\_scale_{i} = \frac{max(|S_{i}|)}{127}$76 $Q\_scale_{i} = \frac{max(|S_{i}|)}{127}$
@@ -123,7 +123,7 @@
123 123 
124 $C_{i,act}, gate_{i} = split(C_{i})$124 $C_{i,act}, gate_{i} = split(C_{i})$
125 125 
126- $S_{i}=Swish(C_{i,act})\odot gate_{i}$,其中$Swish(x)=\frac{x}{1+e^{-x}}$126+ $S_{i}=Swish(C_{i,act})\odot gate_{i}$, where $Swish(x)=\frac{x}{1+e^{-x}}$
127 127 
128 2. Quantize the output:128 2. Quantize the output:
129 129 
@@ -761,7 +761,7 @@ torch_npu.npu_mla_prolog_v2(token_x, weight_dq, weight_uq_qr, weight_uk, weight_
761 import torch_npu761 import torch_npu
762 import math762 import math
763 torch.npu.config.allow_internal_format = True763 torch.npu.config.allow_internal_format = True
764- # 生成随机数据, 并发送到npu764+ # Generate random data and send it to the NPU
765 B = 8765 B = 8
766 He = 7168766 He = 7168
767 Hcq = 1536767 Hcq = 1536
@@ -53,7 +53,6 @@ No value is returned.
53 53 
541. The Ascend PyTorch Profiler is used to collect performance data. This includes information about PyTorch layer operators, CANN layer operators, underlying NPU operators, and operator memory footprints.541. The Ascend PyTorch Profiler is used to collect performance data. This includes information about PyTorch layer operators, CANN layer operators, underlying NPU operators, and operator memory footprints.
55 > **Note**: Ascend PyTorch Profiler is a performance analysis tool developed by CANN for the PyTorch framework. You can add an Ascend PyTorch Profiler interface (`torch_npu.profiler.profile` is recommended) to your PyTorch script to collect specified metrics. During model execution, performance data is collected synchronously. For details about its usage and the resulting files, see Ascend PyTorch Profiler.55 > **Note**: Ascend PyTorch Profiler is a performance analysis tool developed by CANN for the PyTorch framework. You can add an Ascend PyTorch Profiler interface (`torch_npu.profiler.profile` is recommended) to your PyTorch script to collect specified metrics. During model execution, performance data is collected synchronously. For details about its usage and the resulting files, see Ascend PyTorch Profiler.
56- see <a href="https://www.hiascend.com/document/detail/en/mindstudio/latest/TITools/ascend_pytorch_profiler/docs/en/ascend_pytorch_profiler/ascend_pytorch_profiler_user_guide.md">Ascend PyTorch Profiler</a>
57 56 
58 ```python57 ```python
59 >>> import torch58 >>> import torch
@@ -108,3 +107,4 @@ No value is returned.
108 107 
109 For single-operator core control, you can check the `kernel_details.csv` file and check the **BlockDim** column (the number of cores used for operator computation). If the `BlockDim` value is less than or equal to the core limit configured by the user, the core control is successful.108 For single-operator core control, you can check the `kernel_details.csv` file and check the **BlockDim** column (the number of cores used for operator computation). If the `BlockDim` value is less than or equal to the core limit configured by the user, the core control is successful.
110 In this example, the `BlockDim` values of the SwiGlu operator are `22` and `23`, which comply with the core control logic.109 In this example, the `BlockDim` values of the SwiGlu operator are `22` and `23`, which comply with the core control logic.
110+ <!-- see <a href="https://www.hiascend.com/document/detail/en/mindstudio/latest/TITools/ascend_pytorch_profiler/docs/en/ascend_pytorch_profiler/ascend_pytorch_profiler_user_guide.md">Ascend PyTorch Profiler</a> -->
@@ -11,9 +11,9 @@ This document describes the complete adaptation development workflow for calling
11Before getting started, ensure that you have completed the installation of the following environments:11Before getting started, ensure that you have completed the installation of the following environments:
12 12 
131. Install the NPU driver, firmware, and CANN software (Toolkit, ops, and NNAL) by referring to CANN Software Installation.131. Install the NPU driver, firmware, and CANN software (Toolkit, ops, and NNAL) by referring to CANN Software Installation.
14-<!-- [CANN Software Installation](https://www.hiascend.com/document/detail/en/CANNCommunityStructureEdition/910/softwareinst/instg/instg_0000.html?OS=openEuler&InstallType=netyum). -->
15 14 
162. Install the PyTorch framework by referring to [Software Installation](https://gitcode.com/Ascend/pytorch/blob/v2.7.1-26.1.0/docs/en/installation_guide/installation_description.md).152. Install the PyTorch framework by referring to [Software Installation](https://gitcode.com/Ascend/pytorch/blob/v2.7.1-26.1.0/docs/en/installation_guide/installation_description.md).
16+<!-- [CANN Software Installation](https://www.hiascend.com/document/detail/en/CANNCommunityStructureEdition/910/softwareinst/instg/instg_0000.html?OS=openEuler&InstallType=netyum). -->
17 17 
18### Adaptation File Structure18### Adaptation File Structure
19 19 
@@ -190,7 +190,6 @@ The following steps use the `Add` operator as an example.
190After completing the operator adaptation development, you can call the custom operator through C++ extensions.190After completing the operator adaptation development, you can call the custom operator through C++ extensions.
191 191 
1921. Complete the creation, development, compilation, and deployment workflow for the custom operator project. For details, see CANN Ascend C Operator Development.1921. Complete the creation, development, compilation, and deployment workflow for the custom operator project. For details, see CANN Ascend C Operator Development.
193-<!-- see [CANN Ascend C Operator Development](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/latest/programug/Ascendcopdevg/atlas_ascendc_map_10_0002.html) -->
194 193 
1952. Download the code sample.1942. Download the code sample.
196 195 
@@ -215,7 +214,7 @@ After completing the operator adaptation development, you can call the custom op
215 Ran xx tests in xx s214 Ran xx tests in xx s
216 OK215 OK
217 ```216 ```
218- 217+<!-- see [CANN Ascend C Operator Development](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/latest/programug/Ascendcopdevg/atlas_ascendc_map_10_0002.html) -->
219## Reference218## Reference
220 219 
221### `Add` Operator220### `Add` Operator
@@ -11,10 +11,9 @@ This document describes the complete adaptation development workflow for calling
11Before getting started, ensure that you have completed the installation of the following environments:11Before getting started, ensure that you have completed the installation of the following environments:
12 12 
131. Install the NPU driver, firmware, and CANN software (Toolkit, ops, and NNAL) by referring to CANN Software Installation.131. Install the NPU driver, firmware, and CANN software (Toolkit, ops, and NNAL) by referring to CANN Software Installation.
14-<!-- [CANN Software Installation](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/910/softwareinst/instg/instg_0000.html?OS=openEuler&InstallType=netyum) -->
15 14 
162. Install the PyTorch framework by referring to [Installation Guide](https://gitcode.com/Ascend/pytorch/blob/v2.7.1-26.1.0/docs/en/installation_guide/installation_description.md).152. Install the PyTorch framework by referring to [Installation Guide](https://gitcode.com/Ascend/pytorch/blob/v2.7.1-26.1.0/docs/en/installation_guide/installation_description.md).
17- 16+<!-- [CANN Software Installation](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/910/softwareinst/instg/instg_0000.html?OS=openEuler&InstallType=netyum) -->
18### Adaptation File Structure17### Adaptation File Structure
19 18 
20```text19```text
@@ -93,7 +92,6 @@ Before getting started, ensure that you have completed the installation of the f
93After completing the operator adaptation development, you can call the custom operator through C++ extensions.92After completing the operator adaptation development, you can call the custom operator through C++ extensions.
94 93 
951. Complete the creation, development, compilation, and deployment workflow for the custom operator project. For details, see CANN Ascend C Operator Development.941. Complete the creation, development, compilation, and deployment workflow for the custom operator project. For details, see CANN Ascend C Operator Development.
96-<!-- [CANN Ascend C Operator Development](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/latest/programug/Ascendcopdevg/atlas_ascendc_map_10_0002.html) -->
97 95 
982. Download the code sample.962. Download the code sample.
99 97 
@@ -118,3 +116,4 @@ After completing the operator adaptation development, you can call the custom op
118 Ran xx tests in xx s116 Ran xx tests in xx s
119 OK117 OK
120 ```118 ```
119+<!-- [CANN Ascend C Operator Development](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/latest/programug/Ascendcopdevg/atlas_ascendc_map_10_0002.html) -->
@@ -11,10 +11,9 @@ This document describes how to adapt and call a single-operator API through Torc
11Before getting started, ensure that you have completed the installation of the following environments:11Before getting started, ensure that you have completed the installation of the following environments:
12 12 
131. Install the NPU driver, firmware, and CANN software (Toolkit, ops, and NNAL) by referring to CANN Software Installation.131. Install the NPU driver, firmware, and CANN software (Toolkit, ops, and NNAL) by referring to CANN Software Installation.
14-<!-- [CANN Software Installation](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/910/softwareinst/instg/instg_0000.html?OS=openEuler&InstallType=netyum) -->
15 14 
162. Install the PyTorch framework by referring to [Software Installation](https://gitcode.com/Ascend/pytorch/blob/v2.7.1-26.1.0/docs/en/installation_guide/installation_description.md).152. Install the PyTorch framework by referring to [Software Installation](https://gitcode.com/Ascend/pytorch/blob/v2.7.1-26.1.0/docs/en/installation_guide/installation_description.md).
17- 16+<!-- [CANN Software Installation](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/910/softwareinst/instg/instg_0000.html?OS=openEuler&InstallType=netyum) -->
18### Adaptation File Structure17### Adaptation File Structure
19 18 
20```text19```text
@@ -143,7 +142,6 @@ Before getting started, ensure that you have completed the installation of the f
143After completing the operator adaptation development, you can call the custom operator through C++ extensions.142After completing the operator adaptation development, you can call the custom operator through C++ extensions.
144 143 
1451. Complete the creation, development, compilation, and deployment workflow for the custom operator project. For details, see CANN Ascend C Operator Development.1441. Complete the creation, development, compilation, and deployment workflow for the custom operator project. For details, see CANN Ascend C Operator Development.
146-<!-- [CANN Ascend C Operator Development](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/latest/programug/Ascendcopdevg/atlas_ascendc_map_10_0002.html) -->
147 145 
1482. Download the code sample.1462. Download the code sample.
149 147 
@@ -168,3 +166,4 @@ After completing the operator adaptation development, you can call the custom op
168 Ran xx tests in xx s166 Ran xx tests in xx s
169 OK167 OK
170 ```168 ```
169+<!-- [CANN Ascend C Operator Development](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/latest/programug/Ascendcopdevg/atlas_ascendc_map_10_0002.html) -->
@@ -11,10 +11,9 @@ This document describes how to adapt and call a single-operator API through Torc
11Before getting started, ensure that you have completed the installation of the following environments:11Before getting started, ensure that you have completed the installation of the following environments:
12 12 
131. Install the NPU driver, firmware, and CANN software (Toolkit, ops, and NNAL) by referring to CANN Software Installation.131. Install the NPU driver, firmware, and CANN software (Toolkit, ops, and NNAL) by referring to CANN Software Installation.
14-<!-- [CANN Software Installation](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/910/softwareinst/instg/instg_0000.html?OS=openEuler&InstallType=netyum) -->
15 14 
162. Install the PyTorch framework by referring to [Software Installation](https://gitcode.com/Ascend/pytorch/blob/v2.7.1-26.1.0/docs/en/installation_guide/installation_description.md).152. Install the PyTorch framework by referring to [Software Installation](https://gitcode.com/Ascend/pytorch/blob/v2.7.1-26.1.0/docs/en/installation_guide/installation_description.md).
17- 16+<!-- [CANN Software Installation](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/910/softwareinst/instg/instg_0000.html?OS=openEuler&InstallType=netyum) -->
18### Adaptation File Structure17### Adaptation File Structure
19 18 
20```text19```text
@@ -138,7 +137,6 @@ Before getting started, ensure that you have completed the installation of the f
138After completing the operator adaptation development, you can call the custom operator through C++ extensions.137After completing the operator adaptation development, you can call the custom operator through C++ extensions.
139 138 
1401. Complete the creation, development, compilation, and deployment workflow for the custom operator project. For details, see CANN Ascend C Operator Development.1391. Complete the creation, development, compilation, and deployment workflow for the custom operator project. For details, see CANN Ascend C Operator Development.
141-<!-- [CANN Ascend C Operator Development](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/latest/programug/Ascendcopdevg/atlas_ascendc_map_10_0002.html) -->
142 140 
1432. Download the code sample.1412. Download the code sample.
144 142 
@@ -163,3 +161,4 @@ After completing the operator adaptation development, you can call the custom op
163 Ran xx tests in xx s161 Ran xx tests in xx s
164 OK162 OK
165 ```163 ```
164+<!-- [CANN Ascend C Operator Development](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/latest/programug/Ascendcopdevg/atlas_ascendc_map_10_0002.html) -->
@@ -11,10 +11,9 @@ This document describes the complete adaptation development workflow for calling
11Before getting started, ensure that you have completed the installation of the following environments:11Before getting started, ensure that you have completed the installation of the following environments:
12 12 
131. Install the NPU driver, firmware, and CANN software (Toolkit, ops, and NNAL) by referring to CANN Software Installation.131. Install the NPU driver, firmware, and CANN software (Toolkit, ops, and NNAL) by referring to CANN Software Installation.
14-<!-- [CANN Software Installation](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/910/softwareinst/instg/instg_0000.html?OS=openEuler&InstallType=netyum) -->
15 14 
162. Install the PyTorch framework by referring to [Installation Guide](https://gitcode.com/Ascend/pytorch/blob/v2.7.1-26.1.0/docs/en/installation_guide/installation_description.md).152. Install the PyTorch framework by referring to [Installation Guide](https://gitcode.com/Ascend/pytorch/blob/v2.7.1-26.1.0/docs/en/installation_guide/installation_description.md).
17- 16+<!-- [CANN Software Installation](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/910/softwareinst/instg/instg_0000.html?OS=openEuler&InstallType=netyum) -->
18### Adaptation File Structure17### Adaptation File Structure
19 18 
20```text19```text
@@ -76,7 +75,6 @@ Before getting started, ensure that you have completed the installation of the f
76After completing the operator adaptation development, you can call the custom operator through C++ extensions.75After completing the operator adaptation development, you can call the custom operator through C++ extensions.
77 76 
781. Complete the creation, development, compilation, and deployment workflow for the custom operator project. For details, see CANN Ascend C Operator Development.771. Complete the creation, development, compilation, and deployment workflow for the custom operator project. For details, see CANN Ascend C Operator Development.
79-<!-- [CANN Ascend C Operator Development](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/latest/programug/Ascendcopdevg/atlas_ascendc_map_10_0002.html) -->
80 78 
812. Download the code sample.792. Download the code sample.
82 80 
@@ -101,3 +99,4 @@ After completing the operator adaptation development, you can call the custom op
101 Ran xx tests in xx s99 Ran xx tests in xx s
102 OK100 OK
103 ```101 ```
102+<!-- [CANN Ascend C Operator Development](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/latest/programug/Ascendcopdevg/atlas_ascendc_map_10_0002.html) -->
@@ -11,10 +11,9 @@ This document describes the complete process of custom NPU operator adaptation d
11Before getting started, ensure that you have completed the installation of the following environments:11Before getting started, ensure that you have completed the installation of the following environments:
12 12 
131. Install the NPU driver, firmware, and CANN software (Toolkit, ops, and NNAL) by referring to CANN Software Installation.131. Install the NPU driver, firmware, and CANN software (Toolkit, ops, and NNAL) by referring to CANN Software Installation.
14-<!-- [CANN Software Installation](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/910/softwareinst/instg/instg_0000.html?OS=openEuler&InstallType=netyum) -->
15 14 
162. Install the PyTorch framework by referring to [Installation Guide](https://gitcode.com/Ascend/pytorch/tree/v2.7.1-26.1.0/docs/en/installation_guide/installation_description.md).152. Install the PyTorch framework by referring to [Installation Guide](https://gitcode.com/Ascend/pytorch/tree/v2.7.1-26.1.0/docs/en/installation_guide/installation_description.md).
17- 16+<!-- [CANN Software Installation](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/910/softwareinst/instg/instg_0000.html?OS=openEuler&InstallType=netyum) -->
18### Adaptation File Structure17### Adaptation File Structure
19 18 
20```text19```text
@@ -88,7 +87,6 @@ cpp_extension_structured/
88After completing the operator adaptation development, you can call the custom operator through C++ extensions.87After completing the operator adaptation development, you can call the custom operator through C++ extensions.
89 88 
901. Complete the creation, development, compilation, and deployment workflow for the custom operator project. For details, see CANN Ascend C Operator Development.891. Complete the creation, development, compilation, and deployment workflow for the custom operator project. For details, see CANN Ascend C Operator Development.
91-<!-- [CANN Ascend C Operator Development](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/latest/programug/Ascendcopdevg/atlas_ascendc_map_10_0002.html) -->
92 90 
932. Download the code sample.912. Download the code sample.
94 92 
@@ -113,3 +111,4 @@ After completing the operator adaptation development, you can call the custom op
113 Ran xx tests in xx s111 Ran xx tests in xx s
114 OK112 OK
115 ```113 ```
114+<!-- [CANN Ascend C Operator Development](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/latest/programug/Ascendcopdevg/atlas_ascendc_map_10_0002.html) -->