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,198 @@
|
|
|
1
|
+
# PyTorch 场景的精度数据采集
|
|
2
|
+
|
|
3
|
+
msprobe 工具主要通过在训练脚本内添加 dump 接口、启动训练的方式采集精度数据。
|
|
4
|
+
|
|
5
|
+
本工具提供固定的 API 支持列表,若需要删除或增加 dump 的 API,可以在 msprobe/pytorch/hook_module/support_wrap_ops.yaml 文件内手动修改,如下示例:
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
functional: # functional为算子类别,找到对应的类别,在该类别下按照下列格式删除或添加API
|
|
9
|
+
- conv1d
|
|
10
|
+
- conv2d
|
|
11
|
+
- conv3d
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## 1 接口介绍
|
|
15
|
+
|
|
16
|
+
### 1.1 PrecisionDebugger
|
|
17
|
+
|
|
18
|
+
**功能说明**:通过加载 dump 配置文件的方式来确定 dump 操作的详细配置。
|
|
19
|
+
|
|
20
|
+
**原型**:
|
|
21
|
+
|
|
22
|
+
```Python
|
|
23
|
+
PrecisionDebugger(config_path=None, task=None, dump_path=None, level=None, model=None, step=None)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
1. config_path:指定 dump 配置文件路径;model:指定具体的 torch.nn.Module,默认未配置,level 配置为"L0"或"mix"时必须配置该参数。其他参数均在 [config.json](../config.json) 文件中可配,详细配置可见 [config.json 介绍](./02.config_introduction.md)。
|
|
27
|
+
2. 此接口的参数均不是必要,且优先级高于 [config.json](../config.json) 文件中的配置,但可配置的参数相比 config.json 较少。
|
|
28
|
+
|
|
29
|
+
### 1.2 start
|
|
30
|
+
|
|
31
|
+
**功能说明**:启动精度数据采集。在模型初始化之后的位置添加。需要与 stop 函数一起添加在 for 循环内。
|
|
32
|
+
|
|
33
|
+
**原型**:
|
|
34
|
+
|
|
35
|
+
```Python
|
|
36
|
+
debugger.start()
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 1.3 stop
|
|
40
|
+
|
|
41
|
+
**功能说明**:停止精度数据采集。在 **start** 函数之后的任意位置添加。若需要 dump 反向数据,则需要添加在反向计算代码(如,loss.backward)之后。使用示例可参见 [2.1 采集 model 的精度数据](#21-采集-model-的精度数据)和 [2.2 采集完整的前反向数据](#22-采集完整的前反向数据)。
|
|
42
|
+
|
|
43
|
+
**原型**:
|
|
44
|
+
|
|
45
|
+
```Python
|
|
46
|
+
debugger.stop()
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 1.4 forward_backward_dump_end
|
|
50
|
+
|
|
51
|
+
**功能说明**:停止精度数据采集。用于 dump 指定代码的前反向数据。在 **start** 函数之后,反向计算代码(如,loss.backward)之前的任意位置添加,可以采集 **start** 函数和该函数之间的前反向数据,可以通过调整 **start** 函数与该函数的位置,来指定需要 dump 的代码块。要求 **stop** 函数添加在反向计算代码(如,loss.backward)之后,此时该函数与 **stop** 函数之间的代码不会被 dump。使用示例可参见 [2.3 采集指定代码块的前反向数据](#23-采集指定代码块的前反向数据)
|
|
52
|
+
|
|
53
|
+
**原型**:
|
|
54
|
+
|
|
55
|
+
```Python
|
|
56
|
+
forward_backward_dump_end()
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 1.5 step
|
|
60
|
+
|
|
61
|
+
**功能说明**:更新 dump 参数。在最后一个 **stop** 函数后或一个 step 结束的位置添加。需要与 **start** 函数一起添加在 for 循环内。
|
|
62
|
+
|
|
63
|
+
**原型**:
|
|
64
|
+
|
|
65
|
+
```Python
|
|
66
|
+
debugger.step()
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 2 示例代码
|
|
70
|
+
|
|
71
|
+
### 2.1 采集 model 的精度数据
|
|
72
|
+
|
|
73
|
+
这个示例定义了一个 nn.Module 类型的简单网络,在进行数据采集时使用原型函数 PrecisionDebugger 传入 config_path 参数和 model 参数。
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
# 根据需要import包
|
|
77
|
+
import torch
|
|
78
|
+
import torch.nn as nn
|
|
79
|
+
import torch_npu # 需安装 torch_npu
|
|
80
|
+
import torch.nn.functional as F
|
|
81
|
+
from msprobe.pytorch import PrecisionDebugger
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
torch.npu.set_device("npu:0")
|
|
85
|
+
# 定义网络
|
|
86
|
+
class ModuleOP(nn.Module):
|
|
87
|
+
def __init__(self) -> None:
|
|
88
|
+
super().__init__()
|
|
89
|
+
self.linear_1 = nn.Linear(in_features=8,out_features=4)
|
|
90
|
+
self.linear_2 = nn.Linear(in_features=4,out_features=2)
|
|
91
|
+
|
|
92
|
+
def forward(self,x):
|
|
93
|
+
x1 = self.linear_1(x)
|
|
94
|
+
x2 = self.linear_2(x1)
|
|
95
|
+
r1 = F.relu(x2)
|
|
96
|
+
return r1
|
|
97
|
+
|
|
98
|
+
if __name__ == "__main__":
|
|
99
|
+
module = ModuleOP()
|
|
100
|
+
# 注册工具
|
|
101
|
+
debugger = PrecisionDebugger('./config.json', model=module)
|
|
102
|
+
debugger.start()
|
|
103
|
+
x = torch.randn(10,8)
|
|
104
|
+
out = module(x)
|
|
105
|
+
loss = out.sum()
|
|
106
|
+
loss.backward()
|
|
107
|
+
debugger.stop()
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
### 2.2 采集完整的前反向数据
|
|
111
|
+
|
|
112
|
+
```Python
|
|
113
|
+
from msprobe.pytorch import PrecisionDebugger
|
|
114
|
+
|
|
115
|
+
# 请勿将PrecisionDebugger的初始化流程插入到循环代码中
|
|
116
|
+
debugger = PrecisionDebugger(config_path="./config.json", dump_path="./dump_path")
|
|
117
|
+
# 模型、损失函数的定义及初始化等操作
|
|
118
|
+
# ...
|
|
119
|
+
# 数据集迭代的位置一般为模型训练开始的位置
|
|
120
|
+
for data, label in data_loader:
|
|
121
|
+
debugger.start() # 开启数据dump
|
|
122
|
+
# 如下是模型每个step执行的逻辑
|
|
123
|
+
output = model(data)
|
|
124
|
+
#...
|
|
125
|
+
loss.backward()
|
|
126
|
+
debugger.stop() # 关闭数据dump
|
|
127
|
+
debugger.step() # 结束一个step的dump
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### 2.3 采集指定代码块的前反向数据
|
|
131
|
+
|
|
132
|
+
```Python
|
|
133
|
+
from msprobe.pytorch import PrecisionDebugger
|
|
134
|
+
|
|
135
|
+
# 请勿将PrecisionDebugger的初始化流程插入到循环代码中
|
|
136
|
+
debugger = PrecisionDebugger(config_path="./config.json", dump_path="./dump_path")
|
|
137
|
+
|
|
138
|
+
# 模型、损失函数的定义及初始化等操作
|
|
139
|
+
# ...
|
|
140
|
+
# 数据集迭代的位置一般为模型训练开始的位置
|
|
141
|
+
for data, label in data_loader:
|
|
142
|
+
debugger.start() # 开启数据dump
|
|
143
|
+
# 如下是模型每个step执行的逻辑
|
|
144
|
+
output = model(data)
|
|
145
|
+
debugger.forward_backward_dump_end() # 插入该函数到start函数之后,只dump start函数到该函数之间代码的前反向数据,本函数到stop函数之间的数据则不dump
|
|
146
|
+
#...
|
|
147
|
+
loss.backward()
|
|
148
|
+
debugger.stop() # 关闭数据dump
|
|
149
|
+
debugger.step() # 结束一个step的dump
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
## 3 dump 结果文件介绍
|
|
155
|
+
|
|
156
|
+
训练结束后,工具将 dump 的数据保存在 dump_path 参数指定的目录下。目录结构示例如下:
|
|
157
|
+
|
|
158
|
+
```Python
|
|
159
|
+
├── dump_path
|
|
160
|
+
│ ├── step0
|
|
161
|
+
│ | ├── rank0
|
|
162
|
+
│ | │ ├── dump_tensor_data
|
|
163
|
+
| | | | ├── Tensor.permute.1.forward.pt
|
|
164
|
+
| | | | ├── MyModule.0.forward.input.pt # 开启模块级精度数据dump时存在模块级的dump数据文件
|
|
165
|
+
| | | | ...
|
|
166
|
+
| | | | └── Fcuntion.linear.5.backward.output.pt
|
|
167
|
+
│ | | ├── 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范数(平方根)
|
|
168
|
+
│ | | ├── stack.json # 算子调用栈信息
|
|
169
|
+
│ | | └── construct.json # 分层分级结构
|
|
170
|
+
│ | ├── rank1
|
|
171
|
+
| | | ├── dump_tensor_data
|
|
172
|
+
| | | | └── ...
|
|
173
|
+
│ | | ├── dump.json
|
|
174
|
+
│ | | ├── stack.json
|
|
175
|
+
| | | └── construct.json
|
|
176
|
+
│ | ├── ...
|
|
177
|
+
│ | |
|
|
178
|
+
| | └── rank7
|
|
179
|
+
│ ├── step1
|
|
180
|
+
│ | ├── ...
|
|
181
|
+
│ ├── step2
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
dump 过程中,pt 文件在对应算子或者模块被执行后就会落盘,而 json 文件则需要在正常执行 PrecisionDebugger.stop() 后才会写入完整数据,异常的程序终止会保存终止前被执行算子的相关 npy 文件,可能会导致 json 文件中数据丢失。
|
|
185
|
+
|
|
186
|
+
其中 rank 为设备上各卡的 ID,每张卡上 dump 的数据会生成对应 dump 目录。非分布式场景下没有rank ID,目录名称为rank。
|
|
187
|
+
|
|
188
|
+
pt 文件保存的前缀和 PyTorch 对应关系如下:
|
|
189
|
+
|
|
190
|
+
| 前缀 | Torch模块 |
|
|
191
|
+
| ----------- | ------------------- |
|
|
192
|
+
| Tensor | torch.Tensor |
|
|
193
|
+
| Torch | torch |
|
|
194
|
+
| Functional | torch.nn.functional |
|
|
195
|
+
| NPU | NPU亲和算子 |
|
|
196
|
+
| VF | torch._VF |
|
|
197
|
+
| Aten | torch.ops.aten |
|
|
198
|
+
| Distributed | torch.distributed |
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
# MindSpore 场景的精度数据采集
|
|
2
|
+
|
|
3
|
+
msprobe 工具主要通过在训练脚本内添加 dump 接口、启动训练的方式采集精度数据。目前,静态图场景仅支持 kernel 级数据采集,对应 config.json 配置中的 "L2" level;动态图场景支持cell、API、kernel级数据采集,对应 config.json 配置中的 "L0"、"L1" 、"L2" level。
|
|
4
|
+
|
|
5
|
+
精度数据采集功能的配置示例见[MindSpore 静态图场景下 task 配置为 statistics](https://gitee.com/ascend/mstt/blob/master/debug/accuracy_tools/msprobe/docs/03.config_examples.md#21-task-%E9%85%8D%E7%BD%AE%E4%B8%BA-statistics)、[MindSpore 静态图场景下 task 配置为 tensor](https://gitee.com/ascend/mstt/blob/master/debug/accuracy_tools/msprobe/docs/03.config_examples.md#22-task-%E9%85%8D%E7%BD%AE%E4%B8%BA-tensor)、[MindSpore 动态图场景下 task 配置为 statistics](https://gitee.com/ascend/mstt/blob/master/debug/accuracy_tools/msprobe/docs/03.config_examples.md#31-task-%E9%85%8D%E7%BD%AE%E4%B8%BA-statistics)、[MindSpore 动态图场景下 task 配置为 tensor](https://gitee.com/ascend/mstt/blob/master/debug/accuracy_tools/msprobe/docs/03.config_examples.md#32-task-%E9%85%8D%E7%BD%AE%E4%B8%BA-tensor)。
|
|
6
|
+
|
|
7
|
+
动态图 API 级 dump 时,本工具提供固定的 API 支持列表,仅支持对列表中的 API 进行精度数据采集。一般情况下,无需修改该列表,而是通过config.json中的scope/list字段进行 dump API 指定。若需要改变 API 支持列表,可以在 `msprobe/mindspore/dump/hook_cell/support_wrap_ops.yaml` 文件内手动修改,如下示例:
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
ops: # ops为算子类别,找到对应的类别,在该类别下按照下列格式删除或添加API
|
|
11
|
+
- adaptive_avg_pool1d
|
|
12
|
+
- adaptive_avg_pool2d
|
|
13
|
+
- adaptive_avg_pool3d
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## 1 接口介绍
|
|
17
|
+
|
|
18
|
+
### 1.1 msprobe.mindspore.PrecisionDebugger
|
|
19
|
+
|
|
20
|
+
**功能说明**:通过加载 dump 配置文件的方式来确定 dump 操作的详细配置。
|
|
21
|
+
|
|
22
|
+
**原型**:
|
|
23
|
+
|
|
24
|
+
```Python
|
|
25
|
+
PrecisionDebugger(config_path=None)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
1. config_path:指定 dump 配置文件路径,string 类型。参数示例:"./config.json"。未配置该路径时,默认使用 [config.json](../config.json) 文件的默认配置,配置选项含义可见 [config.json 介绍](./02.config_introduction.md)。
|
|
29
|
+
|
|
30
|
+
#### 1.1.1 start
|
|
31
|
+
|
|
32
|
+
**功能说明**:启动精度数据采集。需在模型执行模式(静态图/动态图、O0/O1/O2编译等级)设置后调用。
|
|
33
|
+
静态图场景下,必须在模型初始化及 mindspore.communication.init 调用前添加;动态图场景下,如果进行kernel级别("L2" level)dump或没有使用 [Model](https://www.mindspore.cn/tutorials/zh-CN/r2.3.1/advanced/model.html) 高阶 API 进行训练,则需要与 stop 函数一起添加在 for 循环内,否则只有需要传入model参数时,才使用该接口。
|
|
34
|
+
|
|
35
|
+
**原型**:
|
|
36
|
+
|
|
37
|
+
```Python
|
|
38
|
+
start(model=None)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
1. model:指具体的 mindspore.nn.Cell,默认不配置。Cell级别("L0" level)dump 时,传入 model 可以采集 model 内的所有Cell 对象数据。API级别("L1" level)dump 时,传入 model 可以采集 model 内包含 primitive op 对象在内的所有 API 数据,若不传入 model 参数,则只采集非 primitive op 的 API 数据。
|
|
42
|
+
|
|
43
|
+
#### 1.1.2 stop
|
|
44
|
+
|
|
45
|
+
**功能说明**:停止数据采集。在 **start** 函数之后的任意位置添加。需要与 start 函数一起添加在 for 循环内。若需要 dump 反向数据,则需要添加在反向计算代码之后。**仅未使用 Model 高阶 API 的动态图场景支持。**
|
|
46
|
+
|
|
47
|
+
**原型**:
|
|
48
|
+
|
|
49
|
+
```Python
|
|
50
|
+
stop()
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### 1.1.3 step
|
|
54
|
+
|
|
55
|
+
**功能说明**:在最后一个 **stop** 函数后或一个 step 训练结束的位置添加。**仅未使用 Model 高阶 API 的动态图场景支持。**
|
|
56
|
+
|
|
57
|
+
**原型**:
|
|
58
|
+
|
|
59
|
+
```Python
|
|
60
|
+
step()
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 1.2 msprobe.mindspore.common.utils.MsprobeStep
|
|
64
|
+
|
|
65
|
+
**功能说明**:MindSpore Callback类,自动在每个step开始时调用start()接口,在每个step结束时调用stop()、step()接口。实现使用 Model 高阶 API 的动态图场景下 L0、L1 级别的精度数据采集控制,控制粒度为单个 **Step** ,而 PrecisionDebugger.start, PrecisionDebugger.stop 接口的控制粒度任意训练代码段。
|
|
66
|
+
|
|
67
|
+
**原型**:
|
|
68
|
+
|
|
69
|
+
```Python
|
|
70
|
+
MsprobeStep(debugger)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
1. debugger:PrecisionDebugger对象。
|
|
74
|
+
|
|
75
|
+
## 2 示例代码
|
|
76
|
+
|
|
77
|
+
### 2.1 MindSpore 静态图场景
|
|
78
|
+
|
|
79
|
+
```Python
|
|
80
|
+
import mindspore as ms
|
|
81
|
+
ms.set_context(mode=ms.GRAPH_MODE, device_target="Ascend")
|
|
82
|
+
|
|
83
|
+
from msprobe.mindspore import PrecisionDebugger
|
|
84
|
+
debugger = PrecisionDebugger(config_path="./config.json")
|
|
85
|
+
debugger.start()
|
|
86
|
+
# 请勿将以上初始化流程置于模型实例化或mindspore.communication.init调用后
|
|
87
|
+
# ...
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 2.2 MindSpore 动态图场景
|
|
91
|
+
|
|
92
|
+
#### 2.2.1 未使用 Model 高阶 API(非 L2 级别)
|
|
93
|
+
|
|
94
|
+
```Python
|
|
95
|
+
import mindspore as ms
|
|
96
|
+
ms.set_context(mode=ms.PYNATIVE_MODE, device_target="Ascend")
|
|
97
|
+
|
|
98
|
+
from msprobe.mindspore import PrecisionDebugger
|
|
99
|
+
debugger = PrecisionDebugger(config_path="./config.json")
|
|
100
|
+
|
|
101
|
+
# 模型、损失函数的定义以及初始化等操作
|
|
102
|
+
# ...
|
|
103
|
+
model = Network()
|
|
104
|
+
# 数据集迭代的地方往往是模型开始训练的地方
|
|
105
|
+
for data, label in data_loader:
|
|
106
|
+
debugger.start() # 进行L1级别下非primitive op采集时调用
|
|
107
|
+
# debugger.start(model) # 进行L0级别或L1级别下primitive op的数据采集时调用
|
|
108
|
+
# 如下是模型每个step执行的逻辑
|
|
109
|
+
grad_net = ms.grad(model)(data)
|
|
110
|
+
# ...
|
|
111
|
+
debugger.stop() # 关闭数据dump
|
|
112
|
+
debugger.step() # 结束一个step的dump
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### 2.2.2 未使用 Model 高阶 API(L2 级别)
|
|
116
|
+
|
|
117
|
+
```Python
|
|
118
|
+
import mindspore as ms
|
|
119
|
+
ms.set_context(mode=ms.PYNATIVE_MODE, device_target="Ascend")
|
|
120
|
+
|
|
121
|
+
from msprobe.mindspore import PrecisionDebugger
|
|
122
|
+
debugger = PrecisionDebugger(config_path="./config.json")
|
|
123
|
+
debugger.start()
|
|
124
|
+
# 请勿将以上初始化流程置于模型实例化或mindspore.communication.init调用后
|
|
125
|
+
|
|
126
|
+
# 模型、损失函数的定义以及初始化等操作
|
|
127
|
+
# ...
|
|
128
|
+
model = Network()
|
|
129
|
+
# 数据集迭代的地方往往是模型开始训练的地方
|
|
130
|
+
for data, label in data_loader:
|
|
131
|
+
# 如下是模型每个step执行的逻辑
|
|
132
|
+
grad_net = ms.grad(model)(data)
|
|
133
|
+
# ...
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### 2.2.3 使用 Model 高阶 API(非 L2 级别)
|
|
137
|
+
|
|
138
|
+
```Python
|
|
139
|
+
import mindspore as ms
|
|
140
|
+
from mindspore.train import Model
|
|
141
|
+
ms.set_context(mode=ms.PYNATIVE_MODE, device_target="Ascend")
|
|
142
|
+
|
|
143
|
+
from msprobe.mindspore import PrecisionDebugger
|
|
144
|
+
from msprobe.mindspore.common.utils import MsprobeStep
|
|
145
|
+
debugger = PrecisionDebugger(config_path="./config.json")
|
|
146
|
+
|
|
147
|
+
# 模型、损失函数的定义以及初始化等操作
|
|
148
|
+
# ...
|
|
149
|
+
|
|
150
|
+
model = Network()
|
|
151
|
+
# 只有进行L0级别下Cell对象或L1级别下primitive op的数据采集时才需要调用
|
|
152
|
+
# debugger.start(model)
|
|
153
|
+
trainer = Model(model, loss_fn=loss_fn, optimizer=optimizer, metrics={'accuracy'})
|
|
154
|
+
trainer.train(1, train_dataset, callbacks=[MsprobeStep(debugger)])
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
#### 2.2.4 使用 Model 高阶 API(L2 级别)
|
|
158
|
+
|
|
159
|
+
```Python
|
|
160
|
+
import mindspore as ms
|
|
161
|
+
from mindspore.train import Model
|
|
162
|
+
ms.set_context(mode=ms.PYNATIVE_MODE, device_target="Ascend")
|
|
163
|
+
|
|
164
|
+
from msprobe.mindspore import PrecisionDebugger
|
|
165
|
+
debugger = PrecisionDebugger(config_path="./config.json")
|
|
166
|
+
debugger.start()
|
|
167
|
+
# 请勿将以上初始化流程置于模型实例化或mindspore.communication.init调用后
|
|
168
|
+
|
|
169
|
+
# 模型、损失函数的定义以及初始化等操作
|
|
170
|
+
# ...
|
|
171
|
+
|
|
172
|
+
model = Network()
|
|
173
|
+
trainer = Model(model, loss_fn=loss_fn, optimizer=optimizer, metrics={'accuracy'})
|
|
174
|
+
trainer.train(1, train_dataset)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## 3 dump 结果文件介绍
|
|
178
|
+
|
|
179
|
+
### 3.1 MindSpore 静态图场景
|
|
180
|
+
|
|
181
|
+
训练结束后,工具将 dump 的数据保存在 dump_path 参数指定的目录下。
|
|
182
|
+
|
|
183
|
+
- jit_level 为O0/O1时:
|
|
184
|
+
|
|
185
|
+
dump 结果目录请参见 MindSpore 官网中的[同步 Dump 数据对象目录](https://www.mindspore.cn/tutorials/experts/zh-CN/r2.3.1/debug/dump.html#%E6%95%B0%E6%8D%AE%E5%AF%B9%E8%B1%A1%E7%9B%AE%E5%BD%95%E5%92%8C%E6%95%B0%E6%8D%AE%E6%96%87%E4%BB%B6%E4%BB%8B%E7%BB%8D)。
|
|
186
|
+
|
|
187
|
+
- jit_level 为O2时:
|
|
188
|
+
|
|
189
|
+
dump 结果目录请参见 MindSpore 官网中的[异步 Dump 数据对象目录](https://www.mindspore.cn/tutorials/experts/zh-CN/r2.3.1/debug/dump.html#%E6%95%B0%E6%8D%AE%E5%AF%B9%E8%B1%A1%E7%9B%AE%E5%BD%95%E5%92%8C%E6%95%B0%E6%8D%AE%E6%96%87%E4%BB%B6%E4%BB%8B%E7%BB%8D-1)。
|
|
190
|
+
|
|
191
|
+
jit_level 请参见 [mindspore.set_context](https://www.mindspore.cn/docs/zh-CN/r2.3.1/api_python/mindspore/mindspore.set_context.html) 中的 jit_config 参数。
|
|
192
|
+
|
|
193
|
+
### 3.2 MindSpore 动态图场景
|
|
194
|
+
|
|
195
|
+
训练结束后,工具将 dump 的数据保存在dump_path参数指定的目录下。
|
|
196
|
+
|
|
197
|
+
dump结果目录结构示例如下:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
├── dump_path
|
|
201
|
+
│ ├── step0
|
|
202
|
+
│ | ├── rank0
|
|
203
|
+
│ | │ ├── dump_tensor_data
|
|
204
|
+
| | | | ├── MintFunctional.relu.0.backward.input.0.npy
|
|
205
|
+
| | | | ├── Mint.abs.0.forward.input.0.npy
|
|
206
|
+
| | | | ├── Functional.split.0.forward.input.0.npy
|
|
207
|
+
| | | | ...
|
|
208
|
+
| | | | └── Jit.AlexNet.0.forward.input.0.npy
|
|
209
|
+
| | | | └── Cell.relu.ReLU.forward.0.input.0.npy # config.json文件配置level为L0时dump的cell模块级数据,命名格式为{Cell}_{cell_name}_{class_name}_{前向反向}.{index}.{input/output}.{参数序号}
|
|
210
|
+
│ | | ├── 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范数(平方根)
|
|
211
|
+
│ | | ├── stack.json # 算子调用栈信息
|
|
212
|
+
│ | | └── construct.json # 分层分级结构,level为L1时,construct.json内容为空
|
|
213
|
+
│ | ├── rank1
|
|
214
|
+
| | | ├── dump_tensor_data
|
|
215
|
+
| | | | └── ...
|
|
216
|
+
│ | | ├── dump.json
|
|
217
|
+
│ | | ├── stack.json
|
|
218
|
+
| | | └── construct.json
|
|
219
|
+
│ | ├── ...
|
|
220
|
+
│ | |
|
|
221
|
+
| | └── rank7
|
|
222
|
+
│ ├── step1
|
|
223
|
+
│ | ├── ...
|
|
224
|
+
│ ├── step2
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
dump 过程中,npy 文件在对应算子或者模块被执行后就会落盘,而 json 文件则需要在正常执行 PrecisionDebugger.stop() 后才会写入完整数据,异常的程序终止会保存终止前被执行算子的相关 npy 文件,可能会导致 json 文件中数据丢失。
|
|
228
|
+
|
|
229
|
+
其中 rank 为设备上各卡的 ID,每张卡上 dump 的数据会生成对应 dump 目录。非分布式场景下没有 rank ID,目录名称为 rank。
|
|
230
|
+
|
|
231
|
+
动态图场景下使能 PSJit 或 PIJit,装饰特定 Cell 或 function,被装饰的部分会全部/部分使能**静态图**流程。PSJit 场景下 config.json 文件配置 level 为 L1 时,被 PSJit 装饰的部分也作为 API 被 dump 到对应目录;配置 level 为 L2 时,则只会 dump 用户网络中静态图流程下的相关 kernel, 其结果目录同jit_level 为 O0/O1 时的静态图 dump 相同。PIJit 场景开启 dump 工具后,会被还原为动态图,按 API 粒度进行 dump。
|
|
232
|
+
|
|
233
|
+
npy 文件保存的前缀和 MindSpore 对应关系如下:
|
|
234
|
+
|
|
235
|
+
| 前缀 | MindSpore 模块 |
|
|
236
|
+
| -------------- | ---------------------------- |
|
|
237
|
+
| Tensor | mindspore.Tensor |
|
|
238
|
+
| Functional | mindspore.ops |
|
|
239
|
+
| Primitive | mindspore.ops.Primitive |
|
|
240
|
+
| Mint | mindspore.mint |
|
|
241
|
+
| MintFunctional | mindspore.mint.nn.functional |
|
|
242
|
+
| Jit | mindspore.jit |
|
|
243
|
+
| Cell | mindspore.nn.Cell |
|