mindstudio-probe 1.2.2__py3-none-any.whl → 8.1.0__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.2.2.dist-info → mindstudio_probe-8.1.0.dist-info}/METADATA +4 -3
- {mindstudio_probe-1.2.2.dist-info → mindstudio_probe-8.1.0.dist-info}/RECORD +243 -191
- msprobe/README.md +57 -21
- msprobe/core/__init__.py +17 -0
- msprobe/core/common/const.py +224 -82
- msprobe/core/common/decorator.py +50 -0
- msprobe/core/common/exceptions.py +5 -3
- msprobe/core/common/file_utils.py +274 -40
- msprobe/core/common/framework_adapter.py +169 -0
- msprobe/core/common/global_lock.py +86 -0
- msprobe/core/common/runtime.py +25 -0
- msprobe/core/common/utils.py +148 -72
- msprobe/core/common_config.py +7 -0
- msprobe/core/compare/acc_compare.py +640 -462
- msprobe/core/compare/check.py +36 -107
- msprobe/core/compare/compare_cli.py +4 -0
- msprobe/core/compare/config.py +72 -0
- msprobe/core/compare/highlight.py +217 -215
- msprobe/core/compare/layer_mapping/layer_mapping.py +4 -1
- msprobe/core/compare/merge_result/merge_result.py +12 -6
- msprobe/core/compare/multiprocessing_compute.py +227 -107
- msprobe/core/compare/npy_compare.py +32 -16
- msprobe/core/compare/utils.py +218 -244
- msprobe/{mindspore/runtime.py → core/config_check/__init__.py} +2 -4
- msprobe/{pytorch/dump/kernel_dump/kernel_config.py → core/config_check/checkers/__init__.py} +8 -16
- msprobe/core/config_check/checkers/base_checker.py +60 -0
- msprobe/core/config_check/checkers/dataset_checker.py +138 -0
- msprobe/core/config_check/checkers/env_args_checker.py +96 -0
- msprobe/core/config_check/checkers/hyperparameter_checker.py +170 -0
- msprobe/core/config_check/checkers/pip_checker.py +90 -0
- msprobe/core/config_check/checkers/random_checker.py +367 -0
- msprobe/core/config_check/checkers/weights_checker.py +147 -0
- msprobe/core/config_check/ckpt_compare/ckpt_comparator.py +74 -0
- msprobe/core/config_check/ckpt_compare/megatron_loader.py +302 -0
- msprobe/core/config_check/ckpt_compare/metrics.py +83 -0
- msprobe/core/config_check/ckpt_compare/name_mapping.yaml +12 -0
- msprobe/core/config_check/config_check_cli.py +51 -0
- msprobe/core/config_check/config_checker.py +100 -0
- msprobe/{pytorch/parse.py → core/config_check/resource/dependency.yaml} +7 -4
- msprobe/core/config_check/resource/env.yaml +57 -0
- msprobe/core/config_check/resource/hyperparameter.yaml +21 -0
- msprobe/core/config_check/utils/hyperparameter_parser.py +115 -0
- msprobe/core/config_check/utils/utils.py +107 -0
- msprobe/core/data_dump/api_registry.py +239 -0
- msprobe/core/data_dump/data_collector.py +36 -9
- msprobe/core/data_dump/data_processor/base.py +74 -53
- msprobe/core/data_dump/data_processor/mindspore_processor.py +119 -78
- msprobe/core/data_dump/data_processor/pytorch_processor.py +134 -96
- msprobe/core/data_dump/json_writer.py +146 -57
- msprobe/core/debugger/precision_debugger.py +143 -0
- msprobe/core/grad_probe/constant.py +2 -1
- msprobe/core/grad_probe/grad_compare.py +2 -2
- msprobe/core/grad_probe/utils.py +1 -1
- msprobe/core/hook_manager.py +242 -0
- msprobe/core/monitor/anomaly_processor.py +384 -0
- msprobe/core/overflow_check/abnormal_scene.py +2 -0
- msprobe/core/service.py +356 -0
- msprobe/core/single_save/__init__.py +0 -0
- msprobe/core/single_save/single_comparator.py +243 -0
- msprobe/core/single_save/single_saver.py +157 -0
- msprobe/docs/01.installation.md +6 -5
- msprobe/docs/02.config_introduction.md +89 -30
- msprobe/docs/03.config_examples.md +1 -0
- msprobe/docs/04.kernel_dump_PyTorch.md +1 -1
- msprobe/docs/05.data_dump_PyTorch.md +184 -50
- msprobe/docs/06.data_dump_MindSpore.md +193 -28
- msprobe/docs/07.accuracy_checker_PyTorch.md +13 -3
- msprobe/docs/08.accuracy_checker_online_PyTorch.md +72 -10
- msprobe/docs/09.accuracy_checker_MindSpore.md +19 -7
- msprobe/docs/10.accuracy_compare_PyTorch.md +266 -102
- msprobe/docs/11.accuracy_compare_MindSpore.md +117 -43
- msprobe/docs/12.overflow_check_PyTorch.md +5 -3
- msprobe/docs/13.overflow_check_MindSpore.md +6 -4
- msprobe/docs/14.data_parse_PyTorch.md +4 -10
- msprobe/docs/17.grad_probe.md +2 -1
- msprobe/docs/18.online_dispatch.md +3 -3
- msprobe/docs/19.monitor.md +211 -103
- msprobe/docs/21.visualization_PyTorch.md +100 -28
- msprobe/docs/22.visualization_MindSpore.md +103 -31
- msprobe/docs/23.generate_operator_PyTorch.md +9 -9
- msprobe/docs/25.tool_function_introduction.md +23 -22
- msprobe/docs/26.data_dump_PyTorch_baseline.md +14 -3
- msprobe/docs/27.dump_json_instruction.md +278 -8
- msprobe/docs/28.debugger_save_instruction.md +111 -20
- msprobe/docs/28.kernel_dump_MindSpore.md +1 -1
- msprobe/docs/29.data_dump_MSAdapter.md +229 -0
- msprobe/docs/30.overflow_check_MSAdapter.md +31 -0
- msprobe/docs/31.config_check.md +95 -0
- msprobe/docs/32.ckpt_compare.md +69 -0
- msprobe/docs/33.generate_operator_MindSpore.md +190 -0
- msprobe/docs/34.RL_collect.md +92 -0
- msprobe/docs/35.nan_analyze.md +72 -0
- msprobe/docs/FAQ.md +3 -11
- msprobe/docs/data_dump_MindSpore/data_dump_MindSpore_baseline.md +12 -1
- msprobe/docs/data_dump_MindSpore/dynamic_graph_quick_start_example.md +3 -1
- msprobe/docs/img/compare_result.png +0 -0
- msprobe/docs/img/merge_result.png +0 -0
- msprobe/docs/img/save_compare_result_sample.png +0 -0
- msprobe/docs/img/visualization/proxy.png +0 -0
- msprobe/docs/img/visualization/vis_browser_1.png +0 -0
- msprobe/docs/img/visualization/vis_match_info.png +0 -0
- msprobe/docs/img/visualization/vis_precision_info.png +0 -0
- msprobe/docs/img/visualization/vis_search_info.png +0 -0
- msprobe/docs/img/visualization/vis_show_info.png +0 -0
- msprobe/docs/img/visualization/vis_showcase.png +0 -0
- msprobe/docs/img/visualization/vis_unmatch_info.png +0 -0
- msprobe/mindspore/__init__.py +3 -3
- msprobe/mindspore/api_accuracy_checker/api_accuracy_checker.py +151 -55
- msprobe/mindspore/api_accuracy_checker/api_runner.py +25 -11
- msprobe/mindspore/api_accuracy_checker/base_compare_algorithm.py +2 -1
- msprobe/mindspore/api_accuracy_checker/bench_functions/flash_attention_score.py +580 -0
- msprobe/mindspore/api_accuracy_checker/bench_functions/fusion_operator.py +41 -0
- msprobe/mindspore/api_accuracy_checker/cmd_parser.py +4 -0
- msprobe/mindspore/api_accuracy_checker/data_manager.py +4 -3
- msprobe/mindspore/api_accuracy_checker/generate_op_script/config_op.json +9 -0
- msprobe/mindspore/api_accuracy_checker/generate_op_script/op_generator.py +451 -0
- msprobe/mindspore/api_accuracy_checker/generate_op_script/operator_replication.template +2081 -0
- msprobe/mindspore/api_accuracy_checker/multi_api_accuracy_checker.py +11 -1
- msprobe/mindspore/api_accuracy_checker/torch_mindtorch_importer.py +2 -1
- msprobe/mindspore/cell_processor.py +204 -33
- msprobe/mindspore/code_mapping/graph_parser.py +4 -21
- msprobe/mindspore/common/const.py +73 -2
- msprobe/mindspore/common/utils.py +157 -29
- msprobe/mindspore/compare/common_dir_compare.py +382 -0
- msprobe/mindspore/compare/distributed_compare.py +2 -26
- msprobe/mindspore/compare/ms_compare.py +18 -398
- msprobe/mindspore/compare/ms_graph_compare.py +20 -10
- msprobe/mindspore/compare/utils.py +37 -0
- msprobe/mindspore/debugger/debugger_config.py +59 -7
- msprobe/mindspore/debugger/precision_debugger.py +83 -90
- msprobe/mindspore/dump/cell_dump_process.py +902 -0
- msprobe/mindspore/dump/cell_dump_with_insert_gradient.py +889 -0
- msprobe/mindspore/dump/dump_tool_factory.py +18 -8
- msprobe/mindspore/dump/graph_mode_cell_dump.py +139 -0
- msprobe/mindspore/dump/graph_tensor_dump.py +123 -0
- msprobe/mindspore/dump/hook_cell/api_register.py +176 -0
- msprobe/mindspore/dump/hook_cell/hook_cell.py +22 -12
- msprobe/mindspore/dump/hook_cell/ms_hook_manager.py +88 -0
- msprobe/mindspore/dump/hook_cell/primitive_hooks.py +8 -2
- msprobe/mindspore/dump/hook_cell/support_wrap_ops.yaml +42 -26
- msprobe/mindspore/dump/jit_dump.py +35 -27
- msprobe/mindspore/dump/kernel_kbyk_dump.py +6 -3
- msprobe/mindspore/dym_loader/hook_dynamic_loader.cpp +110 -0
- msprobe/mindspore/dym_loader/hook_dynamic_loader.h +15 -16
- msprobe/mindspore/free_benchmark/api_pynative_self_check.py +22 -12
- msprobe/mindspore/free_benchmark/common/utils.py +1 -1
- msprobe/mindspore/free_benchmark/perturbation/perturbation_factory.py +4 -2
- msprobe/mindspore/free_benchmark/self_check_tool_factory.py +6 -3
- msprobe/mindspore/grad_probe/global_context.py +9 -2
- msprobe/mindspore/grad_probe/grad_analyzer.py +2 -1
- msprobe/mindspore/grad_probe/grad_stat_csv.py +3 -2
- msprobe/mindspore/grad_probe/hook.py +2 -4
- msprobe/mindspore/mindspore_service.py +111 -0
- msprobe/mindspore/monitor/common_func.py +52 -0
- msprobe/mindspore/monitor/data_writers.py +237 -0
- msprobe/mindspore/monitor/distributed/wrap_distributed.py +1 -1
- msprobe/mindspore/monitor/features.py +13 -1
- msprobe/mindspore/monitor/module_hook.py +568 -444
- msprobe/mindspore/monitor/optimizer_collect.py +331 -0
- msprobe/mindspore/monitor/utils.py +71 -9
- msprobe/mindspore/ms_config.py +16 -15
- msprobe/mindspore/overflow_check/overflow_check_tool_factory.py +5 -3
- msprobe/mindspore/task_handler_factory.py +5 -2
- msprobe/msprobe.py +19 -0
- msprobe/nan_analyze/__init__.py +14 -0
- msprobe/nan_analyze/analyzer.py +255 -0
- msprobe/nan_analyze/graph.py +189 -0
- msprobe/nan_analyze/utils.py +211 -0
- msprobe/pytorch/api_accuracy_checker/common/config.py +2 -2
- msprobe/pytorch/api_accuracy_checker/compare/api_precision_compare.py +3 -6
- msprobe/pytorch/api_accuracy_checker/compare/compare.py +36 -34
- msprobe/pytorch/api_accuracy_checker/generate_op_script/op_generator.py +15 -13
- msprobe/pytorch/api_accuracy_checker/generate_op_script/operator_replication.template +206 -4
- msprobe/pytorch/api_accuracy_checker/run_ut/multi_run_ut.py +9 -9
- msprobe/pytorch/api_accuracy_checker/run_ut/run_overflow_check.py +6 -5
- msprobe/pytorch/api_accuracy_checker/run_ut/run_ut.py +31 -9
- msprobe/pytorch/api_accuracy_checker/run_ut/run_ut_utils.py +28 -20
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/attl.py +3 -1
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/client.py +29 -13
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/device_dispatch.py +12 -2
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/server.py +45 -31
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/utils.py +154 -0
- msprobe/pytorch/attl_manager.py +65 -0
- msprobe/pytorch/bench_functions/moe_gating_top_k_softmax.py +6 -0
- msprobe/pytorch/bench_functions/npu_fusion_attention.py +27 -0
- msprobe/pytorch/common/utils.py +53 -19
- msprobe/pytorch/compare/distributed_compare.py +4 -36
- msprobe/pytorch/compare/pt_compare.py +13 -84
- msprobe/pytorch/compare/utils.py +47 -0
- msprobe/pytorch/debugger/debugger_config.py +34 -17
- msprobe/pytorch/debugger/precision_debugger.py +50 -96
- msprobe/pytorch/dump/module_dump/hook_wrapper.py +93 -0
- msprobe/pytorch/dump/module_dump/module_dump.py +15 -61
- msprobe/pytorch/dump/module_dump/module_processer.py +150 -114
- msprobe/pytorch/free_benchmark/common/utils.py +1 -1
- msprobe/pytorch/free_benchmark/compare/single_benchmark.py +1 -1
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/add_noise.py +3 -3
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/bit_noise.py +3 -3
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/change_value.py +1 -1
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/improve_precision.py +1 -1
- msprobe/pytorch/free_benchmark/result_handlers/check_handler.py +1 -1
- msprobe/pytorch/function_factory.py +1 -1
- msprobe/pytorch/grad_probe/grad_monitor.py +2 -2
- msprobe/pytorch/grad_probe/grad_stat_csv.py +3 -2
- msprobe/pytorch/hook_module/api_register.py +155 -0
- msprobe/pytorch/hook_module/hook_module.py +18 -22
- msprobe/pytorch/hook_module/jit_script_wrapper.py +33 -0
- msprobe/pytorch/hook_module/pt_hook_manager.py +68 -0
- msprobe/pytorch/hook_module/register_optimizer_hook.py +2 -1
- msprobe/pytorch/hook_module/support_wrap_ops.yaml +193 -75
- msprobe/pytorch/hook_module/utils.py +28 -2
- msprobe/pytorch/monitor/csv2tb.py +14 -4
- msprobe/pytorch/monitor/data_writers.py +259 -0
- msprobe/pytorch/monitor/distributed/wrap_distributed.py +8 -2
- msprobe/pytorch/monitor/module_hook.py +336 -241
- msprobe/pytorch/monitor/module_metric.py +17 -0
- msprobe/pytorch/monitor/optimizer_collect.py +244 -224
- msprobe/pytorch/monitor/utils.py +84 -4
- msprobe/pytorch/online_dispatch/compare.py +0 -2
- msprobe/pytorch/online_dispatch/dispatch.py +13 -2
- msprobe/pytorch/online_dispatch/dump_compare.py +8 -2
- msprobe/pytorch/online_dispatch/utils.py +3 -0
- msprobe/pytorch/parse_tool/lib/interactive_cli.py +1 -6
- msprobe/pytorch/parse_tool/lib/utils.py +5 -4
- msprobe/pytorch/pt_config.py +16 -11
- msprobe/pytorch/pytorch_service.py +70 -0
- msprobe/visualization/builder/graph_builder.py +69 -10
- msprobe/visualization/builder/msprobe_adapter.py +24 -12
- msprobe/visualization/compare/graph_comparator.py +63 -51
- msprobe/visualization/compare/mode_adapter.py +22 -20
- msprobe/visualization/graph/base_node.py +11 -4
- msprobe/visualization/graph/distributed_analyzer.py +1 -10
- msprobe/visualization/graph/graph.py +2 -13
- msprobe/visualization/graph/node_op.py +1 -2
- msprobe/visualization/graph_service.py +251 -104
- msprobe/visualization/utils.py +26 -44
- msprobe/mindspore/dump/hook_cell/api_registry.py +0 -207
- msprobe/mindspore/dump/hook_cell/wrap_api.py +0 -212
- msprobe/mindspore/dym_loader/hook_dynamic_loader.cc +0 -140
- msprobe/mindspore/monitor/anomaly_detect.py +0 -404
- msprobe/mindspore/monitor/module_spec_verifier.py +0 -94
- msprobe/mindspore/service.py +0 -543
- msprobe/pytorch/hook_module/api_registry.py +0 -166
- msprobe/pytorch/hook_module/wrap_distributed.py +0 -79
- msprobe/pytorch/hook_module/wrap_functional.py +0 -66
- msprobe/pytorch/hook_module/wrap_npu_custom.py +0 -85
- msprobe/pytorch/hook_module/wrap_tensor.py +0 -69
- msprobe/pytorch/hook_module/wrap_torch.py +0 -84
- msprobe/pytorch/hook_module/wrap_vf.py +0 -60
- msprobe/pytorch/monitor/anomaly_analyse.py +0 -201
- msprobe/pytorch/monitor/anomaly_detect.py +0 -410
- msprobe/pytorch/monitor/module_spec_verifier.py +0 -95
- msprobe/pytorch/monitor/unittest/test_monitor.py +0 -160
- msprobe/pytorch/service.py +0 -470
- {mindstudio_probe-1.2.2.dist-info → mindstudio_probe-8.1.0.dist-info}/LICENSE +0 -0
- {mindstudio_probe-1.2.2.dist-info → mindstudio_probe-8.1.0.dist-info}/WHEEL +0 -0
- {mindstudio_probe-1.2.2.dist-info → mindstudio_probe-8.1.0.dist-info}/entry_points.txt +0 -0
- {mindstudio_probe-1.2.2.dist-info → mindstudio_probe-8.1.0.dist-info}/top_level.txt +0 -0
- /msprobe/{mindspore → core}/compare/ms_to_pt_api.yaml +0 -0
- /msprobe/{mindspore/dump → core}/kernel_dump/kernel_config.py +0 -0
- /msprobe/{pytorch/monitor/unittest → core/monitor}/__init__.py +0 -0
|
@@ -51,14 +51,14 @@ msprobe -f pytorch compare -i ./compare.json -o ./output -s
|
|
|
51
51
|
|
|
52
52
|
完整参数说明:
|
|
53
53
|
|
|
54
|
-
| 参数名 | 说明
|
|
55
|
-
|
|
56
|
-
| -i 或 --input_path | 指定[比对文件](#
|
|
57
|
-
| -o 或 --output_path | 配置比对结果文件存盘目录,str 类型,默认在当前目录创建output目录。文件名称基于时间戳自动生成,格式为:`compare_result_{timestamp}.xlsx
|
|
58
|
-
| -s 或 --stack_mode | 比对结果展示调用栈信息(NPU_Stack_Info)的开关,bool 类型。单卡场景开启时,根据[比对文件](#
|
|
54
|
+
| 参数名 | 说明 | 是否必选 |
|
|
55
|
+
|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -------- |
|
|
56
|
+
| -i 或 --input_path | 指定[比对文件](#51-比对文件),str 类型。 | 是 |
|
|
57
|
+
| -o 或 --output_path | 配置比对结果文件存盘目录,str 类型,默认在当前目录创建output目录。文件名称基于时间戳自动生成,格式为:`compare_result_{timestamp}.xlsx`。<br>提示:output目录下与结果件同名文件将被删除覆盖。 | 否 |
|
|
58
|
+
| -s 或 --stack_mode | 比对结果展示调用栈信息(NPU_Stack_Info)的开关,bool 类型。单卡场景开启时,根据[比对文件](#51-比对文件)的参数说明配置stack_path;多卡场景开启时,自动识别npu_dump目录下stack.json文件,如存在生成详细调用栈信息,否则不生成,此参数不生效。通过直接配置该参数开启,默认未配置,表示关闭。 | 否 |
|
|
59
59
|
| -c 或 --compare_only | 仅比对开关,bool 类型。该参数默认未配置,会启用自动精度分析,工具自动针对比对结果进行分析,识别到第一个精度可能不达标节点(在比对结果文件中的 Accuracy Reached or Not 列显示为 No),并给出问题可能产生的原因(打屏展示并生成 `advisor_{timestamp}.txt` 文件)。通过配置该参数取消自动精度分析,仅输出比对结果表格。 | 否 |
|
|
60
|
-
| -f 或 --fuzzy_match | 模糊匹配,bool 类型。开启后,对于网络中同一层级且命名仅调用次数不同的 API,可匹配并进行比对。通过直接配置该参数开启,默认未配置,表示关闭。
|
|
61
|
-
| -dm或--data_mapping | 自定义映射关系比对。需要指定自定义映射文件*.yaml。自定义映射文件的格式请参见[自定义映射文件](#
|
|
60
|
+
| -f 或 --fuzzy_match | 模糊匹配,bool 类型。开启后,对于网络中同一层级且命名仅调用次数不同的 API,可匹配并进行比对。通过直接配置该参数开启,默认未配置,表示关闭。 | 否 |
|
|
61
|
+
| -dm或--data_mapping | 自定义映射关系比对。需要指定自定义映射文件*.yaml。自定义映射文件的格式请参见[自定义映射文件](#52-自定义映射文件)。仅[API和模块无法自动匹配场景](#213-api和模块无法自动匹配场景)需要配置。仅支持逐卡比对,即使用[比对文件](#51-比对文件)的单卡场景示例。 | 否 |
|
|
62
62
|
|
|
63
63
|
#### 2.1.2 整网比对场景
|
|
64
64
|
|
|
@@ -66,19 +66,17 @@ msprobe -f pytorch compare -i ./compare.json -o ./output -s
|
|
|
66
66
|
|
|
67
67
|
支持单卡和多卡,可同时比对多卡的 dump 数据。多机场景需要每个设备单独执行比对操作。
|
|
68
68
|
|
|
69
|
-
1.
|
|
70
|
-
|
|
71
|
-
2. 参见 [PyTorch 场景下的数据采集](./05.data_dump_PyTorch.md)章节完成 CPU 或 GPU 与 NPU 的精度数据 dump。
|
|
69
|
+
1. 参见 [PyTorch 场景下的数据采集](./05.data_dump_PyTorch.md)章节完成 CPU 或 GPU 与 NPU 的精度数据 dump。
|
|
72
70
|
|
|
73
|
-
|
|
71
|
+
2. 创建[比对文件](#51-比对文件)。
|
|
74
72
|
|
|
75
|
-
|
|
73
|
+
3. 运行命令:
|
|
76
74
|
|
|
77
75
|
```shell
|
|
78
76
|
msprobe -f pytorch compare -i ./compare.json -o ./output -s
|
|
79
77
|
```
|
|
80
78
|
|
|
81
|
-
|
|
79
|
+
4. 查看比对结果,请参见 [3 精度比对结果分析](#3-精度比对结果分析)。
|
|
82
80
|
|
|
83
81
|
#### 2.1.3 API和模块无法自动匹配场景
|
|
84
82
|
|
|
@@ -88,7 +86,7 @@ msprobe -f pytorch compare -i ./compare.json -o ./output -s
|
|
|
88
86
|
|
|
89
87
|
2. 参见[PyTorch 场景下的数据采集](./05.data_dump_PyTorch.md)章节完成 CPU 或 GPU 与 NPU 的精度数据 dump。
|
|
90
88
|
|
|
91
|
-
3. 创建[比对文件](#
|
|
89
|
+
3. 创建[比对文件](#51-比对文件)(单卡场景示例)。
|
|
92
90
|
|
|
93
91
|
4. 运行命令:
|
|
94
92
|
|
|
@@ -96,75 +94,30 @@ msprobe -f pytorch compare -i ./compare.json -o ./output -s
|
|
|
96
94
|
msprobe -f pytorch compare -i ./compare.json -o ./output -s -dm data_mapping.yaml
|
|
97
95
|
```
|
|
98
96
|
|
|
99
|
-
data_mapping.yaml文件配置请参见[自定义映射文件](#
|
|
97
|
+
data_mapping.yaml文件配置请参见[自定义映射文件](#52-自定义映射文件)。
|
|
100
98
|
|
|
101
99
|
该场景不支持-f模糊匹配。
|
|
102
100
|
|
|
103
101
|
5. 查看比对结果,请参见 [3 精度比对结果分析](#3-精度比对结果分析)。
|
|
104
102
|
|
|
105
|
-
#### 2.1.4 比对文件
|
|
106
|
-
|
|
107
|
-
以在当前目录创建 ./compare.json 为例。
|
|
108
|
-
|
|
109
|
-
- 单卡场景示例:
|
|
110
|
-
|
|
111
|
-
```json
|
|
112
|
-
{
|
|
113
|
-
"npu_path": "./npu_dump/dump.json",
|
|
114
|
-
"bench_path": "./bench_dump/dump.json",
|
|
115
|
-
"stack_path": "./npu_dump/stack.json",
|
|
116
|
-
"is_print_compare_log": true
|
|
117
|
-
}
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
- 多卡场景示例:
|
|
121
103
|
|
|
122
|
-
|
|
123
|
-
{
|
|
124
|
-
"npu_path": "./npu_dump/step0",
|
|
125
|
-
"bench_path": "./bench_dump/step0",
|
|
126
|
-
"is_print_compare_log": true
|
|
127
|
-
}
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
**参数说明**:
|
|
104
|
+
#### 2.1.4 单点数据比对场景
|
|
131
105
|
|
|
132
|
-
|
|
133
|
-
| -------------------- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------|
|
|
134
|
-
| npu_path | 配置 NPU 环境下的 dump.json 文件(单卡场景)或真实数据目录(多卡场景),str 类型。 | 是 |
|
|
135
|
-
| bench_path | 配置 CPU、GPU 或 NPU 环境下的 dump.json 文件(单卡场景)或真实数据目录(多卡场景),str 类型。 | 是 |
|
|
136
|
-
| stack_path | 配置 NPU dump 目录下的 stack.json 文件,str 类型。如果没有配置stack_path,命令行-s参数不生效,程序自动识别是否存在stack.json文件,如存在,则比对结果中呈现NPU_Stack_Info,如不存在,则不呈现。如果配置了stack_path,比对结果中是否呈现NPU_Stack_Info则通过命令行参数-s来控制。 | 否 |
|
|
137
|
-
| is_print_compare_log | 配置是否开启单个算子的日志打屏。可取值 true 或 false,默认为 true。关闭后则只输出常规日志,bool 类型。 | 否 |
|
|
106
|
+
单点数据比对场景是指:CPU 或 GPU 与 NPU环境的网络中单点保存的数据比对。
|
|
138
107
|
|
|
139
|
-
|
|
108
|
+
支持单卡和多卡,可同时比对多卡的单点数据。多机场景需要每个设备单独执行比对操作。
|
|
140
109
|
|
|
141
|
-
|
|
110
|
+
1. 参见 [单点保存工具](./28.debugger_save_instruction.md)章节完成 CPU 或 GPU 与 NPU 的单点数据采集。
|
|
142
111
|
|
|
143
|
-
|
|
112
|
+
2. 创建[比对文件(单点数据)](#53-比对文件单点数据)。
|
|
144
113
|
|
|
145
|
-
|
|
146
|
-
# API
|
|
147
|
-
{api_type}.{api_name}.{API调用次数}.{前向反向}.{input/output}.{参数序号}: {api_type}.{api_name}.{API调用次数}.{前向反向}.{input/output}.{参数序号}
|
|
148
|
-
# 模块
|
|
149
|
-
{Module}.{module_name}.{前向反向}.{index}.{input/output}.{参数序号}: {Module}.{module_name}.{前向反向}.{index}.{input/output}.{参数序号}
|
|
150
|
-
```
|
|
114
|
+
3. 运行命令:
|
|
151
115
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
文件内容示例:
|
|
157
|
-
|
|
158
|
-
```yaml
|
|
159
|
-
# API
|
|
160
|
-
NPU.npu_fusion_attention.4.forward.input.0: NPU.npu_fusion_attention.4.forward.input.0
|
|
161
|
-
# 模块
|
|
162
|
-
Module.module.language_model.embedding.word_embedding.VocabParallelEmbedding.forward.0.input.0: Module.module.language_model.embedding.word_embedding.VocabParallelEmbedding.forward.0.input.0
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
API和模块名称在dump.json文件中的“data_name”字段展示,如下图红框处所示:
|
|
116
|
+
```shell
|
|
117
|
+
msprobe -f pytorch compare -i ./compare.json -o ./output
|
|
118
|
+
```
|
|
166
119
|
|
|
167
|
-
|
|
120
|
+
4. 查看比对结果,请参见 [3 精度比对结果分析](#3-精度比对结果分析)。
|
|
168
121
|
|
|
169
122
|
### 2.2 比对函数方式
|
|
170
123
|
|
|
@@ -180,13 +133,13 @@ compare(input_param, output_path, stack_mode=False, auto_analyze=True, fuzzy_mat
|
|
|
180
133
|
|
|
181
134
|
**参数说明**:
|
|
182
135
|
|
|
183
|
-
| 参数名 | 说明
|
|
184
|
-
| ------------
|
|
136
|
+
| 参数名 | 说明 | 是否必选 |
|
|
137
|
+
| ------------ |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -------- |
|
|
185
138
|
| input_param | 配置 dump 数据文件及目录,dict 类型。配置参数包括:<br> "npu_json_path":指定 NPU dump 目录下的 dump.json 文件。<br/>**配置示例**:"npu_json_path": "./npu_dump/dump.json"。<br/> "bench_json_path":指定 CPU、GPU 或 NPU dump 目录下的 dump.json 文件。<br/>**配置示例**:"bench_json_path": "./bench_dump/dump.json"。<br/> "stack_json_path":指定 NPU dump 目录下的 stack.json 文件。<br/>**配置示例**:"stack_json_path": "./npu_dump/stack.json"。<br/> "is_print_compare_log":配置是否开启单个算子的日志打屏。<br/>**配置示例**:True 或 False。 | 是 |
|
|
186
|
-
| output_path | 配置比对结果文件存盘目录,str 类型。<br/>**配置示例**:'./output'。文件名称基于时间戳自动生成,格式为:`compare_result_{timestamp}.xlsx
|
|
187
|
-
| stack_mode | 配置 stack_mode 的开关,bool 类型。仅当配置 stack_json_path 时需要,开启时比对结果呈现NPU_Stack_Info,关闭时不呈现。当不配置stack_json_path 时,自动识别是否存在stack.json,存在时呈现NPU_Stack_Info,否则不呈现。<br/>**配置示例**:stack_mode=True,默认为 False。
|
|
188
|
-
| auto_analyze | 自动精度分析,bool 类型。开启后工具自动针对比对结果进行分析,识别到第一个精度可能不达标节点(在比对结果文件中的 Accuracy Reached or Not 列显示为 No),并给出问题可能产生的原因(打屏展示并生成 advisor_{timestamp}.txt 文件)。<br/>**配置示例**:auto_analyze=False,默认为 True。
|
|
189
|
-
| fuzzy_match | 模糊匹配,bool 类型。开启后,对于网络中同一层级且命名仅调用次数不同的 API,可匹配并进行比对。<br/>**配置示例**:fuzzy_match=True,默认为 False。
|
|
139
|
+
| output_path | 配置比对结果文件存盘目录,str 类型。<br/>**配置示例**:'./output'。文件名称基于时间戳自动生成,格式为:`compare_result_{timestamp}.xlsx`。<br>提示:output目录下与结果件同名文件将被删除覆盖。 | 是 |
|
|
140
|
+
| stack_mode | 配置 stack_mode 的开关,bool 类型。仅当配置 stack_json_path 时需要,开启时比对结果呈现NPU_Stack_Info,关闭时不呈现。当不配置stack_json_path 时,自动识别是否存在stack.json,存在时呈现NPU_Stack_Info,否则不呈现。<br/>**配置示例**:stack_mode=True,默认为 False。 | 否 |
|
|
141
|
+
| auto_analyze | 自动精度分析,bool 类型。开启后工具自动针对比对结果进行分析,识别到第一个精度可能不达标节点(在比对结果文件中的 Accuracy Reached or Not 列显示为 No),并给出问题可能产生的原因(打屏展示并生成 advisor_{timestamp}.txt 文件)。<br/>**配置示例**:auto_analyze=False,默认为 True。 | 否 |
|
|
142
|
+
| fuzzy_match | 模糊匹配,bool 类型。开启后,对于网络中同一层级且命名仅调用次数不同的 API,可匹配并进行比对。<br/>**配置示例**:fuzzy_match=True,默认为 False。 | 否 |
|
|
190
143
|
|
|
191
144
|
**函数示例**:
|
|
192
145
|
|
|
@@ -215,12 +168,12 @@ compare_distributed(npu_dump_dir, bench_dump_dir, output_path, **kwargs)
|
|
|
215
168
|
|
|
216
169
|
**参数说明**:
|
|
217
170
|
|
|
218
|
-
| 参数名 | 说明
|
|
219
|
-
| --------------
|
|
220
|
-
| npu_dump_dir | 配置 NPU 环境下的 dump 目录。str 类型。dump 数据目录须指定到 step 级。<br/>**配置示例**:'./npu_dump/step0'。
|
|
221
|
-
| bench_dump_dir | 配置 CPU、GPU 或 NPU 环境下的 dump 目录。str 类型。<br/>**配置示例**:'./gpu_dump/step0'。
|
|
222
|
-
| output_path | 配置比对结果文件存盘目录。需要预先创建 output_path 目录。str 类型。<br/>**配置示例**:'./output'。文件名称基于时间戳自动生成,格式为:`compare_result_rank{npu_ID}
|
|
223
|
-
| **kwargs | 支持 compare 的所有可选参数。 其中,stack_mode不生效,自动识别是否存在stack.json,如存在,呈现NPU_Stack_Info,否则不呈现。
|
|
171
|
+
| 参数名 | 说明 | 是否必选 |
|
|
172
|
+
| -------------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -------- |
|
|
173
|
+
| npu_dump_dir | 配置 NPU 环境下的 dump 目录。str 类型。dump 数据目录须指定到 step 级。<br/>**配置示例**:'./npu_dump/step0'。 | 是 |
|
|
174
|
+
| bench_dump_dir | 配置 CPU、GPU 或 NPU 环境下的 dump 目录。str 类型。<br/>**配置示例**:'./gpu_dump/step0'。 | 是 |
|
|
175
|
+
| output_path | 配置比对结果文件存盘目录。需要预先创建 output_path 目录。str 类型。<br/>**配置示例**:'./output'。文件名称基于时间戳自动生成,格式为:`compare_result_rank{npu_ID}_{timestamp}.xlsx`。<br>提示:output目录下与结果件同名文件将被删除覆盖。 | 是 |
|
|
176
|
+
| **kwargs | 支持 compare 的所有可选参数。 其中,stack_mode不生效,自动识别是否存在stack.json,如存在,呈现NPU_Stack_Info,否则不呈现。 | 否 |
|
|
224
177
|
|
|
225
178
|
**函数示例**:
|
|
226
179
|
|
|
@@ -257,11 +210,11 @@ PyTorch 精度比对是以 CPU 或 GPU 的计算结果为标杆,通过计算
|
|
|
257
210
|
|
|
258
211
|
统计量有 4 种:最大值(max)、最小值(min)、平均值(mean)和 L2-范数(L2 norm)。
|
|
259
212
|
|
|
260
|
-
|dump 数据模式|Cosine (tensor 余弦相似度)|MaxAbsErr (tensor 最大绝对误差)|MaxRelativeErr (tensor 最大相对误差)|One Thousandth Err Ratio (tensor 相对误差小于千分之一的比例)|Five Thousandth Err Ratio (tensor 相对误差小于千分之五的比例)|NPU 和 bench 的统计量绝对误差 (max, min, mean, L2 norm) diff| NPU 和 bench 的统计量相对误差 (max, min, mean, L2 norm) RelativeErr |NPU 和 bench 的统计量 (max, min, mean, L2 norm)|NPU MD5 (NPU 数据 CRC-32 值)|BENCH MD5 (bench 数据 CRC-32 值)|Result (比对结果)|Accuracy Reached or Not (计算精度是否达标)|Err_message (错误信息提示)|NPU_Stack_Info (堆栈信息)|Data_Name (NPU
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|MD5
|
|
213
|
+
|dump 数据模式|Cosine (tensor 余弦相似度)|EucDist (tensor 欧式距离)|MaxAbsErr (tensor 最大绝对误差)|MaxRelativeErr (tensor 最大相对误差)|One Thousandth Err Ratio (tensor 相对误差小于千分之一的比例)|Five Thousandth Err Ratio (tensor 相对误差小于千分之五的比例)|NPU 和 bench 的统计量绝对误差 (max, min, mean, L2 norm) diff| NPU 和 bench 的统计量相对误差 (max, min, mean, L2 norm) RelativeErr |NPU 和 bench 的统计量 (max, min, mean, L2 norm)|NPU MD5 (NPU 数据 CRC-32 值)|BENCH MD5 (bench 数据 CRC-32 值)|Result (比对结果)|Accuracy Reached or Not (计算精度是否达标)|Err_message (错误信息提示)|NPU_Stack_Info (堆栈信息)| Data_Name ([NPU真实数据名,Bench真实数据名]) |
|
|
214
|
+
|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---------------------------------:|
|
|
215
|
+
|真实数据模式|√|√|√|√|√|√|||√||||√|√|√| √ |
|
|
216
|
+
|统计数据模式|||||||√|√|√|||√||√|√| |
|
|
217
|
+
|MD5 模式||||||||||√|√|√|||√| |
|
|
265
218
|
|
|
266
219
|
上表中NPU_Stack_Info字段需要配置-s参数生成。
|
|
267
220
|
|
|
@@ -315,12 +268,12 @@ MD5 模式:
|
|
|
315
268
|
|
|
316
269
|
1. "Need double check api accuracy.":四个统计值中至少 1 个相对误差 > 0.5(统计数据模式);
|
|
317
270
|
2. "Fuzzy matching data, the comparison arruracy may be affected.":NPU 或 Bench 的真实数据名没有匹配上(真实数据模式);
|
|
318
|
-
3. "Dump file: {} not found.":NPU
|
|
271
|
+
3. "Dump file: {} not found or read failed.":NPU 或 Bench 的真实数据不存在或者读取出错(真实数据模式);
|
|
319
272
|
4. "No bench data matched.":Bench 的 API 没有匹配上、Bench 真实数据不存在或读取出错(真实数据模式);
|
|
320
273
|
5. "This is empty data, can not compare.":读取到的数据为空(真实数据模式);
|
|
321
274
|
6. "Shape of NPU and bench Tensor do not match. Skipped.":NPU 和 Bench 的数据结构不一致(真实数据模式);
|
|
322
275
|
7. "The Position of inf or nan in NPU and bench Tensor do not match.":NPU 和 Bench 的数据有 nan/inf(真实数据模式);
|
|
323
|
-
8. "This is type of 0-d tensor, can not calculate 'Cosine', 'One Thousandth Err Ratio' and 'Five Thousandths Err Ratio'.":NPU 为0维张量(真实数据模式);
|
|
276
|
+
8. "This is type of 0-d tensor, can not calculate 'Cosine', 'EucDist', 'One Thousandth Err Ratio' and 'Five Thousandths Err Ratio'.":NPU 为0维张量(真实数据模式);
|
|
324
277
|
9. "Dtype of NPU and bench Tensor do not match.":NPU 和 Bench 数据的数据类型不同(真实数据模式);
|
|
325
278
|
10. "":除以上情况的其余情况(真实数据模式、统计数据模式)。
|
|
326
279
|
|
|
@@ -330,18 +283,24 @@ MD5 模式:
|
|
|
330
283
|
|
|
331
284
|
1. Cosine:通过计算两个向量的余弦值来判断其相似度,数值越接近于 1 说明计算出的两个张量越相似,实际可接受阈值为大于 0.99。在计算中可能会存在 nan,主要由于可能会出现其中一个向量为 0。
|
|
332
285
|
|
|
333
|
-
2.
|
|
286
|
+
2. EucDist:通过计算两个向量的欧式距离来判断其相似度,定义为多维空间中两个点之间的绝对距离。数值越接近0,张量越相似,数值越大,差异越大。
|
|
334
287
|
|
|
335
|
-
3.
|
|
288
|
+
3. MaxAbsErr:当最大绝对误差越接近 0 表示其计算的误差越小,实际可接受阈值为小于 0.001。
|
|
336
289
|
|
|
337
|
-
|
|
290
|
+
4. MaxRelativeErr:当最大相对误差越接近 0 表示其计算的误差越小。
|
|
338
291
|
|
|
339
|
-
|
|
292
|
+
当 dump 数据中存在 0 或 nan 时,比对结果中最大相对误差则出现 inf 或 nan 的情况,属于正常现象。
|
|
293
|
+
|
|
294
|
+
5. One Thousandth Err Ratio(相对误差小于千分之一的元素比例)、Five Thousandths Err Ratio(相对误差小于千分之五的元素比例)精度指标:是指 NPU 的 Tensor 中的元素逐个与对应的标杆数据对比,相对误差小于千分之一、千分之五的比例占总元素个数的比例。该数据仅作为精度下降趋势的参考,并不参与计算精度是否通过的判定。
|
|
340
295
|
|
|
341
296
|
## 4 多卡比对结果提取汇总通信算子数据
|
|
342
297
|
|
|
343
298
|
本功能是将多卡比对场景的比对结果,进行通信算子数据提取和汇总,输出整理好的通信算子多卡比对精度表。
|
|
344
299
|
|
|
300
|
+
**使用场景**
|
|
301
|
+
|
|
302
|
+
已完成精度比对,获得多卡精度比对结果,但是通信算子数据分布在多个结果件中,不利于精度问题的分析。通过此功能,可以汇总多卡通信算子数据,减少问题定位时间。
|
|
303
|
+
|
|
345
304
|
**约束**
|
|
346
305
|
|
|
347
306
|
不支持MD5比对结果。
|
|
@@ -354,11 +313,11 @@ msprobe -f pytorch merge_result -i ./input_dir -o ./output_dir -config ./config.
|
|
|
354
313
|
|
|
355
314
|
**完整参数说明**
|
|
356
315
|
|
|
357
|
-
| 参数名 | 说明
|
|
358
|
-
| ----------------------
|
|
359
|
-
| -i 或 --input_dir | 多卡比对结果存盘目录,即使用compare比对的结果输出目录,str类型。所有比对结果应全部为真实数据比对结果或统计数据比对结果,否则可能导致汇总数据不完整。
|
|
360
|
-
| -o 或 --output_dir | 数据提取汇总结果存盘目录,str类型。文件名称基于时间戳自动生成,格式为:`multi_ranks_compare_merge_{timestamp}.xlsx
|
|
361
|
-
| -config或--config-path | 指定需要汇总数据的API和比对指标的yaml文件路径,str类型。<br>yaml文件详细介绍见下文“**yaml文件说明**”。
|
|
316
|
+
| 参数名 | 说明 | 是否必选 |
|
|
317
|
+
| ---------------------- |-------------------------------------------------------------------------------------------------------------------| -------- |
|
|
318
|
+
| -i 或 --input_dir | 多卡比对结果存盘目录,即使用compare比对的结果输出目录,str类型。所有比对结果应全部为真实数据比对结果或统计数据比对结果,否则可能导致汇总数据不完整。 | 是 |
|
|
319
|
+
| -o 或 --output_dir | 数据提取汇总结果存盘目录,str类型。文件名称基于时间戳自动生成,格式为:`multi_ranks_compare_merge_{timestamp}.xlsx`。<br>提示:output目录下与结果件同名文件将被删除覆盖。 | 是 |
|
|
320
|
+
| -config或--config-path | 指定需要汇总数据的API和比对指标的yaml文件路径,str类型。<br>yaml文件详细介绍见下文“**yaml文件说明**”。 | 是 |
|
|
362
321
|
|
|
363
322
|
**yaml文件说明**
|
|
364
323
|
|
|
@@ -374,10 +333,10 @@ compare_index:
|
|
|
374
333
|
- MeanRelativeErr
|
|
375
334
|
```
|
|
376
335
|
|
|
377
|
-
| 参数名 | 说明
|
|
378
|
-
| -------------
|
|
379
|
-
| api | 表示需要汇总的API或module名称。如果没有配置,工具会提示报错。<br>api名称配置格式为:`{api_type}.{api_name}.{API调用次数}.{前向反向}`<br>须按顺序配置以上四个字段,可按如下组合配置:<br/> {api_type}<br/> {api_type}.{api_name}<br/> {api_type}.{api_name}.{API调用次数}<br/> {api_type}.{api_name}.{API调用次数}.{前向反向}<br/>这里的api指代API或module。
|
|
380
|
-
| compare_index | 表示需要汇总的比对指标。compare_index需为dump_mode对应比对指标的子集。如果没有配置,工具将根据比对结果自动提取dump_mode对应的全部比对指标进行汇总。<br>统计数据模式比对指标:Max diff、Min diff、Mean diff、
|
|
336
|
+
| 参数名 | 说明 |
|
|
337
|
+
| ------------- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
338
|
+
| api | 表示需要汇总的API或module名称。如果没有配置,工具会提示报错。<br>api名称配置格式为:`{api_type}.{api_name}.{API调用次数}.{前向反向}`<br>须按顺序配置以上四个字段,可按如下组合配置:<br/> {api_type}<br/> {api_type}.{api_name}<br/> {api_type}.{api_name}.{API调用次数}<br/> {api_type}.{api_name}.{API调用次数}.{前向反向}<br/>这里的api指代API或module。 |
|
|
339
|
+
| compare_index | 表示需要汇总的比对指标。compare_index需为dump_mode对应比对指标的子集。如果没有配置,工具将根据比对结果自动提取dump_mode对应的全部比对指标进行汇总。<br>统计数据模式比对指标:Max diff、Min diff、Mean diff、L2norm diff、MaxRelativeErr、MinRelativeErr、MeanRelativeErr、NormRelativeErr<br>真实数据模式比对指标:Cosine、EucDist、MaxAbsErr、MaxRelativeErr、One Thousandth Err Ratio、Five Thousandths Err Ratio |
|
|
381
340
|
|
|
382
341
|
**汇总结果件说明**
|
|
383
342
|
|
|
@@ -389,3 +348,208 @@ compare_index:
|
|
|
389
348
|
2. rank*列为多卡数据。
|
|
390
349
|
3. 不同比对指标的数据通过不同sheet页呈现。
|
|
391
350
|
4. 如果一个API或module在某张卡上找不到数据,汇总结果中将空白呈现。
|
|
351
|
+
5. 如果比对指标值为N/A,unsupported,Nan,表示无法计算该比对指标值,汇总结果将以”NPU:’NPU max值‘ Bench:’Bench max值‘“呈现。
|
|
352
|
+
6. 针对图示案例,此处NPU:N/A Bench:N/A表示output为None。
|
|
353
|
+
|
|
354
|
+
<br>
|
|
355
|
+
如何基于group信息查看分组数据:
|
|
356
|
+
|
|
357
|
+
以Distributed.all_reduce.0.forward为例。这个API将多卡数据规约操作,输出为一个group内的规约结果,同一个group内的输出保持一致。<br>这个API中,rank0-3为一个group,Distributed.all_reduce.0.forward.input.group展示为tp-0-1-2-3,rank0-3输出一致;rank4-7为一个group,展示为tp-4-5-6-7,rank4-7输出一致。<br>group除了这种形式,还有如[0, 1, 2, 3]的呈现形式。
|
|
358
|
+
|
|
359
|
+
<br>
|
|
360
|
+
常见通信API预期结果:
|
|
361
|
+
|
|
362
|
+
1. Distributed.all_gather:多卡数据汇总,每张卡输入可以不一致,同group内输出一致,输出是张量列表。
|
|
363
|
+
2. Distributed.all_gather_into_tensor:多卡数据汇总,每张卡输入可以不一致,同group内输出一致,输出是张量。
|
|
364
|
+
3. Distributed.all_reduce:多卡数据规约操作,每张卡输入可以不一致,同group内输出一致,为规约结果。
|
|
365
|
+
4. Distributed.reduce_scatter:多卡数据规约操作,每张卡输入可以不一致,输出为group内规约结果的不同部分,输入是张量列表。
|
|
366
|
+
5. Distributed.reduce_scatter_tensor:多卡数据规约操作,每张卡输入可以不一致,输出为group内规约结果的不同部分,输入是张量。
|
|
367
|
+
6. Distributed.broadcast:输入为要广播的数据,输出为广播后的数据。
|
|
368
|
+
7. Distributed.isend:点对点通信,输入为要发送的数据,输出为发送的数据。
|
|
369
|
+
8. Distributed.irecv:点对点通信,输入为原数据,输出为接收的新数据。
|
|
370
|
+
9. Distributed.all_to_all_single:输出数据为所有卡上的数据切分后合并的结果。
|
|
371
|
+
|
|
372
|
+
## 5 附录
|
|
373
|
+
|
|
374
|
+
### 5.1 比对文件
|
|
375
|
+
|
|
376
|
+
以在当前目录创建 ./compare.json 为例。
|
|
377
|
+
|
|
378
|
+
- 单卡场景示例:
|
|
379
|
+
|
|
380
|
+
```json
|
|
381
|
+
{
|
|
382
|
+
"npu_path": "./npu_dump/dump.json",
|
|
383
|
+
"bench_path": "./bench_dump/dump.json",
|
|
384
|
+
"stack_path": "./npu_dump/stack.json",
|
|
385
|
+
"is_print_compare_log": true
|
|
386
|
+
}
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
- 多卡场景示例:
|
|
390
|
+
|
|
391
|
+
```json
|
|
392
|
+
{
|
|
393
|
+
"npu_path": "./npu_dump/step0", # 需填写到step层级(rank的上一层级)
|
|
394
|
+
"bench_path": "./bench_dump/step0", # 需填写到step层级(rank的上一层级)
|
|
395
|
+
"is_print_compare_log": true
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
**参数说明**
|
|
400
|
+
|
|
401
|
+
| 参数名 | 说明 | 是否必选 |
|
|
402
|
+
| -------------------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------|
|
|
403
|
+
| npu_path | 配置NPU环境下的dump.json文件(单卡场景)或dump目录(多卡场景)。数据类型:str。 | 是 |
|
|
404
|
+
| bench_path | 配置CPU、GPU或NPU环境下的dump.json文件(单卡场景)或dump目录(多卡场景)。数据类型:str。 | 是 |
|
|
405
|
+
| stack_path | 配置NPU dump目录下的stack.json文件。数据类型:str。如果没有配置stack_path,命令行-s参数不生效,程序自动识别是否存在stack.json文件,如存在,则比对结果中呈现NPU_Stack_Info,如不存在,则不呈现。如果配置了stack_path,比对结果中是否呈现NPU_Stack_Info则通过命令行参数-s来控制。 | 否 |
|
|
406
|
+
| is_print_compare_log | 配置是否开启单个算子的日志打屏。可取值true或false,默认为true。关闭后则只输出常规日志。数据类型:bool。 | 否 |
|
|
407
|
+
|
|
408
|
+
### 5.2 自定义映射文件
|
|
409
|
+
|
|
410
|
+
文件名格式:*.yaml,*为文件名,可自定义。
|
|
411
|
+
|
|
412
|
+
文件内容格式:
|
|
413
|
+
|
|
414
|
+
```yaml
|
|
415
|
+
# API
|
|
416
|
+
{api_type}.{api_name}.{API调用次数}.{前向反向}.{input/output}.{参数序号}: {api_type}.{api_name}.{API调用次数}.{前向反向}.{input/output}.{参数序号}
|
|
417
|
+
# 模块
|
|
418
|
+
{Module}.{module_name}.{前向反向}.{index}.{input/output}.{参数序号}: {Module}.{module_name}.{前向反向}.{index}.{input/output}.{参数序号}
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
冒号左侧和右侧分别为PyTorch框架不同版本或不同芯片环境的API的名称和module模块名称。
|
|
422
|
+
|
|
423
|
+
API和模块名称请从《[PyTorch 场景的精度数据采集](05.data_dump_PyTorch.md)》中的dump.json文件获取。
|
|
424
|
+
|
|
425
|
+
文件内容示例:
|
|
426
|
+
|
|
427
|
+
```yaml
|
|
428
|
+
# API
|
|
429
|
+
NPU.npu_fusion_attention.4.forward.input.0: NPU.npu_fusion_attention.4.forward.input.0
|
|
430
|
+
# 模块
|
|
431
|
+
Module.module.language_model.embedding.word_embedding.VocabParallelEmbedding.forward.0.input.0: Module.module.language_model.embedding.word_embedding.VocabParallelEmbedding.forward.0.input.0
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
当dump.json文件中存在“data_name”字段时,API和模块名称为data_name字段去掉文件后缀,如下图红框处所示:
|
|
435
|
+
|
|
436
|
+

|
|
437
|
+
|
|
438
|
+
当dump.json文件中不存在“data_name”字段时,名称的拼写规则如下:
|
|
439
|
+
|
|
440
|
+
input_args、input_kwargs和output使用统一的命名规则,当值是list类型时,名称后面添加'.{index}',当值类型是dict类型时,名称后面加'.{key}',当值类型是具体Tensor或null或int或float或bool或空list/dict等时,命名结束。
|
|
441
|
+
|
|
442
|
+
以下面api的dump文件为例:
|
|
443
|
+
```yaml
|
|
444
|
+
"Functional.max_pool2d.0.forward": {
|
|
445
|
+
"input_args": [
|
|
446
|
+
{
|
|
447
|
+
"type": "torch.Tensor",
|
|
448
|
+
"dytpe": "torch_float32",
|
|
449
|
+
"shape": [
|
|
450
|
+
1,
|
|
451
|
+
64,
|
|
452
|
+
14,
|
|
453
|
+
14
|
|
454
|
+
],
|
|
455
|
+
"Max": xxx,
|
|
456
|
+
"Min": xxx,
|
|
457
|
+
"Mean": xxx,
|
|
458
|
+
"Norm": xxx,
|
|
459
|
+
"requires_grad": true
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
"type": "int",
|
|
463
|
+
"value": 3
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
"type": "int",
|
|
467
|
+
"value": 2
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
"type": "int",
|
|
471
|
+
"value": 1
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
"type": "int",
|
|
475
|
+
"value": 1
|
|
476
|
+
}
|
|
477
|
+
],
|
|
478
|
+
"input_kwargs": {
|
|
479
|
+
"ceil_mode": {
|
|
480
|
+
"type": "bool",
|
|
481
|
+
"value": false
|
|
482
|
+
},
|
|
483
|
+
"return_indices": {
|
|
484
|
+
"type": "bool",
|
|
485
|
+
"value": false
|
|
486
|
+
},
|
|
487
|
+
},
|
|
488
|
+
"output": [
|
|
489
|
+
{
|
|
490
|
+
"type": "torch.Tensor",
|
|
491
|
+
"dtype": "torch.float32",
|
|
492
|
+
"shape": [
|
|
493
|
+
1,
|
|
494
|
+
64,
|
|
495
|
+
7,
|
|
496
|
+
7
|
|
497
|
+
],
|
|
498
|
+
"Max": xxx,
|
|
499
|
+
"Min": xxx,
|
|
500
|
+
"Mean": xxx,
|
|
501
|
+
"Norm": xxx,
|
|
502
|
+
"requires_grad": true
|
|
503
|
+
}
|
|
504
|
+
]
|
|
505
|
+
}
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
初始名称为Functional.max_pool2d.0.forward,input_args是list,长度为5,第0项后面是Tensor,命名结束;第1-4项后面均是int,命名结束;按照顺序命名为
|
|
509
|
+
```
|
|
510
|
+
Functional.max_pool2d.0.forward.input.0
|
|
511
|
+
Functional.max_pool2d.0.forward.input.1
|
|
512
|
+
Functional.max_pool2d.0.forward.input.2
|
|
513
|
+
Functional.max_pool2d.0.forward.input.3
|
|
514
|
+
Functional.max_pool2d.0.forward.input.4
|
|
515
|
+
```
|
|
516
|
+
input_kwargs是dict,key是ceil_mode、return_indices,值均是bool,命名结束;命名为
|
|
517
|
+
```
|
|
518
|
+
Functional.max_pool2d.0.forward.input.ceil_mode
|
|
519
|
+
Functional.max_pool2d.0.forward.input.return_indices
|
|
520
|
+
```
|
|
521
|
+
output是list,长度为1,第0项后面是Tensor,命名结束;按照顺序命名为
|
|
522
|
+
```
|
|
523
|
+
Functional.max_pool2d.0.forward.output.0
|
|
524
|
+
```
|
|
525
|
+
综上,生成的的op_name为
|
|
526
|
+
```
|
|
527
|
+
Functional.max_pool2d.0.forward.input.0
|
|
528
|
+
Functional.max_pool2d.0.forward.input.1
|
|
529
|
+
Functional.max_pool2d.0.forward.input.2
|
|
530
|
+
Functional.max_pool2d.0.forward.input.3
|
|
531
|
+
Functional.max_pool2d.0.forward.input.4
|
|
532
|
+
Functional.max_pool2d.0.forward.input.ceil_mode
|
|
533
|
+
Functional.max_pool2d.0.forward.input.return_indices
|
|
534
|
+
Functional.max_pool2d.0.forward.output.0
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
### 5.3 比对文件(单点数据)
|
|
538
|
+
|
|
539
|
+
- 单卡场景示例:
|
|
540
|
+
|
|
541
|
+
```json
|
|
542
|
+
{
|
|
543
|
+
"npu_path": "./npu_dump/debug.json",
|
|
544
|
+
"bench_path": "./bench_dump/debug.json"
|
|
545
|
+
}
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
- 多卡场景示例(step0目录下包含debug.json文件):
|
|
549
|
+
|
|
550
|
+
```json
|
|
551
|
+
{
|
|
552
|
+
"npu_path": "./npu_dump/step0",
|
|
553
|
+
"bench_path": "./bench_dump/step0"
|
|
554
|
+
}
|
|
555
|
+
```
|