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
msprobe/config/README.md
CHANGED
|
@@ -2,17 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
当前配置文件主要为PrecisionDebugger接口执行dump或无标杆比对操作时调用的配置,当PrecisionDebugger接口未指定该配置文件时,使用该文件的默认配置。配置文件详见[config.json](./config.json)。
|
|
4
4
|
|
|
5
|
+
当在环境上安装msprobe工具后,config.json文件位置可通过如下方式查找:
|
|
6
|
+
|
|
7
|
+
查找msprobe工具安装路径。
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
pip show mindstudio-probe
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
输出结果如下示例:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
Name: mindstudio-probe
|
|
17
|
+
Version: 1.0
|
|
18
|
+
Summary: This is a pytorch precision comparison tools
|
|
19
|
+
Home-page:
|
|
20
|
+
Author:
|
|
21
|
+
Author-email:
|
|
22
|
+
License:
|
|
23
|
+
Location: /home/xx/anaconda3/envs/pt21py38/lib/python3.8/site-packages
|
|
24
|
+
Requires: numpy, openpyxl, pandas, pyyaml, rich, tqdm, wheel
|
|
25
|
+
Required-by:
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Location字段为msprobe工具的安装路径,那么config.json文件位置为/home/xx/anaconda3/envs/pt21py38/lib/python3.8/site-packages/msprobe/config
|
|
29
|
+
|
|
5
30
|
## 参数说明
|
|
6
31
|
|
|
7
32
|
### **通用配置参数**
|
|
8
33
|
|
|
9
34
|
| 参数名 | 说明 | 是否必选 |
|
|
10
35
|
| ----------------- | ------------------------------------------------------------ | -------- |
|
|
11
|
-
| task | dump的任务类型,str
|
|
12
|
-
| dump_path | 设置dump数据目录路径,str类型。配置示例:"dump_path": "./dump_path"。MindSpore
|
|
36
|
+
| task | dump的任务类型,str类型。可取值:<br/> "free_benchmark"(无标杆比对)。<br/> "statistics"(仅dump张量的统计信息,默认值)。<br/> "tensor"(dump张量的统计信息和完整张量数据,MindSpore静态图场景仅dump完整张量数据)。<br/> "overflow_check"(溢出检测)。<br/> "run_ut"(精度预检配置)。<br/>配置示例:"task": "tensor"。<br/>根据task参数取值的不同,可以配置不同场景参数,详见:“**task配置为free_benchmark**”,“**task配置为statistics**”,“**task配置为tensor**”,“**task配置为overflow_check**”,“**task配置为run_ut**”。 | 否 |
|
|
37
|
+
| dump_path | 设置dump数据目录路径,str类型。配置示例:"dump_path": "./dump_path"。MindSpore静态图场景仅支持绝对路径。 | 是 |
|
|
13
38
|
| rank | 指定对某张卡上的数据进行dump,list[int]类型,默认未配置(表示dump所有卡的数据),应配置为大于等于0的整数,且须配置实际可用的Rank ID。配置示例:"rank": [1]。<br> 对于PyTorch场景,Rank ID从0开始计数,最大取值为所有节点可用卡总数-1,若所配置的值大于实际训练所运行的卡的Rank ID,则dump数据为空,比如当前环境Rank ID为0到7,实际训练运行0到3卡,此时若配置Rank ID为4或不存在的10等其他值,此时dump数据为空。<br/> 对于MindSpore场景,所有节点的Rank ID均从0开始计数,最大取值为每个节点可用卡总数-1,config.json配置一次rank参数对所有节点同时生效。 | 否 |
|
|
14
39
|
| step | 指定dump某个step的数据,list[int]类型。默认未配置,表示dump所有step数据。dump特定step时,须指定为训练脚本中存在的step。step为list格式,可配置逐个step,例如:"step": [0,1,2]。 | 否 |
|
|
15
|
-
| level | dump级别,str类型,根据不同级别dump
|
|
40
|
+
| level | dump级别,str类型,根据不同级别dump不同数据。可取值:<br> "L0"(dump module模块级精度数据,仅PyTorch场景支持,使用背景详见“**模块级精度数据dump说明**”)。<br/> "L1"(dump API级精度数据,默认值,仅MindSpore动态图和PyTorch场景支持)。<br/> "L2"(dump kernel级精度数据,仅MindSpore静态图和PyTorch场景支持,且PyTorch场景须配置acl_config参数)。<br/> "mix"(dump module模块级和API级精度数据,即"L0"+"L1",仅PyTorch场景支持)。<br/>配置示例:"level": "L1"。MindSpore动态图场景仅支持"L1"。 | 否 |
|
|
16
41
|
| acl_config | kernel dump的配置文件,str类型。level取"L2"时,该参数必选;level为其他值时,该参数不选。参数示例:acl_config='./acl_config.json'。acl_config.json配置文件详细介绍请参见“**acl_config.json配置文件说明**”。 | 否 |
|
|
17
42
|
| seed | 随机种子数,int类型,默认值为:1234,仅PyTorch场景支持。通过固定随机数保证模型的输入或输出一致,可固定的随机数详见“**固定随机数范围**”。配置示例:"seed": 1234。 | 否 |
|
|
18
43
|
| is_deterministic | 确定性计算模式,bool类型,仅PyTorch场景支持。可取值true(开启)或false(关闭),默认关闭。配置示例:"is_deterministic": true。<br/>即使在相同的硬件和输入下,API多次执行的结果也可能不同,开启确定性计算是为了保证在相同的硬件和输入下,API多次执行的结果相同。<br/>确定性计算会导致API执行性能降低,建议在发现模型多次执行结果不同的情况下开启。<br/>rnn类算子、ReduceSum、ReduceMean等算子可能与确定性计算存在冲突,若开启确定性计算后多次执行的结果不相同,则考虑存在这些算子。 | 否 |
|
|
@@ -20,26 +45,26 @@
|
|
|
20
45
|
|
|
21
46
|
### task配置为free_benchmark
|
|
22
47
|
|
|
23
|
-
仅PyTorch
|
|
48
|
+
仅PyTorch场景与MindSpore动态图场景支持,且"level"需为"L1"。
|
|
24
49
|
|
|
25
50
|
task配置为free_benchmark时,开启**无标杆比对**,在NPU环境下通过对当前模型API的输入添加扰动因子,二次执行,将得到的输出与未添加扰动因子前的输出进行比对,从而**得出该模型中可能因迁移等变化导致精度降低的API**。
|
|
26
51
|
|
|
27
|
-
无标杆比对优势在于省去了从GPU
|
|
52
|
+
无标杆比对优势在于省去了从CPU/GPU环境获取标杆数据的步骤,也省去了在NPU环境执行dump的操作,降低了精度比对的操作难度。
|
|
28
53
|
|
|
29
54
|
建议配置白名单(配置scope或list)控制少量API进行无标杆比对,一次对过多API执行无标杆比对可能导致显存溢出或性能膨胀。
|
|
30
55
|
|
|
31
56
|
| 参数名 | 说明 | 是否必选 |
|
|
32
57
|
| ------------ | ------------------------------------------------------------ | -------- |
|
|
33
|
-
| scope | PyTorch
|
|
34
|
-
| list |
|
|
35
|
-
| fuzz_device | 标杆设备,str类型。可取值:<br/> "npu":无标杆,通过添加扰动因子进行比对,默认值。<br/> "cpu":以CPU为标杆,pert_mode须配置为"to_cpu"
|
|
36
|
-
| pert_mode | 无标杆扰动因子,str类型。可取值:<br/> "improve_precision":对输入做升精度,默认值。<br/> "add_noise":对输入增加噪声。<br/> "no_change":不加扰动直接二次执行。<br/> "bit_noise":输入的末位比特翻转。<br/> "change_value"
|
|
37
|
-
| handler_type | 处理类型,可取值:"check"(进行无标杆比对检查,默认值)、"fix"(将扰动后的API输出结果覆盖原始API输出结果,尝试将Loss曲线恢复正常,该模式下不支持预热if_preheat
|
|
38
|
-
| fuzz_level | 无标杆数据dump级别,即选择比对结果文件应输出的表头属性,当前仅支持取值为:"L1"
|
|
39
|
-
| fuzz_stage | 前反向,选择对API前向或反向进行无标杆比对,可取值:"forward"(前向,默认值)、"backward"
|
|
40
|
-
| if_preheat |
|
|
41
|
-
| preheat_step |
|
|
42
|
-
| max_sample |
|
|
58
|
+
| scope | 自定义检测API列表(仅PyTorch场景支持),list[str]类型,默认值为空列表,当list也为空列表时,表示检测所有API。需要在[]内配置具体API名(在工具dump结果中查看)。配置示例:"scope": ["Torch.matmul.0", "Tensor.pow.4"]。与list参数不能同时配置。 | 否 |
|
|
59
|
+
| list | 自定义检测API类型或API名称,list[str]类型,默认值为空列表,表示检测所有API(PyTorch场景下还需scope也为空列表)。包含如下配置方法:<br> PyTorch场景下,指定某一类API,对某一类的API进行无标杆比对。配置示例:"list": ["relu"]。<br/> MindSpore场景下,指定API名称,对列表中的API进行检测。配置示例:"list": ["mindspore.mint.div", "mindspore.ops.bmm", "mindspore.Tensor.\_\_add\_\_"]。<br/>与scope参数不能同时配置。 | 否 |
|
|
60
|
+
| fuzz_device | 标杆设备,str类型。可取值:<br/> "npu":无标杆,通过添加扰动因子进行比对,默认值。<br/> "cpu":以CPU为标杆,pert_mode须配置为"to_cpu"(仅PyTorch场景支持)。<br/>配置示例:"fuzz_device": "npu"。 | 否 |
|
|
61
|
+
| pert_mode | 无标杆扰动因子,str类型。可取值:<br/> "improve_precision":对输入做升精度,默认值。<br/> "add_noise":对输入增加噪声。<br/> "no_change":不加扰动直接二次执行。<br/> "bit_noise":输入的末位比特翻转。<br/> "change_value":输入的张量首尾值调换(仅PyTorch场景支持)。<br/> "to_cpu":在CPU等价执行(仅PyTorch场景支持)。<br/>配置示例:"pert_mode": "improve_precision"。 | 否 |
|
|
62
|
+
| handler_type | 处理类型,可取值:"check"(进行无标杆比对检查,默认值)、"fix"(将扰动后的API输出结果覆盖原始API输出结果,尝试将Loss曲线恢复正常,该模式下不支持预热if_preheat与反向过程)。配置示例:"handler_type": "fix"。 | 否 |
|
|
63
|
+
| fuzz_level | 无标杆数据dump级别,即选择比对结果文件应输出的表头属性,当前仅支持取值为:"L1"(默认值)。输出结果详见“**无标杆比对数据存盘格式**”。 | 否 |
|
|
64
|
+
| fuzz_stage | 前反向,选择对API前向或反向进行无标杆比对,可取值:"forward"(前向,默认值)、"backward"(反向,仅PyTorch场景支持)。配置示例:"fuzz_stage": "forward"。 | 否 |
|
|
65
|
+
| if_preheat | 预热功能(仅PyTorch场景支持),开启功能后工具可以根据每次迭代的输出调整精度算法的阈值,从而更准确找出存在精度问题的API,bool类型。可取值true(开启)或false(关闭),默认关闭。配置示例:"if_preheat": "true"。"handler_type": "fix"不支持预热。 | 否 |
|
|
66
|
+
| preheat_step | 开启预热的迭代数量(仅PyTorch场景支持),int类型,默认值为15。须配置"if_preheat": "true"。 | 否 |
|
|
67
|
+
| max_sample | 每个算子预热的采样次数的最大阈值(仅PyTorch场景支持),int类型,默认值为20。须配置"if_preheat": "true"。 | 否 |
|
|
43
68
|
|
|
44
69
|
#### 无标杆比对数据存盘格式
|
|
45
70
|
|
|
@@ -57,33 +82,62 @@ task配置为free_benchmark时,开启**无标杆比对**,在NPU环境下通
|
|
|
57
82
|
| max_rel | 输出对比最大相对误差,float类型。 |
|
|
58
83
|
| dtype | 输入的dtype,string类型。 |
|
|
59
84
|
| shape | 输入的shape,tuple类型。 |
|
|
60
|
-
|
|
|
85
|
+
| output_index | 如果输出为列表或元组,其中一个元素检测不一致,则会有该元素的index,否则为空,int类型。 |
|
|
61
86
|
|
|
62
87
|
### task配置为statistics
|
|
63
88
|
|
|
64
89
|
| 参数名 | 说明 | 是否必选 |
|
|
65
90
|
| ------------ | ------------------------------------------------------------ | -------- |
|
|
66
|
-
| scope | PyTorch
|
|
67
|
-
| list | 自定义dump范围,list[str]类型,默认未配置(scope也未配置时表示dump所有API的数据)。包含如下配置方法:<br> PyTorch
|
|
68
|
-
| data_mode | dump数据过滤,str类型。可取值"all"、"forward"、"backward"、"input"和"output",表示仅保存dump的数据中文件名包含"forward"、"backward"、"input"和"output"的前向、反向、输入或输出的dump文件。配置示例"data_mode": ["backward"]或"data_mode": ["forward", "backward"]。默认为["all"],即保存所有dump的数据。除了all参数只能单独配置外,其他参数可以自由组合。<br/>MindSpore
|
|
69
|
-
| summary_mode | 控制dump文件输出的模式,str类型,仅PyTorch
|
|
91
|
+
| scope | PyTorch和MindSpore动态图场景dump范围,list[str]类型,默认未配置(list也未配置时表示dump所有API的数据)。需要在[]内配置两个模块名或API名,用于锁定区间,dump该范围内的数据。配置示例:"scope": ["MyModuleOP1", "MyModuleOP2"]。与level参数取值相关,level为L0和mix级别时,可配置模块名;level为L1级别时,可配置API名。MindSpore动态图场景当前仅支持配置为API名。 | 否 |
|
|
92
|
+
| list | 自定义dump范围,list[str]类型,默认未配置(scope也未配置时表示dump所有API的数据)。包含如下配置方法:<br> PyTorch和MindSpore动态图场景配置具体的API全称,dump该API数据。配置示例:"list": ["Tensor.permute.1.forward", "Tensor.transpose.2.forward", "Torch.relu.3.backward"]。<br/> PyTorch和MindSpore动态图场景指定某一类API,dump某一类的API级别输入输出数据。配置示例:"list": ["relu"]。<br/> MindSpore静态图场景配置kernel_name,可以是算子的名称列表,也可以指定算子类型("level": "L2"时不支持),还可以配置算子名称的正则表达式(当字符串符合”name-regex(xxx)”格式时,后台则会将其作为正则表达式。例如,”name-regex(Default/.+)”可匹配算子名称以”Default/”开头的所有算子)。 | 否 |
|
|
93
|
+
| data_mode | dump数据过滤,str类型。可取值"all"、"forward"、"backward"、"input"和"output",表示仅保存dump的数据中文件名包含"forward"、"backward"、"input"和"output"的前向、反向、输入或输出的dump文件。配置示例"data_mode": ["backward"]或"data_mode": ["forward", "backward"]。默认为["all"],即保存所有dump的数据。除了all参数只能单独配置外,其他参数可以自由组合。<br/>MindSpore静态图场景仅支持"all"、"input"和"output"参数,且各参数只能单独配置,不支持自由组合。 | 否 |
|
|
94
|
+
| summary_mode | 控制dump文件输出的模式,str类型,仅PyTorch和MindSpore动态图场景支持,可取值md5(dump输出包含md5值以及API统计信息的dump.json文件,用于验证数据的完整性)、statistics(dump仅输出包含API统计信息的dump.json文件,默认值)。配置示例:"summary_mode": "md5"。 | 否 |
|
|
70
95
|
|
|
71
96
|
### task配置为tensor
|
|
72
97
|
|
|
98
|
+
MindSpore静态图场景仅dump完整张量数据。
|
|
99
|
+
|
|
73
100
|
| 参数名 | 说明 | 是否必选 |
|
|
74
101
|
| -------------- | ------------------------------------------------------------ | -------- |
|
|
75
|
-
| scope | PyTorch
|
|
76
|
-
| list | 自定义dump范围,list[str]类型,默认未配置(scope也未配置时表示dump所有API的数据)。包含如下配置方法:<br> PyTorch
|
|
102
|
+
| scope | PyTorch和MindSpore动态图场景dump范围,list[str]类型,默认未配置(list也未配置时表示dump所有API的数据)。需要在[]内配置两个模块名或API名,用于锁定区间,dump该范围内的数据。配置示例:"scope": ["MyModuleOP1", "MyModuleOP2"]。与level参数取值相关,level为L0和mix级别时,可配置模块名;level为L1级别时,可配置API名。 | 否 |
|
|
103
|
+
| list | 自定义dump范围,list[str]类型,默认未配置(scope也未配置时表示dump所有API的数据)。包含如下配置方法:<br> PyTorch和MindSpore动态图场景配置具体的API全称,dump该API数据。配置示例:"list": ["Tensor.permute.1.forward", "Tensor.transpose.2.forward", "Torch.relu.3.backward"]。<br/> PyTorch和MindSpore动态图场景指定某一类API,dump某一类的API级别输入输出数据。配置示例:"list": ["relu"]。<br/> PyTorch和MindSpore动态图场景配置kernel_api,dump前向和反向API的kernel_api级别数据,其中dump反向API时需要配置**backward_input**参数。前向API配置示例:"list": ["Tensor.permute.1.forward"];反API配置示例:"list": ["Tensor.permute.1.forward"], "backward.input": "./npu_dump/step0/rank0/Functional.conv2d.1.backward.input.0.pt"]。<br/> MindSpore静态图场景配置kernel_name,可以是算子的名称列表,也可以指定算子类型("level": "L2"时不支持),还可以配置算子名称的正则表达式(当字符串符合”name-regex(xxx)”格式时,后台则会将其作为正则表达式。例如,”name-regex(Default/.+)”可匹配算子名称以”Default/”开头的所有算子)。 | 否 |
|
|
77
104
|
| backward_input | 该输入文件为首次运行训练dump得到反向API输入的dump文件,str类型,仅PyTorch场景支持,默认未配置。例如若需要dump Functional.conv2d.1 API的反向过程的输入输出,则需要在dump目录下查找命名包含Functional.conv2d.1、backward和input字段的dump文件。配置示例:"backward_input": "./npu_dump/step0/rank0/Functional.conv2d.1.backward.input.0.pt"] | 否 |
|
|
78
|
-
| data_mode | dump数据过滤,str类型。可取值"all"、"forward"、"backward"、"input"和"output",表示仅保存dump的数据中文件名包含"forward"、"backward"、"input"和"output"的前向、反向、输入或输出的dump文件。配置示例"data_mode": ["backward"]或"data_mode": ["forward", "backward"]。默认为["all"],即保存所有dump的数据。除了all参数只能单独配置外,其他参数可以自由组合。<br/>MindSpore
|
|
79
|
-
| file_format | MindSpore
|
|
105
|
+
| data_mode | dump数据过滤,str类型。可取值"all"、"forward"、"backward"、"input"和"output",表示仅保存dump的数据中文件名包含"forward"、"backward"、"input"和"output"的前向、反向、输入或输出的dump文件。配置示例"data_mode": ["backward"]或"data_mode": ["forward", "backward"]。默认为["all"],即保存所有dump的数据。除了all参数只能单独配置外,其他参数可以自由组合。<br/>MindSpore静态图场景仅支持"all"、"input"和"output"参数,且各参数只能单独配置,不支持自由组合。 | 否 |
|
|
106
|
+
| file_format | MindSpore静态图场景真实tensor数据的保存格式,str类型,可取值"bin"(dump的tensor文件为二进制格式,"level": "L1"时不支持)、"npy"(dump的tensor文件后缀为.npy,默认值)。 | 否 |
|
|
107
|
+
| online_run_ut | 在线预检模式开关,bool类型,可取值true(开启)、false(关闭),默认未配置,表示关闭。配置为true表示开启在线预检。 | 否 |
|
|
108
|
+
| nfs_path | 在线预检模式共享存储目录路径,str类型,用于GPU设备和NPU设备间进行通信。仅在online_run_ut字段配置为true时生效,未配置该参数后host和port不生效。 | 否 |
|
|
109
|
+
| host | 在线预检模式局域网场景信息接收端IP,str类型,用于GPU设备和NPU设备间进行通信,NPU侧须配置为GPU侧的局域网IP地址。仅在online_run_ut字段配置为true时生效,局域网场景时,不能配置nfs_path参数,否则局域网场景不生效。 | 否 |
|
|
110
|
+
| port | 在线预检模式局域网场景信息接收端端口号,int类型,用于GPU设备和NPU设备间进行通信,NPU侧须配置为GPU侧的端口号。仅在online_run_ut字段配置为true时生效,局域网场景时,不能配置nfs_path参数,否则局域网场景不生效。 | 否 |
|
|
111
|
+
|
|
112
|
+
说明: online_run_ut、nfs_path、host、port参数仅在线预检场景NPU环境生效,详细说明请参见[《在线精度预检》](../pytorch/doc/api_accuracy_checker_online.md)。
|
|
80
113
|
|
|
81
114
|
### task配置为overflow_check
|
|
82
115
|
|
|
116
|
+
MindSpore静态图场景的jit_level为O0/O1时,不支持该功能,须配置jit_level为O2。请参见[mindspore.set_context](https://www.mindspore.cn/docs/zh-CN/r2.3.0/api_python/mindspore/mindspore.JitConfig.html#mindspore-jitconfig)配置jit_config。
|
|
117
|
+
|
|
83
118
|
| 参数名 | 说明 | 是否必选 |
|
|
84
119
|
| ------------- | ------------------------------------------------------------ | -------- |
|
|
85
|
-
| overflow_nums | 控制溢出次数,int类型,仅PyTorch场景支持,表示第N次溢出时,停止训练,过程中检测到溢出API对应kernel数据均dump。配置示例:"overflow_nums": 3。默认为1,即检测到1次溢出,训练停止,配置为-1时,表示持续检测溢出直到训练结束。 | 否 |
|
|
86
|
-
| check_mode | MindSpore
|
|
120
|
+
| overflow_nums | 控制溢出次数,int类型,仅MindSpore动态图和PyTorch场景支持,表示第N次溢出时,停止训练,过程中检测到溢出API对应kernel数据均dump。配置示例:"overflow_nums": 3。默认为1,即检测到1次溢出,训练停止,配置为-1时,表示持续检测溢出直到训练结束。 | 否 |
|
|
121
|
+
| check_mode | MindSpore静态图场景kernel级别的溢出检测,str类型,可取值"aicore"(开启AI Core的溢出检测)、"atomic"(开启Atomic的溢出检测)、"all"(开启AI Core和Atomic的溢出检测,默认值)。配置示例"check_mode": "aicore"。 | 否 |
|
|
122
|
+
|
|
123
|
+
### task配置为run_ut
|
|
124
|
+
|
|
125
|
+
仅PyTorch场景支持。
|
|
126
|
+
|
|
127
|
+
| 参数名称 | 说明 | 是否必选 |
|
|
128
|
+
|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------------|------|
|
|
129
|
+
| white_list | API dump白名单,仅对指定的API进行dump。配置示例:"white_list": ["conv1d", "conv2d"]。默认未配置白名单,即dump全量API数据。 | 否 |
|
|
130
|
+
| black_list | API dump黑名单,被指定的API不进行dump。配置示例:"black_list": ["conv1d", "conv2d"]。默认未配置黑名单,即dump全量API数据。 | 否 |
|
|
131
|
+
| error_data_path | 配置保存精度未达标的API输入输出数据路径,默认为当前路径。配置示例"error_data_path": "./"。 | 否 |
|
|
132
|
+
| is_online | 在线预检模式开关,bool类型,可取值true(开启)、false(关闭),默认关闭。 | 否 |
|
|
133
|
+
| nfs_path | 在线预检模式共享存储目录路径,str类型,用于GPU设备和NPU设备间进行通信。配置该参数后host和port不生效,仅在is_online字段配置为true时生效。 | 否 |
|
|
134
|
+
| host | 在线预检模式局域网场景信息接收端IP,str类型,用于GPU设备和NPU设备间进行通信,GPU侧配置为本机地址127.0.0.1或本机局域网IP。局域网场景时,不能配置nfs_path参数,否则局域网场景不生效。仅在is_online字段配置为true时生效。 | 否 |
|
|
135
|
+
| port | 在线预检模式局域网场景信息接收端端口号,int类型,用于GPU设备和NPU设备间进行通信,GPU侧配置为本机可用端口。局域网场景时,不能配置nfs_path参数,否则局域网场景不生效。仅在is_online字段配置为true时生效。 | 否 |
|
|
136
|
+
| rank_list | 指定在线预检的Rank ID,默认值为[0],list[int]类型,应配置为大于等于0的整数,且须根据实际卡的Rank ID配置,若所配置的值大于实际训练所运行的卡的Rank ID,则在线预检输出数据为空。GPU和NPU须配置一致。仅在is_online字段配置为true时生效。 | 否 |
|
|
137
|
+
|
|
138
|
+
说明:
|
|
139
|
+
<br>(1)white_list和black_list同时配置时,二者配置的API名单若无交集,则白名单生效,若API名单存在交集,则白名单排除的部分以及交集的API不进行dump。
|
|
140
|
+
<br>(2)is_online、nfs_path、host、port、rank_list等字段仅在线预检场景GPU机器生效,详细说明见[《在线精度预检》](../pytorch/doc/api_accuracy_checker_online.md)
|
|
87
141
|
|
|
88
142
|
## 配置示例
|
|
89
143
|
|
|
@@ -180,17 +234,36 @@ task配置为free_benchmark时,开启**无标杆比对**,在NPU环境下通
|
|
|
180
234
|
}
|
|
181
235
|
```
|
|
182
236
|
|
|
183
|
-
###
|
|
237
|
+
### PyTorch场景task配置为run_ut
|
|
184
238
|
|
|
185
239
|
```json
|
|
186
240
|
{
|
|
187
|
-
"task": "
|
|
241
|
+
"task": "run_ut",
|
|
188
242
|
"dump_path": "/home/data_dump",
|
|
189
243
|
"rank": [],
|
|
190
244
|
"step": [],
|
|
191
245
|
"level": "L1",
|
|
192
246
|
"seed": 1234,
|
|
193
247
|
"is_deterministic": false,
|
|
248
|
+
"enable_dataloader": false,
|
|
249
|
+
|
|
250
|
+
"run_ut": {
|
|
251
|
+
"white_list": [],
|
|
252
|
+
"black_list": [],
|
|
253
|
+
"error_data_path": "./"
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### MindSpore静态图场景task配置为statistics
|
|
259
|
+
|
|
260
|
+
```json
|
|
261
|
+
{
|
|
262
|
+
"task": "statistics",
|
|
263
|
+
"dump_path": "/home/data_dump",
|
|
264
|
+
"rank": [],
|
|
265
|
+
"step": [],
|
|
266
|
+
"level": "L2",
|
|
194
267
|
|
|
195
268
|
"statistics": {
|
|
196
269
|
"list": [],
|
|
@@ -200,7 +273,7 @@ task配置为free_benchmark时,开启**无标杆比对**,在NPU环境下通
|
|
|
200
273
|
}
|
|
201
274
|
```
|
|
202
275
|
|
|
203
|
-
### MindSpore
|
|
276
|
+
### MindSpore静态图场景task配置为tensor
|
|
204
277
|
|
|
205
278
|
```json
|
|
206
279
|
{
|
|
@@ -208,9 +281,7 @@ task配置为free_benchmark时,开启**无标杆比对**,在NPU环境下通
|
|
|
208
281
|
"dump_path": "/home/data_dump",
|
|
209
282
|
"rank": [],
|
|
210
283
|
"step": [],
|
|
211
|
-
"level": "
|
|
212
|
-
"seed": 1234,
|
|
213
|
-
"is_deterministic": false,
|
|
284
|
+
"level": "L2",
|
|
214
285
|
|
|
215
286
|
"tensor": {
|
|
216
287
|
"list":[],
|
|
@@ -220,7 +291,7 @@ task配置为free_benchmark时,开启**无标杆比对**,在NPU环境下通
|
|
|
220
291
|
}
|
|
221
292
|
```
|
|
222
293
|
|
|
223
|
-
### MindSpore
|
|
294
|
+
### MindSpore静态图场景task配置为overflow_check
|
|
224
295
|
|
|
225
296
|
```json
|
|
226
297
|
{
|
|
@@ -228,17 +299,88 @@ task配置为free_benchmark时,开启**无标杆比对**,在NPU环境下通
|
|
|
228
299
|
"dump_path": "/home/data_dump",
|
|
229
300
|
"rank": [],
|
|
230
301
|
"step": [],
|
|
231
|
-
"level": "
|
|
232
|
-
"seed": 1234,
|
|
233
|
-
"is_deterministic": false,
|
|
302
|
+
"level": "L2",
|
|
234
303
|
|
|
235
304
|
"overflow_check": {
|
|
236
|
-
"overflow_nums": 1,
|
|
237
305
|
"check_mode": "all"
|
|
238
306
|
}
|
|
239
307
|
}
|
|
240
308
|
```
|
|
241
309
|
|
|
310
|
+
### MindSpore动态图场景task配置为free_benchmark
|
|
311
|
+
|
|
312
|
+
```json
|
|
313
|
+
{
|
|
314
|
+
"task": "free_benchmark",
|
|
315
|
+
"dump_path": "/home/data_dump",
|
|
316
|
+
"rank": [],
|
|
317
|
+
"step": [],
|
|
318
|
+
"level": "L1",
|
|
319
|
+
|
|
320
|
+
"free_benchmark": {
|
|
321
|
+
"list": ["mindspore.ops.add"],
|
|
322
|
+
"fuzz_device": "npu",
|
|
323
|
+
"pert_mode": "improve_precision",
|
|
324
|
+
"handler_type": "check",
|
|
325
|
+
"fuzz_level": "L1",
|
|
326
|
+
"fuzz_stage": "forward"
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### MindSpore动态图场景task配置为statistics
|
|
332
|
+
|
|
333
|
+
```json
|
|
334
|
+
{
|
|
335
|
+
"task": "statistics",
|
|
336
|
+
"dump_path": "/home/data_dump",
|
|
337
|
+
"rank": [],
|
|
338
|
+
"step": [],
|
|
339
|
+
"level": "L1",
|
|
340
|
+
|
|
341
|
+
"statistics": {
|
|
342
|
+
"scope": [],
|
|
343
|
+
"list": [],
|
|
344
|
+
"data_mode": ["all"],
|
|
345
|
+
"summary_mode": "statistics"
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### MindSpore动态图场景task配置为tensor
|
|
351
|
+
|
|
352
|
+
```json
|
|
353
|
+
{
|
|
354
|
+
"task": "tensor",
|
|
355
|
+
"dump_path": "/home/data_dump",
|
|
356
|
+
"rank": [],
|
|
357
|
+
"step": [],
|
|
358
|
+
"level": "L1",
|
|
359
|
+
|
|
360
|
+
"tensor": {
|
|
361
|
+
"scope": [],
|
|
362
|
+
"list":[],
|
|
363
|
+
"data_mode": ["all"],
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### MindSpore动态图场景task配置为overflow_check
|
|
369
|
+
|
|
370
|
+
```json
|
|
371
|
+
{
|
|
372
|
+
"task": "overflow_check",
|
|
373
|
+
"dump_path": "/home/data_dump",
|
|
374
|
+
"rank": [],
|
|
375
|
+
"step": [],
|
|
376
|
+
"level": "L1",
|
|
377
|
+
|
|
378
|
+
"overflow_check": {
|
|
379
|
+
"overflow_nums": 1
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
```
|
|
383
|
+
|
|
242
384
|
## 附录
|
|
243
385
|
|
|
244
386
|
### 模块级精度数据dump说明
|
|
@@ -255,7 +397,7 @@ task配置为free_benchmark时,开启**无标杆比对**,在NPU环境下通
|
|
|
255
397
|
|
|
256
398
|
#### [config.json](./config.json)配置示例
|
|
257
399
|
|
|
258
|
-
当level取"L2"时,须配置acl_config参数,并指定acl_config.json文件(用于指定L2 kernel级dump的配置),此时config.json文件配置示例如下:
|
|
400
|
+
当PyTorch场景level取"L2"时,须配置acl_config参数,并指定acl_config.json文件(用于指定L2 kernel级dump的配置),此时config.json文件配置示例如下:
|
|
259
401
|
|
|
260
402
|
- 前向kernel dump配置示例:
|
|
261
403
|
|
|
@@ -326,13 +468,13 @@ acl_config.json文件须自行创建,配置示例如下:
|
|
|
326
468
|
| 字段名 | 说明 |
|
|
327
469
|
| -------------- | ------------------------------------------------------------ |
|
|
328
470
|
| dump_list | 待dump数据的API模型。为空,无需配置。 |
|
|
329
|
-
| dump_path | dump
|
|
471
|
+
| dump_path | dump数据文件存储到运行环境的目录,主要配置的是kernel级数据的存放路径。支持配置绝对路径或相对路径。dump_path须为已存在目录。 |
|
|
330
472
|
| dump_mode | dump数据模式,配置如下: output:dump API的输出数据。默认值。 input:dump API的输入数据。 all:dump API的输入、输出数据。 |
|
|
331
473
|
| dump_op_switch | 单API模型dump数据开关,配置如下:<br> off:关闭单API模型dump,默认值。<br> on:开启单API模型dump。 |
|
|
332
474
|
|
|
333
475
|
**dump目录说明**
|
|
334
476
|
|
|
335
|
-
配置
|
|
477
|
+
配置acl_config.json后,采集的kernel级数据会在{dump_path}/{time}/{deviceid}/{model_id}目录下生成,例如“/home/HwHiAiUser/output/20200808163566/0/0”
|
|
336
478
|
|
|
337
479
|
```
|
|
338
480
|
├── 20230131172437
|
msprobe/config/config.json
CHANGED
|
@@ -24,5 +24,27 @@
|
|
|
24
24
|
"overflow_check": {
|
|
25
25
|
"overflow_nums": 1,
|
|
26
26
|
"check_mode":"all"
|
|
27
|
+
},
|
|
28
|
+
"run_ut": {
|
|
29
|
+
"white_list": [],
|
|
30
|
+
"black_list": [],
|
|
31
|
+
"error_data_path": "./"
|
|
32
|
+
},
|
|
33
|
+
"grad_probe": {
|
|
34
|
+
"grad_level": "L1",
|
|
35
|
+
"param_list": [],
|
|
36
|
+
"bounds": [-1, 0, 1]
|
|
37
|
+
},
|
|
38
|
+
"free_benchmark": {
|
|
39
|
+
"scope": [],
|
|
40
|
+
"list": [],
|
|
41
|
+
"fuzz_device": "npu",
|
|
42
|
+
"pert_mode": "improve_precision",
|
|
43
|
+
"handler_type": "check",
|
|
44
|
+
"fuzz_level": "L1",
|
|
45
|
+
"fuzz_stage": "forward",
|
|
46
|
+
"if_preheat": false,
|
|
47
|
+
"preheat_step": 15,
|
|
48
|
+
"max_sample": 20
|
|
27
49
|
}
|
|
28
50
|
}
|
msprobe/core/__init__.py
ADDED
|
File without changes
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
|
|
18
18
|
import os
|
|
19
19
|
|
|
20
|
-
from msprobe.
|
|
21
|
-
from msprobe.
|
|
22
|
-
from msprobe.
|
|
20
|
+
from msprobe.core.advisor.advisor_result import AdvisorResult
|
|
21
|
+
from msprobe.core.advisor.advisor_const import AdvisorConst
|
|
22
|
+
from msprobe.core.common.log import logger
|
|
23
23
|
from msprobe.core.common.utils import CompareException
|
|
24
24
|
from msprobe.core.common.file_check import FileChecker
|
|
25
25
|
from msprobe.core.common.const import Const, CompareConst, FileCheckConst
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
import os
|
|
18
18
|
import time
|
|
19
19
|
|
|
20
|
-
from msprobe.
|
|
21
|
-
from msprobe.
|
|
20
|
+
from msprobe.core.advisor.advisor_const import AdvisorConst
|
|
21
|
+
from msprobe.core.common.log import logger
|
|
22
22
|
from msprobe.core.common.const import Const, FileCheckConst
|
|
23
23
|
from msprobe.core.common.file_check import change_mode
|
|
24
24
|
|
msprobe/core/common/const.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import stat
|
|
3
|
+
|
|
3
4
|
import numpy as np
|
|
4
5
|
|
|
6
|
+
|
|
5
7
|
class Const:
|
|
6
8
|
"""
|
|
7
9
|
Class for const
|
|
@@ -15,6 +17,12 @@ class Const:
|
|
|
15
17
|
OFF = 'OFF'
|
|
16
18
|
BACKWARD = 'backward'
|
|
17
19
|
FORWARD = 'forward'
|
|
20
|
+
PRIMITIVE_PREFIX = 'Primitive'
|
|
21
|
+
DEFAULT_LIST = []
|
|
22
|
+
DEFAULT_PATH = './'
|
|
23
|
+
WHITE_LIST = 'white_list'
|
|
24
|
+
BLACK_LIST = 'black_list'
|
|
25
|
+
DUMP_TENSOR_DATA = 'dump_tensor_data'
|
|
18
26
|
|
|
19
27
|
# dump mode
|
|
20
28
|
ALL = "all"
|
|
@@ -25,6 +33,8 @@ class Const:
|
|
|
25
33
|
API_LIST = "api_list"
|
|
26
34
|
API_STACK = "api_stack"
|
|
27
35
|
DUMP_MODE = [ALL, LIST, RANGE, STACK, ACL, API_LIST, API_STACK]
|
|
36
|
+
AUTO = "auto"
|
|
37
|
+
ONLINE_DUMP_MODE = [ALL, LIST, AUTO, OFF]
|
|
28
38
|
SUMMARY = "summary"
|
|
29
39
|
MD5 = "md5"
|
|
30
40
|
SUMMARY_MODE = [ALL, SUMMARY, MD5]
|
|
@@ -35,8 +45,10 @@ class Const:
|
|
|
35
45
|
|
|
36
46
|
PKL_SUFFIX = ".pkl"
|
|
37
47
|
NUMPY_SUFFIX = ".npy"
|
|
48
|
+
PT_SUFFIX = ".pt"
|
|
38
49
|
ONE_GB = 1073741824 # 1 * 1024 * 1024 * 1024
|
|
39
50
|
TEN_GB = 10737418240 # 10 * 1024 * 1024 * 1024
|
|
51
|
+
ONE_MB = 1048576 # 1 * 1024 * 1024
|
|
40
52
|
FILE_PATTERN = r'^[a-zA-Z0-9_./-]+$'
|
|
41
53
|
DISTRIBUTED_PREFIX_LENGTH = 60
|
|
42
54
|
# env dump path
|
|
@@ -52,13 +64,20 @@ class Const:
|
|
|
52
64
|
ENV_ENABLE = "1"
|
|
53
65
|
ENV_DISABLE = "0"
|
|
54
66
|
MAX_SEED_VALUE = 4294967295 # 2**32 - 1
|
|
55
|
-
TASK_LIST = ["tensor", "statistics", "overflow_check", "free_benchmark"]
|
|
56
|
-
LEVEL_LIST = ["L0", "L1", "L2", "mix"]
|
|
57
67
|
STATISTICS = "statistics"
|
|
58
68
|
TENSOR = "tensor"
|
|
59
69
|
OVERFLOW_CHECK = "overflow_check"
|
|
60
70
|
FREE_BENCHMARK = "free_benchmark"
|
|
71
|
+
RUN_UT = "run_ut"
|
|
72
|
+
GRAD_PROBE = "grad_probe"
|
|
73
|
+
TASK_LIST = [TENSOR, STATISTICS, OVERFLOW_CHECK, FREE_BENCHMARK, RUN_UT, GRAD_PROBE]
|
|
74
|
+
LEVEL_L0 = "L0"
|
|
75
|
+
LEVEL_L1 = "L1"
|
|
76
|
+
LEVEL_L2 = "L2"
|
|
77
|
+
LEVEL_MIX = "mix"
|
|
78
|
+
LEVEL_LIST = [LEVEL_L0, LEVEL_L1, LEVEL_L2, LEVEL_MIX]
|
|
61
79
|
ATTR_NAME_PREFIX = "wrap_"
|
|
80
|
+
ATTR_NAME_PREFIX_LEN = len(ATTR_NAME_PREFIX)
|
|
62
81
|
KERNEL_DUMP = "kernel_dump"
|
|
63
82
|
DATA = "data"
|
|
64
83
|
PT_FRAMEWORK = "pytorch"
|
|
@@ -70,12 +89,12 @@ class Const:
|
|
|
70
89
|
INT_TYPE = [np.int32, np.int64]
|
|
71
90
|
NPU = 'NPU'
|
|
72
91
|
DISTRIBUTED = 'Distributed'
|
|
73
|
-
|
|
92
|
+
|
|
74
93
|
INPLACE_LIST = [
|
|
75
94
|
"broadcast", "all_reduce", "reduce", "all_gather", "gather", "scatter", "reduce_scatter",
|
|
76
|
-
"_reduce_scatter_base", "_all_gather_base", "send", "recv", "irecv", "isend", "all_to_all_single"
|
|
95
|
+
"_reduce_scatter_base", "_all_gather_base", "send", "recv", "irecv", "isend", "all_to_all_single", "all_to_all"
|
|
77
96
|
]
|
|
78
|
-
|
|
97
|
+
|
|
79
98
|
CONVERT = {
|
|
80
99
|
"int32_to_int64": ["torch.int32", "torch.int64"],
|
|
81
100
|
}
|
|
@@ -84,6 +103,7 @@ class Const:
|
|
|
84
103
|
"int32_to_int64": ["cross_entropy"]
|
|
85
104
|
}
|
|
86
105
|
|
|
106
|
+
|
|
87
107
|
class CompareConst:
|
|
88
108
|
"""
|
|
89
109
|
Class for compare module const
|
|
@@ -123,6 +143,7 @@ class CompareConst:
|
|
|
123
143
|
NPU_MD5 = "NPU MD5"
|
|
124
144
|
BENCH_MD5 = "BENCH MD5"
|
|
125
145
|
RESULT = "Result"
|
|
146
|
+
MAGNITUDE = 0.5
|
|
126
147
|
|
|
127
148
|
COMPARE_RESULT_HEADER = [
|
|
128
149
|
NPU_NAME, BENCH_NAME, NPU_DTYPE, BENCH_DTYPE, NPU_SHAPE, BENCH_SHAPE, COSINE, MAX_ABS_ERR, MAX_RELATIVE_ERR,
|
|
@@ -160,6 +181,7 @@ class CompareConst:
|
|
|
160
181
|
WARNING = 'Warning'
|
|
161
182
|
ERROR = 'error'
|
|
162
183
|
SKIP = 'SKIP'
|
|
184
|
+
N_A = 'N/A'
|
|
163
185
|
BFLOAT16_MIN = -3.3895313892515355e+38
|
|
164
186
|
BFLOAT16_MAX = 3.3895313892515355e+38
|
|
165
187
|
BFLOAT16_EPS = 3.90625e-3 # 2 ** -8
|
|
@@ -167,6 +189,7 @@ class CompareConst:
|
|
|
167
189
|
# accuracy standards
|
|
168
190
|
COS_THRESHOLD = 0.99
|
|
169
191
|
MAX_ABS_ERR_THRESHOLD = 0.001
|
|
192
|
+
MAX_RELATIVE_ERR_THRESHOLD = 0.001
|
|
170
193
|
COS_MAX_THRESHOLD = 0.9
|
|
171
194
|
MAX_ABS_ERR_MAX_THRESHOLD = 1
|
|
172
195
|
ACCURACY_CHECK_YES = "Yes"
|
|
@@ -195,6 +218,20 @@ class CompareConst:
|
|
|
195
218
|
MAX_RELATIVE_OUT_RED = 0.5
|
|
196
219
|
MAX_RELATIVE_OUT_YELLOW = 0.1
|
|
197
220
|
MAX_RELATIVE_IN_YELLOW = 0.01
|
|
221
|
+
MS_GRAPH_BASE = {
|
|
222
|
+
NPU_NAME: None, BENCH_NAME: None, NPU_DTYPE: None, BENCH_DTYPE: None, NPU_SHAPE: None, BENCH_SHAPE: None,
|
|
223
|
+
NPU_MAX: None, NPU_MIN: None, NPU_MEAN: None, NPU_NORM: None, BENCH_MAX: None, BENCH_MIN: None,
|
|
224
|
+
BENCH_MEAN: None, BENCH_NORM: None, ACCURACY: '', ERROR_MESSAGE: ''
|
|
225
|
+
}
|
|
226
|
+
MS_GRAPH_NPY = {
|
|
227
|
+
COSINE: None, MAX_ABS_ERR: None, MAX_RELATIVE_ERR: None, ONE_THOUSANDTH_ERR_RATIO: None,
|
|
228
|
+
FIVE_THOUSANDTHS_ERR_RATIO: None
|
|
229
|
+
}
|
|
230
|
+
MS_GRAPH_STATISTIC = {
|
|
231
|
+
MAX_DIFF: None, MIN_DIFF: None, MEAN_DIFF: None, NORM_DIFF: None, MAX_RELATIVE_ERR: None,
|
|
232
|
+
MIN_RELATIVE_ERR: None, MEAN_RELATIVE_ERR: None, NORM_RELATIVE_ERR: None
|
|
233
|
+
}
|
|
234
|
+
|
|
198
235
|
|
|
199
236
|
class FileCheckConst:
|
|
200
237
|
"""
|
|
@@ -232,6 +269,7 @@ class FileCheckConst:
|
|
|
232
269
|
YAML_SUFFIX: MAX_YAML_SIZE
|
|
233
270
|
}
|
|
234
271
|
|
|
272
|
+
|
|
235
273
|
class OverflowConst:
|
|
236
274
|
"""
|
|
237
275
|
Class for Overflow
|
|
@@ -239,3 +277,42 @@ class OverflowConst:
|
|
|
239
277
|
OVERFLOW_DEBUG_MODE_ENABLE = "OVERFLOW_DEBUG_MODE_ENABLE"
|
|
240
278
|
OVERFLOW_ORIGINAL_MODE = 0
|
|
241
279
|
OVERFLOW_DEBUG_MODE = 1
|
|
280
|
+
|
|
281
|
+
class MsCompareConst:
|
|
282
|
+
# api_info field
|
|
283
|
+
MINT = "Mint"
|
|
284
|
+
MINT_FUNCTIONAL = "MintFunctional"
|
|
285
|
+
|
|
286
|
+
TASK_FIELD = "task"
|
|
287
|
+
STATISTICS_TASK = "statistics"
|
|
288
|
+
TENSOR_TASK = "tensor"
|
|
289
|
+
DUMP_DATA_DIR_FIELD = "dump_data_dir"
|
|
290
|
+
DATA_FIELD = "data"
|
|
291
|
+
|
|
292
|
+
#detail_csv
|
|
293
|
+
DETAIL_CSV_API_NAME = "API Name"
|
|
294
|
+
DETAIL_CSV_BENCH_DTYPE = "Bench Dtype"
|
|
295
|
+
DETAIL_CSV_TESTED_DTYPE = "Tested Dtype"
|
|
296
|
+
DETAIL_CSV_SHAPE = "Shape"
|
|
297
|
+
DETAIL_CSV_PASS_STATUS = "Status"
|
|
298
|
+
DETAIL_CSV_MESSAGE = "Message"
|
|
299
|
+
DETAIL_CSV_FILE_NAME = "accuracy_checking_details"
|
|
300
|
+
|
|
301
|
+
#result_csv
|
|
302
|
+
RESULT_CSV_FORWARD_TEST_SUCCESS = "Forward Test Success"
|
|
303
|
+
RESULT_CSV_BACKWARD_TEST_SUCCESS = "Backward Test Success"
|
|
304
|
+
RESULT_CSV_FILE_NAME = "accuracy_checking_result"
|
|
305
|
+
|
|
306
|
+
EPSILON = 1e-8
|
|
307
|
+
|
|
308
|
+
class MsgConst:
|
|
309
|
+
"""
|
|
310
|
+
Class for log messages const
|
|
311
|
+
"""
|
|
312
|
+
SPECIAL_CHAR = ["\n", "\r", "\u007F", "\b", "\f", "\t", "\u000B", "%08", "%0a", "%0b", "%0c", "%0d", "%7f"]
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
class GraphMode:
|
|
316
|
+
NPY_MODE = "NPY_MODE"
|
|
317
|
+
STATISTIC_MODE = "STATISTIC_MODE"
|
|
318
|
+
ERROR_MODE = "ERROR_MODE"
|