mindstudio-probe 8.1.0__py3-none-any.whl → 8.1.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.0.dist-info → mindstudio_probe-8.1.1.dist-info}/METADATA +3 -2
- {mindstudio_probe-8.1.0.dist-info → mindstudio_probe-8.1.1.dist-info}/RECORD +46 -47
- msprobe/core/common/const.py +1 -0
- msprobe/core/common/file_utils.py +36 -18
- msprobe/core/common/utils.py +19 -8
- msprobe/core/compare/acc_compare.py +14 -5
- msprobe/core/compare/utils.py +7 -1
- msprobe/core/data_dump/data_collector.py +144 -90
- msprobe/core/data_dump/json_writer.py +31 -1
- msprobe/core/debugger/precision_debugger.py +19 -18
- msprobe/core/service.py +1 -0
- msprobe/core/single_save/single_comparator.py +25 -25
- msprobe/core/single_save/single_saver.py +5 -16
- msprobe/docs/01.installation.md +1 -0
- msprobe/docs/05.data_dump_PyTorch.md +3 -0
- msprobe/docs/06.data_dump_MindSpore.md +3 -0
- msprobe/docs/08.accuracy_checker_online_PyTorch.md +2 -2
- msprobe/docs/25.tool_function_introduction.md +19 -19
- msprobe/docs/33.generate_operator_MindSpore.md +10 -19
- msprobe/mindspore/api_accuracy_checker/api_accuracy_checker.py +1 -0
- msprobe/mindspore/api_accuracy_checker/compute_element.py +0 -1
- msprobe/mindspore/api_accuracy_checker/generate_op_script/op_generator.py +10 -1
- msprobe/mindspore/api_accuracy_checker/torch_mindtorch_importer.py +2 -1
- msprobe/mindspore/common/utils.py +1 -0
- msprobe/mindspore/debugger/precision_debugger.py +4 -4
- msprobe/mindspore/dump/cell_dump_process.py +13 -38
- msprobe/mindspore/dump/cell_dump_with_insert_gradient.py +1 -26
- msprobe/mindspore/dump/hook_cell/api_register.py +3 -3
- msprobe/mindspore/dym_loader/hook_dynamic_loader.cpp +4 -4
- msprobe/mindspore/mindspore_service.py +3 -0
- msprobe/mindspore/monitor/features.py +10 -9
- msprobe/mindspore/monitor/optimizer_collect.py +4 -1
- msprobe/pytorch/api_accuracy_checker/compare/compare_utils.py +20 -20
- msprobe/pytorch/api_accuracy_checker/run_ut/multi_run_ut.py +7 -7
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/utils.py +2 -0
- msprobe/pytorch/common/utils.py +1 -1
- msprobe/pytorch/debugger/precision_debugger.py +28 -25
- msprobe/pytorch/hook_module/api_register.py +3 -3
- msprobe/pytorch/monitor/optimizer_collect.py +4 -1
- msprobe/pytorch/pytorch_service.py +3 -0
- msprobe/visualization/compare/mode_adapter.py +9 -0
- msprobe/visualization/utils.py +3 -0
- msprobe/mindspore/api_accuracy_checker/generate_op_script/config_op.json +0 -9
- {mindstudio_probe-8.1.0.dist-info → mindstudio_probe-8.1.1.dist-info}/LICENSE +0 -0
- {mindstudio_probe-8.1.0.dist-info → mindstudio_probe-8.1.1.dist-info}/WHEEL +0 -0
- {mindstudio_probe-8.1.0.dist-info → mindstudio_probe-8.1.1.dist-info}/entry_points.txt +0 -0
- {mindstudio_probe-8.1.0.dist-info → mindstudio_probe-8.1.1.dist-info}/top_level.txt +0 -0
|
@@ -4,27 +4,27 @@
|
|
|
4
4
|
|
|
5
5
|
| 功能名(英文) | 简介 | 适用场景/优势 | 当前版本局限性 |
|
|
6
6
|
| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
7
|
-
| [
|
|
8
|
-
| [
|
|
9
|
-
| [
|
|
10
|
-
| [
|
|
11
|
-
| [
|
|
12
|
-
| [
|
|
13
|
-
| [
|
|
14
|
-
| [
|
|
15
|
-
| [
|
|
16
|
-
| [
|
|
17
|
-
| [
|
|
18
|
-
| [单API
|
|
7
|
+
| [数据采集<br>(dump)](./05.data_dump_PyTorch.md) | 采集模型训练过程中的API或Module层级的前反向输入输出数据,包括层次关系、统计值信息、真实数据和调用栈等。 | 1、将模型中训练的API或Module的前反向输入输出数据保存下来分析<br> 2、模型出现溢出时,可用于查看哪些API或Module出现了溢出 | 1、API级数据采集仅支持白名单列表上的API<br>2、工具会做一些同步操作,引入工具可能会导致一些同步问题消失<br>3、当前对inplace操作API或Module的支持度有限<br>4、暂不支持参数及参数梯度的采集 |
|
|
8
|
+
| [离线预检<br>(api_accuracy_checker)](./07.accuracy_checker_PyTorch.md) | 为网络中每个API创建用例,检验其精度,并根据不同比对算法综合判定API在NPU上的精度是否达标,快速找出精度差异API。 | 1、对模型中所有的API做精度初步排查<br>2、精度排查不受模型累计误差影响 | 1、依赖GPU环境<br>2、不支持通信算子<br>3、仅支持部分融合算子 |
|
|
9
|
+
| [整网比对<br>(compare)](./10.accuracy_compare_PyTorch.md) | 计算模型整网NPU和标杆设备的精度误差指标,标记精度异常API或Module,助力快速定位精度问题根因。 | 1、整网比对定位精度可疑算子 | 1、由于使用整网dump数据,定位的可疑算子受累计误差影响<br>2、当模型规模较大时,比对所需时间较长 |
|
|
10
|
+
| [在线预检<br>(online_api_accuracy_checker)](./08.accuracy_checker_online_PyTorch.md) | 通过TCP通信或共享存储空间的方式,进行在线精度预检,解决离线预检大数据量落盘、传输困难痛点。 | 1、使用离线预检,数据量较大落盘困难或传输耗时长时,可通过在线预检进行精度排查 | 1、依赖GPU环境,NPU和GPU能够通信<br>2、重计算模式下,不支持反向aten算子预检 |
|
|
11
|
+
| [溢出检查<br>(overflow_checker)](./12.overflow_check_PyTorch.md) | 检测模型计算过程的输入输出,并在溢出时落盘数据,助力用户快速定位溢出位置。 | 1、当模型出现溢出时,用于快速定位最先溢出的API或Module<br>2、相比数据采集,性能更优,磁盘压力更小 | 1、局限性同数据采集 |
|
|
12
|
+
| [数据解析<br>(parse_tool)](./14.data_parse_PyTorch.md) | 交互式界面处理解析kernel层级dump数据,便于查看分析。 | 1、比对kernel层级dump数据的一致性 | 1、仅限于NPU |
|
|
13
|
+
| [无标杆比对<br>(free_benchmark)](./15.free_benchmarking_PyTorch.md) | 不依赖标杆数据,通过对算子输入增加微小扰动,计算扰动后输出与原始输出的相对误差,识别有精度风险算子。 | 1、无标杆数据场景下的算子精度排查<br>2、对个别算子进行升精度、“to cpu”等操作,以验证其对模型loss的影响 | 1、由于需要拷贝输入进行二次执行,所以在遇到大张量的输入时容易发生显存OOM的问题, 特别是反向比对过程。建议结合白名单使用<br>2、比对会延长训练时间,整网比对可能会造成严重的耗时膨胀,建议结合白名单使用 |
|
|
14
|
+
| [梯度状态监测<br>(grad_probe)](./17.grad_probe.md) | 可导出模型权重梯度数据并对比相似度,助力确认训练过程精度问题step和反向中的异常。 | 1、需要分析梯度数据时<br>2、需要定位发生问题的step时 | 暂无 |
|
|
15
|
+
| [在线精度比对<br>(online_dispatch)](./18.online_dispatch.md) | 训练过程中直接完成NPU和CPU的精度比对并输出比对结果。 | 1、执行一次就可获取NPU和CPU分别执行后的精度比对结果 | 暂无 |
|
|
16
|
+
| [训练状态监控<br>(monitor)](./19.monitor.md) | 收集模型训练过程中的激活值、梯度和优化器状态,助力分析计算、通信、优化器各部分异常情况。 | 1、通过监控模块级统计量指标,快速定位异常模块位置,如loss出现nan | 1、仅支持模块级别统计量指标分析<br>2、仅支持megatron、deepspeed框架<br>3、少量增加时间和显存膨胀 |
|
|
17
|
+
| [可视化比对<br>(visualization) ](./21.visualization_PyTorch.md) | 解析dump的精度数据,还原模型图结构,比对各层级精度数据,助力理解模型结构、分析精度问题。 | 1、整网精度比对定位可疑算子,通过浏览器展示比对结果,支持快速搜索到可疑算子<br>2、支持查看模型层级结果,比对模型层级结构差异 | 1、由于使用整网dump数据,定位的可疑算子受累计误差影响<br>2、当模型规模较大时,比对所需时间较长 |
|
|
18
|
+
| [单API自动生成脚本<br>(generate_operator) ](./23.generate_operator_PyTorch.md) | 解析dump的精度数据,提取可疑的API算子,自动生成单API复现脚本,并根据不同的API采用不同的比对算法,给定最终比对结果数据;帮助开发者分析算子精度问题。 | 1、该工具支持从整网dump下来的数据中提取可疑算子,并自动生成单API脚本<br>2、除了支持复现单API的前反向过程,同时会根据不同的API选择不同的比对方法,并给出比对结果 | 1、不支持通信算子<br>2、融合算子需手动修改脚本进行适配<br>3、目前比对的标杆均为和CPU进行比对,暂不支持直接NPU和GPU比对 |
|
|
19
19
|
|
|
20
20
|
## 2 MindSpore框架
|
|
21
21
|
|
|
22
22
|
| 功能名(英文) | 简介 | 适用场景/优势 | 当前版本局限性 |
|
|
23
23
|
| ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
24
|
-
| [数据采集
|
|
25
|
-
| [离线预检
|
|
26
|
-
| [整网比对
|
|
27
|
-
| [溢出检查
|
|
28
|
-
| [无标杆比对
|
|
29
|
-
| [可视化比对
|
|
30
|
-
| [训练状态监控
|
|
24
|
+
| [数据采集 <br>(dump)](./06.data_dump_MindSpore.md) | 采集模型训练过程中的API或Cell层级的前反向输入输出数据,包括层次关系、统计值信息、真实数据和调用栈等。 | 1、将模型中训练的API或Cell的前反向输入输出数据保存下来分析 <br> 2、模型出现溢出时,可用于查看哪些API或Cell出现了溢出 | 1、API级数据采集仅支持白名单列表上的API <br>2、当前对inplace操作API或Cell的支持度有限 <br>3、暂不支持参数及参数梯度的采集 |
|
|
25
|
+
| [离线预检 <br>(api_accuracy_checker)](./09.accuracy_checker_MindSpore.md) | 为网络中每个API创建用例,检验其精度,并根据不同比对算法综合判定API在NPU上的精度是否达标,快速找出精度差异API。 | 1、对模型中所有的API做精度初步排查 <br>2、精度排查不受模型累计误差影响 | 1、仅针对MindSpore.mint API |
|
|
26
|
+
| [整网比对 <br>(compare)](./11.accuracy_compare_MindSpore.md) | NPU精度数据与标杆数据的比对,支持MindSpore框架内和与PyTorch跨框架的比对,助力快速定位精度异常API或Cell。 | 1、MindSpore同框架静态图比对 <br>2、MindSpore同框架动态图比对 <br>3、MindSpore vs PyTorch跨框架动态图比对 | 1、部分PyTorch的API关联不到MindSpore,需要手动配置映射关系 |
|
|
27
|
+
| [溢出检查 <br>(overflow_checker)](./13.overflow_check_MindSpore.md) | 检测模型计算过程的输入输出,并在溢出时落盘数据,助力用户快速定位溢出位置。 | 1、当模型出现溢出时,可用于定位最先溢出的API或Cell或kernel <br>2、相比数据采集,性能更优,磁盘压力更小 | 1、除具有与数据采集功能相同的局限性外,动态图场景下,不支持 Primitive 和 Jit 类 API 的检测 <br>2、动态图场景下,仅支持检测API或Cell级别溢出 <br>3、静态图场景下,仅支持检测kernel级别溢出 |
|
|
28
|
+
| [无标杆比对 <br>(free_benchmark)](./16.free_benchmarking_MindSpore.md) | 不依赖标杆数据,通过对算子输入增加微小扰动,计算扰动后输出与原始输出的相对误差,识别有精度风险算子。 | 1、无标杆数据场景下的算子精度排查 <br>2、对个别算子进行升精度修复,验证其对模型loss的影响 | 1、仅支持动态图场景 <br>2、由于需要拷贝输入进行二次执行,所以在遇到大张量的输入时容易发生显存OOM的问题, 特别是反向比对过程。建议结合白名单使用 <br>3、比对会延长训练时间,整网比对可能会造成严重的耗时膨胀,建议结合白名单使用 <br>4、不支持“to cpu”操作,不支持预热功能 |
|
|
29
|
+
| [可视化比对 <br>(visualization) ](./22.visualization_MindSpore.md) | 解析dump的精度数据,还原模型图结构,比对各层级精度数据,助力理解模型结构、分析精度问题。 | 1、整网精度比对定位可疑算子,通过浏览器展示比对结果,支持快速搜索到可疑算子 <br>2、支持查看模型层级结果,比对模型层级结构差异 | 1、由于使用整网dump数据,定位的可疑算子受累计误差影响 <br>2、当模型规模较大时,比对所需时间较长 |
|
|
30
|
+
| [训练状态监控 <br>(monitor)](./19.monitor.md) | 收集模型训练过程中的激活值、梯度和优化器状态,助力分析计算、通信、优化器各部分异常情况。 | 1、通过监控模块级统计量指标,快速定位异常模块位置,如loss出现nan | 1、仅支持模块级别统计量指标分析 <br>2、仅支持megatron、deepspeed框架 <br>3、少量增加时间和显存膨胀 |
|
|
@@ -113,31 +113,22 @@ a. 在生成单API脚本时可以选择由工具构造随机数获得 dump 数
|
|
|
113
113
|
```
|
|
114
114
|
**配置文件参数说明**
|
|
115
115
|
|
|
116
|
-
| 参数名称 | 解释
|
|
117
|
-
| ----------------------------
|
|
118
|
-
| dump_json_path | dump.json的文件路径,包含所有dump算子的信息;如果已经提取了可疑算子并保存可以不指定。
|
|
119
|
-
| api_name |
|
|
120
|
-
| extract_api_path | 提取可疑算子的json文件路径
|
|
121
|
-
| propagation | 选择复现算子的forward还是backward,默认为forward
|
|
122
|
-
| data_mode | 选择复现算子的随机数据(random_data)还是真实数据(real_data)模式,默认为random_data
|
|
123
|
-
| random_seed | 仅random_data模式有效,表示手动设定的随机种子,默认为
|
|
124
|
-
| iter_times | 仅random_data模式有效,表示单API运行的次数,由于安全相关原因,最大支持设置为1000
|
|
116
|
+
| 参数名称 | 解释 |
|
|
117
|
+
| ---------------------------- |-------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
118
|
+
| dump_json_path | dump.json的文件路径,包含所有dump算子的信息;如果已经提取了可疑算子并保存可以不指定。 |
|
|
119
|
+
| api_name | 算子名(目前MindSpore支持类型包括:Mint,Tensor,Msadapter支持类型包括:Tensor,Functional,Torch类中可自动求导api),如Mint.split.1,Functional.softmax.3、Tensor.add.0、Torch.matmul.5等。 |
|
|
120
|
+
| extract_api_path | 提取可疑算子的json文件路径 |
|
|
121
|
+
| propagation | 选择复现算子的forward还是backward,默认为forward |
|
|
122
|
+
| data_mode | 选择复现算子的随机数据(random_data)还是真实数据(real_data)模式,默认为random_data |
|
|
123
|
+
| random_seed | 仅random_data模式有效,表示手动设定的随机种子,默认为42 |
|
|
124
|
+
| iter_times | 仅random_data模式有效,表示单API运行的次数,由于安全相关原因,最大支持设置为1000 |
|
|
125
125
|
|
|
126
126
|
### 2.3 运行命令生成单API脚本
|
|
127
127
|
config_op.json配置好后,运行如下命令:
|
|
128
128
|
```
|
|
129
|
-
msprobe -f mindspore op_generate -i ./
|
|
129
|
+
msprobe -f mindspore op_generate -i ./config_op.json -o ./
|
|
130
130
|
```
|
|
131
|
-
或者
|
|
132
131
|
|
|
133
|
-
进入到mstt的generate_op_script文件夹
|
|
134
|
-
```
|
|
135
|
-
cd mstt/debug/accuracy_tools/msprobe/mindspore/api_accuracy_checker/generate_op_script
|
|
136
|
-
```
|
|
137
|
-
运行
|
|
138
|
-
```
|
|
139
|
-
python op_generator.py -i ./config_op.json -o ./
|
|
140
|
-
```
|
|
141
132
|
**参数说明**
|
|
142
133
|
| 参数名称 | 解释 | 是否必选 |
|
|
143
134
|
| ---------------------------- | ------------------------------------------------------------ | ---------------------------------- |
|
|
@@ -112,6 +112,7 @@ class ApiAccuracyChecker:
|
|
|
112
112
|
dump_path_aggregation = DumpPathAggregation()
|
|
113
113
|
dump_path_aggregation.dump_file_path = os.path.join(dump_dir, "dump.json")
|
|
114
114
|
dump_path_aggregation.stack_file_path = os.path.join(dump_dir, "stack.json")
|
|
115
|
+
dump_path_aggregation.dump_error_info_path = os.path.join(dump_dir, "dump_error_info.log")
|
|
115
116
|
dump_path_aggregation.dump_tensor_data_dir = dump_data_dir
|
|
116
117
|
return config, dump_path_aggregation
|
|
117
118
|
|
|
@@ -116,10 +116,19 @@ class CommonConfig:
|
|
|
116
116
|
|
|
117
117
|
filtered = {k: v for k, v in json_content.items() if k not in EXCLUED}
|
|
118
118
|
|
|
119
|
+
if not filtered:
|
|
120
|
+
raise ValueError(f'json file is empty!')
|
|
121
|
+
|
|
119
122
|
if len(filtered) > API_INFO:
|
|
120
123
|
raise ValueError(f'json file has more than one API, the API only contains forward and backward info')
|
|
121
124
|
|
|
122
|
-
|
|
125
|
+
is_forward_phase = propagation == Const.FORWARD
|
|
126
|
+
|
|
127
|
+
is_exact_api_count = len(filtered) == API_INFO
|
|
128
|
+
|
|
129
|
+
all_keys_forward = all(k.endswith('forward') for k in filtered)
|
|
130
|
+
|
|
131
|
+
if is_forward_phase and is_exact_api_count and all_keys_forward:
|
|
123
132
|
raise ValueError(
|
|
124
133
|
"json file has more than one API, the API only contains forward info。"
|
|
125
134
|
)
|
|
@@ -108,7 +108,8 @@ def delete_torch_paths():
|
|
|
108
108
|
|
|
109
109
|
if count_delete_env_path >= MsCompareConst.MAX_RECURSION_DEPTH - 1:
|
|
110
110
|
raise Exception(f"Please check if you have a valid PyTorch and MindTorch environment, and ensure "
|
|
111
|
-
f"the PYTHONPATH environment variable depth does not
|
|
111
|
+
f"the PYTHONPATH environment variable depth does not "
|
|
112
|
+
f"exceed {MsCompareConst.MAX_RECURSION_DEPTH}.")
|
|
112
113
|
|
|
113
114
|
|
|
114
115
|
if not is_mindtorch():
|
|
@@ -96,7 +96,7 @@ class PrecisionDebugger(BasePrecisionDebugger):
|
|
|
96
96
|
_dump_set_dynamic()
|
|
97
97
|
|
|
98
98
|
@staticmethod
|
|
99
|
-
def
|
|
99
|
+
def _get_task_config(task, json_config):
|
|
100
100
|
return parse_task_config(task, json_config)
|
|
101
101
|
|
|
102
102
|
@staticmethod
|
|
@@ -129,7 +129,7 @@ class PrecisionDebugger(BasePrecisionDebugger):
|
|
|
129
129
|
|
|
130
130
|
@classmethod
|
|
131
131
|
def start(cls, model=None, token_range=None):
|
|
132
|
-
instance = cls.
|
|
132
|
+
instance = cls._get_instance()
|
|
133
133
|
if instance is None:
|
|
134
134
|
return
|
|
135
135
|
if cls._need_msprobe_c() and _msprobe_c:
|
|
@@ -158,7 +158,7 @@ class PrecisionDebugger(BasePrecisionDebugger):
|
|
|
158
158
|
|
|
159
159
|
@classmethod
|
|
160
160
|
def stop(cls):
|
|
161
|
-
instance = cls.
|
|
161
|
+
instance = cls._get_instance()
|
|
162
162
|
if instance is None:
|
|
163
163
|
return
|
|
164
164
|
|
|
@@ -175,7 +175,7 @@ class PrecisionDebugger(BasePrecisionDebugger):
|
|
|
175
175
|
|
|
176
176
|
@classmethod
|
|
177
177
|
def step(cls):
|
|
178
|
-
instance = cls.
|
|
178
|
+
instance = cls._get_instance()
|
|
179
179
|
if instance is None:
|
|
180
180
|
return
|
|
181
181
|
|
|
@@ -143,10 +143,10 @@ def cell_construct_wrapper(func, self):
|
|
|
143
143
|
if backward_or_all and ops.is_tensor(item):
|
|
144
144
|
if need_tensordump_in(self, 'input_dump_mode', index):
|
|
145
145
|
item = gd(gen_file_path(self.dump_path, self.cell_prefix, KEY_BACKWARD, KEY_OUTPUT, index),
|
|
146
|
-
item, "
|
|
146
|
+
item, "out")
|
|
147
147
|
else:
|
|
148
148
|
item = gd(gen_file_path(self.dump_path, self.cell_prefix, KEY_BACKWARD, KEY_OUTPUT, index),
|
|
149
|
-
item, "
|
|
149
|
+
item, "in")
|
|
150
150
|
if forward_or_all and ops.is_tensor(item):
|
|
151
151
|
if need_tensordump_in(self, 'input_dump_mode', index):
|
|
152
152
|
temp = td_in(
|
|
@@ -169,10 +169,10 @@ def cell_construct_wrapper(func, self):
|
|
|
169
169
|
if backward_or_all and ops.is_tensor(item):
|
|
170
170
|
if need_tensordump_in(self, 'output_dump_mode', index):
|
|
171
171
|
item = gd(gen_file_path(self.dump_path, self.cell_prefix, KEY_BACKWARD, KEY_INPUT, index),
|
|
172
|
-
item, "
|
|
172
|
+
item, "out")
|
|
173
173
|
else:
|
|
174
174
|
item = gd(gen_file_path(self.dump_path, self.cell_prefix, KEY_BACKWARD, KEY_INPUT, index),
|
|
175
|
-
item, "
|
|
175
|
+
item, "in")
|
|
176
176
|
if forward_or_all and ops.is_tensor(item):
|
|
177
177
|
if need_tensordump_in(self, 'output_dump_mode', index):
|
|
178
178
|
temp = td_in(
|
|
@@ -194,10 +194,10 @@ def cell_construct_wrapper(func, self):
|
|
|
194
194
|
if backward_or_all:
|
|
195
195
|
if need_tensordump_in(self, 'output_dump_mode', index):
|
|
196
196
|
out = gd(gen_file_path(self.dump_path, self.cell_prefix, KEY_BACKWARD, KEY_INPUT, 0),
|
|
197
|
-
out, "
|
|
197
|
+
out, "out")
|
|
198
198
|
else:
|
|
199
199
|
out = gd(gen_file_path(self.dump_path, self.cell_prefix, KEY_BACKWARD, KEY_INPUT, 0),
|
|
200
|
-
out, "
|
|
200
|
+
out, "in")
|
|
201
201
|
if forward_or_all and ops.is_tensor(out):
|
|
202
202
|
if need_tensordump_in(self, 'output_dump_mode', index):
|
|
203
203
|
temp = td_in(
|
|
@@ -223,34 +223,9 @@ def sort_filenames(path):
|
|
|
223
223
|
return filenames
|
|
224
224
|
|
|
225
225
|
|
|
226
|
-
# 删除重复dump的文件:自定义文件名相同,并且数据相同
|
|
227
|
-
def del_same_file(path, filenames):
|
|
228
|
-
result_list = []
|
|
229
|
-
seen_prefixes = {}
|
|
230
|
-
for current_filename in filenames:
|
|
231
|
-
parts = current_filename.rsplit(CoreConst.REPLACEMENT_CHARACTER, 1)
|
|
232
|
-
prefix = parts[0]
|
|
233
|
-
if prefix not in seen_prefixes:
|
|
234
|
-
result_list.append(current_filename)
|
|
235
|
-
seen_prefixes[prefix] = current_filename
|
|
236
|
-
else:
|
|
237
|
-
current_file_path = os.path.join(path, current_filename)
|
|
238
|
-
current_file = load_npy(current_file_path)
|
|
239
|
-
prev_filename = seen_prefixes[prefix]
|
|
240
|
-
prev_file_path = os.path.join(path, prev_filename)
|
|
241
|
-
prev_file = load_npy(prev_file_path)
|
|
242
|
-
if np.array_equal(current_file, prev_file):
|
|
243
|
-
remove_path(current_file_path)
|
|
244
|
-
logger.warning(f"{current_file_path} is deleted!")
|
|
245
|
-
else:
|
|
246
|
-
result_list.append(current_filename)
|
|
247
|
-
return result_list
|
|
248
|
-
|
|
249
|
-
|
|
250
226
|
def rename_filename(path="", data_df=None):
|
|
251
227
|
if dump_task == CoreConst.TENSOR:
|
|
252
228
|
filenames = sort_filenames(path)
|
|
253
|
-
filenames = del_same_file(path, filenames)
|
|
254
229
|
if dump_task == CoreConst.STATISTICS:
|
|
255
230
|
filenames = data_df[CoreConst.OP_NAME].tolist()
|
|
256
231
|
|
|
@@ -284,8 +259,8 @@ def rename_filename(path="", data_df=None):
|
|
|
284
259
|
|
|
285
260
|
|
|
286
261
|
# Extract the field between the first "." and the third to last ".", i.e. {cell_name}
|
|
287
|
-
def get_cell_name(
|
|
288
|
-
parts =
|
|
262
|
+
def get_cell_name(cell_str):
|
|
263
|
+
parts = cell_str.split(CoreConst.SEP)
|
|
289
264
|
if len(parts) < 4:
|
|
290
265
|
return None
|
|
291
266
|
start_index = 1
|
|
@@ -294,10 +269,10 @@ def get_cell_name(str):
|
|
|
294
269
|
|
|
295
270
|
|
|
296
271
|
# Extract the field between the last "." and the second to last ".", i.e. {data_made}
|
|
297
|
-
def get_data_mode(
|
|
298
|
-
last_dot_index =
|
|
299
|
-
second_last_dot_index =
|
|
300
|
-
data_mode =
|
|
272
|
+
def get_data_mode(cell_str):
|
|
273
|
+
last_dot_index = cell_str.rfind(CoreConst.SEP)
|
|
274
|
+
second_last_dot_index = cell_str.rfind(CoreConst.SEP, 0, last_dot_index)
|
|
275
|
+
data_mode = cell_str[second_last_dot_index + 1:last_dot_index]
|
|
301
276
|
return data_mode
|
|
302
277
|
|
|
303
278
|
|
|
@@ -804,7 +779,7 @@ def create_kbyk_json(dump_path, summary_mode, step):
|
|
|
804
779
|
rank_id = os.environ.get('RANK_ID')
|
|
805
780
|
if rank_id is None:
|
|
806
781
|
rank_id = 0
|
|
807
|
-
config_json_path = os.path.join(dump_path, rank_id + "kernel_kbyk_dump.json")
|
|
782
|
+
config_json_path = os.path.join(dump_path, str(rank_id) + "kernel_kbyk_dump.json")
|
|
808
783
|
save_json(config_json_path, config_json, indent=4)
|
|
809
784
|
logger.info(config_json_path + " has been created.")
|
|
810
785
|
return config_json_path
|
|
@@ -201,34 +201,9 @@ def sort_filenames(path):
|
|
|
201
201
|
return filenames
|
|
202
202
|
|
|
203
203
|
|
|
204
|
-
# 删除重复dump的文件:自定义文件名相同,并且数据相同
|
|
205
|
-
def del_same_file(path, filenames):
|
|
206
|
-
result_list = []
|
|
207
|
-
seen_prefixes = {}
|
|
208
|
-
for current_filename in filenames:
|
|
209
|
-
parts = current_filename.rsplit(CoreConst.REPLACEMENT_CHARACTER, 1)
|
|
210
|
-
prefix = parts[0]
|
|
211
|
-
if prefix not in seen_prefixes:
|
|
212
|
-
result_list.append(current_filename)
|
|
213
|
-
seen_prefixes[prefix] = current_filename
|
|
214
|
-
else:
|
|
215
|
-
current_file_path = os.path.join(path, current_filename)
|
|
216
|
-
current_file = load_npy(current_file_path)
|
|
217
|
-
prev_filename = seen_prefixes[prefix]
|
|
218
|
-
prev_file_path = os.path.join(path, prev_filename)
|
|
219
|
-
prev_file = load_npy(prev_file_path)
|
|
220
|
-
if np.array_equal(current_file, prev_file):
|
|
221
|
-
remove_path(current_file_path)
|
|
222
|
-
logger.warning(f"{current_file_path} is deleted!")
|
|
223
|
-
else:
|
|
224
|
-
result_list.append(current_filename)
|
|
225
|
-
return result_list
|
|
226
|
-
|
|
227
|
-
|
|
228
204
|
def rename_filename(path="", data_df=None):
|
|
229
205
|
if dump_task == CoreConst.TENSOR:
|
|
230
206
|
filenames = sort_filenames(path)
|
|
231
|
-
filenames = del_same_file(path, filenames)
|
|
232
207
|
if dump_task == CoreConst.STATISTICS:
|
|
233
208
|
filenames = data_df[CoreConst.OP_NAME].tolist()
|
|
234
209
|
|
|
@@ -781,7 +756,7 @@ def create_kbyk_json(dump_path, summary_mode, step):
|
|
|
781
756
|
rank_id = os.environ.get('RANK_ID')
|
|
782
757
|
if rank_id is None:
|
|
783
758
|
rank_id = 0
|
|
784
|
-
config_json_path = os.path.join(dump_path, rank_id + "kernel_kbyk_dump.json")
|
|
759
|
+
config_json_path = os.path.join(dump_path, str(rank_id) + "kernel_kbyk_dump.json")
|
|
785
760
|
save_json(config_json_path, config_json, indent=4)
|
|
786
761
|
logger.info(config_json_path + " has been created.")
|
|
787
762
|
return config_json_path
|
|
@@ -118,12 +118,12 @@ class ApiTemplate(HOOKCell):
|
|
|
118
118
|
try:
|
|
119
119
|
bound = inspect.signature(self.api_func).bind(*args, **kwargs)
|
|
120
120
|
bound.apply_defaults()
|
|
121
|
-
|
|
121
|
+
use_async_op_flag = bound.arguments.get("async_op", False)
|
|
122
122
|
except Exception as e:
|
|
123
|
-
|
|
123
|
+
use_async_op_flag = False
|
|
124
124
|
logger.warning(f"fail to get dist api's func signature because {e}, no wait")
|
|
125
125
|
|
|
126
|
-
if
|
|
126
|
+
if use_async_op_flag or self.api_name in ["isend", "irecv"]:
|
|
127
127
|
output = self.async_to_sync(output)
|
|
128
128
|
if self.api_name == "batch_isend_irecv" and isinstance(output, list):
|
|
129
129
|
output = [self.async_to_sync(handle) for handle in output]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
* Copyright 2024 Huawei Technologies Co., Ltd
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2024-2025. Huawei Technologies Co., Ltd. All rights reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -39,7 +39,7 @@ bool HookDynamicLoader::LoadFunction(void *handle, const std::string &functionNa
|
|
|
39
39
|
return true;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
bool HookDynamicLoader::LoadLibrary()
|
|
42
|
+
bool HookDynamicLoader::LoadLibrary()
|
|
43
43
|
{
|
|
44
44
|
std::string msprobePath = "";
|
|
45
45
|
// 获取gil锁
|
|
@@ -98,7 +98,7 @@ bool HookDynamicLoader::UnloadLibrary()
|
|
|
98
98
|
return true;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
void *HookDynamicLoader::GetHooker(const std::string &funcName)
|
|
101
|
+
void *HookDynamicLoader::GetHooker(const std::string &funcName)
|
|
102
102
|
{
|
|
103
103
|
std::lock_guard<std::mutex> lock(mutex_);
|
|
104
104
|
auto iter = funcMap_.find(funcName);
|
|
@@ -64,12 +64,13 @@ def get_dtype(t):
|
|
|
64
64
|
return t.dtype
|
|
65
65
|
|
|
66
66
|
|
|
67
|
-
FUNC_MAP = {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
FUNC_MAP = {
|
|
68
|
+
"min": get_min,
|
|
69
|
+
"max": get_max,
|
|
70
|
+
"mean": get_mean,
|
|
71
|
+
"norm": get_norm,
|
|
72
|
+
"nans": get_nans,
|
|
73
|
+
"zeros": get_zeros,
|
|
74
|
+
"shape": get_shape,
|
|
75
|
+
"dtype": get_dtype
|
|
76
|
+
}
|
|
@@ -105,6 +105,9 @@ class OptimizerMon(object):
|
|
|
105
105
|
else:
|
|
106
106
|
logger.warning(f"step of {name} is None, maybe something wrong happened.")
|
|
107
107
|
continue
|
|
108
|
+
if exp_avg is None or exp_avg_sq is None:
|
|
109
|
+
logger.warning(f"exp_avg or exp_avg_sq of {name} is None, skip calculation.")
|
|
110
|
+
continue
|
|
108
111
|
exp_avg_hat = exp_avg / (1 - self.optim.defaults['betas'][0] ** step)
|
|
109
112
|
exp_avg_sq_hat = exp_avg_sq / (1 - self.optim.defaults['betas'][1] ** step)
|
|
110
113
|
update_dict[name] = exp_avg_hat / (mint.sqrt(exp_avg_sq_hat) + self.optim.defaults['eps'])
|
|
@@ -292,7 +295,7 @@ class DeepSpeedZeroOptimizerStage3Mon(DeepSpeedZeroOptimizerMon):
|
|
|
292
295
|
self.fp32_flat_groups = optim.fp32_partitioned_groups_flat
|
|
293
296
|
self.param2group = self.get_group_index()
|
|
294
297
|
|
|
295
|
-
def param_not_in_partition(self,
|
|
298
|
+
def param_not_in_partition(self, lp_param, group_idx):
|
|
296
299
|
"""Each param partioned across all zero ranks"""
|
|
297
300
|
return False
|
|
298
301
|
|
|
@@ -73,27 +73,27 @@ DETAIL_TEST_ROWS = [
|
|
|
73
73
|
|
|
74
74
|
|
|
75
75
|
precision_configs = {
|
|
76
|
-
torch.float16
|
|
77
|
-
'small_value'
|
|
76
|
+
torch.float16: {
|
|
77
|
+
'small_value': [
|
|
78
78
|
1e-3
|
|
79
79
|
],
|
|
80
|
-
'small_value_atol'
|
|
80
|
+
'small_value_atol': [
|
|
81
81
|
1e-5
|
|
82
82
|
]
|
|
83
83
|
},
|
|
84
84
|
torch.bfloat16: {
|
|
85
|
-
'small_value'
|
|
85
|
+
'small_value': [
|
|
86
86
|
1e-3
|
|
87
87
|
],
|
|
88
|
-
'small_value_atol'
|
|
88
|
+
'small_value_atol': [
|
|
89
89
|
1e-5
|
|
90
90
|
]
|
|
91
91
|
},
|
|
92
|
-
torch.float32:{
|
|
93
|
-
'small_value'
|
|
92
|
+
torch.float32: {
|
|
93
|
+
'small_value': [
|
|
94
94
|
1e-6
|
|
95
95
|
],
|
|
96
|
-
'small_value_atol'
|
|
96
|
+
'small_value_atol': [
|
|
97
97
|
1e-9
|
|
98
98
|
]
|
|
99
99
|
}
|
|
@@ -101,33 +101,33 @@ precision_configs = {
|
|
|
101
101
|
|
|
102
102
|
|
|
103
103
|
ULP_PARAMETERS = {
|
|
104
|
-
torch.float16
|
|
105
|
-
'min_eb'
|
|
104
|
+
torch.float16: {
|
|
105
|
+
'min_eb': [
|
|
106
106
|
-14
|
|
107
107
|
],
|
|
108
|
-
'exponent_num'
|
|
108
|
+
'exponent_num': [
|
|
109
109
|
10
|
|
110
110
|
]
|
|
111
111
|
},
|
|
112
|
-
torch.bfloat16
|
|
113
|
-
'min_eb'
|
|
112
|
+
torch.bfloat16: {
|
|
113
|
+
'min_eb': [
|
|
114
114
|
-126
|
|
115
115
|
],
|
|
116
|
-
'exponent_num'
|
|
116
|
+
'exponent_num': [
|
|
117
117
|
7
|
|
118
118
|
]
|
|
119
119
|
},
|
|
120
|
-
torch.float32
|
|
121
|
-
'min_eb'
|
|
120
|
+
torch.float32: {
|
|
121
|
+
'min_eb': [
|
|
122
122
|
-126
|
|
123
123
|
],
|
|
124
|
-
'exponent_num'
|
|
124
|
+
'exponent_num': [
|
|
125
125
|
23
|
|
126
126
|
]
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
|
|
130
|
+
|
|
131
131
|
class ApiPrecisionCompareColumn:
|
|
132
132
|
API_NAME = 'API Name'
|
|
133
133
|
DEVICE_DTYPE = 'DEVICE Dtype'
|
|
@@ -202,7 +202,7 @@ class ApiPrecisionCompareColumn:
|
|
|
202
202
|
|
|
203
203
|
|
|
204
204
|
CompareMessage = {
|
|
205
|
-
"topk"
|
|
205
|
+
"topk": "在npu上,topk的入参sorted=False时不生效,会返回有序tensor,而cpu上会返回无序tensor。 如果topk精度不达标,请检查是否是该原因导致的。"
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
|