mindstudio-probe 1.0.3__py3-none-any.whl → 1.0.4__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.3.dist-info → mindstudio_probe-1.0.4.dist-info}/LICENSE +201 -201
- {mindstudio_probe-1.0.3.dist-info → mindstudio_probe-1.0.4.dist-info}/METADATA +36 -34
- mindstudio_probe-1.0.4.dist-info/RECORD +276 -0
- {mindstudio_probe-1.0.3.dist-info → mindstudio_probe-1.0.4.dist-info}/WHEEL +1 -1
- {mindstudio_probe-1.0.3.dist-info → mindstudio_probe-1.0.4.dist-info}/entry_points.txt +1 -0
- msprobe/README.md +101 -237
- msprobe/{config/config.json → config.json} +49 -49
- msprobe/core/advisor/advisor.py +124 -124
- msprobe/core/advisor/advisor_const.py +59 -59
- msprobe/core/advisor/advisor_result.py +58 -58
- msprobe/core/common/const.py +341 -318
- msprobe/core/common/exceptions.py +99 -99
- msprobe/core/common/{file_check.py → file_utils.py} +478 -283
- msprobe/core/common/log.py +76 -69
- msprobe/core/common/utils.py +385 -616
- msprobe/core/common_config.py +85 -71
- msprobe/core/compare/acc_compare.py +299 -298
- msprobe/core/compare/check.py +95 -95
- msprobe/core/compare/compare_cli.py +49 -49
- msprobe/core/compare/highlight.py +223 -222
- msprobe/core/compare/multiprocessing_compute.py +149 -149
- msprobe/core/compare/npy_compare.py +295 -295
- msprobe/core/compare/utils.py +430 -429
- msprobe/core/data_dump/data_collector.py +154 -144
- msprobe/core/data_dump/data_processor/base.py +314 -293
- msprobe/core/data_dump/data_processor/factory.py +59 -59
- msprobe/core/data_dump/data_processor/mindspore_processor.py +186 -198
- msprobe/core/data_dump/data_processor/pytorch_processor.py +366 -389
- msprobe/core/data_dump/json_writer.py +96 -116
- msprobe/core/data_dump/scope.py +178 -178
- msprobe/core/grad_probe/constant.py +70 -70
- msprobe/core/grad_probe/grad_compare.py +171 -175
- msprobe/core/grad_probe/utils.py +64 -52
- msprobe/docs/01.installation.md +89 -0
- msprobe/docs/02.config_introduction.md +165 -0
- msprobe/docs/03.config_examples.md +247 -0
- msprobe/docs/04.acl_config_examples.md +76 -0
- msprobe/docs/05.data_dump_PyTorch.md +198 -0
- msprobe/docs/06.data_dump_MindSpore.md +243 -0
- msprobe/docs/07.accuracy_checker_PyTorch.md +274 -0
- msprobe/docs/08.accuracy_checker_online_PyTorch.md +198 -0
- msprobe/docs/09.accuracy_checker_MindSpore.md +68 -0
- msprobe/docs/10.accuracy_compare_PyTorch.md +245 -0
- msprobe/docs/11.accuracy_compare_MindSpore.md +202 -0
- msprobe/docs/12.overflow_check_PyTorch.md +79 -0
- msprobe/docs/13.overflow_check_MindSpore.md +31 -0
- msprobe/{pytorch/doc/parse_tool.md → docs/14.data_parse_PyTorch.md} +283 -286
- msprobe/docs/15.free_benchmarking_PyTorch.md +164 -0
- msprobe/{doc/grad_probe/grad_probe.md → docs/17.grad_probe.md} +207 -207
- msprobe/docs/FAQ_PyTorch.md +177 -0
- msprobe/docs/S02.report_free_benchmarking_validation_performance_baseline.md +146 -0
- msprobe/docs/img/free_benchmark_framework.png +0 -0
- msprobe/mindspore/__init__.py +1 -1
- msprobe/mindspore/api_accuracy_checker/api_accuracy_checker.py +254 -245
- msprobe/mindspore/api_accuracy_checker/api_info.py +69 -69
- msprobe/mindspore/api_accuracy_checker/api_runner.py +155 -151
- msprobe/mindspore/api_accuracy_checker/base_compare_algorithm.py +196 -196
- msprobe/mindspore/api_accuracy_checker/cmd_parser.py +6 -0
- msprobe/mindspore/api_accuracy_checker/compute_element.py +238 -223
- msprobe/mindspore/api_accuracy_checker/main.py +8 -15
- msprobe/mindspore/api_accuracy_checker/type_mapping.py +113 -113
- msprobe/mindspore/api_accuracy_checker/utils.py +79 -62
- msprobe/mindspore/cell_processor.py +34 -34
- msprobe/mindspore/common/const.py +106 -87
- msprobe/mindspore/common/log.py +37 -37
- msprobe/mindspore/common/utils.py +81 -57
- msprobe/mindspore/compare/distributed_compare.py +75 -75
- msprobe/mindspore/compare/ms_compare.py +219 -117
- msprobe/mindspore/compare/ms_graph_compare.py +348 -317
- msprobe/mindspore/compare/ms_to_pt_api.yaml +399 -399
- msprobe/mindspore/debugger/debugger_config.py +66 -74
- msprobe/mindspore/debugger/precision_debugger.py +126 -107
- msprobe/mindspore/dump/dump_tool_factory.py +35 -35
- msprobe/mindspore/dump/hook_cell/api_registry.py +118 -104
- msprobe/mindspore/dump/hook_cell/hook_cell.py +55 -53
- msprobe/mindspore/dump/hook_cell/support_wrap_ops.yaml +922 -925
- msprobe/mindspore/dump/hook_cell/wrap_api.py +113 -0
- msprobe/mindspore/dump/jit_dump.py +72 -56
- msprobe/mindspore/dump/kernel_graph_dump.py +59 -60
- msprobe/mindspore/dump/kernel_kbyk_dump.py +64 -65
- msprobe/mindspore/free_benchmark/api_pynative_self_check.py +116 -116
- msprobe/mindspore/free_benchmark/common/config.py +12 -12
- msprobe/mindspore/free_benchmark/common/handler_params.py +17 -17
- msprobe/mindspore/free_benchmark/common/utils.py +71 -71
- msprobe/mindspore/free_benchmark/data/support_wrap_ops.yaml +842 -842
- msprobe/mindspore/free_benchmark/decorator/dec_forward.py +43 -42
- msprobe/mindspore/free_benchmark/decorator/decorator_factory.py +107 -107
- msprobe/mindspore/free_benchmark/handler/base_handler.py +90 -90
- msprobe/mindspore/free_benchmark/handler/check_handler.py +41 -41
- msprobe/mindspore/free_benchmark/handler/fix_handler.py +36 -36
- msprobe/mindspore/free_benchmark/handler/handler_factory.py +21 -21
- msprobe/mindspore/free_benchmark/perturbation/add_noise.py +67 -67
- msprobe/mindspore/free_benchmark/perturbation/base_perturbation.py +21 -21
- msprobe/mindspore/free_benchmark/perturbation/bit_noise.py +63 -63
- msprobe/mindspore/free_benchmark/perturbation/exchange_value.py +51 -0
- msprobe/mindspore/free_benchmark/perturbation/improve_precision.py +35 -34
- msprobe/mindspore/free_benchmark/perturbation/no_change.py +12 -12
- msprobe/mindspore/free_benchmark/perturbation/perturbation_factory.py +29 -27
- msprobe/mindspore/free_benchmark/self_check_tool_factory.py +33 -33
- msprobe/mindspore/grad_probe/global_context.py +90 -91
- msprobe/mindspore/grad_probe/grad_analyzer.py +231 -231
- msprobe/mindspore/grad_probe/grad_monitor.py +27 -27
- msprobe/mindspore/grad_probe/grad_stat_csv.py +131 -131
- msprobe/mindspore/grad_probe/hook.py +94 -92
- msprobe/mindspore/grad_probe/utils.py +29 -28
- msprobe/mindspore/ms_config.py +128 -126
- msprobe/mindspore/overflow_check/kernel_graph_overflow_check.py +44 -45
- msprobe/mindspore/overflow_check/overflow_check_tool_factory.py +34 -34
- msprobe/mindspore/runtime.py +4 -4
- msprobe/mindspore/service.py +378 -354
- msprobe/mindspore/task_handler_factory.py +24 -24
- msprobe/msprobe.py +105 -107
- msprobe/pytorch/__init__.py +3 -3
- msprobe/pytorch/api_accuracy_checker/common/config.py +53 -55
- msprobe/pytorch/api_accuracy_checker/common/utils.py +214 -165
- msprobe/pytorch/api_accuracy_checker/compare/algorithm.py +213 -213
- msprobe/pytorch/api_accuracy_checker/compare/api_precision_compare.py +606 -581
- msprobe/pytorch/api_accuracy_checker/compare/api_precision_standard.yaml +132 -132
- msprobe/pytorch/api_accuracy_checker/compare/api_precision_threshold.yaml +390 -390
- msprobe/pytorch/api_accuracy_checker/compare/compare.py +386 -381
- msprobe/pytorch/api_accuracy_checker/compare/compare_column.py +73 -73
- msprobe/pytorch/api_accuracy_checker/compare/compare_utils.py +245 -244
- msprobe/pytorch/api_accuracy_checker/config.yaml +10 -10
- msprobe/pytorch/api_accuracy_checker/run_ut/data_generate.py +335 -332
- msprobe/pytorch/api_accuracy_checker/run_ut/multi_run_ut.py +200 -199
- msprobe/pytorch/api_accuracy_checker/run_ut/run_overflow_check.py +133 -134
- msprobe/pytorch/api_accuracy_checker/run_ut/run_ut.py +592 -581
- msprobe/pytorch/api_accuracy_checker/run_ut/run_ut_utils.py +70 -74
- msprobe/pytorch/api_accuracy_checker/run_ut/torch_ut_setting.json +7 -4
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/attl.py +197 -202
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/client.py +325 -324
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/device_dispatch.py +204 -204
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/server.py +219 -218
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/ssl_config.py +10 -10
- msprobe/pytorch/bench_functions/__init__.py +15 -15
- msprobe/pytorch/bench_functions/apply_adam_w.py +28 -28
- msprobe/pytorch/bench_functions/confusion_transpose.py +19 -19
- msprobe/pytorch/bench_functions/fast_gelu.py +55 -55
- msprobe/pytorch/bench_functions/layer_norm_eval.py +6 -6
- msprobe/pytorch/bench_functions/linear.py +12 -12
- msprobe/pytorch/bench_functions/matmul_backward.py +48 -48
- msprobe/pytorch/bench_functions/npu_fusion_attention.py +509 -421
- msprobe/pytorch/bench_functions/rms_norm.py +15 -15
- msprobe/pytorch/bench_functions/rotary_mul.py +52 -52
- msprobe/pytorch/bench_functions/scaled_mask_softmax.py +26 -26
- msprobe/pytorch/bench_functions/swiglu.py +55 -55
- msprobe/pytorch/common/__init__.py +2 -2
- msprobe/pytorch/common/compare_script.template +14 -14
- msprobe/pytorch/common/log.py +20 -31
- msprobe/pytorch/common/parse_json.py +39 -39
- msprobe/pytorch/common/utils.py +305 -300
- msprobe/pytorch/compare/distributed_compare.py +66 -66
- msprobe/pytorch/compare/mapping.yaml +607 -607
- msprobe/pytorch/compare/match.py +34 -33
- msprobe/pytorch/compare/pt_compare.py +50 -40
- msprobe/pytorch/debugger/debugger_config.py +95 -95
- msprobe/pytorch/debugger/precision_debugger.py +125 -125
- msprobe/pytorch/free_benchmark/__init__.py +8 -8
- msprobe/pytorch/free_benchmark/common/constant.py +70 -70
- msprobe/pytorch/free_benchmark/common/counter.py +71 -71
- msprobe/pytorch/free_benchmark/common/enums.py +37 -37
- msprobe/pytorch/free_benchmark/common/params.py +129 -129
- msprobe/pytorch/free_benchmark/common/utils.py +102 -102
- msprobe/pytorch/free_benchmark/compare/grad_saver.py +179 -179
- msprobe/pytorch/free_benchmark/compare/single_benchmark.py +104 -104
- msprobe/pytorch/free_benchmark/main.py +105 -105
- msprobe/pytorch/free_benchmark/perturbed_layers/base_layer.py +13 -13
- msprobe/pytorch/free_benchmark/perturbed_layers/layer_factory.py +41 -41
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/add_noise.py +90 -90
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/bit_noise.py +104 -104
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/change_value.py +63 -63
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/improve_precision.py +68 -68
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/no_change.py +28 -28
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/npu_base_layser.py +45 -45
- msprobe/pytorch/free_benchmark/perturbed_layers/run_cpu.py +19 -19
- msprobe/pytorch/free_benchmark/result_handlers/base_handler.py +217 -217
- msprobe/pytorch/free_benchmark/result_handlers/check_handler.py +39 -39
- msprobe/pytorch/free_benchmark/result_handlers/fix_handler.py +23 -23
- msprobe/pytorch/free_benchmark/result_handlers/handler_factory.py +30 -30
- msprobe/pytorch/free_benchmark/result_handlers/preheat_handler.py +170 -170
- msprobe/pytorch/function_factory.py +76 -75
- msprobe/pytorch/functional/dump_module.py +39 -39
- msprobe/pytorch/grad_probe/grad_monitor.py +91 -90
- msprobe/pytorch/grad_probe/grad_stat_csv.py +128 -128
- msprobe/pytorch/hook_module/api_registry.py +161 -161
- msprobe/pytorch/hook_module/hook_module.py +120 -120
- msprobe/pytorch/hook_module/support_wrap_ops.yaml +1879 -1877
- msprobe/pytorch/hook_module/utils.py +30 -29
- msprobe/pytorch/hook_module/wrap_aten.py +110 -110
- msprobe/pytorch/hook_module/wrap_distributed.py +78 -78
- msprobe/pytorch/hook_module/wrap_functional.py +105 -105
- msprobe/pytorch/hook_module/wrap_npu_custom.py +93 -84
- msprobe/pytorch/hook_module/wrap_tensor.py +71 -71
- msprobe/pytorch/hook_module/wrap_torch.py +86 -86
- msprobe/pytorch/hook_module/wrap_vf.py +62 -62
- msprobe/pytorch/module_processer.py +138 -138
- msprobe/pytorch/online_dispatch/__init__.py +20 -20
- msprobe/pytorch/online_dispatch/compare.py +236 -236
- msprobe/pytorch/online_dispatch/dispatch.py +271 -271
- msprobe/pytorch/online_dispatch/dump_compare.py +155 -156
- msprobe/pytorch/online_dispatch/single_compare.py +391 -391
- msprobe/pytorch/online_dispatch/torch_ops_config.yaml +49 -49
- msprobe/pytorch/online_dispatch/utils.py +130 -146
- msprobe/pytorch/parse.py +4 -4
- msprobe/pytorch/parse_tool/cli.py +32 -32
- msprobe/pytorch/parse_tool/lib/compare.py +260 -271
- msprobe/pytorch/parse_tool/lib/config.py +52 -52
- msprobe/pytorch/parse_tool/lib/file_desc.py +31 -31
- msprobe/pytorch/parse_tool/lib/interactive_cli.py +102 -102
- msprobe/pytorch/parse_tool/lib/parse_exception.py +54 -54
- msprobe/pytorch/parse_tool/lib/parse_tool.py +158 -158
- msprobe/pytorch/parse_tool/lib/utils.py +316 -321
- msprobe/pytorch/parse_tool/lib/visualization.py +85 -91
- msprobe/pytorch/pt_config.py +188 -187
- msprobe/pytorch/service.py +246 -252
- mindstudio_probe-1.0.3.dist-info/RECORD +0 -272
- msprobe/config/README.md +0 -539
- msprobe/mindspore/doc/compare.md +0 -58
- msprobe/mindspore/doc/dump.md +0 -217
- msprobe/mindspore/dump/hook_cell/wrap_functional.py +0 -91
- msprobe/mindspore/dump/hook_cell/wrap_tensor.py +0 -63
- msprobe/pytorch/doc/FAQ.md +0 -193
- msprobe/pytorch/doc/api_accuracy_checker.md +0 -313
- msprobe/pytorch/doc/api_accuracy_checker_online.md +0 -187
- msprobe/pytorch/doc/dump.md +0 -260
- msprobe/pytorch/doc/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 -182
- msprobe/pytorch/doc/ptdbg_ascend_compare.md +0 -240
- msprobe/pytorch/doc/ptdbg_ascend_overview.md +0 -68
- msprobe/pytorch/doc/ptdbg_ascend_quickstart.md +0 -381
- msprobe/pytorch/doc/run_overflow_check.md +0 -25
- msprobe/pytorch/doc//321/205/320/254/320/270/321/207/342/225/221/342/224/220/321/207/342/226/223/342/225/233/321/205/342/225/221/320/266/321/206/320/277/320/244/321/205/320/277/342/225/243.md +0 -90
- 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 +0 -151
- {mindstudio_probe-1.0.3.dist-info → mindstudio_probe-1.0.4.dist-info}/top_level.txt +0 -0
- /msprobe/{pytorch/doc → docs}/img/BLOOM-7B_1.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/BLOOM-7B_2.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/BLOOM-7B_3.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/BLOOM-7B_4.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/GPT-3_1.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/GPT-3_2.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/GPT-3_3.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/GPT-3_4.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/GPT-3_5.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/GPT-3_6.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/GPT-3_7.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/GPT-3_8.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/YOLOV5S_1.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/YOLOV5S_2.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/accuracy_checking_details.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/accuracy_checking_result.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/api_precision_compare_details.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/api_precision_compare_result.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/auto_analyze_log.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/compare_result_pkl.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/compare_result_pkl_md5.png.png +0 -0
- /msprobe/{pytorch/doc → docs}/img/cpu_info.png +0 -0
- /msprobe/{config → docs}/img/free_benchmark.png +0 -0
- /msprobe/{doc/grad_probe/img/image-1.png → docs/img/grad_probe_image-1.png} +0 -0
- /msprobe/{doc/grad_probe/img/image-2.png → docs/img/grad_probe_image-2.png} +0 -0
- /msprobe/{doc/grad_probe/img/image-3.png → docs/img/grad_probe_image-3.png} +0 -0
- /msprobe/{doc/grad_probe/img/image-4.png → docs/img/grad_probe_image-4.png} +0 -0
- /msprobe/{doc/grad_probe/img/image.png → docs/img/grad_probe_image.png} +0 -0
- /msprobe/{pytorch/doc → docs}/img/module_compare.png +0 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# 安装
|
|
2
|
+
|
|
3
|
+
推荐使用 [miniconda](https://docs.anaconda.com/miniconda/) 管理环境依赖。
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
conda create -n msprobe python=3.8
|
|
7
|
+
conda activate msprobe
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## 1. 从 PyPI 安装
|
|
11
|
+
```shell
|
|
12
|
+
pip install mindstudio-probe[==版本号]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 2. 下载 whl 包安装
|
|
16
|
+
|
|
17
|
+
|版本|发布日期|支持 PyTorch 版本|支持 MindSpore 版本|下载链接|校验码|
|
|
18
|
+
|:--:|:--:|:--:|:--:|:--:|:--:|
|
|
19
|
+
| 1.0.3 | 2024.08.23 | 1.11/2.0/2.1/2.2 | 2.4.0 | [mindstudio_probe-1.0.3-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/1.0/mindstudio_probe-1.0.3-py3-none-any.whl) | 7060cc141a5b98ef770cd9220995d299393f32a61938261e632c7e8b5160bef2 |
|
|
20
|
+
| 1.0.2 | 2024.08.09 | 1.11/2.0/2.1/2.2 | 2.4.0 | [mindstudio_probe-1.0.2-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/1.0/mindstudio_probe-1.0.2-py3-none-any.whl) | e4a980e5d98c426ce5ce9842520d9bc031d3b3de621c74b3d59414cc6e238e0e |
|
|
21
|
+
| 1.0.1 | 2024.07.25 | 2.0/2.1/2.2 | 2.4.0 | [mindstudio_probe-1.0.1-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/1.0/mindstudio_probe-1.0.1-py3-none-any.whl) | b699e224e4d4e3bcf9412c54fa858a1ee370f0d7a2bc69cb3f1273ac14a6dc82 |
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
sha256sum {name}.whl # 验证whl包,若校验码一致,则whl包在下载中没有受损
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install ./mindstudio_probe-{version}-py3-none-any.whl # 安装whl包
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
若覆盖安装,请在命令行末尾添加 `--force-reinstall` 参数。
|
|
33
|
+
|
|
34
|
+
## 3. 从源码安装
|
|
35
|
+
|
|
36
|
+
```shell
|
|
37
|
+
git clone https://gitee.com/ascend/mstt.git
|
|
38
|
+
cd mstt/debug/accuracy_tools
|
|
39
|
+
|
|
40
|
+
pip install setuptools wheel
|
|
41
|
+
|
|
42
|
+
python setup.py bdist_wheel
|
|
43
|
+
pip install ./dist/mindstudio_probe*.whl
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
# 查看 msprobe 工具信息
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip show mindstudio-probe
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
示例如下:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
Name: mindstudio-probe
|
|
56
|
+
Version: 1.0.x
|
|
57
|
+
Summary: Pytorch Ascend Probe Utils
|
|
58
|
+
Home-page: https://gitee.com/ascend/mstt/tree/master/debug/accuracy_tools/msprobe
|
|
59
|
+
Author: Ascend Team
|
|
60
|
+
Author-email: pmail_mindstudio@huawei.com
|
|
61
|
+
License: Apache License 2.0
|
|
62
|
+
Location: /home/xxx/miniconda3/envs/xxx/lib/python3.8/site-packages/mindstudio_probe-1.0.0-py3.8.egg
|
|
63
|
+
Requires: einops, matplotlib, numpy, openpyxl, pandas, pyOpenSSL, pyyaml, rich, tqdm, twisted, wheel
|
|
64
|
+
Required-by:
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
# Ascend 生态链接
|
|
68
|
+
|
|
69
|
+
## 1 安装 CANN 包
|
|
70
|
+
|
|
71
|
+
1.1 根据 CPU 架构和 NPU 型号选择 toolkit 和 kernal 包,可以参考 [CANN 软件安装指南](https://gitee.com/link?target=https%3A%2F%2Fwww.hiascend.com%2Fdocument%2Fdetail%2Fzh%2Fcanncommercial%2F700%2Fenvdeployment%2Finstg%2Finstg_0001.html)和[昇腾社区](https://www.hiascend.cn/developer/download/community/result?module=cann)。
|
|
72
|
+
|
|
73
|
+
1.2 运行示例
|
|
74
|
+
```bash
|
|
75
|
+
Ascend-cann-toolkit_x.x.x_linux-aarch64.run --full --install-path={cann_path}
|
|
76
|
+
Ascend-cann-kernels_x.x.x_linux.run --install --install-path={cann_path}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
1.3 配置环境变量
|
|
80
|
+
```bash
|
|
81
|
+
source {cann_path}/ascend-toolkit/set_env.sh
|
|
82
|
+
```
|
|
83
|
+
## 2 安装 PyTorch_NPU
|
|
84
|
+
|
|
85
|
+
链接:[https://gitee.com/ascend/pytorch](https://gitee.com/ascend/pytorch)。
|
|
86
|
+
|
|
87
|
+
## 3 安装 ModelLink
|
|
88
|
+
|
|
89
|
+
链接:[https://gitee.com/ascend/ModelLink](https://gitee.com/ascend/ModelLink)。
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# 配置文件介绍
|
|
2
|
+
|
|
3
|
+
- 当调用 **PrecisionDebugger** 接口执行 dump 或其他操作时,需要使用 [config.json](../config.json) 文件;当未指定 config.json 时,将使用默认配置。
|
|
4
|
+
- msprobe 成功安装后,config.json 一般位于如下目录:
|
|
5
|
+
```
|
|
6
|
+
/home/***/miniconda3/envs/***/lib/python3.8/site-packages/msprobe/
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## 1 参数介绍
|
|
10
|
+
|
|
11
|
+
### 1.1 通用配置
|
|
12
|
+
|
|
13
|
+
| 参数名 | 解释 | 是否必选 |
|
|
14
|
+
| ----------------- | ---------------- | -------- |
|
|
15
|
+
| task | dump 的任务类型,str 类型。可取值,<br/> "statistics":仅 dump API 统计信息,默认值;<br/> "tensor":dump API 统计信息和完全复刻整网的 API 运行情况的真实数据;<br/> "run_ut":精度预检,仅 PyTorch 场景支持。<br/> "overflow_check":溢出检测,仅 PyTorch 和 MindSpore 静态图场景支持;<br/> "free_benchmark":无标杆比对;<br/> 根据 task 参数取值的不同,可以配置不同场景参数,详见:<br/>[1.2 task 配置为 statistics](#12-task-配置为-statistics),<br/>[1.3 task 配置为 tensor](#13-task-配置为-tensor),<br/>[1.4 task 配置为 run_ut](#14-task-配置为-run_ut),<br/>[1.5 task 配置为 overflow_check](#15-task-配置为-overflow_check),<br/>[1.6 task 配置为 free_benchmark](#16-task-配置为-free_benchmark)。 <br/> **配置示例**:"task": "tensor"。 | 否 |
|
|
16
|
+
| dump_path | 设置 dump 数据目录路径,str 类型。<br/> **配置示例**:"dump_path": "./dump_path"。MindSpore 场景仅支持绝对路径。 | 是 |
|
|
17
|
+
| rank | 指定对某张卡上的数据进行 dump,list[int] 类型,默认未配置(表示 dump 所有卡的数据),应配置为 ≥0 的整数,且须配置实际可用的 Rank ID。<br/> <hr>PyTorch 场景:Rank ID 从 0 开始计数,最大取值为所有节点可用卡总数-1,若所配置的值大于实际训练所运行的卡的 Rank ID,则 dump 数据为空,比如当前环境 Rank ID 为 0 到 7,实际训练运行 0 到 3 卡,此时若配置 Rank ID 为 4 或不存在的 10 等其他值,dump 数据为空。<br/> **配置示例**:"rank": [1]。<hr> MindSpore 场景:所有节点的 Rank ID 均从 0 开始计数,最大取值为每个节点可用卡总数-1,config.json 配置一次 rank 参数对所有节点同时生效。<br/> **配置示例**:"rank": [1]。 | 否 |
|
|
18
|
+
| step | 指定 dump 某个 step 的数据,list[int] 类型。默认未配置,表示 dump 所有 step 数据。dump 特定 step 时,须指定为训练脚本中存在的 step。step 为 list 格式,可配置逐个 step。<br/> **配置示例**:"step": [0,1,2]。 | 否 |
|
|
19
|
+
| level | dump 级别,str 类型,根据不同级别 dump 不同数据。可取值,<br/>"L0":dump 模块级精度数据,仅 PyTorch 与 MindSpore 动态图场景支持,使用背景详见 [1.1.1 模块级精度数据 dump 说明](#111-模块级精度数据-dump-说明);<br/>"L1":dump API 级精度数据,默认值,仅 PyTorch 与 MindSpore 动态图场景支持;<br/>"L2":dump kernel 级精度数据,PyTorch场景下须配置 acl_config 参数;<br/>"mix":dump module 模块级和 API 级精度数据,即"L0"+"L1",仅 PyTorch 场景支持。<br/> **配置示例**:"level": "L1"。 | 否 |
|
|
20
|
+
| acl_config | kernel dump 的配置文件,str 类型。level 取"L2"时,该参数必要;level 为其他值时,该参数不选。<br/> **配置示例**:acl_config="./acl_config.json"。具体配置见[ acl_config 示例](./04.acl_config_examples.md)。 | 否 |
|
|
21
|
+
| seed | 随机种子数,int 类型,默认值为:1234,仅 PyTorch 场景支持。通过固定随机数保证模型的输入或输出一致,可固定的随机数详见 [1.1.2 固定随机数范围(仅 PyTorch 场景支持)](#112-固定随机数范围仅-pytorch-场景支持)。<br/> **配置示例**:"seed": 1234。 | 否 |
|
|
22
|
+
| is_deterministic | 确定性计算模式,bool 类型,仅 PyTorch 场景支持。可取值 true(开启)或 false(关闭),默认关闭。<br/> 即使在相同的硬件和输入下,API 多次执行的结果也可能不同,开启确定性计算是为了保证在相同的硬件和输入下,API 多次执行的结果相同。<br/>确定性计算会导致 API 执行性能降低,建议在发现模型多次执行结果不同的情况下开启。<br/> rnn 类算子、ReduceSum、ReduceMean 等算子可能与确定性计算存在冲突,若开启确定性计算后多次执行的结果不相同,则考虑存在这些算子。<br/> **配置示例**:"is_deterministic": true。<br/> | 否 |
|
|
23
|
+
| enable_dataloader | 自动控制开关,bool 类型,仅 PyTorch 场景支持。可取值 true(开启)或 false(关闭),默认为 false。配置为 True 后自动识别 step 参数指定的迭代,并在该迭代执行完成后退出训练,此时 start、stop 和 step 函数可不配置,开启该开关要求训练脚本是通过 torch.utils.data.dataloader 方式加载数据。仅支持 PyTorch 单卡训练使用,分布式训练场景下存在数据 dump 不全问题,**下个版本即将废弃该功能**。 | 否 |
|
|
24
|
+
|
|
25
|
+
#### 1.1.1 模块级精度数据 dump 说明
|
|
26
|
+
|
|
27
|
+
仅 PyTorch 与 MindSpore 动态图场景支持。
|
|
28
|
+
|
|
29
|
+
大模型场景下,通常不是简单的利用自动迁移能力实现从 GPU 到 NPU 的训练脚本迁移,而是会对 NPU 网络进行一系列针对性的适配,因此,常常会造成迁移后的 NPU 模型存在部分子结构不能与 GPU 原始模型完全对应。模型结构不一致导致 API 调用类型及数量不一致,若直接按照 API 粒度进行精度数据 dump 和比对,则无法完全比对所有的 API。
|
|
30
|
+
|
|
31
|
+
本小节介绍的功能是对模型中的大粒度模块进行数据 dump,使其比对时,对于无法以 API 粒度比对的模块可以直接以模块粒度进行比对。
|
|
32
|
+
|
|
33
|
+
模块指的是继承 nn.Module 类(PyTorch场景)或 nn.Cell 类(MindSpore场景)的子类,通常情况下这类模块就是一个小模型,可以被视为一个整体,dump 数据时以模块为粒度进行 dump。
|
|
34
|
+
|
|
35
|
+
#### 1.1.2 固定随机数范围(仅 PyTorch 场景支持)
|
|
36
|
+
|
|
37
|
+
seed_all 函数可固定随机数的范围如下表。
|
|
38
|
+
|
|
39
|
+
| API | 固定随机数 |
|
|
40
|
+
| ---------------------------------------- | --------------------------- |
|
|
41
|
+
| os.environ['PYTHONHASHSEED'] = str(seed) | 禁止 Python 中的 hash 随机化 |
|
|
42
|
+
| random.seed(seed) | 设置 random 随机生成器的种子 |
|
|
43
|
+
| np.random.seed(seed) | 设置 numpy 中随机生成器的种子 |
|
|
44
|
+
| torch.manual_seed(seed) | 设置当前 CPU 的随机种子 |
|
|
45
|
+
| torch.cuda.manual_seed(seed) | 设置当前 GPU 的随机种子 |
|
|
46
|
+
| torch.cuda.manual_seed_all(seed) | 设置所有 GPU 的随机种子 |
|
|
47
|
+
| torch_npu.npu.manual_seed(seed) | 设置当前 NPU 的随机种子 |
|
|
48
|
+
| torch_npu.npu.manual_seed_all(seed) | 设置所有 NPU 的随机种子 |
|
|
49
|
+
| torch.backends.cudnn.enable=False | 关闭 cuDNN |
|
|
50
|
+
| torch.backends.cudnn.benchmark=False | cuDNN 确定性地选择算法 |
|
|
51
|
+
| torch.backends.cudnn.deterministic=True | cuDNN 仅使用确定性的卷积算法 |
|
|
52
|
+
|
|
53
|
+
需要保证 CPU 或 GPU 以及 NPU 的模型输入完全一致,dump 数据的比对才有意义,seed_all 并不能保证模型输入完全一致,如下表所示场景需要保证输入的一致性。
|
|
54
|
+
|
|
55
|
+
| 场景 | 固定方法 |
|
|
56
|
+
| --------------- | ------------- |
|
|
57
|
+
| 数据集的 shuffle | 关闭 shuffle。 |
|
|
58
|
+
| dropout | 关闭 dropout。 |
|
|
59
|
+
|
|
60
|
+
关闭 shuffle 示例:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
train_loader = torch.utils.data.DataLoader(
|
|
64
|
+
train_dataset,
|
|
65
|
+
batch_size = batch_size,
|
|
66
|
+
shuffle = False,
|
|
67
|
+
num_workers = num_workers
|
|
68
|
+
)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
关闭 dropout:
|
|
72
|
+
|
|
73
|
+
在使用 `from msprobe.pytorch import PrecisionDebugger` 后,工具会自动将 `torch.nn.functional.dropout`、`torch.nn.functional.dropout2d`、`torch.nn.functional.dropout3d`、`torch.nn.Dropout`、`torch.nn.Dropout2d`、`torch.nn.Dropout3d` 的接口参数 p 置为0。
|
|
74
|
+
|
|
75
|
+
### 1.2 task 配置为 statistics
|
|
76
|
+
|
|
77
|
+
| 参数名 | 解释 | 是否必选 |
|
|
78
|
+
| ------------ | ------------------- | -------- |
|
|
79
|
+
| scope | PyTorch 和 MindSpore 动态图场景 dump 范围,list[str] 类型,默认未配置(list 也未配置时表示 dump 所有 API 的数据)。该参数在 [ ] 内配置两个模块名或 API 名,用于锁定区间,dump 该范围内的数据。<br/>**配置示例**:"scope": ["MyModuleOP1", "MyModuleOP2"]。与 level 参数取值相关,level 为 L0 和 mix 级别时,可配置模块名;level 为 L1 级别时,可配置 API 名。MindSpore 动态图场景当前仅支持配置为 API 名。 | 否 |
|
|
80
|
+
| list | 自定义 dump 范围,list[str] 类型,默认未配置(scope 也未配置时表示 dump 所有 API 的数据)。包含如下配置方法:<br> PyTorch 和 MindSpore 动态图场景配置具体的 API 全称,dump 该 API 数据。<br/>**配置示例**:"list": ["Tensor.permute.1.forward", "Tensor.transpose.2.forward", "Torch.relu.3.backward"]。<br/> <hr> PyTorch 和 MindSpore 动态图场景指定某一类 API,dump 某一类的 API 级别输入输出数据。<br/>**配置示例**:"list": ["relu"]。<hr> MindSpore 静态图场景配置 kernel_name,可以是算子的名称列表,也可以指定算子类型("level": "L2"时不支持),还可以配置算子名称的正则表达式(当字符串符合“name-regex(xxx)”格式时,后台则会将其作为正则表达式。例如,“name-regex(Default/.+)”可匹配算子名称以“Default/”开头的所有算子)。 | 否 |
|
|
81
|
+
| data_mode | dump 数据过滤,str 类型。<br/><hr>PyTorch 场景:支持"all"、"forward"、"backward"、"input"和"output",表示仅保存 dump 的数据中文件名包含"forward"、"backward"、"input"和"output"的前向、反向、输入或输出的 dump 文件。<br/> **配置示例**:"data_mode": ["all"]。 <hr>MindSpore 场景:仅支持"all"、"input"和"output"参数,且各参数只能单独配置,不支持自由组合。<br/>**配置示例**:"data_mode": ["backward"] 或 "data_mode": ["forward", "backward"]。默认为["all"],即保存所有 dump 的数据。除了 all 参数只能单独配置外,其他参数可以自由组合。 | 否 |
|
|
82
|
+
| summary_mode | 控制 dump 文件输出的模式,str 类型,仅 PyTorch 场景支持,可取值,<br/> md5:dump 输出包含 md5 值以及 API 统计信息的 dump.json 文件,用于验证数据的完整性;<br/> statistics:dump 仅输出包含 API 统计信息的 dump.json 文件,默认值。<br/> **配置示例**:"summary_mode": "md5"。 | 否 |
|
|
83
|
+
|
|
84
|
+
### 1.3 task 配置为 tensor
|
|
85
|
+
|
|
86
|
+
| 参数名 | 解释 | 是否必选 |
|
|
87
|
+
| -------------- | ---------------------- | -------- |
|
|
88
|
+
| scope | 与[ 1.2 task 配置为 statistics ](#12-task-配置为-statistics)中的解释相同。 | 否 |
|
|
89
|
+
| list | 与[ 1.2 task 配置为 statistics ](#12-task-配置为-statistics)中的解释相同。另外,<br/> PyTorch 和 MindSpore 动态图场景配置 kernel_api,dump 前向和反向 API 的kernel_api 级别数据,其中 dump 反向 API 时需要配置 **backward_input** 参数。<br/>**前向 API 配置示例**:"list": ["Tensor.permute.1.forward"];<br/>**反向 API 配置示例**:"list": ["Tensor.permute.1.forward"], "backward.input": ["./npu_dump/step0/rank0/Functional.conv2d.1.backward.input.0.pt"]。<br/> | 否 |
|
|
90
|
+
| backward_input | 该输入文件为首次运行训练 dump 得到反向 API 输入的 dump 文件,str 类型,仅 PyTorch 场景支持,默认未配置。例如若需要 dump Functional.conv2d.1 API 的反向过程的输入输出,则需要在 dump 目录下查找命名包含 Functional.conv2d.1、backward 和 input 字段的 dump 文件。<br/>**配置示例**:"backward_input": ["./npu_dump/step0/rank0/Functional.conv2d.1.backward.input.0.pt"] | 否 |
|
|
91
|
+
| data_mode | 与[ 1.2 task 配置为 statistics ](#12-task-配置为-statistics)中的解释相同 | 否 |
|
|
92
|
+
| file_format | MindSpore 静态图场景 tensor 数据的保存格式,str 类型,可取值,<br/> "bin":dump 的 tensor 文件为二进制格式,"level": "L1" 时不支持;<br/>"npy":dump 的 tensor 文件后缀为 .npy,默认值。 | 否 |
|
|
93
|
+
| online_run_ut<sup>a<sup/> | 在线预检模式开关,bool 类型,可取值 true(开启)、false(关闭),默认未配置,表示关闭。配置为 true 表示开启在线预预检。| 否 |
|
|
94
|
+
| nfs_path<sup>a<sup/> | 在线预检模式共享存储目录路径,str 类型,用于 GPU 设备和 NPU 设备间进行通信。仅在 online_run_ut 字段配置为 true 时生效,未配置该参数后 host 和 port 不生效。 | 否 |
|
|
95
|
+
| host<sup>a<sup/> | 在线预检模式局域网场景信息接收端 IP,str 类型,用于 GPU 设备和 NPU 设备间进行通信,NPU 侧须配置为 GPU 侧的局域网 IP 地址。仅在 online_run_ut 字段配置为 true 时生效,局域网场景时,不能配置 nfs_path 参数,否则局域网场景不生效。 | 否 |
|
|
96
|
+
| port<sup>a<sup/> | 在线预检模式局域网场景信息接收端端口号,int 类型,用于 GPU 设备和 NPU 设备间进行通信,NPU 侧须配置为 GPU 侧的端口号。仅在 online_run_ut 字段配置为 true 时生效,局域网场景时,不能配置 nfs_path 参数,否则局域网场景不生效。| 否 |
|
|
97
|
+
|
|
98
|
+
**a**:online_run_ut、nfs_path、host、port 等字段仅在线预检场景 NPU 机器生效。
|
|
99
|
+
|
|
100
|
+
### 1.4 task 配置为 run_ut
|
|
101
|
+
|
|
102
|
+
| 参数名称 | 解释 | 是否必选 |
|
|
103
|
+
| --------------- | ------------------------ | ------------ |
|
|
104
|
+
| white_list<sup>a</sup> | API dump 白名单,仅对指定的 API 进行 dump。<br/>**配置示例**:"white_list": ["conv1d", "conv2d"]。默认未配置白名单,即 dump 全量 API 数据。 | 否 |
|
|
105
|
+
| black_list<sup>a</sup> | API dump 黑名单,被指定的 API 不进行 dump。<br/>**配置示例**:"black_list": ["conv1d", "conv2d"]。默认未配置黑名单,即 dump 全量 API 数据。 | 否 |
|
|
106
|
+
| error_data_path | 配置保存精度未达标的 API 输入输出数据路径,默认为当前路径。<br/>**配置示例**:"error_data_path": "./"。 | 否 |
|
|
107
|
+
| is_online<sup>b</sup> | 在线预检模式开关,bool 类型,可取值 true(开启)、false(关闭),默认关闭。 | 否 |
|
|
108
|
+
| nfs_path<sup>b</sup> | 在线预检模式共享存储目录路径,str 类型,用于 GPU 设备和 NPU 设备间进行通信。配置该参数后 host 和 port 不生效,仅在 is_online 字段配置为 true 时生效。 | 否 |
|
|
109
|
+
| host<sup>b</sup> | 在线预检模式局域网场景信息接收端 IP,str 类型,用于 GPU 设备和 NPU 设备间进行通信,GPU 侧配置为本机地址 127.0.0.1 或本机局域网 IP。局域网场景时,不能配置 nfs_path 参数,否则局域网场景不生效。仅在 is_online 字段配置为 true 时生效。 | 否 |
|
|
110
|
+
| port<sup>b</sup> | 在线预检模式局域网场景信息接收端端口号,int 类型,用于 GPU 设备和 NPU 设备间进行通信,GPU 侧配置为本机可用端口。局域网场景时,不能配置 nfs_path 参数,否则局域网场景不生效。仅在 is_online 字段配置为 true 时生效。| 否 |
|
|
111
|
+
| rank_list<sup>b</sup> | 指定在线预检的 Rank ID,默认值为 [0],list[int] 类型,应配置为大于等于 0 的整数,且须根据实际卡的 Rank ID 配置,若所配置的值大于实际训练所运行的卡的 Rank ID,则在线预检输出数据为空。GPU 和 NPU 须配置一致。仅在 is_online 字段配置为 true 时生效。 | 否 |
|
|
112
|
+
|
|
113
|
+
**a**:white_list 和 black_list 同时配置时,二者配置的 API 名单若无交集,则白名单生效,若 API 名单存在交集,则白名单排除的部分以及交集的 API 不进行 dump。
|
|
114
|
+
|
|
115
|
+
**b**:is_online、nfs_path、host、port、rank_list 等字段仅在线预检场景 GPU 机器生效。
|
|
116
|
+
|
|
117
|
+
### 1.5 task 配置为 overflow_check
|
|
118
|
+
|
|
119
|
+
PyTorch 与 MindSpore 动态图场景下,"level"须为"L1";MindSpore 静态图场景下,"level"须为"L2"。
|
|
120
|
+
|
|
121
|
+
| 参数名 | 解释 | 是否必选 |
|
|
122
|
+
| ------------- | ---------------------- | -------- |
|
|
123
|
+
| overflow_nums | 最大溢出次数,int 类型,默认为 1,仅 PyTorch 与 MindSpore 动态图场景支持。表示第 N 次溢出后,不再进行溢出检测。过程中检测到溢出 API 对应的 输入输出 数据均 dump。<br/>**配置示例**:"overflow_nums": 3。配置为 -1 时,表示持续检测溢出直到训练结束。 | 否 |
|
|
124
|
+
| check_mode | MindSpore 静态图场景 kernel 级别的溢出检测,str 类型,可取值:<br/>"aicore":开启 AI Core 的溢出检测;<br/>"atomic":开启 Atomic 的溢出检测;<br/>"all":开启 AI Core 和 Atomic 的溢出检测,默认值。<br/>**配置示例**:"check_mode": "aicore"。 | 否 |
|
|
125
|
+
|
|
126
|
+
### 1.6 task 配置为 free_benchmark
|
|
127
|
+
|
|
128
|
+
仅 PyTorch 场景与 MindSpore 动态图场景支持,且"level"为"L1"。
|
|
129
|
+
|
|
130
|
+
- task 配置为 free_benchmark 时,开启**无标杆比对**,在 NPU 环境下通过对当前模型 API 的输入添加扰动因子,二次执行,将得到的输出与未添加扰动因子前的输出进行比对,从而**得出该模型中可能存在因迁移等变化导致精度降低的 API**。
|
|
131
|
+
|
|
132
|
+
- 无标杆比对优势在于省去了从 CPU/GPU 环境获取标杆数据的步骤,也省去了在 NPU 环境执行 dump 的操作,降低了精度比对的操作难度。
|
|
133
|
+
|
|
134
|
+
- 建议配置白名单(配置 scope 或 list)控制少量 API 进行无标杆比对,一次对过多 API 执行无标杆比对可能导致显存溢出或性能膨胀。
|
|
135
|
+
|
|
136
|
+
| 参数名 | 解释 | 是否必选 |
|
|
137
|
+
| ------------ | -------------- | -------- |
|
|
138
|
+
| scope | 自定义检测 API 列表(仅 PyTorch 场景支持),list[str] 类型,默认值为空列表,当 list 也为空列表时,表示检测所有 API。需要在 [ ] 内配置具体 API 名(在 dump 的结果中查看)。<br/>**配置示例**:"scope": ["Torch.matmul.0", "Tensor.pow.4"]。<br/>与 list 参数不能同时配置。 | 否 |
|
|
139
|
+
| list | 自定义检测 API 类型或 API 名称,list[str] 类型,默认值为空列表,表示检测所有 API(PyTorch 场景下还需 scope 也为空列表)。<br><hr> PyTorch 场景:指定某一类 API,对某一类的 API 进行无标杆比对。<br/>**配置示例**:"list": ["relu"]。<br/> <hr> MindSpore 场景:指定 API 名称,对列表中的 API 进行检测。<br/>**配置示例**:"list": ["mindspore.mint.div", "mindspore.ops.bmm", "mindspore.Tensor.\_\_add\_\_"]。<br/>与 scope 参数不能同时配置。 | 否 |
|
|
140
|
+
| fuzz_device | 标杆设备,str 类型。可取值,<br/> "npu":无标杆,通过添加扰动因子进行比对,默认值;<br/> "cpu":以 CPU 为标杆,pert_mode 须配置为"to_cpu"(仅 PyTorch 场景支持)。<br/>**配置示例**:"fuzz_device": "cpu"。 | 否 |
|
|
141
|
+
| 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"。 | 否 |
|
|
142
|
+
| handler_type | 处理类型,可取值,<br/> "check":进行无标杆比对检查,默认值;<br/> "fix":将扰动后的 API 输出结果覆盖原始 API 输出结果,尝试将 Loss 曲线恢复正常,该模式下不支持预热 if_preheat。<br/> **配置示例**:"handler_type": "fix"。 | 否 |
|
|
143
|
+
| fuzz_level | 无标杆数据 dump 级别,即选择比对结果文件应输出的表头属性,当前仅支持取值为:"L1"。输出结果详见 [1.6.1 无标杆比对数据存盘格式]()。 | 否 |
|
|
144
|
+
| fuzz_stage | 前反向,选择对 API 前向或反向进行无标杆比对,可取值:<br/> "forward":前向,默认值;<br/> "backward":反向。<br/> **配置示例**:"fuzz_stage": "backward"。 | 否 |
|
|
145
|
+
| if_preheat | 预热功能(仅 PyTorch 场景支持),开启功能后工具可以根据每次迭代的输出调整精度算法的阈值,从而更准确地找出存在精度问题的 API,bool 类型。可取值:<br/> true(开启)或 false(关闭),默认关闭。<br/> **配置示例**:"if_preheat": "true"。"handler_type": "fix"不支持预热。 | 否 |
|
|
146
|
+
| preheat_step | 开启预热的迭代数量(仅 PyTorch 场景支持),int 类型,默认值为 15。须配置 "if_preheat": "true"。 | 否 |
|
|
147
|
+
| max_sample | 每个算子预热的采样次数的最大阈值(仅 PyTorch 场景支持),int 类型,默认值为 20。须配置 "if_preheat": "true"。 | 否 |
|
|
148
|
+
|
|
149
|
+
#### 1.6.1 无标杆比对数据存盘格式
|
|
150
|
+
|
|
151
|
+
无标杆比对在 dump_path 目录下输出结果文件 `free_benchmark.csv`,如下示例:
|
|
152
|
+
|
|
153
|
+

|
|
154
|
+
|
|
155
|
+
| 字段 | 说明 |
|
|
156
|
+
| ------------ | --------------------- |
|
|
157
|
+
| rank | Rank ID,int 类型。 |
|
|
158
|
+
| pert_mode | 扰动因子的类型,string 类型。 |
|
|
159
|
+
| stage | 前向或反向,string 类型。 |
|
|
160
|
+
| step | 迭代数,int 类型。 |
|
|
161
|
+
| api_name | API 名称,string 类型。 |
|
|
162
|
+
| max_rel | 输出对比最大相对误差,float 类型。 |
|
|
163
|
+
| dtype | 输入的 dtype,string 类型。 |
|
|
164
|
+
| shape | 输入的 shape,tuple 类型。 |
|
|
165
|
+
| output_index | 如果输出为列表或元组,其中一个元素检测不一致,则会有该元素的 index,否则为空,int 类型。 |
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# config.json 配置示例
|
|
2
|
+
|
|
3
|
+
以下示例包含当前支持的所有场景可配置的完整参数。
|
|
4
|
+
|
|
5
|
+
## 1 PyTorch 场景
|
|
6
|
+
|
|
7
|
+
### 1.1 task 配置为 statistics
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"task": "statistics",
|
|
12
|
+
"dump_path": "/home/data_dump",
|
|
13
|
+
"rank": [],
|
|
14
|
+
"step": [],
|
|
15
|
+
"level": "L1",
|
|
16
|
+
"seed": 1234,
|
|
17
|
+
"is_deterministic": false,
|
|
18
|
+
"enable_dataloader": false,
|
|
19
|
+
|
|
20
|
+
"statistics": {
|
|
21
|
+
"scope": [],
|
|
22
|
+
"list": [],
|
|
23
|
+
"data_mode": ["all"],
|
|
24
|
+
"summary_mode": "statistics"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 1.2 task 配置为 tensor
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"task": "tensor",
|
|
34
|
+
"dump_path": "/home/data_dump",
|
|
35
|
+
"rank": [],
|
|
36
|
+
"step": [],
|
|
37
|
+
"level": "L1",
|
|
38
|
+
"seed": 1234,
|
|
39
|
+
"is_deterministic": false,
|
|
40
|
+
"enable_dataloader": false,
|
|
41
|
+
|
|
42
|
+
"tensor": {
|
|
43
|
+
"scope": [],
|
|
44
|
+
"list":[],
|
|
45
|
+
"data_mode": ["all"],
|
|
46
|
+
"backward_input": ""
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 1.3 task 配置为 run_ut
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"task": "run_ut",
|
|
56
|
+
"dump_path": "/home/data_dump",
|
|
57
|
+
"rank": [],
|
|
58
|
+
"step": [],
|
|
59
|
+
"level": "L1",
|
|
60
|
+
"seed": 1234,
|
|
61
|
+
"is_deterministic": false,
|
|
62
|
+
"enable_dataloader": false,
|
|
63
|
+
|
|
64
|
+
"run_ut": {
|
|
65
|
+
"white_list": [],
|
|
66
|
+
"black_list": [],
|
|
67
|
+
"error_data_path": "./"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 1.4 task 配置为 overflow_check
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"task": "overflow_check",
|
|
77
|
+
"dump_path": "/home/data_dump",
|
|
78
|
+
"rank": [],
|
|
79
|
+
"step": [],
|
|
80
|
+
"level": "L1",
|
|
81
|
+
"seed": 1234,
|
|
82
|
+
"is_deterministic": false,
|
|
83
|
+
"enable_dataloader": false,
|
|
84
|
+
|
|
85
|
+
"overflow_check": {
|
|
86
|
+
"overflow_nums": 1
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### 1.5 task 配置为 free_benchmark
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"task": "free_benchmark",
|
|
96
|
+
"dump_path": "/home/data_dump",
|
|
97
|
+
"rank": [],
|
|
98
|
+
"step": [],
|
|
99
|
+
"level": "L1",
|
|
100
|
+
"seed": 1234,
|
|
101
|
+
"is_deterministic": false,
|
|
102
|
+
"enable_dataloader": false,
|
|
103
|
+
|
|
104
|
+
"free_benchmark": {
|
|
105
|
+
"scope": [],
|
|
106
|
+
"list": ["conv2d"],
|
|
107
|
+
"fuzz_device": "npu",
|
|
108
|
+
"pert_mode": "improve_precision",
|
|
109
|
+
"handler_type": "check",
|
|
110
|
+
"fuzz_level": "L1",
|
|
111
|
+
"fuzz_stage": "forward",
|
|
112
|
+
"if_preheat": false,
|
|
113
|
+
"preheat_step": 15,
|
|
114
|
+
"max_sample": 20
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## 2 MindSpore 静态图场景
|
|
120
|
+
|
|
121
|
+
### 2.1 task 配置为 statistics
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"task": "statistics",
|
|
126
|
+
"dump_path": "/home/data_dump",
|
|
127
|
+
"rank": [],
|
|
128
|
+
"step": [],
|
|
129
|
+
"level": "L2",
|
|
130
|
+
|
|
131
|
+
"statistics": {
|
|
132
|
+
"list": [],
|
|
133
|
+
"data_mode": ["all"],
|
|
134
|
+
"summary_mode": "statistics"
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### 2.2 task 配置为 tensor
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"task": "tensor",
|
|
144
|
+
"dump_path": "/home/data_dump",
|
|
145
|
+
"rank": [],
|
|
146
|
+
"step": [],
|
|
147
|
+
"level": "L2",
|
|
148
|
+
|
|
149
|
+
"tensor": {
|
|
150
|
+
"list":[],
|
|
151
|
+
"data_mode": ["all"],
|
|
152
|
+
"backward_input": ""
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### 2.3 task 配置为 overflow_check
|
|
158
|
+
|
|
159
|
+
```json
|
|
160
|
+
{
|
|
161
|
+
"task": "overflow_check",
|
|
162
|
+
"dump_path": "/home/data_dump",
|
|
163
|
+
"rank": [],
|
|
164
|
+
"step": [],
|
|
165
|
+
"level": "L2",
|
|
166
|
+
|
|
167
|
+
"overflow_check": {
|
|
168
|
+
"check_mode": "all"
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## 3 MindSpore 动态图场景
|
|
174
|
+
|
|
175
|
+
### 3.1 task 配置为 statistics
|
|
176
|
+
|
|
177
|
+
```json
|
|
178
|
+
{
|
|
179
|
+
"task": "statistics",
|
|
180
|
+
"dump_path": "/home/data_dump",
|
|
181
|
+
"rank": [],
|
|
182
|
+
"step": [],
|
|
183
|
+
"level": "L1",
|
|
184
|
+
|
|
185
|
+
"statistics": {
|
|
186
|
+
"scope": [],
|
|
187
|
+
"list": [],
|
|
188
|
+
"data_mode": ["all"],
|
|
189
|
+
"summary_mode": "statistics"
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### 3.2 task 配置为 tensor
|
|
195
|
+
|
|
196
|
+
```json
|
|
197
|
+
{
|
|
198
|
+
"task": "tensor",
|
|
199
|
+
"dump_path": "/home/data_dump",
|
|
200
|
+
"rank": [],
|
|
201
|
+
"step": [],
|
|
202
|
+
"level": "L1",
|
|
203
|
+
|
|
204
|
+
"tensor": {
|
|
205
|
+
"scope": [],
|
|
206
|
+
"list":[],
|
|
207
|
+
"data_mode": ["all"]
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### 3.3 task 配置为 overflow_check
|
|
213
|
+
|
|
214
|
+
```json
|
|
215
|
+
{
|
|
216
|
+
"task": "overflow_check",
|
|
217
|
+
"dump_path": "/home/data_dump",
|
|
218
|
+
"rank": [],
|
|
219
|
+
"step": [],
|
|
220
|
+
"level": "L1",
|
|
221
|
+
|
|
222
|
+
"overflow_check": {
|
|
223
|
+
"overflow_nums": 1
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### 3.4 task 配置为 free_benchmark
|
|
229
|
+
|
|
230
|
+
```json
|
|
231
|
+
{
|
|
232
|
+
"task": "free_benchmark",
|
|
233
|
+
"dump_path": "/home/data_dump",
|
|
234
|
+
"rank": [],
|
|
235
|
+
"step": [],
|
|
236
|
+
"level": "L1",
|
|
237
|
+
|
|
238
|
+
"free_benchmark": {
|
|
239
|
+
"list": ["mindspore.ops.add"],
|
|
240
|
+
"fuzz_device": "npu",
|
|
241
|
+
"pert_mode": "improve_precision",
|
|
242
|
+
"handler_type": "check",
|
|
243
|
+
"fuzz_level": "L1",
|
|
244
|
+
"fuzz_stage": "forward"
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
```
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# acl_config.json 配置文件说明
|
|
2
|
+
|
|
3
|
+
当 PyTorch 场景 level 取"L2"时,须配置 acl_config 参数,并指定 acl_config.json 文件(用于指定 L2 kernel 级 dump 的配置),此时 **config.json** 文件配置示例如下:
|
|
4
|
+
|
|
5
|
+
## 1 前向 kernel dump 配置示例
|
|
6
|
+
|
|
7
|
+
"scope"配置为前向 API 名称,仅支持配置一个 API。
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"task": "tensor",
|
|
12
|
+
"dump_path": "/home/data_dump",
|
|
13
|
+
"level": "L2",
|
|
14
|
+
"rank": [0],
|
|
15
|
+
"step": [0],
|
|
16
|
+
"is_deterministic": false,
|
|
17
|
+
"tensor": {
|
|
18
|
+
"scope": ["Tensor.__mul__.10.forward"],
|
|
19
|
+
"list":[],
|
|
20
|
+
"data_mode": ["all"],
|
|
21
|
+
"backward_input": [""],
|
|
22
|
+
"file_format": "npy"
|
|
23
|
+
},
|
|
24
|
+
"acl_config": "acl_config.json"
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 2 反向 kernel dump 配置示例
|
|
29
|
+
|
|
30
|
+
执行反向 kernel dump 前需要先使用工具 dump 该 API 的反向输入,保存 pt 文件,"backward_input"参数中传入该 pt 文件路径。
|
|
31
|
+
|
|
32
|
+
"scope"配置为反向API名称,仅支持配置一个API。
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"task": "tensor",
|
|
37
|
+
"dump_path": "/home/data_dump",
|
|
38
|
+
"level": "L2",
|
|
39
|
+
"rank": [0],
|
|
40
|
+
"step": [0],
|
|
41
|
+
"is_deterministic": false,
|
|
42
|
+
"tensor": {
|
|
43
|
+
"scope": ["Tensor.__mul__.10.backward"],
|
|
44
|
+
"list":[],
|
|
45
|
+
"data_mode": ["all"],
|
|
46
|
+
"backward_input": ["Tensor.__mul__.10.backward.input.0.pt"],
|
|
47
|
+
"file_format": "npy"
|
|
48
|
+
},
|
|
49
|
+
"acl_config": "acl_config.json"
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## 3 acl_config.json 配置示例
|
|
54
|
+
|
|
55
|
+
该文件须自行创建,配置示例如下:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"dump":
|
|
60
|
+
{
|
|
61
|
+
"dump_list":[],
|
|
62
|
+
"dump_path":"./dump/output",
|
|
63
|
+
"dump_mode":"all",
|
|
64
|
+
"dump_op_switch":"on"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**acl_config.json 参数说明**
|
|
70
|
+
|
|
71
|
+
| 字段名 | 解释 |
|
|
72
|
+
| -------------- | ------------------------------------------------------------ |
|
|
73
|
+
| dump_list | 待 dump 数据的 API 模型。为空,无需配置。 |
|
|
74
|
+
| dump_path | dump 数据文件存储到运行环境的目录,主要配置的是 kernel 级数据的存放路径。支持配置绝对路径或相对路径。dump_path 须为已存在目录。 |
|
|
75
|
+
| dump_mode | dump 数据模式,可取值,<br/> output:dump API 的输出数据,默认值;<br/> input:dump API 的输入数据;<br/> all:dump API 的输入、输出数据。 |
|
|
76
|
+
| dump_op_switch | 单 API 模型 dump 数据开关,可取值,<br> off:关闭单API模型dump,默认值;<br> on:开启单API模型dump。 |
|