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
@@ -0,0 +1,29 @@
1
+ # msprobe 工具功能模块简介、适用场景和当前版本局限性
2
+
3
+ ## 1 PyTorch框架
4
+
5
+ | 功能名(英文) | 简介 | 适用场景/优势 | 当前版本局限性 |
6
+ |------------------------------------------------------------------------------------|---------------------------------------------------------------|--------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|
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
+
20
+ ## 2 MindSpore框架
21
+
22
+ | 功能名(英文) | 简介 | 适用场景/优势 | 当前版本局限性 |
23
+ |----------------------------------------------------------------------|-------------------------------------------------------------------|------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
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、当模型规模较大时,比对所需时间较长 |
@@ -0,0 +1,37 @@
1
+ # PyTorch 场景的精度数据采集基线
2
+
3
+ ## "tensor"模式采集数据量参考基线
4
+
5
+ 该基线为pytorch框架下,使用"tensor"模式采集数据量参考基线。本基线测试了两个模型,分别为LLAMA2-7B和LLAMA2-13B,测试了不同采集模式下,不同global_batch_size下,单卡和8卡下,数据量的变化。
6
+
7
+ ### LLAMA2-7B
8
+
9
+ <table>
10
+ <tr><th>采集模式</th><th>global_batch_size</th><th>单卡</th><th>8卡</th></tr>
11
+ </td><td rowspan="3">L0</td><td>1</td><td>7.8GB</td><td>63GB</td></tr>
12
+ <tr><td>2</td><td>16GB</td><td>125GB</td></tr>
13
+ <tr><td>3</td><td>24GB</td><td>187GB</td></tr>
14
+ </td><td rowspan="3">L1</td><td>1</td><td>300.8GB</td><td>2.3TB</td></tr>
15
+ <tr><td>2</td><td>480GB</td><td>3.6TB</td></tr>
16
+ <tr><td>3</td><td>640GB</td><td>4.9TB</td></tr>
17
+ </td><td rowspan="3">mix</td><td>1</td><td>313.6GB</td><td>2.4TB</td></tr>
18
+ <tr><td>2</td><td>512GB</td><td>3.8TB</td></tr>
19
+ <tr><td>3</td><td>672GB</td><td>5.1TB</td></tr>
20
+
21
+ </table>
22
+
23
+ ### LLAMA2-13B
24
+
25
+ <table>
26
+ <tr><th>采集模式</th><th>global_batch_size</th><th>单卡</th><th>8卡</th></tr>
27
+ </td><td rowspan="3">L0</td><td>1</td><td>13GB</td><td>97GB</td></tr>
28
+ <tr><td>2</td><td>25B</td><td>194GB</td></tr>
29
+ <tr><td>3</td><td>37G</td><td>291GB</td></tr>
30
+ </td><td rowspan="3">L1</td><td>1</td><td>440GB</td><td>3.4TB</td></tr>
31
+ <tr><td>2</td><td>720GB</td><td>5.4TB</td></tr>
32
+ <tr><td>3</td><td>960GB</td><td>7.3TB</td></tr>
33
+ </td><td rowspan="3">mix</td><td>1</td><td>480GB</td><td>3.6TB</td></tr>
34
+ <tr><td>2</td><td>720GB</td><td>5.6TB</td></tr>
35
+ <tr><td>3</td><td>1000GB</td><td>7.7TB</td></tr>
36
+
37
+ </table>
@@ -0,0 +1,521 @@
1
+ # dump.json文件说明及示例
2
+
3
+ ## 1. dump.json文件介绍(Pytorch)
4
+
5
+ ### 1.1 L0级别
6
+ L0级别的dump.json文件包括模块的前反向的输入输出,以及模块的参数和参数梯度。以Pytorch的Conv2d模块为例,网络中模块调用代码为:
7
+ `output = torch.nn.Conv2d(64, 128, 5, padding=2, bias=True)(input)`
8
+
9
+ dump.json文件中包含以下字段:
10
+
11
+ 1. `Module.conv2.Conv2d.forward.0`为模块的前向数据,其中input_args为模块的输入数据(位置参数),input_kwargs为模块的输入数据(关键字参数),output为模块的输出数据,parameters为模块的参数数据,包括权重(weight)和偏置(bias)。
12
+ 2. `Module.conv2.Conv2d.parameters_grad`为模块的参数梯度数据,包括权重(weight)和偏置(bias)的梯度。
13
+ 3. `Module.conv2.Conv2d.backward.0`为模块的反向数据,其中input为模块反向的输入梯度(对应前向输出的梯度),output为模块的反向输出梯度(对应前向输入的梯度)。
14
+
15
+ ```json
16
+ {
17
+ "task": "tensor",
18
+ "level": "L0",
19
+ "framework": "pytorch",
20
+ "dump_data_dir": "/dump/path",
21
+ "data": {
22
+ "Module.conv2.Conv2d.forward.0": {
23
+ "input_args": [
24
+ {
25
+ "type": "torch.Tensor",
26
+ "dtype": "torch.float32",
27
+ "shape": [
28
+ 8,
29
+ 16,
30
+ 14,
31
+ 14
32
+ ],
33
+ "Max": 1.638758659362793,
34
+ "Min": 0.0,
35
+ "Mean": 0.2544615864753723,
36
+ "Norm": 70.50277709960938,
37
+ "requires_grad": true,
38
+ "data_name": "Module.conv2.Conv2d.forward.0.input.0.pt"
39
+ }
40
+ ],
41
+ "input_kwargs": {},
42
+ "output": [
43
+ {
44
+ "type": "torch.Tensor",
45
+ "dtype": "torch.float32",
46
+ "shape": [
47
+ 8,
48
+ 32,
49
+ 10,
50
+ 10
51
+ ],
52
+ "Max": 1.6815717220306396,
53
+ "Min": -1.5120246410369873,
54
+ "Mean": -0.025344856083393097,
55
+ "Norm": 149.65576171875,
56
+ "requires_grad": true,
57
+ "data_name": "Module.conv2.Conv2d.forward.0.output.0.pt"
58
+ }
59
+ ],
60
+ "parameters": {
61
+ "weight": {
62
+ "type": "torch.Tensor",
63
+ "dtype": "torch.float32",
64
+ "shape": [
65
+ 32,
66
+ 16,
67
+ 5,
68
+ 5
69
+ ],
70
+ "Max": 0.05992485210299492,
71
+ "Min": -0.05999220535159111,
72
+ "Mean": -0.0006165213999338448,
73
+ "Norm": 3.421217441558838,
74
+ "requires_grad": true,
75
+ "data_name": "Module.conv2.Conv2d.forward.0.parameters.weight.pt"
76
+ },
77
+ "bias": {
78
+ "type": "torch.Tensor",
79
+ "dtype": "torch.float32",
80
+ "shape": [
81
+ 32
82
+ ],
83
+ "Max": 0.05744686722755432,
84
+ "Min": -0.04894155263900757,
85
+ "Mean": 0.006410328671336174,
86
+ "Norm": 0.17263513803482056,
87
+ "requires_grad": true,
88
+ "data_name": "Module.conv2.Conv2d.forward.0.parameters.bias.pt"
89
+ }
90
+ }
91
+ },
92
+ "Module.conv2.Conv2d.parameters_grad": {
93
+ "weight": [
94
+ {
95
+ "type": "torch.Tensor",
96
+ "dtype": "torch.float32",
97
+ "shape": [
98
+ 32,
99
+ 16,
100
+ 5,
101
+ 5
102
+ ],
103
+ "Max": 0.018550323322415352,
104
+ "Min": -0.008627401664853096,
105
+ "Mean": 0.0006675920449197292,
106
+ "Norm": 0.26084786653518677,
107
+ "requires_grad": false,
108
+ "data_name": "Module.conv2.Conv2d.parameters_grad.weight.pt"
109
+ }
110
+ ],
111
+ "bias": [
112
+ {
113
+ "type": "torch.Tensor",
114
+ "dtype": "torch.float32",
115
+ "shape": [
116
+ 32
117
+ ],
118
+ "Max": 0.014914230443537235,
119
+ "Min": -0.006656786892563105,
120
+ "Mean": 0.002657240955159068,
121
+ "Norm": 0.029451673850417137,
122
+ "requires_grad": false,
123
+ "data_name": "Module.conv2.Conv2d.parameters_grad.bias.pt"
124
+ }
125
+ ]
126
+ },
127
+ "Module.conv2.Conv2d.backward.0": {
128
+ "input": [
129
+ {
130
+ "type": "torch.Tensor",
131
+ "dtype": "torch.float32",
132
+ "shape": [
133
+ 8,
134
+ 32,
135
+ 10,
136
+ 10
137
+ ],
138
+ "Max": 0.0015069986693561077,
139
+ "Min": -0.001139344065450132,
140
+ "Mean": 3.3215508210560074e-06,
141
+ "Norm": 0.020567523315548897,
142
+ "requires_grad": false,
143
+ "data_name": "Module.conv2.Conv2d.backward.0.input.0.pt"
144
+ }
145
+ ],
146
+ "output": [
147
+ {
148
+ "type": "torch.Tensor",
149
+ "dtype": "torch.float32",
150
+ "shape": [
151
+ 8,
152
+ 16,
153
+ 14,
154
+ 14
155
+ ],
156
+ "Max": 0.0007466732058674097,
157
+ "Min": -0.00044813455315306783,
158
+ "Mean": 6.814070275140693e-06,
159
+ "Norm": 0.01474067009985447,
160
+ "requires_grad": false,
161
+ "data_name": "Module.conv2.Conv2d.backward.0.output.0.pt"
162
+ }
163
+ ]
164
+ }
165
+ }
166
+ }
167
+ ```
168
+
169
+ ### 1.2 L1级别
170
+ L1级别的dump.json文件包括API的前反向的输入输出。以Pytorch的relu函数为例,网络中API调用代码为:
171
+ `output = torch.nn.functional.relu(input)`
172
+
173
+ dump.json文件中包含以下字段:
174
+ 1. `Functional.relu.0.forward`为API的前向数据,其中input_args为API的输入数据(位置参数),input_kwargs为API的输入数据(关键字参数),output为API的输出数据。
175
+ 2. `Functional.relu.0.backward`为API的反向数据,其中input为API的反向输入梯度(对应前向输出的梯度),output为API的反向输出梯度(对应前向输入的梯度)。
176
+
177
+ ```json
178
+ {
179
+ "task": "tensor",
180
+ "level": "L1",
181
+ "framework": "pytorch",
182
+ "dump_data_dir":"/dump/path",
183
+ "data": {
184
+ "Functional.relu.0.forward": {
185
+ "input_args": [
186
+ {
187
+ "type": "torch.Tensor",
188
+ "dtype": "torch.float32",
189
+ "shape": [
190
+ 32,
191
+ 16,
192
+ 28,
193
+ 28
194
+ ],
195
+ "Max": 1.3864083290100098,
196
+ "Min": -1.3364859819412231,
197
+ "Mean": 0.03711778670549393,
198
+ "Norm": 236.20692443847656,
199
+ "requires_grad": true,
200
+ "data_name": "Functional.relu.0.forward.input.0.pt"
201
+ }
202
+ ],
203
+ "input_kwargs": {},
204
+ "output": [
205
+ {
206
+ "type": "torch.Tensor",
207
+ "dtype": "torch.float32",
208
+ "shape": [
209
+ 32,
210
+ 16,
211
+ 28,
212
+ 28
213
+ ],
214
+ "Max": 1.3864083290100098,
215
+ "Min": 0.0,
216
+ "Mean": 0.16849493980407715,
217
+ "Norm": 175.23345947265625,
218
+ "requires_grad": true,
219
+ "data_name": "Functional.relu.0.forward.output.0.pt"
220
+ }
221
+ ]
222
+ },
223
+ "Functional.relu.0.backward": {
224
+ "input": [
225
+ {
226
+ "type": "torch.Tensor",
227
+ "dtype": "torch.float32",
228
+ "shape": [
229
+ 32,
230
+ 16,
231
+ 28,
232
+ 28
233
+ ],
234
+ "Max": 0.0001815402356442064,
235
+ "Min": -0.00013352684618439525,
236
+ "Mean": 0.00011915402356442064,
237
+ "Norm": 0.007598237134516239,
238
+ "requires_grad": false,
239
+ "data_name": "Functional.relu.0.backward.input.0.pt"
240
+ }
241
+ ],
242
+ "output": [
243
+ {
244
+ "type": "torch.Tensor",
245
+ "dtype": "torch.float32",
246
+ "shape": [
247
+ 32,
248
+ 16,
249
+ 28,
250
+ 28
251
+ ],
252
+ "Max": 0.0001815402356442064,
253
+ "Min": -0.00012117840378778055,
254
+ "Mean": 2.0098118724831693e-08,
255
+ "Norm": 0.006532244384288788,
256
+ "requires_grad": false,
257
+ "data_name": "Functional.relu.0.backward.output.0.pt"
258
+ }
259
+ ]
260
+ }
261
+ }
262
+ }
263
+ ```
264
+
265
+ ### 1.3 mix级别
266
+
267
+ mix级别的dump.json文件同时包括L0和L1级别的dump数据,文件格式与上述示例相同。
268
+
269
+ ## 2. dump.json文件示例(MindSpore)
270
+
271
+ ### 2.1 L0级别
272
+
273
+ L0级别的dump.json文件包括模块的前反向的输入输出,以及模块的参数和参数梯度。
274
+ 以MindSpore的Conv2d模块为例,dump.json文件中使用的模块调用代码为:
275
+ `output = mindspore.nn.Conv2d(64, 128, 5, pad_mode='same', has_bias=True)(input)`
276
+
277
+ dump.json文件中包含以下字段:
278
+ 1. `Cell.conv2.Conv2d.forward.0`为模块的前向数据,其中input_args为模块的输入数据(位置参数),input_kwargs为模块的输入数据(关键字参数),output为模块的输出数据,parameters为模块的参数数据,包括权重(weight)和偏置(bias)。
279
+ 2. `Cell.conv2.Conv2d.parameters_grad`为模块的参数梯度数据,包括权重(weight)和偏置(bias)的梯度。
280
+ 3. `Cell.conv2.Conv2d.backward.0`为模块的反向数据,其中input为模块反向的输入梯度(对应前向输出的梯度),output为模块的反向输出梯度(对应前向输入的梯度)。
281
+
282
+ ```json
283
+ {
284
+ "task": "tensor",
285
+ "level": "L0",
286
+ "framework": "mindspore",
287
+ "dump_data_dir": "/dump/path",
288
+ "data": {
289
+ "Cell.conv2.Conv2d.forward.0": {
290
+ "input_args": [
291
+ {
292
+ "type": "mindspore.Tensor",
293
+ "dtype": "Float32",
294
+ "shape": [
295
+ 8,
296
+ 16,
297
+ 14,
298
+ 14
299
+ ],
300
+ "Max": 1.638758659362793,
301
+ "Min": 0.0,
302
+ "Mean": 0.2544615864753723,
303
+ "Norm": 70.50277709960938,
304
+ "data_name": "Cell.conv2.Conv2d.forward.0.input.0.npy"
305
+ }
306
+ ],
307
+ "input_kwargs": {},
308
+ "output": [
309
+ {
310
+ "type": "mindspore.Tensor",
311
+ "dtype": "Float32",
312
+ "shape": [
313
+ 8,
314
+ 32,
315
+ 10,
316
+ 10
317
+ ],
318
+ "Max": 1.6815717220306396,
319
+ "Min": -1.5120246410369873,
320
+ "Mean": -0.025344856083393097,
321
+ "Norm": 149.65576171875,
322
+ "data_name": "Cell.conv2.Conv2d.forward.0.output.0.npy"
323
+ }
324
+ ],
325
+ "parameters": {
326
+ "weight": {
327
+ "type": "mindspore.Tensor",
328
+ "dtype": "Float32",
329
+ "shape": [
330
+ 32,
331
+ 16,
332
+ 5,
333
+ 5
334
+ ],
335
+ "Max": 0.05992485210299492,
336
+ "Min": -0.05999220535159111,
337
+ "Mean": -0.0006165213999338448,
338
+ "Norm": 3.421217441558838,
339
+ "data_name": "Cell.conv2.Conv2d.forward.0.parameters.weight.npy"
340
+ },
341
+ "bias": {
342
+ "type": "mindspore.Tensor",
343
+ "dtype": "Float32",
344
+ "shape": [
345
+ 32
346
+ ],
347
+ "Max": 0.05744686722755432,
348
+ "Min": -0.04894155263900757,
349
+ "Mean": 0.006410328671336174,
350
+ "Norm": 0.17263513803482056,
351
+ "data_name": "Cell.conv2.Conv2d.forward.0.parameters.bias.npy"
352
+ }
353
+ }
354
+ },
355
+ "Cell.conv2.Conv2d.parameters_grad": {
356
+ "weight": [
357
+ {
358
+ "type": "mindspore.Tensor",
359
+ "dtype": "Float32",
360
+ "shape": [
361
+ 32,
362
+ 16,
363
+ 5,
364
+ 5
365
+ ],
366
+ "Max": 0.018550323322415352,
367
+ "Min": -0.008627401664853096,
368
+ "Mean": 0.0006675920449197292,
369
+ "Norm": 0.26084786653518677,
370
+ "data_name": "Cell.conv2.Conv2d.parameters_grad.weight.npy"
371
+ }
372
+ ],
373
+ "bias": [
374
+ {
375
+ "type": "mindspore.Tensor",
376
+ "dtype": "Float32",
377
+ "shape": [
378
+ 32
379
+ ],
380
+ "Max": 0.014914230443537235,
381
+ "Min": -0.006656786892563105,
382
+ "Mean": 0.002657240955159068,
383
+ "Norm": 0.029451673850417137,
384
+ "data_name": "Cell.conv2.Conv2d.parameters_grad.bias.npy"
385
+ }
386
+ ]
387
+ },
388
+ "Cell.conv2.Conv2d.backward.0": {
389
+ "input": [
390
+ {
391
+ "type": "mindspore.Tensor",
392
+ "dtype": "Float32",
393
+ "shape": [
394
+ 8,
395
+ 32,
396
+ 10,
397
+ 10
398
+ ],
399
+ "Max": 0.0015069986693561077,
400
+ "Min": -0.001139344065450132,
401
+ "Mean": 3.3215508210560074e-06,
402
+ "Norm": 0.020567523315548897,
403
+ "data_name": "Cell.conv2.Conv2d.backward.0.input.0.npy"
404
+ }
405
+ ],
406
+ "output": [
407
+ {
408
+ "type": "mindspore.Tensor",
409
+ "dtype": "Float32",
410
+ "shape": [
411
+ 8,
412
+ 16,
413
+ 14,
414
+ 14
415
+ ],
416
+ "Max": 0.0007466732058674097,
417
+ "Min": -0.00044813455315306783,
418
+ "Mean": 6.814070275140693e-06,
419
+ "Norm": 0.01474067009985447,
420
+ "data_name": "Cell.conv2.Conv2d.backward.0.output.0.npy"
421
+ }
422
+ ]
423
+ }
424
+ }
425
+ }
426
+ ```
427
+
428
+ ### 2.2 L1级别
429
+ L1级别的dump.json文件包括API的前反向的输入输出,以MindSpore的relu函数为例,网络中API调用代码为:
430
+ `output = mindspore.ops.relu(input)`
431
+
432
+ dump.json文件中包含以下字段:
433
+ 1. `Functional.relu.0.forward`为API的前向数据,其中input_args为API的输入数据(位置参数),input_kwargs为API的输入数据(关键字参数),output为API的输出数据。
434
+ 2. `Functional.relu.0.backward`为API的反向数据,其中input为API的反向输入梯度(对应前向输出的梯度),output为API的反向输出梯度(对应前向输入的梯度)。
435
+
436
+ ```json
437
+ {
438
+ "task": "tensor",
439
+ "level": "L1",
440
+ "framework": "mindspore",
441
+ "dump_data_dir":"/dump/path",
442
+ "data": {
443
+ "Functional.relu.0.forward": {
444
+ "input_args": [
445
+ {
446
+ "type": "mindspore.Tensor",
447
+ "dtype": "Float32",
448
+ "shape": [
449
+ 32,
450
+ 16,
451
+ 28,
452
+ 28
453
+ ],
454
+ "Max": 1.3864083290100098,
455
+ "Min": -1.3364859819412231,
456
+ "Mean": 0.03711778670549393,
457
+ "Norm": 236.20692443847656,
458
+ "data_name": "Functional.relu.0.forward.input.0.npy"
459
+ }
460
+ ],
461
+ "input_kwargs": {},
462
+ "output": [
463
+ {
464
+ "type": "mindspore.Tensor",
465
+ "dtype": "Float32",
466
+ "shape": [
467
+ 32,
468
+ 16,
469
+ 28,
470
+ 28
471
+ ],
472
+ "Max": 1.3864083290100098,
473
+ "Min": 0.0,
474
+ "Mean": 0.16849493980407715,
475
+ "Norm": 175.23345947265625,
476
+ "data_name": "Functional.relu.0.forward.output.0.npy"
477
+ }
478
+ ]
479
+ },
480
+ "Functional.relu.0.backward": {
481
+ "input": [
482
+ {
483
+ "type": "mindspore.Tensor",
484
+ "dtype": "Float32",
485
+ "shape": [
486
+ 32,
487
+ 16,
488
+ 28,
489
+ 28
490
+ ],
491
+ "Max": 0.0001815402356442064,
492
+ "Min": -0.00013352684618439525,
493
+ "Mean": 0.00011915402356442064,
494
+ "Norm": 0.007598237134516239,
495
+ "data_name": "Functional.relu.0.backward.input.0.npy"
496
+ }
497
+ ],
498
+ "output": [
499
+ {
500
+ "type": "mindspore.Tensor",
501
+ "dtype": "Float32",
502
+ "shape": [
503
+ 32,
504
+ 16,
505
+ 28,
506
+ 28
507
+ ],
508
+ "Max": 0.0001815402356442064,
509
+ "Min": -0.00012117840378778055,
510
+ "Mean": 2.0098118724831693e-08,
511
+ "Norm": 0.006532244384288788,
512
+ "data_name": "Functional.relu.0.backward.output.0.npy"
513
+ }
514
+ ]
515
+ }
516
+ }
517
+ }
518
+ ```
519
+
520
+ ### 2.3 mix级别
521
+ mix级别的dump.json文件同时包括L0和L1级别的dump数据,文件格式与上述示例相同。
msprobe/docs/FAQ.md CHANGED
@@ -10,6 +10,32 @@
10
10
  - 输入参数或输出参数类型当前工具不支持,会有日志打印提醒。
11
11
  - 输入或者输出tensor的dtype为bool时,Mean和Norm等字段为null。
12
12
 
13
+ 2. 如果存在namedtuple类型的数据作为nn.Module的输出,工具会将各字段数据dump下来,但是输出数据类型会被转成tuple,原因是什么?
14
+ - 这是由于pytorch框架自身,在注册module的backward hook时,会将namedtuple类型转成tuple类型。
15
+
16
+ 3. 如果某个api在dump支持列表support_wrap_ops.yaml中,但没有dump该api的数据,原因是什么?
17
+ - 首先确认api调用是否在采集范围内,即需要在 **start** 和 **stop** 接口涵盖的范围内。
18
+ - 其次,由于工具只在被调用时才对api进行patch,从而使得数据可以被dump下来。因此当api是被直接import进行调用时,由于该api的地址已经确定,
19
+ 工具无法再对其进行patch,故而该api数据无法被dump下来。如下示例,relu将无法被dump:
20
+ ```python
21
+ import torch
22
+ from torch import relu # 此时relu地址已经确定,无法修改
23
+
24
+ from msprobe.pytorch import PrecisionDebugger
25
+
26
+ debugger = PrecisionDebugger(dump_path="./dump_data")
27
+ x = torch.randn(10)
28
+ debugger.start() # 此时会对torch下面的api进行patch,但已无法对import进来的api进行patch了
29
+ x = relu(x)
30
+ debugger.stop()
31
+ ```
32
+ 在上述场景中,若希望采集relu数据,只需要将`relu(x)`修改为`torch.relu(x)`即可。
33
+
34
+ 4. 在使用L0 dump时,发现有些 module 的数据没有采集下来,原因是什么?
35
+ - 确认日志打印中是否存在`The {module_name} has registered deprecated register_backward_hook`信息,
36
+ 该信息说明 module 挂载了被 PyTorch 框架废弃的 register_backward_hook,这与工具使用的 register_full_backward_hook 接口会产生冲突,故工具会跳过该 module 的反向数据采集。
37
+ - 如果您希望所有 module 数据都能采集下来,可以将模型中使用的 register_backward_hook 接口改为 PyTorch 框架推荐的 register_full_backward_pre_hook 或 register_full_backward_hook 接口。
38
+
13
39
  # 2 精度预检(PyTorch)
14
40
 
15
41
  1. 预检工具在 dump 和 run_ut 的过程中,是否需要同时开启或关闭 jit 编译(jit_compile)?
@@ -180,9 +206,10 @@ def npu_forward_fused_softmax(self, input_, mask):
180
206
 
181
207
  答:注释工具目录 `mstt/debug/accuracy_tools/msprobe/pytorch/hook_module/support_wrap_ops.yaml` 文件中 `Tensor: ` 下的 `- __getitem__`,工具会跳过采集该 API。如果是需要采集关键位置 API 也可以考虑根据报错堆栈信息注释引发报错的类型检查。
182
208
 
183
- 11. 添加 msprobe 工具后 F.gelu 触发 ValueError 报错:`activation_func must be F.gelu` 等。以及采集 Megatron 数据时报错:`ValueError(Only support fusion of gelu and swiglu)`。
209
+ 11. 使用 msprobe 工具数据采集功能后,模型出现报错,报错信息为:`activation_func must be F.gelu` `ValueError(Only support fusion of gelu and swiglu)`。
184
210
 
185
- 答:这一类问题是因为工具本身封装了 torch 算子,所以校验算子名时会报错。注释 `mstt/debug/accuracy_tools/msprobe/pytorch/hook_module/support_wrap_ops.yaml` 文件中的 `-gelu` 或者 `-silu`,工具会跳过采集该 API。如果需要采集关键位置 API 也可以考虑根据报错堆栈信息注释引发报错的类型检查。
211
+ 答:这一类报错常见于 Megatron/MindSpeed/ModelLink 等加速库或模型仓中,原因是工具本身会封装 torch API(API类型和地址会发生改变),而有些 API 在工具使能前类型和地址就已经确定,此时工具无法对这类 API 再进行封装,而加速库中会对某些 API 进行类型检查,即会把工具无法封装的原始的 API和工具封装之后的 API 进行判断,所以会报错。
212
+ 规避方式有3种:①将PrecisionDebugger的实例化放在文件的开始位置,即导包后的位置,确保所有API都被封装;②注释 `mstt/debug/accuracy_tools/msprobe/pytorch/hook_module/support_wrap_ops.yaml` 文件中的 `-gelu` 或者 `-silu`,工具会跳过采集该 API。③ 可以考虑根据报错堆栈信息注释引发报错的类型检查。
186
213
 
187
214
  12. 添加 msprobe 工具后触发与 AsStrided 算子相关、或者编译相关的报错,如:`Failed to compile Op [AsStrided]`。
188
215
 
@@ -0,0 +1,14 @@
1
+ # MindSpore 场景的精度预检基线
2
+
3
+ ## "multi_run_ut"模式精度预检耗时参考基线
4
+
5
+ 该基线为MindSpore框架下,使用"multi_run_ut"模式精度预检耗时参考基线。本基线测试了38B语言大模型在不同卡数下耗时的变化。
6
+
7
+ ### 38B语言大模型
8
+
9
+ | 卡数 | 总耗时 (分钟) | 备注 |
10
+ | ----- |----------|---------- |
11
+ | 1 卡 | 21.0 | 单卡基线 |
12
+ | 2 卡 | 11.5 | 双卡基线 |
13
+ | 4 卡 | 6.7 | 四卡基线 |
14
+ | 8 卡 | 3.5 | 八卡基线 |