mindstudio-probe 1.0.1__py3-none-any.whl → 1.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mindstudio_probe-1.0.1.dist-info → mindstudio_probe-1.0.3.dist-info}/METADATA +5 -1
- mindstudio_probe-1.0.3.dist-info/RECORD +272 -0
- msprobe/README.md +78 -23
- msprobe/__init__.py +1 -0
- msprobe/config/README.md +182 -40
- msprobe/config/config.json +22 -0
- msprobe/core/__init__.py +0 -0
- msprobe/{pytorch → core}/advisor/advisor.py +3 -3
- msprobe/{pytorch → core}/advisor/advisor_result.py +2 -2
- msprobe/core/common/const.py +82 -5
- msprobe/core/common/exceptions.py +30 -18
- msprobe/core/common/file_check.py +19 -1
- msprobe/core/common/log.py +15 -1
- msprobe/core/common/utils.py +130 -30
- msprobe/core/common_config.py +32 -19
- msprobe/core/compare/acc_compare.py +299 -0
- msprobe/core/compare/check.py +95 -0
- msprobe/core/compare/compare_cli.py +49 -0
- msprobe/core/compare/highlight.py +222 -0
- msprobe/core/compare/multiprocessing_compute.py +149 -0
- msprobe/{pytorch → core}/compare/npy_compare.py +55 -4
- msprobe/core/compare/utils.py +429 -0
- msprobe/core/data_dump/data_collector.py +39 -35
- msprobe/core/data_dump/data_processor/base.py +85 -37
- msprobe/core/data_dump/data_processor/factory.py +5 -7
- msprobe/core/data_dump/data_processor/mindspore_processor.py +198 -0
- msprobe/core/data_dump/data_processor/pytorch_processor.py +94 -51
- msprobe/core/data_dump/json_writer.py +11 -11
- msprobe/core/grad_probe/__init__.py +0 -0
- msprobe/core/grad_probe/constant.py +71 -0
- msprobe/core/grad_probe/grad_compare.py +175 -0
- msprobe/core/grad_probe/utils.py +52 -0
- msprobe/doc/grad_probe/grad_probe.md +207 -0
- msprobe/doc/grad_probe/img/image-1.png +0 -0
- msprobe/doc/grad_probe/img/image-2.png +0 -0
- msprobe/doc/grad_probe/img/image-3.png +0 -0
- msprobe/doc/grad_probe/img/image-4.png +0 -0
- msprobe/doc/grad_probe/img/image.png +0 -0
- msprobe/mindspore/api_accuracy_checker/__init__.py +0 -0
- msprobe/mindspore/api_accuracy_checker/api_accuracy_checker.py +246 -0
- msprobe/mindspore/api_accuracy_checker/api_info.py +69 -0
- msprobe/mindspore/api_accuracy_checker/api_runner.py +152 -0
- msprobe/mindspore/api_accuracy_checker/base_compare_algorithm.py +197 -0
- msprobe/mindspore/api_accuracy_checker/compute_element.py +224 -0
- msprobe/mindspore/api_accuracy_checker/main.py +16 -0
- msprobe/mindspore/api_accuracy_checker/type_mapping.py +114 -0
- msprobe/mindspore/api_accuracy_checker/utils.py +63 -0
- msprobe/mindspore/cell_processor.py +34 -0
- msprobe/mindspore/common/const.py +87 -0
- msprobe/mindspore/common/log.py +38 -0
- msprobe/mindspore/common/utils.py +57 -0
- msprobe/mindspore/compare/distributed_compare.py +75 -0
- msprobe/mindspore/compare/ms_compare.py +117 -0
- msprobe/mindspore/compare/ms_graph_compare.py +317 -0
- msprobe/mindspore/compare/ms_to_pt_api.yaml +399 -0
- msprobe/mindspore/debugger/debugger_config.py +38 -15
- msprobe/mindspore/debugger/precision_debugger.py +79 -4
- msprobe/mindspore/doc/compare.md +58 -0
- msprobe/mindspore/doc/dump.md +158 -6
- msprobe/mindspore/dump/dump_tool_factory.py +19 -22
- msprobe/mindspore/dump/hook_cell/api_registry.py +104 -0
- msprobe/mindspore/dump/hook_cell/hook_cell.py +53 -0
- msprobe/mindspore/dump/hook_cell/support_wrap_ops.yaml +925 -0
- msprobe/mindspore/dump/hook_cell/wrap_functional.py +91 -0
- msprobe/mindspore/dump/hook_cell/wrap_tensor.py +63 -0
- msprobe/mindspore/dump/jit_dump.py +56 -0
- msprobe/mindspore/dump/kernel_kbyk_dump.py +65 -0
- msprobe/mindspore/free_benchmark/__init__.py +0 -0
- msprobe/mindspore/free_benchmark/api_pynative_self_check.py +116 -0
- msprobe/mindspore/free_benchmark/common/__init__.py +0 -0
- msprobe/mindspore/free_benchmark/common/config.py +12 -0
- msprobe/mindspore/free_benchmark/common/handler_params.py +17 -0
- msprobe/mindspore/free_benchmark/common/utils.py +71 -0
- msprobe/mindspore/free_benchmark/data/support_wrap_ops.yaml +842 -0
- msprobe/mindspore/free_benchmark/decorator/__init__.py +0 -0
- msprobe/mindspore/free_benchmark/decorator/dec_forward.py +42 -0
- msprobe/mindspore/free_benchmark/decorator/decorator_factory.py +107 -0
- msprobe/mindspore/free_benchmark/handler/__init__.py +0 -0
- msprobe/mindspore/free_benchmark/handler/base_handler.py +90 -0
- msprobe/mindspore/free_benchmark/handler/check_handler.py +41 -0
- msprobe/mindspore/free_benchmark/handler/fix_handler.py +36 -0
- msprobe/mindspore/free_benchmark/handler/handler_factory.py +21 -0
- msprobe/mindspore/free_benchmark/perturbation/add_noise.py +67 -0
- msprobe/mindspore/free_benchmark/perturbation/base_perturbation.py +21 -0
- msprobe/mindspore/free_benchmark/perturbation/bit_noise.py +63 -0
- msprobe/mindspore/free_benchmark/perturbation/improve_precision.py +34 -0
- msprobe/mindspore/free_benchmark/perturbation/no_change.py +12 -0
- msprobe/mindspore/free_benchmark/perturbation/perturbation_factory.py +27 -0
- msprobe/mindspore/free_benchmark/self_check_tool_factory.py +33 -0
- msprobe/mindspore/grad_probe/__init__.py +0 -0
- msprobe/mindspore/grad_probe/global_context.py +91 -0
- msprobe/mindspore/grad_probe/grad_analyzer.py +231 -0
- msprobe/mindspore/grad_probe/grad_monitor.py +27 -0
- msprobe/mindspore/grad_probe/grad_stat_csv.py +132 -0
- msprobe/mindspore/grad_probe/hook.py +92 -0
- msprobe/mindspore/grad_probe/utils.py +29 -0
- msprobe/mindspore/ms_config.py +63 -15
- msprobe/mindspore/overflow_check/overflow_check_tool_factory.py +17 -15
- msprobe/mindspore/runtime.py +4 -0
- msprobe/mindspore/service.py +354 -0
- msprobe/mindspore/task_handler_factory.py +7 -4
- msprobe/msprobe.py +66 -26
- msprobe/pytorch/__init__.py +1 -1
- msprobe/pytorch/api_accuracy_checker/common/config.py +21 -16
- msprobe/pytorch/api_accuracy_checker/common/utils.py +1 -60
- msprobe/pytorch/api_accuracy_checker/compare/algorithm.py +2 -5
- msprobe/pytorch/api_accuracy_checker/compare/api_precision_compare.py +46 -10
- msprobe/pytorch/api_accuracy_checker/compare/compare.py +84 -48
- msprobe/pytorch/api_accuracy_checker/compare/compare_utils.py +8 -12
- msprobe/pytorch/api_accuracy_checker/config.yaml +7 -1
- msprobe/pytorch/api_accuracy_checker/run_ut/data_generate.py +15 -11
- msprobe/pytorch/api_accuracy_checker/run_ut/multi_run_ut.py +11 -15
- msprobe/pytorch/api_accuracy_checker/run_ut/run_overflow_check.py +16 -9
- msprobe/pytorch/api_accuracy_checker/run_ut/run_ut.py +193 -105
- msprobe/pytorch/api_accuracy_checker/run_ut/run_ut_utils.py +68 -1
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/__init__.py +0 -0
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/attl.py +202 -0
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/client.py +324 -0
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/device_dispatch.py +204 -0
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/server.py +218 -0
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/ssl_config.py +10 -0
- msprobe/pytorch/bench_functions/__init__.py +15 -0
- msprobe/pytorch/bench_functions/apply_adam_w.py +28 -0
- msprobe/pytorch/bench_functions/confusion_transpose.py +19 -0
- msprobe/pytorch/bench_functions/fast_gelu.py +55 -0
- msprobe/pytorch/bench_functions/layer_norm_eval.py +6 -0
- msprobe/pytorch/bench_functions/linear.py +12 -0
- msprobe/pytorch/bench_functions/matmul_backward.py +48 -0
- msprobe/pytorch/bench_functions/npu_fusion_attention.py +421 -0
- msprobe/pytorch/bench_functions/rms_norm.py +15 -0
- msprobe/pytorch/bench_functions/rotary_mul.py +52 -0
- msprobe/pytorch/bench_functions/scaled_mask_softmax.py +26 -0
- msprobe/pytorch/bench_functions/swiglu.py +55 -0
- msprobe/pytorch/common/parse_json.py +3 -1
- msprobe/pytorch/common/utils.py +83 -7
- msprobe/pytorch/compare/distributed_compare.py +19 -64
- msprobe/pytorch/compare/match.py +3 -6
- msprobe/pytorch/compare/pt_compare.py +40 -0
- msprobe/pytorch/debugger/debugger_config.py +11 -2
- msprobe/pytorch/debugger/precision_debugger.py +34 -4
- msprobe/pytorch/doc/api_accuracy_checker.md +57 -13
- msprobe/pytorch/doc/api_accuracy_checker_online.md +187 -0
- msprobe/pytorch/doc/dump.md +73 -20
- msprobe/pytorch/doc/ptdbg_ascend_compare.md +75 -11
- msprobe/pytorch/doc/ptdbg_ascend_quickstart.md +3 -3
- msprobe/pytorch/doc/run_overflow_check.md +1 -1
- msprobe/pytorch/doc//321/206/320/247/320/260/321/206/320/260/320/227/321/206/320/255/320/226/321/205/342/225/226/320/265/321/205/320/225/342/225/226/321/205/320/254/342/225/221/321/206/320/251/320/277/321/211/320/272/320/234/321/210/320/277/320/221/321/205/320/242/320/234/321/206/320/220/320/267/321/210/320/223/342/225/234/321/205/320/257/342/225/221/321/207/342/225/221/342/224/220/321/206/320/232/320/265/321/205/320/241/320/232.md +151 -0
- msprobe/pytorch/free_benchmark/common/constant.py +3 -0
- msprobe/pytorch/free_benchmark/common/utils.py +4 -0
- msprobe/pytorch/free_benchmark/compare/grad_saver.py +22 -26
- msprobe/pytorch/free_benchmark/main.py +7 -4
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/add_noise.py +1 -1
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/bit_noise.py +1 -1
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/change_value.py +1 -1
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/improve_precision.py +3 -3
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/no_change.py +1 -1
- msprobe/pytorch/free_benchmark/perturbed_layers/run_cpu.py +1 -1
- msprobe/pytorch/free_benchmark/result_handlers/base_handler.py +43 -29
- msprobe/pytorch/free_benchmark/result_handlers/handler_factory.py +0 -1
- msprobe/pytorch/function_factory.py +75 -0
- msprobe/pytorch/functional/dump_module.py +4 -4
- msprobe/pytorch/grad_probe/__init__.py +0 -0
- msprobe/pytorch/grad_probe/grad_monitor.py +90 -0
- msprobe/pytorch/grad_probe/grad_stat_csv.py +129 -0
- msprobe/pytorch/hook_module/hook_module.py +14 -3
- msprobe/pytorch/hook_module/support_wrap_ops.yaml +2 -1
- msprobe/pytorch/hook_module/utils.py +9 -9
- msprobe/pytorch/hook_module/wrap_aten.py +20 -10
- msprobe/pytorch/hook_module/wrap_distributed.py +10 -7
- msprobe/pytorch/hook_module/wrap_functional.py +4 -7
- msprobe/pytorch/hook_module/wrap_npu_custom.py +21 -10
- msprobe/pytorch/hook_module/wrap_tensor.py +5 -6
- msprobe/pytorch/hook_module/wrap_torch.py +5 -7
- msprobe/pytorch/hook_module/wrap_vf.py +6 -8
- msprobe/pytorch/module_processer.py +53 -13
- msprobe/pytorch/online_dispatch/compare.py +4 -4
- msprobe/pytorch/online_dispatch/dispatch.py +39 -41
- msprobe/pytorch/online_dispatch/dump_compare.py +17 -47
- msprobe/pytorch/online_dispatch/single_compare.py +5 -5
- msprobe/pytorch/online_dispatch/utils.py +2 -43
- msprobe/pytorch/parse_tool/lib/compare.py +31 -19
- msprobe/pytorch/parse_tool/lib/config.py +2 -1
- msprobe/pytorch/parse_tool/lib/parse_tool.py +4 -4
- msprobe/pytorch/parse_tool/lib/utils.py +34 -80
- msprobe/pytorch/parse_tool/lib/visualization.py +4 -3
- msprobe/pytorch/pt_config.py +100 -6
- msprobe/pytorch/service.py +104 -19
- mindstudio_probe-1.0.1.dist-info/RECORD +0 -228
- msprobe/mindspore/dump/api_kbk_dump.py +0 -55
- msprobe/pytorch/compare/acc_compare.py +0 -1024
- msprobe/pytorch/compare/highlight.py +0 -100
- msprobe/test/core_ut/common/test_utils.py +0 -345
- msprobe/test/core_ut/data_dump/test_data_collector.py +0 -47
- msprobe/test/core_ut/data_dump/test_json_writer.py +0 -183
- msprobe/test/core_ut/data_dump/test_scope.py +0 -151
- msprobe/test/core_ut/test_common_config.py +0 -152
- msprobe/test/core_ut/test_file_check.py +0 -218
- msprobe/test/core_ut/test_log.py +0 -109
- msprobe/test/mindspore_ut/test_api_kbk_dump.py +0 -51
- msprobe/test/mindspore_ut/test_debugger_config.py +0 -42
- msprobe/test/mindspore_ut/test_dump_tool_factory.py +0 -51
- msprobe/test/mindspore_ut/test_kernel_graph_dump.py +0 -66
- msprobe/test/mindspore_ut/test_kernel_graph_overflow_check.py +0 -63
- msprobe/test/mindspore_ut/test_ms_config.py +0 -69
- msprobe/test/mindspore_ut/test_overflow_check_tool_factory.py +0 -51
- msprobe/test/mindspore_ut/test_precision_debugger.py +0 -56
- msprobe/test/mindspore_ut/test_task_handler_factory.py +0 -58
- msprobe/test/pytorch_ut/advisor/test_advisor.py +0 -83
- msprobe/test/pytorch_ut/api_accuracy_checker/common/test_common_utils.py +0 -108
- msprobe/test/pytorch_ut/api_accuracy_checker/common/test_config.py +0 -39
- msprobe/test/pytorch_ut/api_accuracy_checker/compare/test_algorithm.py +0 -112
- msprobe/test/pytorch_ut/api_accuracy_checker/compare/test_api_precision_compare.py +0 -77
- msprobe/test/pytorch_ut/api_accuracy_checker/compare/test_compare.py +0 -125
- msprobe/test/pytorch_ut/api_accuracy_checker/compare/test_compare_column.py +0 -10
- msprobe/test/pytorch_ut/api_accuracy_checker/compare/test_compare_utils.py +0 -43
- msprobe/test/pytorch_ut/api_accuracy_checker/run_ut/dump.json +0 -179
- msprobe/test/pytorch_ut/api_accuracy_checker/run_ut/forward.json +0 -63
- msprobe/test/pytorch_ut/api_accuracy_checker/run_ut/test_data_generate.py +0 -99
- msprobe/test/pytorch_ut/api_accuracy_checker/run_ut/test_multi_run_ut.py +0 -115
- msprobe/test/pytorch_ut/api_accuracy_checker/run_ut/test_run_ut.py +0 -72
- msprobe/test/pytorch_ut/compare/test_acc_compare.py +0 -17
- msprobe/test/pytorch_ut/free_benchmark/perturbed_layers/test_perturbed_layser.py +0 -105
- msprobe/test/pytorch_ut/free_benchmark/result_handlers/test_result_handler.py +0 -121
- msprobe/test/pytorch_ut/free_benchmark/test_main.py +0 -101
- msprobe/test/pytorch_ut/functional/test_dump_module.py +0 -15
- msprobe/test/pytorch_ut/hook_module/test_api_registry.py +0 -130
- msprobe/test/pytorch_ut/hook_module/test_hook_module.py +0 -42
- msprobe/test/pytorch_ut/hook_module/test_wrap_aten.py +0 -65
- msprobe/test/pytorch_ut/hook_module/test_wrap_distributed.py +0 -35
- msprobe/test/pytorch_ut/hook_module/test_wrap_functional.py +0 -20
- msprobe/test/pytorch_ut/hook_module/test_wrap_tensor.py +0 -35
- msprobe/test/pytorch_ut/hook_module/test_wrap_torch.py +0 -43
- msprobe/test/pytorch_ut/hook_module/test_wrap_vf.py +0 -11
- msprobe/test/pytorch_ut/test_pt_config.py +0 -69
- msprobe/test/pytorch_ut/test_service.py +0 -59
- msprobe/test/resources/advisor.txt +0 -3
- msprobe/test/resources/compare_result_20230703104808.csv +0 -9
- msprobe/test/resources/compare_result_without_accuracy.csv +0 -9
- msprobe/test/resources/config.yaml +0 -3
- msprobe/test/resources/npu_test.pkl +0 -8
- msprobe/test/run_test.sh +0 -30
- msprobe/test/run_ut.py +0 -58
- msprobe/test/test_module_processer.py +0 -64
- {mindstudio_probe-1.0.1.dist-info → mindstudio_probe-1.0.3.dist-info}/LICENSE +0 -0
- {mindstudio_probe-1.0.1.dist-info → mindstudio_probe-1.0.3.dist-info}/WHEEL +0 -0
- {mindstudio_probe-1.0.1.dist-info → mindstudio_probe-1.0.3.dist-info}/entry_points.txt +0 -0
- {mindstudio_probe-1.0.1.dist-info → mindstudio_probe-1.0.3.dist-info}/top_level.txt +0 -0
- /msprobe/{pytorch → core}/advisor/advisor_const.py +0 -0
- /msprobe/pytorch/doc/{atat → msprobe}/321/207/342/226/223/342/225/233/321/205/342/225/221/320/266/321/205/342/225/226/320/265/321/205/320/225/342/225/226/321/206/320/245/342/226/221/321/206/320/235/320/276dump/321/206/320/260/320/227/321/205/320/227/320/226/321/206/320/220/320/267/321/210/320/223/342/225/234/321/205/320/257/342/225/221/321/207/342/225/221/342/224/220/321/206/320/232/320/265/321/205/320/241/320/232.md" +0 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# 在线精度预检
|
|
2
|
+
|
|
3
|
+
为了应对大模型场景下,通过离线预检方式dump API输入输出数据导致的存储资源紧张问题,提供在线精度预检功能。本功能实现在执行NPU训练操作的过程中,通过TCP/IP协议在NPU
|
|
4
|
+
Host与GPU Host设备间建立连接,将NPU上对应API的输入数据在GPU设备上运行,将两份输出数据进行比对,得到预检比对结果,从而减少数据dump的步骤,降低存储资源的占用。
|
|
5
|
+
|
|
6
|
+
## 在线精度预检流程
|
|
7
|
+
|
|
8
|
+
在线精度预检当前支持**局域网场景**和**共享存储场景**,请根据不同的场景选择对应的配置。
|
|
9
|
+
|
|
10
|
+
在线精度预检操作流程如下:
|
|
11
|
+
|
|
12
|
+
1. 准备GPU和NPU可正常运行的训练环境,PyTorch版本大于等于2.0,并保证两台Host在同一局域网内可正常通信或能通过共享存储进行通信。
|
|
13
|
+
2. GPU和NPU Host设备上同时安装msprobe工具,详见《[MindStudio精度调试工具](./../../README.md)
|
|
14
|
+
》,其中在线预检要多安装twisted、pyOpenSSL依赖,该依赖为Python模块。
|
|
15
|
+
3. 分别配置GPU侧、NPU侧的config.json文件。
|
|
16
|
+
4. 在GPU侧运行msprobe -f pytorch run_ut -config ./config.json。
|
|
17
|
+
5. 在NPU侧配置训练脚本。
|
|
18
|
+
6. 在NPU侧执行训练。
|
|
19
|
+
|
|
20
|
+
## 在线精度预检操作指导
|
|
21
|
+
|
|
22
|
+
### 配置config.json文件
|
|
23
|
+
|
|
24
|
+
安装完成预检工具后,需要分别在GPU和NPU环境下分别配置config.json。其中需要重点关注文件中的is_online、is_benchmark_device、host和port参数的配置,保障在线预检时GPU和NPU两台设备间的通信正常。
|
|
25
|
+
|
|
26
|
+
#### GPU侧在线预检配置说明
|
|
27
|
+
|
|
28
|
+
| 参数名称 | 说明 | 是否必选 |
|
|
29
|
+
|-----------------|-----------------------------------------------------------------------------------------------------------------------|------|
|
|
30
|
+
| task | 任务名称,str类型,配置为run_ut表示预检任务。通过其他字段is_online判断离线预检、在线预检任务。 | 是 |
|
|
31
|
+
| white_list | 预检的API白名单,list[str]类型。参数示例:white_list=["conv1d", "conv2d"]。默认未配置白名单,即预检全量API数据。 | 否 |
|
|
32
|
+
| black_list | 预检的API黑名单,list[str]类型。参数示例:white_list=["conv1d", "conv2d"]。默认未配置黑名单,即预检全量API数据。 | 否 |
|
|
33
|
+
| error_data_path | 配置保存精度未达标的API输入输出数据路径,str类型。在线预检模式下该参数不生效。 | 否 |
|
|
34
|
+
| is_online | 在线预检模式开关,bool类型,可取值True(开启)、False(关闭),默认关闭。 | 是 |
|
|
35
|
+
| nfs_path | 在线预检模式共享存储目录路径,str类型,用于GPU设备和NPU设备间进行通信。配置该参数后host和port不生效。 | 否 |
|
|
36
|
+
| host | 在线预检模式局域网场景信息接收端IP,str类型,用于GPU设备和NPU设备间进行通信,GPU侧配置为本机地址127.0.0.1或本机局域网IP。局域网场景时,不能配置nfs_path参数,否则局域网场景不生效。 | 否 |
|
|
37
|
+
| port | 在线预检模式局域网场景信息接收端端口号,int类型,用于GPU设备和NPU设备间进行通信,GPU侧配置为本机可用端口。局域网场景时,不能配置nfs_path参数,否则局域网场景不生效。 | 否 |
|
|
38
|
+
| rank_list | 指定在线预检的Rank ID,默认值为[0],list[int]类型,应配置为大于等于0的整数,且须根据实际卡的Rank ID配置,若所配置的值大于实际训练所运行的卡的Rank ID,则在线预检输出数据为空。GPU和NPU须配置一致。 | 是 |
|
|
39
|
+
|
|
40
|
+
#### NPU侧在线预检配置说明
|
|
41
|
+
|
|
42
|
+
| 参数名称 | 说明 | 是否必选 |
|
|
43
|
+
|------------------|--------------------------------------------------------------------------------------------------------|------|
|
|
44
|
+
| task | 任务名称,str类型,配置为tensor表示dump API统计信息和完全复刻整网的API运行情况的真实数据。通过字段onlin_run_ut判断是否使用在线预检功能。 | 是 |
|
|
45
|
+
| dump_path | dump路径,str类型,配置为合法路径即可,兼容tensor任务静态检查 | 是 |
|
|
46
|
+
| level | dump级别,str类型,在线预检时配置为L1,表示dump API级精度数据。在线预检可不配置,默认取值L1。 | 是 |
|
|
47
|
+
| rank | 指定对某张卡上的数据进行dump,list[int]类型,默认未配置(表示dump所有卡的数据),需要与GPU侧配置项rank_list保持一致。 | 否 |
|
|
48
|
+
| step | 指定dump某个step的数据,list[int]类型,默认未配置,表示dump所有step的数据。dump特定step时,须指定为训练脚本中存在的step。 | 否 |
|
|
49
|
+
| seed | 随机种子数,int类型,默认值为1234。通过固定随机数保证模型的输入或输出一致。 | 否 |
|
|
50
|
+
| is_deterministic | 确定性计算模式,bool类型,可取值true(开启)或false(关闭),默认关闭。 | 否 |
|
|
51
|
+
| scope | dump范围,list[str]类型,默认未配置(list也未配置时师表dump所有api的额数据),配置方式参考[《config配置文件说明》](./../../config/README.md) | 否 |
|
|
52
|
+
| list | 自定义dump范围,list[str]类型,默认未配置(scope也未配置时表示dump所有api的数据),配置方式参考[《config配置文件说明》](./../../config/README.md) | 否 |
|
|
53
|
+
| online_run_ut | 在线预检模式开关,bool类型,可取值True(开启)、False(关闭),默认关闭。 | 是 |
|
|
54
|
+
| nfs_path | 在线预检模式共享存储目录路径,str类型,用于GPU设备和NPU设备间进行通信。配置该参数后host和port不生效。 | 否 |
|
|
55
|
+
| host | 在线预检模式局域网场景信息接收端IP,str类型,用于GPU设备和NPU设备间进行通信,NPU侧须配置为GPU侧的局域网IP地址。局域网场景时,不能配置nfs_path参数,否则局域网场景不生效。 | 否 |
|
|
56
|
+
| port | 在线预检模式局域网场景信息接收端端口号,int类型,用于GPU设备和NPU设备间进行通信,NPU侧须配置为GPU侧的端口号。局域网场景时,不能配置nfs_path参数,否则局域网场景不生效。 | 否 |
|
|
57
|
+
|
|
58
|
+
#### 局域网场景配置示例
|
|
59
|
+
|
|
60
|
+
若复制下列示例,请删除注释后使用。
|
|
61
|
+
|
|
62
|
+
GPU侧:
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"task": "run_ut",
|
|
67
|
+
"run_ut": {
|
|
68
|
+
"white_list": [],
|
|
69
|
+
"black_list": [],
|
|
70
|
+
"error_data_path": "./",
|
|
71
|
+
"is_online": true,
|
|
72
|
+
"nfs_path": "",
|
|
73
|
+
"host": "127.0.0.1",
|
|
74
|
+
"port": 59208,
|
|
75
|
+
"rank_list": [0]
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
NPU侧:
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"task": "tensor",
|
|
85
|
+
"dump_path": "./dump_path",
|
|
86
|
+
"rank": [0],
|
|
87
|
+
"step": [0],
|
|
88
|
+
"level": "L1",
|
|
89
|
+
"seed": 1234,
|
|
90
|
+
"is_deterministic": true,
|
|
91
|
+
"tensor": {
|
|
92
|
+
"scope": [],
|
|
93
|
+
"list": [],
|
|
94
|
+
"online_run_ut": true,
|
|
95
|
+
"nfs_path": "",
|
|
96
|
+
"host": "xx.xx.xx.x",
|
|
97
|
+
"port": 59208
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### 共享存储场景配置示例
|
|
103
|
+
|
|
104
|
+
若复制下列示例,请删除注释后使用。
|
|
105
|
+
|
|
106
|
+
GPU侧:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"task": "run_ut",
|
|
111
|
+
"run_ut": {
|
|
112
|
+
"white_list": [],
|
|
113
|
+
"black_list": [],
|
|
114
|
+
"error_data_path": "./",
|
|
115
|
+
"is_online": true,
|
|
116
|
+
"nfs_path": "/nfs/xxx/data",
|
|
117
|
+
"host": "",
|
|
118
|
+
"port": -1,
|
|
119
|
+
"rank_list": [0]
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
NPU侧:
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"task": "tensor",
|
|
129
|
+
"dump_path": "./dump_path",
|
|
130
|
+
"rank": [0],
|
|
131
|
+
"step": [0],
|
|
132
|
+
"level": "L1",
|
|
133
|
+
"seed": 1234,
|
|
134
|
+
"is_deterministic": true,
|
|
135
|
+
"tensor": {
|
|
136
|
+
"scope": [],
|
|
137
|
+
"list": [],
|
|
138
|
+
"online_run_ut": true,
|
|
139
|
+
"nfs_path": "/nfs/xxx/data",
|
|
140
|
+
"host": "",
|
|
141
|
+
"port": -1
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### 在GPU侧运行run_ut
|
|
147
|
+
|
|
148
|
+
由于GPU侧为通信接收端,需先于NPU侧执行run_ut操作,命令如下:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
msprobe -f pytorch run_ut -config ./config.json
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
GPU侧配置好config.json文件后执行run_ut命令,此时GPU处于预检等待状态:
|
|
155
|
+
|
|
156
|
+
- 局域网场景:当NPU侧启动训练后将预检的API输入和输出数据发送到GPU侧时,GPU启动预检操作。
|
|
157
|
+
- 共享存储场景:当NPU侧启动训练后将预检的API输入和输出数据发送到共享存储时,GPU启动预检操作。
|
|
158
|
+
|
|
159
|
+
### 在NPU侧配置训练脚本
|
|
160
|
+
|
|
161
|
+
在NPU训练脚本中添加如下代码以获取run_ut操作的预检API输入和输出数据:
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
from msprobe.pytorch import PrecisionDebugger
|
|
165
|
+
|
|
166
|
+
debugger = PrecisionDebugger("config.json")
|
|
167
|
+
...
|
|
168
|
+
|
|
169
|
+
debugger.start()
|
|
170
|
+
|
|
171
|
+
...
|
|
172
|
+
|
|
173
|
+
debugger.stop()
|
|
174
|
+
debugger.step()
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### 在NPU侧执行训练脚本
|
|
178
|
+
|
|
179
|
+
配置完NPU侧训练脚本后即可执行训练脚本,命令示例如下:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
bash train.sh
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
训练脚本执行完毕后,在GPU侧dump_path目录下生成比对结果文件,详细介绍请参见《[精度预检工具](./api_accuracy_checker.md)》中的”
|
|
186
|
+
**预检结果**“。
|
|
187
|
+
|
msprobe/pytorch/doc/dump.md
CHANGED
|
@@ -12,7 +12,7 @@ msprobe工具主要通过在训练脚本内添加dump接口并启动训练的方
|
|
|
12
12
|
|
|
13
13
|
通过加载dump配置文件的方式来确定dump操作的详细配置。
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
PrecisionDebugger接口可以在from msprobe.pytorch import PrecisionDebugger之后的位置添加。详细使用可参考“**示例代码**”或“**model配置代码示例**”。
|
|
16
16
|
|
|
17
17
|
**原型**
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ msprobe工具主要通过在训练脚本内添加dump接口并启动训练的方
|
|
|
20
20
|
PrecisionDebugger(config_path=None, task=None, dump_path=None, level=None, model=None, step=None)
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
说明:上述参数除config_path和model外,其他参数均在[config.json](../../config)文件中可配,此处的参数优先级高于[config.json](../../config)文件中的配置,而config.json文件可以配置更多参数,若需要进行更多场景的精度数据dump,建议配置[config.json](../../config)文件。
|
|
23
|
+
说明:上述参数除config_path和model外,其他参数均在[config.json](../../config)文件中可配,此处的参数优先级高于[config.json](../../config)文件中的配置,而config.json文件可以配置更多参数,若需要进行更多场景的精度数据dump,建议配置[config.json](../../config)文件。config.json文件的配置可参考《[配置文件说明](https://gitee.com/ascend/mstt/blob/master/debug/accuracy_tools/msprobe/config/README.md)》。
|
|
24
24
|
|
|
25
25
|
**参数说明**
|
|
26
26
|
|
|
@@ -77,9 +77,9 @@ if __name__ == "__main__"
|
|
|
77
77
|
|
|
78
78
|
**功能说明**
|
|
79
79
|
|
|
80
|
-
启动函数。
|
|
80
|
+
dump启动函数。
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
在模型初始化之后的位置添加。需要与stop函数一起添加在for循环内。
|
|
83
83
|
|
|
84
84
|
**原型**
|
|
85
85
|
|
|
@@ -93,9 +93,9 @@ debugger.start()
|
|
|
93
93
|
|
|
94
94
|
**功能说明**
|
|
95
95
|
|
|
96
|
-
停止函数。
|
|
96
|
+
dump停止函数。
|
|
97
97
|
|
|
98
|
-
在**start
|
|
98
|
+
在**start**函数之后的任意位置添加。若需要dump反向数据,则需要添加在反向计算代码(如loss.backward)之后。
|
|
99
99
|
|
|
100
100
|
**原型**
|
|
101
101
|
|
|
@@ -105,13 +105,33 @@ debugger.stop()
|
|
|
105
105
|
|
|
106
106
|
该函数为类函数,可以使用debugger.stop()也可以使用PrecisionDebugger.stop()。
|
|
107
107
|
|
|
108
|
+
### forward_backward_dump_end函数
|
|
109
|
+
|
|
110
|
+
**功能说明**
|
|
111
|
+
|
|
112
|
+
dump停止函数。用于dump指定代码的前反向数据。
|
|
113
|
+
|
|
114
|
+
在**start**函数之后,反向计算代码(如loss.backward)之前的任意位置添加,可以dump **start**函数和该函数之间的前反向数据,可以通过调整**start**函数与该函数的位置,来指定需要dump的代码块。
|
|
115
|
+
|
|
116
|
+
要求**stop**函数添加在反向计算代码(如loss.backward)之后,此时该函数与**stop**函数之间的代码不会被dump。
|
|
117
|
+
|
|
118
|
+
使用示例参见“**示例代码 > 扩展示例**”。
|
|
119
|
+
|
|
120
|
+
**原型**
|
|
121
|
+
|
|
122
|
+
```Python
|
|
123
|
+
forward_backward_dump_end()
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
该函数为类函数,可以使用debugger.forward_backward_dump_end()也可以使用PrecisionDebugger.forward_backward_dump_end()。
|
|
127
|
+
|
|
108
128
|
### step函数
|
|
109
129
|
|
|
110
130
|
**功能说明**
|
|
111
131
|
|
|
112
132
|
结束标识。
|
|
113
133
|
|
|
114
|
-
在最后一个**stop**函数后或一个step
|
|
134
|
+
在最后一个**stop**函数后或一个step结束的位置添加。需要与start函数一起添加在for循环内。
|
|
115
135
|
|
|
116
136
|
**原型**
|
|
117
137
|
|
|
@@ -123,24 +143,57 @@ debugger.step()
|
|
|
123
143
|
|
|
124
144
|
## 示例代码
|
|
125
145
|
|
|
146
|
+
### 基础操作
|
|
147
|
+
|
|
148
|
+
如下示例可dump完整代码的前反向数据。
|
|
149
|
+
|
|
126
150
|
```Python
|
|
127
151
|
from msprobe.pytorch import PrecisionDebugger
|
|
152
|
+
|
|
153
|
+
# 请勿将PrecisionDebugger的初始化流程插入到循环代码中
|
|
128
154
|
debugger = PrecisionDebugger(config_path="./config.json", dump_path="./dump_path")
|
|
129
|
-
# 请勿将以上初始化流程插入到循环代码中
|
|
130
155
|
|
|
131
|
-
#
|
|
132
|
-
#
|
|
133
|
-
debugger.start()
|
|
156
|
+
# 模型、损失函数的定义及初始化等操作
|
|
157
|
+
# ...
|
|
134
158
|
|
|
135
|
-
#
|
|
159
|
+
# 数据集迭代的位置一般为模型训练开始的位置
|
|
160
|
+
for data, label in data_loader:
|
|
161
|
+
debugger.start() # 开启数据dump
|
|
136
162
|
|
|
137
|
-
|
|
138
|
-
|
|
163
|
+
# 如下是模型每个step执行的逻辑
|
|
164
|
+
output = model(data)
|
|
165
|
+
#...
|
|
166
|
+
loss.backward()
|
|
167
|
+
|
|
168
|
+
debugger.stop() # 关闭数据dump
|
|
169
|
+
debugger.step() # 结束一个step的dump
|
|
170
|
+
```
|
|
139
171
|
|
|
140
|
-
|
|
172
|
+
### 扩展示例
|
|
141
173
|
|
|
142
|
-
|
|
143
|
-
|
|
174
|
+
如下示例dump指定代码块前反向数据。
|
|
175
|
+
|
|
176
|
+
```Python
|
|
177
|
+
from msprobe.pytorch import PrecisionDebugger
|
|
178
|
+
|
|
179
|
+
# 请勿将PrecisionDebugger的初始化流程插入到循环代码中
|
|
180
|
+
debugger = PrecisionDebugger(config_path="./config.json", dump_path="./dump_path")
|
|
181
|
+
|
|
182
|
+
# 模型、损失函数的定义及初始化等操作
|
|
183
|
+
# ...
|
|
184
|
+
|
|
185
|
+
# 数据集迭代的位置一般为模型训练开始的位置
|
|
186
|
+
for data, label in data_loader:
|
|
187
|
+
debugger.start() # 开启数据dump
|
|
188
|
+
|
|
189
|
+
# 如下是模型每个step执行的逻辑
|
|
190
|
+
output = model(data)
|
|
191
|
+
debugger.forward_backward_dump_end() # 插入该函数到start函数之后,只dump start函数到该函数之间代码的前反向数据,本函数到stop函数之间的数据则不dump
|
|
192
|
+
#...
|
|
193
|
+
loss.backward()
|
|
194
|
+
|
|
195
|
+
debugger.stop() # 关闭数据dump
|
|
196
|
+
debugger.step() # 结束一个step的dump
|
|
144
197
|
```
|
|
145
198
|
|
|
146
199
|
## dump结果文件介绍
|
|
@@ -158,7 +211,7 @@ dump结果目录结构示例如下:
|
|
|
158
211
|
| | | | ├── MyModule.0.forward.input.pt # 开启模块级精度数据dump时存在模块级的dump数据文件
|
|
159
212
|
| | | | ...
|
|
160
213
|
| | | | └── Fcuntion.linear.5.backward.output.pt
|
|
161
|
-
│ | | ├── dump.json # 保存前反向算子、算子的统计量信息或溢出算子信息。包含dump数据的API名称(命名格式为:`{api_type}_{api_name}_{API调用次数}_{前向反向}_{input/output}.{参数序号}`)、dtype、 shape、各数据的max、min、mean、L2norm统计信息以及当配置summary_mode="md5"时的md5数据。其中,“参数序号”表示该API下的第n个参数,例如1,则为第一个参数,若该参数为list格式,则根据list继续排序,例如1.1,表示该API的第1个参数的第1个子参数;L2norm表示
|
|
214
|
+
│ | | ├── dump.json # 保存前反向算子、算子的统计量信息或溢出算子信息。包含dump数据的API名称(命名格式为:`{api_type}_{api_name}_{API调用次数}_{前向反向}_{input/output}.{参数序号}`)、dtype、 shape、各数据的max、min、mean、L2norm统计信息以及当配置summary_mode="md5"时的md5数据。其中,“参数序号”表示该API下的第n个参数,例如1,则为第一个参数,若该参数为list格式,则根据list继续排序,例如1.1,表示该API的第1个参数的第1个子参数;L2norm表示L2范数(平方根)
|
|
162
215
|
│ | | ├── stack.json # 算子调用栈信息
|
|
163
216
|
│ | | └── construct.json # 分层分级结构
|
|
164
217
|
│ | ├── rank1
|
|
@@ -175,9 +228,9 @@ dump结果目录结构示例如下:
|
|
|
175
228
|
│ ├── step2
|
|
176
229
|
```
|
|
177
230
|
|
|
178
|
-
dump过程中,pt文件在对应算子或者模块被执行后就会落盘,而json文件则需要在正常执行PrecisionDebugger.stop()
|
|
231
|
+
dump过程中,pt文件在对应算子或者模块被执行后就会落盘,而json文件则需要在正常执行PrecisionDebugger.stop()后才会写入完整数据,异常的程序终止会保存终止前被执行算子的相关npy文件,可能会导致json文件中数据丢失。
|
|
179
232
|
|
|
180
|
-
其中rank为设备上各卡的ID,每张卡上dump的数据会生成对应dump
|
|
233
|
+
其中rank为设备上各卡的ID,每张卡上dump的数据会生成对应dump目录。非分布式场景下没有rank ID,目录名称为rank。
|
|
181
234
|
|
|
182
235
|
pt文件保存的前缀和PyTorch对应关系如下:
|
|
183
236
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# **精度比对工具**
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 总体说明
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- 本节主要介绍通过命令行方式和比对函数方式进行CPU或GPU与NPU的精度数据比对,执行精度比对操作前需要先完成CPU或GPU与NPU的精度数据dump,参见《[精度数据采集](./dump.md)》。
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- 训练精度一体化工具msprobe,使用子命令compare进行比对,可支持单卡和多卡场景的精度数据比对。
|
|
8
8
|
|
|
9
9
|
- 比对函数均通过单独创建精度比对脚本执行,可支持单卡和多卡场景的精度数据比对。
|
|
10
10
|
|
|
@@ -12,12 +12,76 @@
|
|
|
12
12
|
|
|
13
13
|
用户环境性能弱于标准约束或非独占使用的比对速度酌情向下浮动。比对速度的计算方式:两份比对文件大小/比对耗时。
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
## 约束
|
|
16
16
|
|
|
17
17
|
- NPU自研API,在CPU或GPU若没有对应的API,该API的dump数据不比对。
|
|
18
18
|
- NPU与CPU或GPU的计算结果误差可能会随着模型的执行不断累积,最终会出现同一个API因为输入的数据差异较大而无法比对的情况。
|
|
19
19
|
- CPU或GPU与NPU中两个相同的API会因为调用次数不同导致无法比对或比对到错误的API,不影响整体运行,该API忽略。
|
|
20
20
|
|
|
21
|
+
## 命令行方式比对
|
|
22
|
+
|
|
23
|
+
将CPU或GPU与NPU的dump文件进行比对,支持单卡和多卡,可同时比对多卡的dump数据。多机场景需要每个设备单独执行比对操作。
|
|
24
|
+
|
|
25
|
+
请先参见《[精度数据采集](./dump.md)》完成CPU或GPU与NPU的精度数据dump。
|
|
26
|
+
|
|
27
|
+
### 操作步骤
|
|
28
|
+
|
|
29
|
+
1. 创建比对文件,文件内容及示例请参见“**比对文件**”。
|
|
30
|
+
|
|
31
|
+
2. 执行如下示例命令进行比对:
|
|
32
|
+
|
|
33
|
+
```shell
|
|
34
|
+
msprobe -f pytorch compare -i ./compare.json -o ./output -s
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**完整参数说明**
|
|
38
|
+
|
|
39
|
+
| 参数名 | 说明 | 是否必选 |
|
|
40
|
+
|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -------- |
|
|
41
|
+
| -i或--input_path | 指定比对文件路径。比对文件内容及示例请参见“**比对文件**”。 | 是 |
|
|
42
|
+
| -o或--output_path | 配置比对结果文件存盘目录。文件名称基于时间戳自动生成,格式为:`compare_result_{timestamp}.xlsx`。 | 是 |
|
|
43
|
+
| -s或--stack_mode | 配置stack_mode的开关。仅当**比对文件**配置"stack_path"需要开启。通过直接配置该参数开启,默认未配置,表示关闭。 | 否 |
|
|
44
|
+
| -c或--compare_only | 仅比对开关。未配置默认关闭仅比对,使用自动精度分析,工具自动针对比对结果进行分析,识别到第一个精度不达标节点(在比对结果文件中的“Accuracy Reached or Not”列显示为No),并给出问题可能产生的原因(打屏展示并生成advisor_{timestamp}.txt文件)。该参数默认未配置,使用自动精度分析,通过配置该参数开启仅比对,关闭自动精度分析,仅输出比对结果表格。 | 否 |
|
|
45
|
+
| -f或--fuzzy_match | 模糊匹配。开启后,对于网络中同一层级且命名仅调用次数不同的API,可匹配并进行比对。通过直接配置该参数开启,默认未配置,表示关闭。 | 否 |
|
|
46
|
+
|
|
47
|
+
3. 查看比对结果,请参见“**比对结果分析**”。
|
|
48
|
+
|
|
49
|
+
### 比对文件
|
|
50
|
+
|
|
51
|
+
以在当前目录创建./compare.json为例。
|
|
52
|
+
|
|
53
|
+
- 单卡场景示例
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"npu_path": "./npu_dump/dump.json",
|
|
58
|
+
"bench_path": "./bench_dump/dump.json",
|
|
59
|
+
"stack_path": "./npu_dump/stack.json",
|
|
60
|
+
"is_print_compare_log": true
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
- 多卡场景示例
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"npu_path": "./npu_dump/step0",
|
|
69
|
+
"bench_path": "./bench_dump/step0",
|
|
70
|
+
"is_print_compare_log": true
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**参数说明**
|
|
75
|
+
|
|
76
|
+
| 参数名 | 说明 | 是否必选 |
|
|
77
|
+
| -------------------- | ------------------------------------------------------------ | ------------------ |
|
|
78
|
+
| npu_path | 配置NPU环境下的dump.json文件(单卡场景)或真实数据目录(多卡场景)。数据类型:str。 | 是 |
|
|
79
|
+
| bench_path | 配置CPU、GPU或NPU环境下的dump.json文件(单卡场景)或真实数据目录(多卡场景)。数据类型:str。 | 是 |
|
|
80
|
+
| stack_path | 配置NPU dump目录下的stack.json文件。数据类型:str。 | 单卡必选,多卡不选 |
|
|
81
|
+
| is_print_compare_log | 配置是否开启日志打屏。可取值True或False。数据类型:bool | 否 |
|
|
82
|
+
|
|
83
|
+
## 比对函数方式比对
|
|
84
|
+
|
|
21
85
|
### compare_distributed
|
|
22
86
|
|
|
23
87
|
**功能说明**
|
|
@@ -66,7 +130,7 @@ compare(input_param, output_path, stack_mode=False, auto_analyze=True, fuzzy_mat
|
|
|
66
130
|
|
|
67
131
|
| 参数名 | 说明 | 是否必选 |
|
|
68
132
|
| ------------ | ------------------------------------------------------------ | -------- |
|
|
69
|
-
| input_param | 配置dump数据文件及目录。数据类型:dict。配置参数包括:<br> "npu_json_path":指定NPU dump目录下的dump.json文件。参数示例:"npu_json_path": "./npu_dump/dump.json"。必选。<br/> "bench_json_path":指定CPU、GPU或NPU dump目录下的dump.json文件。参数示例:"bench_json_path": "./
|
|
133
|
+
| input_param | 配置dump数据文件及目录。数据类型:dict。配置参数包括:<br> "npu_json_path":指定NPU dump目录下的dump.json文件。参数示例:"npu_json_path": "./npu_dump/dump.json"。必选。<br/> "bench_json_path":指定CPU、GPU或NPU dump目录下的dump.json文件。参数示例:"bench_json_path": "./bench_dump/dump.json"。必选。<br/> "stack_json_path":指定NPU dump目录下的stack.json文件。参数示例:"stack_json_path": "./npu_dump/stack.json"。可选。<br/> "is_print_compare_log":配置是否开启日志打屏。可取值True或False。可选。 | 是 |
|
|
70
134
|
| output_path | 配置比对结果文件存盘目录。参数示例:'./output'。文件名称基于时间戳自动生成,格式为:`compare_result_{timestamp}.xlsx`。数据类型:str。 | 是 |
|
|
71
135
|
| stack_mode | 配置stack_mode的开关。仅当配置"stack_json_path"需要开启。可取值True或False,参数示例:stack_mode=True,默认为False。数据类型:bool。 | 否 |
|
|
72
136
|
| auto_analyze | 自动精度分析,开启后工具自动针对比对结果进行分析,识别到第一个精度不达标节点(在比对结果文件中的“Accuracy Reached or Not”列显示为No),并给出问题可能产生的原因(打屏展示并生成advisor_{timestamp}.txt文件)。可取值True或False,参数示例:auto_analyze=False,默认为True。数据类型:bool。 | 否 |
|
|
@@ -78,13 +142,13 @@ compare(input_param, output_path, stack_mode=False, auto_analyze=True, fuzzy_mat
|
|
|
78
142
|
|
|
79
143
|
```Python
|
|
80
144
|
from msprobe.pytorch import compare
|
|
81
|
-
|
|
145
|
+
input_param={
|
|
82
146
|
"npu_json_path": "./npu_dump/dump.json",
|
|
83
|
-
"bench_json_path": "./
|
|
147
|
+
"bench_json_path": "./bench_dump/dump.json",
|
|
84
148
|
"stack_json_path": "./npu_dump/stack.json",
|
|
85
149
|
"is_print_compare_log": True
|
|
86
150
|
}
|
|
87
|
-
compare(
|
|
151
|
+
compare(input_param, output_path="./output", stack_mode=True)
|
|
88
152
|
```
|
|
89
153
|
|
|
90
154
|
### 统计量比对
|
|
@@ -97,13 +161,13 @@ compare(dump_result_param, output_path="./output", stack_mode=True)
|
|
|
97
161
|
|
|
98
162
|
```Python
|
|
99
163
|
from msprobe.pytorch import compare
|
|
100
|
-
|
|
164
|
+
input_param={
|
|
101
165
|
"npu_json_path": "./npu_dump/dump.json",
|
|
102
|
-
"bench_json_path": "./
|
|
166
|
+
"bench_json_path": "./bench_dump/dump.json",
|
|
103
167
|
"stack_json_path": "./npu_dump/stack.json",
|
|
104
168
|
"is_print_compare_log": True
|
|
105
169
|
}
|
|
106
|
-
compare(
|
|
170
|
+
compare(input_param, output_path="./output", stack_mode=True)
|
|
107
171
|
```
|
|
108
172
|
|
|
109
173
|
**比对结果**
|
|
@@ -83,13 +83,13 @@ PyTorch训练场景的精度问题分析建议参考以下思路进行精度比
|
|
|
83
83
|
|
|
84
84
|
```python
|
|
85
85
|
from msprobe.pytorch import compare
|
|
86
|
-
|
|
86
|
+
input_param={
|
|
87
87
|
"npu_json_path": "./npu_dump/dump.json",
|
|
88
|
-
"bench_json_path": "./
|
|
88
|
+
"bench_json_path": "./bench_dump/dump.json",
|
|
89
89
|
"stack_json_path": "./npu_dump/stack.json",
|
|
90
90
|
"is_print_compare_log": True
|
|
91
91
|
}
|
|
92
|
-
compare(
|
|
92
|
+
compare(input_param, output_path="./output", stack_mode=True)
|
|
93
93
|
```
|
|
94
94
|
|
|
95
95
|
执行比对:
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
针对训练过程中的溢出检测场景(当《[精度数据采集](./dump.md)》开启溢出检测dump时),对于输入正常但输出存在溢出的API,会在训练执行目录下将溢出的API信息按照前向和反向分类,dump并保存为`dump.json`,前向过程溢出的API可通过该工具对`dump.json`进行解析,输出溢出API为正常溢出还是非正常溢出,从而帮助用户快速判断。
|
|
4
4
|
|
|
5
|
-
工具支持PyTorch版本:1.11
|
|
5
|
+
工具支持PyTorch版本:1.11/2.0/2.1/2.2。
|
|
6
6
|
|
|
7
7
|
操作步骤如下:
|
|
8
8
|
|