Merged
modify document:修改950芯片名称及AIDD扫描低错 #7704
modify document:修改950芯片名称及AIDD扫描低错 #7704
Merged
chic666Add on Sep 16
Total: 18 files changed+49-47
@@ -124,7 +124,7 @@ if __name__ == "__main__":
124 124 
125For end-to-end examples of more scenarios and launch methods, refer to the[training demo](https://gitcode.com/ascend/ModelZoo-PyTorch/tree/master/PyTorch/built-in/docs/dist_train_demo).125For end-to-end examples of more scenarios and launch methods, refer to the[training demo](https://gitcode.com/ascend/ModelZoo-PyTorch/tree/master/PyTorch/built-in/docs/dist_train_demo).
126 126 
127-## Single-node Eight-device Training (Shell Script)<a id="suctom-anchor01"></a>127+## Single-node Eight-device Training (Shell Script)<a id="custom-anchor01"></a>
128 128 
1291. Modify the model script. `train_8p_shell.py` is used as an example.1291. Modify the model script. `train_8p_shell.py` is used as an example.
130 1. Modify the `train()` function.130 1. Modify the `train()` function.
@@ -208,7 +208,7 @@ For end-to-end examples of more scenarios and launch methods, refer to the[train
208 bash start_train_8p.sh # Modify according to the actual name208 bash start_train_8p.sh # Modify according to the actual name
209 ```209 ```
210 210 
211-## Single-node Eight-device Training (mp.spawn)<a id="suctom-anchor02"></a>211+## Single-node Eight-device Training (mp.spawn)<a id="custom-anchor02"></a>
212 212 
2131. Modify the model script. `train_8p_spawn.py` is used as an example.2131. Modify the model script. `train_8p_spawn.py` is used as an example.
214 1. Import `torch.multiprocessing`.214 1. Import `torch.multiprocessing`.
@@ -269,7 +269,7 @@ For end-to-end examples of more scenarios and launch methods, refer to the[train
269 python train_8p_spawn.py269 python train_8p_spawn.py
270 ```270 ```
271 271 
272-## Single-node Eight-device Training (torch.distributed.launch)<a id="suctom-anchor03"></a>272+## Single-node Eight-device Training (torch.distributed.launch)<a id="custom-anchor03"></a>
273 273 
2741. Modify the model script. `train_8p_torch_distributed_launch.py` is used as an example.2741. Modify the model script. `train_8p_torch_distributed_launch.py` is used as an example.
275 1. Modify the `get_train_args()` function.275 1. Modify the `get_train_args()` function.
@@ -298,7 +298,7 @@ For end-to-end examples of more scenarios and launch methods, refer to the[train
298 python -m torch.distributed.launch --nproc_per_node 8 --master_addr localhost --master_port 12345 train_8p_torch_distributed_launch.py298 python -m torch.distributed.launch --nproc_per_node 8 --master_addr localhost --master_port 12345 train_8p_torch_distributed_launch.py
299 ```299 ```
300 300 
301-## Single-node Eight-device Training (torchrun)<a id="suctom-anchor04"></a>301+## Single-node Eight-device Training (torchrun)<a id="custom-anchor04"></a>
302 302 
3031. The [model script](#custom-anchor) does not need to be modified.`train_8p_torchrun.py` is used as an example.3031. The [model script](#custom-anchor) does not need to be modified.`train_8p_torchrun.py` is used as an example.
3042. Run the training script.3042. Run the training script.
@@ -307,7 +307,7 @@ For end-to-end examples of more scenarios and launch methods, refer to the[train
307 torchrun --nproc_per_node 8 --master_addr localhost --master_port 12345 train_8p_torchrun.py307 torchrun --nproc_per_node 8 --master_addr localhost --master_port 12345 train_8p_torchrun.py
308 ```308 ```
309 309 
310-## Single-node Eight-device Training (torch_npu_run)<a id="suctom-anchor05"></a>310+## Single-node Eight-device Training (torch_npu_run)<a id="custom-anchor05"></a>
311 311 
3121. Modify the model script. `train_8p_torch_npu_run.py` is used as an example.3121. Modify the model script. `train_8p_torch_npu_run.py` is used as an example.
313 1. Modify the `get_train_args()` function.313 1. Modify the `get_train_args()` function.
@@ -337,7 +337,7 @@ For end-to-end examples of more scenarios and launch methods, refer to the[train
337 torch_npu_run --rdzv_backend parallel --master_addr xxxx --master_port 12345 --nproc_per_node 8 train_8p_torch_npu_run.py # Replace xxxx with the local IP address337 torch_npu_run --rdzv_backend parallel --master_addr xxxx --master_port 12345 --nproc_per_node 8 train_8p_torch_npu_run.py # Replace xxxx with the local IP address
338 ```338 ```
339 339 
340-## Dual-node 16-Device Training (Shell Script)<a id="suctom-anchor06"></a>340+## Dual-node 16-Device Training (Shell Script)<a id="custom-anchor06"></a>
341 341 
3421. Modify the model script. `train_16p_shell.py` is used as an example.3421. Modify the model script. `train_16p_shell.py` is used as an example.
343 1. Modify the `train()` function.343 1. Modify the `train()` function.
@@ -421,7 +421,7 @@ For end-to-end examples of more scenarios and launch methods, refer to the[train
421 bash start_train_16p_slave_node.sh # Modify based on the actual name421 bash start_train_16p_slave_node.sh # Modify based on the actual name
422 ```422 ```
423 423 
424-## Dual-node 16-device Training (mp.spawn)<a id="suctom-anchor07"></a>424+## Dual-node 16-device Training (mp.spawn)<a id="custom-anchor07"></a>
425 425 
4261. Modify the model script. `train_16p_spawn.py` is used as an example.4261. Modify the model script. `train_16p_spawn.py` is used as an example.
427 1. Import `torch.multiprocessing`.427 1. Import `torch.multiprocessing`.
@@ -518,7 +518,7 @@ For end-to-end examples of more scenarios and launch methods, refer to the[train
518 python train_16p_spawn.py --nnodes 2 --node_rank 1518 python train_16p_spawn.py --nnodes 2 --node_rank 1
519 ```519 ```
520 520 
521-## Dual-node 16-device Training (torch.distributed.launch)<a id="suctom-anchor08"></a>521+## Dual-node 16-device Training (torch.distributed.launch)<a id="custom-anchor08"></a>
522 522 
5231. Modify the model script. `train_16p_python.py` is used as an example.5231. Modify the model script. `train_16p_python.py` is used as an example.
524 1. Modify the `get_train_args()` function.524 1. Modify the `get_train_args()` function.
@@ -577,7 +577,7 @@ For end-to-end examples of more scenarios and launch methods, refer to the[train
577 python -m torch.distributed.launch --nnodes 2 --nproc_per_node 8 --node_rank 1 --master_addr xxxx --master_port 12345 train_16p_python.py577 python -m torch.distributed.launch --nnodes 2 --nproc_per_node 8 --node_rank 1 --master_addr xxxx --master_port 12345 train_16p_python.py
578 ```578 ```
579 579 
580-## Dual-node 16-device Training (torchrun)<a id="suctom-anchor09"></a>580+## Dual-node 16-device Training (torchrun)<a id="custom-anchor09"></a>
581 581 
5821. Modify the model script. `train_16p_torchrun.py` is used as an example.5821. Modify the model script. `train_16p_torchrun.py` is used as an example.
583 1. Modify the `train()` function.583 1. Modify the `train()` function.
@@ -616,7 +616,7 @@ For end-to-end examples of more scenarios and launch methods, refer to the[train
616 torchrun --nnodes 2 --nproc_per_node 8 --node_rank 1 --master_addr xxxx --master_port 12345 train_16p_torchrun.py616 torchrun --nnodes 2 --nproc_per_node 8 --node_rank 1 --master_addr xxxx --master_port 12345 train_16p_torchrun.py
617 ```617 ```
618 618 
619-## Dual-node 16-device Training (torch_npu_run)<a id="suctom-anchor11"></a>619+## Dual-node 16-device Training (torch_npu_run)<a id="custom-anchor11"></a>
620 620 
6211. Modify the model script. `train_16p_torch_npu_run.py` is used as an example.6211. Modify the model script. `train_16p_torch_npu_run.py` is used as an example.
622 1. Modify the `get_train_args()` function.622 1. Modify the `get_train_args()` function.
@@ -6,7 +6,7 @@
6 6 
7|Product|Supported|7|Product|Supported|
8|--|:-:|8|--|:-:|
9-|<term>Ascend 950 products</term>|√|9+|<term>Ascend 950PR&950DT products</term>|√|
10|<term>Atlas A3 training products</term>|√|10|<term>Atlas A3 training products</term>|√|
11|<term>Atlas A3 inference products</term>|x|11|<term>Atlas A3 inference products</term>|x|
12|<term>Atlas A2 training products</term>|√|12|<term>Atlas A2 training products</term>|√|
@@ -14,7 +14,7 @@ It is recommended to use the built-in AMP module of the PyTorch framework for mi
14The constraints on mixed precision adaptation are as follows:14The constraints on mixed precision adaptation are as follows:
15 15 
16- Mixed precision adaptation should be performed after script migration is complete and before training starts.16- Mixed precision adaptation should be performed after script migration is complete and before training starts.
17-- If you use <term>Atlas A2 training products</term>/<term>Atlas A3 training products</term>/<term>Ascend 950 products</term>, enable mixed precision as needed.17+- Developers can choose whether to enable mixed precision.
18- Enabling mixed precision may improve performance, but it does not take effect for all models. If performance does not improve, further performance tuning modifications are required.18- Enabling mixed precision may improve performance, but it does not take effect for all models. If performance does not improve, further performance tuning modifications are required.
19- After enabling mixed precision training, changes in the numerical representation range and minimum spacing may cause a very small number of networks to experience precision degradation or even failure to converge. Refer to [Mixed Precision Issue Debugging](mixed_prec_debug.md) for resolution.19- After enabling mixed precision training, changes in the numerical representation range and minimum spacing may cause a very small number of networks to experience precision degradation or even failure to converge. Refer to [Mixed Precision Issue Debugging](mixed_prec_debug.md) for resolution.
20 20 
@@ -16,7 +16,7 @@ In the above example, improper mixed precision configuration may cause gradient
16 16 
17## Tuning Approach17## Tuning Approach
18 18 
19-The following provides several solutions for precision tuning. If you encounter the preceding issue on <term>Atlas A2 training products</term>/<term>Atlas A3 training products</term>, you can fall back to full-precision computation to avoid this issue.19+The following provides several solutions for precision tuning. If you encounter the preceding issue, you can fall back to full-precision computation to avoid this issue.
20 20 
211. Modify the mixed precision level.211. Modify the mixed precision level.
22 22 
@@ -17,7 +17,7 @@
17超参数对模型训练收敛有关键性影响,这里说的超参数主要包括:**优化器选择、学习率设定、梯度裁剪阈值、Loss scale**等。17超参数对模型训练收敛有关键性影响,这里说的超参数主要包括:**优化器选择、学习率设定、梯度裁剪阈值、Loss scale**等。
18 18 
19- **优化器与学习率**:优化器的选择直接影响到模型训练过程中的更新策略,而学习率作为核心超参数之一,若设置不当,可能导致训练过程中出现诸如全局梯度范数(GNorm)突变、Loss曲线无法收敛、上升甚至剧烈波动等问题。因此,在训练大型模型时,需细致地搜索合适的学习率以保证收敛性能。19- **优化器与学习率**:优化器的选择直接影响到模型训练过程中的更新策略,而学习率作为核心超参数之一,若设置不当,可能导致训练过程中出现诸如全局梯度范数(GNorm)突变、Loss曲线无法收敛、上升甚至剧烈波动等问题。因此,在训练大型模型时,需细致地搜索合适的学习率以保证收敛性能。
20-- **梯度裁剪阈值**:梯度裁剪对模型训练稳定性也至关重要,使用过高的梯度裁剪阈值可能会导致GNorm如图1中蓝线那样持续保持在高位。梯度裁剪在反向传播完成后能够降低某些张量的梯度值,这样可以阻止梯度爆炸,并使训练过程更加稳定。裁剪范围值可以通过试验配置,也可以使用文献中的常用值,也可以通过实验观察范围然后选择一个合理值。网络中的所有层通常都使用相同的梯度裁剪配置,一般来说输出层相比隐藏层允许更大范围的梯度。20+- **梯度裁剪阈值**:梯度裁剪对模型训练稳定性也至关重要,使用过高的梯度裁剪阈值可能会导致GNorm如图1中蓝线那样持续保持在高位。梯度裁剪在反向传播完成后能够降低某些张量的梯度值,这样可以阻止梯度爆炸,并使训练过程更加稳定。裁剪范围值可以通过实验配置,也可以使用文献中的常用值,也可以通过实验观察范围然后选择一个合理值。网络中的所有层通常都使用相同的梯度裁剪配置,一般来说输出层相比隐藏层允许更大范围的梯度。
21 21 
22 **图 1** 过高的梯度裁剪阈值 22 **图 1** 过高的梯度裁剪阈值
23 23
@@ -124,7 +124,7 @@ if __name__ == "__main__":
124 124 
125更多场景和拉起方式的端到端示例可参考[LINK](https://gitcode.com/ascend/ModelZoo-PyTorch/tree/master/PyTorch/built-in/docs/dist_train_demo)。125更多场景和拉起方式的端到端示例可参考[LINK](https://gitcode.com/ascend/ModelZoo-PyTorch/tree/master/PyTorch/built-in/docs/dist_train_demo)。
126 126 
127-## 拉起单机八卡训练(shell脚本方式)<a id="suctom-anchor01"></a>127+## 拉起单机八卡训练(shell脚本方式)<a id="custom-anchor01"></a>
128 128 
1291. 修改模型脚本,脚本名称为`train_8p_shell.py`,`train_8p_shell.py`仅为示例。1291. 修改模型脚本,脚本名称为`train_8p_shell.py`,`train_8p_shell.py`仅为示例。
130 1. 修改train\(\)函数。130 1. 修改train\(\)函数。
@@ -208,7 +208,7 @@ if __name__ == "__main__":
208 bash start_train_8p.sh # 根据实际命名进行修改208 bash start_train_8p.sh # 根据实际命名进行修改
209 ```209 ```
210 210 
211-## 拉起单机八卡训练(mp.spawn方式)<a id="suctom-anchor02"></a>211+## 拉起单机八卡训练(mp.spawn方式)<a id="custom-anchor02"></a>
212 212 
2131. 修改模型脚本,脚本名称为`train_8p_spawn.py`,`train_8p_spawn.py`仅为示例。2131. 修改模型脚本,脚本名称为`train_8p_spawn.py`,`train_8p_spawn.py`仅为示例。
214 1. 导入torch.multiprocessing。214 1. 导入torch.multiprocessing。
@@ -269,7 +269,7 @@ if __name__ == "__main__":
269 python train_8p_spawn.py269 python train_8p_spawn.py
270 ```270 ```
271 271 
272-## 拉起单机八卡训练(torch.distributed.launch方式)<a id="suctom-anchor03"></a>272+## 拉起单机八卡训练(torch.distributed.launch方式)<a id="custom-anchor03"></a>
273 273 
2741. 修改模型脚本,脚本名称为`train_8p_torch_distributed_launch.py`,`train_8p_torch_distributed_launch.py`仅为示例。2741. 修改模型脚本,脚本名称为`train_8p_torch_distributed_launch.py`,`train_8p_torch_distributed_launch.py`仅为示例。
275 1. 修改get\_train\_args\(\)函数。275 1. 修改get\_train\_args\(\)函数。
@@ -298,7 +298,7 @@ if __name__ == "__main__":
298 python -m torch.distributed.launch --nproc_per_node 8 --master_addr localhost --master_port 12345 train_8p_torch_distributed_launch.py298 python -m torch.distributed.launch --nproc_per_node 8 --master_addr localhost --master_port 12345 train_8p_torch_distributed_launch.py
299 ```299 ```
300 300 
301-## 拉起单机八卡训练(torchrun方式)<a id="suctom-anchor04"></a>301+## 拉起单机八卡训练(torchrun方式)<a id="custom-anchor04"></a>
302 302 
3031. [模型脚本示例](#custom-anchor)以torchrun方式为例,模型脚本无需修改。脚本名称为`train_8p_torchrun.py`,`train_8p_torchrun.py`仅为示例。3031. [模型脚本示例](#custom-anchor)以torchrun方式为例,模型脚本无需修改。脚本名称为`train_8p_torchrun.py`,`train_8p_torchrun.py`仅为示例。
3042. 运行训练脚本。3042. 运行训练脚本。
@@ -307,7 +307,7 @@ if __name__ == "__main__":
307 torchrun --nproc_per_node 8 --master_addr localhost --master_port 12345 train_8p_torchrun.py307 torchrun --nproc_per_node 8 --master_addr localhost --master_port 12345 train_8p_torchrun.py
308 ```308 ```
309 309 
310-## 拉起单机八卡训练(torch\_npu\_run方式)<a id="suctom-anchor05"></a>310+## 拉起单机八卡训练(torch\_npu\_run方式)<a id="custom-anchor05"></a>
311 311 
3121. 修改模型脚本,脚本名称为`train_8p_torch_npu_run.py`,`train_8p_torch_npu_run.py`仅为示例。3121. 修改模型脚本,脚本名称为`train_8p_torch_npu_run.py`,`train_8p_torch_npu_run.py`仅为示例。
313 1. 修改get\_train\_args\(\)函数。313 1. 修改get\_train\_args\(\)函数。
@@ -337,7 +337,7 @@ if __name__ == "__main__":
337 torch_npu_run --rdzv_backend parallel --master_addr xxxx --master_port 12345 --nproc_per_node 8 train_8p_torch_npu_run.py # 将xxxx改为本机IP地址337 torch_npu_run --rdzv_backend parallel --master_addr xxxx --master_port 12345 --nproc_per_node 8 train_8p_torch_npu_run.py # 将xxxx改为本机IP地址
338 ```338 ```
339 339 
340-## 拉起双机16卡训练(shell脚本方式)<a id="suctom-anchor06"></a>340+## 拉起双机16卡训练(shell脚本方式)<a id="custom-anchor06"></a>
341 341 
3421. 修改模型脚本,脚本名称为`train_16p_shell.py`,`train_16p_shell.py`仅为示例。3421. 修改模型脚本,脚本名称为`train_16p_shell.py`,`train_16p_shell.py`仅为示例。
343 1. 修改train\(\)函数。343 1. 修改train\(\)函数。
@@ -421,7 +421,7 @@ if __name__ == "__main__":
421 bash start_train_16p_slave_node.sh # 根据实际命名进行修改421 bash start_train_16p_slave_node.sh # 根据实际命名进行修改
422 ```422 ```
423 423 
424-## 拉起双机16卡训练(mp.spawn方式)<a id="suctom-anchor07"></a>424+## 拉起双机16卡训练(mp.spawn方式)<a id="custom-anchor07"></a>
425 425 
4261. 修改模型脚本,脚本名称为`train_16p_spawn.py`,`train_16p_spawn.py`仅为示例。4261. 修改模型脚本,脚本名称为`train_16p_spawn.py`,`train_16p_spawn.py`仅为示例。
427 1. 导入torch.multiprocessing。427 1. 导入torch.multiprocessing。
@@ -518,7 +518,7 @@ if __name__ == "__main__":
518 python train_16p_spawn.py --nnodes 2 --node_rank 1518 python train_16p_spawn.py --nnodes 2 --node_rank 1
519 ```519 ```
520 520 
521-## 拉起双机16卡训练(torch.distributed.launch方式)<a id="suctom-anchor08"></a>521+## 拉起双机16卡训练(torch.distributed.launch方式)<a id="custom-anchor08"></a>
522 522 
5231. 修改模型脚本,脚本名称为`train_16p_python.py`,`train_16p_python.py`仅为示例。5231. 修改模型脚本,脚本名称为`train_16p_python.py`,`train_16p_python.py`仅为示例。
524 1. 修改get\_train\_args\(\)函数。524 1. 修改get\_train\_args\(\)函数。
@@ -577,7 +577,7 @@ if __name__ == "__main__":
577 python -m torch.distributed.launch --nnodes 2 --nproc_per_node 8 --node_rank 1 --master_addr xxxx --master_port 12345 train_16p_python.py577 python -m torch.distributed.launch --nnodes 2 --nproc_per_node 8 --node_rank 1 --master_addr xxxx --master_port 12345 train_16p_python.py
578 ```578 ```
579 579 
580-## 拉起双机16卡训练(torchrun方式)<a id="suctom-anchor09"></a>580+## 拉起双机16卡训练(torchrun方式)<a id="custom-anchor09"></a>
581 581 
5821. 修改模型脚本,脚本名称为`train_16p_torchrun.py`,`train_16p_torchrun.py`仅为示例。5821. 修改模型脚本,脚本名称为`train_16p_torchrun.py`,`train_16p_torchrun.py`仅为示例。
583 1. 修改train\(\)函数。583 1. 修改train\(\)函数。
@@ -616,7 +616,7 @@ if __name__ == "__main__":
616 torchrun --nnodes 2 --nproc_per_node 8 --node_rank 1 --master_addr xxxx --master_port 12345 train_16p_torchrun.py616 torchrun --nnodes 2 --nproc_per_node 8 --node_rank 1 --master_addr xxxx --master_port 12345 train_16p_torchrun.py
617 ```617 ```
618 618 
619-## 拉起双机16卡训练(torch\_npu\_run方式)<a id="suctom-anchor11"></a>619+## 拉起双机16卡训练(torch\_npu\_run方式)<a id="custom-anchor11"></a>
620 620 
6211. 修改模型脚本,脚本名称为`train_16p_torch_npu_run.py`,`train_16p_torch_npu_run.py`仅为示例。6211. 修改模型脚本,脚本名称为`train_16p_torch_npu_run.py`,`train_16p_torch_npu_run.py`仅为示例。
622 1. 修改get\_train\_args\(\)函数。622 1. 修改get\_train\_args\(\)函数。
@@ -6,12 +6,12 @@
6 6 
7|产品|是否支持|7|产品|是否支持|
8|--|:-:|8|--|:-:|
9-|<term>Ascend 950 系列产品</term>|√|9+|<term>Ascend 950PR&950DT系列产品</term>|√|
10-|<term>Atlas A3 训练系列产品</term>|√|10+|<term>Atlas A3训练系列产品</term>|√|
11-|<term>Atlas A3 推理系列产品</term>|x|11+|<term>Atlas A3推理系列产品</term>|x|
12-|<term>Atlas A2 训练系列产品</term>|√|12+|<term>Atlas A2训练系列产品</term>|√|
13-|<term>Atlas A2 推理系列产品</term>|x|13+|<term>Atlas A2推理系列产品</term>|x|
14-|<term>Atlas 200I/500 A2 推理产品</term>|x|14+|<term>Atlas 200I/500 A2推理产品</term>|x|
15|<term>Atlas 推理系列产品</term>|x|15|<term>Atlas 推理系列产品</term>|x|
16|<term>Atlas 训练系列产品</term>|x|16|<term>Atlas 训练系列产品</term>|x|
17 17 
@@ -14,7 +14,7 @@
14当前混合精度适配约束如下:14当前混合精度适配约束如下:
15 15 
16- 混合精度适配操作应在脚本迁移完成后、训练开始之前。16- 混合精度适配操作应在脚本迁移完成后、训练开始之前。
17-- 若用户使用<term>Atlas A2 训练系列产品</term>/<term>Atlas A3 训练系列产品</term>/<term>Ascend 950 系列产品</term>,则可以自行选择是否开启混合精度。17+- 用户可以自行选择是否开启混合精度。
18- 混合精度开启可能会提升性能,但不针对所有模型生效。如果性能没有提升,则需要做进一步性能调优修改。18- 混合精度开启可能会提升性能,但不针对所有模型生效。如果性能没有提升,则需要做进一步性能调优修改。
19- 在开启混合精度训练后,由于数值表示范围和最小间隔发生变化,可能导致极少部分网络出现精度下降甚至无法收敛的情况,可以参考[混合精度问题调测](mixed_prec_debug.md)进行解决。19- 在开启混合精度训练后,由于数值表示范围和最小间隔发生变化,可能导致极少部分网络出现精度下降甚至无法收敛的情况,可以参考[混合精度问题调测](mixed_prec_debug.md)进行解决。
20 20 
@@ -16,7 +16,9 @@
16 16 
17## 调优思路17## 调优思路
18 18 
19-用户可以参考以下方案进行精度调优尝试。如果用户在<term>Atlas A2 训练系列产品</term>/<term>Atlas A3 训练系列产品</term>遇到此问题,也可以选择回退到全精度计算规避此问题。19+用户可以参考以下方案进行精度调优尝试。
20+ 
21+如果用户遇到此问题,可以选择回退到全精度计算规避此问题。
20 22 
211. 修改混合精度级别。231. 修改混合精度级别。
22 24 
@@ -241,8 +241,8 @@
241>241>
242> - 集合通信存在如下约束:242> - 集合通信存在如下约束:
243> - 数据并行模式中不同device上执行的计算图相同。243> - 数据并行模式中不同device上执行的计算图相同。
244-> - 针对<term>Atlas A2 训练系列产品</term>/<term>Atlas A3 训练系列产品</term>:AllReduce和reduce\_scatter仅支持int8、int32、float16、float32和bfloat16数据类型。244+> - 针对<term>Atlas A2训练系列产品</term>/<term>Atlas A3训练系列产品</term>:AllReduce和reduce\_scatter仅支持int8、int32、float16、float32和bfloat16数据类型。
245-> - 针对<term>Atlas A2 训练系列产品</term>/<term>Atlas A3 训练系列产品</term>,若用户准备进行2卡训练,可将8卡训练脚本进行改写,改为2卡训练脚本。可参见以下修改方法:245+> - 针对<term>Atlas A2训练系列产品</term>/<term>Atlas A3训练系列产品</term>,若用户准备进行2卡训练,可将8卡训练脚本进行改写,改为2卡训练脚本。可参见以下修改方法:
246> 1. 若8卡脚本的batch\_size是单卡脚本的batch\_size的8倍,则将8卡训练时的batch\_size和learning\_rate同时除以4,作为2卡训练时的batch\_size和learning\_rate。246> 1. 若8卡脚本的batch\_size是单卡脚本的batch\_size的8倍,则将8卡训练时的batch\_size和learning\_rate同时除以4,作为2卡训练时的batch\_size和learning\_rate。
247> 2. 将nproc\_per\_node修改为2。247> 2. 将nproc\_per\_node修改为2。
248> - 一个device对应执行一个训练进程,当前不支持多进程在同一个device上进行训练。248> - 一个device对应执行一个训练进程,当前不支持多进程在同一个device上进行训练。
@@ -452,7 +452,7 @@
452 > [!NOTE]452 > [!NOTE]
453 >453 >
454 > 配置device IP需遵守以下规则:454 > 配置device IP需遵守以下规则:
455- > 1. 针对<term>Atlas A2 训练系列产品</term>/<term>Atlas A3 训练系列产品</term>,多台节点的NPU在同一网段即可。455+ > 1. 针对<term>Atlas A2 训练系列产品</term>/<term>Atlas A3训练系列产品</term>,多台节点的NPU在同一网段即可。
456 > 2. 每个IP都不能冲突,相同网段下的IP需在最后8位做区分。456 > 2. 每个IP都不能冲突,相同网段下的IP需在最后8位做区分。
457 457 
458 3. 使用hccn\_tool配置网络检测对象IP,从device0 - device7配置8次。458 3. 使用hccn\_tool配置网络检测对象IP,从device0 - device7配置8次。
@@ -606,9 +606,9 @@
606>606>
607> - 集合通信存在如下约束:607> - 集合通信存在如下约束:
608> - 数据并行模式中不同device上执行的计算图相同。608> - 数据并行模式中不同device上执行的计算图相同。
609-> - 针对<term>Atlas A2 训练系列产品</term>/<term>Atlas A3 训练系列产品</term>:AllReduce和reduce\_scatter仅支持int8、int32、float16、float32和bfloat16数据类型。609+> - 针对<term>Atlas A2训练系列产品</term>/<term>Atlas A3训练系列产品</term>:AllReduce和reduce\_scatter仅支持int8、int32、float16、float32和bfloat16数据类型。
610-> - 针对<term>Atlas A2 训练系列产品</term>/<term>Atlas A3 训练系列产品</term>,在Server集群场景(即由集群管理主节点和一组训练服务器组成训练服务器集群)下要求参与集合通信的NPU数目为(1\~8)\*n(其中n为参与训练的Server个数,上限为1152),其中,n为2的指数倍情况下,集群性能最好,建议用户优先采用此种方式进行集群组网。同时建议每个Server中参与集合通信的NPU数量保持一致,若不一致,会造成性能劣化。610+> - 针对<term>Atlas A2训练系列产品</term>/<term>Atlas A3训练系列产品</term>,在Server集群场景(即由集群管理主节点和一组训练服务器组成训练服务器集群)下要求参与集合通信的NPU数目为(1\~8)\*n(其中n为参与训练的Server个数,上限为1152),其中,n为2的指数倍情况下,集群性能最好,建议用户优先采用此种方式进行集群组网。同时建议每个Server中参与集合通信的NPU数量保持一致,若不一致,会造成性能劣化。
611-> - 针对<term>Atlas A2 训练系列产品</term>/<term>Atlas A3 训练系列产品</term>,若用户准备进行2卡训练,可将8卡训练脚本进行改写,改为2卡训练脚本。可参见以下修改方法:611+> - 针对<term>Atlas A2训练系列产品</term>/<term>Atlas A3训练系列产品</term>,若用户准备进行2卡训练,可将8卡训练脚本进行改写,改为2卡训练脚本。可参见以下修改方法:
612> 1. 若8卡脚本的batch\_size是单卡脚本的batch\_size的8倍,则将8卡训练时的batch\_size和learning\_rate同时除以4,作为2卡训练时的batch\_size和learning\_rate。612> 1. 若8卡脚本的batch\_size是单卡脚本的batch\_size的8倍,则将8卡训练时的batch\_size和learning\_rate同时除以4,作为2卡训练时的batch\_size和learning\_rate。
613> 2. 将nproc\_per\_node修改为2。613> 2. 将nproc\_per\_node修改为2。
614> - 一个device对应执行一个训练进程,当前不支持多进程在同一个device上进行训练。614> - 一个device对应执行一个训练进程,当前不支持多进程在同一个device上进行训练。
@@ -106,7 +106,7 @@
106 106 
107算力利用率可以衡量AI处理器算力的发挥程度,也可以衡量对负载和AI处理器的亲和优化。对于昇腾或GPU等重算力AI处理器,我们希望尽量多的算力都在CUBE/TensorCore上,如果Vector计算成为瓶颈,较多的时间会消耗在Vector计算上,此时**step\_time**增加,算力利用率降低。所以,算力利用率可以反映实际的算力发挥情况,牵引软硬件栈的优化。同时,算力利用率和吞吐成正比关系,可以纵向反映性能问题。107算力利用率可以衡量AI处理器算力的发挥程度,也可以衡量对负载和AI处理器的亲和优化。对于昇腾或GPU等重算力AI处理器,我们希望尽量多的算力都在CUBE/TensorCore上,如果Vector计算成为瓶颈,较多的时间会消耗在Vector计算上,此时**step\_time**增加,算力利用率降低。所以,算力利用率可以反映实际的算力发挥情况,牵引软硬件栈的优化。同时,算力利用率和吞吐成正比关系,可以纵向反映性能问题。
108 108 
109-影响算力利用率的因素是所有非矩阵运算花的时间,包括AICORE内部的数据搬运、VECTOR计算及卡间不可掩盖的通信时间等。109+影响算力利用率的因素是所有非矩阵运算花的时间,包括AI Core内部的数据搬运、VECTOR计算及卡间不可掩盖的通信时间等。
110 110 
111### 通信性能指标111### 通信性能指标
112 112 
@@ -5,7 +5,7 @@
5HCCL(Huawei Collective Communication Library,华为集合通信库)是基于昇腾AI处理器的高性能集合通信库,提供单机多卡、多机多卡集合通信原语,在PCIe、HCCS和RoCE高速链路实现集合通信功能,实现分布式训练。5HCCL(Huawei Collective Communication Library,华为集合通信库)是基于昇腾AI处理器的高性能集合通信库,提供单机多卡、多机多卡集合通信原语,在PCIe、HCCS和RoCE高速链路实现集合通信功能,实现分布式训练。
6 6 
7- HCCS(Huawei Cache Coherence System),华为一致性系统总线,用于NPU和NPU之间互联的高速总线。7- HCCS(Huawei Cache Coherence System),华为一致性系统总线,用于NPU和NPU之间互联的高速总线。
8-- PCIe(Peripheral Component Interconnect Express),一种串行外设扩展总线标准,用于计算机系统的外设扩展使用。8+- PCIe(Peripheral Component Interconnect Express),一种串行外设扩展总线标准,用于计算机系统的外设扩展。
9- DMA(Direct Memory Access)指一种高速的数据传输操作,允许在外部设备和存储器之间直接读写数据,既不通过CPU,也不需要CPU干预。9- DMA(Direct Memory Access)指一种高速的数据传输操作,允许在外部设备和存储器之间直接读写数据,既不通过CPU,也不需要CPU干预。
10- RDMA(Remote Direct Memory Access),远程直接内存访问技术,一般指能够跨过网络的DMA方式。10- RDMA(Remote Direct Memory Access),远程直接内存访问技术,一般指能够跨过网络的DMA方式。
11- RoCE(RDMA over Converged Ethernet),承载在融合以太网上的RDMA技术,即跨越以太网的RDMA通信方式,本文特指RoCE v2。11- RoCE(RDMA over Converged Ethernet),承载在融合以太网上的RDMA技术,即跨越以太网的RDMA通信方式,本文特指RoCE v2。
@@ -8,7 +8,7 @@
8|------|----------------------|8|------|----------------------|
9|torch_npu 接口|torch_npu.npu_rms_norm(x, gamma, epsilon)|9|torch_npu 接口|torch_npu.npu_rms_norm(x, gamma, epsilon)|
10|支持的PyTorch版本|2.6.0|10|支持的PyTorch版本|2.6.0|
11-|支持的芯片类型|Atlas A2 训练系列产品,Atlas A3 训练系列产品|11+|支持的芯片类型|Atlas A2训练系列产品,Atlas A3训练系列产品|
12|支持的数据类型|float16, bfloat16, float|12|支持的数据类型|float16, bfloat16, float|
13 13 
14## torch\_npu接口参数14## torch\_npu接口参数
@@ -8,7 +8,7 @@
8|-------|-------------------------|8|-------|-------------------------|
9|torch_npu 接口|torch_npu.npu_rotary_mul(x, r1, r2)|9|torch_npu 接口|torch_npu.npu_rotary_mul(x, r1, r2)|
10|支持的PyTorch版本|2.7.1, 2.10.0|10|支持的PyTorch版本|2.7.1, 2.10.0|
11-|支持的芯片类型|Atlas A2 训练系列产品,Atlas A3 训练系列产品|11+|支持的芯片类型|Atlas A2训练系列产品,Atlas A3训练系列产品|
12|支持的数据类型|float16, bfloat16, float|12|支持的数据类型|float16, bfloat16, float|
13 13 
14## torch\_npu接口参数14## torch\_npu接口参数
@@ -8,7 +8,7 @@
8|-------|---------------------------------------------|8|-------|---------------------------------------------|
9|torch_npu 接口|torch_npu.npu_scaled_masked_softmax(x, mask, scale, fixed_triu_mask)|9|torch_npu 接口|torch_npu.npu_scaled_masked_softmax(x, mask, scale, fixed_triu_mask)|
10|支持的PyTorch版本|2.7.1, 2.10.0|10|支持的PyTorch版本|2.7.1, 2.10.0|
11-|支持的芯片类型|Atlas A2 训练系列产品,Atlas A3 训练系列产品|11+|支持的芯片类型|Atlas A2训练系列产品,Atlas A3训练系列产品|
12|支持的数据类型|float16, bfloat16, float|12|支持的数据类型|float16, bfloat16, float|
13 13 
14## torch\_npu接口参数14## torch\_npu接口参数
@@ -8,7 +8,7 @@
8|------|-------|8|------|-------|
9|torch_npu 接口|torch_npu.npu_swiglu(self,dim)|9|torch_npu 接口|torch_npu.npu_swiglu(self,dim)|
10|支持的PyTorch版本|2.6.0|10|支持的PyTorch版本|2.6.0|
11-|支持的芯片类型|Atlas A2 训练系列产品,Atlas A3 训练系列产品|11+|支持的芯片类型|Atlas A2训练系列产品,Atlas A3训练系列产品|
12|支持的数据类型|float16, bfloat16, float32|12|支持的数据类型|float16, bfloat16, float32|
13 13 
14## torch\_npu接口参数14## torch\_npu接口参数
@@ -313,7 +313,7 @@ tcmalloc(即Thread-Caching Malloc)是一个通用的内存分配器,通过
313 313 
314 ![](../../figures/hp_opt_fig_06.png)314 ![](../../figures/hp_opt_fig_06.png)
315 315 
316- 5. 如需关闭大业内存池,则删除启动项参数。316+ 5. 如需关闭大页内存池,则删除启动项参数。
317 317 
318 ```shell318 ```shell
319 grubby --update-kernel=/boot/vmlinuz-4.18.0-193.el8.aarch64 --remove-args="hugepages hugepagesz default_hugepagesz"319 grubby --update-kernel=/boot/vmlinuz-4.18.0-193.el8.aarch64 --remove-args="hugepages hugepagesz default_hugepagesz"
@@ -4,7 +4,7 @@
4 4 
5BERT的全称是Bidirectional Encoder Representation from Transformers,即双向Transformer的Encoder,是一种用于自然语言处理(NLP)的预训练技术。5BERT的全称是Bidirectional Encoder Representation from Transformers,即双向Transformer的Encoder,是一种用于自然语言处理(NLP)的预训练技术。
6 6 
7-BERT-base模型是一个12层,768维,12个自注意头(self attention head),110M参数的神经网络结构,它的整体框架是由多层transformer的encoder堆叠而成的。每一层的encoder则是由一层muti-head-attention和一层feed-forward组成,每个attention的主要作用是通过目标词与句子中的所有词汇的相关度,对目标词重新编码。所以每个attention的计算包括三个步骤:计算词之间的相关度,对相关度归一化,通过相关度和所有词的编码进行加权求和获取目标词的编码,本文档描述的是BERT-base模型在PyTorch上实现的版本。7+BERT-base模型是一个12层,768维,12个自注意头(self attention head),110M参数的神经网络结构,它的整体框架是由多层transformer的encoder堆叠而成的。每一层的encoder则是由一层multi-head-attention和一层feed-forward组成,每个attention的主要作用是通过目标词与句子中的所有词汇的相关度,对目标词重新编码。所以每个attention的计算包括三个步骤:计算词之间的相关度,对相关度归一化,通过相关度和所有词的编码进行加权求和获取目标词的编码,本文档描述的是BERT-base模型在PyTorch上实现的版本。
8 8 
9* [参考实现](https://github.com/NVIDIA/DeepLearningExamples/tree/master/PyTorch/LanguageModeling/BERT)。9* [参考实现](https://github.com/NVIDIA/DeepLearningExamples/tree/master/PyTorch/LanguageModeling/BERT)。
10* 本代码仓为适配NPU的实现。10* 本代码仓为适配NPU的实现。
@@ -49,7 +49,7 @@ BERT-base模型是一个12层,768维,12个自注意头(self attention head
49 49 
503. 下载词典503. 下载词典
51 51 
52- 在数据集v1.1目录下执行一下命令,建立**data/uncased_L-24_H-1024_A-16**文件目录。52+ 在数据集v1.1目录下执行以下命令,建立**data/uncased_L-24_H-1024_A-16**文件目录。
53 53 
54 ```bash54 ```bash
55 mkdir data55 mkdir data