diff --git a/debug/accuracy_tools/api_accuracy_checker/README.md b/debug/accuracy_tools/api_accuracy_checker/README.md
index c2db434f7164d7e613041302b84a429f7de41e98..7a5bc611320289bd94cfc3e5dff33bea86d00bf7 100644
--- a/debug/accuracy_tools/api_accuracy_checker/README.md
+++ b/debug/accuracy_tools/api_accuracy_checker/README.md
@@ -11,23 +11,23 @@ Ascend模型精度预检工具能在昇腾NPU上扫描用户训练模型中所
3. 支持随机生成模式和真实数据模式
4. 单API测试,排除整网中的累计误差问题
-## 使用方式
-
-1. 安装预检工具
+## 工具安装
- 将att仓代码下载到本地,并配置环境变量。假设下载后att仓路径为 $ATT_HOME,环境变量应配置为:
+1. 将att仓代码下载到本地,并配置环境变量。假设下载后att仓路径为 $ATT_HOME,环境变量应配置为:
```bash
export PYTHONPATH=$PYTHONPATH:$ATT_HOME/debug/accuracy_tools/
```
- 安装依赖tqdm、rich、pyyaml
+2. 安装依赖tqdm、rich、pyyaml
```bash
pip3 install tqdm rich pyyaml
```
-2. 在训练脚本(如main.py)中加入以下代码导入工具dump模块,启动训练即可自动抓取网络所有API信息
+## 使用方式
+
+1. 在训练脚本(如main.py)中加入以下代码导入工具dump模块,启动训练即可自动抓取网络所有API信息
- 如果训练脚本是通过torch.utils.data.dataloader方式加载数据,就可以在训练脚本中加入以下代码导入工具dump模块,启动训练即可自动抓取网络所有API信息
@@ -68,14 +68,14 @@ Ascend模型精度预检工具能在昇腾NPU上扫描用户训练模型中所
```Python
from api_accuracy_checker.dump import msCheckerConfig
- msCheckerConfig.update_config(dump_path="my/dump/path", real_data=True, target_iter=1)
+ msCheckerConfig.update_config(dump_path="my/dump/path", real_data=True, target_iter=[1])
```
- | 参数名称 | 说明 | 是否必选 |
- | ----------------- | ------------------------------------------------------------ | -------- |
- | dump_path | 设置dump路径,须为已存在目录,默认为当前目录。 | 否 |
- | real_data | 真实数据模式,可取值True或False,默认为False,配置为True后开启真实数据模式,dump信息增加forward_real_data和backward_real_data目录,目录下保存每个API输入的具体数值。开启真实数据模式目前仅支持单卡,且会存盘较多数据,可能对磁盘空间有较大冲击。 | 否 |
- | target_iter | 指定dump某个step的数据,默认为1,仅支持dump1个step,须指定为训练脚本中存在的step。 | 否 |
+ | 参数名称 | 说明 | 是否必选 |
+ | ----------- | ------------------------------------------------------------ | -------- |
+ | dump_path | 设置dump路径,须为已存在目录,默认为当前目录。 | 否 |
+ | real_data | 真实数据模式,可取值True或False,默认为False,配置为True后开启真实数据模式,dump信息增加forward_real_data和backward_real_data目录,目录下保存每个API输入的具体数值。开启真实数据模式目前仅支持单卡,且会存盘较多数据,可能对磁盘空间有较大冲击。 | 否 |
+ | target_iter | 指定dump某个step的数据,默认为[1],须指定为训练脚本中存在的step。target_iter为list格式,可配置逐个step,例如:target_iter=[0,1,2];也可以配置step范围,例如:target_iter=list(range(0,9)),表示dump第0到第8个step。 | 否 |
3. 将API信息输入给run_ut模块运行精度检测并比对,运行如下命令:
@@ -102,6 +102,12 @@ Ascend模型精度预检工具能在昇腾NPU上扫描用户训练模型中所
```
数据默认会存盘到'./ut_error_data'路径下(相对于启动run_ut的路径),有需要的话,用户可以通过msCheckerConfig.update_config来配置保存路径,参数为error_data_path
+## API预检白名单
+
+精度预检工具可以对指定API进行预检操作,只需要修改att\debug\accuracy_tools\api_accuracy_checker\hook_module目录下的support_wrap_ops.yaml文件。
+
+support_wrap_ops.yaml文件当前记录所有PyTorch API名称,可以直接编辑该文件,删除不需要的API,保留需要预检的API。
+
## API预检指标
API预检通过测试,则在accuracy_checking_details.csv文件中的“pass”列标记“pass”,否则标记“error”或“warning”,详细规则如下:
diff --git a/debug/accuracy_tools/ptdbg_ascend/README.md b/debug/accuracy_tools/ptdbg_ascend/README.md
index 40325fa5501cf67cd3429087fa816a0ca672b6a7..80a9da216cbcaff177e64f6fd340493cf3d1b53e 100644
--- a/debug/accuracy_tools/ptdbg_ascend/README.md
+++ b/debug/accuracy_tools/ptdbg_ascend/README.md
@@ -10,6 +10,7 @@
| ptdbg_ascend版本 | 发布日期 | 支持PyTorch版本 | 下载链接 | 参考指南 | 校验码 |
| ---------------- | ---------- | -------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
+ | 4.0.T2 | 2023-11-29 | 1.11.0/2.0/2.1 | [ptdbg_ascend-4.0.T2-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/package/ptdbg_ascend/4.0/ptdbg_ascend-4.0.T2-py3-none-any.whl) | [ptdbg_ascend精度工具功能说明_v4.0.T2](doc/ptdbg_ascend精度工具功能说明_v4.0.T2.md) | d7d8a5e6e75b488e5b476532546bbef8af9e5ac0988e00a0d09118d7854d66ea |
| 4.0.T1 | 2023-11-09 | 1.11.0/2.0/2.1 | [ptdbg_ascend-4.0.T1-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/package/ptdbg_ascend/4.0/ptdbg_ascend-4.0.T1-py3-none-any.whl) | [ptdbg_ascend精度工具功能说明_v4.0.T1](doc/ptdbg_ascend精度工具功能说明_v4.0.T1.md) | 2a3dd23c9573fbd6b78c128cbfcd9f2fdf09b66d0ca5619e4095781d3ba5761c |
| 3.0 | 2023-10-16 | 1.8.1/1.11.0/2.0/2.1 | [ptdbg_ascend-3.0-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/package/ptdbg_ascend/3.0/ptdbg_ascend-3.0-py3-none-any.whl) | [ptdbg_ascend精度工具功能说明_v3.0](doc/ptdbg_ascend精度工具功能说明_v3.0.md) | eb177ec795f8ae8b0c937a3cf543914f535bb64c76ba2e520fc6f0456ff6740b |
| 2.0 | 2023-7-07 | 1.8.1/1.11.0/2.0 | [ptdbg_ascend-2.0-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/package/ptdbg_ascend/2.0/ptdbg_ascend-2.0-py3-none-any.whl) | [ptdbg_ascend精度工具功能说明_v2.0](doc/ptdbg_ascend精度工具功能说明_v2.0.md) | 85e046f133f0f40ed660337ce8207249b1dac47ac668910625bea49809f31d66 |
@@ -117,6 +118,7 @@ ptdbg_ascend精度工具的安装方式包括:**下载whl包安装**和**源
| ptdbg_ascend版本 | 发布日期 | 支持PyTorch版本 | 下载链接 | 参考指南 | 校验码 |
| ---------------- | ---------- | -------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
+ | 4.0.T2 | 2023-11-29 | 1.11.0/2.0/2.1 | [ptdbg_ascend-4.0.T2-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/package/ptdbg_ascend/4.0/ptdbg_ascend-4.0.T2-py3-none-any.whl) | [ptdbg_ascend精度工具功能说明_v4.0.T2](doc/ptdbg_ascend精度工具功能说明_v4.0.T2.md) | d7d8a5e6e75b488e5b476532546bbef8af9e5ac0988e00a0d09118d7854d66ea |
| 4.0.T1 | 2023-11-09 | 1.11.0/2.0/2.1 | [ptdbg_ascend-4.0.T1-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/package/ptdbg_ascend/4.0/ptdbg_ascend-4.0.T1-py3-none-any.whl) | [ptdbg_ascend精度工具功能说明_v4.0.T1](doc/ptdbg_ascend精度工具功能说明_v4.0.T1.md) | 2a3dd23c9573fbd6b78c128cbfcd9f2fdf09b66d0ca5619e4095781d3ba5761c |
| 3.0 | 2023-10-16 | 1.8.1/1.11.0/2.0/2.1 | [ptdbg_ascend-3.0-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/package/ptdbg_ascend/3.0/ptdbg_ascend-3.0-py3-none-any.whl) | [ptdbg_ascend精度工具功能说明_v3.0](doc/ptdbg_ascend精度工具功能说明_v3.0.md) | eb177ec795f8ae8b0c937a3cf543914f535bb64c76ba2e520fc6f0456ff6740b |
| 2.0 | 2023-7-07 | 1.8.1/1.11.0/2.0 | [ptdbg_ascend-2.0-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/package/ptdbg_ascend/2.0/ptdbg_ascend-2.0-py3-none-any.whl) | [ptdbg_ascend精度工具功能说明_v2.0](doc/ptdbg_ascend精度工具功能说明_v2.0.md) | 85e046f133f0f40ed660337ce8207249b1dac47ac668910625bea49809f31d66 |
diff --git "a/debug/accuracy_tools/ptdbg_ascend/doc/ptdbg_ascend\347\262\276\345\272\246\345\267\245\345\205\267\345\212\237\350\203\275\350\257\264\346\230\216_v3.0.md" "b/debug/accuracy_tools/ptdbg_ascend/doc/ptdbg_ascend\347\262\276\345\272\246\345\267\245\345\205\267\345\212\237\350\203\275\350\257\264\346\230\216_v3.0.md"
index 1dd70c19fac8cf5ed1f4c30475ef3d45d5eb22a7..03ed6bb61156a65803abdcfb2d75956961b0ab59 100644
--- "a/debug/accuracy_tools/ptdbg_ascend/doc/ptdbg_ascend\347\262\276\345\272\246\345\267\245\345\205\267\345\212\237\350\203\275\350\257\264\346\230\216_v3.0.md"
+++ "b/debug/accuracy_tools/ptdbg_ascend/doc/ptdbg_ascend\347\262\276\345\272\246\345\267\245\345\205\267\345\212\237\350\203\275\350\257\264\346\230\216_v3.0.md"
@@ -566,7 +566,7 @@ configure_hook可配置多种dump模式,示例如下:
仅支持NPU环境。
-- 示例11:dump指定API的ACL级别溢出数据
+- 示例11:dump溢出API的ACL级别数据
```python
debugger.configure_hook(mode="acl", acl_config="./dump.json")
@@ -615,6 +615,7 @@ debugger.stop()
```python
from ptdbg_ascend import *
debugger = PrecisionDebugger(dump_path="./dump_path", hook_name="dump", step=[0,2], enable_dataloader=True)
+ # 请勿将以上初始化流程插入到循环代码中
```
- 示例2:开启溢出检测dump
@@ -622,6 +623,7 @@ debugger.stop()
```python
from ptdbg_ascend import *
debugger = PrecisionDebugger(dump_path="./dump_path", hook_name="overflow_check", step=[0,2], enable_dataloader=True)
+ # 请勿将以上初始化流程插入到循环代码中
```
### 示例代码(手动模式)
@@ -632,7 +634,8 @@ debugger.stop()
```python
from ptdbg_ascend import *
- debugger = PrecisionDebugger(dump_path="./dump_path", hook_name="dump")
+ debugger = PrecisionDebugger(dump_path="./dump_path", hook_name="dump", step=[0])
+ # 请勿将以上初始化流程插入到循环代码中
# 模型初始化
# 下面代码也可以用PrecisionDebugger.start()和PrecisionDebugger.stop()
@@ -653,7 +656,8 @@ debugger.stop()
```python
from ptdbg_ascend import *
- debugger = PrecisionDebugger(dump_path="./dump_path", hook_name="overflow_check")
+ debugger = PrecisionDebugger(dump_path="./dump_path", hook_name="overflow_check", step=[0])
+ # 请勿将以上初始化流程插入到循环代码中
# 模型初始化
# 下面代码也可以用PrecisionDebugger.start()和PrecisionDebugger.stop()
diff --git "a/debug/accuracy_tools/ptdbg_ascend/doc/ptdbg_ascend\347\262\276\345\272\246\345\267\245\345\205\267\345\212\237\350\203\275\350\257\264\346\230\216_v4.0.T1.md" "b/debug/accuracy_tools/ptdbg_ascend/doc/ptdbg_ascend\347\262\276\345\272\246\345\267\245\345\205\267\345\212\237\350\203\275\350\257\264\346\230\216_v4.0.T1.md"
index 1d046591f2d64f2a936f44bbaf6537dab9c37941..20c61de585e044f85f7bfa289634c85c462a27ef 100644
--- "a/debug/accuracy_tools/ptdbg_ascend/doc/ptdbg_ascend\347\262\276\345\272\246\345\267\245\345\205\267\345\212\237\350\203\275\350\257\264\346\230\216_v4.0.T1.md"
+++ "b/debug/accuracy_tools/ptdbg_ascend/doc/ptdbg_ascend\347\262\276\345\272\246\345\267\245\345\205\267\345\212\237\350\203\275\350\257\264\346\230\216_v4.0.T1.md"
@@ -566,7 +566,7 @@ configure_hook可配置多种dump模式,示例如下:
仅支持NPU环境。
-- 示例11:dump指定API的ACL级别溢出数据
+- 示例11:dump溢出API的ACL级别数据
```python
debugger.configure_hook(mode="acl", acl_config="./dump.json")
@@ -615,6 +615,7 @@ debugger.stop()
```python
from ptdbg_ascend import *
debugger = PrecisionDebugger(dump_path="./dump_path", hook_name="dump", step=[0,2], enable_dataloader=True)
+ # 请勿将以上初始化流程插入到循环代码中
```
- 示例2:开启溢出检测dump
@@ -622,6 +623,7 @@ debugger.stop()
```python
from ptdbg_ascend import *
debugger = PrecisionDebugger(dump_path="./dump_path", hook_name="overflow_check", step=[0,2], enable_dataloader=True)
+ # 请勿将以上初始化流程插入到循环代码中
```
### 示例代码(手动模式)
@@ -632,7 +634,8 @@ debugger.stop()
```python
from ptdbg_ascend import *
- debugger = PrecisionDebugger(dump_path="./dump_path", hook_name="dump")
+ debugger = PrecisionDebugger(dump_path="./dump_path", hook_name="dump", step=[0])
+ # 请勿将以上初始化流程插入到循环代码中
# 模型初始化
# 下面代码也可以用PrecisionDebugger.start()和PrecisionDebugger.stop()
@@ -653,7 +656,8 @@ debugger.stop()
```python
from ptdbg_ascend import *
- debugger = PrecisionDebugger(dump_path="./dump_path", hook_name="overflow_check")
+ debugger = PrecisionDebugger(dump_path="./dump_path", hook_name="overflow_check", step=[0])
+ # 请勿将以上初始化流程插入到循环代码中
# 模型初始化
# 下面代码也可以用PrecisionDebugger.start()和PrecisionDebugger.stop()
diff --git "a/debug/accuracy_tools/ptdbg_ascend/doc/ptdbg_ascend\347\262\276\345\272\246\345\267\245\345\205\267\345\212\237\350\203\275\350\257\264\346\230\216_v4.0.T2.md" "b/debug/accuracy_tools/ptdbg_ascend/doc/ptdbg_ascend\347\262\276\345\272\246\345\267\245\345\205\267\345\212\237\350\203\275\350\257\264\346\230\216_v4.0.T2.md"
index 928308a0279ba44b775c6fe2ae64f92a24bc960a..700ab067fd8794cafe88b1b2496b3c915ff88113 100644
--- "a/debug/accuracy_tools/ptdbg_ascend/doc/ptdbg_ascend\347\262\276\345\272\246\345\267\245\345\205\267\345\212\237\350\203\275\350\257\264\346\230\216_v4.0.T2.md"
+++ "b/debug/accuracy_tools/ptdbg_ascend/doc/ptdbg_ascend\347\262\276\345\272\246\345\267\245\345\205\267\345\212\237\350\203\275\350\257\264\346\230\216_v4.0.T2.md"
@@ -451,7 +451,7 @@ PrecisionDebugger(dump_path=None, hook_name=None, rank=None, step=[], enable_dat
| dump_path | 设置dump数据目录路径,参数示例:"./dump_path"。
默认在dump_path目录下生成`ptdbg_dump_{version}`目录,并在该目录下生成`dump.pkl`文件以及`dump`数据文件保存目录。
当**configure_hook**函数配置了mode参数时,`dump.pkl`文件以及`dump`数据文件保存目录名称添加mode参数值为前缀,详情请参见“**dump数据存盘说明**”。
未配置dump_path时,也可以通过环境变量ASCEND_WORK_PATH配置dump路径,此时dump数据将落盘在${ASCEND_WORK_PATH}/dump_data下,自定义配置dump_path优先级高于环境变量,dump_path和环境变量需要二选一。 | 否 |
| hook_name | dump模式,可取值dump和overflow_check,表示dump和溢出检测功能,二选一。 | 是 |
| rank | 指定对某张卡上的数据进行dump或溢出检测,默认未配置(表示dump所有卡的数据),须根据实际卡的Rank ID配置。应配置为大于0的正整数,且须根据实际卡的Rank ID配置,若所配置的值大于实际训练所运行的卡的Rank ID,则dump数据为空,比如当前环境Rank ID为0~7,实际训练运行0~3卡,此时若配置Rank ID为4或不存在的10等其他值,此时dump数据为空。 | 否 |
-| step | 指定dump某个step的数据,默认未配置,须指定为训练脚本中存在的step。step为list格式,可配置逐个step,例如:step=[1,2,3];也可以配置step范围,例如:step=list(range(1,10)),表示dump第1到第10个step。 | 否 |
+| step | 指定dump某个step的数据,默认未配置,须指定为训练脚本中存在的step。step为list格式,可配置逐个step,例如:step=[0,1,2];也可以配置step范围,例如:step=list(range(0,9)),表示dump第0到第8个step。 | 否 |
| enable_dataloader | 自动控制开关,可取值True(开启)或False(关闭),默认为False。配置为True后自动识别dump step参数指定的迭代,并在该迭代执行完成后退出训练,此时start和stop函数可不配置,开启该开关要求训练脚本是通过torch.utils.data.dataloader方式加载数据;配置为False则需要配置start和stop函数,并在最后一个stop函数后或一个step结束的位置添加debugger.step()。 | 否 |
### configure_hook函数(可选)
@@ -574,7 +574,7 @@ configure_hook可配置多种dump模式,示例如下:
仅支持NPU环境。
-- 示例11:dump指定API的ACL级别溢出数据
+- 示例11:dump溢出API的ACL级别数据
```python
debugger.configure_hook(mode="acl", acl_config="./dump.json")
@@ -623,6 +623,7 @@ debugger.stop()
```python
from ptdbg_ascend import *
debugger = PrecisionDebugger(dump_path="./dump_path", hook_name="dump", step=[0,2], enable_dataloader=True)
+ # 请勿将以上初始化流程插入到循环代码中
```
- 示例2:开启溢出检测dump
@@ -630,6 +631,7 @@ debugger.stop()
```python
from ptdbg_ascend import *
debugger = PrecisionDebugger(dump_path="./dump_path", hook_name="overflow_check", step=[0,2], enable_dataloader=True)
+ # 请勿将以上初始化流程插入到循环代码中
```
### 示例代码(手动模式)
@@ -640,7 +642,8 @@ debugger.stop()
```python
from ptdbg_ascend import *
- debugger = PrecisionDebugger(dump_path="./dump_path", hook_name="dump")
+ debugger = PrecisionDebugger(dump_path="./dump_path", hook_name="dump", step=[0])
+ # 请勿将以上初始化流程插入到循环代码中
# 模型初始化
# 下面代码也可以用PrecisionDebugger.start()和PrecisionDebugger.stop()
@@ -661,7 +664,8 @@ debugger.stop()
```python
from ptdbg_ascend import *
- debugger = PrecisionDebugger(dump_path="./dump_path", hook_name="overflow_check")
+ debugger = PrecisionDebugger(dump_path="./dump_path", hook_name="overflow_check", step=[0])
+ # 请勿将以上初始化流程插入到循环代码中
# 模型初始化
# 下面代码也可以用PrecisionDebugger.start()和PrecisionDebugger.stop()
@@ -1228,7 +1232,7 @@ if __name__ == "__main__":
# 注册工具
set_dump_path("./dump_data/npu")
- set_dump_wwitch("ON")
+ set_dump_switch("ON")
register_hook(module, acc_cmp_dump)
x = torch.randn(2, 2)
@@ -1238,7 +1242,7 @@ if __name__ == "__main__":
module_dump_end() # 结束模块级精度数据dump
loss = out.sum()
loss.bachward()
- set_dump_wwitch("OFF")
+ set_dump_switch("OFF")
```
## dump数据存盘说明
diff --git "a/debug/accuracy_tools/ptdbg_ascend/doc/\345\234\250\347\272\277\347\262\276\345\272\246\346\257\224\345\257\271.md" "b/debug/accuracy_tools/ptdbg_ascend/doc/\345\234\250\347\272\277\347\262\276\345\272\246\346\257\224\345\257\271.md"
index b0a98e8852ff0d2bb395b07eb5ffa3a537b95928..317c99573c9c44a97c27a57282a7201e98aedd7b 100644
--- "a/debug/accuracy_tools/ptdbg_ascend/doc/\345\234\250\347\272\277\347\262\276\345\272\246\346\257\224\345\257\271.md"
+++ "b/debug/accuracy_tools/ptdbg_ascend/doc/\345\234\250\347\272\277\347\262\276\345\272\246\346\257\224\345\257\271.md"
@@ -1,89 +1,90 @@
-# **PyTorch在线精度比对工具使用指南**
+# **PyTorch NPU在线精度比对工具使用指南**
-本文主要介绍ptdbg_ascend 在线精度比对功能使用,ptdbg_ascend工具的原理及安装请参见《[PyTorch精度工具](https://gitee.com/ascend/att/blob/master/debug/accuracy_tools/ptdbg_ascend/README.md)》。本节只介绍在线精度比对部分
+PyTorch NPU在线精度比对是ptdbg_ascend工具实现在PyTorch训练过程中直接完成精度比对并输出比对结果的功能。
+
+在线精度比对实现的是NPU与CPU之间的精度比对。
## PyTorch NPU在线精度比对总体流程
1. 准备NPU训练工程。
-2. 在环境下安装ptdbg_ascend工具。
+2. 在NPU环境下安装ptdbg_ascend工具,参见《[PyTorch精度工具](https://gitee.com/ascend/att/blob/master/debug/accuracy_tools/ptdbg_ascend/README.md)》。
-3. 在训练脚本内插入ptdbg_ascend工具在线比对接口。
+3. 在训练脚本内插入ptdbg_ascend工具在线精度比对接口。
-4. 执行训练在线精度比对NPU和CPU执行结果
+4. 执行训练并获取在线精度比对NPU和CPU分别执行后的精度比对结果。
5. 比对结果分析。
-## PyTorch NPU在线精度比
+## PyTorch NPU在线精度比对
### 总体说明
- 本节主要介绍NPU精度比对所需要的函数以及示例。
-- 在线精度比对工具通过截获Pytorch框架中部分Aten Ir及其输入输出,并将输入转到CPU执行,在线比对NPU和CPU的输出结果
+- 在线精度比对工具通过截获PyTorch框架中部分Aten Ir及其输入输出,并将输入数据转到CPU执行,最后将NPU和CPU的执行结果进行精度比对得到比对结果。
### 约束
-- Pytorch 只支持2.0及其以上版本
-- 只支持Aten Ir级在线精度比对,所有Aten Ir可以通过dir(torch.ops.aten)查看,其中部分IR不支持 在线比对:Aten Ir无对应CPU实现;NPU/CPU同AtenIR 实现逻辑不一致,导致同输入不同输出
-- 正反向不支持同时在线精度比对,不支持跨step在线精度比对
+- Pytorch 只支持2.0及其以上版本。
+- 只支持Aten Ir级在线精度比对,所有Aten Ir可以通过dir(torch.ops.aten)查看,其中部分IR不支持在线比对:Aten Ir无对应CPU实现、NPU和CPU同AtenIR实现逻辑不一致,导致同输入不同输出。
+- 正反向不支持同时在线精度比对,不支持跨step在线精度比对。
### 场景示例
-1.在线精度比对
+1. 在NPU训练脚本中添加在线精度比对接口,示例如下:
+
```python
-from ptdbg_ascend import seed_all
-from ptdbg_ascend.online_dispatch import PtdbgDispatch
-
- # 在main函数开始前固定随机数
- seed_all()
-
-
- ...
-
- # 在需要调试精度的正向或反向代码前设置
- # 正向示例
- with PtdbgDispatch(dump_mode="auto", dump_path="/home/dump"):
- output = model_cpu(inputs)
- # 反向示例
- with PtdbgDispatch(dump_mode="auto", dump_path="/home/dump"):
- loss.backward()
+ from ptdbg_ascend import seed_all
+ from ptdbg_ascend.online_dispatch import PtdbgDispatch
+
+ # 在main函数开始前固定随机数
+ seed_all()
+
+
+ ...
+
+ # 在需要调试精度的正向或反向代码前设置
+ # 正向示例
+ with PtdbgDispatch(dump_mode="auto", dump_path="/home/dump"):
+ output = model_cpu(inputs)
+ # 反向示例
+ with PtdbgDispatch(dump_mode="auto", dump_path="/home/dump"):
+ loss.backward()
```
+2. 执行训练。
-2.找出精度不达标的Aten IR
-
-执行过程中会打屏Failed,Failed在比对结果csv中的Accuracy Reached or Not列标记为No,并在Dump目录下存盘精度不达标Aten IR的输入输出
-
-
-精度不达标的判断条件如下:
-
-1) Cosine < 0.99 且 MaxAbsError > 0.001时,精度不达标
-
-2) Cosine < 0.9,精度不达标
+3. 找出精度不达标的Aten IR。
-3) MaxAbsError > 1,精度不达标
+ 执行过程中会打屏Failed,Failed在比对结果csv中的Accuracy Reached or Not列标记为No,并在Dump目录下存盘精度不达标Aten IR的输入输出。
+ 
+### 计算精度评价指标
+1. Cosine < 0.99 且 MaxAbsError > 0.001时,精度不达标;
+2. Cosine < 0.9,精度不达标;
+3. MaxAbsError > 1,精度不达标。
-
-
### 在线精度比对参数设置说明
- | 参数名称 | 说明 | 是否必选 |
- | -------- | ----------------------------------------------- | -------- |
- | dump_mode| 可取值"all"、"list"、"auto"、"off",默认值为 off,不Dump数据 | 否 |
- | api_list | dump_mode设置为list时设置,需要Dump Aten ir api名字,默认为None,Aten ir名字可以通过dir(torch.ops.aten)查看 | 否 |
- | dump_path| dump文件生成的路径 | 是 |
- | tag | 传入tag字符串,成为dump文件夹名一部分,默认为None | 否 |
- | process_num | 多进程并发数默认为0| 否 |
- | debug | debug信息打印,默认为False | 否 |
+| 参数名称 | 说明 | 是否必选 |
+| -------- | ----------------------------------------------- | -------- |
+| dump_mode| dump模式,可取值"all"、"list"、"auto"、"off",默认值为off(表示不Dump数据)。 | 否 |
+| api_list | dump范围,dump_mode="list"时设置,需要Dump Aten Ir API名称,默认为None,Aten Ir API名称可以通过dir(torch.ops.aten)查看。 | 否 |
+| dump_path| dump文件生成的路径。 | 是 |
+| tag | 传入tag字符串,成为dump文件夹名一部分,默认为None。 | 否 |
+| process_num | 多进程并发数,默认为0。 | 否 |
+| debug | debug信息打印,默认为False。 | 否 |
### dump数据存盘说明
-存盘文件夹名:ptdbg+版本号+tag+rank卡号+时间戳,下划线连接tag为用户输入标记,默认无。
-子目录下会有1个比对csv结果文件,npu文件夹下包含Aten IR在npu上的输入输出,cpu文件夹下只包含cpu输出
-
- ptdbg_v3.2_rank4_20230911170521
- ├── compare_result_rank4_20230911170521.csv
- ├── cpu
- │ ├── native_batch_norm_backward_10_output.0.npy
- │ ............
- └── npu
- ├── native_batch_norm_backward_10_input.0.npy
- ............
+dump数据存盘目录名格式:`ptdbg_{version}_tag_rankid_{timestamp}`。
+
+子目录下包含1个比对结果csv文件、cpu和npudump数据目录,npu目录下包含Aten IR在NPU上的输入输出的dump数据,由于CPU的输入是直接使用NPU的输入执行,因此cpu目录下只包含执行输出的dump数据。
+
+```bash
+ptdbg_v3.2_rank4_20230911170521
+├── compare_result_rank4_20230911170521.csv
+├── cpu
+│ ├── native_batch_norm_backward_10_output.0.npy
+│ ............
+└── npu
+ ├── native_batch_norm_backward_10_input.0.npy
+ ............
+```