mindstudio-probe 1.1.0__py3-none-any.whl → 1.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. {mindstudio_probe-1.1.0.dist-info → mindstudio_probe-1.2.1.dist-info}/METADATA +7 -6
  2. mindstudio_probe-1.2.1.dist-info/RECORD +396 -0
  3. {mindstudio_probe-1.1.0.dist-info → mindstudio_probe-1.2.1.dist-info}/WHEEL +1 -1
  4. {mindstudio_probe-1.1.0.dist-info → mindstudio_probe-1.2.1.dist-info}/entry_points.txt +0 -1
  5. msprobe/CMakeLists.txt +5 -0
  6. msprobe/README.md +51 -20
  7. msprobe/config.json +2 -3
  8. msprobe/core/advisor/advisor.py +8 -3
  9. msprobe/core/common/const.py +264 -15
  10. msprobe/core/common/exceptions.py +27 -3
  11. msprobe/core/common/file_utils.py +176 -26
  12. msprobe/core/common/inplace_op_checker.py +15 -0
  13. msprobe/core/common/inplace_ops.yaml +3 -0
  14. msprobe/core/common/log.py +27 -9
  15. msprobe/core/common/utils.py +204 -77
  16. msprobe/core/common_config.py +49 -14
  17. msprobe/core/compare/acc_compare.py +274 -198
  18. msprobe/core/compare/check.py +32 -33
  19. msprobe/core/compare/compare_cli.py +32 -14
  20. msprobe/core/compare/highlight.py +283 -127
  21. msprobe/core/compare/layer_mapping/__init__.py +19 -0
  22. msprobe/core/compare/layer_mapping/data_scope_parser.py +246 -0
  23. msprobe/core/compare/layer_mapping/layer_mapping.py +249 -0
  24. msprobe/core/compare/layer_mapping/postprocess_pass.py +95 -0
  25. msprobe/core/compare/merge_result/merge_result.py +380 -0
  26. msprobe/core/compare/merge_result/merge_result_cli.py +31 -0
  27. msprobe/core/compare/multiprocessing_compute.py +2 -2
  28. msprobe/core/compare/npy_compare.py +135 -144
  29. msprobe/core/compare/utils.py +419 -274
  30. msprobe/core/data_dump/data_collector.py +60 -28
  31. msprobe/core/data_dump/data_processor/base.py +84 -36
  32. msprobe/core/data_dump/data_processor/factory.py +5 -3
  33. msprobe/core/data_dump/data_processor/mindspore_processor.py +152 -18
  34. msprobe/core/data_dump/data_processor/pytorch_processor.py +267 -110
  35. msprobe/core/data_dump/json_writer.py +29 -1
  36. msprobe/core/data_dump/scope.py +119 -39
  37. msprobe/core/grad_probe/constant.py +27 -13
  38. msprobe/core/grad_probe/grad_compare.py +18 -1
  39. msprobe/core/grad_probe/utils.py +30 -2
  40. msprobe/core/overflow_check/abnormal_scene.py +189 -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 +96 -7
  48. msprobe/docs/02.config_introduction.md +50 -23
  49. msprobe/docs/03.config_examples.md +2 -9
  50. msprobe/docs/04.kernel_dump_PyTorch.md +73 -0
  51. msprobe/docs/05.data_dump_PyTorch.md +93 -61
  52. msprobe/docs/06.data_dump_MindSpore.md +200 -95
  53. msprobe/docs/07.accuracy_checker_PyTorch.md +28 -28
  54. msprobe/docs/08.accuracy_checker_online_PyTorch.md +1 -6
  55. msprobe/docs/09.accuracy_checker_MindSpore.md +44 -8
  56. msprobe/docs/10.accuracy_compare_PyTorch.md +114 -50
  57. msprobe/docs/11.accuracy_compare_MindSpore.md +340 -48
  58. msprobe/docs/12.overflow_check_PyTorch.md +2 -2
  59. msprobe/docs/13.overflow_check_MindSpore.md +6 -6
  60. msprobe/docs/15.free_benchmarking_PyTorch.md +4 -5
  61. msprobe/docs/16.free_benchmarking_MindSpore.md +56 -37
  62. msprobe/docs/17.grad_probe.md +5 -6
  63. msprobe/docs/19.monitor.md +561 -0
  64. msprobe/docs/20.monitor_performance_baseline.md +52 -0
  65. msprobe/docs/21.visualization_PyTorch.md +466 -0
  66. msprobe/docs/22.visualization_MindSpore.md +481 -0
  67. msprobe/docs/23.generate_operator_PyTorch.md +107 -0
  68. msprobe/docs/24.code_mapping_Mindspore.md +28 -0
  69. msprobe/docs/25.tool_function_introduction.md +29 -0
  70. msprobe/docs/26.data_dump_PyTorch_baseline.md +37 -0
  71. msprobe/docs/27.dump_json_instruction.md +521 -0
  72. msprobe/docs/FAQ.md +29 -2
  73. msprobe/docs/accuracy_checker_MindSpore/accuracy_checker_MindSpore_baseline.md +14 -0
  74. msprobe/docs/data_dump_MindSpore/data_dump_MindSpore_baseline.md +22 -0
  75. msprobe/docs/data_dump_MindSpore/dynamic_graph_quick_start_example.md +211 -0
  76. msprobe/docs/img/compare_result.png +0 -0
  77. msprobe/docs/img/merge_result.png +0 -0
  78. msprobe/docs/img/monitor/cpu_info.png +0 -0
  79. msprobe/docs/img/visualization/fuzzy_match_ms.png +0 -0
  80. msprobe/docs/img/visualization/fuzzy_match_pt.png +0 -0
  81. msprobe/docs/img/visualization/tensorboard_1.png +0 -0
  82. msprobe/docs/img/visualization/tensorboard_2.png +0 -0
  83. msprobe/docs/img/visualization/vis_browser_1.png +0 -0
  84. msprobe/docs/img/visualization/vis_browser_2.png +0 -0
  85. msprobe/docs/img/visualization/vis_precision_info.png +0 -0
  86. msprobe/docs/img/visualization/vis_search_info.png +0 -0
  87. msprobe/docs/img/visualization/vis_show_info.png +0 -0
  88. msprobe/docs/img/visualization/vis_showcase.png +0 -0
  89. msprobe/docs/img/visualization/vis_unmatch_info.png +0 -0
  90. msprobe/docs/visualization/GPTModel.png +0 -0
  91. msprobe/docs/visualization/ParallelMLP.png +0 -0
  92. msprobe/docs/visualization/layer_mapping_example.md +132 -0
  93. msprobe/docs/visualization/mapping.png +0 -0
  94. msprobe/docs/visualization/mapping1.png +0 -0
  95. msprobe/docs/visualization/module_name.png +0 -0
  96. msprobe/docs/visualization/module_name1.png +0 -0
  97. msprobe/docs/visualization/no_mapping.png +0 -0
  98. msprobe/docs/visualization/no_mapping1.png +0 -0
  99. msprobe/docs/visualization/no_mapping_analyze.png +0 -0
  100. msprobe/docs/visualization/top_layer.png +0 -0
  101. msprobe/mindspore/__init__.py +25 -0
  102. msprobe/mindspore/api_accuracy_checker/api_accuracy_checker.py +151 -151
  103. msprobe/mindspore/api_accuracy_checker/api_info.py +21 -6
  104. msprobe/mindspore/api_accuracy_checker/api_runner.py +43 -18
  105. msprobe/mindspore/api_accuracy_checker/base_compare_algorithm.py +21 -7
  106. msprobe/mindspore/api_accuracy_checker/checker_support_api.yaml +77 -0
  107. msprobe/mindspore/api_accuracy_checker/cmd_parser.py +64 -1
  108. msprobe/mindspore/api_accuracy_checker/compute_element.py +64 -31
  109. msprobe/mindspore/api_accuracy_checker/data_manager.py +301 -0
  110. msprobe/mindspore/api_accuracy_checker/main.py +28 -3
  111. msprobe/mindspore/api_accuracy_checker/multi_api_accuracy_checker.py +212 -0
  112. msprobe/mindspore/api_accuracy_checker/multi_data_manager.py +60 -0
  113. msprobe/mindspore/api_accuracy_checker/type_mapping.py +22 -5
  114. msprobe/mindspore/api_accuracy_checker/utils.py +34 -17
  115. msprobe/mindspore/cell_processor.py +33 -12
  116. msprobe/mindspore/code_mapping/bind.py +264 -0
  117. msprobe/mindspore/code_mapping/cmd_parser.py +40 -0
  118. msprobe/mindspore/code_mapping/graph.py +49 -0
  119. msprobe/mindspore/code_mapping/graph_parser.py +226 -0
  120. msprobe/mindspore/code_mapping/main.py +24 -0
  121. msprobe/mindspore/code_mapping/processor.py +34 -0
  122. msprobe/mindspore/common/const.py +35 -13
  123. msprobe/mindspore/common/log.py +5 -9
  124. msprobe/mindspore/common/utils.py +88 -4
  125. msprobe/mindspore/compare/distributed_compare.py +22 -24
  126. msprobe/mindspore/compare/ms_compare.py +333 -268
  127. msprobe/mindspore/compare/ms_graph_compare.py +95 -52
  128. msprobe/mindspore/debugger/debugger_config.py +7 -1
  129. msprobe/mindspore/debugger/precision_debugger.py +87 -12
  130. msprobe/mindspore/dump/dump_tool_factory.py +3 -1
  131. msprobe/mindspore/dump/hook_cell/api_registry.py +95 -18
  132. msprobe/mindspore/dump/hook_cell/hook_cell.py +60 -38
  133. msprobe/mindspore/dump/hook_cell/primitive_hooks.py +45 -30
  134. msprobe/mindspore/dump/hook_cell/support_wrap_ops.yaml +36 -1
  135. msprobe/mindspore/dump/hook_cell/wrap_api.py +92 -1
  136. msprobe/mindspore/dump/jit_dump.py +17 -5
  137. msprobe/mindspore/dump/kernel_dump/kernel_config.py +33 -0
  138. msprobe/mindspore/dump/kernel_graph_dump.py +9 -4
  139. msprobe/mindspore/dump/kernel_kbyk_dump.py +2 -4
  140. msprobe/mindspore/dym_loader/hook_dynamic_loader.cc +140 -0
  141. msprobe/mindspore/dym_loader/hook_dynamic_loader.h +53 -0
  142. msprobe/mindspore/free_benchmark/api_pynative_self_check.py +156 -41
  143. msprobe/mindspore/free_benchmark/common/handler_params.py +1 -2
  144. msprobe/mindspore/free_benchmark/common/utils.py +19 -4
  145. msprobe/mindspore/free_benchmark/data/support_wrap_ops.yaml +0 -204
  146. msprobe/mindspore/free_benchmark/handler/base_handler.py +3 -3
  147. msprobe/mindspore/free_benchmark/handler/check_handler.py +4 -5
  148. msprobe/mindspore/free_benchmark/handler/fix_handler.py +4 -4
  149. msprobe/mindspore/free_benchmark/handler/handler_factory.py +4 -4
  150. msprobe/mindspore/free_benchmark/perturbation/add_noise.py +2 -2
  151. msprobe/mindspore/free_benchmark/perturbation/base_perturbation.py +15 -6
  152. msprobe/mindspore/free_benchmark/perturbation/bit_noise.py +2 -2
  153. msprobe/mindspore/free_benchmark/perturbation/exchange_value.py +2 -2
  154. msprobe/mindspore/free_benchmark/perturbation/improve_precision.py +13 -6
  155. msprobe/mindspore/free_benchmark/perturbation/perturbation_factory.py +2 -2
  156. msprobe/mindspore/free_benchmark/self_check_tool_factory.py +2 -2
  157. msprobe/mindspore/grad_probe/global_context.py +28 -8
  158. msprobe/mindspore/grad_probe/grad_analyzer.py +50 -24
  159. msprobe/mindspore/grad_probe/grad_monitor.py +16 -1
  160. msprobe/mindspore/grad_probe/grad_stat_csv.py +33 -5
  161. msprobe/mindspore/grad_probe/hook.py +35 -12
  162. msprobe/mindspore/grad_probe/utils.py +18 -5
  163. msprobe/mindspore/mindtorch/__init__.py +18 -0
  164. msprobe/mindspore/mindtorch/mindtorch_adaptor.py +255 -0
  165. msprobe/mindspore/ms_config.py +27 -16
  166. msprobe/mindspore/overflow_check/kernel_graph_overflow_check.py +9 -4
  167. msprobe/mindspore/runtime.py +15 -0
  168. msprobe/mindspore/service.py +285 -113
  169. msprobe/mindspore/task_handler_factory.py +15 -0
  170. msprobe/msprobe.py +48 -10
  171. msprobe/pytorch/__init__.py +8 -6
  172. msprobe/pytorch/api_accuracy_checker/common/config.py +62 -0
  173. msprobe/pytorch/api_accuracy_checker/common/utils.py +31 -16
  174. msprobe/pytorch/api_accuracy_checker/compare/algorithm.py +41 -8
  175. msprobe/pytorch/api_accuracy_checker/compare/api_precision_compare.py +103 -271
  176. msprobe/pytorch/api_accuracy_checker/compare/api_precision_standard.yaml +4 -1
  177. msprobe/pytorch/api_accuracy_checker/compare/compare.py +69 -68
  178. msprobe/pytorch/api_accuracy_checker/compare/compare_column.py +54 -0
  179. msprobe/pytorch/api_accuracy_checker/compare/compare_input.py +51 -0
  180. msprobe/pytorch/api_accuracy_checker/compare/compare_utils.py +2 -4
  181. msprobe/pytorch/api_accuracy_checker/generate_op_script/config_op.json +9 -0
  182. msprobe/pytorch/api_accuracy_checker/generate_op_script/op_generator.py +478 -0
  183. msprobe/pytorch/api_accuracy_checker/generate_op_script/operator_replication.template +365 -0
  184. msprobe/pytorch/api_accuracy_checker/precision_standard/absolute_threshold.py +106 -0
  185. msprobe/pytorch/api_accuracy_checker/precision_standard/accumulative_error_compare.py +107 -0
  186. msprobe/pytorch/api_accuracy_checker/precision_standard/base_standard.py +151 -0
  187. msprobe/pytorch/api_accuracy_checker/precision_standard/benchmark_compare.py +226 -0
  188. msprobe/pytorch/api_accuracy_checker/precision_standard/binary_consistency.py +68 -0
  189. msprobe/pytorch/api_accuracy_checker/precision_standard/standard_config.py +218 -0
  190. msprobe/pytorch/api_accuracy_checker/precision_standard/standard_register.py +104 -0
  191. msprobe/pytorch/api_accuracy_checker/precision_standard/thousandth_standard.py +63 -0
  192. msprobe/pytorch/api_accuracy_checker/precision_standard/ulp_compare.py +200 -0
  193. msprobe/pytorch/api_accuracy_checker/run_ut/data_generate.py +63 -2
  194. msprobe/pytorch/api_accuracy_checker/run_ut/multi_run_ut.py +21 -15
  195. msprobe/pytorch/api_accuracy_checker/run_ut/run_overflow_check.py +54 -22
  196. msprobe/pytorch/api_accuracy_checker/run_ut/run_ut.py +140 -71
  197. msprobe/pytorch/api_accuracy_checker/run_ut/run_ut_utils.py +49 -8
  198. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/attl.py +9 -24
  199. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/client.py +4 -12
  200. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/device_dispatch.py +5 -3
  201. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/dump_dispatch.py +9 -4
  202. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/server.py +3 -11
  203. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/utils.py +2 -2
  204. msprobe/pytorch/bench_functions/confusion_transpose.py +5 -1
  205. msprobe/pytorch/bench_functions/matmul_backward.py +12 -0
  206. msprobe/pytorch/bench_functions/npu_fusion_attention.py +142 -16
  207. msprobe/pytorch/bench_functions/rotary_mul.py +4 -0
  208. msprobe/pytorch/bench_functions/swiglu.py +10 -2
  209. msprobe/pytorch/common/parse_json.py +7 -6
  210. msprobe/pytorch/common/utils.py +101 -7
  211. msprobe/pytorch/compare/distributed_compare.py +17 -30
  212. msprobe/pytorch/compare/pt_compare.py +44 -22
  213. msprobe/pytorch/debugger/debugger_config.py +46 -27
  214. msprobe/pytorch/debugger/precision_debugger.py +42 -12
  215. msprobe/pytorch/dump/kernel_dump/kernel_config.py +33 -0
  216. msprobe/pytorch/dump/module_dump/module_dump.py +86 -0
  217. msprobe/pytorch/{module_processer.py → dump/module_dump/module_processer.py} +81 -10
  218. msprobe/pytorch/free_benchmark/common/constant.py +15 -0
  219. msprobe/pytorch/free_benchmark/common/counter.py +15 -0
  220. msprobe/pytorch/free_benchmark/common/enums.py +15 -0
  221. msprobe/pytorch/free_benchmark/common/params.py +10 -2
  222. msprobe/pytorch/free_benchmark/common/utils.py +29 -4
  223. msprobe/pytorch/free_benchmark/compare/grad_saver.py +20 -5
  224. msprobe/pytorch/free_benchmark/compare/single_benchmark.py +2 -0
  225. msprobe/pytorch/free_benchmark/perturbed_layers/npu/add_noise.py +3 -1
  226. msprobe/pytorch/free_benchmark/perturbed_layers/npu/bit_noise.py +6 -4
  227. msprobe/pytorch/free_benchmark/perturbed_layers/npu/change_value.py +2 -0
  228. msprobe/pytorch/free_benchmark/perturbed_layers/npu/improve_precision.py +4 -0
  229. msprobe/pytorch/free_benchmark/result_handlers/base_handler.py +41 -47
  230. msprobe/pytorch/free_benchmark/result_handlers/fix_handler.py +6 -5
  231. msprobe/pytorch/free_benchmark/result_handlers/preheat_handler.py +0 -4
  232. msprobe/pytorch/grad_probe/grad_monitor.py +23 -6
  233. msprobe/pytorch/grad_probe/grad_stat_csv.py +40 -10
  234. msprobe/pytorch/hook_module/__init__.py +1 -1
  235. msprobe/pytorch/hook_module/hook_module.py +14 -11
  236. msprobe/pytorch/hook_module/register_optimizer_hook.py +59 -0
  237. msprobe/pytorch/hook_module/support_wrap_ops.yaml +35 -0
  238. msprobe/pytorch/hook_module/wrap_distributed.py +6 -8
  239. msprobe/pytorch/hook_module/wrap_functional.py +0 -38
  240. msprobe/pytorch/monitor/__init__.py +0 -0
  241. msprobe/pytorch/monitor/anomaly_analyse.py +201 -0
  242. msprobe/pytorch/monitor/anomaly_detect.py +425 -0
  243. msprobe/pytorch/monitor/csv2tb.py +166 -0
  244. msprobe/pytorch/monitor/distributed/__init__.py +0 -0
  245. msprobe/pytorch/monitor/distributed/distributed_ops.yaml +19 -0
  246. msprobe/pytorch/monitor/distributed/stack_blacklist.yaml +5 -0
  247. msprobe/pytorch/monitor/distributed/wrap_distributed.py +283 -0
  248. msprobe/pytorch/monitor/features.py +108 -0
  249. msprobe/pytorch/monitor/module_hook.py +1076 -0
  250. msprobe/pytorch/monitor/module_metric.py +172 -0
  251. msprobe/pytorch/monitor/module_spec_verifier.py +95 -0
  252. msprobe/pytorch/monitor/optimizer_collect.py +333 -0
  253. msprobe/pytorch/monitor/unittest/__init__.py +0 -0
  254. msprobe/pytorch/monitor/unittest/test_monitor.py +160 -0
  255. msprobe/pytorch/monitor/utils.py +321 -0
  256. msprobe/pytorch/monitor/visualizer.py +59 -0
  257. msprobe/pytorch/online_dispatch/__init__.py +2 -3
  258. msprobe/pytorch/online_dispatch/compare.py +29 -38
  259. msprobe/pytorch/online_dispatch/dispatch.py +58 -27
  260. msprobe/pytorch/online_dispatch/dump_compare.py +21 -9
  261. msprobe/pytorch/online_dispatch/single_compare.py +53 -32
  262. msprobe/pytorch/online_dispatch/torch_ops_config.yaml +1 -1
  263. msprobe/pytorch/online_dispatch/utils.py +49 -21
  264. msprobe/pytorch/parse_tool/lib/compare.py +21 -27
  265. msprobe/pytorch/parse_tool/lib/config.py +6 -8
  266. msprobe/pytorch/parse_tool/lib/file_desc.py +15 -1
  267. msprobe/pytorch/parse_tool/lib/interactive_cli.py +10 -10
  268. msprobe/pytorch/parse_tool/lib/parse_exception.py +7 -7
  269. msprobe/pytorch/parse_tool/lib/parse_tool.py +12 -12
  270. msprobe/pytorch/parse_tool/lib/utils.py +33 -53
  271. msprobe/pytorch/parse_tool/lib/visualization.py +11 -10
  272. msprobe/pytorch/pt_config.py +31 -8
  273. msprobe/pytorch/service.py +188 -108
  274. msprobe/visualization/__init__.py +14 -0
  275. msprobe/visualization/builder/__init__.py +14 -0
  276. msprobe/visualization/builder/graph_builder.py +222 -0
  277. msprobe/visualization/builder/msprobe_adapter.py +227 -0
  278. msprobe/visualization/compare/__init__.py +14 -0
  279. msprobe/visualization/compare/graph_comparator.py +180 -0
  280. msprobe/visualization/compare/mode_adapter.py +197 -0
  281. msprobe/visualization/graph/__init__.py +14 -0
  282. msprobe/visualization/graph/base_node.py +119 -0
  283. msprobe/visualization/graph/distributed_analyzer.py +318 -0
  284. msprobe/visualization/graph/graph.py +209 -0
  285. msprobe/visualization/graph/node_colors.py +95 -0
  286. msprobe/visualization/graph/node_op.py +39 -0
  287. msprobe/visualization/graph_service.py +288 -0
  288. msprobe/visualization/utils.py +217 -0
  289. mindstudio_probe-1.1.0.dist-info/RECORD +0 -287
  290. msprobe/docs/04.acl_config_examples.md +0 -78
  291. msprobe/mindspore/compare/layer_mapping.py +0 -146
  292. msprobe/mindspore/compare/modify_mapping.py +0 -107
  293. msprobe/mindspore/free_benchmark/decorator/dec_forward.py +0 -57
  294. msprobe/mindspore/free_benchmark/decorator/decorator_factory.py +0 -122
  295. msprobe/pytorch/functional/module_dump.py +0 -84
  296. {mindstudio_probe-1.1.0.dist-info → mindstudio_probe-1.2.1.dist-info}/LICENSE +0 -0
  297. {mindstudio_probe-1.1.0.dist-info → mindstudio_probe-1.2.1.dist-info}/top_level.txt +0 -0
  298. /msprobe/mindspore/{free_benchmark/decorator → code_mapping}/__init__.py +0 -0
  299. /msprobe/pytorch/{functional → dump/module_dump}/__init__.py +0 -0
@@ -1,5 +1,10 @@
1
1
  # MindSpore 场景的精度比对
2
2
 
3
+ ## 🚨 重要通知
4
+
5
+ **1. 精度比对已支持自动识别stack.json并呈现NPU_Stack_Info,用户可无需配置compare.json中的"stack_path"字段和命令行中的-s参数。具体使用参见“4.1 比对文件”中的参数说明。命令行方式中的-s(--stack_mode)将于2025.9.30废弃,并且不再需要配置compare.json中的"stack_path"字段。**
6
+
7
+
3
8
  ## 1 简介
4
9
 
5
10
  msprobe精度比对工具主要用于如下场景:
@@ -33,14 +38,16 @@ msprobe -f mindspore compare -i ./compare.json -o ./output -s
33
38
  | 参数名 | 说明 | 是否必选 |
34
39
  | -------------------- | ------------------------------------------------------------ | -------- |
35
40
  | -i或--input_path | 指定比对文件。比对文件内容及示例请参见[比对文件](#31-比对文件)或[比对文件(kernel)](#32-比对文件kernel)(比对文件(kernel)仅[不同版本下的全量kernel比对](#23-不同版本下的全量kernel比对)场景支持)。 | 是 |
36
- | -o或--output_path | 配置比对结果文件存盘目录。文件名称基于时间戳自动生成,格式为:<br> `compare_result_{timestamp}.xlsx`<br/> `compare_result_{rank_id}_{step_id}_{timestamp}.xlsx`(仅[不同版本下的全量kernel比对](#23-不同版本下的全量kernel比对)场景支持)。 | |
37
- | -s或--stack_mode | 配置stack_mode的开关。仅当[比对文件](#31-比对文件)配置"stack_path"需要开启。通过直接配置该参数开启,默认未配置,表示关闭。 | 否 |
41
+ | -o或--output_path | 配置比对结果文件存盘目录,默认会在当前目录创建output目录。文件名称基于时间戳自动生成,格式为:<br> `compare_result_{timestamp}.xlsx`<br/> `compare_result_{rank_id}_{step_id}_{timestamp}.xlsx`(仅[不同版本下的全量kernel比对](#23-不同版本下的全量kernel比对)场景支持)。 | |
42
+ | -s或--stack_mode | 比对结果展示调用栈信息(NPU_Stack_Info)的开关,bool 类型。单卡场景开启时,需要使用[比对文件](#31-比对文件)的单卡场景配置stack_path指定stack.json文件,才能生成详细调用栈信息,否则在比对时会报错;暂不支持多卡场景。通过直接配置该参数开启,默认未配置,表示关闭。 | 否 |
38
43
  | -c或--compare_only | 仅比对开关,bool 类型。该参数默认未配置,会启用自动精度分析,工具自动针对比对结果进行分析,识别到第一个精度可能不达标节点(在比对结果文件中的 Accuracy Reached or Not 列显示为 No),并给出问题可能产生的原因(打屏展示并生成 `advisor_{timestamp}.txt` 文件)。通过配置该参数取消自动精度分析,仅输出比对结果表格。 | 否 |
39
44
  | -f或--fuzzy_match | 模糊匹配。开启后,对于网络中同一层级且命名仅调用次数不同的API,可匹配并进行比对。通过直接配置该参数开启,默认未配置,表示关闭。 | 否 |
40
- | -am或--api_mapping | 跨框架比对。配置该参数时表示开启跨框架API比对功能。仅[跨框架的API比对](#25-跨框架的api比对)场景需要配置。 | 否 |
41
- | -cm或--cell_mapping | 跨框架比对。配置该参数时表示开启跨框架cell模块比对功能,可以指定自定义映射文件*.yaml,不指定映射文件时按照msprobe定义的默认映射关系进行比对。自定义映射文件的格式请参见[自定义映射文件(cell)](#33-自定义映射文件cell)。仅[跨框架的cell模块比对](#26-跨框架的cell模块比对)场景需要配置。 | 否 |
42
- | -dm或--data_mapping | 跨框架比对。配置该参数时表示开启跨框架API或模块的比对功能,需要指定自定义映射文件*.yaml。自定义映射文件的格式请参见[自定义映射文件(API和模块)](#34-自定义映射文件api和模块)。仅[跨框架的API或模块比对](#27-跨框架的api或模块比对)场景需要配置。 | 否 |
43
- | -lm或--layer_mapping | 跨框架比对。配置该参数时表示开启跨框架Layer层的比对功能,指定模型代码中的Layer层后,可以识别对应dump数据中的模块或API。需要指定自定义映射文件*.yaml。自定义映射文件的格式请参见[自定义映射文件(Layer)](#35-自定义映射文件layer)。仅[跨框架的Layer层比对](#28-跨框架的layer层比对)场景需要配置。 | 否 |
45
+ | -am或--api_mapping | 跨框架比对。配置该参数时表示开启跨框架API比对功能,可以指定自定义映射文件*.yaml,不指定映射文件时按照msprobe定义的默认映射关系进行比对。自定义映射文件的格式请参见[自定义映射文件(api_mapping)](#33-自定义映射文件api_mapping)。仅[跨框架的API比对](#25-跨框架的api比对)场景需要配置。 | 否 |
46
+ | -cm或--cell_mapping | 跨框架比对。配置该参数时表示开启跨框架cell模块比对功能,可以指定自定义映射文件*.yaml,不指定映射文件时按照msprobe定义的默认映射关系进行比对。自定义映射文件的格式请参见[自定义映射文件(cell_mapping)](#34-自定义映射文件cell_mapping)。仅[跨框架的cell模块比对](#26-跨框架的cell模块比对)场景需要配置。 | 否 |
47
+ | -dm或--data_mapping | 同框架或跨框架比对。通过映射文件指定两个具体参数的对应关系,可以在L0、L1或mix采集场景下使用。配置该参数的同时需要指定自定义映射文件*.yaml。自定义映射文件的格式请参见[自定义映射文件(data_mapping)](#35-自定义映射文件data_mapping) | 否 |
48
+ | -lm或--layer_mapping | 跨框架比对。配置该参数时表示开启跨框架Layer层的比对功能,指定模型代码中的Layer层后,可以识别对应dump数据中的模块或API。需要指定自定义映射文件*.yaml。自定义映射文件的格式请参见[自定义映射文件(Layer_mapping)](#36-自定义映射文件layer_mapping)。仅[跨框架的Layer层比对](#27-跨框架的layer层比对)场景需要配置。 | 否 |
49
+
50
+ 动态图模式没有填写任何mapping时,按照同框架比对的方式进行比对,比对数据和标杆数据的Cell或Api名称需要完全相同才能匹配得上。
44
51
 
45
52
  ### 2.2 不同版本下的全量API比对
46
53
 
@@ -102,6 +109,21 @@ msprobe -f mindspore compare -i ./compare.json -o ./output -s
102
109
  msprobe -f mindspore compare -i ./compare.json -o ./output -s -am
103
110
  ```
104
111
 
112
+
113
+
114
+ ```shell
115
+ msprobe -f mindspore compare -i ./compare.json -o ./output -s -am api_mapping.yaml
116
+ ```
117
+
118
+ api_mapping.yaml文件配置请参见[自定义映射文件(api_mapping)](#33-自定义映射文件api_mapping)。
119
+ 不传入api_mapping.yaml的情况下将按照内置的api映射进行匹配;传入api_mapping.yaml的情况下优先按照api_mapping.yaml的内容进行匹配,api_mapping.yaml中没有涉及的按照内置的api映射进行匹配。
120
+
121
+ 此外,也可以通过data_mapping.yaml文件实现具体参数的匹配,例:
122
+ ```shell
123
+ msprobe -f mindspore compare -i ./compare.json -o ./output -s -dm data_mapping.yaml
124
+ ```
125
+ data_mapping.yaml的写法请参见[自定义映射文件(data_mapping)](#35-自定义映射文件data_mapping)。
126
+
105
127
  5. 查看比对结果,请详见PyTorch目录下的《[PyTorch 场景的精度比对-精度比对结果分析](./10.accuracy_compare_PyTorch.md#3-精度比对结果分析)》章节。
106
128
 
107
129
  ### 2.6 跨框架的cell模块比对
@@ -124,15 +146,22 @@ msprobe -f mindspore compare -i ./compare.json -o ./output -s
124
146
  msprobe -f mindspore compare -i ./compare.json -o ./output -s -cm cell_mapping.yaml
125
147
  ```
126
148
 
127
- cell_mapping.yaml文件配置请参见[自定义映射文件(cell)](#33-自定义映射文件cell)。
149
+ cell_mapping.yaml文件配置请参见[自定义映射文件(cell_mapping)](#34-自定义映射文件cell_mapping)。
150
+ 不传入cell_mapping.yaml的情况下仅将Cell改成Module后进行匹配;传入cell_mapping.yaml的情况下将按照cell_mapping.yaml的内容进行匹配。
151
+
152
+ 此外,也可以通过data_mapping.yaml文件实现具体参数的匹配,例:
153
+ ```shell
154
+ msprobe -f mindspore compare -i ./compare.json -o ./output -s -dm data_mapping.yaml
155
+ ```
156
+ data_mapping.yaml的写法请参见[自定义映射文件(data_mapping)](#35-自定义映射文件data_mapping)。
128
157
 
129
158
  5. 查看比对结果,请详见PyTorch目录下的《[PyTorch 场景的精度比对-精度比对结果分析](./10.accuracy_compare_PyTorch.md#3-精度比对结果分析)》章节。
130
159
 
131
- ### 2.7 跨框架的API或模块比对
160
+ ### 2.7 跨框架的Layer层比对
132
161
 
133
- 该场景可用于在“**跨框架的API比对**”和“**跨框架的cell模块比对**”场景均无法完全覆盖模型中的API和模块时,通过手动指定映射关系来补全未被比对的API或模块。
162
+ layer_mapping可以从Layer层识别整网的API和Cell,简化配置。
134
163
 
135
- 1. 配置[config.json](../config.json)文件level配置为L0或L1、task配置为tensor或statistics并指定需要dump的API或模块名。
164
+ 1. 配置[config.json](../config.json)文件level配置为L0或mix、task配置为tensor或statistics并指定需要dump的API或模块名。
136
165
 
137
166
  2. 参见《[MindSpore 场景的精度数据采集](./06.data_dump_MindSpore.md)》和《[PyTorch 场景的精度数据采集](./05.data_dump_PyTorch.md)》完成不同环境下API或模块精度数据的采集,得到两个框架的API或模块dump数据。
138
167
 
@@ -141,36 +170,75 @@ msprobe -f mindspore compare -i ./compare.json -o ./output -s
141
170
  4. 执行如下示例命令进行比对:
142
171
 
143
172
  ```shell
144
- msprobe -f mindspore compare -i ./compare.json -o ./output -s -dm data_mapping.yaml
173
+ msprobe -f mindspore compare -i ./compare.json -o ./output -s -lm layer_mapping.yaml
145
174
  ```
146
175
 
147
- data_mapping.yaml文件配置请参见[自定义映射文件(all)](#34-自定义映射文件all)。
176
+ layer_mapping.yaml文件配置请参见[自定义映射文件(layer_mapping)](#36-自定义映射文件layer_mapping)。
177
+
178
+ 此外,也可以通过data_mapping.yaml文件实现具体参数的匹配,例:
179
+ ```shell
180
+ msprobe -f mindspore compare -i ./compare.json -o ./output -s -dm data_mapping.yaml
181
+ ```
182
+ data_mapping.yaml的写法请参见[自定义映射文件(data_mapping)](#35-自定义映射文件data_mapping)。
148
183
 
149
184
  5. 查看比对结果,请详见PyTorch目录下的《[PyTorch 场景的精度比对-精度比对结果分析](./10.accuracy_compare_PyTorch.md#3-精度比对结果分析)》章节。
150
185
 
151
- ### 2.8 跨框架的Layer层比对
186
+ ## 3 多卡比对结果提取汇总通信算子数据
152
187
 
153
- 该场景可简化API或模块场景的配置,从Layer层识别整网的API和模块。
188
+ 本功能是将多卡比对场景的比对结果,进行通信算子数据提取和汇总,输出整理好的通信算子多卡比对精度表。
154
189
 
155
- 1. 配置[config.json](../config.json)文件level配置为L0或mix、task配置为tensor或statistics并指定需要dump的API或模块名。
190
+ **约束**
156
191
 
157
- 2. 参见《[MindSpore 场景的精度数据采集](./06.data_dump_MindSpore.md)》和《[PyTorch 场景的精度数据采集](./05.data_dump_PyTorch.md)》完成不同环境下API或模块精度数据的采集,得到两个框架的API或模块dump数据。
192
+ - 不支持MD5比对结果。
193
+ - 不支持MindSpore静态图比对结果。
158
194
 
159
- 3. 创建比对文件,文件内容及示例请参见[比对文件](#31-比对文件)。
195
+ **命令示例**
160
196
 
161
- 4. 执行如下示例命令进行比对:
197
+ ```bash
198
+ msprobe -f mindspore merge_result -i ./input_dir -o ./output_dir -config ./config.yaml
199
+ ```
162
200
 
163
- ```shell
164
- msprobe -f mindspore compare -i ./compare.json -o ./output -s -lm layer_mapping.yaml
165
- ```
201
+ **完整参数说明**
166
202
 
167
- layer_mapping.yaml文件配置请参见[自定义映射文件(Layer)](#35-自定义映射文件layer)。
203
+ | 参数名 | 说明 | 是否必选 |
204
+ | ---------------------- | ------------------------------------------------------------ | -------- |
205
+ | -i 或 --input_dir | 多卡比对结果存盘目录,即使用compare比对的结果输出目录,str类型。所有比对结果应全部为真实数据比对结果或统计数据比对结果,否则可能导致汇总数据不完整。 | 是 |
206
+ | -o 或 --output_dir | 数据提取汇总结果存盘目录,str类型。文件名称基于时间戳自动生成,格式为:`multi_ranks_compare_merge_{timestamp}.xlsx`。 | 是 |
207
+ | -config或--config-path | 指定需要汇总数据的API和比对指标的yaml文件路径,str类型。<br>yaml文件详细介绍见下文“**yaml文件说明**”。 | 是 |
168
208
 
169
- 5. 查看比对结果,请详见PyTorch目录下的《[PyTorch 场景的精度比对-精度比对结果分析](./10.accuracy_compare_PyTorch.md#3-精度比对结果分析)》章节。
209
+ **yaml文件说明**
210
+
211
+ 以config.yaml文件名为例,配置示例如下:
170
212
 
171
- ## 3 附录
213
+ ```
214
+ api:
215
+ - Distributed.all_reduce
216
+ - Distributed.all_gather_into_tensor
217
+ compare_index:
218
+ - Max diff
219
+ - L2norm diff
220
+ - MeanRelativeErr
221
+ ```
222
+
223
+ | 参数名 | 说明 |
224
+ | ------------- | ------------------------------------------------------------ |
225
+ | api | 表示需要汇总的API或module名称。如果没有配置,工具会提示报错。<br/>api名称配置格式为:`{api_type}.{api_name}.{API调用次数}.{前向反向}`<br/>须按顺序配置以上四个字段,可按如下组合配置:<br/> {api_type}<br/> {api_type}.{api_name}<br/> {api_type}.{api_name}.{API调用次数}<br/> {api_type}.{api_name}.{API调用次数}.{前向反向}<br/>这里的api指代API或module。 |
226
+ | compare_index | 表示需要汇总的比对指标。compare_index需为dump_mode对应比对指标的子集。如果没有配置,工具将根据比对结果自动提取dump_mode对应的全部比对指标进行汇总。<br>统计数据模式比对指标:Max diff、Min diff、Mean diff、Norm diff、MaxRelativeErr、MinRelativeErr、MeanRelativeErr、NormRelativeErr<br>真实数据模式比对指标:Cosine、MaxAbsErr、MaxRelativeErr、One Thousandth Err Ratio、Five Thousandths Err Ratio |
227
+
228
+ **汇总结果件说明**
229
+
230
+ 多卡数据汇总结果如下所示:
231
+
232
+ ![merge_result](img/merge_result.png)
172
233
 
173
- ### 3.1 比对文件
234
+ 1. NPU Name列表示API或module名称。
235
+ 2. rank*列为多卡数据。
236
+ 3. 不同比对指标的数据通过不同sheet页呈现。
237
+ 4. 如果一个API或module在某张卡上找不到数据,汇总结果中将空白呈现。
238
+
239
+ ## 4 附录
240
+
241
+ ### 4.1 比对文件
174
242
 
175
243
  以在当前目录创建./compare.json为例,单卡场景示例如下:
176
244
 
@@ -184,17 +252,25 @@ msprobe -f mindspore compare -i ./compare.json -o ./output -s
184
252
  }
185
253
  ```
186
254
 
255
+ 多卡场景示例如下:
256
+ ```json
257
+ {
258
+ "npu_path": "./npu_dump/step0", # 需填写到step层级(rank的上一层级)
259
+ "bench_path": "./bench_dump/step0", # 需填写到step层级(rank的上一层级)
260
+ "is_print_compare_log": true
261
+ }
262
+ ```
187
263
 
188
264
  **参数说明**
189
265
 
190
266
  | 参数名 | 说明 | 是否必选 |
191
- | -------------------- | ------------------------------------------------------------ | -------- |
192
- | npu_path | 配置NPU环境下的dump.json文件(单卡场景)。跨框架场景指定为MindSpore的json文件。数据类型:str。 | 是 |
193
- | bench_path | 配置CPU、GPU或NPU环境下的dump.json文件(单卡场景)。 跨框架场景指定为PyTorch的json文件。数据类型:str。 | 是 |
194
- | stack_path | 配置NPU dump目录下的stack.json文件。数据类型:str。 | |
195
- | is_print_compare_log | 配置是否开启单个算子的日志打屏。可取值true或false,默认为true。关闭后则只输出常规日志。数据类型:bool | 否 |
267
+ | -------------------- | ------------------------------------------------------------ |------|
268
+ | npu_path | 配置NPU环境下的dump.json文件(单卡场景)。跨框架场景指定为MindSpore的json文件。数据类型:str。 | 是 |
269
+ | bench_path | 配置CPU、GPU或NPU环境下的dump.json文件(单卡场景)。 跨框架场景指定为PyTorch的json文件。数据类型:str。 | 是 |
270
+ | stack_path | 配置NPU dump目录下的stack.json文件。数据类型:str。 如果没有配置stack_path,命令行-s参数不生效,程序自动识别是否存在stack.json文件,如存在,则比对结果中呈现NPU_Stack_Info,如不存在,则不呈现。如果配置了stack_path,比对结果中是否呈现NPU_Stack_Info则通过命令行参数-s来控制。 | |
271
+ | is_print_compare_log | 配置是否开启单个算子的日志打屏。可取值true或false,默认为true。关闭后则只输出常规日志。数据类型:bool | 否 |
196
272
 
197
- ### 3.2 比对文件(kernel)
273
+ ### 4.2 比对文件(kernel)
198
274
 
199
275
  仅[不同版本下的全量kernel比对](#23-不同版本下的全量kernel比对)场景支持。
200
276
 
@@ -232,19 +308,86 @@ msprobe -f mindspore compare -i ./compare.json -o ./output -s
232
308
  | rank_id | 配置比对的Rank ID。npu_path和bench_path目录下的dump文件需要存在对应Rank的数据。默认为空,表示比对所有Rank。可配置一个或多个Rank,多个Rank ID用逗号隔开,例如:"rank_id": [1,2,3]。数据类型:list[int]。 | 否 |
233
309
  | step_id | 配置比对的Step ID。npu_path和bench_path目录下的dump文件需要存在对应Step的数据。默认为空,表示比对所有Step。可配置一个或多个Step,多个Step ID用逗号隔开,例如:"step_id": [1,2,3]。数据类型:list[int]。 | 否 |
234
310
 
235
- ### 3.3 自定义映射文件(cell
311
+ ### 4.3 自定义映射文件(api_mapping
236
312
 
237
313
  文件名格式:\*.yaml,*为文件名,可自定义。
238
314
 
239
315
  文件内容格式:
240
316
 
241
317
  ```yaml
242
- {cell_name}.{class_name}: {module_name}.{class_name}
318
+ ms_api: {ms_api_name}
319
+ pt_api: {pt_api_name}
320
+ ms_args:
321
+ - {index1}
322
+ - {index2}
323
+ ...
324
+ - {indexN}
325
+ pt_args:
326
+ - {index1}
327
+ - {index2}
328
+ ...
329
+ - {indexN}
330
+ ms_outputs:
331
+ - {index1}
332
+ - {index2}
333
+ ...
334
+ - {indexN}
335
+ pt_outputs:
336
+ - {index1}
337
+ - {index2}
338
+ ...
339
+ - {indexN}
243
340
  ```
244
341
 
245
- 冒号左侧为MindSpore框架cell模块的{cell_name}.{class_name},冒号右侧为PyTorch框架module模块的{module_name}.{class_name}。
342
+ - ms_api/pt_api:分别为MindSpore和PyTorch框架的API名称,配置格式为{api_type}.{api_name}。API名称请分别从《[MindSpore 场景的精度数据采集](./06.data_dump_MindSpore.md)》和《[PyTorch 场景的精度数据采集](./05.data_dump_PyTorch.md)》中的dump.json文件获取。
343
+ - ms_args/pt_args:分别为ms_api/pt_api对应的MindSpore和PyTorch框架API的入参的序号。
344
+ - ms_outputs/pt_outputs:分别为ms_api/pt_api对应的MindSpore和PyTorch框架API的输出的序号。
345
+
346
+ **说明**:
347
+
348
+ - MindSpore和PyTorch框架的API映射关系可以从《[PyTorch与MindSpore API映射表](https://www.mindspore.cn/docs/zh-CN/r2.3.0rc2/note/api_mapping/pytorch_api_mapping.html)》获取,其中PyTorch与MindSpore API名称前缀的映射关系如下:
349
+
350
+ | PyTorch | PyTorch在dump文件中的名称 | MindSpore | MindSpore在dump文件中的名称 |
351
+ | ------------------- | ------------------------- | ---------------- | --------------------------- |
352
+ | torch.nn.functional | Functional | mindspore.ops | Functional |
353
+ | torch.Tensor | Tensor | mindspore.Tensor | Tensor |
354
+ | torch | Torch | mindspore.ops | Functional |
355
+
356
+ 实际配置自定义映射文件(API)时需要使用dump文件中的名称。
357
+
358
+ - 自定义映射文件(API)需要满足ms_args/pt_args列表中的元素个数一致,ms_outputs/pt_outputs相同。
359
+
360
+ - 须确保列表自定义映射文件(API)配置元素的合法性,比如ms_args/pt_args的API用到的参数只有3个参数,那么用户实际指定的参数序号只能包含0、1、2;另外参数序号列表中的值不能重复。
361
+
362
+ 文件内容示例:
363
+
364
+ ```yaml
365
+ ms_api: Functional.abs
366
+ pt_api: Torch.abs
367
+ ms_args:
368
+ - 0
369
+ - 1
370
+ pt_args:
371
+ - 0
372
+ - 1
373
+ ms_outputs:
374
+ - 0
375
+ - 1
376
+ pt_outputs:
377
+ - 0
378
+ - 1
379
+ # ms_args/pt_args和ms_outputs/pt_outputs参数的配置需要根据ms_api/pt_api的API入参和输出的顺序,例如Functional.abs API的入参为(a b c),那对应的ms_args为0 1 2,可根据实际需要选择,而Torch.abs的入参如果是(a b c),那么ms_args和pt_args配置一致即可,但如果Torch.abs的入参如果是(a c)或其他与Functional.abs不完全映射的值,那么ms_args和pt_args配置的序号需要与入参对应,Torch.abs(a c)的序号为0 1,Functional.abs(a b c)为0 1 2,只有a和c参数可以映射,那么ms_args配置为0 2,pt_args配置为0 1。ms_outputs/pt_outputs同理。
380
+ ```
381
+
382
+ ### 4.4 自定义映射文件(cell_mapping)
383
+
384
+ 文件名格式:\*.yaml,*为文件名,可自定义。
385
+
386
+ 文件内容格式:
246
387
 
247
- {cell_name}.{class_name}从dump cell模块级.npy文件名获取,命名格式为:`{Cell}.{cell_name}.{class_name}.{前向反向}.{index}.{input/output}.{参数序号}`
388
+ ```yaml
389
+ {cell_name}.{class_name}: {module_name}.{class_name}
390
+ ```
248
391
 
249
392
  文件内容示例:
250
393
 
@@ -253,7 +396,21 @@ fc2.Dense: fc2.Linear
253
396
  conv1.Conv2d: conv3.Conv2d
254
397
  ```
255
398
 
256
- ### 3.4 自定义映射文件(API和模块)
399
+ 冒号左侧为MindSpore框架cell模块的{cell_name}.{class_name},冒号右侧为PyTorch框架module模块的{module_name}.{class_name}。
400
+
401
+ ```yaml
402
+ {cell_name}.{class_name}从dump cell模块级.npy文件名获取,命名格式为:
403
+ {Cell}.{cell_name}.{class_name}.{forward/backward}.{index}.{input/output}.{参数序号/参数名}
404
+
405
+ {Cell}.{cell_name}.{class_name}.parameters_grad.{parameter_name}
406
+
407
+ {module_name}.{class_name}从dump module模块级.npy文件名获取,命名格式为:
408
+ {Module}.{module_name}.{class_name}.{forward/backward}.{index}.{input/output}.{参数序号/参数名}
409
+
410
+ {Module}.{module_name}.{class_name}.parameters_grad.{parameter_name}
411
+ ```
412
+
413
+ ### 4.5 自定义映射文件(data_mapping)
257
414
 
258
415
  文件名格式:\*.yaml,*为文件名,可自定义。
259
416
 
@@ -261,9 +418,11 @@ conv1.Conv2d: conv3.Conv2d
261
418
 
262
419
  ```yaml
263
420
  # API
264
- {api_type}.{api_name}.{API调用次数}.{前向反向}.{input/output}.{参数序号}: {api_type}.{api_name}.{API调用次数}.{前向反向}.{input/output}.{参数序号}
421
+ {api_type}.{api_name}.{API调用次数}.{forward/backward}.{input/output}.{参数序号/参数名}: {api_type}.{api_name}.{API调用次数}.{forward/backward}.{input/output}.{参数序号/参数名}
265
422
  # 模块
266
- {Cell}.{cell_name}.{class_name}.{前向反向}.{index}.{input/output}.{参数序号}: {Module}.{module_name}.{前向反向}.{index}.{input/output}.{参数序号}
423
+ {Cell}.{cell_name}.{class_name}.{forward/backward}.{index}.{input/output}.{参数序号/参数名}: {Module}.{module_name}.{class_name}.{forward/backward}.{index}.{input/output}.{参数序号/参数名}
424
+
425
+ {Cell}.{cell_name}.{class_name}.parameters_grad.{parameter_name}: {Module}.{module_name}.{class_name}.parameters_grad.{parameter_name}
267
426
  ```
268
427
 
269
428
  冒号左侧为MindSpore框架API的名称和Cell模块的名称,冒号右侧为PyTorch框架API的名称和module模块名称。
@@ -277,9 +436,11 @@ API和模块名称请分别从《[MindSpore 场景的精度数据采集](./06.da
277
436
  Functional.flash_attention_score.4.forward.input.0: NPU.npu_fusion_attention.4.forward.input.0
278
437
  # 模块
279
438
  Cell.relu.ReLU.forward.0.input.0: Module.module.language_model.embedding.word_embedding.VocabParallelEmbedding.forward.0.input.0
439
+
440
+ Cell.relu.ReLU.parameters_grad.weight: Module.module.language_model.embedding.word_embedding.VocabParallelEmbedding.parameters_grad.weight
280
441
  ```
281
442
 
282
- API和模块名称在dump.json文件中的“data_name”字段展示,如下图红框处所示:
443
+ dump.json文件中存在“data_name”字段时,API和模块名称为data_name字段去掉文件后缀,如下图红框处所示:
283
444
 
284
445
  - MindSpore dump
285
446
 
@@ -289,7 +450,145 @@ API和模块名称在dump.json文件中的“data_name”字段展示,如下
289
450
 
290
451
  ![pt_dump](./img/pt_dump.png)
291
452
 
292
- ### 3.5 自定义映射文件(Layer)
453
+ 当dump.json文件中不存在“data_name”字段时,名称的拼写规则如下:
454
+
455
+ input_args、input_kwargs和output使用统一的命名规则,当值是list类型时,名称后面添加'.{index}',当值类型是dict类型时,名称后面加'.{key}',当值类型是具体Tensor或null或空list/dict时,命名结束。
456
+
457
+ 以下面cell的dump文件为例:
458
+ ```yaml
459
+ "Cell.network.module.NetworkWithLoss.forward.0": {
460
+ "input_args": [
461
+ {
462
+ "type": "mindspore.Tensor",
463
+ "dtype": "Float32",
464
+ "shape": [
465
+ 24,
466
+ 16,
467
+ 1,
468
+ 60,
469
+ 34
470
+ ],
471
+ "Max": 3.591925621032715,
472
+ "Min": -3.6856653690338135,
473
+ "Mean": -0.017044123262166977,
474
+ "Norm": 940.671630859375,
475
+ "md5": "00d69ba8"
476
+ },
477
+ {
478
+ "y": {
479
+ "type": "mindspore.Tensor",
480
+ "dtype": "Float32",
481
+ "shape": [
482
+ 24,
483
+ 1,
484
+ 100,
485
+ 4096
486
+ ],
487
+ "Max": 2.433350086212158,
488
+ "Min": -4.09375,
489
+ "Mean": -0.00010696164099499583,
490
+ "Norm": 170.3390655517578,
491
+ "md5": "a72e1fa4"
492
+ },
493
+ "y_mask": {
494
+ "type": "mindspore.Tensor",
495
+ "dtype": "Float32",
496
+ "shape": [
497
+ 24,
498
+ 100
499
+ ],
500
+ "Max": 1.0,
501
+ "Min": 0.0,
502
+ "Mean": 0.22999998927116394,
503
+ "Norm": 23.494680404663086,
504
+ "md5": "bbcbd5ab"
505
+ },
506
+ "x_mask": {
507
+ "type": "mindspore.Tensor",
508
+ "dtype": "Float32",
509
+ "shape": [
510
+ 24,
511
+ 510
512
+ ],
513
+ "Max": 1.0,
514
+ "Min": 1.0,
515
+ "Mean": 1.0,
516
+ "Norm": 110.63453674316406,
517
+ "md5": "766d1028"
518
+ },
519
+ "loss_mask": {
520
+ "type": "mindspore.Tensor",
521
+ "dtype": "Float32",
522
+ "shape": [
523
+ 24,
524
+ 1,
525
+ 60,
526
+ 34
527
+ ],
528
+ "Max": 1.0,
529
+ "Min": 1.0,
530
+ "Mean": 1.0,
531
+ "Norm": 221.26907348632812,
532
+ "md5": "0cb690ce"
533
+ },
534
+ "data_info": {
535
+ "img_hw": null
536
+ }
537
+ }
538
+ ],
539
+ "input_kwargs": {},
540
+ "output": [
541
+ {
542
+ "type": "mindspore.Tensor",
543
+ "dtype": "Float32",
544
+ "shape": [],
545
+ "Max": 0.3672327995300293,
546
+ "Min": 0.3672327995300293,
547
+ "Mean": 0.3672327995300293,
548
+ "Norm": 0.3672327995300293,
549
+ "md5": "28f8f74f"
550
+ }
551
+ ]
552
+ }
553
+ ```
554
+ ,
555
+ 初始名称为`Cell.network.module.NetworkWithLoss.forward.0`,`input_args`是`list`,长度为2,按照顺序命名为
556
+ ```
557
+ Cell.network.module.NetworkWithLoss.forward.0.input.0
558
+ Cell.network.module.NetworkWithLoss.forward.0.input.1
559
+ ```
560
+ 第0项后面直接是`Tensor`,命名结束
561
+ 第1项后面是`dict`,key包括`y`、`y_mask`、`x_mask`和`data_info`,命名为
562
+ ```
563
+ Cell.network.module.NetworkWithLoss.forward.0.input.1.y
564
+ Cell.network.module.NetworkWithLoss.forward.0.input.1.y_mask
565
+ Cell.network.module.NetworkWithLoss.forward.0.input.1.x_mask
566
+ Cell.network.module.NetworkWithLoss.forward.0.input.1.data_info
567
+ ```
568
+ `y`后面是`Tensor`,命名结束;`y_mask`后面是`Tensor`,命名结束;`x_mask`后面是`Tensor`,命名结束;`data_info`后面是`dict`,key是`img_hw`,命名为
569
+ ```
570
+ Cell.network.module.NetworkWithLoss.forward.0.input.1.data_info.img_hw
571
+ ```
572
+ `img_hw`后面是`null`,命名结束。
573
+
574
+ `input_kwargs`是`dict`,长度为0,命名结束。
575
+ `output`是`list`,长度为1,按照顺序命名为
576
+ ```
577
+ Cell.network.module.NetworkWithLoss.forward.0.output.0
578
+ ```
579
+ 第0项后面是`Tensor`,命名结束。
580
+
581
+ 综上,生成的op_name为:
582
+ ```
583
+ Cell.network.module.NetworkWithLoss.forward.0.input.0
584
+ Cell.network.module.NetworkWithLoss.forward.0.input.1.y
585
+ Cell.network.module.NetworkWithLoss.forward.0.input.1.y_mask
586
+ Cell.network.module.NetworkWithLoss.forward.0.input.1.x_mask
587
+ Cell.network.module.NetworkWithLoss.forward.0.input.1.data_info.img_hw
588
+ Cell.network.module.NetworkWithLoss.forward.0.output.0
589
+ ```
590
+
591
+ ### 4.6 自定义映射文件(Layer_mapping)
293
592
 
294
593
  文件名格式:\*.yaml,*为文件名,可自定义。
295
594
 
@@ -315,13 +614,6 @@ PipelineCell:
315
614
 
316
615
  Cell:
317
616
  network_with_loss: module
318
-
319
- layers: # 手动映射MindSpore与PyTorch模型代码中的Layer层序号
320
- '5': '0'
321
- '6': '1'
322
- '7': '2'
323
- '8': '3'
324
- '9': '4'
325
617
  ```
326
618
 
327
619
  Layer层名称需要从模型代码中获取。
@@ -330,4 +622,4 @@ yaml文件中只需配置MindSpore与PyTorch模型代码中功能一致但名称
330
622
 
331
623
  模型代码示例:
332
624
 
333
- ![ms_dump](./img/ms_layer.png)
625
+ ![ms_dump](./img/ms_layer.png)
@@ -26,7 +26,7 @@ msprobe 工具在 PyTorch 场景下提供溢出数据采集功能和溢出数据
26
26
 
27
27
  ### 1.5 其他说明
28
28
 
29
- 溢出数据采集功能在昇腾 NPU 上支持饱和模式和 INF/NAN 模式。INF/NAN 模式遵循 IEEE 754 标准,根据定义输出 INF/NAN 的计算结果。与之对应的饱和模式在计算出现溢出时,饱和为浮点数极值(+-MAX)。对于 CANN 侧配置,Atlas 训练系列产品(如 910A),默认为饱和模式,且不建议使用 INF/NAN 模式;Atlas A2 训练系列产品(如 910B),默认为 INF/NAN 模式,且不建议使用饱和模式。
29
+ 溢出数据采集功能在昇腾 NPU 上支持饱和模式和 INF/NAN 模式。INF/NAN 模式遵循 IEEE 754 标准,根据定义输出 INF/NAN 的计算结果。与之对应的饱和模式在计算出现溢出时,饱和为浮点数极值(+-MAX)。对于 CANN 侧配置,Atlas 训练系列产品,默认为饱和模式,且不建议使用 INF/NAN 模式;Atlas A2 训练系列产品,默认为 INF/NAN 模式,且不建议使用饱和模式。
30
30
 
31
31
  INF/NAN 模式的使能方式如下:
32
32
 
@@ -53,7 +53,7 @@ export INF_NAN_MODE_ENABLE=1
53
53
  2. 执行溢出 API 解析操作。
54
54
 
55
55
  ```bash
56
- msprobe -f pytorch run_overflow_check -api_info ./dump.json
56
+ msprobe -f pytorch run_overflow_check -api_info ./dump_path/step{step_number}/rank{rank_number}/dump.json
57
57
  ```
58
58
 
59
59
  | 参数名称 | 说明 | 是否必选 |
@@ -1,8 +1,8 @@
1
1
  # MindSpore 场景的溢出检测
2
2
 
3
- msprobe 工具提供静态图O2编译等级下的过程溢出检测与动态图场景下的结果溢出检测。其中前者检测对象为 kernel 级别,对应 config.json 配置中的 "L2" level,后者检测对象为 API 级别(支持的API类型为ops、Tensor、mint和mint.nn.functional,不支持Primitive和Jit类API),对应 config.json 配置中的 "L1" level。
3
+ msprobe 工具提供静态图O2编译等级下与动态图场景下的溢出检测功能。其中前者检测对象为 **kernel** 级别,对应 config.json 配置中的 **"L2"** level,后者检测对象为 **API** 级别(支持的API类型为ops、Tensor、mint和mint.nn.functional,不支持Primitive和Jit类API) **cell** 级别,分别对应 config.json 配置中的 **"L1"** 、**"L0"** level。
4
4
 
5
- 需要注意,动态图场景下的溢出检测功能仅支持 INF/NAN 模式<sup>a</sup>。INF/NAN 模式的使能方式如下:
5
+ 需要注意,本工具仅支持在 INF/NAN 模式<sup>a</sup>下进行溢出检测。INF/NAN 模式的使能方式如下:
6
6
 
7
7
  ```Shell
8
8
  # 使能 CANN 侧 INF/NAN 模式
@@ -11,21 +11,21 @@ export INF_NAN_MODE_ENABLE=1
11
11
  export MS_ASCEND_CHECK_OVERFLOW_MODE="INFNAN_MODE"
12
12
  ```
13
13
 
14
- **a**:INF/NAN 模式遵循 IEEE 754 标准,根据定义输出 INF/NAN 的计算结果。与之对应的饱和模式在计算出现溢出时,饱和为浮点数极值(+-MAX)。对于 CANN 侧配置,Atlas 训练系列产品(如 910A),默认为饱和模式,且不建议使用 INF/NAN 模式;Atlas A2训练系列产品(如 910B),默认为 INF/NAN 模式,且不建议使用饱和模式。对于 MindSpore 框架侧配置,仅支持对 Atlas A2 训练系列产品进行设置,默认为 INF/NAN 模式。CANN 侧 与 MindSpore 框架侧配置须一致。
14
+ **a**:在处理浮点数计算溢出问题时,NPU 当前支持两种溢出模式:INF/NAN 模式与饱和模式。INF/NAN 模式遵循 IEEE 754 标准,根据定义输出 INF/NAN 的计算结果。与之对应的饱和模式在计算出现溢出时,饱和为浮点数极值(+-MAX)。对于 CANN 侧配置,Atlas 训练系列产品,默认为饱和模式,且不建议使用 INF/NAN 模式;Atlas A2训练系列产品,默认为 INF/NAN 模式,且不建议使用饱和模式。对于 MindSpore 框架侧配置,仅支持对 Atlas A2 训练系列产品进行设置,默认为 INF/NAN 模式。CANN 侧 与 MindSpore 框架侧配置须一致。
15
15
 
16
16
  溢出检测任务的配置示例见[MindSpore 静态图场景下 task 配置为 overflow_check](https://gitee.com/ascend/mstt/blob/master/debug/accuracy_tools/msprobe/docs/03.config_examples.md#23-task-%E9%85%8D%E7%BD%AE%E4%B8%BA-overflow_check)、[MindSpore 动态图场景下 task 配置为 overflow_check](https://gitee.com/ascend/mstt/blob/master/debug/accuracy_tools/msprobe/docs/03.config_examples.md#33-task-%E9%85%8D%E7%BD%AE%E4%B8%BA-overflow_check)。
17
17
 
18
18
 
19
19
  ## 1 接口介绍
20
20
 
21
- 溢出检测功能提供的接口与数据采集任务一致,详见[MindSpore 场景的精度数据采集](./06.data_dump_MindSpore.md)中的"**1 接口介绍**"章节。
21
+ 溢出检测功能提供的接口与数据采集任务一致,详见MindSpore 场景的精度数据采集中的["**1 接口介绍**"](./06.data_dump_MindSpore.md#1-接口介绍)章节。
22
22
 
23
23
  需要注意,目前暂不支持动态图 "L1" level 下 primitive op 的溢出检测。
24
24
 
25
25
  ## 2 示例代码
26
26
 
27
- 溢出检测功能使用方式与数据采集任务一致,详见[MindSpore 场景的精度数据采集](./06.data_dump_MindSpore.md)中的"**2 示例代码**"章节。
27
+ 溢出检测功能使用方式与数据采集任务一致,详见MindSpore 场景的精度数据采集中的["**2 示例代码**"](./06.data_dump_MindSpore.md#2-示例代码)节。
28
28
 
29
29
  ## 3 溢出检测结果文件介绍
30
30
 
31
- 溢出检测结果文件目录结构与含义与数据采集任务一致,详见[MindSpore 场景的精度数据采集](./06.data_dump_MindSpore.md)中的"**3 dump 结果文件介绍**"章节。
31
+ 溢出检测结果文件目录结构与含义与数据采集任务一致,但仅保存溢出 API 或 kernel 的真实数据或统计信息。详见MindSpore 场景的精度数据采集中的["**3 dump 结果文件介绍**"](./06.data_dump_MindSpore.md#3-dump-结果文件介绍)章节。
@@ -64,8 +64,6 @@ D-->config.json配置
64
64
  "rank": [],
65
65
  "step": [],
66
66
  "level": "L1",
67
- "seed": 1234,
68
- "is_deterministic": false,
69
67
 
70
68
  "free_benchmark": {
71
69
  "scope": [],
@@ -98,14 +96,15 @@ D-->config.json配置
98
96
  <tr><th>参数</th><th>是否必选</th><th>可配置项</th><th>适用场景</th></tr>
99
97
  <tr><td rowspan="6">pert_mode</td><td rowspan="6">否</td><td>"improve_precision" (默认)</td><td>(常用)(可做验证) 插桩算子可能在<b>低精度</b>下有精度问题,扰动因子会将输入的低精度向量升精度。</td></tr>
100
98
  <tr><td>"bit_noise"</td><td>(常用)插桩算子可能在<b>轻微扰动</b>下暴露精度问题,扰动因子会将输入向量最后一个比特位翻转。</td></tr>
101
- <tr><td>"add_noise"</td><td>插桩算子可能在<b>轻微扰动</b>下暴露精度问题,扰动因子会为输入向量增加一个极小。</td></tr>
102
- <tr><td>"change_value"</td><td>插桩算子可能存在<b>大数吃小数</b>问题,扰动因子会交换输入向量的首尾。</td></tr>
103
- <tr><td>"no_change"</td><td>插桩算子可能存在<b>数值稳定性</b>精度问题,扰动因子会复制原始输。</td></tr>
99
+ <tr><td>"add_noise"</td><td>插桩算子可能在<b>轻微扰动</b>下暴露精度问题,扰动因子会为输入向量增加一个极小值。</td></tr>
100
+ <tr><td>"change_value"</td><td>插桩算子可能存在<b>大数吃小数</b>问题,扰动因子会交换输入向量的首尾值。</td></tr>
101
+ <tr><td>"no_change"</td><td>插桩算子可能存在<b>数值稳定性</b>精度问题,扰动因子会复制原始输入。</td></tr>
104
102
  <tr><td>"to_cpu"</td><td>(可做验证) 插桩算子可能在<b>同 CPU </b>精度表现不一致,扰动因子会将输入转至 CPU,需要配合 fuzz_device="cpu"使用。</td></tr>
105
103
  <tr><td rowspan="2">fuzz_device</td><td rowspan="2">否</td><td>"npu" (默认)</td><td>pert_mode 不需要to cpu操作。</td></tr>
106
104
  <tr><td>"cpu"</td><td>pert_mode 须配置为"to_cpu",目前仅支持"to cpu"扰动因子。</td></tr>
107
105
  </table>
108
106
 
107
+
109
108
  #### 3.2.3 选择处理方式
110
109
 
111
110
  <table>