diff --git a/debug/accuracy_tools/api_accuracy_checker/README.md b/debug/accuracy_tools/api_accuracy_checker/README.md index 3ee506f042e28c30a7d3baefc3e72539df94a18b..a5f4a0666b5c89e1c028964c916f2dc1611f5921 100644 --- a/debug/accuracy_tools/api_accuracy_checker/README.md +++ b/debug/accuracy_tools/api_accuracy_checker/README.md @@ -21,10 +21,10 @@ Ascend模型精度预检工具能在昇腾NPU上扫描用户训练模型中所 export PYTHONPATH=$PYTHONPATH:$ATT_HOME/debug/accuracy_tools/ ``` - 安装依赖tqdm、prettytable、pyyaml + 安装依赖tqdm、rich、pyyaml ```bash - pip3 install tqdm prettytable pyyaml + pip3 install tqdm rich pyyaml ``` 2. 在训练脚本(如main.py)中加入以下代码导入工具dump模块,启动训练即可自动抓取网络所有API信息 @@ -38,8 +38,14 @@ Ascend模型精度预检工具能在昇腾NPU上扫描用户训练模型中所 ```Python import api_accuracy_checker.dump as DP DP.dump.set_dump_switch("ON") + + ... + + DP.dump.set_dump_switch("OFF") # 可选,未配置"OFF"参数时表示dump从DP.dump.set_dump_switch("ON")开始的所有数据 ``` + DP.dump.set_dump_switch:开启工具dump模块,该接口取值为"ON"和"OFF"。 + 上述代码要添加在迭代前向的代码段中,或者说是遍历数据集循环的代码段中。如对于GPT-3可以添加在pretrain_gpt.py 的forward_step函数中。之后工具会适配这个场景开关的自动打开。 工具默认抓取训练的**第二个迭代**并且在第二个迭代后会报错退出训练进程,可通过target_iter参数配置。报错信息如下,这个报错仅用于停止训练,属于正常现象: @@ -77,12 +83,14 @@ Ascend模型精度预检工具能在昇腾NPU上扫描用户训练模型中所 python run_ut.py -forward ./forward_info_0.json -backward ./backward_info_0.json ``` - | 参数名称 | 说明 | 是否必选 | - | ---------------- | ------------------------------------------------------------ | -------- | - | -forward | 指定前向API信息文件forward_info_{pid}.json。 | 是 | - | -backward | 指定反向API信息文件backward_info_{pid}.json。 | 是 | - | -save_error_data | 保存精度未达标的API输入输出数据。 | 否 | - | --out_path | 指指定run_ut执行结果存盘路径,默认“./”(相对于run_ut的路径)。 | 否 | + | 参数名称 | 说明 | 是否必选 | + | -------------------------------- | ------------------------------------------------------------ | -------- | + | -forward或--forward_input_file | 指定前向API信息文件forward_info_{pid}.json。 | 是 | + | -backward或--backward_input_file | 指定反向API信息文件backward_info_{pid}.json。 | 是 | + | -save_error_data | 保存精度未达标的API输入输出数据。 | 否 | + | -o或--out_path | 指指定run_ut执行结果存盘路径,默认“./”(相对于run_ut的路径)。 | 否 | + | -j或--jit_compile | 开启jit编译。 | 否 | + | -d或--device | 指定Device ID,选择UT代码运行所在的卡,默认值为0。 | 否 | run_ut执行结果包括accuracy_checking_result.csv和accuracy_checking_details.csv两个文件。accuracy_checking_result.csv是API粒度的,标明每个API是否通过测试。建议用户先查看accuracy_checking_result.csv文件,对于其中没有通过测试的或者特定感兴趣的API,根据其API name字段在accuracy_checking_details.csv中查询其各个输出的达标情况以及比较指标。 @@ -113,10 +121,10 @@ Ascend模型精度预检工具能在昇腾NPU上扫描用户训练模型中所 export PYTHONPATH=$PYTHONPATH:$ATT_HOME/debug/accuracy_tools/ ``` - 安装依赖tqdm、prettytable、pyyaml + 安装依赖tqdm、rich、pyyaml ```bash - pip3 install tqdm prettytable pyyaml + pip3 install tqdm rich pyyaml ``` 2. 执行溢出API解析操作 @@ -126,6 +134,13 @@ Ascend模型精度预检工具能在昇腾NPU上扫描用户训练模型中所 python run_overflow_check.py -forward ./forward_info_0.json ``` + | 参数名称 | 说明 | 是否必选 | + | -------------------------------- | -------------------------------------------------- | -------- | + | -forward或--forward_input_file | 指定前向API信息文件forward_info_{pid}.json。 | 是 | + | -backward或--backward_input_file | 指定反向API信息文件backward_info_{pid}.json。 | 是 | + | -j或--jit_compile | 开启jit编译。 | 否 | + | -d或--device | 指定Device ID,选择UT代码运行所在的卡,默认值为0。 | 否 | + 反向过程溢出的API暂不支持该功能。 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.1.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.1.md" index 4a8ce75df45ab0cded29874c81ecd2054c2c9ff7..50220ae2fc6c97e5698bde57fef92f741783487a 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.1.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.1.md" @@ -296,20 +296,19 @@ set_dump_switch("ON", mode="api_list", api_list=["distributed"]) 通信类API支持列表: -| 序号 | Distributed | -| :--- | ----------------- | -| 1 | send | -| 2 | recv | -| 3 | broadcast | -| 4 | all_reduce | -| 5 | reduce | -| 6 | all_gather | -| 7 | gather | -| 8 | batch_isend_irecv | -| 9 | isend | -| 10 | irecv | -| 11 | scatter | -| 12 | reduce_scatter | +| 序号 | Distributed | +| :--- | -------------- | +| 1 | send | +| 2 | recv | +| 3 | broadcast | +| 4 | all_reduce | +| 5 | reduce | +| 6 | all_gather | +| 7 | gather | +| 8 | isend | +| 9 | irecv | +| 10 | scatter | +| 11 | reduce_scatter | ### 溢出检测场景 @@ -816,19 +815,17 @@ dump操作必选。 **函数原型** ```python -register_hook(model, hook, overflow_nums=overflow_nums, dump_mode=dump_mode, dump_config=dump_config_file, rank=0) +register_hook(model, hook, overflow_nums=overflow_nums, dump_mode=dump_mode, dump_config=dump_config_file) ``` **参数说明** | 参数名 | 说明 | 是否必选 | | ------------- | ------------------------------------------------------------ | -------- | -| model | model对象。 | 是 | -| hook | 注册工具的dump和溢出检测钩子。可取值overflow_check和acc_cmp_dump,二选一。 | 是 | +| hook | 注册工具的dump和溢出检测钩子。可取值overflow_check(表示溢出检测)和acc_cmp_dump(表示dump数据),二选一。 | 是 | | overflow_nums | 控制溢出次数,表示第N次溢出时,停止训练,过程中检测到溢出API对应ACL数据均dump。参数示例:overflow_nums=3。配置overflow_check时可配置,默认不配置,即检测到1次溢出,训练停止。 | 否 | | dump_mode | 控制针对溢出API的dump模式。可取值"api"或"acl",配置acl时表示dump ACL级别的溢出数据,此时set_dump_path参数不生效,dump数据目录由dump_config的.json文件配置,参数示例:dump_mode="acl"。默认不配置,即dump API级别的溢出数据。 | 否 | | dump_config | acl dump的配置文件。dump_mode="acl"时,该参数必选;dump_mode="api"时,该参数不选。参数示例:dump_config='./dump.json'。 | 否 | -| rank | 控制dump数据保存的rank目录名称。参数示例:rank=1。默认不配置,即自动读取dump数据所属的卡并保存在该卡对应的rank目录下。目录结构参见“**dump数据存盘说明**”。
多卡情况下,可能出现工具识别rank出错,导致dump数据保存到错误的rank目录下,此时需要根据“**[rank_id获取方法](https://gitee.com/ascend/att/blob/master/debug/accuracy_tools/ptdbg_ascend/doc/rank_id获取方法.md)**”配置该参数,以获取正确的rank_id;工具可正确识别rank_id时无须配置该参数。 | 否 | **函数示例** @@ -1170,7 +1167,7 @@ dump结果目录结构示例如下: | └── rank7 ``` -其中ptdbg_dump_{version}为未设置set_dump_path的dump_tag参数时的默认命名;rank为设备上各卡的ID,每张卡上dump的数据会生成对应dump目录,可由register_hook函数的rank参数控制rank目录名称。 +其中ptdbg_dump_{version}为未设置set_dump_path的dump_tag参数时的默认命名;rank为设备上各卡的ID,每张卡上dump的数据会生成对应dump目录。 当使用debugger方式dump数据时,配置了PrecisionDebugger模块的step=[]参数,dump结果目录则以step为父目录,例如配置step=[0,1,2]时,dump结果目录为: @@ -1276,7 +1273,7 @@ compare_distributed('./npu_dump/ptdbg_dump_v2.0', './gpu_dump/ptdbg_dump_v2.0', **函数原型** ```python -compare(input_param, output_path, stack_mode=False, auto_analyze=True, suffix='', fuzzy_match=False) +compare(input_param, output_path, stack_mode=False, auto_analyze=True, fuzzy_match=False) ``` **参数说明** @@ -1287,7 +1284,6 @@ compare(input_param, output_path, stack_mode=False, auto_analyze=True, suffix='' | output_path | 配置比对结果csv文件存盘目录。参数示例:'./output'。文件名称基于时间戳自动生成,格式为:`compare_result_{timestamp}.csv`。 | 是 | | stack_mode | 配置stack_mode的开关。仅当dump数据时配置set_dump_switch的mode="api_stack"时需要开启。参数示例:stack_mode=True,默认为False。 | 否 | | auto_analyze | 自动精度分析,开启后工具自动针对比对结果进行分析,识别到第一个精度不达标节点(在比对结果文件中的“Accuracy Reached or Not”列显示为No),并给出问题可能产生的原因(打屏展示并生成advisor_{timestamp}.txt文件)。可取值True或False,参数示例:auto_analyze=False,默认为True。 | 否 | -| suffix | 标识比对结果的文件名。配置的suffix值在比对结果文件名的compare_result和{timestamp}中间插入,例如:`compare_result_{suffix}_{timestamp}`。默认为空。 | 否 | | fuzzy_match | 模糊匹配。开启后,对于网络中同一层级且命名仅调用次数不同的API,可匹配并进行比对。可取值True或False,参数示例:fuzzy_match=True,默认为False。 | 否 | **函数示例**