mindstudio-probe 8.1.2__py3-none-any.whl → 8.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-8.1.2.dist-info → mindstudio_probe-8.2.1.dist-info}/METADATA +2 -2
- {mindstudio_probe-8.1.2.dist-info → mindstudio_probe-8.2.1.dist-info}/RECORD +172 -147
- msprobe/README.md +6 -6
- msprobe/core/common/const.py +98 -41
- msprobe/core/common/db_manager.py +256 -0
- msprobe/core/common/file_utils.py +28 -5
- msprobe/core/common/log.py +7 -0
- msprobe/core/common/megatron_utils.py +59 -0
- msprobe/core/common/parallel_state.py +193 -0
- msprobe/core/common/utils.py +20 -13
- msprobe/core/common_config.py +5 -0
- msprobe/core/compare/acc_compare.py +140 -93
- msprobe/core/compare/check.py +13 -0
- msprobe/core/compare/compare_cli.py +64 -6
- msprobe/core/compare/config.py +10 -8
- msprobe/core/compare/diff_analyze/diff_analyze_threshold.yaml +14 -0
- msprobe/core/compare/diff_analyze/first_diff_analyze.py +135 -0
- msprobe/core/compare/diff_analyze/ignore_op_list.yaml +3 -0
- msprobe/core/compare/find_first/__init__.py +0 -0
- msprobe/core/compare/find_first/analyzer.py +282 -0
- msprobe/core/compare/find_first/data_processor.py +35 -0
- msprobe/core/compare/find_first/graph.py +188 -0
- msprobe/core/compare/find_first/utils.py +189 -0
- msprobe/core/compare/highlight.py +74 -101
- msprobe/core/compare/layer_mapping/layer_mapping.py +14 -9
- msprobe/core/compare/merge_result/merge_result.py +2 -2
- msprobe/core/compare/multiprocessing_compute.py +45 -28
- msprobe/core/compare/npy_compare.py +7 -10
- msprobe/core/compare/utils.py +338 -130
- msprobe/core/config_check/checkers/dataset_checker.py +2 -1
- msprobe/core/config_check/checkers/env_args_checker.py +5 -5
- msprobe/core/config_check/checkers/hyperparameter_checker.py +30 -10
- msprobe/core/config_check/checkers/pip_checker.py +4 -3
- msprobe/core/config_check/checkers/random_checker.py +3 -3
- msprobe/core/config_check/checkers/weights_checker.py +2 -1
- msprobe/core/config_check/ckpt_compare/megatron_loader.py +2 -0
- msprobe/core/config_check/resource/hyperparameter.yaml +11 -1
- msprobe/core/config_check/utils/hyperparameter_parser.py +7 -3
- msprobe/core/config_check/utils/utils.py +10 -0
- msprobe/core/data_dump/api_registry.py +49 -30
- msprobe/core/data_dump/data_collector.py +71 -29
- msprobe/core/data_dump/data_processor/base.py +2 -0
- msprobe/core/data_dump/data_processor/mindspore_processor.py +47 -53
- msprobe/core/data_dump/data_processor/pytorch_processor.py +227 -93
- msprobe/core/data_dump/json_writer.py +81 -7
- msprobe/core/data_dump/scope.py +4 -6
- msprobe/core/hook_manager.py +129 -70
- msprobe/core/monitor/csv2db.py +361 -0
- msprobe/core/monitor/db_utils.py +278 -0
- msprobe/core/monitor/utils.py +35 -1
- msprobe/core/service.py +31 -39
- msprobe/core/single_save/single_comparator.py +16 -3
- msprobe/docs/01.installation.md +51 -19
- msprobe/docs/02.config_introduction.md +16 -20
- msprobe/docs/03.config_examples.md +26 -0
- msprobe/docs/04.kernel_dump_PyTorch.md +1 -1
- msprobe/docs/05.data_dump_PyTorch.md +6 -2
- msprobe/docs/06.data_dump_MindSpore.md +44 -7
- msprobe/docs/07.accuracy_checker_PyTorch.md +1 -1
- msprobe/docs/10.accuracy_compare_PyTorch.md +124 -44
- msprobe/docs/11.accuracy_compare_MindSpore.md +75 -7
- msprobe/docs/14.data_parse_PyTorch.md +1 -1
- msprobe/docs/19.monitor.md +94 -7
- msprobe/docs/21.visualization_PyTorch.md +71 -101
- msprobe/docs/22.visualization_MindSpore.md +69 -119
- msprobe/docs/23.generate_operator_PyTorch.md +1 -1
- msprobe/docs/25.tool_function_introduction.md +0 -1
- msprobe/docs/26.data_dump_PyTorch_baseline.md +7 -7
- msprobe/docs/28.debugger_save_instruction.md +184 -81
- msprobe/docs/29.data_dump_MSAdapter.md +6 -0
- msprobe/docs/31.config_check.md +4 -2
- msprobe/docs/36.calculation_result_change.md +75 -0
- msprobe/docs/FAQ.md +22 -1
- msprobe/docs/data_dump_MindSpore/dynamic_graph_quick_start_example.md +6 -2
- msprobe/docs/img/compare_result.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/docs/visualization/mindspeed_llamafactoary_img/1.png +0 -0
- msprobe/docs/visualization/mindspeed_llamafactoary_img/2.png +0 -0
- msprobe/docs/visualization/mindspeed_llamafactoary_img/3.png +0 -0
- msprobe/docs/visualization/mindspeed_llamafactoary_img/4.png +0 -0
- msprobe/docs/visualization/mindspeed_llamafactoary_img/5.png +0 -0
- msprobe/docs/visualization/mindspeed_llamafactoary_img/6.png +0 -0
- msprobe/docs/visualization/mindspeed_llamafactoary_img/7.png +0 -0
- msprobe/docs/visualization/mindspeed_llamafactoary_img/llamafactory-qwen25vl.txt +59 -0
- msprobe/docs/visualization/mindspeed_llamafactoary_img/llamafactory1.png +0 -0
- msprobe/docs/visualization/mindspeed_llamafactoary_img/llamafactory2.png +0 -0
- msprobe/docs/visualization/mindspeed_llamafactoary_img/mindspeed-mm-qwen25vl.txt +80 -0
- msprobe/docs/visualization/mindspeed_llamafactoary_img/mindspeed1.png +0 -0
- msprobe/docs/visualization/mindspeed_llamafactoary_img/mindspeed2.png +0 -0
- msprobe/docs/visualization/mindspeed_llamafactory_mapping.md +330 -0
- msprobe/mindspore/__init__.py +1 -1
- msprobe/mindspore/api_accuracy_checker/api_accuracy_checker.py +1 -1
- msprobe/mindspore/api_accuracy_checker/api_runner.py +9 -6
- msprobe/mindspore/api_accuracy_checker/compute_element.py +18 -12
- msprobe/mindspore/cell_processor.py +64 -25
- msprobe/mindspore/common/utils.py +51 -7
- msprobe/mindspore/compare/common_dir_compare.py +45 -37
- msprobe/mindspore/compare/ms_compare.py +10 -2
- msprobe/mindspore/compare/ms_graph_compare.py +47 -52
- msprobe/mindspore/debugger/debugger_config.py +18 -7
- msprobe/mindspore/debugger/precision_debugger.py +16 -12
- msprobe/mindspore/dump/cell_dump_process.py +130 -68
- msprobe/mindspore/dump/cell_dump_with_insert_gradient.py +10 -2
- msprobe/mindspore/dump/graph_mode_cell_dump.py +35 -9
- msprobe/mindspore/dump/graph_tensor_dump.py +11 -0
- msprobe/mindspore/dump/hook_cell/api_register.py +19 -20
- msprobe/mindspore/dump/hook_cell/hook_cell.py +12 -34
- msprobe/mindspore/dump/hook_cell/ms_hook_manager.py +142 -21
- msprobe/mindspore/dump/kernel_kbyk_dump.py +24 -0
- msprobe/mindspore/exception_dump/__init__.py +0 -0
- msprobe/mindspore/exception_dump/exception_dump_tool_factory.py +51 -0
- msprobe/mindspore/exception_dump/kernel_graph_exception_dump.py +57 -0
- msprobe/mindspore/free_benchmark/api_pynative_self_check.py +5 -4
- msprobe/mindspore/mindspore_service.py +2 -2
- msprobe/mindspore/mindtorch/mindtorch_adaptor.py +12 -7
- msprobe/mindspore/monitor/features.py +82 -0
- msprobe/mindspore/monitor/module_hook.py +168 -10
- msprobe/mindspore/monitor/utils.py +27 -1
- msprobe/mindspore/ms_config.py +12 -4
- msprobe/mindspore/overflow_check/overflow_check_tool_factory.py +1 -1
- msprobe/mindspore/task_handler_factory.py +3 -1
- msprobe/nan_analyze/graph.py +1 -1
- msprobe/pytorch/api_accuracy_checker/common/config.py +3 -36
- msprobe/pytorch/api_accuracy_checker/compare/api_precision_compare.py +0 -24
- msprobe/pytorch/api_accuracy_checker/compare/compare.py +2 -12
- msprobe/pytorch/api_accuracy_checker/config.yaml +1 -6
- msprobe/pytorch/api_accuracy_checker/run_ut/multi_run_ut.py +2 -2
- msprobe/pytorch/api_accuracy_checker/run_ut/run_ut.py +12 -132
- msprobe/pytorch/common/utils.py +1 -21
- msprobe/pytorch/compare/pt_compare.py +10 -2
- msprobe/pytorch/{hook_module/jit_script_wrapper.py → compare/pt_diff_analyze.py} +3 -15
- msprobe/pytorch/compare/utils.py +2 -1
- msprobe/pytorch/debugger/debugger_config.py +18 -23
- msprobe/pytorch/dump/module_dump/hook_wrapper.py +10 -7
- msprobe/pytorch/dump/module_dump/module_processer.py +41 -19
- msprobe/pytorch/free_benchmark/main.py +7 -4
- msprobe/pytorch/hook_module/api_register.py +62 -24
- msprobe/pytorch/hook_module/hook_module.py +9 -29
- msprobe/pytorch/hook_module/pt_hook_manager.py +84 -15
- msprobe/pytorch/hook_module/script_wrapper.py +140 -0
- msprobe/pytorch/hook_module/support_wrap_ops.yaml +6 -0
- msprobe/pytorch/monitor/csv2tb.py +1 -1
- msprobe/pytorch/monitor/features.py +94 -0
- msprobe/pytorch/monitor/module_hook.py +221 -81
- msprobe/pytorch/monitor/module_metric.py +27 -1
- msprobe/pytorch/monitor/optimizer_collect.py +109 -4
- msprobe/pytorch/online_dispatch/dispatch.py +42 -24
- msprobe/pytorch/online_dispatch/dump_compare.py +1 -1
- msprobe/pytorch/parse_tool/lib/visualization.py +0 -1
- msprobe/pytorch/pt_config.py +2 -51
- msprobe/pytorch/pytorch_service.py +7 -14
- msprobe/visualization/builder/graph_builder.py +192 -63
- msprobe/visualization/builder/graph_merger.py +986 -0
- msprobe/visualization/builder/msprobe_adapter.py +17 -15
- msprobe/visualization/compare/graph_comparator.py +26 -16
- msprobe/visualization/db_utils.py +252 -0
- msprobe/visualization/graph/base_node.py +2 -22
- msprobe/visualization/graph/distributed_analyzer.py +12 -12
- msprobe/visualization/graph/graph.py +44 -16
- msprobe/visualization/graph_service.py +143 -59
- msprobe/visualization/utils.py +103 -4
- msprobe/docs/08.accuracy_checker_online_PyTorch.md +0 -295
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/attl.py +0 -205
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/client.py +0 -378
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/device_dispatch.py +0 -239
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/dump_dispatch.py +0 -115
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/server.py +0 -250
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/torch_ops_config.yaml +0 -63
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/utils.py +0 -198
- msprobe/pytorch/attl_manager.py +0 -65
- {mindstudio_probe-8.1.2.dist-info → mindstudio_probe-8.2.1.dist-info}/LICENSE +0 -0
- {mindstudio_probe-8.1.2.dist-info → mindstudio_probe-8.2.1.dist-info}/WHEEL +0 -0
- {mindstudio_probe-8.1.2.dist-info → mindstudio_probe-8.2.1.dist-info}/entry_points.txt +0 -0
- {mindstudio_probe-8.1.2.dist-info → mindstudio_probe-8.2.1.dist-info}/top_level.txt +0 -0
- /msprobe/{pytorch/api_accuracy_checker/tensor_transport_layer → core/compare/diff_analyze}/__init__.py +0 -0
msprobe/core/service.py
CHANGED
|
@@ -13,12 +13,11 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
from abc import ABC, abstractmethod
|
|
18
16
|
import copy
|
|
19
|
-
from collections import defaultdict
|
|
20
17
|
import functools
|
|
21
18
|
import os
|
|
19
|
+
from abc import ABC, abstractmethod
|
|
20
|
+
from collections import defaultdict
|
|
22
21
|
|
|
23
22
|
from msprobe.core.common.exceptions import DistributedNotInitializedError
|
|
24
23
|
from msprobe.core.common.file_utils import create_directory
|
|
@@ -26,8 +25,8 @@ from msprobe.core.common.runtime import Runtime
|
|
|
26
25
|
from msprobe.core.common.utils import Const, print_tools_ends_info, DumpPathAggregation
|
|
27
26
|
from msprobe.core.data_dump.api_registry import ApiRegistry
|
|
28
27
|
from msprobe.core.data_dump.data_collector import build_data_collector
|
|
29
|
-
from msprobe.core.hook_manager import BaseHookManager
|
|
30
28
|
from msprobe.core.kernel_dump.kernel_config import create_kernel_config_json
|
|
29
|
+
from msprobe.core.common.megatron_utils import MegatronStepInfo
|
|
31
30
|
|
|
32
31
|
|
|
33
32
|
class BaseService(ABC):
|
|
@@ -36,7 +35,6 @@ class BaseService(ABC):
|
|
|
36
35
|
self.config.level = getattr(config, 'level_ori', config.level) # 兼容MindSpore配置
|
|
37
36
|
self.model = None
|
|
38
37
|
self.data_collector = build_data_collector(self.config)
|
|
39
|
-
self.attl_manager = None
|
|
40
38
|
self.current_iter = 0
|
|
41
39
|
self.loop = 0
|
|
42
40
|
self.init_step = 0
|
|
@@ -46,6 +44,7 @@ class BaseService(ABC):
|
|
|
46
44
|
self.current_rank = None
|
|
47
45
|
self.dump_iter_dir = None
|
|
48
46
|
self.should_stop_service = False
|
|
47
|
+
self.hooked_modules = []
|
|
49
48
|
self.ori_customer_func = {}
|
|
50
49
|
self.debug_variable_counter = None
|
|
51
50
|
self.currrent_step_first_debug_save = True
|
|
@@ -63,7 +62,7 @@ class BaseService(ABC):
|
|
|
63
62
|
@property
|
|
64
63
|
def _is_l2_level(self):
|
|
65
64
|
return self.config.level == Const.LEVEL_L2
|
|
66
|
-
|
|
65
|
+
|
|
67
66
|
@property
|
|
68
67
|
def _is_mix_level(self):
|
|
69
68
|
return self.config.level == Const.LEVEL_MIX
|
|
@@ -71,7 +70,7 @@ class BaseService(ABC):
|
|
|
71
70
|
@property
|
|
72
71
|
def _is_need_module_hook(self):
|
|
73
72
|
return self.config.level in [Const.LEVEL_MIX, Const.LEVEL_L0]
|
|
74
|
-
|
|
73
|
+
|
|
75
74
|
@property
|
|
76
75
|
def _is_need_api_hook(self):
|
|
77
76
|
return self.config.level in [Const.LEVEL_MIX, Const.LEVEL_L1, Const.LEVEL_L2]
|
|
@@ -91,10 +90,6 @@ class BaseService(ABC):
|
|
|
91
90
|
self.config.task in self.data_collector.tasks_need_tensor_data or
|
|
92
91
|
(self.config.task == Const.STATISTICS and self.config.tensor_list)
|
|
93
92
|
)
|
|
94
|
-
|
|
95
|
-
@property
|
|
96
|
-
def _is_online_run_ut(self):
|
|
97
|
-
return getattr(self.config, "online_run_ut", False)
|
|
98
93
|
|
|
99
94
|
@property
|
|
100
95
|
@abstractmethod
|
|
@@ -111,16 +106,21 @@ class BaseService(ABC):
|
|
|
111
106
|
@staticmethod
|
|
112
107
|
def _change_jit_switch(status):
|
|
113
108
|
"""修改JitDump开关,mindspore子类重写"""
|
|
114
|
-
pass
|
|
109
|
+
pass
|
|
115
110
|
|
|
116
111
|
def start(self, model=None, token_range=None):
|
|
117
112
|
"""通用start模板"""
|
|
118
113
|
self._process_iteration()
|
|
119
114
|
if self._is_debug_level:
|
|
120
115
|
return
|
|
116
|
+
if model:
|
|
117
|
+
self.model = model
|
|
118
|
+
if self._is_need_module_hook and self.model not in self.hooked_modules:
|
|
119
|
+
self._register_module_hook()
|
|
120
|
+
self.hooked_modules.append(self.model)
|
|
121
121
|
if self._need_stop_service():
|
|
122
|
-
return
|
|
123
|
-
|
|
122
|
+
return
|
|
123
|
+
Runtime.is_running = True
|
|
124
124
|
self.cur_token_id = 0
|
|
125
125
|
if self.first_start:
|
|
126
126
|
try:
|
|
@@ -129,25 +129,21 @@ class BaseService(ABC):
|
|
|
129
129
|
self.current_rank = None
|
|
130
130
|
Runtime.current_rank = self.current_rank
|
|
131
131
|
if self._is_no_dump_rank:
|
|
132
|
+
Runtime.is_running = False
|
|
132
133
|
return
|
|
133
134
|
self._register_hook()
|
|
134
|
-
if self._is_need_module_hook:
|
|
135
|
-
self._register_module_hook()
|
|
136
135
|
self.first_start = False
|
|
137
136
|
|
|
138
137
|
if token_range:
|
|
139
138
|
self._register_infer_count_hook(self.model, token_range)
|
|
140
139
|
self.logger.info(f"{Const.TOOL_NAME}: debugger.start() is set successfully")
|
|
141
140
|
if token_range is None:
|
|
142
|
-
Runtime.is_running = True
|
|
143
141
|
self.primitive_switch = True
|
|
144
142
|
self._change_jit_switch(True)
|
|
145
143
|
self.logger.info(f"Dump switch is turned on at step {self.current_iter}. ")
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
self.create_dirs()
|
|
150
|
-
self.logger.info(f"Dump data will be saved in {self.dump_iter_dir}.")
|
|
144
|
+
|
|
145
|
+
self.create_dirs()
|
|
146
|
+
self.logger.info(f"Dump data will be saved in {self.dump_iter_dir}.")
|
|
151
147
|
|
|
152
148
|
def stop(self):
|
|
153
149
|
"""通用stop模板"""
|
|
@@ -156,14 +152,13 @@ class BaseService(ABC):
|
|
|
156
152
|
if self._is_no_dump_step or self._is_no_dump_rank:
|
|
157
153
|
return
|
|
158
154
|
self.logger.info(f"{Const.TOOL_NAME}: debugger.stop() is set successfully. "
|
|
159
|
-
|
|
155
|
+
"Please set debugger.start() to turn on the dump switch again. ")
|
|
160
156
|
Runtime.is_running = False
|
|
161
157
|
self.primitive_switch = False
|
|
162
158
|
self._change_jit_switch(False)
|
|
163
159
|
if self._is_l2_level:
|
|
164
160
|
return
|
|
165
|
-
|
|
166
|
-
self._run_ut_dispatch(False)
|
|
161
|
+
|
|
167
162
|
self._process_async_dump()
|
|
168
163
|
self.data_collector.write_json()
|
|
169
164
|
|
|
@@ -176,6 +171,7 @@ class BaseService(ABC):
|
|
|
176
171
|
self.currrent_step_first_debug_save = True
|
|
177
172
|
self.loop += 1
|
|
178
173
|
self._reset_status()
|
|
174
|
+
MegatronStepInfo.reset()
|
|
179
175
|
|
|
180
176
|
def save(self, variable, name, save_backward):
|
|
181
177
|
'''
|
|
@@ -218,14 +214,13 @@ class BaseService(ABC):
|
|
|
218
214
|
def register_custom_api(self, module, api_name, api_prefix):
|
|
219
215
|
self.ori_customer_func[str(module) + Const.SEP + api_name] = getattr(module, api_name)
|
|
220
216
|
ApiRegistry.register_custom_api(module, api_name, api_prefix,
|
|
221
|
-
|
|
217
|
+
functools.partial(self.build_hook, Const.API), self.api_template)
|
|
222
218
|
|
|
223
219
|
def restore_custom_api(self, module, api):
|
|
224
220
|
ori_func = self.ori_customer_func.get(str(module) + Const.SEP + api)
|
|
225
221
|
if ori_func:
|
|
226
222
|
setattr(module, api, ori_func)
|
|
227
223
|
|
|
228
|
-
|
|
229
224
|
def build_hook(self, hook_type, name):
|
|
230
225
|
return self.hook_manager.build_hook(hook_type, name)
|
|
231
226
|
|
|
@@ -247,24 +242,22 @@ class BaseService(ABC):
|
|
|
247
242
|
def _init_specific_components(self):
|
|
248
243
|
"""初始化框架特定组件"""
|
|
249
244
|
pass
|
|
250
|
-
|
|
245
|
+
|
|
251
246
|
@abstractmethod
|
|
252
247
|
def _register_hook(self):
|
|
253
248
|
"""注册hook函数"""
|
|
254
249
|
pass
|
|
255
|
-
|
|
250
|
+
|
|
256
251
|
@abstractmethod
|
|
257
252
|
def _register_module_hook(self):
|
|
258
253
|
"""注册模块级别的hook函数"""
|
|
259
|
-
|
|
254
|
+
|
|
260
255
|
def _need_stop_service(self):
|
|
261
256
|
if self.should_stop_service:
|
|
262
257
|
return True
|
|
263
258
|
end_service = self.config.step and self.current_iter > max(self.config.step) or \
|
|
264
|
-
|
|
259
|
+
self.data_collector and self.data_collector.data_processor.is_terminated
|
|
265
260
|
if end_service:
|
|
266
|
-
if self._is_online_run_ut and self.attl_manager:
|
|
267
|
-
self.attl_manager.attl_stop()
|
|
268
261
|
self.primitive_switch = False
|
|
269
262
|
self._change_jit_switch(False)
|
|
270
263
|
Runtime.is_running = False
|
|
@@ -307,10 +300,9 @@ class BaseService(ABC):
|
|
|
307
300
|
if root_model and isinstance(root_model, list):
|
|
308
301
|
root_model = root_model[0]
|
|
309
302
|
self.logger.warning("Infer model can only input one to support token_range, choose the first one.")
|
|
310
|
-
|
|
311
|
-
return
|
|
303
|
+
|
|
312
304
|
root_model.register_forward_pre_hook(infer_hook)
|
|
313
|
-
|
|
305
|
+
|
|
314
306
|
def _create_l2_dirs(self, cur_rank):
|
|
315
307
|
create_directory(self.dump_iter_dir)
|
|
316
308
|
kernel_config_path = create_kernel_config_json(self.dump_iter_dir, cur_rank)
|
|
@@ -319,12 +311,12 @@ class BaseService(ABC):
|
|
|
319
311
|
def _create_default_dirs(self, cur_rank):
|
|
320
312
|
dump_dir = os.path.join(self.dump_iter_dir, f"rank{cur_rank}")
|
|
321
313
|
create_directory(dump_dir)
|
|
322
|
-
|
|
314
|
+
|
|
323
315
|
dump_data_dir = None
|
|
324
316
|
if self._need_tensor_data:
|
|
325
317
|
dump_data_dir = os.path.join(dump_dir, "dump_tensor_data")
|
|
326
318
|
create_directory(dump_data_dir)
|
|
327
|
-
|
|
319
|
+
|
|
328
320
|
self._configure_dump_paths(dump_dir, dump_data_dir)
|
|
329
321
|
|
|
330
322
|
def _configure_dump_paths(self, dump_dir, dump_data_dir):
|
|
@@ -353,6 +345,6 @@ class BaseService(ABC):
|
|
|
353
345
|
def _reset_status(self):
|
|
354
346
|
"""通用状态重置"""
|
|
355
347
|
self.data_collector.reset_status()
|
|
356
|
-
|
|
348
|
+
self.hook_manager.reset_status()
|
|
357
349
|
if self._is_l2_level:
|
|
358
350
|
self.data_collector.data_processor.reset_status()
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
16
|
import os
|
|
17
|
+
import re
|
|
17
18
|
import multiprocessing
|
|
18
19
|
from dataclasses import dataclass
|
|
19
20
|
|
|
@@ -70,6 +71,9 @@ class SingleComparator:
|
|
|
70
71
|
比较两个NumPy数组,计算最大绝对误差、最大相对误差和相同元素的百分比
|
|
71
72
|
"""
|
|
72
73
|
# 计算每个维度上的最小尺寸
|
|
74
|
+
if array1.ndim != array2.ndim:
|
|
75
|
+
array1 = array1.flatten()
|
|
76
|
+
array2 = array2.flatten()
|
|
73
77
|
min_shape = [min(s1, s2) for s1, s2 in zip(array1.shape, array2.shape)]
|
|
74
78
|
# 截取数组到相同的形状
|
|
75
79
|
sliced_array1 = array1[tuple(slice(0, s) for s in min_shape)]
|
|
@@ -176,9 +180,18 @@ class SingleComparator:
|
|
|
176
180
|
continue
|
|
177
181
|
for step, step_path in cls.get_steps(tag_path):
|
|
178
182
|
for rank, rank_path in cls.get_ranks(step_path):
|
|
179
|
-
for
|
|
180
|
-
|
|
181
|
-
|
|
183
|
+
for item in os.listdir(rank_path):
|
|
184
|
+
next_path = os.path.join(rank_path, item)
|
|
185
|
+
if re.match(r"micro_step(\d+)", item):
|
|
186
|
+
micro_step = re.match(r"micro_step(\d+)", item).group(1)
|
|
187
|
+
for array_id, array_path in cls.get_arrays(next_path):
|
|
188
|
+
array_paths.setdefault(tag, []).append(
|
|
189
|
+
(step, rank, int(micro_step), array_id, array_path))
|
|
190
|
+
elif re.match(r"\w{1,100}_(\d{1,100})\.npy", item):
|
|
191
|
+
array_id = re.match(r"\w{1,100}_(\d{1,100})\.npy", item).group(1)
|
|
192
|
+
array_paths.setdefault(tag, []).append((step, rank, 0, int(array_id), next_path))
|
|
193
|
+
else:
|
|
194
|
+
array_paths.setdefault(tag, []).append((step, rank, 0, 0, next_path))
|
|
182
195
|
return array_paths
|
|
183
196
|
|
|
184
197
|
@classmethod
|
msprobe/docs/01.installation.md
CHANGED
|
@@ -14,18 +14,20 @@ pip install mindstudio-probe
|
|
|
14
14
|
|
|
15
15
|
## 2 下载 whl 包安装
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|8.
|
|
20
|
-
|8.1.
|
|
21
|
-
|8.
|
|
22
|
-
|1.
|
|
23
|
-
|
|
|
24
|
-
|1.
|
|
25
|
-
|1.2.
|
|
26
|
-
|1.
|
|
27
|
-
|1.
|
|
28
|
-
|1.
|
|
17
|
+
| 版本 | 发布日期 |支持 PyTorch 版本|支持 MindSpore 版本| 下载链接 |校验码|
|
|
18
|
+
|:-----:|:----------:|:--:|:--:|:----------------------------------------------------------------------------------------------------------------------------------:|:--:|
|
|
19
|
+
| 8.2.0 | 2025.9.03 |1.11/2.0/2.1/2.2|2.4.0/2.5.0/2.6.0| [mindstudio_probe-8.2.0-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/8.2/mindstudio_probe-8.2.0-py3-none-any.whl) |bbc1577d76754adf987069308177d3e0a04e36de9c7f22e75c34cf4ad0ce1af2|
|
|
20
|
+
| 8.1.2 | 2025.8.01 |1.11/2.0/2.1/2.2|2.4.0/2.5.0/2.6.0| [mindstudio_probe-8.1.2-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/8.1/mindstudio_probe-8.1.2-py3-none-any.whl) |ff07bb81fddd3b8f3096d119ca1481bde8fdb24f10644def5250caad727448ab|
|
|
21
|
+
| 8.1.1 | 2025.6.20 |1.11/2.0/2.1/2.2|2.4.0/2.5.0/2.6.0| [mindstudio_probe-8.1.1-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/8.1/mindstudio_probe-8.1.1-py3-none-any.whl) |2aad10a243575544d7feef552caf4d06aa93028488ebd0bbc9aa350379da859d|
|
|
22
|
+
| 8.1.0 | 2025.6.14 |1.11/2.0/2.1/2.2|2.4.0/2.5.0/2.6.0| [mindstudio_probe-8.1.0-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/8.1/mindstudio_probe-8.1.0-py3-none-any.whl) |d10c0a57d073bbe7c681042a11e93a0eaaaf5aa45e1cec997142ce2593d77afd|
|
|
23
|
+
| 8.0.0 | 2025.5.07 |1.11/2.0/2.1/2.2|2.4.0/2.5.0/2.6.0| [mindstudio_probe-8.0.0-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/8.0/mindstudio_probe-8.0.0-py3-none-any.whl) |6810eade7ae99e3b24657d5cab251119882decd791aa76a7aeeb94dea767daec|
|
|
24
|
+
| 1.3.0 | 2025.4.17 |1.11/2.0/2.1/2.2|2.4.0/2.5.0/2.6.0| [mindstudio_probe-1.3.0-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/1.3/mindstudio_probe-1.3.0-py3-none-any.whl) |85dbc5518b5c23d29c67d7b85d662517d0318352f372891f8d91e73e71b439c3|
|
|
25
|
+
| 1.2.2 | 2025.3.03 |1.11/2.0/2.1/2.2|2.4.0| [mindstudio_probe-1.2.2-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/1.2/mindstudio_probe-1.2.2-py3-none-any.whl) |961411bb460d327ea51d6ca4d0c8e8c5565f07c0852d7b8592b781ca35b87212|
|
|
26
|
+
| 1.2.1 | 2025.2.07 |1.11/2.0/2.1/2.2|2.4.0| [mindstudio_probe-1.2.1-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/1.2/mindstudio_probe-1.2.1-py3-none-any.whl) |b64b342118558e0339b39237f88a49b93fd24551b0cb202c872fbfef4260c86b|
|
|
27
|
+
| 1.2.0 | 2025.1.13 |1.11/2.0/2.1/2.2|2.4.0| [mindstudio_probe-1.2.0-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/1.2/mindstudio_probe-1.2.0-py3-none-any.whl) |1e3aeea1706112f6ee52fd1165037936bb209138f0b9ec42ea21e2c1c8942cdc|
|
|
28
|
+
| 1.1.1 | 2024.12.09 |1.11/2.0/2.1/2.2|2.4.0| [mindstudio_probe-1.1.1-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/1.1/mindstudio_probe-1.1.1-py3-none-any.whl) |577b597555dc155b76ba1a62d575c3546004644e140a456c3ba0824d46283735|
|
|
29
|
+
| 1.1.0 | 2024.10.14 |1.11/2.0/2.1/2.2|2.4.0| [mindstudio_probe-1.1.0-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/1.1/mindstudio_probe-1.1.0-py3-none-any.whl) |83a5a9b7c65a357639f8c9636d88c693b4cf0eb590d4f8f5cb56395ba69b1f6d|
|
|
30
|
+
| 1.0.4 | 2024.09.09 |1.11/2.0/2.1/2.2|2.4.0| [mindstudio_probe-1.0.4-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/1.0/mindstudio_probe-1.0.4-py3-none-any.whl) |4e1909566a71a855b356597750c20ee43d964a22b2c2b02ac08312a5def75fd6|
|
|
29
31
|
| 1.0.3 | 2024.08.23 | 1.11/2.0/2.1/2.2 | 2.4.0 | [mindstudio_probe-1.0.3-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/1.0/mindstudio_probe-1.0.3-py3-none-any.whl) | 7060cc141a5b98ef770cd9220995d299393f32a61938261e632c7e8b5160bef2 |
|
|
30
32
|
| 1.0.2 | 2024.08.09 | 1.11/2.0/2.1/2.2 | 2.4.0 | [mindstudio_probe-1.0.2-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/1.0/mindstudio_probe-1.0.2-py3-none-any.whl) | e4a980e5d98c426ce5ce9842520d9bc031d3b3de621c74b3d59414cc6e238e0e |
|
|
31
33
|
| 1.0.1 | 2024.07.25 | 2.0/2.1/2.2 | 2.4.0 | [mindstudio_probe-1.0.1-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/1.0/mindstudio_probe-1.0.1-py3-none-any.whl) | b699e224e4d4e3bcf9412c54fa858a1ee370f0d7a2bc69cb3f1273ac14a6dc82 |
|
|
@@ -38,18 +40,18 @@ sha256sum {name}.whl # 验证whl包,若校验码一致,则whl包在下载中
|
|
|
38
40
|
```bash
|
|
39
41
|
pip install ./mindstudio_probe-{version}-py3-none-any.whl # 安装whl包
|
|
40
42
|
```
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
若覆盖安装,请在命令行末尾添加 `--force-reinstall` 参数。
|
|
44
|
+
上面提供的whl包链接不包含adump功能,如果需要使用adump功能,请参考[从源码安装](#3-从源码安装)下载源码编译whl包。
|
|
43
45
|
|
|
44
46
|
## 3 从源码安装
|
|
45
47
|
|
|
46
48
|
```shell
|
|
47
|
-
git clone https://
|
|
49
|
+
git clone https://gitcode.com/Ascend/mstt.git
|
|
48
50
|
cd mstt/debug/accuracy_tools
|
|
49
51
|
|
|
50
52
|
pip install setuptools wheel
|
|
51
53
|
|
|
52
|
-
python setup.py bdist_wheel [--include-mod=[adump]]
|
|
54
|
+
python setup.py bdist_wheel [--include-mod=[adump]] [--no-check]
|
|
53
55
|
cd ./dist
|
|
54
56
|
pip install ./mindstudio_probe*.whl
|
|
55
57
|
```
|
|
@@ -57,9 +59,39 @@ pip install ./mindstudio_probe*.whl
|
|
|
57
59
|
|参数|说明|是否必选|
|
|
58
60
|
|--|--|:--:|
|
|
59
61
|
|--include-mod|指定可选模块,可取值`adump`,表示在编whl包时加入adump模块。默认未配置该参数,表示编基础包。<br>• adump模块用于MindSpore静态图场景L2级别的dump。<br>• 仅MindSpore 2.5.0及以上版本支持adump模块。<br>• 若使用源码安装,编译环境需支持GCC 7.5或以上版本,和CMake 3.14或以上版本。<br>• 生成的whl包仅限编译时使用的python版本和处理器架构可用。|否|
|
|
62
|
+
|--no-check|指定可选模块`adump`后,会下载所依赖的三方库包,下载过程会进行证书校验。--no-check可以跳过证书校验。|否|
|
|
60
63
|
|
|
61
64
|
# 特性变更说明
|
|
62
65
|
|
|
66
|
+
## 8.1.1
|
|
67
|
+
|
|
68
|
+
【数据采集】
|
|
69
|
+
|
|
70
|
+
- 单点保存能力增强,新增 MindSpore 和 Pytorch 框架异步单点保存,MindSpore 静态图单点保存能力。
|
|
71
|
+
- task 支持 statistic + tenser 模式共存
|
|
72
|
+
- MindSpore 静态图支持模块级 dump 及比对
|
|
73
|
+
- 支持分析整网首个溢出节点
|
|
74
|
+
- 提供对外接口支持用户注册自定义 api 的 dump
|
|
75
|
+
|
|
76
|
+
【训练状态监控】
|
|
77
|
+
|
|
78
|
+
- 支持偏离历史值及时告警
|
|
79
|
+
- 支持 nan 值和极大值即时告警
|
|
80
|
+
- 支持堆栈信息采集
|
|
81
|
+
- 支持 mbs 粒度梯度信息采集
|
|
82
|
+
- 支持采集 shape, dtype 信息
|
|
83
|
+
- 激活值监控支持多输入场景
|
|
84
|
+
|
|
85
|
+
【训练检查】
|
|
86
|
+
|
|
87
|
+
- 新增模块,用于[训练前配置项](./docs/31.config_check.md)对齐
|
|
88
|
+
- 支持三方库,环境变量,训练超参,模型权重,输入数据及随机性函数检查
|
|
89
|
+
- 支持 [checkpoint 比对](./docs/32.ckpt_compare.md)
|
|
90
|
+
|
|
91
|
+
【单算子API自动生成脚本】
|
|
92
|
+
|
|
93
|
+
- 新增支持 MindSpore 框架
|
|
94
|
+
|
|
63
95
|
## 1.2.0
|
|
64
96
|
|
|
65
97
|
【数据采集】
|
|
@@ -182,7 +214,7 @@ pip show mindstudio-probe
|
|
|
182
214
|
Name: mindstudio-probe
|
|
183
215
|
Version: 1.0.x
|
|
184
216
|
Summary: Pytorch Ascend Probe Utils
|
|
185
|
-
Home-page: https://
|
|
217
|
+
Home-page: https://gitcode.com/Ascend/mstt/tree/master/debug/accuracy_tools/msprobe
|
|
186
218
|
Author: Ascend Team
|
|
187
219
|
Author-email: pmail_mindstudio@huawei.com
|
|
188
220
|
License: Apache License 2.0
|
|
@@ -195,7 +227,7 @@ Required-by:
|
|
|
195
227
|
|
|
196
228
|
## 1 安装 CANN 包
|
|
197
229
|
|
|
198
|
-
1.1 根据 CPU 架构和 NPU 型号选择 toolkit 和 kernel,可以参考 [CANN 软件安装指南](https://
|
|
230
|
+
1.1 根据 CPU 架构和 NPU 型号选择 toolkit 和 kernel,可以参考 [CANN 软件安装指南](https://www.hiascend.com/document/detail/zh/canncommercial/700/envdeployment/instg/instg_0001.html)和[昇腾社区](https://www.hiascend.cn/developer/download/community/result?module=cann)。
|
|
199
231
|
|
|
200
232
|
1.2 运行示例
|
|
201
233
|
```bash
|
|
@@ -209,7 +241,7 @@ source {cann_path}/ascend-toolkit/set_env.sh
|
|
|
209
241
|
```
|
|
210
242
|
## 2 安装 PyTorch_NPU
|
|
211
243
|
|
|
212
|
-
链接:[https://
|
|
244
|
+
链接:[https://gitcode.com/Ascend/pytorch](https://gitcode.com/Ascend/pytorch)。
|
|
213
245
|
|
|
214
246
|
## 3 安装 MindSpeed LLM
|
|
215
247
|
|
|
@@ -10,15 +10,16 @@
|
|
|
10
10
|
|
|
11
11
|
### 1.1 通用配置
|
|
12
12
|
|
|
13
|
-
| 参数
|
|
14
|
-
|
|
15
|
-
| task | dump 的任务类型,str 类型。可选参数:<br/> "statistics":仅采集统计信息,默认值;<br/> "tensor":采集统计信息和完全复刻整网的真实数据;<br/> "run_ut":精度预检,仅 PyTorch 场景支持,采集数据时勿选;<br/> "overflow_check":溢出检测;<br/> "free_benchmark":无标杆比对,不支持 MSAdapter 场景;<br/> "grad_probe":梯度监控, 不支持 MSAdapter 场景; <br/> "structure":仅采集模型结构以及调用栈信息,不采集具体数据。 <br/> 根据 task 参数取值的不同,可以配置不同场景参数,详见:<br/>[1.2 task 配置为 statistics](#12-task-配置为-statistics),<br/>[1.3 task 配置为 tensor](#13-task-配置为-tensor),<br/>[1.4 task 配置为 run_ut](#14-task-配置为-run_ut),<br/>[1.5 task 配置为 overflow_check](#15-task-配置为-overflow_check),<br/>[1.6 task 配置为 free_benchmark](#16-task-配置为-free_benchmark),<br/>[1.7 task 配置为 grad_probe](#17-task-配置为-grad_probe),<br/>[1.8 task 配置为 structure](#18-task-配置为-structure)。 <br/> **配置示例**:"task": "tensor"。 | 否 |
|
|
13
|
+
| 参数 | 解释 | 是否必选 |
|
|
14
|
+
|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -------- |
|
|
15
|
+
| task | dump 的任务类型,str 类型。可选参数:<br/> "statistics":仅采集统计信息,默认值;<br/> "tensor":采集统计信息和完全复刻整网的真实数据;<br/> "run_ut":精度预检,仅 PyTorch 场景支持,采集数据时勿选;<br/> "overflow_check":溢出检测;<br/> "free_benchmark":无标杆比对,不支持 MSAdapter 场景;<br/> "grad_probe":梯度监控, 不支持 MSAdapter 场景; <br/> "structure":仅采集模型结构以及调用栈信息,不采集具体数据。 <br/> 根据 task 参数取值的不同,可以配置不同场景参数,详见:<br/>[1.2 task 配置为 statistics](#12-task-配置为-statistics),<br/>[1.3 task 配置为 tensor](#13-task-配置为-tensor),<br/>[1.4 task 配置为 run_ut](#14-task-配置为-run_ut),<br/>[1.5 task 配置为 overflow_check](#15-task-配置为-overflow_check),<br/>[1.6 task 配置为 free_benchmark](#16-task-配置为-free_benchmark),<br/>[1.7 task 配置为 grad_probe](#17-task-配置为-grad_probe),<br/>[1.8 task 配置为 structure](#18-task-配置为-structure),<br/>[1.9 task 配置为 exception_dump](#19-task-配置为-exception_dump)。 <br/> **配置示例**:"task": "tensor"。 | 否 |
|
|
16
16
|
| dump_path | 设置 dump 数据目录路径,str 类型。<br/> **配置示例**:"dump_path": "./dump_path"。 | 是 |
|
|
17
17
|
| rank | 指定对某张卡上的数据进行采集,list[Union[int, str]] 类型,默认未配置(表示采集所有卡的数据),应配置元素为 ≥0 的整数或类似"4-6"的字符串,且须配置实际可用的 Rank ID。<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 参数对所有节点同时生效。静态图 L0 级别 dump 暂不支持指定rank。<br/> 注意,单卡训练时,rank必须为[],即空列表,不能指定rank。<br/>**配置示例**:"rank": [1, "4-6"]。 | 否 |
|
|
18
18
|
| step | 指定采集某个 step 的数据,list[Union[int, str]] 类型。默认未配置,表示采集所有 step 数据。采集特定 step 时,须指定为训练脚本中存在的 step,可逐个配置,也可以指定范围。<br/> **配置示例**:"step": [0, 1 , 2, "4-6"]。 | 否 |
|
|
19
19
|
| level | dump 级别,str 类型,根据不同级别采集不同数据。可选参数:<br/>"L0":dump 模块级精度数据,使用背景详见 [1.1.1 模块级精度数据 dump 说明](#111-模块级精度数据-dump-说明)。<br/>"L1":dump API 级精度数据,默认值,仅 PyTorch、MSAdapter 以及 MindSpore 动态图场景支持。<br/>"L2":dump kernel 级精度数据,PyTorch 场景详细介绍见 [PyTorch 场景的 kernel dump 说明](./04.kernel_dump_PyTorch.md);MindSpore 动态图场景详细介绍见 [MindSpore 动态图场景的 kernel dump 说明](./28.kernel_dump_MindSpore.md);MindSpore 静态图场景详细介绍见《MindSpore 场景的数据采集》中的 ["**8.1 静态图场景**"](./06.data_dump_MindSpore.md#81-静态图场景)小节。<br/>"mix":dump module 模块级和 API 级精度数据,即"L0"+"L1",仅 PyTorch、MSAdapter 以及 MindSpore 动态图场景支持。<br/>"debug":单点保存功能,详见[单点保存工具](./28.debugger_save_instruction.md)。<br/> **配置示例**:"level": "L1"。 | 否 |
|
|
20
20
|
| enable_dataloader | 自动控制开关,bool 类型,仅 PyTorch 场景支持。可选参数 true(开启)或 false(关闭),默认为 false。配置为 true 后自动识别 step 参数指定的迭代,并在该迭代执行完成后退出训练,此时 start、stop 和 step 函数可不配置,开启该开关要求训练脚本是通过 torch.utils.data.dataloader 方式加载数据。仅支持 PyTorch 单卡训练使用,分布式训练场景下存在数据 dump 不全问题。 **这个特性下个版本将被废弃** | 否 |
|
|
21
|
-
| async_dump | 异步 dump 开关,bool 类型, 支持 task 为 tensor 或 statistic 模式, level 支持 L0、 L1、 mix、 debug 模式。可选参数 true(开启)或 false(关闭),默认为 false。配置为 true 后开启异步 dump,即采集的精度数据会在当前 step 训练结束后统一落盘,训练过程中工具不触发同步操作。由于使用该模式有**显存溢出**的风险,当 task 配置为 tensor 时,即真实数据的异步dump模式,必须配置 [list](#13-task-配置为-tensor) 参数,指定需要 dump 的 tensor
|
|
21
|
+
| async_dump | 异步 dump 开关,bool 类型, 支持 task 为 tensor 或 statistic 模式, level 支持 L0、 L1、 mix、 debug 模式。可选参数 true(开启)或 false(关闭),默认为 false。配置为 true 后开启异步 dump,即采集的精度数据会在当前 step 训练结束后统一落盘,训练过程中工具不触发同步操作。由于使用该模式有**显存溢出**的风险,当 task 配置为 tensor 时,即真实数据的异步dump模式,必须配置 [list](#13-task-配置为-tensor) 参数,指定需要 dump 的 tensor 。该模式下,summary_mode 不支持 md5 值,也不支持复数类型 tensor 的统计量计算。 <br/> | 否 |
|
|
22
|
+
| precision | 控制统计值计算所用精度,可选值["high", "low"],默认值为"low"。选择"high"时,统计量使用float32进行计算,会增加device内存占用,精度更高,但在处理较大数值时可能会导致**显存溢出**;为"low"时使用与原始数据相同的类型进行计算,device内存占用较少。支持 Pytorch,MindSpore 动态图,MindSpore静态图 O0/O1 场景。支持 task 配置为 statistic 或 tensor, level 配置为 L0,L1,mix,debug。 | 否 |
|
|
22
23
|
|
|
23
24
|
#### 1.1.1 模块级精度数据 dump 说明
|
|
24
25
|
|
|
@@ -46,18 +47,17 @@
|
|
|
46
47
|
<tr><td rowspan="2">tensor_list</td><td>自定义采集真实数据的算子列表,list[str] 类型,默认未配置。包含以下配置方法:</td><td rowspan="2">否</td></tr>
|
|
47
48
|
<tr><td>PyTorch、MSAdapter 以及 MindSpore 动态图场景指定某一类 API 或模块,即会 dump 这一类 API 或模块输入输出的统计量信息和完整的 tensor 数据。<br/><b>配置示例</b>:"tensor_list": ["relu"]。 <br/> PyTorch、MSAdapter 以及 MindSpore 动态图场景目前只支持level配置为 L0, L1 和 mix 级别。 <br/> MindSpore 静态图场景不支持。</td></tr>
|
|
48
49
|
<tr><td>device</td><td>控制统计值计算所用的设备,可选值["device", "host"],默认"host"。使用device计算会比host有性能加速,只支持min/max/avg/l2norm统计量。支持 MindSpore静态图 O0/O1 场景。</td><td>否</td></tr>
|
|
49
|
-
<tr><td>precision</td><td>控制统计值计算所用精度,可选值["high", "low"],默认值为"high"。选择"high"时,avg/l2norm统计量使用float32进行计算,会增加device内存占用,精度更高;为"low"时使用与原始数据相同的类型进行计算,device内存占用较少,但在处理较大数值时可能会导致统计量溢出。支持 MindSpore静态图 O0/O1 场景。</td><td>否</td></tr>
|
|
50
50
|
<tr><td rowspan="3">data_mode</td><td>dump 数据过滤,str 类型。</td><td rowspan="3">否</td></tr><tr><td>PyTorch、MSAdapter 以及 MindSpore 动态图场景:支持"all"、"forward"、"backward"、"input"和"output",除"all"外,其余参数可以自由组合。默认为["all"],即保存所有 dump 的数据。<br/> <b>配置示例</b>:"data_mode": ["backward"] (仅保存反向数据)或 "data_mode": ["forward", "input"](仅保存前向的输入数据)。</td></tr>
|
|
51
51
|
<tr><td>MindSpore 静态图场景:L0 级别 dump 仅支持"all"、"forward"和"backward"参数;L2 级别 dump 仅支持"all"、"input"和"output"参数。且各参数只能单独配置,不支持自由组合。<br/><b>配置示例</b>:"data_mode": ["all"]。</td></tr>
|
|
52
52
|
<tr><td rowspan="3">summary_mode</td><td>控制 dump 文件输出的模式,str 类型,支持 PyTorch、MSAdapter、MindSpore 动态图以及 MindSpore 静态图 L2 级别 jit_level=O2 场景和 L0 级别 jit_level=O0/O1 场景。</td><td rowspan="3">否</td></tr>
|
|
53
53
|
<tr><td>PyTorch、MSAdapter 以及 MindSpore 动态图场景:可选参数为<br/> md5:dump 输出包含 CRC-32 值以及 API 统计信息的 dump.json 文件,用于验证数据的完整性;<br/> statistics:dump 仅输出包含 API 统计信息的 dump.json 文件,默认值。<br/><b>配置示例</b>:"summary_mode": "md5"。</td></tr>
|
|
54
|
-
<tr><td>MindSpore 静态图 L2 级别 jit_level=O2 场景:支持上述配置的同时额外支持配置统计项列表,可选统计项为max、min、mean、l2norm,可从中任意选取组合搭配。其中mean、l2norm的结果为float数据格式。<br/>MindSpore 静态图 L0 级别 jit_level=O0/O1场景:仅支持上述配置中"statistics"字段和max、min、mean、l2norm中任意组合搭配的统计项列表。<br/><b>配置示例</b>:"summary_mode": ["max", "min"]。</td></tr>
|
|
54
|
+
<tr><td>MindSpore 静态图 L2 级别 jit_level=O2 场景:支持上述配置的同时额外支持配置统计项列表,可选统计项为max、min、mean、l2norm,可从中任意选取组合搭配。其中mean、l2norm的结果为float数据格式。<br/>MindSpore 静态图 L2 级别 jit_level=O0/O1 场景:支持上述配置的同时额外支持配置统计项列表,可选统计项为max、min、mean、l2norm、count、negative zero count、zero count、positive zero count、nan count、negative inf count、positive inf count、hash、md5,可从中任意选取组合搭配。注意:hash统计项在MindSpore2.7.0及以前版本计算MD5值,在以后版本计算SHA1值。<br/>MindSpore 静态图 L0 级别 jit_level=O0/O1场景:仅支持上述配置中"statistics"字段和max、min、mean、l2norm中任意组合搭配的统计项列表。<br/><b>配置示例</b>:"summary_mode": ["max", "min"]。</td></tr>
|
|
55
55
|
</table>
|
|
56
56
|
|
|
57
57
|
**说明**:
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
1. "summary_mode" 配置为 "md5" 时,所使用的校验算法为 CRC-32 算法。
|
|
60
|
+
1. PyTorch、MSAdapter 以及 MindSpore 动态图场景,"summary_mode" 配置为 "md5" 时,所使用的校验算法为 CRC-32 算法;MindSpore 静态图场景,"summary_mode" 配置为 "md5" 时,所使用的校验算法为 MD5 算法。
|
|
61
61
|
|
|
62
62
|
**示例**:
|
|
63
63
|
- [PyTorch场景](03.config_examples.md#11-task-配置为-statistics)
|
|
@@ -73,14 +73,7 @@
|
|
|
73
73
|
| data_mode | 与[ 1.2 task 配置为 statistics ](#12-task-配置为-statistics)中的解释相同 | 否 |
|
|
74
74
|
| file_format | tensor 数据的保存格式,str 类型,仅支持 MindSpore 静态图场景的 L2 级别配置该字段,其他场景不生效。可选参数:<br/> "bin":dump 的 tensor 文件为二进制格式;<br/>"npy":dump 的 tensor 文件后缀为 .npy,默认值。 | 否 |
|
|
75
75
|
| summary_mode | 控制 dump 文件输出的模式,str 类型,支持 PyTorch、MSAdapter、MindSpore 动态图。可选参数:<br/> md5:dump 输出包含 CRC-32 值以及 API 统计信息的 dump.json 文件,用于验证数据的完整性;<br/> statistics:dump 仅输出包含 API 统计信息的 dump.json 文件,默认值。| 否 |
|
|
76
|
-
| online_run_ut<sup>a</sup> | 在线预检模式开关,bool 类型,可选参数 true(开启)、false(关闭),默认未配置,表示关闭。配置为 true 表示开启在线预检。| 否 |
|
|
77
|
-
| nfs_path<sup>a</sup> | 在线预检模式共享存储目录路径,str 类型,用于 GPU 设备和 NPU 设备间进行通信。仅在 online_run_ut 字段配置为 true 时生效,配置该参数后 host 和 port 不生效。 | 否 |
|
|
78
|
-
| host<sup>a</sup> | 在线预检模式局域网场景信息接收端 IP,str 类型,用于 GPU 设备和 NPU 设备间进行通信,NPU 侧须配置为 GPU 侧的局域网 IP 地址。仅在 online_run_ut 字段配置为 true 时生效,局域网场景时,不能配置 nfs_path 参数,否则局域网场景不生效。 | 否 |
|
|
79
|
-
| port<sup>a</sup> | 在线预检模式局域网场景信息接收端端口号,int 类型,用于 GPU 设备和 NPU 设备间进行通信,NPU 侧须配置为 GPU 侧的端口号。仅在 online_run_ut 字段配置为 true 时生效,局域网场景时,不能配置 nfs_path 参数,否则局域网场景不生效。| 否 |
|
|
80
76
|
|
|
81
|
-
**说明**:
|
|
82
|
-
|
|
83
|
-
1. online_run_ut、nfs_path、host、port 等字段仅在线预检场景 NPU 机器生效。
|
|
84
77
|
|
|
85
78
|
**示例**:
|
|
86
79
|
- [PyTorch场景](03.config_examples.md#12-task-配置为-tensor)
|
|
@@ -95,17 +88,11 @@
|
|
|
95
88
|
| white_list<sup>a</sup> | API dump 白名单,仅对指定的 API 进行 dump。<br/>**配置示例**:"white_list": ["conv1d", "conv2d"]。默认未配置白名单,即 dump 全量 API 数据。 | 否 |
|
|
96
89
|
| black_list<sup>a</sup> | API dump 黑名单,被指定的 API 不进行 dump。<br/>**配置示例**:"black_list": ["conv1d", "conv2d"]。默认未配置黑名单,即 dump 全量 API 数据。 | 否 |
|
|
97
90
|
| error_data_path | 配置保存精度未达标的 API 输入输出数据路径,默认为当前路径。<br/>**配置示例**:"error_data_path": "./"。 | 否 |
|
|
98
|
-
| is_online<sup>b</sup> | 在线预检模式开关,bool 类型,可选参数 true(开启)、false(关闭),默认关闭。 | 否 |
|
|
99
|
-
| nfs_path<sup>b</sup> | 在线预检模式共享存储目录路径,str 类型,用于 GPU 设备和 NPU 设备间进行通信。配置该参数后 host 和 port 不生效,仅在 is_online 字段配置为 true 时生效。 | 否 |
|
|
100
|
-
| host<sup>b</sup> | 在线预检模式局域网场景信息接收端 IP,str 类型,用于 GPU 设备和 NPU 设备间进行通信,GPU 侧配置为本机地址 127.0.0.1 或本机局域网 IP。局域网场景时,不能配置 nfs_path 参数,否则局域网场景不生效。仅在 is_online 字段配置为 true 时生效。 | 否 |
|
|
101
|
-
| port<sup>b</sup> | 在线预检模式局域网场景信息接收端端口号,int 类型,用于 GPU 设备和 NPU 设备间进行通信,GPU 侧配置为本机可用端口。局域网场景时,不能配置 nfs_path 参数,否则局域网场景不生效。仅在 is_online 字段配置为 true 时生效。| 否 |
|
|
102
|
-
| rank_list<sup>b</sup> | 指定在线预检的 Rank ID,默认值为 [0],list[int] 类型,应配置为大于等于 0 的整数,且须根据实际卡的 Rank ID 配置,若所配置的值大于实际训练所运行的卡的 Rank ID,则在线预检输出数据为空。GPU 和 NPU 须配置一致。仅在 is_online 字段配置为 true 时生效。 | 否 |
|
|
103
91
|
|
|
104
92
|
**说明**:
|
|
105
93
|
|
|
106
94
|
1. white_list 和 black_list 同时配置时,二者配置的 API 名单若无交集,则白名单生效,若 API 名单存在交集,则白名单排除的部分以及交集的 API 不进行 dump。
|
|
107
95
|
|
|
108
|
-
2. is_online、nfs_path、host、port、rank_list 等字段仅在线预检场景 GPU 机器生效。
|
|
109
96
|
|
|
110
97
|
**示例**:
|
|
111
98
|
```json
|
|
@@ -223,3 +210,12 @@ structure 模式仅采集模型结构,无其他特殊配置。
|
|
|
223
210
|
- [PyTorch场景](03.config_examples.md#16-task-配置为-structure)
|
|
224
211
|
- [MindSpore动态图场景](03.config_examples.md#35-task-配置为-structure)
|
|
225
212
|
|
|
213
|
+
### 1.9 task 配置为 exception_dump
|
|
214
|
+
MindSpore 动态图场景下,"level"须为"L2"; MindSpore 静态图场景下,"level"须为"L2",且模型编译优化等级(jit_level)须为"O0"或"O1"。
|
|
215
|
+
|
|
216
|
+
在运行过程中会在指定目录下生成kernel_graph_exception_dump.json的中间文件,该文件包含异常dump的相关设置。
|
|
217
|
+
除中间文件外的其他 dump 结果文件请参见 MindSpore 官方文档中的[ Ascend 下 O0/O1 模式 Dump 数据对象目录和数据文件介绍](https://www.mindspore.cn/docs/zh-CN/r2.5.0/model_train/debug/dump.html#%E6%95%B0%E6%8D%AE%E5%AF%B9%E8%B1%A1%E7%9B%AE%E5%BD%95%E5%92%8C%E6%95%B0%E6%8D%AE%E6%96%87%E4%BB%B6%E4%BB%8B%E7%BB%8D)
|
|
218
|
+
|
|
219
|
+
**示例**:
|
|
220
|
+
- [MindSpore动态图场景](03.config_examples.md#36-task-配置为-exception_dump)
|
|
221
|
+
- [MindSpore静态图场景](03.config_examples.md#24-task-配置为-exception_dump)
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"rank": [],
|
|
14
14
|
"step": [],
|
|
15
15
|
"level": "L1",
|
|
16
|
+
"async_dump": false,
|
|
16
17
|
|
|
17
18
|
"statistics": {
|
|
18
19
|
"scope": [],
|
|
@@ -33,6 +34,7 @@
|
|
|
33
34
|
"rank": [],
|
|
34
35
|
"step": [],
|
|
35
36
|
"level": "L1",
|
|
37
|
+
"async_dump": false,
|
|
36
38
|
|
|
37
39
|
"tensor": {
|
|
38
40
|
"scope": [],
|
|
@@ -166,6 +168,18 @@
|
|
|
166
168
|
}
|
|
167
169
|
```
|
|
168
170
|
|
|
171
|
+
### 2.4 task 配置为 exception_dump
|
|
172
|
+
|
|
173
|
+
```json
|
|
174
|
+
{
|
|
175
|
+
"task": "exception_dump",
|
|
176
|
+
"dump_path": "/home/data_dump",
|
|
177
|
+
"rank": [],
|
|
178
|
+
"step": [],
|
|
179
|
+
"level": "L2"
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
169
183
|
## 3 MindSpore 动态图场景
|
|
170
184
|
|
|
171
185
|
### 3.1 task 配置为 statistics
|
|
@@ -253,3 +267,15 @@
|
|
|
253
267
|
"level": "mix"
|
|
254
268
|
}
|
|
255
269
|
```
|
|
270
|
+
|
|
271
|
+
### 3.6 task 配置为 exception_dump
|
|
272
|
+
|
|
273
|
+
```json
|
|
274
|
+
{
|
|
275
|
+
"task": "exception_dump",
|
|
276
|
+
"dump_path": "/home/data_dump",
|
|
277
|
+
"rank": [],
|
|
278
|
+
"step": [],
|
|
279
|
+
"level": "L2"
|
|
280
|
+
}
|
|
281
|
+
```
|
|
@@ -68,6 +68,6 @@ kernel dump 采集成功后,会在指定的 dump_path 目录下生成如下文
|
|
|
68
68
|
|
|
69
69
|
2. 其次需要确认 API 是否运行在昇腾 NPU 上,如果是运行在其他设备上则不会存在 kernel 级数据。
|
|
70
70
|
|
|
71
|
-
3. 如果排除上述两点仍然没有数据,您可以使用《[Ascend Extension for PyTorch 插件](https://
|
|
71
|
+
3. 如果排除上述两点仍然没有数据,您可以使用《[Ascend Extension for PyTorch 插件](https://gitcode.com/Ascend/pytorch)》提供的
|
|
72
72
|
torch_npu.npu 接口进行 kernel 层数据采集,工具的 kernel dump 也是基于其中的init_dump、set_dump和finalize_dump三个子接口实现的。
|
|
73
73
|
torch_npu.npu 接口详细描述见《[torch_npu.npu API 概述](https://www.hiascend.com/document/detail/zh/Pytorch/60RC3/apiref/apilist/ptaoplist_000192.html)》。
|
|
@@ -15,6 +15,8 @@ functional: # functional为算子类别,找到对应的类别,在该类别
|
|
|
15
15
|
|
|
16
16
|
删除API的场景:部分模型代码逻辑会存在API原生类型校验,工具执行dump操作时,对模型的API封装可能与模型的原生API类型不一致,此时可能引发校验失败,详见《[FAQ](FAQ.md)》中“异常情况”的第10和11条。
|
|
17
17
|
|
|
18
|
+
加工具后loss/gnorm发生变化:可能是工具中的item操作引入同步,pt/ms框架的hook机制等原因导致的,详见《[工具导致计算结果变化](36.calculation_result_change.md)》。
|
|
19
|
+
|
|
18
20
|
## 快速上手
|
|
19
21
|
|
|
20
22
|
这个示例定义了一个 nn.Module 类型的简单网络,使用原型函数 PrecisionDebugger 进行数据采集。
|
|
@@ -168,14 +170,14 @@ module_dump_end()
|
|
|
168
170
|
|
|
169
171
|
**原型**:
|
|
170
172
|
```python
|
|
171
|
-
seed_all(seed=1234, mode=False, rm_dropout=
|
|
173
|
+
seed_all(seed=1234, mode=False, rm_dropout=False)
|
|
172
174
|
```
|
|
173
175
|
|
|
174
176
|
**参数说明**:
|
|
175
177
|
|
|
176
178
|
1. seed: 随机性种子。参数示例: seed=1000。默认值:1234。非必选
|
|
177
179
|
2. mode:确定性计算模式。可配置True或False。参数示例:mode=True。默认为False。非必选(注意:确定性计算会导致API执行性能降低,建议在发现模型多次执行结果不同的情况下开启)
|
|
178
|
-
3. rm_dropout:控制dropout失效的开关。可配置 True 或 False,默认值:
|
|
180
|
+
3. rm_dropout:控制dropout失效的开关。可配置 True 或 False,默认值:False,非必选。参数示例:rm_dropout=True。
|
|
179
181
|
该参数设置为 True 后, 工具会自动将 `torch.nn.functional.dropout`、`torch.nn.functional.dropout2d`、`torch.nn.functional.dropout3d`、`torch.nn.Dropout`、`torch.nn.Dropout2d`、`torch.nn.Dropout3d`
|
|
180
182
|
的接口参数 p 置为0,以避免因随机dropout造成的网络随机性。 注意:通过rm_dropout控制dropout失效或生效需要在初始化dropout实例前调用才能生效。
|
|
181
183
|
|
|
@@ -238,6 +240,8 @@ save(variable, name, save_backward=True)
|
|
|
238
240
|
| name | 指定的名称 | str | 是 |
|
|
239
241
|
| save_backward | 是否保存反向数据 | boolean | 否 |
|
|
240
242
|
|
|
243
|
+
具体使用样例可参考:[单点保存工具使用介绍](./28.debugger_save_instruction.md)。
|
|
244
|
+
|
|
241
245
|
### 1.10 set_init_step
|
|
242
246
|
|
|
243
247
|
**功能说明**:设置起始step数,step数默认从0开始计数,使用该接口后step从指定值开始计数。该函数需要写在训练迭代的循环开始前,不能写在循环内。
|