mindstudio-probe 1.0.1__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.1.dist-info → mindstudio_probe-1.0.4.dist-info}/LICENSE +201 -201
- {mindstudio_probe-1.0.1.dist-info → mindstudio_probe-1.0.4.dist-info}/METADATA +36 -30
- mindstudio_probe-1.0.4.dist-info/RECORD +276 -0
- {mindstudio_probe-1.0.1.dist-info → mindstudio_probe-1.0.4.dist-info}/WHEEL +1 -1
- {mindstudio_probe-1.0.1.dist-info → mindstudio_probe-1.0.4.dist-info}/entry_points.txt +1 -0
- msprobe/README.md +101 -182
- msprobe/__init__.py +1 -0
- msprobe/{config/config.json → config.json} +49 -27
- msprobe/core/__init__.py +0 -0
- msprobe/{pytorch → core}/advisor/advisor.py +124 -124
- msprobe/{pytorch → core}/advisor/advisor_const.py +59 -59
- msprobe/{pytorch → core}/advisor/advisor_result.py +58 -58
- msprobe/core/common/const.py +341 -241
- msprobe/core/common/exceptions.py +100 -88
- msprobe/core/common/{file_check.py → file_utils.py} +478 -265
- msprobe/core/common/log.py +76 -55
- msprobe/core/common/utils.py +385 -516
- msprobe/core/common_config.py +85 -58
- msprobe/core/compare/acc_compare.py +300 -0
- msprobe/core/compare/check.py +95 -0
- msprobe/core/compare/compare_cli.py +49 -0
- msprobe/core/compare/highlight.py +223 -0
- msprobe/core/compare/multiprocessing_compute.py +149 -0
- msprobe/{pytorch → core}/compare/npy_compare.py +295 -244
- msprobe/core/compare/utils.py +430 -0
- msprobe/core/data_dump/data_collector.py +154 -140
- msprobe/core/data_dump/data_processor/base.py +314 -245
- msprobe/core/data_dump/data_processor/factory.py +59 -61
- msprobe/core/data_dump/data_processor/mindspore_processor.py +186 -0
- msprobe/core/data_dump/data_processor/pytorch_processor.py +366 -346
- msprobe/core/data_dump/json_writer.py +96 -116
- msprobe/core/data_dump/scope.py +178 -178
- msprobe/core/grad_probe/__init__.py +0 -0
- msprobe/core/grad_probe/constant.py +71 -0
- msprobe/core/grad_probe/grad_compare.py +171 -0
- msprobe/core/grad_probe/utils.py +64 -0
- 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/docs/17.grad_probe.md +207 -0
- 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/docs/img/grad_probe_image-1.png +0 -0
- msprobe/docs/img/grad_probe_image-2.png +0 -0
- msprobe/docs/img/grad_probe_image-3.png +0 -0
- msprobe/docs/img/grad_probe_image-4.png +0 -0
- msprobe/docs/img/grad_probe_image.png +0 -0
- msprobe/mindspore/__init__.py +1 -1
- msprobe/mindspore/api_accuracy_checker/__init__.py +0 -0
- msprobe/mindspore/api_accuracy_checker/api_accuracy_checker.py +255 -0
- msprobe/mindspore/api_accuracy_checker/api_info.py +69 -0
- msprobe/mindspore/api_accuracy_checker/api_runner.py +156 -0
- msprobe/mindspore/api_accuracy_checker/base_compare_algorithm.py +197 -0
- msprobe/mindspore/api_accuracy_checker/cmd_parser.py +6 -0
- msprobe/mindspore/api_accuracy_checker/compute_element.py +239 -0
- msprobe/mindspore/api_accuracy_checker/main.py +9 -0
- msprobe/mindspore/api_accuracy_checker/type_mapping.py +114 -0
- msprobe/mindspore/api_accuracy_checker/utils.py +80 -0
- msprobe/mindspore/cell_processor.py +34 -0
- msprobe/mindspore/common/const.py +106 -0
- msprobe/mindspore/common/log.py +38 -0
- msprobe/mindspore/common/utils.py +81 -0
- msprobe/mindspore/compare/distributed_compare.py +75 -0
- msprobe/mindspore/compare/ms_compare.py +219 -0
- msprobe/mindspore/compare/ms_graph_compare.py +348 -0
- msprobe/mindspore/compare/ms_to_pt_api.yaml +399 -0
- msprobe/mindspore/debugger/debugger_config.py +66 -51
- msprobe/mindspore/debugger/precision_debugger.py +126 -32
- msprobe/mindspore/dump/dump_tool_factory.py +35 -38
- msprobe/mindspore/dump/hook_cell/api_registry.py +118 -0
- msprobe/mindspore/dump/hook_cell/hook_cell.py +55 -0
- msprobe/mindspore/dump/hook_cell/support_wrap_ops.yaml +922 -0
- msprobe/mindspore/dump/hook_cell/wrap_api.py +113 -0
- msprobe/mindspore/dump/jit_dump.py +72 -0
- msprobe/mindspore/dump/kernel_graph_dump.py +59 -60
- msprobe/mindspore/dump/kernel_kbyk_dump.py +64 -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 +43 -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/exchange_value.py +51 -0
- msprobe/mindspore/free_benchmark/perturbation/improve_precision.py +35 -0
- msprobe/mindspore/free_benchmark/perturbation/no_change.py +12 -0
- msprobe/mindspore/free_benchmark/perturbation/perturbation_factory.py +29 -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 +90 -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 +94 -0
- msprobe/mindspore/grad_probe/utils.py +30 -0
- msprobe/mindspore/ms_config.py +128 -78
- msprobe/mindspore/overflow_check/kernel_graph_overflow_check.py +44 -45
- msprobe/mindspore/overflow_check/overflow_check_tool_factory.py +34 -32
- msprobe/mindspore/runtime.py +4 -0
- msprobe/mindspore/service.py +378 -0
- msprobe/mindspore/task_handler_factory.py +24 -21
- msprobe/msprobe.py +105 -67
- msprobe/pytorch/__init__.py +4 -4
- msprobe/pytorch/api_accuracy_checker/common/config.py +53 -50
- msprobe/pytorch/api_accuracy_checker/common/utils.py +214 -224
- msprobe/pytorch/api_accuracy_checker/compare/algorithm.py +213 -216
- msprobe/pytorch/api_accuracy_checker/compare/api_precision_compare.py +606 -545
- 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 -345
- msprobe/pytorch/api_accuracy_checker/compare/compare_column.py +73 -73
- msprobe/pytorch/api_accuracy_checker/compare/compare_utils.py +245 -248
- msprobe/pytorch/api_accuracy_checker/config.yaml +10 -4
- msprobe/pytorch/api_accuracy_checker/run_ut/data_generate.py +335 -328
- msprobe/pytorch/api_accuracy_checker/run_ut/multi_run_ut.py +200 -203
- msprobe/pytorch/api_accuracy_checker/run_ut/run_overflow_check.py +133 -127
- msprobe/pytorch/api_accuracy_checker/run_ut/run_ut.py +592 -493
- msprobe/pytorch/api_accuracy_checker/run_ut/run_ut_utils.py +70 -7
- msprobe/pytorch/api_accuracy_checker/run_ut/torch_ut_setting.json +7 -4
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/__init__.py +0 -0
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/attl.py +197 -0
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/client.py +325 -0
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/device_dispatch.py +204 -0
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/server.py +219 -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 +509 -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/__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 -37
- msprobe/pytorch/common/utils.py +305 -224
- msprobe/pytorch/compare/distributed_compare.py +66 -111
- msprobe/pytorch/compare/mapping.yaml +607 -607
- msprobe/pytorch/compare/match.py +34 -36
- msprobe/pytorch/compare/pt_compare.py +50 -0
- msprobe/pytorch/debugger/debugger_config.py +95 -86
- msprobe/pytorch/debugger/precision_debugger.py +125 -95
- msprobe/pytorch/free_benchmark/__init__.py +8 -8
- msprobe/pytorch/free_benchmark/common/constant.py +70 -67
- 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 -98
- msprobe/pytorch/free_benchmark/compare/grad_saver.py +179 -183
- msprobe/pytorch/free_benchmark/compare/single_benchmark.py +104 -104
- msprobe/pytorch/free_benchmark/main.py +105 -102
- 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 -203
- 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 -31
- msprobe/pytorch/free_benchmark/result_handlers/preheat_handler.py +170 -170
- msprobe/pytorch/function_factory.py +76 -0
- msprobe/pytorch/functional/dump_module.py +39 -39
- msprobe/pytorch/grad_probe/__init__.py +0 -0
- msprobe/pytorch/grad_probe/grad_monitor.py +91 -0
- msprobe/pytorch/grad_probe/grad_stat_csv.py +129 -0
- msprobe/pytorch/hook_module/api_registry.py +161 -161
- msprobe/pytorch/hook_module/hook_module.py +120 -109
- msprobe/pytorch/hook_module/support_wrap_ops.yaml +1879 -1876
- msprobe/pytorch/hook_module/utils.py +30 -29
- msprobe/pytorch/hook_module/wrap_aten.py +110 -100
- msprobe/pytorch/hook_module/wrap_distributed.py +78 -75
- msprobe/pytorch/hook_module/wrap_functional.py +105 -108
- msprobe/pytorch/hook_module/wrap_npu_custom.py +93 -73
- msprobe/pytorch/hook_module/wrap_tensor.py +71 -72
- msprobe/pytorch/hook_module/wrap_torch.py +86 -88
- msprobe/pytorch/hook_module/wrap_vf.py +62 -64
- msprobe/pytorch/module_processer.py +138 -98
- msprobe/pytorch/online_dispatch/__init__.py +20 -20
- msprobe/pytorch/online_dispatch/compare.py +236 -236
- msprobe/pytorch/online_dispatch/dispatch.py +271 -273
- msprobe/pytorch/online_dispatch/dump_compare.py +155 -186
- 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 -187
- msprobe/pytorch/parse.py +4 -4
- msprobe/pytorch/parse_tool/cli.py +32 -32
- msprobe/pytorch/parse_tool/lib/compare.py +260 -259
- msprobe/pytorch/parse_tool/lib/config.py +52 -51
- 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 -367
- msprobe/pytorch/parse_tool/lib/visualization.py +85 -90
- msprobe/pytorch/pt_config.py +188 -93
- msprobe/pytorch/service.py +246 -167
- mindstudio_probe-1.0.1.dist-info/RECORD +0 -228
- msprobe/config/README.md +0 -397
- msprobe/mindspore/doc/dump.md +0 -65
- 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/pytorch/doc/FAQ.md +0 -193
- msprobe/pytorch/doc/api_accuracy_checker.md +0 -269
- msprobe/pytorch/doc/atat/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/dump.md +0 -207
- msprobe/pytorch/doc/ptdbg_ascend_compare.md +0 -176
- 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/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.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/{pytorch/doc → docs}/img/module_compare.png +0 -0
msprobe/config/README.md
DELETED
|
@@ -1,397 +0,0 @@
|
|
|
1
|
-
# 配置文件说明
|
|
2
|
-
|
|
3
|
-
当前配置文件主要为PrecisionDebugger接口执行dump或无标杆比对操作时调用的配置,当PrecisionDebugger接口未指定该配置文件时,使用该文件的默认配置。配置文件详见[config.json](./config.json)。
|
|
4
|
-
|
|
5
|
-
## 参数说明
|
|
6
|
-
|
|
7
|
-
### **通用配置参数**
|
|
8
|
-
|
|
9
|
-
| 参数名 | 说明 | 是否必选 |
|
|
10
|
-
| ----------------- | ------------------------------------------------------------ | -------- |
|
|
11
|
-
| task | dump的任务类型,str类型。可取值"free_benchmark"(无标杆比对,仅PyTorch场景支持)、"statistics"(仅dump API统计信息,默认值)、"tensor"(dump API统计信息和完全复刻整网的API运行情况的真实数据)、"overflow_check"(溢出检测)。配置示例:"task": "tensor"。根据task参数取值的不同,可以配置不同场景参数,详见:“**task配置为free_benchmark**”,“**task配置为statistics**”,“**task配置为tensor**”,“**task配置为overflow_check**”。 | 否 |
|
|
12
|
-
| dump_path | 设置dump数据目录路径,str类型。配置示例:"dump_path": "./dump_path"。MindSpore场景仅支持绝对路径。 | 是 |
|
|
13
|
-
| 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
|
-
| step | 指定dump某个step的数据,list[int]类型。默认未配置,表示dump所有step数据。dump特定step时,须指定为训练脚本中存在的step。step为list格式,可配置逐个step,例如:"step": [0,1,2]。 | 否 |
|
|
15
|
-
| level | dump级别,str类型,根据不同级别dump不同数据。可取值"L0"(dump module模块级精度数据,仅PyTorch场景支持,使用背景详见“**模块级精度数据dump说明**”)、"L1"(dump API级精度数据,默认值)、"L2"(dump kernel级精度数据,须配置acl_config参数)、"mix"(dump module模块级和API级精度数据,即"L0"+"L1",仅PyTorch场景支持)。配置示例:"level": "L1"。 | 否 |
|
|
16
|
-
| acl_config | kernel dump的配置文件,str类型。level取"L2"时,该参数必选;level为其他值时,该参数不选。参数示例:acl_config='./acl_config.json'。acl_config.json配置文件详细介绍请参见“**acl_config.json配置文件说明**”。 | 否 |
|
|
17
|
-
| seed | 随机种子数,int类型,默认值为:1234,仅PyTorch场景支持。通过固定随机数保证模型的输入或输出一致,可固定的随机数详见“**固定随机数范围**”。配置示例:"seed": 1234。 | 否 |
|
|
18
|
-
| is_deterministic | 确定性计算模式,bool类型,仅PyTorch场景支持。可取值true(开启)或false(关闭),默认关闭。配置示例:"is_deterministic": true。<br/>即使在相同的硬件和输入下,API多次执行的结果也可能不同,开启确定性计算是为了保证在相同的硬件和输入下,API多次执行的结果相同。<br/>确定性计算会导致API执行性能降低,建议在发现模型多次执行结果不同的情况下开启。<br/>rnn类算子、ReduceSum、ReduceMean等算子可能与确定性计算存在冲突,若开启确定性计算后多次执行的结果不相同,则考虑存在这些算子。 | 否 |
|
|
19
|
-
| enable_dataloader | 自动控制开关,bool类型,仅PyTorch场景支持。可取值true(开启)或false(关闭),默认为false。配置为True后自动识别step参数指定的迭代,并在该迭代执行完成后退出训练,此时start、stop和step函数可不配置,开启该开关要求训练脚本是通过torch.utils.data.dataloader方式加载数据。仅支持PyTorch单卡训练使用,分布式训练场景下存在数据dump不全问题,**下个版本即将废弃该功能**。 | 否 |
|
|
20
|
-
|
|
21
|
-
### task配置为free_benchmark
|
|
22
|
-
|
|
23
|
-
仅PyTorch场景支持。
|
|
24
|
-
|
|
25
|
-
task配置为free_benchmark时,开启**无标杆比对**,在NPU环境下通过对当前模型API的输入添加扰动因子,二次执行,将得到的输出与未添加扰动因子前的输出进行比对,从而**得出该模型中可能因迁移等变化导致精度降低的API**。
|
|
26
|
-
|
|
27
|
-
无标杆比对优势在于省去了从GPU环境获取dump数据并执行的步骤,也省去了在NPU环境执行dump的操作,降低了精度比对的操作难度。
|
|
28
|
-
|
|
29
|
-
建议配置白名单(配置scope或list)控制少量API进行无标杆比对,一次对过多API执行无标杆比对可能导致显存溢出或性能膨胀。
|
|
30
|
-
|
|
31
|
-
| 参数名 | 说明 | 是否必选 |
|
|
32
|
-
| ------------ | ------------------------------------------------------------ | -------- |
|
|
33
|
-
| scope | PyTorch场景dump范围,list[str]类型,默认未配置(list也未配置时表示dump所有API的数据)。需要在[]内配置两个模块名或API名,用于锁定区间,dump该范围内的数据。配置示例:"scope": ["MyModuleOP1", "MyModuleOP2"]。与level参数取值相关,level为L0和mix级别时,可配置模块名;level为L1级别时,可配置API名。与list参数不能同时配置。 | 否 |
|
|
34
|
-
| list | 自定义dump范围,list[str]类型,默认未配置(scope也未配置时表示dump所有API的数据)。包含如下配置方法:<br> PyTorch场景配置具体的API全称,dump该API数据。配置示例:"list": ["Tensor.permute.1.forward", "Tensor.transpose.2.forward", "Torch.relu.3.backward"]。<br/> PyTorch场景指定某一类API,dump某一类的API级别输入输出数据。配置示例:"list": ["relu"]。<br/> PyTorch场景配置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/>与scope参数不能同时配置。 | 否 |
|
|
35
|
-
| fuzz_device | 标杆设备,str类型。可取值:<br/> "npu":无标杆,通过添加扰动因子进行比对,默认值。<br/> "cpu":以CPU为标杆,pert_mode须配置为"to_cpu"。<br/>配置示例:"fuzz_device": "cpu"。 | 否 |
|
|
36
|
-
| pert_mode | 无标杆扰动因子,str类型。可取值:<br/> "improve_precision":对输入做升精度,默认值。<br/> "add_noise":对输入增加噪声。<br/> "no_change":不加扰动直接二次执行。<br/> "bit_noise":输入的末位比特翻转。<br/> "change_value":输入的张量首尾值调换。<br/> "to_cpu":在CPU等价执行。<br/>配置示例:"pert_mode": "to_cpu"。 | 否 |
|
|
37
|
-
| handler_type | 处理类型,可取值:"check"(进行无标杆比对检查,默认值)、"fix"(将扰动后的API输出结果覆盖原始API输出结果,尝试将Loss曲线恢复正常,该模式下不支持预热if_preheat)。配置示例:"handler_type": "fix"。 | 否 |
|
|
38
|
-
| fuzz_level | 无标杆数据dump级别,即选择比对结果文件应输出的表头属性,当前仅支持取值为:"L1"。输出结果详见“**无标杆比对数据存盘格式**”。 | 否 |
|
|
39
|
-
| fuzz_stage | 前反向,选择对API前向或反向进行无标杆比对,可取值:"forward"(前向,默认值)、"backward"(反向)。配置示例:"fuzz_stage": "backward"。 | 否 |
|
|
40
|
-
| if_preheat | 预热功能,开启功能后工具可以根据每次迭代的输出调整精度算法的阈值,从而更准确找出存在精度问题的API,bool类型。可取值true(开启)或false(关闭),默认关闭。配置示例:"if_preheat": "true"。"handler_type": "fix"不支持预热。 | 否 |
|
|
41
|
-
| preheat_step | 开启预热的迭代数量,int类型,默认值为15。须配置"if_preheat": "true"。 | 否 |
|
|
42
|
-
| max_sample | 每个算子预热的采样次数的最大阈值,int类型,默认值为20。须配置"if_preheat": "true"。 | 否 |
|
|
43
|
-
|
|
44
|
-
#### 无标杆比对数据存盘格式
|
|
45
|
-
|
|
46
|
-
无标杆比对在dump_path目录下输出结果文件free_benchmark.csv,如下示例:
|
|
47
|
-
|
|
48
|
-

|
|
49
|
-
|
|
50
|
-
| 字段 | 说明 |
|
|
51
|
-
| ------------ | ------------------------------------------------------------ |
|
|
52
|
-
| rank | Rank ID,int类型。 |
|
|
53
|
-
| pert_mode | 扰动因子的类型,string类型。 |
|
|
54
|
-
| stage | 前向或反向,string类型。 |
|
|
55
|
-
| step | 迭代数,int类型。 |
|
|
56
|
-
| api_name | API名称,string类型。 |
|
|
57
|
-
| max_rel | 输出对比最大相对误差,float类型。 |
|
|
58
|
-
| dtype | 输入的dtype,string类型。 |
|
|
59
|
-
| shape | 输入的shape,tuple类型。 |
|
|
60
|
-
| Output_index | 如果输出为列表或元组,其中一个元素检测不一致,则会有该元素的index,否则为空,int类型。 |
|
|
61
|
-
|
|
62
|
-
### task配置为statistics
|
|
63
|
-
|
|
64
|
-
| 参数名 | 说明 | 是否必选 |
|
|
65
|
-
| ------------ | ------------------------------------------------------------ | -------- |
|
|
66
|
-
| scope | PyTorch场景dump范围,list[str]类型,默认未配置(list也未配置时表示dump所有API的数据)。需要在[]内配置两个模块名或API名,用于锁定区间,dump该范围内的数据。配置示例:"scope": ["MyModuleOP1", "MyModuleOP2"]。与level参数取值相关,level为L0和mix级别时,可配置模块名;level为L1级别时,可配置API名。 | 否 |
|
|
67
|
-
| list | 自定义dump范围,list[str]类型,默认未配置(scope也未配置时表示dump所有API的数据)。包含如下配置方法:<br> PyTorch场景配置具体的API全称,dump该API数据。配置示例:"list": ["Tensor.permute.1.forward", "Tensor.transpose.2.forward", "Torch.relu.3.backward"]。<br/> PyTorch场景指定某一类API,dump某一类的API级别输入输出数据。配置示例:"list": ["relu"]。<br/> MindSpore场景配置kernel_name,可以是算子的名称列表,也可以指定算子类型("level": "L2"时不支持),还可以配置算子名称的正则表达式(当字符串符合”name-regex(xxx)”格式时,后台则会将其作为正则表达式。例如,”name-regex(Default/.+)”可匹配算子名称以”Default/”开头的所有算子)。 | 否 |
|
|
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场景仅支持"all"、"input"和"output"参数,且各参数只能单独配置,不支持自由组合。 | 否 |
|
|
69
|
-
| summary_mode | 控制dump文件输出的模式,str类型,仅PyTorch场景支持,可取值md5(dump输出包含md5值以及API统计信息的dump.json文件,用于验证数据的完整性)、statistics(dump仅输出包含API统计信息的dump.json文件,默认值)。配置示例:"summary_mode": "md5"。 | 否 |
|
|
70
|
-
|
|
71
|
-
### task配置为tensor
|
|
72
|
-
|
|
73
|
-
| 参数名 | 说明 | 是否必选 |
|
|
74
|
-
| -------------- | ------------------------------------------------------------ | -------- |
|
|
75
|
-
| scope | PyTorch场景dump范围,list[str]类型,默认未配置(list也未配置时表示dump所有API的数据)。需要在[]内配置两个模块名或API名,用于锁定区间,dump该范围内的数据。配置示例:"scope": ["MyModuleOP1", "MyModuleOP2"]。与level参数取值相关,level为L0和mix级别时,可配置模块名;level为L1级别时,可配置API名。 | 否 |
|
|
76
|
-
| list | 自定义dump范围,list[str]类型,默认未配置(scope也未配置时表示dump所有API的数据)。包含如下配置方法:<br> PyTorch场景配置具体的API全称,dump该API数据。配置示例:"list": ["Tensor.permute.1.forward", "Tensor.transpose.2.forward", "Torch.relu.3.backward"]。<br/> PyTorch场景指定某一类API,dump某一类的API级别输入输出数据。配置示例:"list": ["relu"]。<br/> PyTorch场景配置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
|
-
| 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场景仅支持"all"、"input"和"output"参数,且各参数只能单独配置,不支持自由组合。 | 否 |
|
|
79
|
-
| file_format | MindSpore场景真实tensor数据的保存格式,str类型,可取值"bin"(dump的tensor文件为二进制格式,"level": "L1"时不支持)、"npy"(dump的tensor文件后缀为.npy,默认值)。 | 否 |
|
|
80
|
-
|
|
81
|
-
### task配置为overflow_check
|
|
82
|
-
|
|
83
|
-
| 参数名 | 说明 | 是否必选 |
|
|
84
|
-
| ------------- | ------------------------------------------------------------ | -------- |
|
|
85
|
-
| overflow_nums | 控制溢出次数,int类型,仅PyTorch场景支持,表示第N次溢出时,停止训练,过程中检测到溢出API对应kernel数据均dump。配置示例:"overflow_nums": 3。默认为1,即检测到1次溢出,训练停止,配置为-1时,表示持续检测溢出直到训练结束。 | 否 |
|
|
86
|
-
| check_mode | MindSpore场景kernel级别的溢出检测,str类型,可取值"aicore"(开启AI Core的溢出检测)、"atomic"(开启Atomic的溢出检测)、"all"(开启AI Core和Atomic的溢出检测,默认值)。配置示例"check_mode": "aicore"。 | 否 |
|
|
87
|
-
|
|
88
|
-
## 配置示例
|
|
89
|
-
|
|
90
|
-
以下示例包含当前支持的所有场景可配置的完整参数。
|
|
91
|
-
|
|
92
|
-
### PyTorch场景task配置为free_benchmark
|
|
93
|
-
|
|
94
|
-
```json
|
|
95
|
-
{
|
|
96
|
-
"task": "free_benchmark",
|
|
97
|
-
"dump_path": "/home/data_dump",
|
|
98
|
-
"rank": [],
|
|
99
|
-
"step": [],
|
|
100
|
-
"level": "L1",
|
|
101
|
-
"seed": 1234,
|
|
102
|
-
"is_deterministic": false,
|
|
103
|
-
"enable_dataloader": false,
|
|
104
|
-
|
|
105
|
-
"free_benchmark": {
|
|
106
|
-
"scope": [],
|
|
107
|
-
"list": ["conv2d"],
|
|
108
|
-
"fuzz_device": "npu",
|
|
109
|
-
"pert_mode": "improve_precision",
|
|
110
|
-
"handler_type": "check",
|
|
111
|
-
"fuzz_level": "L1",
|
|
112
|
-
"fuzz_stage": "forward",
|
|
113
|
-
"if_preheat": false,
|
|
114
|
-
"preheat_step": 15,
|
|
115
|
-
"max_sample": 20
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
### PyTorch场景task配置为statistics
|
|
121
|
-
|
|
122
|
-
```json
|
|
123
|
-
{
|
|
124
|
-
"task": "statistics",
|
|
125
|
-
"dump_path": "/home/data_dump",
|
|
126
|
-
"rank": [],
|
|
127
|
-
"step": [],
|
|
128
|
-
"level": "L1",
|
|
129
|
-
"seed": 1234,
|
|
130
|
-
"is_deterministic": false,
|
|
131
|
-
"enable_dataloader": false,
|
|
132
|
-
|
|
133
|
-
"statistics": {
|
|
134
|
-
"scope": [],
|
|
135
|
-
"list": [],
|
|
136
|
-
"data_mode": ["all"],
|
|
137
|
-
"summary_mode": "statistics"
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### PyTorch场景task配置为tensor
|
|
143
|
-
|
|
144
|
-
```json
|
|
145
|
-
{
|
|
146
|
-
"task": "tensor",
|
|
147
|
-
"dump_path": "/home/data_dump",
|
|
148
|
-
"rank": [],
|
|
149
|
-
"step": [],
|
|
150
|
-
"level": "L1",
|
|
151
|
-
"seed": 1234,
|
|
152
|
-
"is_deterministic": false,
|
|
153
|
-
"enable_dataloader": false,
|
|
154
|
-
|
|
155
|
-
"tensor": {
|
|
156
|
-
"scope": [],
|
|
157
|
-
"list":[],
|
|
158
|
-
"data_mode": ["all"],
|
|
159
|
-
"backward_input": ""
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
### PyTorch场景task配置为overflow_check
|
|
165
|
-
|
|
166
|
-
```json
|
|
167
|
-
{
|
|
168
|
-
"task": "overflow_check",
|
|
169
|
-
"dump_path": "/home/data_dump",
|
|
170
|
-
"rank": [],
|
|
171
|
-
"step": [],
|
|
172
|
-
"level": "L1",
|
|
173
|
-
"seed": 1234,
|
|
174
|
-
"is_deterministic": false,
|
|
175
|
-
"enable_dataloader": false,
|
|
176
|
-
|
|
177
|
-
"overflow_check": {
|
|
178
|
-
"overflow_nums": 1
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
### MindSpore场景task配置为statistics
|
|
184
|
-
|
|
185
|
-
```json
|
|
186
|
-
{
|
|
187
|
-
"task": "statistics",
|
|
188
|
-
"dump_path": "/home/data_dump",
|
|
189
|
-
"rank": [],
|
|
190
|
-
"step": [],
|
|
191
|
-
"level": "L1",
|
|
192
|
-
"seed": 1234,
|
|
193
|
-
"is_deterministic": false,
|
|
194
|
-
|
|
195
|
-
"statistics": {
|
|
196
|
-
"list": [],
|
|
197
|
-
"data_mode": ["all"],
|
|
198
|
-
"summary_mode": "statistics"
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
### MindSpore场景task配置为tensor
|
|
204
|
-
|
|
205
|
-
```json
|
|
206
|
-
{
|
|
207
|
-
"task": "tensor",
|
|
208
|
-
"dump_path": "/home/data_dump",
|
|
209
|
-
"rank": [],
|
|
210
|
-
"step": [],
|
|
211
|
-
"level": "L1",
|
|
212
|
-
"seed": 1234,
|
|
213
|
-
"is_deterministic": false,
|
|
214
|
-
|
|
215
|
-
"tensor": {
|
|
216
|
-
"list":[],
|
|
217
|
-
"data_mode": ["all"],
|
|
218
|
-
"backward_input": ""
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
### MindSpore场景task配置为overflow_check
|
|
224
|
-
|
|
225
|
-
```json
|
|
226
|
-
{
|
|
227
|
-
"task": "overflow_check",
|
|
228
|
-
"dump_path": "/home/data_dump",
|
|
229
|
-
"rank": [],
|
|
230
|
-
"step": [],
|
|
231
|
-
"level": "L1",
|
|
232
|
-
"seed": 1234,
|
|
233
|
-
"is_deterministic": false,
|
|
234
|
-
|
|
235
|
-
"overflow_check": {
|
|
236
|
-
"overflow_nums": 1,
|
|
237
|
-
"check_mode": "all"
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
## 附录
|
|
243
|
-
|
|
244
|
-
### 模块级精度数据dump说明
|
|
245
|
-
|
|
246
|
-
仅PyTorch场景支持。
|
|
247
|
-
|
|
248
|
-
大模型场景下,通常不是简单的利用自动迁移能力实现GPU到NPU的训练脚本迁移,而是会对NPU网络进行一系列针对性的适配,因此,常常会造成迁移后的NPU模型存在部分子结构不能与GPU原始模型完全对应。模型结构不一致导致API调用类型及数量不一致,若直接按照API粒度进行精度数据dump和比对,则无法完全比对所有的API。
|
|
249
|
-
|
|
250
|
-
本节介绍的功能是对模型中的大粒度模块进行数据dump,使其比对时,对于无法以API粒度比对的模块可以直接以模块粒度进行比对。
|
|
251
|
-
|
|
252
|
-
模块指的是继承自nn.Module类模块,通常情况下这类模块就是一个小模型,可以被视为一个整体,dump数据时以模块为粒度进行dump。
|
|
253
|
-
|
|
254
|
-
### acl_config.json配置文件说明
|
|
255
|
-
|
|
256
|
-
#### [config.json](./config.json)配置示例
|
|
257
|
-
|
|
258
|
-
当level取"L2"时,须配置acl_config参数,并指定acl_config.json文件(用于指定L2 kernel级dump的配置),此时config.json文件配置示例如下:
|
|
259
|
-
|
|
260
|
-
- 前向kernel dump配置示例:
|
|
261
|
-
|
|
262
|
-
"scope"配置为前向API名称,仅支持配置一个API。
|
|
263
|
-
|
|
264
|
-
```json
|
|
265
|
-
{
|
|
266
|
-
"task": "tensor",
|
|
267
|
-
"dump_path": "/home/data_dump",
|
|
268
|
-
"level": "L2",
|
|
269
|
-
"rank": [0],
|
|
270
|
-
"step": [0],
|
|
271
|
-
"is_deterministic": false,
|
|
272
|
-
"tensor": {
|
|
273
|
-
"scope": ["Tensor.__mul__.10.forward"],
|
|
274
|
-
"list":[],
|
|
275
|
-
"data_mode": ["all"],
|
|
276
|
-
"backward_input": [""],
|
|
277
|
-
"file_format": "npy"
|
|
278
|
-
},
|
|
279
|
-
"acl_config": "acl_config.json"
|
|
280
|
-
}
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
- 反向kernel dump配置示例:
|
|
284
|
-
|
|
285
|
-
执行反向kernel dump前需要先使用工具dump该API的反向输入,保存pt文件,在"backward_input"参数中传入该pt文件路径。
|
|
286
|
-
|
|
287
|
-
"scope"配置为反向API名称,仅支持配置一个API。
|
|
288
|
-
|
|
289
|
-
```json
|
|
290
|
-
{
|
|
291
|
-
"task": "tensor",
|
|
292
|
-
"dump_path": "/home/data_dump",
|
|
293
|
-
"level": "L2",
|
|
294
|
-
"rank": [0],
|
|
295
|
-
"step": [0],
|
|
296
|
-
"is_deterministic": false,
|
|
297
|
-
"tensor": {
|
|
298
|
-
"scope": ["Tensor.__mul__.10.backward"],
|
|
299
|
-
"list":[],
|
|
300
|
-
"data_mode": ["all"],
|
|
301
|
-
"backward_input": ["Tensor.__mul__.10.backward.input.0.pt"],
|
|
302
|
-
"file_format": "npy"
|
|
303
|
-
},
|
|
304
|
-
"acl_config": "acl_config.json"
|
|
305
|
-
}
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
#### acl_config.json配置示例
|
|
309
|
-
|
|
310
|
-
acl_config.json文件须自行创建,配置示例如下:
|
|
311
|
-
|
|
312
|
-
```
|
|
313
|
-
{
|
|
314
|
-
"dump":
|
|
315
|
-
{
|
|
316
|
-
"dump_list":[],
|
|
317
|
-
"dump_path":"./dump/output",
|
|
318
|
-
"dump_mode":"all",
|
|
319
|
-
"dump_op_switch":"on"
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
**acl_config.json参数说明**
|
|
325
|
-
|
|
326
|
-
| 字段名 | 说明 |
|
|
327
|
-
| -------------- | ------------------------------------------------------------ |
|
|
328
|
-
| dump_list | 待dump数据的API模型。为空,无需配置。 |
|
|
329
|
-
| dump_path | dump数据文件存储到运行环境的目录,主要用于指定kernel dump数据路径。支持配置绝对路径或相对路径。dump_path须为已存在目录。 |
|
|
330
|
-
| dump_mode | dump数据模式,配置如下: output:dump API的输出数据。默认值。 input:dump API的输入数据。 all:dump API的输入、输出数据。 |
|
|
331
|
-
| dump_op_switch | 单API模型dump数据开关,配置如下:<br> off:关闭单API模型dump,默认值。<br> on:开启单API模型dump。 |
|
|
332
|
-
|
|
333
|
-
**dump目录说明**
|
|
334
|
-
|
|
335
|
-
配置register_hook的dump_config后,采集的dump数据会在{dump_path}/{time}/{deviceid}/{model_id}目录下生成,例如“/home/HwHiAiUser/output/20200808163566/0/0”
|
|
336
|
-
|
|
337
|
-
```
|
|
338
|
-
├── 20230131172437
|
|
339
|
-
│ └── 1
|
|
340
|
-
│ ├── 0
|
|
341
|
-
│ │ ├── Add.Add.45.0.1675157077183551
|
|
342
|
-
│ │ ├── Cast.trans_Cast_0.31.0.1675157077159449
|
|
343
|
-
│ │ ├── Cast.trans_Cast_5.43.0.1675157077180129
|
|
344
|
-
│ │ ├── MatMul.MatMul.39.0.1675157077172961
|
|
345
|
-
│ │ ├── Mul.Mul.29.0.1675157077155731
|
|
346
|
-
│ │ ├── NPUAllocFloatStatus.NPUAllocFloatStatus.24.0.1675157077145262
|
|
347
|
-
│ │ ├── TransData.trans_TransData_1.33.0.1675157077162791
|
|
348
|
-
│ │ └── TransData.trans_TransData_4.41.0.1675157077176648
|
|
349
|
-
│ ├── 1701737061
|
|
350
|
-
│ │ └── Cast.trans_Cast_2.35.0.1675157077166214
|
|
351
|
-
│ ├── 25
|
|
352
|
-
│ │ └── NPUClearFloatStatus.NPUClearFloatStatus.26.0.1675157077150342
|
|
353
|
-
│ └── 68
|
|
354
|
-
│ └── TransData.trans_TransData_3.37.0.1675157077169473
|
|
355
|
-
```
|
|
356
|
-
|
|
357
|
-
### 固定随机数范围
|
|
358
|
-
|
|
359
|
-
仅PyTorch场景支持。
|
|
360
|
-
|
|
361
|
-
seed_all函数可固定随机数的范围如下表。
|
|
362
|
-
|
|
363
|
-
| API | 固定随机数 |
|
|
364
|
-
| ---------------------------------------- | --------------------------- |
|
|
365
|
-
| os.environ['PYTHONHASHSEED'] = str(seed) | 禁止Python中的hash随机化 |
|
|
366
|
-
| random.seed(seed) | 设置random随机生成器的种子 |
|
|
367
|
-
| np.random.seed(seed) | 设置numpy中随机生成器的种子 |
|
|
368
|
-
| torch.manual_seed(seed) | 设置当前CPU的随机种子 |
|
|
369
|
-
| torch.cuda.manual_seed(seed) | 设置当前GPU的随机种子 |
|
|
370
|
-
| torch.cuda.manual_seed_all(seed) | 设置所有GPU的随机种子 |
|
|
371
|
-
| torch_npu.npu.manual_seed(seed) | 设置当前NPU的随机种子 |
|
|
372
|
-
| torch_npu.npu.manual_seed_all(seed) | 设置所有NPU的随机种子 |
|
|
373
|
-
| torch.backends.cudnn.enable=False | 关闭cuDNN |
|
|
374
|
-
| torch.backends.cudnn.benchmark=False | cuDNN确定性地选择算法 |
|
|
375
|
-
| torch.backends.cudnn.deterministic=True | cuDNN仅使用确定性的卷积算法 |
|
|
376
|
-
|
|
377
|
-
需要保证CPU或GPU以及NPU的模型输入完全一致,dump数据的比对才有意义,seed_all并不能保证模型输入完全一致,如下表所示场景需要保证输入的一致性。
|
|
378
|
-
|
|
379
|
-
| 场景 | 固定方法 |
|
|
380
|
-
| --------------- | ------------- |
|
|
381
|
-
| 数据集的shuffle | 关闭shuffle。 |
|
|
382
|
-
| dropout | 关闭dropout。 |
|
|
383
|
-
|
|
384
|
-
关闭shuffle示例:
|
|
385
|
-
|
|
386
|
-
```Python
|
|
387
|
-
train_loader = torch.utils.data.DataLoader(
|
|
388
|
-
train_dataset,
|
|
389
|
-
batch_size = batch_size,
|
|
390
|
-
shuffle = False,
|
|
391
|
-
num_workers = num_workers
|
|
392
|
-
)
|
|
393
|
-
```
|
|
394
|
-
|
|
395
|
-
关闭dropout:
|
|
396
|
-
|
|
397
|
-
在使用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。
|
msprobe/mindspore/doc/dump.md
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
# **精度数据采集**
|
|
2
|
-
|
|
3
|
-
msprobe工具主要通过在训练脚本内添加dump接口并启动训练的方式来采集精度数据。
|
|
4
|
-
|
|
5
|
-
执行dump操作需要安装msprobe工具。详见《[MindStudio精度调试工具](../../README.md)》的“工具安装”章节。
|
|
6
|
-
|
|
7
|
-
## dump接口介绍
|
|
8
|
-
|
|
9
|
-
### PrecisionDebugger
|
|
10
|
-
|
|
11
|
-
**功能说明**
|
|
12
|
-
|
|
13
|
-
通过加载dump配置文件的方式来确定dump操作的详细配置。
|
|
14
|
-
|
|
15
|
-
可以在from msprobe.mindspore import PrecisionDebugger和模型初始化之间的任意位置添加该接口。
|
|
16
|
-
|
|
17
|
-
**原型**
|
|
18
|
-
|
|
19
|
-
```Python
|
|
20
|
-
PrecisionDebugger(config_path=None)
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
**参数说明**
|
|
24
|
-
|
|
25
|
-
| 参数名 | 说明 | 是否必选 |
|
|
26
|
-
| ----------- | ------------------------------------------------------------ | -------- |
|
|
27
|
-
| config_path | 指定dump配置文件路径,String类型。参数示例:"./config.json"。未配置该路径时,默认使用[config.json](../../config)文件的默认配置。config.json文件可以配置更多参数,若需要进行更多场景的精度数据dump,建议配置[config.json](../../config/config.json)文件。 | 否 |
|
|
28
|
-
|
|
29
|
-
### start函数
|
|
30
|
-
|
|
31
|
-
**功能说明**
|
|
32
|
-
|
|
33
|
-
启动函数。
|
|
34
|
-
|
|
35
|
-
**原型**
|
|
36
|
-
|
|
37
|
-
```Python
|
|
38
|
-
debugger.start()
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
该函数为类函数,可以使用debugger.start()也可以使用PrecisionDebugger.start()。
|
|
42
|
-
|
|
43
|
-
## 示例代码
|
|
44
|
-
|
|
45
|
-
```Python
|
|
46
|
-
from msprobe.mindspore import PrecisionDebugger
|
|
47
|
-
debugger = PrecisionDebugger(config_path="./config.json")
|
|
48
|
-
# 请勿将以上初始化流程插入到循环代码中
|
|
49
|
-
# 下面代码也可以用PrecisionDebugger.start()
|
|
50
|
-
debugger.start()
|
|
51
|
-
...
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## dump结果文件介绍
|
|
55
|
-
|
|
56
|
-
训练结束后,工具将dump的数据保存在dump_path参数指定的目录下。
|
|
57
|
-
|
|
58
|
-
- level为L1时
|
|
59
|
-
|
|
60
|
-
dump结果目录请参见MindSpore官网中的《[同步Dump数据对象目录](https://www.mindspore.cn/tutorials/experts/zh-CN/r2.3.0rc2/debug/dump.html#%E5%90%8C%E6%AD%A5dump%E6%95%B0%E6%8D%AE%E5%AF%B9%E8%B1%A1%E7%9B%AE%E5%BD%95)》。
|
|
61
|
-
|
|
62
|
-
- level为L2时
|
|
63
|
-
|
|
64
|
-
dump结果目录请参见MindSpore官网中的《[异步Dump数据对象目录](https://www.mindspore.cn/tutorials/experts/zh-CN/r2.3.0rc2/debug/dump.html#%E5%BC%82%E6%AD%A5dump%E6%95%B0%E6%8D%AE%E5%AF%B9%E8%B1%A1%E7%9B%AE%E5%BD%95)》。
|
|
65
|
-
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import json
|
|
3
|
-
from msprobe.core.common.utils import make_dump_path_if_not_exists
|
|
4
|
-
from msprobe.mindspore.debugger.debugger_config import DebuggerConfig
|
|
5
|
-
from msprobe.core.common.log import logger
|
|
6
|
-
from msprobe.core.common.file_check import FileOpen
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class ApiKbkDump:
|
|
10
|
-
def __init__(self, config: DebuggerConfig):
|
|
11
|
-
self.dump_json = dict()
|
|
12
|
-
self.dump_json["common_dump_settings"] = dict()
|
|
13
|
-
self.dump_json["common_dump_settings"]["dump_mode"] = 0
|
|
14
|
-
self.dump_json["common_dump_settings"]["path"] = ""
|
|
15
|
-
self.dump_json["common_dump_settings"]["net_name"] = "Net"
|
|
16
|
-
self.dump_json["common_dump_settings"]["iteration"] = "all"
|
|
17
|
-
self.dump_json["common_dump_settings"]["saved_data"] = "statistic"
|
|
18
|
-
self.dump_json["common_dump_settings"]["input_output"] = 0
|
|
19
|
-
self.dump_json["common_dump_settings"]["kernels"] = []
|
|
20
|
-
self.dump_json["common_dump_settings"]["support_device"] = [0,1,2,3,4,5,6,7]
|
|
21
|
-
self.dump_json["e2e_dump_settings"] = dict()
|
|
22
|
-
self.dump_json["e2e_dump_settings"]["enable"] = True
|
|
23
|
-
self.dump_json["e2e_dump_settings"]["trans_flag"] = True
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if len(config.list) > 0:
|
|
27
|
-
self.dump_json["common_dump_settings"]["dump_mode"] = 1
|
|
28
|
-
self.dump_json["common_dump_settings"]["kernels"] = config.list
|
|
29
|
-
self.dump_json["common_dump_settings"]["path"] = config.dump_path
|
|
30
|
-
if len(config.step) > 0:
|
|
31
|
-
step_str = ""
|
|
32
|
-
for s in config.step:
|
|
33
|
-
step_str += (str(s) + '|')
|
|
34
|
-
self.dump_json["common_dump_settings"]["iteration"] = step_str[:-1]
|
|
35
|
-
if len(config.rank) > 0:
|
|
36
|
-
self.dump_json["common_dump_settings"]["support_device"] = config.rank
|
|
37
|
-
if config.task == "tensor":
|
|
38
|
-
self.dump_json["common_dump_settings"]["saved_data"] = "tensor"
|
|
39
|
-
if len(config.data_mode) == 1:
|
|
40
|
-
if config.data_mode[0] == "input":
|
|
41
|
-
self.dump_json["common_dump_settings"]["input_output"] = 1
|
|
42
|
-
if config.data_mode[0] == "output":
|
|
43
|
-
self.dump_json["common_dump_settings"]["input_output"] = 2
|
|
44
|
-
|
|
45
|
-
def handle(self):
|
|
46
|
-
json_path = self.dump_json["common_dump_settings"]["path"]
|
|
47
|
-
make_dump_path_if_not_exists(json_path)
|
|
48
|
-
json_path = os.path.join(json_path, "api_kbk_dump.json")
|
|
49
|
-
with FileOpen(json_path, 'w') as f:
|
|
50
|
-
json.dump(self.dump_json, f)
|
|
51
|
-
logger.info(json_path + " has been created.")
|
|
52
|
-
os.environ["GRAPH_OP_RUN"] = "1"
|
|
53
|
-
os.environ["MINDSPORE_DUMP_CONFIG"] = json_path
|
|
54
|
-
if "MS_ACL_DUMP_CFG_PATH" in os.environ:
|
|
55
|
-
del os.environ["MS_ACL_DUMP_CFG_PATH"]
|