mindstudio-probe 1.0.4__py3-none-any.whl → 1.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.
Files changed (278) hide show
  1. {mindstudio_probe-1.0.4.dist-info → mindstudio_probe-1.1.1.dist-info}/METADATA +5 -5
  2. mindstudio_probe-1.1.1.dist-info/RECORD +341 -0
  3. {mindstudio_probe-1.0.4.dist-info → mindstudio_probe-1.1.1.dist-info}/WHEEL +1 -1
  4. {mindstudio_probe-1.0.4.dist-info → mindstudio_probe-1.1.1.dist-info}/entry_points.txt +0 -1
  5. msprobe/README.md +84 -18
  6. msprobe/__init__.py +16 -1
  7. msprobe/config.json +1 -5
  8. msprobe/core/advisor/advisor.py +16 -11
  9. msprobe/core/advisor/advisor_const.py +6 -7
  10. msprobe/core/advisor/advisor_result.py +12 -12
  11. msprobe/core/common/const.py +164 -3
  12. msprobe/core/common/exceptions.py +26 -4
  13. msprobe/core/common/file_utils.py +196 -27
  14. msprobe/core/common/inplace_op_checker.py +53 -0
  15. msprobe/core/common/inplace_ops.yaml +251 -0
  16. msprobe/core/common/log.py +46 -18
  17. msprobe/core/common/utils.py +308 -209
  18. msprobe/core/common_config.py +60 -38
  19. msprobe/core/compare/acc_compare.py +332 -94
  20. msprobe/core/compare/check.py +104 -22
  21. msprobe/core/compare/compare_cli.py +42 -5
  22. msprobe/core/compare/highlight.py +162 -57
  23. msprobe/core/compare/layer_mapping/__init__.py +19 -0
  24. msprobe/core/compare/layer_mapping/data_scope_parser.py +235 -0
  25. msprobe/core/compare/layer_mapping/layer_mapping.py +242 -0
  26. msprobe/core/compare/layer_mapping/postprocess_pass.py +94 -0
  27. msprobe/core/compare/multiprocessing_compute.py +33 -8
  28. msprobe/core/compare/npy_compare.py +73 -29
  29. msprobe/core/compare/utils.py +306 -247
  30. msprobe/core/data_dump/data_collector.py +44 -43
  31. msprobe/core/data_dump/data_processor/base.py +88 -35
  32. msprobe/core/data_dump/data_processor/factory.py +20 -3
  33. msprobe/core/data_dump/data_processor/mindspore_processor.py +14 -8
  34. msprobe/core/data_dump/data_processor/pytorch_processor.py +180 -66
  35. msprobe/core/data_dump/json_writer.py +63 -42
  36. msprobe/core/data_dump/scope.py +143 -48
  37. msprobe/core/grad_probe/constant.py +31 -13
  38. msprobe/core/grad_probe/grad_compare.py +20 -4
  39. msprobe/core/grad_probe/utils.py +44 -3
  40. msprobe/core/overflow_check/abnormal_scene.py +185 -0
  41. msprobe/core/overflow_check/api_info.py +55 -0
  42. msprobe/core/overflow_check/checker.py +138 -0
  43. msprobe/core/overflow_check/filter.py +157 -0
  44. msprobe/core/overflow_check/ignore_rules.yaml +55 -0
  45. msprobe/core/overflow_check/level.py +22 -0
  46. msprobe/core/overflow_check/utils.py +28 -0
  47. msprobe/docs/01.installation.md +29 -9
  48. msprobe/docs/02.config_introduction.md +83 -84
  49. msprobe/docs/03.config_examples.md +3 -20
  50. msprobe/docs/04.kernel_dump_PyTorch.md +73 -0
  51. msprobe/docs/05.data_dump_PyTorch.md +143 -13
  52. msprobe/docs/06.data_dump_MindSpore.md +197 -88
  53. msprobe/docs/07.accuracy_checker_PyTorch.md +69 -46
  54. msprobe/docs/08.accuracy_checker_online_PyTorch.md +52 -17
  55. msprobe/docs/09.accuracy_checker_MindSpore.md +51 -15
  56. msprobe/docs/10.accuracy_compare_PyTorch.md +187 -99
  57. msprobe/docs/11.accuracy_compare_MindSpore.md +253 -31
  58. msprobe/docs/12.overflow_check_PyTorch.md +1 -1
  59. msprobe/docs/13.overflow_check_MindSpore.md +6 -6
  60. msprobe/docs/15.free_benchmarking_PyTorch.md +60 -55
  61. msprobe/docs/16.free_benchmarking_MindSpore.md +159 -0
  62. msprobe/docs/17.grad_probe.md +19 -22
  63. msprobe/docs/18.online_dispatch.md +89 -0
  64. msprobe/docs/19.monitor.md +468 -0
  65. msprobe/docs/20.monitor_performance_baseline.md +52 -0
  66. msprobe/docs/21.visualization_PyTorch.md +386 -0
  67. msprobe/docs/22.visualization_MindSpore.md +384 -0
  68. msprobe/docs/23.tool_function_introduction.md +28 -0
  69. msprobe/docs/{FAQ_PyTorch.md → FAQ.md} +25 -10
  70. msprobe/docs/data_dump_Mindspore/dynamic_graph_quick_start_example.md +211 -0
  71. msprobe/docs/img/compare_result.png +0 -0
  72. msprobe/docs/img/monitor/cpu_info.png +0 -0
  73. msprobe/docs/img/ms_dump.png +0 -0
  74. msprobe/docs/img/ms_layer.png +0 -0
  75. msprobe/docs/img/pt_dump.png +0 -0
  76. msprobe/mindspore/__init__.py +16 -0
  77. msprobe/mindspore/api_accuracy_checker/api_accuracy_checker.py +130 -138
  78. msprobe/mindspore/api_accuracy_checker/api_info.py +27 -5
  79. msprobe/mindspore/api_accuracy_checker/api_runner.py +43 -18
  80. msprobe/mindspore/api_accuracy_checker/base_compare_algorithm.py +21 -7
  81. msprobe/mindspore/api_accuracy_checker/checker_support_api.yaml +77 -0
  82. msprobe/mindspore/api_accuracy_checker/cmd_parser.py +63 -1
  83. msprobe/mindspore/api_accuracy_checker/compute_element.py +59 -24
  84. msprobe/mindspore/api_accuracy_checker/data_manager.py +264 -0
  85. msprobe/mindspore/api_accuracy_checker/main.py +27 -3
  86. msprobe/mindspore/api_accuracy_checker/multi_api_accuracy_checker.py +206 -0
  87. msprobe/mindspore/api_accuracy_checker/multi_data_manager.py +58 -0
  88. msprobe/mindspore/api_accuracy_checker/type_mapping.py +22 -5
  89. msprobe/mindspore/api_accuracy_checker/utils.py +34 -17
  90. msprobe/mindspore/cell_processor.py +58 -13
  91. msprobe/mindspore/common/const.py +35 -13
  92. msprobe/mindspore/common/log.py +5 -9
  93. msprobe/mindspore/common/utils.py +60 -5
  94. msprobe/mindspore/compare/distributed_compare.py +15 -28
  95. msprobe/mindspore/compare/ms_compare.py +319 -158
  96. msprobe/mindspore/compare/ms_graph_compare.py +99 -49
  97. msprobe/mindspore/debugger/debugger_config.py +20 -14
  98. msprobe/mindspore/debugger/precision_debugger.py +43 -13
  99. msprobe/mindspore/dump/dump_tool_factory.py +18 -1
  100. msprobe/mindspore/dump/hook_cell/api_registry.py +23 -3
  101. msprobe/mindspore/dump/hook_cell/primitive_hooks.py +203 -0
  102. msprobe/mindspore/dump/hook_cell/support_wrap_ops.yaml +107 -10
  103. msprobe/mindspore/dump/hook_cell/wrap_api.py +21 -13
  104. msprobe/mindspore/dump/jit_dump.py +56 -20
  105. msprobe/mindspore/dump/kernel_graph_dump.py +19 -5
  106. msprobe/mindspore/dump/kernel_kbyk_dump.py +19 -6
  107. msprobe/mindspore/dym_loader/hook_dynamic_loader.cc +140 -0
  108. msprobe/mindspore/dym_loader/hook_dynamic_loader.h +53 -0
  109. msprobe/mindspore/free_benchmark/api_pynative_self_check.py +162 -41
  110. msprobe/mindspore/free_benchmark/common/config.py +15 -0
  111. msprobe/mindspore/free_benchmark/common/handler_params.py +15 -1
  112. msprobe/mindspore/free_benchmark/common/utils.py +37 -8
  113. msprobe/mindspore/free_benchmark/data/support_wrap_ops.yaml +0 -204
  114. msprobe/mindspore/free_benchmark/handler/base_handler.py +20 -5
  115. msprobe/mindspore/free_benchmark/handler/check_handler.py +21 -7
  116. msprobe/mindspore/free_benchmark/handler/fix_handler.py +18 -3
  117. msprobe/mindspore/free_benchmark/handler/handler_factory.py +21 -6
  118. msprobe/mindspore/free_benchmark/perturbation/add_noise.py +23 -8
  119. msprobe/mindspore/free_benchmark/perturbation/base_perturbation.py +29 -5
  120. msprobe/mindspore/free_benchmark/perturbation/bit_noise.py +25 -10
  121. msprobe/mindspore/free_benchmark/perturbation/exchange_value.py +45 -19
  122. msprobe/mindspore/free_benchmark/perturbation/improve_precision.py +29 -8
  123. msprobe/mindspore/free_benchmark/perturbation/no_change.py +16 -1
  124. msprobe/mindspore/free_benchmark/perturbation/perturbation_factory.py +22 -7
  125. msprobe/mindspore/free_benchmark/self_check_tool_factory.py +17 -2
  126. msprobe/mindspore/grad_probe/global_context.py +44 -14
  127. msprobe/mindspore/grad_probe/grad_analyzer.py +27 -13
  128. msprobe/mindspore/grad_probe/grad_monitor.py +16 -1
  129. msprobe/mindspore/grad_probe/grad_stat_csv.py +33 -5
  130. msprobe/mindspore/grad_probe/hook.py +24 -10
  131. msprobe/mindspore/grad_probe/utils.py +18 -5
  132. msprobe/mindspore/ms_config.py +22 -15
  133. msprobe/mindspore/overflow_check/kernel_graph_overflow_check.py +20 -6
  134. msprobe/mindspore/overflow_check/overflow_check_tool_factory.py +15 -0
  135. msprobe/mindspore/runtime.py +15 -0
  136. msprobe/mindspore/service.py +75 -150
  137. msprobe/mindspore/task_handler_factory.py +15 -0
  138. msprobe/msprobe.py +24 -7
  139. msprobe/pytorch/__init__.py +23 -3
  140. msprobe/pytorch/api_accuracy_checker/common/config.py +81 -2
  141. msprobe/pytorch/api_accuracy_checker/common/utils.py +53 -21
  142. msprobe/pytorch/api_accuracy_checker/compare/algorithm.py +19 -2
  143. msprobe/pytorch/api_accuracy_checker/compare/api_precision_compare.py +50 -25
  144. msprobe/pytorch/api_accuracy_checker/compare/compare.py +51 -21
  145. msprobe/pytorch/api_accuracy_checker/compare/compare_column.py +23 -6
  146. msprobe/pytorch/api_accuracy_checker/compare/compare_utils.py +28 -8
  147. msprobe/pytorch/api_accuracy_checker/config.yaml +1 -1
  148. msprobe/pytorch/api_accuracy_checker/generate_op_script/config_op.json +9 -0
  149. msprobe/pytorch/api_accuracy_checker/generate_op_script/op_generator.py +454 -0
  150. msprobe/pytorch/api_accuracy_checker/generate_op_script/operator_replication.template +365 -0
  151. msprobe/pytorch/api_accuracy_checker/run_ut/data_generate.py +73 -33
  152. msprobe/pytorch/api_accuracy_checker/run_ut/multi_run_ut.py +44 -18
  153. msprobe/pytorch/api_accuracy_checker/run_ut/run_overflow_check.py +32 -11
  154. msprobe/pytorch/api_accuracy_checker/run_ut/run_ut.py +122 -172
  155. msprobe/pytorch/api_accuracy_checker/run_ut/run_ut_utils.py +158 -4
  156. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/attl.py +30 -24
  157. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/client.py +68 -31
  158. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/device_dispatch.py +27 -4
  159. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/dump_dispatch.py +115 -0
  160. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/server.py +26 -9
  161. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/torch_ops_config.yaml +63 -0
  162. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/utils.py +44 -0
  163. msprobe/pytorch/bench_functions/__init__.py +18 -3
  164. msprobe/pytorch/bench_functions/apply_adam_w.py +15 -0
  165. msprobe/pytorch/bench_functions/confusion_transpose.py +20 -1
  166. msprobe/pytorch/bench_functions/fast_gelu.py +15 -0
  167. msprobe/pytorch/bench_functions/layer_norm_eval.py +15 -0
  168. msprobe/pytorch/bench_functions/linear.py +15 -0
  169. msprobe/pytorch/bench_functions/matmul_backward.py +33 -6
  170. msprobe/pytorch/bench_functions/npu_fusion_attention.py +280 -157
  171. msprobe/pytorch/bench_functions/rms_norm.py +15 -0
  172. msprobe/pytorch/bench_functions/rotary_mul.py +32 -9
  173. msprobe/pytorch/bench_functions/scaled_mask_softmax.py +15 -0
  174. msprobe/pytorch/bench_functions/swiglu.py +29 -6
  175. msprobe/pytorch/common/__init__.py +15 -0
  176. msprobe/pytorch/common/log.py +18 -6
  177. msprobe/pytorch/common/parse_json.py +31 -16
  178. msprobe/pytorch/common/utils.py +96 -40
  179. msprobe/pytorch/compare/distributed_compare.py +13 -14
  180. msprobe/pytorch/compare/match.py +15 -0
  181. msprobe/pytorch/compare/pt_compare.py +44 -10
  182. msprobe/pytorch/debugger/debugger_config.py +69 -52
  183. msprobe/pytorch/debugger/precision_debugger.py +72 -24
  184. msprobe/pytorch/dump/kernel_dump/kernel_config.py +33 -0
  185. msprobe/pytorch/free_benchmark/__init__.py +20 -5
  186. msprobe/pytorch/free_benchmark/common/constant.py +15 -0
  187. msprobe/pytorch/free_benchmark/common/counter.py +15 -0
  188. msprobe/pytorch/free_benchmark/common/enums.py +43 -0
  189. msprobe/pytorch/free_benchmark/common/params.py +23 -1
  190. msprobe/pytorch/free_benchmark/common/utils.py +43 -5
  191. msprobe/pytorch/free_benchmark/compare/grad_saver.py +47 -9
  192. msprobe/pytorch/free_benchmark/compare/single_benchmark.py +17 -0
  193. msprobe/pytorch/free_benchmark/main.py +19 -4
  194. msprobe/pytorch/free_benchmark/perturbed_layers/base_layer.py +15 -0
  195. msprobe/pytorch/free_benchmark/perturbed_layers/layer_factory.py +19 -4
  196. msprobe/pytorch/free_benchmark/perturbed_layers/npu/add_noise.py +18 -1
  197. msprobe/pytorch/free_benchmark/perturbed_layers/npu/bit_noise.py +21 -4
  198. msprobe/pytorch/free_benchmark/perturbed_layers/npu/change_value.py +28 -2
  199. msprobe/pytorch/free_benchmark/perturbed_layers/npu/improve_precision.py +19 -0
  200. msprobe/pytorch/free_benchmark/perturbed_layers/npu/no_change.py +15 -0
  201. msprobe/pytorch/free_benchmark/perturbed_layers/npu/npu_base_layser.py +15 -0
  202. msprobe/pytorch/free_benchmark/perturbed_layers/run_cpu.py +15 -0
  203. msprobe/pytorch/free_benchmark/result_handlers/base_handler.py +65 -16
  204. msprobe/pytorch/free_benchmark/result_handlers/check_handler.py +15 -0
  205. msprobe/pytorch/free_benchmark/result_handlers/fix_handler.py +21 -5
  206. msprobe/pytorch/free_benchmark/result_handlers/handler_factory.py +15 -0
  207. msprobe/pytorch/free_benchmark/result_handlers/preheat_handler.py +19 -4
  208. msprobe/pytorch/function_factory.py +17 -2
  209. msprobe/pytorch/functional/module_dump.py +84 -0
  210. msprobe/pytorch/grad_probe/grad_monitor.py +23 -6
  211. msprobe/pytorch/grad_probe/grad_stat_csv.py +40 -10
  212. msprobe/pytorch/hook_module/__init__.py +16 -1
  213. msprobe/pytorch/hook_module/api_registry.py +13 -8
  214. msprobe/pytorch/hook_module/hook_module.py +17 -19
  215. msprobe/pytorch/hook_module/support_wrap_ops.yaml +1 -0
  216. msprobe/pytorch/hook_module/utils.py +4 -6
  217. msprobe/pytorch/hook_module/wrap_aten.py +12 -11
  218. msprobe/pytorch/hook_module/wrap_distributed.py +6 -7
  219. msprobe/pytorch/hook_module/wrap_functional.py +21 -20
  220. msprobe/pytorch/hook_module/wrap_npu_custom.py +9 -17
  221. msprobe/pytorch/hook_module/wrap_tensor.py +4 -6
  222. msprobe/pytorch/hook_module/wrap_torch.py +4 -6
  223. msprobe/pytorch/hook_module/wrap_vf.py +4 -6
  224. msprobe/pytorch/module_processer.py +18 -6
  225. msprobe/pytorch/monitor/anomaly_analyse.py +201 -0
  226. msprobe/pytorch/monitor/anomaly_detect.py +340 -0
  227. msprobe/pytorch/monitor/distributed/distributed_ops.yaml +19 -0
  228. msprobe/pytorch/monitor/distributed/stack_blacklist.yaml +5 -0
  229. msprobe/pytorch/monitor/distributed/wrap_distributed.py +272 -0
  230. msprobe/pytorch/monitor/features.py +108 -0
  231. msprobe/pytorch/monitor/module_hook.py +870 -0
  232. msprobe/pytorch/monitor/module_metric.py +193 -0
  233. msprobe/pytorch/monitor/module_spec_verifier.py +93 -0
  234. msprobe/pytorch/monitor/optimizer_collect.py +295 -0
  235. msprobe/pytorch/monitor/unittest/__init__.py +0 -0
  236. msprobe/pytorch/monitor/unittest/test_monitor.py +145 -0
  237. msprobe/pytorch/monitor/utils.py +250 -0
  238. msprobe/pytorch/monitor/visualizer.py +59 -0
  239. msprobe/pytorch/online_dispatch/__init__.py +2 -3
  240. msprobe/pytorch/online_dispatch/compare.py +38 -48
  241. msprobe/pytorch/online_dispatch/dispatch.py +50 -25
  242. msprobe/pytorch/online_dispatch/dump_compare.py +21 -9
  243. msprobe/pytorch/online_dispatch/single_compare.py +60 -39
  244. msprobe/pytorch/online_dispatch/torch_ops_config.yaml +9 -1
  245. msprobe/pytorch/online_dispatch/utils.py +48 -23
  246. msprobe/pytorch/parse.py +15 -0
  247. msprobe/pytorch/parse_tool/cli.py +5 -6
  248. msprobe/pytorch/parse_tool/lib/compare.py +19 -26
  249. msprobe/pytorch/parse_tool/lib/config.py +1 -1
  250. msprobe/pytorch/parse_tool/lib/parse_tool.py +4 -2
  251. msprobe/pytorch/parse_tool/lib/utils.py +40 -55
  252. msprobe/pytorch/parse_tool/lib/visualization.py +3 -1
  253. msprobe/pytorch/pt_config.py +192 -40
  254. msprobe/pytorch/service.py +110 -35
  255. msprobe/visualization/__init__.py +14 -0
  256. msprobe/visualization/builder/__init__.py +14 -0
  257. msprobe/visualization/builder/graph_builder.py +165 -0
  258. msprobe/visualization/builder/msprobe_adapter.py +205 -0
  259. msprobe/visualization/compare/__init__.py +14 -0
  260. msprobe/visualization/compare/graph_comparator.py +130 -0
  261. msprobe/visualization/compare/mode_adapter.py +211 -0
  262. msprobe/visualization/graph/__init__.py +14 -0
  263. msprobe/visualization/graph/base_node.py +124 -0
  264. msprobe/visualization/graph/graph.py +200 -0
  265. msprobe/visualization/graph/node_colors.py +95 -0
  266. msprobe/visualization/graph/node_op.py +39 -0
  267. msprobe/visualization/graph_service.py +214 -0
  268. msprobe/visualization/utils.py +232 -0
  269. mindstudio_probe-1.0.4.dist-info/RECORD +0 -276
  270. msprobe/docs/04.acl_config_examples.md +0 -76
  271. msprobe/mindspore/free_benchmark/decorator/dec_forward.py +0 -43
  272. msprobe/mindspore/free_benchmark/decorator/decorator_factory.py +0 -107
  273. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/ssl_config.py +0 -10
  274. msprobe/pytorch/functional/dump_module.py +0 -39
  275. {mindstudio_probe-1.0.4.dist-info → mindstudio_probe-1.1.1.dist-info}/LICENSE +0 -0
  276. {mindstudio_probe-1.0.4.dist-info → mindstudio_probe-1.1.1.dist-info}/top_level.txt +0 -0
  277. /msprobe/{mindspore/free_benchmark/decorator → pytorch/monitor}/__init__.py +0 -0
  278. /msprobe/pytorch/{functional/data_processor.py → monitor/distributed/__init__.py} +0 -0
@@ -0,0 +1,386 @@
1
+ # PyTorch 场景的分级可视化构图比对
2
+
3
+ 分级可视化工具将msprobe工具dump的精度数据进行解析,还原模型图结构,实现模型各个层级的精度数据比对,方便用户理解模型结构、分析精度问题。
4
+
5
+ 工具支持PyTorch版本:2.1/2.2
6
+
7
+ ## 1.依赖安装
8
+
9
+ 分级可视化工具依赖**msprobe工具**和**tensorboard。**
10
+
11
+ ### 1.1 安装msprobe工具
12
+
13
+ 现阶段分级可视化工具还未集成在已发布的msprobe工具中,需要从源码安装,请参考从源码安装章节。
14
+
15
+ [msprobe工具安装](https://gitee.com/ascend/mstt/blob/master/debug/accuracy_tools/msprobe/docs/01.installation.md)
16
+
17
+ ### 1.2 安装tb_graph_ascend
18
+
19
+ **请安装tb_graph_ascend,否则无法解析构图结果。**
20
+
21
+ [tb_graph_ascend下载](https://mindstudio-sample.obs.cn-north-4.myhuaweicloud.com/GRAPH_ASCEND/tb_graph_ascend-0.1.0-py3-none-any.whl)
22
+
23
+ ``pip3 install``即可。
24
+
25
+ ## 2.模型结构数据采集
26
+ [PyTorch场景的数据采集](https://gitee.com/ascend/mstt/blob/master/debug/accuracy_tools/msprobe/docs/05.data_dump_PyTorch.md)
27
+
28
+ **需要选择level为L0(module信息)或者mix(module信息+api信息),才能采集到模型结构数据,即采集结果件construct.json内容不为空**。
29
+
30
+ ## 3.生成图结构文件
31
+
32
+ ### 3.1 构图命令行说明
33
+
34
+ **命令示例如下**:
35
+ ```
36
+ msprobe -f pytorch graph -i ./compare.json -o ./output
37
+ ```
38
+ **命令行参数说明**:
39
+
40
+ | 参数名 | 说明 | 是否必选 |
41
+ |------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------|
42
+ | -i 或 --input_path | 指定比对文件,str 类型。 | 是 |
43
+ | -o 或 --output_path | 配置比对结果文件存盘目录,str 类型。文件名称基于时间戳自动生成,格式为:`compare_{timestamp}.vis`。 | 是 |
44
+ | -lm 或 --layer_mapping | 跨套件比对,例如同一个模型分别使用了DeepSpeed和Megatron套件的比对场景。配置该参数时表示开启跨套件Layer层的比对功能,指定模型代码中的Layer层后,可以识别对应dump数据中的模块或API。需要指定自定义映射文件*.yaml。自定义映射文件的格式请参见[自定义映射文件(Layer)](#71-自定义映射文件layer)。 | 否 |
45
+ | -oc 或 --overflow_check | 是否开启溢出检测模式,开启后会在输出vis文件中(`compare_{timestamp}.vis`)对每个溢出节点进行标记溢出等级,溢出等级说明参考如下 | 否 |
46
+
47
+ **溢出等级说明**
48
+ - medium:输入异常,输出正常场景
49
+ - high:输入异常,输出异常;输出norm值相较于输入存在异常增大情况
50
+ - critical:输入正常,输出异常场景
51
+
52
+ **比对文件说明**:
53
+ 以在当前目录创建 ./compare.json 为例。
54
+ ```
55
+ {
56
+ "npu_path": "./npu_dump",
57
+ "bench_path": "./bench_dump",
58
+ "is_print_compare_log": true
59
+ }
60
+ ```
61
+ **比对文件参数说明**:
62
+
63
+ | 参数名 | 说明 | 是否必选 |
64
+ |-------------------|----------------------------------------------------------------------------|------|
65
+ | npu_path | 指定待调试侧比对路径,str类型。工具根据路径格式自动进行单rank比对、多rank批量比对或多step批量比对,具体格式参考3.2 图构建和比对。 | 是 |
66
+ | bench_path | 指定标杆侧比对路径,str类型。单图构建场景可以不配置。 | 否 |
67
+ | is_print_compare_log | 配置是否开启单个算子的日志打屏。可取值 true 或 false,默认为 true。关闭后则只输出常规日志,bool 类型。 | 否 |
68
+
69
+
70
+ ### 3.2 图构建和比对
71
+
72
+ **如果只是想查看一个模型的结构,请选择单图构建**;
73
+ **如果想比较两个模型的结构差异和精度数据差异,请选择双图比对**。
74
+
75
+ #### 3.2.1 单图构建
76
+
77
+ 展示模型结构、精度数据、堆栈信息。
78
+
79
+ **1. 准备比对文件**:
80
+
81
+ 以在当前目录创建 ./compare.json 为例。
82
+ ```
83
+ {
84
+ "npu_path": "./npu_dump",
85
+ "is_print_compare_log": true
86
+ }
87
+ ```
88
+ npu_path格式:必须包含dump.json、stack.json和construct.json,且construct.json不能为空。如果construct.json为空,请检查dump的level参数是否没有选择L0或者mix。
89
+ ```
90
+ ├── npu_path
91
+ │ ├── dump_tensor_data(配置dump的task参数选择tensor时存在)
92
+ | | ├── Tensor.permute.1.forward.pt
93
+ | | ├── MyModule.0.forward.input.pt
94
+ | | ...
95
+ | | └── Fcuntion.linear.5.backward.output.pt
96
+ | ├── dump.json # 数据信息
97
+ | ├── stack.json # 调用栈信息
98
+ | └── construct.json # 分层分级结构
99
+ ```
100
+ **2. 执行命令**:
101
+ ```
102
+ msprobe -f pytorch graph -i ./compare.json -o ./output
103
+ ```
104
+ #### 3.2.2 双图比对
105
+
106
+ 展示模型结构、结构差异、精度数据和精度比对指标、精度是否疑似有问题(精度比对指标差异越大颜色越深)。
107
+
108
+ 当前比对支持三种类型的dump数据,分级可视化工具比对时会自动判断:
109
+
110
+ 1.统计信息:仅dump了API和Module的输入输出数据统计信息,占用磁盘空间小;
111
+
112
+ 2.真实数据:不仅dump了API和Module的输入输出数据统计信息,还将tensor进行存盘,占用磁盘空间大,但比对更加准确;
113
+
114
+ 3.md5:dump了API和Module的输入输出数据统计信息和md5信息。
115
+
116
+ dump类型如何配置见[数据采集配置文件介绍](https://gitee.com/ascend/mstt/blob/master/debug/accuracy_tools/msprobe/docs/02.config_introduction.md)
117
+
118
+ **1. 准备比对文件**:
119
+
120
+ 以在当前目录创建 ./compare.json 为例。
121
+ ```
122
+ {
123
+ "npu_path": "./npu_dump",
124
+ "bench_path": "./bench_dump",
125
+ "is_print_compare_log": true
126
+ }
127
+ ```
128
+ npu_path或bench_path格式:必须包含dump.json、stack.json和construct.json,且construct.json不能为空。如果construct.json为空,请检查dump的level参数是否没有选择L0或者mix。
129
+ ```
130
+ ├── npu_path或bench_path
131
+ │ ├── dump_tensor_data(仅配置dump的task参数选择tensor时存在)
132
+ | | ├── Tensor.permute.1.forward.pt
133
+ | | ├── MyModule.0.forward.input.pt
134
+ | | ...
135
+ | | └── Function.linear.5.backward.output.pt
136
+ | ├── dump.json # 数据信息
137
+ | ├── stack.json # 调用栈信息
138
+ | └── construct.json # 分层分级结构,level为L1时,construct.json内容为空
139
+ ```
140
+ **2. 执行命令**:
141
+ ```
142
+ msprobe -f pytorch graph -i ./compare.json -o ./output
143
+ ```
144
+
145
+ 比对完成后将在**output**下生成一个**vis后缀文件**。
146
+
147
+ #### 3.2.3 批量构建或比对
148
+ ##### 3.2.3.1 多rank批量构建或比对
149
+ 批量构建或比对一个step下的所有rank的数据
150
+
151
+ **1. 准备比对文件**:
152
+
153
+ 以在当前目录创建 ./compare.json 为例。
154
+ ```
155
+ {
156
+ "npu_path": "./npu_dump",
157
+ "bench_path": "./bench_dump", # 只进行图构建可不配置
158
+ "is_print_compare_log": true
159
+ }
160
+ ```
161
+ npu_path或bench_path格式:必须只包含rank+数字格式的文件夹,且每个rank文件夹中必须包含dump.json、stack.json和construct.json,且construct.json不能为空。如果construct.json为空,请检查dump的level参数是否没有选择L0或者mix。
162
+
163
+ 进行批量图比对时,npu_path和bench_path中包含的rank+数字格式的文件夹必须数量一致且能够一一对应。
164
+ ```
165
+ ├── npu_path或bench_path
166
+ | ├── rank0
167
+ | │ ├── dump_tensor_data(仅配置dump的task参数选择tensor时存在)
168
+ | | | ├── Tensor.permute.1.forward.pt
169
+ | | | ├── MyModule.0.forward.input.pt
170
+ | | | ...
171
+ | | | └── Function.linear.5.backward.output.pt
172
+ | | ├── dump.json # 数据信息
173
+ | | ├── stack.json # 算子调用栈信息
174
+ | | └── construct.json # 分层分级结构,level为L1时,construct.json内容为空
175
+ | ├── rank1
176
+ | | ├── dump_tensor_data
177
+ | | | └── ...
178
+ | | ├── dump.json
179
+ | | ├── stack.json
180
+ | | └── construct.json
181
+ | ├── ...
182
+ | |
183
+ | └── rankn
184
+ ```
185
+ **2. 执行命令**:
186
+ ```
187
+ msprobe -f pytorch graph -i ./compare.json -o ./output
188
+ ```
189
+ 比对完成后将在**output**下生成n个**vis后缀文件**。
190
+
191
+ 图构建:
192
+ ```
193
+ ├── build_rank0_{timestamp}.vis
194
+ ├── build_rank1_{timestamp}.vis
195
+ ├── build_rank2_{timestamp}.vis
196
+ ├── build_rank3_{timestamp}.vis
197
+ ├── ...
198
+ ├── build_rankn_{timestamp}.vis
199
+ ```
200
+ 图比对:
201
+ ```
202
+ ├── compare_rank0_{timestamp}.vis
203
+ ├── compare_rank1_{timestamp}.vis
204
+ ├── compare_rank2_{timestamp}.vis
205
+ ├── compare_rank3_{timestamp}.vis
206
+ ├── ...
207
+ ├── compare_rankn_{timestamp}.vis
208
+ ```
209
+ ##### 3.2.3.2 多step批量构建或比对
210
+ 批量构建或比对多个step下的所有rank的数据
211
+
212
+ **1. 准备比对文件**:
213
+
214
+ 以在当前目录创建 ./compare.json 为例。
215
+ ```
216
+ {
217
+ "npu_path": "./npu_dump",
218
+ "bench_path": "./bench_dump", # 只进行图构建可不配置
219
+ "is_print_compare_log": true
220
+ }
221
+ ```
222
+ npu_path或bench_path格式:必须只包含step+数字格式的文件夹,且每个step文件夹中必须只包含rank+数字格式的文件夹,每个rank文件夹中必须包含dump.json、stack.json和construct.json,且construct.json不能为空。如果construct.json为空,请检查dump的level参数是否没有选择L0或者mix。
223
+
224
+ 进行批量图比对时,npu_path和bench_path中包含的step+数字格式的文件夹必须数量一致且能够一一对应,每个step文件夹中包含的rank+数字格式的文件夹必须数量一致且能够一一对应。
225
+ ```
226
+ ├── npu_path或bench_path
227
+ │ ├── step0
228
+ │ | ├── rank0
229
+ │ | │ ├── dump_tensor_data(仅配置dump的task参数选择tensor时存在)
230
+ | | | | ├── Tensor.permute.1.forward.pt
231
+ | | | | ├── MyModule.0.forward.input.pt
232
+ | | | | ...
233
+ | | | | └── Function.linear.5.backward.output.pt
234
+ │ | | ├── dump.json # 数据信息
235
+ │ | | ├── stack.json # 调用栈信息
236
+ │ | | └── construct.json # 分层分级结构,level为L1时,construct.json内容为空
237
+ │ | ├── rank1
238
+ | | | ├── dump_tensor_data
239
+ | | | | └── ...
240
+ │ | | ├── dump.json
241
+ │ | | ├── stack.json
242
+ | | | └── construct.json
243
+ │ | ├── ...
244
+ │ | |
245
+ | | └── rankn
246
+ │ ├── step1
247
+ │ | ├── ...
248
+ │ ├── step2
249
+ ```
250
+ **2. 执行命令**:
251
+ ```
252
+ msprobe -f pytorch graph -i ./compare.json -o ./output
253
+ ```
254
+ 比对完成后将在**output**下生成若干个**vis后缀文件**。
255
+
256
+ 图构建:
257
+ ```
258
+ ├── build_step0_rank0_{timestamp}.vis
259
+ ├── build_step0_rank1_{timestamp}.vis
260
+ ├── build_step0_rank2_{timestamp}.vis
261
+ ├── build_step0_rank3_{timestamp}.vis
262
+ ├── build_step1_rank0_{timestamp}.vis
263
+ ├── build_step1_rank1_{timestamp}.vis
264
+ ├── build_step1_rank2_{timestamp}.vis
265
+ ├── build_step1_rank3_{timestamp}.vis
266
+ ├── ...
267
+ ├── build_stepn_rankn_{timestamp}.vis
268
+ ```
269
+ 图比对:
270
+ ```
271
+ ├── compare_step0_rank0_{timestamp}.vis
272
+ ├── compare_step0_rank1_{timestamp}.vis
273
+ ├── compare_step0_rank2_{timestamp}.vis
274
+ ├── compare_step0_rank3_{timestamp}.vis
275
+ ├── compare_step1_rank0_{timestamp}.vis
276
+ ├── compare_step1_rank1_{timestamp}.vis
277
+ ├── compare_step1_rank2_{timestamp}.vis
278
+ ├── compare_step1_rank3_{timestamp}.vis
279
+ ├── ...
280
+ ├── compare_stepn_rankn_{timestamp}.vis
281
+ ```
282
+
283
+ ## 4.启动tensorboard
284
+
285
+ 将生成vis文件的路径**out_path**传入--logdir
286
+
287
+ ```
288
+ tensorboard --logdir out_path --bind_all --port [可选,端口号]
289
+ ```
290
+
291
+ 启动后会打印日志。
292
+ ``TensorBoard 2.15.1 at http://localhost.localdomain:6008/ (Press CTRL+C to quit)``
293
+ localhost.localdomain是机器地址,6008是端口号。
294
+
295
+ **如果链接打不开,可以尝试使用vscode连接服务器,在vscode终端输入:**
296
+
297
+ ```
298
+ tensorboard --logdir out_path
299
+ ```
300
+
301
+ CTRL+C点击链接即可
302
+
303
+ ## 5.浏览器查看
304
+
305
+ 推荐使用谷歌浏览器,在浏览器中输入机器地址+端口号回车,出现TensorBoard页面,右上方选择GRAPHS_ASCEND即可展示模型结构图。
306
+
307
+ 节点需要双击打开。
308
+
309
+ 键盘WS可放大缩小,AD可左右移动,鼠标滚轮可上下移动。
310
+
311
+ ## 6.图比对说明
312
+
313
+ ### 颜色
314
+
315
+ 颜色越深,精度比对差异越大,越可疑,具体信息可见浏览器页面左下角颜色图例。
316
+
317
+ ### 疑似有精度问题判定
318
+
319
+ #### 真实数据模式
320
+ 节点中所有输入的最小双千指标和所有输出的最小双千分之一指标的差值,反映了双千指标的下降情况,**值越大精度差距越大,颜色标记越深**。
321
+
322
+ ``One Thousandth Err Ratio(双千分之一)精度指标:Tensor中的元素逐个与对应的标杆数据对比,相对误差小于千分之一的比例占总元素个数的比例,比例越接近1越好``
323
+
324
+ #### 统计信息模式
325
+ 节点中输出的统计量相对误差,**值越大精度差距越大,颜色标记越深**。
326
+
327
+ ``相对误差:abs((npu统计值 - bench统计值) / bench统计值)``
328
+
329
+ 其中小值不使用相对误差来判断精度差异,而是使用**绝对误差**来判断精度差异
330
+
331
+ **判定为小值的阈值:**
332
+
333
+ - torch.float32:e-6
334
+ - torch.float16:e-3
335
+ - torch.bfloat16:e-3
336
+
337
+ **小值域的绝对误差阈值:**
338
+
339
+ - torch.float32:e-6
340
+ - torch.float16:e-3
341
+ - torch.bfloat16:e-3
342
+
343
+ #### md5模式
344
+ 节点中任意输入输出的md5值不同。
345
+
346
+ ## 7.附录
347
+ ### 7.1 自定义映射文件(Layer)
348
+
349
+ 文件名格式:\*.yaml,*为文件名,可自定义。
350
+
351
+ 文件内容示例:
352
+
353
+ ```yaml
354
+ PanGuVLMModel: # Layer层名称
355
+ vision_model: language_model.vision_encoder # 模型代码中嵌套的Layer层名称
356
+ vision_projection: language_model.projection
357
+
358
+ RadioViTModel:
359
+ input_conditioner: radio_model.input_conditioner
360
+ patch_generator: radio_model.patch_generator
361
+ radio_model: radio_model.transformer
362
+
363
+ ParallelTransformerLayer:
364
+ input_norm: input_layernorm
365
+ post_attention_norm: post_attention_layernorm
366
+
367
+ GPTModel:
368
+ decoder: encoder
369
+
370
+ SelfAttention:
371
+ linear_qkv: query_key_value
372
+ core_attention: core_attention_flash
373
+ linear_proj: dense
374
+
375
+ MLP:
376
+ linear_fc1: dense_h_to_4h
377
+ linear_fc2: dense_4h_to_h
378
+ ```
379
+
380
+ Layer层名称需要从模型代码中获取。
381
+
382
+ yaml文件中只需配置待调试侧与标杆侧模型代码中功能一致但名称不同的Layer层,名称相同的Layer层会被自动识别并映射。
383
+
384
+ 模型代码示例:
385
+
386
+ ![ms_dump](./img/ms_layer.png)