mindstudio-probe 1.1.0__py3-none-any.whl → 1.2.1__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.1.0.dist-info → mindstudio_probe-1.2.1.dist-info}/METADATA +7 -6
- mindstudio_probe-1.2.1.dist-info/RECORD +396 -0
- {mindstudio_probe-1.1.0.dist-info → mindstudio_probe-1.2.1.dist-info}/WHEEL +1 -1
- {mindstudio_probe-1.1.0.dist-info → mindstudio_probe-1.2.1.dist-info}/entry_points.txt +0 -1
- msprobe/CMakeLists.txt +5 -0
- msprobe/README.md +51 -20
- msprobe/config.json +2 -3
- msprobe/core/advisor/advisor.py +8 -3
- msprobe/core/common/const.py +264 -15
- msprobe/core/common/exceptions.py +27 -3
- msprobe/core/common/file_utils.py +176 -26
- msprobe/core/common/inplace_op_checker.py +15 -0
- msprobe/core/common/inplace_ops.yaml +3 -0
- msprobe/core/common/log.py +27 -9
- msprobe/core/common/utils.py +204 -77
- msprobe/core/common_config.py +49 -14
- msprobe/core/compare/acc_compare.py +274 -198
- msprobe/core/compare/check.py +32 -33
- msprobe/core/compare/compare_cli.py +32 -14
- msprobe/core/compare/highlight.py +283 -127
- msprobe/core/compare/layer_mapping/__init__.py +19 -0
- msprobe/core/compare/layer_mapping/data_scope_parser.py +246 -0
- msprobe/core/compare/layer_mapping/layer_mapping.py +249 -0
- msprobe/core/compare/layer_mapping/postprocess_pass.py +95 -0
- msprobe/core/compare/merge_result/merge_result.py +380 -0
- msprobe/core/compare/merge_result/merge_result_cli.py +31 -0
- msprobe/core/compare/multiprocessing_compute.py +2 -2
- msprobe/core/compare/npy_compare.py +135 -144
- msprobe/core/compare/utils.py +419 -274
- msprobe/core/data_dump/data_collector.py +60 -28
- msprobe/core/data_dump/data_processor/base.py +84 -36
- msprobe/core/data_dump/data_processor/factory.py +5 -3
- msprobe/core/data_dump/data_processor/mindspore_processor.py +152 -18
- msprobe/core/data_dump/data_processor/pytorch_processor.py +267 -110
- msprobe/core/data_dump/json_writer.py +29 -1
- msprobe/core/data_dump/scope.py +119 -39
- msprobe/core/grad_probe/constant.py +27 -13
- msprobe/core/grad_probe/grad_compare.py +18 -1
- msprobe/core/grad_probe/utils.py +30 -2
- msprobe/core/overflow_check/abnormal_scene.py +189 -0
- msprobe/core/overflow_check/api_info.py +55 -0
- msprobe/core/overflow_check/checker.py +138 -0
- msprobe/core/overflow_check/filter.py +157 -0
- msprobe/core/overflow_check/ignore_rules.yaml +55 -0
- msprobe/core/overflow_check/level.py +22 -0
- msprobe/core/overflow_check/utils.py +28 -0
- msprobe/docs/01.installation.md +96 -7
- msprobe/docs/02.config_introduction.md +50 -23
- msprobe/docs/03.config_examples.md +2 -9
- msprobe/docs/04.kernel_dump_PyTorch.md +73 -0
- msprobe/docs/05.data_dump_PyTorch.md +93 -61
- msprobe/docs/06.data_dump_MindSpore.md +200 -95
- msprobe/docs/07.accuracy_checker_PyTorch.md +28 -28
- msprobe/docs/08.accuracy_checker_online_PyTorch.md +1 -6
- msprobe/docs/09.accuracy_checker_MindSpore.md +44 -8
- msprobe/docs/10.accuracy_compare_PyTorch.md +114 -50
- msprobe/docs/11.accuracy_compare_MindSpore.md +340 -48
- msprobe/docs/12.overflow_check_PyTorch.md +2 -2
- msprobe/docs/13.overflow_check_MindSpore.md +6 -6
- msprobe/docs/15.free_benchmarking_PyTorch.md +4 -5
- msprobe/docs/16.free_benchmarking_MindSpore.md +56 -37
- msprobe/docs/17.grad_probe.md +5 -6
- msprobe/docs/19.monitor.md +561 -0
- msprobe/docs/20.monitor_performance_baseline.md +52 -0
- msprobe/docs/21.visualization_PyTorch.md +466 -0
- msprobe/docs/22.visualization_MindSpore.md +481 -0
- msprobe/docs/23.generate_operator_PyTorch.md +107 -0
- msprobe/docs/24.code_mapping_Mindspore.md +28 -0
- msprobe/docs/25.tool_function_introduction.md +29 -0
- msprobe/docs/26.data_dump_PyTorch_baseline.md +37 -0
- msprobe/docs/27.dump_json_instruction.md +521 -0
- msprobe/docs/FAQ.md +29 -2
- msprobe/docs/accuracy_checker_MindSpore/accuracy_checker_MindSpore_baseline.md +14 -0
- msprobe/docs/data_dump_MindSpore/data_dump_MindSpore_baseline.md +22 -0
- msprobe/docs/data_dump_MindSpore/dynamic_graph_quick_start_example.md +211 -0
- msprobe/docs/img/compare_result.png +0 -0
- msprobe/docs/img/merge_result.png +0 -0
- msprobe/docs/img/monitor/cpu_info.png +0 -0
- msprobe/docs/img/visualization/fuzzy_match_ms.png +0 -0
- msprobe/docs/img/visualization/fuzzy_match_pt.png +0 -0
- msprobe/docs/img/visualization/tensorboard_1.png +0 -0
- msprobe/docs/img/visualization/tensorboard_2.png +0 -0
- msprobe/docs/img/visualization/vis_browser_1.png +0 -0
- msprobe/docs/img/visualization/vis_browser_2.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/docs/visualization/GPTModel.png +0 -0
- msprobe/docs/visualization/ParallelMLP.png +0 -0
- msprobe/docs/visualization/layer_mapping_example.md +132 -0
- msprobe/docs/visualization/mapping.png +0 -0
- msprobe/docs/visualization/mapping1.png +0 -0
- msprobe/docs/visualization/module_name.png +0 -0
- msprobe/docs/visualization/module_name1.png +0 -0
- msprobe/docs/visualization/no_mapping.png +0 -0
- msprobe/docs/visualization/no_mapping1.png +0 -0
- msprobe/docs/visualization/no_mapping_analyze.png +0 -0
- msprobe/docs/visualization/top_layer.png +0 -0
- msprobe/mindspore/__init__.py +25 -0
- msprobe/mindspore/api_accuracy_checker/api_accuracy_checker.py +151 -151
- msprobe/mindspore/api_accuracy_checker/api_info.py +21 -6
- msprobe/mindspore/api_accuracy_checker/api_runner.py +43 -18
- msprobe/mindspore/api_accuracy_checker/base_compare_algorithm.py +21 -7
- msprobe/mindspore/api_accuracy_checker/checker_support_api.yaml +77 -0
- msprobe/mindspore/api_accuracy_checker/cmd_parser.py +64 -1
- msprobe/mindspore/api_accuracy_checker/compute_element.py +64 -31
- msprobe/mindspore/api_accuracy_checker/data_manager.py +301 -0
- msprobe/mindspore/api_accuracy_checker/main.py +28 -3
- msprobe/mindspore/api_accuracy_checker/multi_api_accuracy_checker.py +212 -0
- msprobe/mindspore/api_accuracy_checker/multi_data_manager.py +60 -0
- msprobe/mindspore/api_accuracy_checker/type_mapping.py +22 -5
- msprobe/mindspore/api_accuracy_checker/utils.py +34 -17
- msprobe/mindspore/cell_processor.py +33 -12
- msprobe/mindspore/code_mapping/bind.py +264 -0
- msprobe/mindspore/code_mapping/cmd_parser.py +40 -0
- msprobe/mindspore/code_mapping/graph.py +49 -0
- msprobe/mindspore/code_mapping/graph_parser.py +226 -0
- msprobe/mindspore/code_mapping/main.py +24 -0
- msprobe/mindspore/code_mapping/processor.py +34 -0
- msprobe/mindspore/common/const.py +35 -13
- msprobe/mindspore/common/log.py +5 -9
- msprobe/mindspore/common/utils.py +88 -4
- msprobe/mindspore/compare/distributed_compare.py +22 -24
- msprobe/mindspore/compare/ms_compare.py +333 -268
- msprobe/mindspore/compare/ms_graph_compare.py +95 -52
- msprobe/mindspore/debugger/debugger_config.py +7 -1
- msprobe/mindspore/debugger/precision_debugger.py +87 -12
- msprobe/mindspore/dump/dump_tool_factory.py +3 -1
- msprobe/mindspore/dump/hook_cell/api_registry.py +95 -18
- msprobe/mindspore/dump/hook_cell/hook_cell.py +60 -38
- msprobe/mindspore/dump/hook_cell/primitive_hooks.py +45 -30
- msprobe/mindspore/dump/hook_cell/support_wrap_ops.yaml +36 -1
- msprobe/mindspore/dump/hook_cell/wrap_api.py +92 -1
- msprobe/mindspore/dump/jit_dump.py +17 -5
- msprobe/mindspore/dump/kernel_dump/kernel_config.py +33 -0
- msprobe/mindspore/dump/kernel_graph_dump.py +9 -4
- msprobe/mindspore/dump/kernel_kbyk_dump.py +2 -4
- msprobe/mindspore/dym_loader/hook_dynamic_loader.cc +140 -0
- msprobe/mindspore/dym_loader/hook_dynamic_loader.h +53 -0
- msprobe/mindspore/free_benchmark/api_pynative_self_check.py +156 -41
- msprobe/mindspore/free_benchmark/common/handler_params.py +1 -2
- msprobe/mindspore/free_benchmark/common/utils.py +19 -4
- msprobe/mindspore/free_benchmark/data/support_wrap_ops.yaml +0 -204
- msprobe/mindspore/free_benchmark/handler/base_handler.py +3 -3
- msprobe/mindspore/free_benchmark/handler/check_handler.py +4 -5
- msprobe/mindspore/free_benchmark/handler/fix_handler.py +4 -4
- msprobe/mindspore/free_benchmark/handler/handler_factory.py +4 -4
- msprobe/mindspore/free_benchmark/perturbation/add_noise.py +2 -2
- msprobe/mindspore/free_benchmark/perturbation/base_perturbation.py +15 -6
- msprobe/mindspore/free_benchmark/perturbation/bit_noise.py +2 -2
- msprobe/mindspore/free_benchmark/perturbation/exchange_value.py +2 -2
- msprobe/mindspore/free_benchmark/perturbation/improve_precision.py +13 -6
- msprobe/mindspore/free_benchmark/perturbation/perturbation_factory.py +2 -2
- msprobe/mindspore/free_benchmark/self_check_tool_factory.py +2 -2
- msprobe/mindspore/grad_probe/global_context.py +28 -8
- msprobe/mindspore/grad_probe/grad_analyzer.py +50 -24
- msprobe/mindspore/grad_probe/grad_monitor.py +16 -1
- msprobe/mindspore/grad_probe/grad_stat_csv.py +33 -5
- msprobe/mindspore/grad_probe/hook.py +35 -12
- msprobe/mindspore/grad_probe/utils.py +18 -5
- msprobe/mindspore/mindtorch/__init__.py +18 -0
- msprobe/mindspore/mindtorch/mindtorch_adaptor.py +255 -0
- msprobe/mindspore/ms_config.py +27 -16
- msprobe/mindspore/overflow_check/kernel_graph_overflow_check.py +9 -4
- msprobe/mindspore/runtime.py +15 -0
- msprobe/mindspore/service.py +285 -113
- msprobe/mindspore/task_handler_factory.py +15 -0
- msprobe/msprobe.py +48 -10
- msprobe/pytorch/__init__.py +8 -6
- msprobe/pytorch/api_accuracy_checker/common/config.py +62 -0
- msprobe/pytorch/api_accuracy_checker/common/utils.py +31 -16
- msprobe/pytorch/api_accuracy_checker/compare/algorithm.py +41 -8
- msprobe/pytorch/api_accuracy_checker/compare/api_precision_compare.py +103 -271
- msprobe/pytorch/api_accuracy_checker/compare/api_precision_standard.yaml +4 -1
- msprobe/pytorch/api_accuracy_checker/compare/compare.py +69 -68
- msprobe/pytorch/api_accuracy_checker/compare/compare_column.py +54 -0
- msprobe/pytorch/api_accuracy_checker/compare/compare_input.py +51 -0
- msprobe/pytorch/api_accuracy_checker/compare/compare_utils.py +2 -4
- msprobe/pytorch/api_accuracy_checker/generate_op_script/config_op.json +9 -0
- msprobe/pytorch/api_accuracy_checker/generate_op_script/op_generator.py +478 -0
- msprobe/pytorch/api_accuracy_checker/generate_op_script/operator_replication.template +365 -0
- msprobe/pytorch/api_accuracy_checker/precision_standard/absolute_threshold.py +106 -0
- msprobe/pytorch/api_accuracy_checker/precision_standard/accumulative_error_compare.py +107 -0
- msprobe/pytorch/api_accuracy_checker/precision_standard/base_standard.py +151 -0
- msprobe/pytorch/api_accuracy_checker/precision_standard/benchmark_compare.py +226 -0
- msprobe/pytorch/api_accuracy_checker/precision_standard/binary_consistency.py +68 -0
- msprobe/pytorch/api_accuracy_checker/precision_standard/standard_config.py +218 -0
- msprobe/pytorch/api_accuracy_checker/precision_standard/standard_register.py +104 -0
- msprobe/pytorch/api_accuracy_checker/precision_standard/thousandth_standard.py +63 -0
- msprobe/pytorch/api_accuracy_checker/precision_standard/ulp_compare.py +200 -0
- msprobe/pytorch/api_accuracy_checker/run_ut/data_generate.py +63 -2
- msprobe/pytorch/api_accuracy_checker/run_ut/multi_run_ut.py +21 -15
- msprobe/pytorch/api_accuracy_checker/run_ut/run_overflow_check.py +54 -22
- msprobe/pytorch/api_accuracy_checker/run_ut/run_ut.py +140 -71
- msprobe/pytorch/api_accuracy_checker/run_ut/run_ut_utils.py +49 -8
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/attl.py +9 -24
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/client.py +4 -12
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/device_dispatch.py +5 -3
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/dump_dispatch.py +9 -4
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/server.py +3 -11
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/utils.py +2 -2
- msprobe/pytorch/bench_functions/confusion_transpose.py +5 -1
- msprobe/pytorch/bench_functions/matmul_backward.py +12 -0
- msprobe/pytorch/bench_functions/npu_fusion_attention.py +142 -16
- msprobe/pytorch/bench_functions/rotary_mul.py +4 -0
- msprobe/pytorch/bench_functions/swiglu.py +10 -2
- msprobe/pytorch/common/parse_json.py +7 -6
- msprobe/pytorch/common/utils.py +101 -7
- msprobe/pytorch/compare/distributed_compare.py +17 -30
- msprobe/pytorch/compare/pt_compare.py +44 -22
- msprobe/pytorch/debugger/debugger_config.py +46 -27
- msprobe/pytorch/debugger/precision_debugger.py +42 -12
- msprobe/pytorch/dump/kernel_dump/kernel_config.py +33 -0
- msprobe/pytorch/dump/module_dump/module_dump.py +86 -0
- msprobe/pytorch/{module_processer.py → dump/module_dump/module_processer.py} +81 -10
- msprobe/pytorch/free_benchmark/common/constant.py +15 -0
- msprobe/pytorch/free_benchmark/common/counter.py +15 -0
- msprobe/pytorch/free_benchmark/common/enums.py +15 -0
- msprobe/pytorch/free_benchmark/common/params.py +10 -2
- msprobe/pytorch/free_benchmark/common/utils.py +29 -4
- msprobe/pytorch/free_benchmark/compare/grad_saver.py +20 -5
- msprobe/pytorch/free_benchmark/compare/single_benchmark.py +2 -0
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/add_noise.py +3 -1
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/bit_noise.py +6 -4
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/change_value.py +2 -0
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/improve_precision.py +4 -0
- msprobe/pytorch/free_benchmark/result_handlers/base_handler.py +41 -47
- msprobe/pytorch/free_benchmark/result_handlers/fix_handler.py +6 -5
- msprobe/pytorch/free_benchmark/result_handlers/preheat_handler.py +0 -4
- msprobe/pytorch/grad_probe/grad_monitor.py +23 -6
- msprobe/pytorch/grad_probe/grad_stat_csv.py +40 -10
- msprobe/pytorch/hook_module/__init__.py +1 -1
- msprobe/pytorch/hook_module/hook_module.py +14 -11
- msprobe/pytorch/hook_module/register_optimizer_hook.py +59 -0
- msprobe/pytorch/hook_module/support_wrap_ops.yaml +35 -0
- msprobe/pytorch/hook_module/wrap_distributed.py +6 -8
- msprobe/pytorch/hook_module/wrap_functional.py +0 -38
- msprobe/pytorch/monitor/__init__.py +0 -0
- msprobe/pytorch/monitor/anomaly_analyse.py +201 -0
- msprobe/pytorch/monitor/anomaly_detect.py +425 -0
- msprobe/pytorch/monitor/csv2tb.py +166 -0
- msprobe/pytorch/monitor/distributed/__init__.py +0 -0
- msprobe/pytorch/monitor/distributed/distributed_ops.yaml +19 -0
- msprobe/pytorch/monitor/distributed/stack_blacklist.yaml +5 -0
- msprobe/pytorch/monitor/distributed/wrap_distributed.py +283 -0
- msprobe/pytorch/monitor/features.py +108 -0
- msprobe/pytorch/monitor/module_hook.py +1076 -0
- msprobe/pytorch/monitor/module_metric.py +172 -0
- msprobe/pytorch/monitor/module_spec_verifier.py +95 -0
- msprobe/pytorch/monitor/optimizer_collect.py +333 -0
- msprobe/pytorch/monitor/unittest/__init__.py +0 -0
- msprobe/pytorch/monitor/unittest/test_monitor.py +160 -0
- msprobe/pytorch/monitor/utils.py +321 -0
- msprobe/pytorch/monitor/visualizer.py +59 -0
- msprobe/pytorch/online_dispatch/__init__.py +2 -3
- msprobe/pytorch/online_dispatch/compare.py +29 -38
- msprobe/pytorch/online_dispatch/dispatch.py +58 -27
- msprobe/pytorch/online_dispatch/dump_compare.py +21 -9
- msprobe/pytorch/online_dispatch/single_compare.py +53 -32
- msprobe/pytorch/online_dispatch/torch_ops_config.yaml +1 -1
- msprobe/pytorch/online_dispatch/utils.py +49 -21
- msprobe/pytorch/parse_tool/lib/compare.py +21 -27
- msprobe/pytorch/parse_tool/lib/config.py +6 -8
- msprobe/pytorch/parse_tool/lib/file_desc.py +15 -1
- msprobe/pytorch/parse_tool/lib/interactive_cli.py +10 -10
- msprobe/pytorch/parse_tool/lib/parse_exception.py +7 -7
- msprobe/pytorch/parse_tool/lib/parse_tool.py +12 -12
- msprobe/pytorch/parse_tool/lib/utils.py +33 -53
- msprobe/pytorch/parse_tool/lib/visualization.py +11 -10
- msprobe/pytorch/pt_config.py +31 -8
- msprobe/pytorch/service.py +188 -108
- msprobe/visualization/__init__.py +14 -0
- msprobe/visualization/builder/__init__.py +14 -0
- msprobe/visualization/builder/graph_builder.py +222 -0
- msprobe/visualization/builder/msprobe_adapter.py +227 -0
- msprobe/visualization/compare/__init__.py +14 -0
- msprobe/visualization/compare/graph_comparator.py +180 -0
- msprobe/visualization/compare/mode_adapter.py +197 -0
- msprobe/visualization/graph/__init__.py +14 -0
- msprobe/visualization/graph/base_node.py +119 -0
- msprobe/visualization/graph/distributed_analyzer.py +318 -0
- msprobe/visualization/graph/graph.py +209 -0
- msprobe/visualization/graph/node_colors.py +95 -0
- msprobe/visualization/graph/node_op.py +39 -0
- msprobe/visualization/graph_service.py +288 -0
- msprobe/visualization/utils.py +217 -0
- mindstudio_probe-1.1.0.dist-info/RECORD +0 -287
- msprobe/docs/04.acl_config_examples.md +0 -78
- msprobe/mindspore/compare/layer_mapping.py +0 -146
- msprobe/mindspore/compare/modify_mapping.py +0 -107
- msprobe/mindspore/free_benchmark/decorator/dec_forward.py +0 -57
- msprobe/mindspore/free_benchmark/decorator/decorator_factory.py +0 -122
- msprobe/pytorch/functional/module_dump.py +0 -84
- {mindstudio_probe-1.1.0.dist-info → mindstudio_probe-1.2.1.dist-info}/LICENSE +0 -0
- {mindstudio_probe-1.1.0.dist-info → mindstudio_probe-1.2.1.dist-info}/top_level.txt +0 -0
- /msprobe/mindspore/{free_benchmark/decorator → code_mapping}/__init__.py +0 -0
- /msprobe/pytorch/{functional → dump/module_dump}/__init__.py +0 -0
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
# Copyright (c) 2024-2025, Huawei Technologies Co., Ltd.
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
1
16
|
import numpy as np
|
|
2
17
|
import mindspore as ms
|
|
3
18
|
|
|
@@ -23,23 +38,18 @@ class Const:
|
|
|
23
38
|
ASCEND_910A = "ascend910"
|
|
24
39
|
|
|
25
40
|
OPS_PREFIX = "mindspore.ops."
|
|
26
|
-
|
|
41
|
+
TENSOR_PREFIX = "mindspore.Tensor."
|
|
27
42
|
MINT_PREFIX = "mindspore.mint."
|
|
28
43
|
MINT_NN_FUNC_PREFIX = "mindspore.mint.nn.functional."
|
|
29
|
-
|
|
30
|
-
COMMUNICATION_API_LIST = [
|
|
31
|
-
"mindspore.communication.comm_func.all_gather_into_tensor",
|
|
32
|
-
"mindspore.communication.comm_func.gather_into_tensor",
|
|
33
|
-
"mindspore.communication.comm_func.all_reduce",
|
|
34
|
-
"mindspore.communication.comm_func.reduce",
|
|
35
|
-
"mindspore.communication.comm_func.reduce_scatter_tensor"
|
|
36
|
-
]
|
|
44
|
+
|
|
37
45
|
TENSOR_DATA_PREFIX = "Tensor."
|
|
38
46
|
STUB_TENSOR_DATA_PREFIX = "Tensor."
|
|
39
47
|
OPS_DATA_PREFIX = "Functional."
|
|
40
48
|
MINT_DATA_PREFIX = "Mint."
|
|
41
49
|
MINT_NN_FUNC_DATA_PREFIX = "MintFunctional."
|
|
42
50
|
DISTRIBUTED_DATA_PREFIX = "Distributed."
|
|
51
|
+
TORCH_DATA_PREFIX = "Torch."
|
|
52
|
+
TORCH_NPU_DATA_PREFIX = "NPU."
|
|
43
53
|
|
|
44
54
|
SUPPORTED_API_LIST_FILE = "support_wrap_ops.yaml"
|
|
45
55
|
SUPPORTED_TENSOR_LIST_KEY = "tensor"
|
|
@@ -50,6 +60,15 @@ class Const:
|
|
|
50
60
|
|
|
51
61
|
DROPOUT_API_NAME_PREFIX = "dropout"
|
|
52
62
|
|
|
63
|
+
GRAPH_DATA_MODE_LIST = [CoreConst.ALL, CoreConst.INPUT, CoreConst.OUTPUT]
|
|
64
|
+
|
|
65
|
+
HOOK_MS_PREFIX_DICT = {
|
|
66
|
+
OPS_DATA_PREFIX: OPS_PREFIX,
|
|
67
|
+
TENSOR_DATA_PREFIX: TENSOR_PREFIX,
|
|
68
|
+
MINT_DATA_PREFIX: MINT_PREFIX,
|
|
69
|
+
MINT_NN_FUNC_DATA_PREFIX: MINT_NN_FUNC_PREFIX
|
|
70
|
+
}
|
|
71
|
+
|
|
53
72
|
|
|
54
73
|
class FreeBenchmarkConst:
|
|
55
74
|
ADD_NOISE = "add_noise"
|
|
@@ -65,19 +84,21 @@ class FreeBenchmarkConst:
|
|
|
65
84
|
DEFAULT_PERT_TYPE = IMPROVE_PRECISION
|
|
66
85
|
DEFAULT_HANDLER_TYPE = CHECK
|
|
67
86
|
DEVICE_LIST = [DEFAULT_DEVICE]
|
|
68
|
-
STAGE_LIST = [CoreConst.FORWARD]
|
|
87
|
+
STAGE_LIST = [CoreConst.FORWARD, CoreConst.BACKWARD]
|
|
69
88
|
DUMP_LEVEL_LIST = [DEFAULT_DUMP_LEVEL]
|
|
70
89
|
PERT_TYPE_LIST = [IMPROVE_PRECISION, ADD_NOISE, BIT_NOISE, NO_CHANGE, EXCHANGE_VALUE]
|
|
71
90
|
HANDLER_TYPE_LIST = [CHECK, FIX]
|
|
72
91
|
NO_CHANGE_ERROR_THRESHOLD = 1.0
|
|
73
92
|
SYMBOL_FLIPPING_RATIO = 8.0
|
|
74
93
|
|
|
94
|
+
SUPPORTED_CHECK_API_FILE = "support_wrap_ops.yaml"
|
|
95
|
+
CHECK_RESULT_FILE = "free_benchmark.csv"
|
|
96
|
+
|
|
75
97
|
API_PREFIX_DICT = {
|
|
76
98
|
"ops": Const.OPS_PREFIX,
|
|
77
|
-
"Tensor": Const.
|
|
99
|
+
"Tensor": Const.TENSOR_PREFIX,
|
|
78
100
|
"mint": Const.MINT_PREFIX,
|
|
79
|
-
"mint.nn.functional": Const.MINT_NN_FUNC_PREFIX
|
|
80
|
-
"communication": Const.COMM_PREFIX
|
|
101
|
+
"mint.nn.functional": Const.MINT_NN_FUNC_PREFIX
|
|
81
102
|
}
|
|
82
103
|
|
|
83
104
|
PERT_VALUE_DICT = {
|
|
@@ -88,6 +109,7 @@ class FreeBenchmarkConst:
|
|
|
88
109
|
}
|
|
89
110
|
|
|
90
111
|
ERROR_THRESHOLD = {
|
|
112
|
+
ms.bfloat16: 1.004,
|
|
91
113
|
ms.float16: 1.002,
|
|
92
114
|
ms.float32: 1.0002
|
|
93
115
|
}
|
msprobe/mindspore/common/log.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
# Copyright 2024 Huawei Technologies Co., Ltd
|
|
1
|
+
# Copyright (c) 2024-2024, Huawei Technologies Co., Ltd.
|
|
2
|
+
# All rights reserved.
|
|
2
3
|
#
|
|
3
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
5
|
# you may not use this file except in compliance with the License.
|
|
@@ -11,15 +12,10 @@
|
|
|
11
12
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
13
|
# See the License for the specific language governing permissions and
|
|
13
14
|
# limitations under the License.
|
|
14
|
-
# ============================================================================
|
|
15
15
|
|
|
16
|
-
import os
|
|
17
|
-
import time
|
|
18
|
-
import sys
|
|
19
|
-
|
|
20
|
-
from msprobe.mindspore.common.utils import get_rank_if_initialized
|
|
21
|
-
from msprobe.core.common.log import BaseLogger
|
|
22
16
|
from msprobe.core.common.exceptions import DistributedNotInitializedError
|
|
17
|
+
from msprobe.core.common.log import BaseLogger
|
|
18
|
+
from msprobe.mindspore.common.utils import get_rank_if_initialized
|
|
23
19
|
|
|
24
20
|
|
|
25
21
|
class MindsporeLogger(BaseLogger):
|
|
@@ -35,4 +31,4 @@ class MindsporeLogger(BaseLogger):
|
|
|
35
31
|
return current_rank
|
|
36
32
|
|
|
37
33
|
|
|
38
|
-
logger = MindsporeLogger()
|
|
34
|
+
logger = MindsporeLogger()
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
# Copyright 2024 Huawei Technologies Co., Ltd
|
|
1
|
+
# Copyright (c) 2024-2025, Huawei Technologies Co., Ltd.
|
|
2
|
+
# All rights reserved.
|
|
2
3
|
#
|
|
3
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
5
|
# you may not use this file except in compliance with the License.
|
|
@@ -11,13 +12,15 @@
|
|
|
11
12
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
13
|
# See the License for the specific language governing permissions and
|
|
13
14
|
# limitations under the License.
|
|
14
|
-
# ============================================================================
|
|
15
15
|
|
|
16
16
|
import os
|
|
17
17
|
import random
|
|
18
18
|
|
|
19
19
|
import mindspore as ms
|
|
20
20
|
|
|
21
|
+
from mindspore import ops
|
|
22
|
+
from mindspore.mint import nn
|
|
23
|
+
|
|
21
24
|
from msprobe.core.common.exceptions import DistributedNotInitializedError
|
|
22
25
|
from msprobe.core.common.file_utils import path_len_exceeds_limit, check_path_exists, save_npy
|
|
23
26
|
from msprobe.core.common.log import logger
|
|
@@ -54,6 +57,11 @@ def convert_to_int(value):
|
|
|
54
57
|
return -1
|
|
55
58
|
|
|
56
59
|
|
|
60
|
+
def clean_input_kwargs(cell):
|
|
61
|
+
if hasattr(cell, 'input_kwargs'):
|
|
62
|
+
del cell.input_kwargs
|
|
63
|
+
|
|
64
|
+
|
|
57
65
|
def list_lowest_level_directories(root_dir):
|
|
58
66
|
check_path_exists(root_dir)
|
|
59
67
|
lowest_level_dirs = []
|
|
@@ -74,13 +82,15 @@ def list_lowest_level_directories(root_dir):
|
|
|
74
82
|
return lowest_level_dirs
|
|
75
83
|
|
|
76
84
|
|
|
77
|
-
def seed_all(seed=1234, mode=False):
|
|
78
|
-
check_seed_all(seed, mode)
|
|
85
|
+
def seed_all(seed=1234, mode=False, rm_dropout=True):
|
|
86
|
+
check_seed_all(seed, mode, rm_dropout)
|
|
79
87
|
os.environ['PYTHONHASHSEED'] = str(seed)
|
|
80
88
|
ms.set_seed(seed)
|
|
81
89
|
random.seed(seed)
|
|
82
90
|
ms.set_context(deterministic="ON" if mode else "OFF")
|
|
83
91
|
os.environ['HCCL_DETERMINISTIC'] = str(mode)
|
|
92
|
+
if rm_dropout:
|
|
93
|
+
remove_dropout()
|
|
84
94
|
|
|
85
95
|
|
|
86
96
|
class MsprobeStep(ms.train.Callback):
|
|
@@ -95,3 +105,77 @@ class MsprobeStep(ms.train.Callback):
|
|
|
95
105
|
def on_train_step_end(self, run_context):
|
|
96
106
|
self.debugger.stop()
|
|
97
107
|
self.debugger.step()
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class Dropout(ops.Dropout):
|
|
111
|
+
def __init__(self, keep_prob=0.5, seed0=0, seed1=1):
|
|
112
|
+
super().__init__(1., seed0, seed1)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class Dropout2D(ops.Dropout2D):
|
|
116
|
+
def __init__(self, keep_prob=0.5):
|
|
117
|
+
super().__init__(1.)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class Dropout3D(ops.Dropout3D):
|
|
121
|
+
def __init__(self, keep_prob=0.5):
|
|
122
|
+
super().__init__(1.)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class DropoutExt(nn.Dropout):
|
|
126
|
+
def __init__(self, p=0.5):
|
|
127
|
+
super().__init__(0)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def dropout_ext(input_tensor, p=0.5, training=True):
|
|
131
|
+
return input_tensor
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def remove_dropout():
|
|
135
|
+
ops.Dropout = Dropout
|
|
136
|
+
ops.operations.Dropout = Dropout
|
|
137
|
+
ops.Dropout2D = Dropout2D
|
|
138
|
+
ops.operations.Dropout2D = Dropout2D
|
|
139
|
+
ops.Dropout3D = Dropout3D
|
|
140
|
+
ops.operations.Dropout3D = Dropout3D
|
|
141
|
+
nn.Dropout = DropoutExt
|
|
142
|
+
nn.functional.dropout = dropout_ext
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
mindtorch_check_result = None
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def is_mindtorch():
|
|
149
|
+
global mindtorch_check_result
|
|
150
|
+
if mindtorch_check_result is None:
|
|
151
|
+
mindtorch_check_result = False
|
|
152
|
+
try:
|
|
153
|
+
import torch
|
|
154
|
+
from mindspore._c_expression import Tensor
|
|
155
|
+
except ImportError:
|
|
156
|
+
return mindtorch_check_result
|
|
157
|
+
tensor = torch.tensor(0.0)
|
|
158
|
+
if isinstance(tensor, Tensor):
|
|
159
|
+
mindtorch_check_result = True
|
|
160
|
+
return mindtorch_check_result
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
register_backward_hook_functions = {}
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def set_register_backward_hook_functions():
|
|
167
|
+
global register_backward_hook_functions
|
|
168
|
+
if is_mindtorch():
|
|
169
|
+
import torch
|
|
170
|
+
from msprobe.mindspore.mindtorch import (_call_impl,
|
|
171
|
+
register_full_backward_pre_hook,
|
|
172
|
+
register_full_backward_hook)
|
|
173
|
+
if not hasattr(torch, "register_full_backward_hook"):
|
|
174
|
+
setattr(torch.nn.Module, "_call_impl", _call_impl)
|
|
175
|
+
setattr(torch.nn.Module, "register_full_backward_pre_hook", register_full_backward_pre_hook)
|
|
176
|
+
setattr(torch.nn.Module, "register_full_backward_hook", register_full_backward_hook)
|
|
177
|
+
register_backward_hook_functions["pre"] = torch.nn.Module.register_full_backward_pre_hook
|
|
178
|
+
register_backward_hook_functions["full"] = torch.nn.Module.register_full_backward_hook
|
|
179
|
+
else:
|
|
180
|
+
register_backward_hook_functions["pre"] = ms.nn.Cell.register_backward_pre_hook
|
|
181
|
+
register_backward_hook_functions["full"] = ms.nn.Cell.register_backward_hook
|
|
@@ -1,10 +1,24 @@
|
|
|
1
|
+
# Copyright (c) 2024-2024, Huawei Technologies Co., Ltd.
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
1
16
|
import os
|
|
2
|
-
from msprobe.core.common.utils import CompareException
|
|
3
|
-
check_configuration_param, task_dumppath_get
|
|
17
|
+
from msprobe.core.common.utils import CompareException
|
|
4
18
|
from msprobe.core.common.file_utils import create_directory
|
|
5
19
|
from msprobe.core.common.exceptions import FileCheckException
|
|
6
20
|
from msprobe.mindspore.common.log import logger
|
|
7
|
-
from msprobe.mindspore.compare.ms_compare import
|
|
21
|
+
from msprobe.mindspore.compare.ms_compare import ms_compare
|
|
8
22
|
from msprobe.core.compare.utils import check_and_return_dir_contents, extract_json
|
|
9
23
|
from msprobe.mindspore.compare.ms_graph_compare import GraphMSComparator
|
|
10
24
|
|
|
@@ -13,43 +27,27 @@ def ms_compare_distributed(npu_dump_dir, bench_dump_dir, output_path, **kwargs):
|
|
|
13
27
|
if kwargs.get('suffix'):
|
|
14
28
|
logger.error("Argument 'suffix' is not supported for compare_distributed.")
|
|
15
29
|
raise CompareException(CompareException.INVALID_PARAM_ERROR)
|
|
16
|
-
|
|
17
|
-
auto_analyze = kwargs.get('auto_analyze', True)
|
|
18
|
-
fuzzy_match = kwargs.get('fuzzy_match', False)
|
|
30
|
+
is_print_compare_log = kwargs.get('is_print_compare_log', True)
|
|
19
31
|
# get the ranks and match by order
|
|
20
32
|
npu_ranks = sorted(check_and_return_dir_contents(npu_dump_dir, 'rank'))
|
|
21
33
|
bench_ranks = sorted(check_and_return_dir_contents(bench_dump_dir, 'rank'))
|
|
22
34
|
if len(npu_ranks) != len(bench_ranks):
|
|
23
35
|
logger.error('The number of ranks in the two runs are different. '
|
|
24
|
-
|
|
25
|
-
|
|
36
|
+
'Unable to match the ranks. Please use another folder to compare '
|
|
37
|
+
'or use compare() api and manually match the ranks.')
|
|
26
38
|
raise CompareException(CompareException.INVALID_PATH_ERROR)
|
|
27
39
|
for nr, br in zip(npu_ranks, bench_ranks):
|
|
28
40
|
npu_data_dir = os.path.join(npu_dump_dir, nr)
|
|
29
41
|
bench_data_dir = os.path.join(bench_dump_dir, br)
|
|
30
42
|
npu_path = extract_json(npu_data_dir, stack_json=False)
|
|
31
43
|
bench_path = extract_json(bench_data_dir, stack_json=False)
|
|
32
|
-
stack_path = extract_json(npu_data_dir, stack_json=True)
|
|
33
44
|
|
|
34
45
|
dump_result_param = {
|
|
35
46
|
'npu_json_path': npu_path,
|
|
36
47
|
'bench_json_path': bench_path,
|
|
37
|
-
'
|
|
38
|
-
'is_print_compare_log': True
|
|
48
|
+
'is_print_compare_log': is_print_compare_log
|
|
39
49
|
}
|
|
40
|
-
|
|
41
|
-
summary_compare, md5_compare = task_dumppath_get(dump_result_param)
|
|
42
|
-
check_configuration_param(stack_mode, auto_analyze, fuzzy_match,
|
|
43
|
-
dump_result_param.get('is_print_compare_log', True))
|
|
44
|
-
create_directory(output_path)
|
|
45
|
-
check_compare_param(dump_result_param, output_path,
|
|
46
|
-
summary_compare=summary_compare, md5_compare=md5_compare)
|
|
47
|
-
except (CompareException, FileCheckException) as error:
|
|
48
|
-
logger.error('Compare failed. Please check the arguments and do it again!')
|
|
49
|
-
raise CompareException(error.code) from error
|
|
50
|
-
ms_comparator = MSComparator()
|
|
51
|
-
ms_comparator.compare_core(dump_result_param, output_path, suffix=f'_{nr}-{br}',
|
|
52
|
-
summary_compare=summary_compare, md5_compare=md5_compare, **kwargs)
|
|
50
|
+
ms_compare(input_param=dump_result_param, output_path=output_path, suffix=f'_{nr}-{br}', **kwargs)
|
|
53
51
|
|
|
54
52
|
|
|
55
53
|
def ms_graph_compare(inputs, outputs):
|