mindstudio-probe 8.2.0__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.2.0.dist-info → mindstudio_probe-8.2.1.dist-info}/METADATA +2 -2
- {mindstudio_probe-8.2.0.dist-info → mindstudio_probe-8.2.1.dist-info}/RECORD +63 -61
- msprobe/README.md +4 -4
- msprobe/core/common/const.py +6 -0
- msprobe/core/common/db_manager.py +35 -4
- msprobe/core/common/file_utils.py +28 -5
- msprobe/core/common/megatron_utils.py +59 -0
- msprobe/core/common/utils.py +14 -3
- msprobe/core/compare/diff_analyze/first_diff_analyze.py +16 -4
- msprobe/core/compare/diff_analyze/ignore_op_list.yaml +3 -0
- msprobe/core/compare/find_first/analyzer.py +8 -7
- msprobe/core/compare/find_first/graph.py +11 -3
- msprobe/core/compare/find_first/utils.py +3 -2
- msprobe/core/compare/highlight.py +13 -6
- msprobe/core/compare/multiprocessing_compute.py +17 -10
- msprobe/core/compare/utils.py +14 -5
- msprobe/core/data_dump/data_collector.py +18 -21
- msprobe/core/data_dump/data_processor/pytorch_processor.py +43 -20
- msprobe/core/data_dump/json_writer.py +18 -8
- msprobe/core/data_dump/scope.py +4 -6
- msprobe/core/hook_manager.py +21 -0
- msprobe/core/service.py +2 -0
- msprobe/core/single_save/single_comparator.py +16 -3
- msprobe/docs/01.installation.md +7 -5
- msprobe/docs/04.kernel_dump_PyTorch.md +1 -1
- msprobe/docs/06.data_dump_MindSpore.md +1 -1
- msprobe/docs/10.accuracy_compare_PyTorch.md +46 -5
- msprobe/docs/14.data_parse_PyTorch.md +1 -1
- msprobe/docs/19.monitor.md +2 -0
- msprobe/docs/21.visualization_PyTorch.md +15 -80
- msprobe/docs/22.visualization_MindSpore.md +20 -104
- msprobe/docs/23.generate_operator_PyTorch.md +1 -1
- msprobe/docs/26.data_dump_PyTorch_baseline.md +7 -7
- 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/api_accuracy_checker/api_accuracy_checker.py +1 -1
- msprobe/mindspore/cell_processor.py +33 -5
- msprobe/mindspore/compare/common_dir_compare.py +22 -26
- msprobe/mindspore/debugger/precision_debugger.py +1 -1
- msprobe/mindspore/dump/cell_dump_process.py +73 -62
- msprobe/mindspore/dump/graph_mode_cell_dump.py +21 -10
- msprobe/mindspore/dump/hook_cell/ms_hook_manager.py +2 -0
- msprobe/pytorch/compare/utils.py +2 -1
- msprobe/pytorch/dump/module_dump/hook_wrapper.py +10 -7
- msprobe/pytorch/dump/module_dump/module_processer.py +15 -8
- msprobe/pytorch/monitor/module_hook.py +28 -9
- msprobe/pytorch/online_dispatch/dispatch.py +42 -24
- msprobe/visualization/builder/graph_builder.py +169 -64
- msprobe/visualization/builder/graph_merger.py +0 -1
- msprobe/visualization/builder/msprobe_adapter.py +1 -1
- msprobe/visualization/db_utils.py +25 -2
- msprobe/visualization/graph/base_node.py +0 -24
- msprobe/visualization/graph/graph.py +5 -14
- msprobe/visualization/graph_service.py +29 -53
- {mindstudio_probe-8.2.0.dist-info → mindstudio_probe-8.2.1.dist-info}/LICENSE +0 -0
- {mindstudio_probe-8.2.0.dist-info → mindstudio_probe-8.2.1.dist-info}/WHEEL +0 -0
- {mindstudio_probe-8.2.0.dist-info → mindstudio_probe-8.2.1.dist-info}/entry_points.txt +0 -0
- {mindstudio_probe-8.2.0.dist-info → mindstudio_probe-8.2.1.dist-info}/top_level.txt +0 -0
msprobe/core/hook_manager.py
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
|
+
import gc
|
|
16
17
|
import os
|
|
17
18
|
import threading
|
|
18
19
|
from abc import ABC, abstractmethod
|
|
@@ -65,6 +66,18 @@ class BaseHookManager(ABC):
|
|
|
65
66
|
BaseHookManager.hook_handle_dict.clear()
|
|
66
67
|
BaseHookManager.params_grad_info.clear()
|
|
67
68
|
|
|
69
|
+
@staticmethod
|
|
70
|
+
def ensure_gc_enabled():
|
|
71
|
+
is_gc_disabled = not gc.isenabled()
|
|
72
|
+
if is_gc_disabled:
|
|
73
|
+
gc.enable()
|
|
74
|
+
return is_gc_disabled
|
|
75
|
+
|
|
76
|
+
@staticmethod
|
|
77
|
+
def restore_gc_state(original_state):
|
|
78
|
+
if original_state:
|
|
79
|
+
gc.disable()
|
|
80
|
+
|
|
68
81
|
@staticmethod
|
|
69
82
|
def _clear_input_kwargs(module, tid):
|
|
70
83
|
if hasattr(module, 'msprobe_input_kwargs') and tid in module.msprobe_input_kwargs:
|
|
@@ -168,9 +181,11 @@ class BaseHookManager(ABC):
|
|
|
168
181
|
if not self._should_execute_hook(Const.MODULE, tid):
|
|
169
182
|
return
|
|
170
183
|
with ThreadSafe():
|
|
184
|
+
original_state = self.ensure_gc_enabled()
|
|
171
185
|
BaseHookManager.inner_switch[tid] = True
|
|
172
186
|
self.data_collector.params_data_collect(ori_name, param_name, self._pid, grad)
|
|
173
187
|
BaseHookManager.inner_switch[tid] = False
|
|
188
|
+
self.restore_gc_state(original_state)
|
|
174
189
|
return
|
|
175
190
|
|
|
176
191
|
return hook_fn
|
|
@@ -185,6 +200,7 @@ class BaseHookManager(ABC):
|
|
|
185
200
|
return None
|
|
186
201
|
|
|
187
202
|
with ThreadSafe():
|
|
203
|
+
original_state = self.ensure_gc_enabled()
|
|
188
204
|
self._register_forward_hook(module, api_name)
|
|
189
205
|
BaseHookManager.inner_api_count[tid] += 1
|
|
190
206
|
if BaseHookManager.inner_api_count[tid] != 1:
|
|
@@ -209,6 +225,7 @@ class BaseHookManager(ABC):
|
|
|
209
225
|
self._is_recompute
|
|
210
226
|
)
|
|
211
227
|
BaseHookManager.inner_switch[tid] = False
|
|
228
|
+
self.restore_gc_state(original_state)
|
|
212
229
|
return args
|
|
213
230
|
|
|
214
231
|
return forward_pre_hook
|
|
@@ -221,6 +238,7 @@ class BaseHookManager(ABC):
|
|
|
221
238
|
return None
|
|
222
239
|
|
|
223
240
|
with ThreadSafe():
|
|
241
|
+
original_state = self.ensure_gc_enabled()
|
|
224
242
|
if hook_type == Const.API:
|
|
225
243
|
if BaseHookManager.inner_api_count[tid] != 1:
|
|
226
244
|
if BaseHookManager.inner_api_count[tid] > 1:
|
|
@@ -276,6 +294,7 @@ class BaseHookManager(ABC):
|
|
|
276
294
|
return forward_new_output
|
|
277
295
|
|
|
278
296
|
BaseHookManager.inner_switch[tid] = False
|
|
297
|
+
self.restore_gc_state(original_state)
|
|
279
298
|
return output
|
|
280
299
|
|
|
281
300
|
return forward_hook
|
|
@@ -287,6 +306,7 @@ class BaseHookManager(ABC):
|
|
|
287
306
|
return
|
|
288
307
|
|
|
289
308
|
with ThreadSafe():
|
|
309
|
+
original_state = self.ensure_gc_enabled()
|
|
290
310
|
BaseHookManager.inner_switch[tid] = True
|
|
291
311
|
self.data_collector.update_api_or_module_name(full_name)
|
|
292
312
|
|
|
@@ -306,5 +326,6 @@ class BaseHookManager(ABC):
|
|
|
306
326
|
params_dict = self._get_params_dict(module)
|
|
307
327
|
self.data_collector.params_data_collect_in_bw_hook(params_dict, full_name)
|
|
308
328
|
BaseHookManager.inner_switch[tid] = False
|
|
329
|
+
self.restore_gc_state(original_state)
|
|
309
330
|
|
|
310
331
|
return backward_hook
|
msprobe/core/service.py
CHANGED
|
@@ -26,6 +26,7 @@ from msprobe.core.common.utils import Const, print_tools_ends_info, DumpPathAggr
|
|
|
26
26
|
from msprobe.core.data_dump.api_registry import ApiRegistry
|
|
27
27
|
from msprobe.core.data_dump.data_collector import build_data_collector
|
|
28
28
|
from msprobe.core.kernel_dump.kernel_config import create_kernel_config_json
|
|
29
|
+
from msprobe.core.common.megatron_utils import MegatronStepInfo
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
class BaseService(ABC):
|
|
@@ -170,6 +171,7 @@ class BaseService(ABC):
|
|
|
170
171
|
self.currrent_step_first_debug_save = True
|
|
171
172
|
self.loop += 1
|
|
172
173
|
self._reset_status()
|
|
174
|
+
MegatronStepInfo.reset()
|
|
173
175
|
|
|
174
176
|
def save(self, variable, name, save_backward):
|
|
175
177
|
'''
|
|
@@ -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
|
@@ -16,6 +16,7 @@ pip install mindstudio-probe
|
|
|
16
16
|
|
|
17
17
|
| 版本 | 发布日期 |支持 PyTorch 版本|支持 MindSpore 版本| 下载链接 |校验码|
|
|
18
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|
|
|
19
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|
|
|
20
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|
|
|
21
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|
|
|
@@ -45,12 +46,12 @@ pip install ./mindstudio_probe-{version}-py3-none-any.whl # 安装whl包
|
|
|
45
46
|
## 3 从源码安装
|
|
46
47
|
|
|
47
48
|
```shell
|
|
48
|
-
git clone https://
|
|
49
|
+
git clone https://gitcode.com/Ascend/mstt.git
|
|
49
50
|
cd mstt/debug/accuracy_tools
|
|
50
51
|
|
|
51
52
|
pip install setuptools wheel
|
|
52
53
|
|
|
53
|
-
python setup.py bdist_wheel [--include-mod=[adump]]
|
|
54
|
+
python setup.py bdist_wheel [--include-mod=[adump]] [--no-check]
|
|
54
55
|
cd ./dist
|
|
55
56
|
pip install ./mindstudio_probe*.whl
|
|
56
57
|
```
|
|
@@ -58,6 +59,7 @@ pip install ./mindstudio_probe*.whl
|
|
|
58
59
|
|参数|说明|是否必选|
|
|
59
60
|
|--|--|:--:|
|
|
60
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可以跳过证书校验。|否|
|
|
61
63
|
|
|
62
64
|
# 特性变更说明
|
|
63
65
|
|
|
@@ -212,7 +214,7 @@ pip show mindstudio-probe
|
|
|
212
214
|
Name: mindstudio-probe
|
|
213
215
|
Version: 1.0.x
|
|
214
216
|
Summary: Pytorch Ascend Probe Utils
|
|
215
|
-
Home-page: https://
|
|
217
|
+
Home-page: https://gitcode.com/Ascend/mstt/tree/master/debug/accuracy_tools/msprobe
|
|
216
218
|
Author: Ascend Team
|
|
217
219
|
Author-email: pmail_mindstudio@huawei.com
|
|
218
220
|
License: Apache License 2.0
|
|
@@ -225,7 +227,7 @@ Required-by:
|
|
|
225
227
|
|
|
226
228
|
## 1 安装 CANN 包
|
|
227
229
|
|
|
228
|
-
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)。
|
|
229
231
|
|
|
230
232
|
1.2 运行示例
|
|
231
233
|
```bash
|
|
@@ -239,7 +241,7 @@ source {cann_path}/ascend-toolkit/set_env.sh
|
|
|
239
241
|
```
|
|
240
242
|
## 2 安装 PyTorch_NPU
|
|
241
243
|
|
|
242
|
-
链接:[https://
|
|
244
|
+
链接:[https://gitcode.com/Ascend/pytorch](https://gitcode.com/Ascend/pytorch)。
|
|
243
245
|
|
|
244
246
|
## 3 安装 MindSpeed LLM
|
|
245
247
|
|
|
@@ -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)》。
|
|
@@ -88,7 +88,7 @@ PrecisionDebugger(config_path=None, task=None, dump_path=None, level=None, step=
|
|
|
88
88
|
|
|
89
89
|
#### 6.1.1 start
|
|
90
90
|
|
|
91
|
-
**功能说明**:启动精度数据采集。静态图场景下,必须在mindspore.communication.init 调用前添加。如果没有使用 [Model](https://
|
|
91
|
+
**功能说明**:启动精度数据采集。静态图场景下,必须在mindspore.communication.init 调用前添加。如果没有使用 [Model](https://www.mindspore.cn/tutorials/zh-CN/r2.3.1/advanced/model.html) 高阶 API 进行训练,则需要与 stop 函数一起添加在 for 循环内,否则只有需要传入model参数时,才使用该接口。
|
|
92
92
|
|
|
93
93
|
**原型**:
|
|
94
94
|
|
|
@@ -251,7 +251,48 @@ PyTorch 精度比对是以 CPU 或 GPU 的计算结果为标杆,通过计算
|
|
|
251
251
|
|
|
252
252
|
上表中NPU_Stack_Info字段需要配置-s参数生成。
|
|
253
253
|
|
|
254
|
-
### 3.2
|
|
254
|
+
### 3.2 比对指标计算公式
|
|
255
|
+
|
|
256
|
+
$N$: NPU侧tensor
|
|
257
|
+
|
|
258
|
+
$B$: Bench侧tensor
|
|
259
|
+
|
|
260
|
+
RE(Relative Error, 相对误差): $\vert\frac {N-B} {B}\vert$
|
|
261
|
+
|
|
262
|
+
真实数据模式:
|
|
263
|
+
|
|
264
|
+
Cosine: $\frac {{N}\cdot{B}} {{\vert\vert{N}\vert\vert}_2{\vert\vert{B}\vert\vert}_2}$
|
|
265
|
+
|
|
266
|
+
EucDist: ${\vert\vert{A-B}\vert\vert}_2$
|
|
267
|
+
|
|
268
|
+
MaxAbsErr: $max(\vert{N-B}\vert)$
|
|
269
|
+
|
|
270
|
+
MaxRelativeErr: $max(RE)$
|
|
271
|
+
|
|
272
|
+
One Thousandth Err Ratio: $\frac {\sum\mathbb{I}(RE<0.001)} {size(RE)}$
|
|
273
|
+
|
|
274
|
+
Five Thousandth Err Ratio: $\frac {\sum\mathbb{I}(RE<0.005)} {size(RE)}$
|
|
275
|
+
|
|
276
|
+
统计数据模式:
|
|
277
|
+
|
|
278
|
+
Max diff: $max(N)-max(B)$
|
|
279
|
+
|
|
280
|
+
Min diff: $min(N)-min(B)$
|
|
281
|
+
|
|
282
|
+
Mean diff: $mean(N)-mean(B)$
|
|
283
|
+
|
|
284
|
+
L2 Norm diff: $l2norm(N)-l2norm(B)$
|
|
285
|
+
|
|
286
|
+
MaxRelativeErr: $\vert\frac{max(N)-max(B)}{max(B)}\vert*100\%$
|
|
287
|
+
|
|
288
|
+
MinRelativeErr: $\vert\frac{min(N)-min(B)}{min(B)}\vert*100\%$
|
|
289
|
+
|
|
290
|
+
MeanRelativeErr: $\vert\frac{mean(N)-mean(B)}{mean(B)}\vert*100\%$
|
|
291
|
+
|
|
292
|
+
NormRelativeErr: $\vert\frac{l2norm(N)-l2norm(B)}{l2norm(B)}\vert*100\%$
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
### 3.3 颜色标记——真实数据模式、统计数据模式
|
|
255
296
|
|
|
256
297
|
通过在命令行中配置-hl或--highlight开启,或者在比对函数中配置参数highlight=True开启,用于标记精度可疑API或模块。开启后,比对性能会有降低,建议比对较大dump.json文件时不配置此参数。
|
|
257
298
|
颜色标记分为红色标记和黄色标记,红色标记优先级高于黄色标记。
|
|
@@ -270,7 +311,7 @@ PyTorch 精度比对是以 CPU 或 GPU 的计算结果为标杆,通过计算
|
|
|
270
311
|
4. 一个 API 或模块的 Cosine 的 input/parameters - output > 0.1(真实数据模式);
|
|
271
312
|
5. 一个 API 或模块的 Requires_grad Consistent 为 False。
|
|
272
313
|
|
|
273
|
-
### 3.
|
|
314
|
+
### 3.4 比对结果(Result)——统计数据模式、MD5 模式
|
|
274
315
|
|
|
275
316
|
统计数据模式:
|
|
276
317
|
1. Warning 情况:4种统计值至少一种相对误差 > 0.5,要重点检查该 API;
|
|
@@ -282,7 +323,7 @@ MD5 模式:
|
|
|
282
323
|
2. Different 情况:NPU 与标杆的 CRC-32 值不一致,即 API 数据不完全一致;
|
|
283
324
|
3. N/A 情况:API 没有匹配上。
|
|
284
325
|
|
|
285
|
-
### 3.
|
|
326
|
+
### 3.5 判断计算精度达标情况(Accuracy Reached or Not)——真实数据模式
|
|
286
327
|
|
|
287
328
|
标记为 `No`,表示精度不达标:
|
|
288
329
|
1. Cosine < 0.99 且 MaxAbsError > 0.001;
|
|
@@ -300,7 +341,7 @@ MD5 模式:
|
|
|
300
341
|
标记为 `Yes`,表示精度达标:
|
|
301
342
|
1. 除以上情况外的其余情况。
|
|
302
343
|
|
|
303
|
-
### 3.
|
|
344
|
+
### 3.6 错误信息提示(Err_message)——真实数据模式、统计数据模式
|
|
304
345
|
|
|
305
346
|
1. "Need double check api accuracy.":四个统计值中至少 1 个相对误差 > 0.5(统计数据模式);
|
|
306
347
|
2. "Fuzzy matching data, the comparison accuracy may be affected.":NPU 或 Bench 的真实数据名没有匹配上(真实数据模式);
|
|
@@ -319,7 +360,7 @@ MD5 模式:
|
|
|
319
360
|
|
|
320
361
|
除以上错误信息提示外,异常数据颜色高亮标记的原因叠加呈现于此列。
|
|
321
362
|
|
|
322
|
-
### 3.
|
|
363
|
+
### 3.7 计算精度评价指标分析
|
|
323
364
|
|
|
324
365
|
1. Cosine:通过计算两个向量的余弦值来判断其相似度,数值越接近于 1 说明计算出的两个张量越相似,实际可接受阈值为大于 0.99。在计算中可能会存在 nan,主要由于可能会出现其中一个向量为 0。
|
|
325
366
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
使用场景:本工具主要用于精度比对前后两次 NPU kernel 层级 dump 数据的一致性。
|
|
8
8
|
|
|
9
|
-
依赖:CANN 包中的 msaccucmp 工具,需要安装 Ascend-CANN-toolkit,详见《[CANN 软件安装指南](https://
|
|
9
|
+
依赖:CANN 包中的 msaccucmp 工具,需要安装 Ascend-CANN-toolkit,详见《[CANN 软件安装指南](https://www.hiascend.com/document/detail/zh/canncommercial/700/envdeployment/instg/instg_0001.html)》。
|
|
10
10
|
|
|
11
11
|
## 2 数据解析操作指导
|
|
12
12
|
|
msprobe/docs/19.monitor.md
CHANGED
|
@@ -62,6 +62,8 @@ monitor.set_monitor(
|
|
|
62
62
|
)
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+
*注意*:若框架为FSDP1,请先保证model包裹FSDP时设置use_orig_params=True。
|
|
66
|
+
|
|
65
67
|
*注意*:补充deepspeed下常用框架的使能位置。
|
|
66
68
|
|
|
67
69
|
deepspeed与accelerate、transformers同时使用时,optimizer传值方式为`optimizer=optimizer.optimizer`,若未使用deepspeed,单独使用accelerate、transformers,optimizer传值方式为`optimizer=optimizer`。
|
|
@@ -21,18 +21,16 @@
|
|
|
21
21
|
|
|
22
22
|
### 1.1 安装msprobe工具
|
|
23
23
|
|
|
24
|
-
[msprobe工具安装](
|
|
24
|
+
[msprobe工具安装](./01.installation.md)
|
|
25
25
|
|
|
26
26
|
### 1.2 安装tb_graph_ascend
|
|
27
27
|
|
|
28
28
|
**请安装tb_graph_ascend,否则无法解析构图结果。**
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
如需升级工具,请先``pip3 uninstall tb-graph-ascend``再``pip3 install tb-graph-ascend``即可。
|
|
30
|
+
[tb_graph_ascend安装](../../../../plugins/tensorboard-plugins/tb_graph_ascend#2-安装方式)
|
|
33
31
|
|
|
34
32
|
## 2.模型结构数据采集
|
|
35
|
-
[PyTorch场景的数据采集](
|
|
33
|
+
[PyTorch场景的数据采集](./05.data_dump_PyTorch.md)
|
|
36
34
|
|
|
37
35
|
**需要选择level为L0(module信息)或者mix(module信息+api信息),才能采集到模型结构数据,即采集结果件construct.json内容不为空**。
|
|
38
36
|
|
|
@@ -50,11 +48,10 @@ msprobe -f pytorch graph -i ./compare.json -o ./output
|
|
|
50
48
|
|------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------|
|
|
51
49
|
| -f 或 --framework | 指定训练框架。pytorch。 | 是 |
|
|
52
50
|
| -i 或 --input_path | 指定比对文件,参考[比对文件说明](#313-比对文件说明) | 是 |
|
|
53
|
-
| -o 或 --output_path | 配置比对结果文件存盘目录,str 类型。文件名称基于时间戳自动生成,格式为:`compare_{timestamp}.vis或build_{timestamp}.vis`。
|
|
51
|
+
| -o 或 --output_path | 配置比对结果文件存盘目录,str 类型。文件名称基于时间戳自动生成,格式为:`compare_{timestamp}.vis.db或build_{timestamp}.vis.db`。 | 是 |
|
|
54
52
|
| -lm 或 --layer_mapping | 跨套件比对,例如同一个模型分别使用了DeepSpeed和Megatron套件的比对场景。配置该参数时表示开启跨套件Layer层的比对功能,指定模型代码中的Layer层后,可以识别对应dump数据中的模块或API。需要指定自定义映射文件*.yaml。自定义映射文件的格式请参见[自定义映射文件(Layer)](#71-自定义映射文件layer),如何配置自定义映射文件请参考[模型分级可视化如何配置layer mapping映射文件](./visualization/layer_mapping_example.md)。 配置该参数后,将仅按节点名称进行比对,忽略节点的 type 和 shape。如果调试侧和标杆侧有名称不同的节点,则需要配置自定义映射文件,-lm参数传入自定义映射文件路径;如果调试侧和标杆侧节点名称相同,则仅指定-lm即可。<br/><br/>可参考的实际案例:[MindSpeed&LLamaFactory数据采集和自动比对](./visualization/mindspeed_llamafactory_mapping.md) | 否 |
|
|
55
|
-
| -oc 或 --overflow_check | 是否开启溢出检测模式,开启后会在输出
|
|
53
|
+
| -oc 或 --overflow_check | 是否开启溢出检测模式,开启后会在输出db文件中(`compare_{timestamp}.vis.db或build_{timestamp}.vis.db`)对每个溢出节点进行标记溢出等级,溢出等级说明参考[溢出等级说明](#312-溢出等级说明) | 否 |
|
|
56
54
|
| -f 或 --fuzzy_match | 是否开启模糊匹配,bool类型。模糊匹配说明参考[匹配说明](#311-匹配说明) | 否 |
|
|
57
|
-
| -cs 或 --complete_stack | 是否使用完整的堆栈信息,bool类型。默认使用精简的堆栈信息,数据量小有助于增加流畅度。完整堆栈和精简堆栈信息参考[堆栈信息说明](#72-堆栈信息说明) | 否 |
|
|
58
55
|
|
|
59
56
|
#### 3.1.1 匹配说明
|
|
60
57
|
|
|
@@ -139,7 +136,7 @@ msprobe -f pytorch graph -i ./compare.json -o ./output
|
|
|
139
136
|
|
|
140
137
|
3.md5:dump了API和Module的输入输出数据统计信息和md5信息。
|
|
141
138
|
|
|
142
|
-
dump类型如何配置见[数据采集配置文件介绍](https://
|
|
139
|
+
dump类型如何配置见[数据采集配置文件介绍](https://gitcode.com/Ascend/mstt/blob/master/debug/accuracy_tools/msprobe/docs/02.config_introduction.md)
|
|
143
140
|
|
|
144
141
|
**1. 准备比对文件**:
|
|
145
142
|
|
|
@@ -168,7 +165,7 @@ npu_path或bench_path格式:必须包含dump.json、stack.json和construct.jso
|
|
|
168
165
|
msprobe -f pytorch graph -i ./compare.json -o ./output
|
|
169
166
|
```
|
|
170
167
|
|
|
171
|
-
比对完成后将在**output**下生成一个**vis后缀文件**。
|
|
168
|
+
比对完成后将在**output**下生成一个**vis.db后缀文件**。
|
|
172
169
|
|
|
173
170
|
#### 3.2.3 批量构建或比对
|
|
174
171
|
##### 3.2.3.1 多rank批量构建或比对
|
|
@@ -212,25 +209,15 @@ npu_path或bench_path格式:必须只包含rank+数字格式的文件夹,且
|
|
|
212
209
|
```
|
|
213
210
|
msprobe -f pytorch graph -i ./compare.json -o ./output
|
|
214
211
|
```
|
|
215
|
-
比对完成后将在**output**下生成
|
|
212
|
+
比对完成后将在**output**下生成1个**vis.db后缀文件**。
|
|
216
213
|
|
|
217
214
|
图构建:
|
|
218
215
|
```
|
|
219
|
-
├──
|
|
220
|
-
├── build_rank1_{timestamp}.vis
|
|
221
|
-
├── build_rank2_{timestamp}.vis
|
|
222
|
-
├── build_rank3_{timestamp}.vis
|
|
223
|
-
├── ...
|
|
224
|
-
├── build_rankn_{timestamp}.vis
|
|
216
|
+
├── build_{timestamp}.vis.db
|
|
225
217
|
```
|
|
226
218
|
图比对:
|
|
227
219
|
```
|
|
228
|
-
├──
|
|
229
|
-
├── compare_rank1_{timestamp}.vis
|
|
230
|
-
├── compare_rank2_{timestamp}.vis
|
|
231
|
-
├── compare_rank3_{timestamp}.vis
|
|
232
|
-
├── ...
|
|
233
|
-
├── compare_rankn_{timestamp}.vis
|
|
220
|
+
├── compare_{timestamp}.vis.db
|
|
234
221
|
```
|
|
235
222
|
##### 3.2.3.2 多step批量构建或比对
|
|
236
223
|
批量构建或比对多个step下的所有rank的数据
|
|
@@ -277,33 +264,15 @@ npu_path或bench_path格式:必须只包含step+数字格式的文件夹,且
|
|
|
277
264
|
```
|
|
278
265
|
msprobe -f pytorch graph -i ./compare.json -o ./output
|
|
279
266
|
```
|
|
280
|
-
比对完成后将在**output
|
|
267
|
+
比对完成后将在**output**下生成1个**vis.db后缀文件**。
|
|
281
268
|
|
|
282
269
|
图构建:
|
|
283
270
|
```
|
|
284
|
-
├──
|
|
285
|
-
├── build_step0_rank1_{timestamp}.vis
|
|
286
|
-
├── build_step0_rank2_{timestamp}.vis
|
|
287
|
-
├── build_step0_rank3_{timestamp}.vis
|
|
288
|
-
├── build_step1_rank0_{timestamp}.vis
|
|
289
|
-
├── build_step1_rank1_{timestamp}.vis
|
|
290
|
-
├── build_step1_rank2_{timestamp}.vis
|
|
291
|
-
├── build_step1_rank3_{timestamp}.vis
|
|
292
|
-
├── ...
|
|
293
|
-
├── build_stepn_rankn_{timestamp}.vis
|
|
271
|
+
├── build_{timestamp}.vis.db
|
|
294
272
|
```
|
|
295
273
|
图比对:
|
|
296
274
|
```
|
|
297
|
-
├──
|
|
298
|
-
├── compare_step0_rank1_{timestamp}.vis
|
|
299
|
-
├── compare_step0_rank2_{timestamp}.vis
|
|
300
|
-
├── compare_step0_rank3_{timestamp}.vis
|
|
301
|
-
├── compare_step1_rank0_{timestamp}.vis
|
|
302
|
-
├── compare_step1_rank1_{timestamp}.vis
|
|
303
|
-
├── compare_step1_rank2_{timestamp}.vis
|
|
304
|
-
├── compare_step1_rank3_{timestamp}.vis
|
|
305
|
-
├── ...
|
|
306
|
-
├── compare_stepn_rankn_{timestamp}.vis
|
|
275
|
+
├── compare_{timestamp}.vis.db
|
|
307
276
|
```
|
|
308
277
|
|
|
309
278
|
#### 3.2.4 仅模型结构比对
|
|
@@ -412,9 +381,11 @@ tensorboard --logdir out_path
|
|
|
412
381
|
|
|
413
382
|
### 5.1 浏览器打开图
|
|
414
383
|
推荐使用谷歌浏览器,在浏览器中输入机器地址+端口号回车,出现TensorBoard页面,其中/#graph_ascend会自动拼接。
|
|
384
|
+
|
|
415
385
|

|
|
416
386
|
|
|
417
387
|
如果您切换了TensorBoard的其他功能,此时想回到模型分级可视化页面,可以点击左上方的**GRAPH_ASCEND**
|
|
388
|
+
|
|
418
389
|

|
|
419
390
|
|
|
420
391
|
### 5.2 查看图
|
|
@@ -534,42 +505,6 @@ yaml文件中只需配置待调试侧与标杆侧模型代码中功能一致但
|
|
|
534
505
|
|
|
535
506
|

|
|
536
507
|
|
|
537
|
-
### 7.2 堆栈信息说明
|
|
538
|
-
|
|
539
|
-
**精简堆栈**
|
|
540
|
-
|
|
541
|
-
保留一条当前模块或api的调用信息
|
|
542
|
-
|
|
543
|
-
```json
|
|
544
|
-
{
|
|
545
|
-
"Module.layer1.0.bn1.BatchNorm2d.forward.0": [
|
|
546
|
-
"File /home/torchvision/models/resnet.py, line 93, in forward, \n out = self.bn1(out)"
|
|
547
|
-
]
|
|
548
|
-
}
|
|
549
|
-
```
|
|
550
|
-
|
|
551
|
-
**完整堆栈**
|
|
552
|
-
|
|
553
|
-
当前模块或api完整的调用信息
|
|
554
|
-
|
|
555
|
-
```json
|
|
556
|
-
{
|
|
557
|
-
"Module.layer1.0.bn1.BatchNorm2d.forward.0": [
|
|
558
|
-
"File /home/torchvision/models/resnet.py, line 93, in forward, \n out = self.bn1(out)",
|
|
559
|
-
"File /home/torch/nn/modules/module.py, line 1568, in _call_impl, \n result = forward_call(*args, **kwargs)",
|
|
560
|
-
"File /home/torch/nn/modules/module.py, line 1518, in _wrapped_call_impl, \n return self._call_impl(*args, **kwargs)",
|
|
561
|
-
"File /home/torch/nn/modules/container.py, line 215, in forward, \n input = module(input)",
|
|
562
|
-
"File /home/torch/nn/modules/module.py, line 1568, in _call_impl, \n result = forward_call(*args, **kwargs)",
|
|
563
|
-
"File /home/torch/nn/modules/module.py, line 1518, in _wrapped_call_impl, \n return self._call_impl(*args, **kwargs)",
|
|
564
|
-
"File /home/torchvision/models/resnet.py, line 273, in _forward_impl, \n x = self.layer1(x)",
|
|
565
|
-
"File /home/torchvision/models/resnet.py, line 285, in forward, \n return self._forward_impl(x)",
|
|
566
|
-
"File /home/torch/nn/modules/module.py, line 1527, in _call_impl, \n return forward_call(*args, **kwargs)",
|
|
567
|
-
"File /home/torch/nn/modules/module.py, line 1518, in _wrapped_call_impl, \n return self._call_impl(*args, **kwargs)",
|
|
568
|
-
"File /home/visualization/resnet18.py, line 40, in <module>, \n outputs = model(inputs)"
|
|
569
|
-
]
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
```
|
|
573
508
|
# FAQ
|
|
574
509
|
1. 图比对场景,节点呈现灰色,且没有精度比对数据,怎么处理?
|
|
575
510
|
|