mindstudio-probe 1.0.3__py3-none-any.whl → 1.1.0__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.3.dist-info → mindstudio_probe-1.1.0.dist-info}/LICENSE +201 -201
  2. {mindstudio_probe-1.0.3.dist-info → mindstudio_probe-1.1.0.dist-info}/METADATA +36 -34
  3. mindstudio_probe-1.1.0.dist-info/RECORD +287 -0
  4. {mindstudio_probe-1.0.3.dist-info → mindstudio_probe-1.1.0.dist-info}/WHEEL +1 -1
  5. {mindstudio_probe-1.0.3.dist-info → mindstudio_probe-1.1.0.dist-info}/entry_points.txt +1 -0
  6. msprobe/README.md +131 -237
  7. msprobe/__init__.py +16 -1
  8. msprobe/{config/config.json → config.json} +47 -49
  9. msprobe/core/advisor/advisor.py +124 -124
  10. msprobe/core/advisor/advisor_const.py +58 -59
  11. msprobe/core/advisor/advisor_result.py +58 -58
  12. msprobe/core/common/const.py +402 -318
  13. msprobe/core/common/exceptions.py +99 -99
  14. msprobe/core/common/{file_check.py → file_utils.py} +523 -283
  15. msprobe/core/common/inplace_op_checker.py +38 -0
  16. msprobe/core/common/inplace_ops.yaml +251 -0
  17. msprobe/core/common/log.py +86 -69
  18. msprobe/core/common/utils.py +371 -616
  19. msprobe/core/common_config.py +78 -71
  20. msprobe/core/compare/acc_compare.py +472 -298
  21. msprobe/core/compare/check.py +180 -95
  22. msprobe/core/compare/compare_cli.py +69 -49
  23. msprobe/core/compare/highlight.py +259 -222
  24. msprobe/core/compare/multiprocessing_compute.py +174 -149
  25. msprobe/core/compare/npy_compare.py +310 -295
  26. msprobe/core/compare/utils.py +464 -429
  27. msprobe/core/data_dump/data_collector.py +153 -144
  28. msprobe/core/data_dump/data_processor/base.py +337 -293
  29. msprobe/core/data_dump/data_processor/factory.py +76 -59
  30. msprobe/core/data_dump/data_processor/mindspore_processor.py +192 -198
  31. msprobe/core/data_dump/data_processor/pytorch_processor.py +383 -389
  32. msprobe/core/data_dump/json_writer.py +117 -116
  33. msprobe/core/data_dump/scope.py +194 -178
  34. msprobe/core/grad_probe/constant.py +74 -70
  35. msprobe/core/grad_probe/grad_compare.py +170 -175
  36. msprobe/core/grad_probe/utils.py +77 -52
  37. msprobe/docs/01.installation.md +99 -0
  38. msprobe/docs/02.config_introduction.md +137 -0
  39. msprobe/docs/03.config_examples.md +237 -0
  40. msprobe/docs/04.acl_config_examples.md +78 -0
  41. msprobe/docs/05.data_dump_PyTorch.md +326 -0
  42. msprobe/docs/06.data_dump_MindSpore.md +285 -0
  43. msprobe/docs/07.accuracy_checker_PyTorch.md +297 -0
  44. msprobe/docs/08.accuracy_checker_online_PyTorch.md +238 -0
  45. msprobe/docs/09.accuracy_checker_MindSpore.md +68 -0
  46. msprobe/docs/10.accuracy_compare_PyTorch.md +327 -0
  47. msprobe/docs/11.accuracy_compare_MindSpore.md +333 -0
  48. msprobe/docs/12.overflow_check_PyTorch.md +79 -0
  49. msprobe/docs/13.overflow_check_MindSpore.md +31 -0
  50. msprobe/{pytorch/doc/parse_tool.md → docs/14.data_parse_PyTorch.md} +283 -286
  51. msprobe/docs/15.free_benchmarking_PyTorch.md +170 -0
  52. msprobe/docs/16.free_benchmarking_MindSpore.md +140 -0
  53. msprobe/{doc/grad_probe/grad_probe.md → docs/17.grad_probe.md} +205 -207
  54. msprobe/{pytorch/doc//321/205/320/254/320/270/321/207/342/225/221/342/224/220/321/207/342/226/223/342/225/233/321/205/342/225/221/320/266/321/206/320/277/320/244/321/205/320/277/342/225/243.md → docs/18.online_dispatch.md} +89 -90
  55. msprobe/docs/FAQ.md +189 -0
  56. msprobe/docs/S02.report_free_benchmarking_validation_performance_baseline.md +146 -0
  57. msprobe/docs/img/free_benchmark_framework.png +0 -0
  58. msprobe/docs/img/ms_dump.png +0 -0
  59. msprobe/docs/img/ms_layer.png +0 -0
  60. msprobe/docs/img/pt_dump.png +0 -0
  61. msprobe/mindspore/__init__.py +2 -1
  62. msprobe/mindspore/api_accuracy_checker/api_accuracy_checker.py +278 -245
  63. msprobe/mindspore/api_accuracy_checker/api_info.py +76 -69
  64. msprobe/mindspore/api_accuracy_checker/api_runner.py +155 -151
  65. msprobe/mindspore/api_accuracy_checker/base_compare_algorithm.py +196 -196
  66. msprobe/mindspore/api_accuracy_checker/cmd_parser.py +6 -0
  67. msprobe/mindspore/api_accuracy_checker/compute_element.py +238 -223
  68. msprobe/mindspore/api_accuracy_checker/main.py +8 -15
  69. msprobe/mindspore/api_accuracy_checker/type_mapping.py +113 -113
  70. msprobe/mindspore/api_accuracy_checker/utils.py +79 -62
  71. msprobe/mindspore/cell_processor.py +58 -34
  72. msprobe/mindspore/common/const.py +108 -87
  73. msprobe/mindspore/common/log.py +37 -37
  74. msprobe/mindspore/common/utils.py +97 -57
  75. msprobe/mindspore/compare/distributed_compare.py +62 -75
  76. msprobe/mindspore/compare/layer_mapping.py +146 -0
  77. msprobe/mindspore/compare/modify_mapping.py +107 -0
  78. msprobe/mindspore/compare/ms_compare.py +357 -117
  79. msprobe/mindspore/compare/ms_graph_compare.py +364 -317
  80. msprobe/mindspore/compare/ms_to_pt_api.yaml +399 -399
  81. msprobe/mindspore/debugger/debugger_config.py +69 -74
  82. msprobe/mindspore/debugger/precision_debugger.py +150 -107
  83. msprobe/mindspore/dump/dump_tool_factory.py +50 -35
  84. msprobe/mindspore/dump/hook_cell/api_registry.py +128 -104
  85. msprobe/mindspore/dump/hook_cell/hook_cell.py +55 -53
  86. msprobe/mindspore/dump/hook_cell/primitive_hooks.py +206 -0
  87. msprobe/mindspore/dump/hook_cell/support_wrap_ops.yaml +994 -925
  88. msprobe/mindspore/dump/hook_cell/wrap_api.py +121 -0
  89. msprobe/mindspore/dump/jit_dump.py +96 -56
  90. msprobe/mindspore/dump/kernel_graph_dump.py +75 -60
  91. msprobe/mindspore/dump/kernel_kbyk_dump.py +79 -65
  92. msprobe/mindspore/free_benchmark/api_pynative_self_check.py +131 -116
  93. msprobe/mindspore/free_benchmark/common/config.py +27 -12
  94. msprobe/mindspore/free_benchmark/common/handler_params.py +32 -17
  95. msprobe/mindspore/free_benchmark/common/utils.py +85 -71
  96. msprobe/mindspore/free_benchmark/data/support_wrap_ops.yaml +842 -842
  97. msprobe/mindspore/free_benchmark/decorator/dec_forward.py +57 -42
  98. msprobe/mindspore/free_benchmark/decorator/decorator_factory.py +122 -107
  99. msprobe/mindspore/free_benchmark/handler/base_handler.py +105 -90
  100. msprobe/mindspore/free_benchmark/handler/check_handler.py +56 -41
  101. msprobe/mindspore/free_benchmark/handler/fix_handler.py +51 -36
  102. msprobe/mindspore/free_benchmark/handler/handler_factory.py +36 -21
  103. msprobe/mindspore/free_benchmark/perturbation/add_noise.py +82 -67
  104. msprobe/mindspore/free_benchmark/perturbation/base_perturbation.py +36 -21
  105. msprobe/mindspore/free_benchmark/perturbation/bit_noise.py +78 -63
  106. msprobe/mindspore/free_benchmark/perturbation/exchange_value.py +77 -0
  107. msprobe/mindspore/free_benchmark/perturbation/improve_precision.py +49 -34
  108. msprobe/mindspore/free_benchmark/perturbation/no_change.py +27 -12
  109. msprobe/mindspore/free_benchmark/perturbation/perturbation_factory.py +44 -27
  110. msprobe/mindspore/free_benchmark/self_check_tool_factory.py +48 -33
  111. msprobe/mindspore/grad_probe/global_context.py +100 -91
  112. msprobe/mindspore/grad_probe/grad_analyzer.py +231 -231
  113. msprobe/mindspore/grad_probe/grad_monitor.py +27 -27
  114. msprobe/mindspore/grad_probe/grad_stat_csv.py +131 -131
  115. msprobe/mindspore/grad_probe/hook.py +94 -92
  116. msprobe/mindspore/grad_probe/utils.py +29 -28
  117. msprobe/mindspore/ms_config.py +128 -126
  118. msprobe/mindspore/overflow_check/kernel_graph_overflow_check.py +60 -45
  119. msprobe/mindspore/overflow_check/overflow_check_tool_factory.py +49 -34
  120. msprobe/mindspore/runtime.py +4 -4
  121. msprobe/mindspore/service.py +297 -354
  122. msprobe/mindspore/task_handler_factory.py +24 -24
  123. msprobe/msprobe.py +105 -107
  124. msprobe/pytorch/__init__.py +23 -4
  125. msprobe/pytorch/api_accuracy_checker/common/config.py +70 -55
  126. msprobe/pytorch/api_accuracy_checker/common/utils.py +246 -165
  127. msprobe/pytorch/api_accuracy_checker/compare/algorithm.py +230 -213
  128. msprobe/pytorch/api_accuracy_checker/compare/api_precision_compare.py +632 -581
  129. msprobe/pytorch/api_accuracy_checker/compare/api_precision_standard.yaml +132 -132
  130. msprobe/pytorch/api_accuracy_checker/compare/api_precision_threshold.yaml +390 -390
  131. msprobe/pytorch/api_accuracy_checker/compare/compare.py +416 -381
  132. msprobe/pytorch/api_accuracy_checker/compare/compare_column.py +90 -73
  133. msprobe/pytorch/api_accuracy_checker/compare/compare_utils.py +265 -244
  134. msprobe/pytorch/api_accuracy_checker/config.yaml +10 -10
  135. msprobe/pytorch/api_accuracy_checker/run_ut/data_generate.py +370 -332
  136. msprobe/pytorch/api_accuracy_checker/run_ut/multi_run_ut.py +221 -199
  137. msprobe/pytorch/api_accuracy_checker/run_ut/run_overflow_check.py +150 -134
  138. msprobe/pytorch/api_accuracy_checker/run_ut/run_ut.py +518 -581
  139. msprobe/pytorch/api_accuracy_checker/run_ut/run_ut_utils.py +213 -74
  140. msprobe/pytorch/api_accuracy_checker/run_ut/torch_ut_setting.json +7 -4
  141. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/attl.py +218 -202
  142. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/client.py +370 -324
  143. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/device_dispatch.py +227 -204
  144. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/dump_dispatch.py +110 -0
  145. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/server.py +244 -218
  146. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/torch_ops_config.yaml +63 -0
  147. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/utils.py +44 -0
  148. msprobe/pytorch/bench_functions/__init__.py +30 -15
  149. msprobe/pytorch/bench_functions/apply_adam_w.py +43 -28
  150. msprobe/pytorch/bench_functions/confusion_transpose.py +34 -19
  151. msprobe/pytorch/bench_functions/fast_gelu.py +70 -55
  152. msprobe/pytorch/bench_functions/layer_norm_eval.py +21 -6
  153. msprobe/pytorch/bench_functions/linear.py +27 -12
  154. msprobe/pytorch/bench_functions/matmul_backward.py +63 -48
  155. msprobe/pytorch/bench_functions/npu_fusion_attention.py +538 -421
  156. msprobe/pytorch/bench_functions/rms_norm.py +30 -15
  157. msprobe/pytorch/bench_functions/rotary_mul.py +71 -52
  158. msprobe/pytorch/bench_functions/scaled_mask_softmax.py +41 -26
  159. msprobe/pytorch/bench_functions/swiglu.py +70 -55
  160. msprobe/pytorch/common/__init__.py +17 -2
  161. msprobe/pytorch/common/compare_script.template +14 -14
  162. msprobe/pytorch/common/log.py +33 -32
  163. msprobe/pytorch/common/parse_json.py +54 -39
  164. msprobe/pytorch/common/utils.py +310 -300
  165. msprobe/pytorch/compare/distributed_compare.py +66 -66
  166. msprobe/pytorch/compare/mapping.yaml +607 -607
  167. msprobe/pytorch/compare/match.py +49 -33
  168. msprobe/pytorch/compare/pt_compare.py +82 -40
  169. msprobe/pytorch/debugger/debugger_config.py +108 -95
  170. msprobe/pytorch/debugger/precision_debugger.py +173 -125
  171. msprobe/pytorch/free_benchmark/__init__.py +23 -8
  172. msprobe/pytorch/free_benchmark/common/constant.py +70 -70
  173. msprobe/pytorch/free_benchmark/common/counter.py +71 -71
  174. msprobe/pytorch/free_benchmark/common/enums.py +65 -37
  175. msprobe/pytorch/free_benchmark/common/params.py +144 -129
  176. msprobe/pytorch/free_benchmark/common/utils.py +118 -102
  177. msprobe/pytorch/free_benchmark/compare/grad_saver.py +200 -179
  178. msprobe/pytorch/free_benchmark/compare/single_benchmark.py +119 -104
  179. msprobe/pytorch/free_benchmark/main.py +120 -105
  180. msprobe/pytorch/free_benchmark/perturbed_layers/base_layer.py +28 -13
  181. msprobe/pytorch/free_benchmark/perturbed_layers/layer_factory.py +56 -41
  182. msprobe/pytorch/free_benchmark/perturbed_layers/npu/add_noise.py +105 -90
  183. msprobe/pytorch/free_benchmark/perturbed_layers/npu/bit_noise.py +119 -104
  184. msprobe/pytorch/free_benchmark/perturbed_layers/npu/change_value.py +87 -63
  185. msprobe/pytorch/free_benchmark/perturbed_layers/npu/improve_precision.py +83 -68
  186. msprobe/pytorch/free_benchmark/perturbed_layers/npu/no_change.py +43 -28
  187. msprobe/pytorch/free_benchmark/perturbed_layers/npu/npu_base_layser.py +60 -45
  188. msprobe/pytorch/free_benchmark/perturbed_layers/run_cpu.py +34 -19
  189. msprobe/pytorch/free_benchmark/result_handlers/base_handler.py +256 -217
  190. msprobe/pytorch/free_benchmark/result_handlers/check_handler.py +54 -39
  191. msprobe/pytorch/free_benchmark/result_handlers/fix_handler.py +38 -23
  192. msprobe/pytorch/free_benchmark/result_handlers/handler_factory.py +45 -30
  193. msprobe/pytorch/free_benchmark/result_handlers/preheat_handler.py +185 -170
  194. msprobe/pytorch/function_factory.py +91 -75
  195. msprobe/pytorch/functional/module_dump.py +84 -0
  196. msprobe/pytorch/grad_probe/grad_monitor.py +91 -90
  197. msprobe/pytorch/grad_probe/grad_stat_csv.py +128 -128
  198. msprobe/pytorch/hook_module/__init__.py +16 -1
  199. msprobe/pytorch/hook_module/api_registry.py +166 -161
  200. msprobe/pytorch/hook_module/hook_module.py +118 -120
  201. msprobe/pytorch/hook_module/support_wrap_ops.yaml +1879 -1877
  202. msprobe/pytorch/hook_module/utils.py +28 -29
  203. msprobe/pytorch/hook_module/wrap_aten.py +111 -110
  204. msprobe/pytorch/hook_module/wrap_distributed.py +77 -78
  205. msprobe/pytorch/hook_module/wrap_functional.py +104 -105
  206. msprobe/pytorch/hook_module/wrap_npu_custom.py +85 -84
  207. msprobe/pytorch/hook_module/wrap_tensor.py +69 -71
  208. msprobe/pytorch/hook_module/wrap_torch.py +84 -86
  209. msprobe/pytorch/hook_module/wrap_vf.py +60 -62
  210. msprobe/pytorch/module_processer.py +153 -138
  211. msprobe/pytorch/online_dispatch/__init__.py +20 -20
  212. msprobe/pytorch/online_dispatch/compare.py +235 -236
  213. msprobe/pytorch/online_dispatch/dispatch.py +271 -271
  214. msprobe/pytorch/online_dispatch/dump_compare.py +155 -156
  215. msprobe/pytorch/online_dispatch/single_compare.py +391 -391
  216. msprobe/pytorch/online_dispatch/torch_ops_config.yaml +57 -49
  217. msprobe/pytorch/online_dispatch/utils.py +127 -146
  218. msprobe/pytorch/parse.py +19 -4
  219. msprobe/pytorch/parse_tool/cli.py +31 -32
  220. msprobe/pytorch/parse_tool/lib/compare.py +259 -271
  221. msprobe/pytorch/parse_tool/lib/config.py +52 -52
  222. msprobe/pytorch/parse_tool/lib/file_desc.py +31 -31
  223. msprobe/pytorch/parse_tool/lib/interactive_cli.py +102 -102
  224. msprobe/pytorch/parse_tool/lib/parse_exception.py +54 -54
  225. msprobe/pytorch/parse_tool/lib/parse_tool.py +161 -158
  226. msprobe/pytorch/parse_tool/lib/utils.py +320 -321
  227. msprobe/pytorch/parse_tool/lib/visualization.py +85 -91
  228. msprobe/pytorch/pt_config.py +317 -187
  229. msprobe/pytorch/service.py +311 -252
  230. mindstudio_probe-1.0.3.dist-info/RECORD +0 -272
  231. msprobe/config/README.md +0 -539
  232. msprobe/mindspore/doc/compare.md +0 -58
  233. msprobe/mindspore/doc/dump.md +0 -217
  234. msprobe/mindspore/dump/hook_cell/wrap_functional.py +0 -91
  235. msprobe/mindspore/dump/hook_cell/wrap_tensor.py +0 -63
  236. msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/ssl_config.py +0 -10
  237. msprobe/pytorch/doc/FAQ.md +0 -193
  238. msprobe/pytorch/doc/api_accuracy_checker.md +0 -313
  239. msprobe/pytorch/doc/api_accuracy_checker_online.md +0 -187
  240. msprobe/pytorch/doc/dump.md +0 -260
  241. msprobe/pytorch/doc/msprobe/321/207/342/226/223/342/225/233/321/205/342/225/221/320/266/321/205/342/225/226/320/265/321/205/320/225/342/225/226/321/206/320/245/342/226/221/321/206/320/235/320/276dump/321/206/320/260/320/227/321/205/320/227/320/226/321/206/320/220/320/267/321/210/320/223/342/225/234/321/205/320/257/342/225/221/321/207/342/225/221/342/224/220/321/206/320/232/320/265/321/205/320/241/320/232.md +0 -182
  242. msprobe/pytorch/doc/ptdbg_ascend_compare.md +0 -240
  243. msprobe/pytorch/doc/ptdbg_ascend_overview.md +0 -68
  244. msprobe/pytorch/doc/ptdbg_ascend_quickstart.md +0 -381
  245. msprobe/pytorch/doc/run_overflow_check.md +0 -25
  246. msprobe/pytorch/doc//321/206/320/247/320/260/321/206/320/260/320/227/321/206/320/255/320/226/321/205/342/225/226/320/265/321/205/320/225/342/225/226/321/205/320/254/342/225/221/321/206/320/251/320/277/321/211/320/272/320/234/321/210/320/277/320/221/321/205/320/242/320/234/321/206/320/220/320/267/321/210/320/223/342/225/234/321/205/320/257/342/225/221/321/207/342/225/221/342/224/220/321/206/320/232/320/265/321/205/320/241/320/232.md +0 -151
  247. msprobe/pytorch/functional/data_processor.py +0 -0
  248. msprobe/pytorch/functional/dump_module.py +0 -39
  249. {mindstudio_probe-1.0.3.dist-info → mindstudio_probe-1.1.0.dist-info}/top_level.txt +0 -0
  250. /msprobe/{pytorch/doc → docs}/img/BLOOM-7B_1.png +0 -0
  251. /msprobe/{pytorch/doc → docs}/img/BLOOM-7B_2.png +0 -0
  252. /msprobe/{pytorch/doc → docs}/img/BLOOM-7B_3.png +0 -0
  253. /msprobe/{pytorch/doc → docs}/img/BLOOM-7B_4.png +0 -0
  254. /msprobe/{pytorch/doc → docs}/img/GPT-3_1.png +0 -0
  255. /msprobe/{pytorch/doc → docs}/img/GPT-3_2.png +0 -0
  256. /msprobe/{pytorch/doc → docs}/img/GPT-3_3.png +0 -0
  257. /msprobe/{pytorch/doc → docs}/img/GPT-3_4.png +0 -0
  258. /msprobe/{pytorch/doc → docs}/img/GPT-3_5.png +0 -0
  259. /msprobe/{pytorch/doc → docs}/img/GPT-3_6.png +0 -0
  260. /msprobe/{pytorch/doc → docs}/img/GPT-3_7.png +0 -0
  261. /msprobe/{pytorch/doc → docs}/img/GPT-3_8.png +0 -0
  262. /msprobe/{pytorch/doc → docs}/img/YOLOV5S_1.png +0 -0
  263. /msprobe/{pytorch/doc → docs}/img/YOLOV5S_2.png +0 -0
  264. /msprobe/{pytorch/doc → docs}/img/accuracy_checking_details.png +0 -0
  265. /msprobe/{pytorch/doc → docs}/img/accuracy_checking_result.png +0 -0
  266. /msprobe/{pytorch/doc → docs}/img/api_precision_compare_details.png +0 -0
  267. /msprobe/{pytorch/doc → docs}/img/api_precision_compare_result.png +0 -0
  268. /msprobe/{pytorch/doc → docs}/img/auto_analyze_log.png +0 -0
  269. /msprobe/{pytorch/doc → docs}/img/compare_result_pkl.png +0 -0
  270. /msprobe/{pytorch/doc → docs}/img/compare_result_pkl_md5.png.png +0 -0
  271. /msprobe/{pytorch/doc → docs}/img/cpu_info.png +0 -0
  272. /msprobe/{config → docs}/img/free_benchmark.png +0 -0
  273. /msprobe/{doc/grad_probe/img/image-1.png → docs/img/grad_probe_image-1.png} +0 -0
  274. /msprobe/{doc/grad_probe/img/image-2.png → docs/img/grad_probe_image-2.png} +0 -0
  275. /msprobe/{doc/grad_probe/img/image-3.png → docs/img/grad_probe_image-3.png} +0 -0
  276. /msprobe/{doc/grad_probe/img/image-4.png → docs/img/grad_probe_image-4.png} +0 -0
  277. /msprobe/{doc/grad_probe/img/image.png → docs/img/grad_probe_image.png} +0 -0
  278. /msprobe/{pytorch/doc → docs}/img/module_compare.png +0 -0
@@ -1,68 +0,0 @@
1
- # **精度比对工具**
2
-
3
- ## 简介
4
-
5
- 在PyTorch训练网络,对同一模型或API调试过程中,遇到API相关的计算精度问题,定位时费时费力。
6
-
7
- msprobe的精度比对工具,用来进行PyTorch整网API粒度的数据dump、精度比对和溢出检测,从而定位PyTorch训练场景下的精度问题。
8
-
9
- **使用场景**
10
-
11
- 主要的使用场景包括:
12
-
13
- - 同一模型,从CPU或GPU移植到NPU中存在精度下降问题,对比NPU芯片中的API计算数值与CPU或GPU芯片中的API计算数值,进行问题定位。
14
- - 同一模型,进行迭代(模型、框架版本升级或设备硬件升级)时存在的精度下降问题,对比相同模型在迭代前后版本的API计算数值,进行问题定位。
15
-
16
- ## 原理介绍
17
-
18
- 精度对比工具,通过在PyTorch模型中注册hook,跟踪计算图中API的前向传播与反向传播时的输入与输出,排查存在计算精度误差,进行问题的精准定位。
19
-
20
- **精度比对流程**
21
-
22
- 1. 当模型在CPU或GPU上进行正向和反向传播时,分别dump每一层的数值输入与输出。
23
-
24
- 2. 当模型在NPU中进行计算时,采用相同的方式dump下相应的数据。
25
-
26
- 3. 通过对比dump出的数值,计算余弦相似度和最大绝对误差的方式,定位和排查NPU API存在的计算精度问题。如下图所示。
27
-
28
- 精度比对逻辑图
29
-
30
- ![module_compare](img/module_compare.png)
31
-
32
- **API匹配条件**
33
-
34
- 进行精度比对时,需要判断CPU或GPU的API与NPU的API是否相同可比对,须满足以下匹配条件:
35
-
36
- - 两个API的名称相同,API命名规则:`{api_type}.{api_name}.{api调用次数}.{正反向}.{输入输出}.index`,如:Functional.conv2d.1.backward.input.0。
37
- - 两个API的输入输出Tensor数量和各个Tensor的Shape相同。
38
-
39
- 通常满足以上两个条件,工具就认为是同一个API,成功进行API的匹配,后续进行相应的计算精度比对。
40
-
41
- ## 精度比对总体流程
42
-
43
- 1. 准备CPU或GPU训练工程。
44
-
45
- 2. 在环境下安装msprobe工具。详见《[MindStudio精度调试工具](../../README.md)》的“工具安装”章节。
46
-
47
- 3. 在训练脚本内添加msprobe工具dump接口PrecisionDebugger采集标杆数据。详见《[精度数据采集](./dump.md)》。
48
-
49
- 4. 执行训练dump数据。
50
-
51
- 5. 将CPU或GPU训练工程迁移为NPU训练工程。详见《[PyTorch模型迁移调优指南](https://www.hiascend.com/document/detail/zh/Pytorch/60RC1/ptmoddevg/trainingmigrguide/PT_LMTMOG_0003.html)》。
52
-
53
- 6. 在NPU环境下安装msprobe工具。详见《[MindStudio精度调试工具](../../README.md)》的“工具安装”章节。
54
-
55
- 7. 在NPU训练脚本内添加msprobe工具dump接口PrecisionDebugger采集标杆数据。详见《[精度数据采集](./dump.md)》。
56
-
57
- 8. NPU环境下执行训练dump数据。
58
-
59
- 9. 执行精度比对。
60
-
61
- 1. 创建并配置精度比对脚本,例如compare.py。
62
-
63
- 2. 执行CPU或GPU dump与NPU dump数据的精度比对。
64
-
65
- 3. 比对结果分析。
66
-
67
- 详见《[CPU或GPU与NPU精度数据比对](./ptdbg_ascend_compare.md)》。
68
-
@@ -1,381 +0,0 @@
1
- # **精度比对工具**
2
-
3
- 本文主要介绍msprobe的精度比对工具的快速入门和场景化示例。
4
-
5
- 本文介绍的操作需要安装msprobe工具,详见《[MindStudio精度调试工具](../../README.md)》的“工具安装”章节。
6
-
7
- 本文介绍的操作主要是精度数据dump和精度比对,详细操作指导可参考《[精度数据采集](./dump.md)》和《[CPU或GPU与NPU精度数据比对](./ptdbg_ascend.md)》。
8
-
9
- ## 快速入门
10
-
11
- ### 单卡场景精度比对
12
-
13
- **精度分析建议**
14
-
15
- PyTorch训练场景的精度问题分析建议参考以下思路进行精度比对和比对结果分析:
16
-
17
- 1. 整网比对:dump整网数据并进行精度比对,初步定位异常范围。
18
-
19
- 对于模型数据庞大(比如达到T级别)的场景,不推荐直接dump整网比对,整网dump可能导致磁盘不足,需要预留足够的存储空间或者分多次dump。
20
-
21
- 2. 缩小范围:根据Accuracy Reached or Not找出不符合精度标准的API。
22
-
23
- 3. 范围比对:对不符合精度标准的API重新dump详细信息。
24
-
25
- 4. 分析原因并优化:分析API精度不符合标准的原因并进行优化调整。
26
-
27
- 5. 整网比对:重新进行整网比对,判断优化后的API是否已符合精度标准以及是否出现新的精度问题。
28
-
29
- 6. 重复1~5步,直到不存在精度问题为止。
30
-
31
- **精度分析示例**
32
-
33
- 1. 修改dump配置文件config.json。
34
-
35
- ```json
36
- {
37
- "task": "tensor",
38
- "dump_path": "./npu_dump",
39
- "rank": [],
40
- "step": [],
41
- "level": "L1",
42
- "seed": 1234,
43
- "is_deterministic": false,
44
-
45
- "tensor": {
46
- "scope": [],
47
- "list": [],
48
- "data_mode": ["all"],
49
- "summary_mode": "statistics"
50
- }
51
- }
52
- ```
53
-
54
- 2. 在训练脚本内添加msprobe工具,dump整网数据。
55
-
56
- 分别dump CPU或GPU以及NPU数据,在PyTorch训练脚本插入dump接口,示例代码如下(下面以NPU为例,CPU或GPU dump基本相同):
57
-
58
- ```python
59
- from msprobe.pytorch import PrecisionDebugger
60
- debugger = PrecisionDebugger(config_path="./config.json", dump_path="./npu_dump")
61
- # 请勿将以上初始化流程插入到循环代码中
62
-
63
- # 模型初始化
64
- # 下面代码也可以用PrecisionDebugger.start()和PrecisionDebugger.stop()
65
- debugger.start()
66
-
67
- # 需要dump的代码片段1
68
-
69
- debugger.stop()
70
- debugger.start()
71
-
72
- # 需要dump的代码片段2
73
-
74
- debugger.stop()
75
- debugger.step()
76
- ```
77
-
78
- 3. 比对整网数据。
79
-
80
- 第1步中的NPU dump数据目录为npu_dump,假设GPU dump数据目录为gpu_dump;dump将生成dump.json、stack.json、construct.json文件以及dump数据目录。
81
-
82
- 创建并配置精度比对脚本,以创建compare.py为例,示例代码如下:
83
-
84
- ```python
85
- from msprobe.pytorch import compare
86
- input_param={
87
- "npu_json_path": "./npu_dump/dump.json",
88
- "bench_json_path": "./bench_dump/dump.json",
89
- "stack_json_path": "./npu_dump/stack.json",
90
- "is_print_compare_log": True
91
- }
92
- compare(input_param, output_path="./output", stack_mode=True)
93
- ```
94
-
95
- 执行比对:
96
-
97
- ```bash
98
- python3 compare.py
99
- ```
100
-
101
- 在output目录下生成结果文件,包括:`compare_result_{timestamp}.xlsx`和`advisor_{timestamp}.txt`
102
-
103
- 4. 找出存在问题的API。
104
-
105
- 1. 根据`advisor_{timestamp}.txt`或打屏信息的提示,可找到存在精度问题的算子(Suspect Nodes)和专家建议(Expert Advice)。
106
-
107
- ![auto_analyze_log](img/auto_analyze_log.png)
108
-
109
- 2. 根据第2步结果文件`compare_result_{timestamp}.xlsx`中的Accuracy Reached or No字段显示为NO的API,针对该API执行后续比对操作,分析该API存在的精度问题。
110
-
111
- 5. (可选)重新比对。
112
-
113
- 根据第3步的dump数据重新配置compare.py并执行比对,可以对单API模型进行问题复现。
114
-
115
- **注意**:部分API存在调用嵌套关系,比如functional.batch_norm实际调用torch.batch_norm,该场景会影响kernel init初始化多次,导致功能异常。
116
-
117
- ### 溢出检测场景
118
-
119
- 溢出检测是针对NPU的PyTorch API,检测是否存在溢出的情况。当前仅支持识别aicore浮点溢出。
120
-
121
- 溢出检测原理:针对溢出阶段,开启acl dump模式,重新对溢出阶段执行,落盘数据。
122
-
123
- 建议按照如下步骤操作:
124
-
125
- 1. 修改dump配置文件config.json。
126
-
127
- ```json
128
- {
129
- "task": "overflow_check",
130
- "dump_path": "./npu_dump",
131
- "rank": [],
132
- "step": [],
133
- "level": "L1",
134
- "seed": 1234,
135
- "is_deterministic": false,
136
-
137
- "overflow_check": {
138
- "overflow_nums": 3
139
- }
140
- }
141
- ```
142
-
143
- 2. 在NPU训练脚本内添加msprobe工具,执行溢出检测dump。
144
-
145
- ```python
146
- from msprobe.pytorch import PrecisionDebugger
147
- debugger = PrecisionDebugger(config_path="./config.json", dump_path="./npu_dump")
148
- # 请勿将以上初始化流程插入到循环代码中
149
-
150
- # 模型初始化
151
- # 下面代码也可以用PrecisionDebugger.start()和PrecisionDebugger.stop()
152
- debugger.start()
153
-
154
- # 需要dump的代码片段1
155
-
156
- debugger.stop()
157
- debugger.start()
158
-
159
- # 需要dump的代码片段2
160
-
161
- debugger.stop()
162
- debugger.step()
163
- ```
164
-
165
- 多卡使用时各卡单独计算溢出次数。
166
-
167
- 3. NPU环境下执行训练dump溢出数据。
168
-
169
- 针对输入正常但输出存在溢出的API,会在训练执行目录下将溢出的API信息dump并保存为`dump.json`通过《[溢出解析工具](./run_overflow_check.md)》对json文件进行解析,输出溢出API为正常溢出还是非正常溢出,从而帮助用户快速判断。
170
-
171
- 溢出解析工具执行命令如下:
172
-
173
- ```bash
174
- msprobe -f pytorch run_overflow_check -api_info ./dump.json
175
- ```
176
-
177
- 反向过程溢出的API暂不支持精度预检功能。
178
-
179
-
180
- 当重复执行溢出检测dump操作时,需要删除上一次dump目录下的溢出检测dump数据,否则将因重名而报错。
181
-
182
- **注意事项**
183
-
184
- * (暂不支持)level为L2场景下,会增加npu的内存消耗,请谨慎开启。
185
- * (暂不支持)l部分API存在调用嵌套关系,比如functional.batch_norm实际调用torch.batch_norm,该场景会影响acl init初始化多次,导致level为L2功能异常。
186
- * 混合精度动态loss scale场景下,正常训练会有"Gradient overflow. SKipping step"日志,添加溢出检测后日志消失,可以通过设置环境变量export OVERFLOW_DEBUG_MODE_ENABLE=1,并将register_hook位置调整amp.initialize之前解决。此功能需要cann包配套支持,不支持版本执行报错EZ3003。
187
-
188
- ## 场景化示例
189
-
190
- ### 多卡场景精度比对
191
-
192
- 精度工具支持多卡场景的精度比对,多卡场景的dump步骤与单卡场景完全一致,请参见“**单卡场景精度比对**”章节,不同的是多卡数据精度比对时需要使用“compare_distributed”函数进行比对。
193
-
194
- 如下示例:
195
-
196
- 说明:多机多卡场景需要每个节点单独执行比对操作。
197
-
198
- 假设NPU dump 数据目录为npu_dump,GPU dump数据目录为gpu_dump。
199
-
200
- 1. 创建比对脚本,例如compare_distributed.py,拷贝如下代码。
201
-
202
- ```python
203
- from msprobe.pytorch import *
204
- compare_distributed('./npu_dump/step0', './gpu_dump/step0', './output')
205
- ```
206
-
207
- dump数据目录须指定到step级。
208
-
209
- 2. 执行比对:
210
-
211
- ```bash
212
- python3 compare_distributed.py
213
- ```
214
-
215
- 两次运行须用相同数量的卡,传入`compare_distributed`的两个文件夹下须有相同个数的rank文件夹,且不包含其他无关文件,否则将无法比对。
216
-
217
- **多卡set_dump_path注意事项**
218
-
219
- 多卡一般为多进程,须保证每个进程都正确调用PrecisionDebugger,或把PrecisionDebugger插入到import语句后,如:
220
-
221
- ```python
222
- from msprobe.pytorch import PrecisionDebugger
223
- debugger = PrecisionDebugger(config_path="./config.json", dump_path="./npu_dump")
224
- ```
225
-
226
- 如此可保证set_dump_path在每个进程都被调用。
227
-
228
- ### NPU vs NPU精度比对
229
-
230
- 对于NPU vs NPU场景,是针对同一模型,进行迭代(模型、API版本升级或设备硬件升级)时存在的精度下降问题,对比相同模型在迭代前后版本的API计算数值,进行问题定位。
231
-
232
- 一般情况下迭代涉及NPU自定义算子,因此,可以仅dump NPU自定义算子进行比对。比对精度问题分析请参见“**单卡场景精度比对**”章节。
233
-
234
- 工具当前支持dump NPU自定义算子如下:
235
-
236
- | 序号 | NPU自定义算子 |
237
- | :--- | ----------------------------------------------- |
238
- | 1 | torch_npu.one_ |
239
- | 2 | torch_npu.npu_sort_v2 |
240
- | 3 | torch_npu.npu_transpose |
241
- | 4 | torch_npu.npu_broadcast |
242
- | 5 | torch_npu.npu_dtype_cast |
243
- | 6 | torch_npu.empty_with_format |
244
- | 7 | torch_npu.npu_one_hot |
245
- | 8 | torch_npu.npu_stride_add |
246
- | 9 | torch_npu.npu_ps_roi_pooling |
247
- | 10 | torch_npu.npu_roi_align |
248
- | 11 | torch_npu.npu_nms_v4 |
249
- | 12 | torch_npu.npu_iou |
250
- | 13 | torch_npu.npu_nms_with_mask |
251
- | 14 | torch_npu.npu_pad |
252
- | 15 | torch_npu.npu_bounding_box_encode |
253
- | 16 | torch_npu.npu_bounding_box_decode |
254
- | 17 | torch_npu.npu_batch_nms |
255
- | 18 | torch_npu.npu_slice |
256
- | 19 | torch_npu._npu_dropout |
257
- | 20 | torch_npu.npu_indexing |
258
- | 21 | torch_npu.npu_ifmr |
259
- | 22 | torch_npu.npu_max |
260
- | 23 | torch_npu.npu_scatter |
261
- | 24 | torch_npu.npu_layer_norm_eval |
262
- | 25 | torch_npu.npu_alloc_float_status |
263
- | 26 | torch_npu.npu_confusion_transpose |
264
- | 27 | torch_npu.npu_bmmV2 |
265
- | 28 | torch_npu.fast_gelu |
266
- | 29 | torch_npu.npu_sub_sample |
267
- | 30 | torch_npu.npu_deformable_conv2d |
268
- | 31 | torch_npu.npu_mish |
269
- | 32 | torch_npu.npu_anchor_response_flags |
270
- | 33 | torch_npu.npu_yolo_boxes_encode |
271
- | 34 | torch_npu.npu_grid_assign_positive |
272
- | 35 | torch_npu.npu_normalize_batch |
273
- | 36 | torch_npu.npu_masked_fill_range |
274
- | 37 | torch_npu.npu_linear |
275
- | 38 | torch_npu.npu_bert_apply_adam |
276
- | 39 | torch_npu.npu_giou |
277
- | 40 | torch_npu.npu_ciou |
278
- | 41 | torch_npu.npu_diou |
279
- | 42 | torch_npu.npu_sign_bits_pack |
280
- | 43 | torch_npu.npu_sign_bits_unpack |
281
- | 44 | torch_npu.npu_flash_attention |
282
- | 45 | torch_npu.npu_scaled_masked_softmax |
283
- | 46 | torch_npu.npu_rotary_mul |
284
- | 47 | torch_npu.npu_roi_align |
285
- | 48 | torch_npu.npu_roi_alignbk |
286
- | 49 | torch_npu.npu_ptiou |
287
- | 50 | torch_npu.npu_fusion_attention |
288
- | 51 | torch_npu.npu_dropout_with_add_softmax |
289
- | 52 | torch_npu.npu_random_choice_with_mask |
290
- | 53 | torch_npu.npu_rotated_iou |
291
- | 54 | torch_npu.npu_conv2d |
292
- | 55 | torch_npu.npu_conv3d |
293
- | 56 | torch_npu.npu_softmax_cross_entropy_with_logits |
294
- | 57 | torch_npu.npu_all_gather_base_mm |
295
- | 58 | torch_npu.npu_swiglu |
296
- | 59 | torch_npu.npu_rms_norm |
297
- | 60 | torch_npu.npu_mm_reduce_scatter_base |
298
- | 61 | torch_npu.npu_mm_all_reduce_base |
299
- | 62 | torch_npu.npu_conv_transpose2d |
300
- | 63 | torch_npu.npu_convolution |
301
- | 64 | torch_npu.npu_convolution_transpose |
302
- | 65 | torch_npu.npu_min |
303
- | 66 | torch_npu.npu_nms_rotated |
304
- | 67 | torch_npu.npu_reshape |
305
- | 68 | torch_npu.npu_rotated_box_decode |
306
- | 69 | torch_npu.npu_rotated_box_encode |
307
- | 70 | torch_npu.npu_rotated_overlaps |
308
- | 71 | torch_npu.npu_silu |
309
- | 72 | torch_npu.npu_fused_attention_score |
310
- | 73 | torch_npu.npu_multi_head_attention |
311
- | 74 | torch_npu.npu_gru |
312
- | 75 | torch_npu.npu_incre_flash_attention |
313
- | 76 | torch_npu.npu_prompt_flash_attention |
314
- | 77 | torch_npu.npu_lstm |
315
- | 78 | torch_npu.npu_apply_adam |
316
-
317
- ### 通信API的数据dump
318
-
319
- 通信类API数据可以使用全量dump方式获取,若只dump通信类API数据,可以使用如下示例:
320
-
321
- 1. 修改dump配置文件config.json。
322
-
323
- ```json
324
- {
325
- "task": "tensor",
326
- "dump_path": "./npu_dump",
327
- "rank": [],
328
- "step": [],
329
- "level": "L1",
330
- "seed": 1234,
331
- "is_deterministic": false,
332
-
333
- "tensor": {
334
- "scope": [],
335
- "list": ["distributed"],
336
- "data_mode": ["all"],
337
- "summary_mode": "statistics"
338
- }
339
- }
340
- ```
341
-
342
- 2. 在训练脚本内添加msprobe工具,dump整网数据。
343
-
344
- ```python
345
- from msprobe.pytorch import PrecisionDebugger
346
- debugger = PrecisionDebugger(config_path="./config.json", dump_path="./npu_dump")
347
- # 请勿将以上初始化流程插入到循环代码中
348
-
349
- # 模型初始化
350
- # 下面代码也可以用PrecisionDebugger.start()和PrecisionDebugger.stop()
351
- debugger.start()
352
-
353
- # 需要dump的代码片段1
354
-
355
- debugger.stop()
356
- debugger.start()
357
-
358
- # 需要dump的代码片段2
359
-
360
- debugger.stop()
361
- debugger.step()
362
- ```
363
-
364
- 通信类API支持列表:
365
-
366
- | 序号 | Distributed |
367
- | :--- | -------------------- |
368
- | 1 | send |
369
- | 2 | recv |
370
- | 3 | broadcast |
371
- | 4 | all_reduce |
372
- | 5 | reduce |
373
- | 6 | all_gather |
374
- | 7 | gather |
375
- | 8 | isend |
376
- | 9 | irecv |
377
- | 10 | scatter |
378
- | 11 | reduce_scatter |
379
- | 12 | _reduce_scatter_base |
380
- | 13 | _all_gather_base |
381
-
@@ -1,25 +0,0 @@
1
- # **溢出解析工具**
2
-
3
- 针对训练过程中的溢出检测场景(当《[精度数据采集](./dump.md)》开启溢出检测dump时),对于输入正常但输出存在溢出的API,会在训练执行目录下将溢出的API信息按照前向和反向分类,dump并保存为`dump.json`,前向过程溢出的API可通过该工具对`dump.json`进行解析,输出溢出API为正常溢出还是非正常溢出,从而帮助用户快速判断。
4
-
5
- 工具支持PyTorch版本:1.11/2.0/2.1/2.2。
6
-
7
- 操作步骤如下:
8
-
9
- 1. 安装工具。
10
-
11
- 详见《[MindStudio精度调试工具](../../README.md)》的“工具安装”章节。
12
-
13
- 2. 执行溢出API解析操作。
14
-
15
- ```bash
16
- msprobe -f pytorch run_overflow_check -api_info ./dump.json
17
- ```
18
-
19
- | 参数名称 | 说明 | 是否必选 |
20
- | -------------------------- | -------------------------------------------------- | -------- |
21
- | -api_info或--api_info_file | 指定API信息文件dump.json。 | 是 |
22
- | -j或--jit_compile | 开启jit编译。 | 否 |
23
- | -d或--device | 指定Device ID,选择UT代码运行所在的卡,默认值为0。 | 否 |
24
-
25
- 反向过程溢出的API暂不支持该功能。
@@ -1,151 +0,0 @@
1
- # 无标杆工具场景验证和性能基线报告
2
-
3
- ## 环境信息
4
-
5
- NPU:Atlas A2 训练系列产品
6
-
7
- CPU:
8
-
9
- ![输入图片说明](img/cpu_info.png)
10
-
11
- Torch:2.1.0
12
-
13
- CANN:8.0.T5
14
-
15
- 除上述环境信息影响性能外,API的数量、种类以及Shape都会对性能产生影响,因此本次选取不同场景网络和不同算子进行测试。
16
-
17
- ## 模型信息和性能基线
18
-
19
- 大模型在使用msprobe工具dump数据时,建议先简化模型层数,减少dump数据量。
20
-
21
- 以下场景的性能基线测试数据均为多次测试后取平均值,因此实际运行时性能数据可能会根据环境状态稍有浮动。
22
-
23
-
24
-
25
- ### LLaMA2-7B
26
-
27
- NUM_LAYER:1,1卡,主要数据类型:FLOAT16,模型来源: ascend/ModelLink
28
- 其中,softmax算子为FLOAT32,输入输出均为2G大小,为模型最大显存开销的API。
29
-
30
- 在该模型下、对无标杆工具处理模式、插装范围、扰动方式组合下性能和显存基线进行覆盖。
31
-
32
- 性能基线报告
33
- 其中耗时为训练10步,去除第一步耗时所得的平均每步耗时。
34
-
35
- | 处理模式 | 前/反向 | 算子范围 | 扰动方式 | 耗时(s) | 显存峰值(GB) | 耗时膨胀倍数 | 显存峰值膨胀倍数 | 备注 |
36
- |--------------------------------|-----------------------------------|-----------------|----------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|
37
- | / | / | / | / | 0.24 | 13.69 | 1 | 1 | 混精模式基线 |
38
- | check | 前 | ["softmax"] | improve_precision | 0.26 | 13.69 | 1.08 | 1 | softmax本身为高精度,跳过 |
39
- | check | 前 | ["softmax"] | add_noise | 0.54 | 19.17 | 2.25 | 1.40 | |
40
- | check | 前 | ["softmax"] | bit_noise | 0.56 | 19.17 | 2.33 | 1.40 | |
41
- | check | 前 | ["softmax"] | change_value | 0.48 | 14.9 | 2 | 1.09 | |
42
- | check | 前 | ["softmax"] | no_change | 0.47 | 14.9 | 1.96 | 1.09 | |
43
- | check | 前 | ["softmax"] | to_cpu | 26.45 | 22.67 | 110.21 | 1.66 | 不建议整网 |
44
- | check | 前 | ["matmul"] | improve_precision | 0.57 | 13.69 | 2.38 | 1 | |
45
- | check | 前 | ["matmul"] | change_value | 0.48 | 13.69 | 2 | 1 | |
46
- | check | 前 | ["matmul"] | to_cpu | 78.43 | 19.20 | 326.79 | 1.40 | 不建议整网 |
47
- | check | 前 | [] | improve_precision | 3.45 | 18.79 | 14.37 | 1.37 | |
48
- | check | 前 | [] | add_noise | 4.67 | 19.17 | 19.46 | 1.40 | |
49
- | check | 前 | [] | bit_noise | 16.99 | 19.17 | 70.79 | 1.40 | |
50
- | check | 前 | [] | no_change | 3.22 | 14.90 | 13.42 | 1.09 | |
51
- | check | 反 | ["softmax"] | improve_precision | 6.23 | 25.69 | 25.96 | 1.88 | 不建议整网 |
52
- | check | 反 | ["softmax"] | change_value | 22.76 | 25.69 | 94.83 | 1.88 | 不建议整网 |
53
- | check | 反 | ["softmax"] | to_cpu | 141.71 | 26.19 | 590.46 | 1.91 | 不建议整网 |
54
- | fix | 前 | ["softmax"] | to_cpu | 9.70 | 16.67 | 40.42 | 1.22 | 不支持整网、不支持反向 |
55
- | fix | 前 | ["softmax"] | improve_precision | 0.26 | 14.67 | 1.08 | 1.07 | 不支持整网、不支持反向 |
56
- | 预热 | 前 | [] | improve_precision | 155.07 | 24.79 | 646.13 | 1.81 | 低精度模型基线、只测预热的迭代 |
57
- | 预热 | 反 | [] | improve_precision | 72.29 | 22.01 | 301.21 | 1.61 | 低精度模型基线、只测预热的迭代,grad_output为高精度的算子跳过 |
58
-
59
- ### Aquila2-7B
60
-
61
- NUM_LAYER:1,1卡,主要数据类型:FLOAT16,模型来源: ascend/ModelLink
62
-
63
- | 处理模式 | 前/反向 | 算子范围 | 扰动方式 | 耗时(s) | 显存峰值(GB) | 耗时膨胀倍数 | 显存峰值膨胀倍数 | 备注 |
64
- |--------------------------------|-----------------------------------|-----------------|----------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|
65
- | / | / | / | / | 0.17 | 13.66 | 1 | 1 | 混精模式基线 |
66
- | check | 前 | [] | improve_precision | 1.57 | 14.24 | 9.24 | 1.04 | |
67
- | check | 反 | [] | add_noise | 21.05 | 14.19 | 123.82 | 1.04 | |
68
- | fix | 前 | [] | improve_precision | 0.95 | 15.55 | 5.59 | 1.14 | |
69
-
70
- ### Baichuan2-7B
71
-
72
- NUM_LAYER:1,1卡,主要数据类型:FLOAT16,模型来源: ascend/ModelLink
73
-
74
- | 处理模式 | 前/反向 | 算子范围 | 扰动方式 | 耗时(s) | 显存峰值(GB) | 耗时膨胀倍数 | 显存峰值膨胀倍数 | 备注 |
75
- |--------------------------------|-----------------------------------|-----------------|----------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|
76
- | / | / | / | / | 0.26 | 12.12 | 1 | 1 | 混精模式基线 |
77
- | check | 前 | [] | improve_precision | 1.02 | 12.27 | 3.92 | 1.01 | |
78
- | check | 反 | [] | add_noise | 11.15 | 12.67 | 42.88 | 1.05 | |
79
- | fix | 前 | [] | improve_precision | 0.95 | 12.82 | 3.65 | 1.06 | |
80
-
81
- ### Bloom-7B
82
-
83
- NUM_LAYER:1,1卡,主要数据类型:FLOAT16,模型来源: ascend/ModelLink
84
-
85
- | 处理模式 | 前/反向 | 算子范围 | 扰动方式 | 耗时(s) | 显存峰值(GB) | 耗时膨胀倍数 | 显存峰值膨胀倍数 | 备注 |
86
- |--------------------------------|-----------------------------------|-----------------|----------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|
87
- | / | / | / | / | 0.14 | 9.51 | 1 | 1 | 混精模式基线 |
88
- | check | 前 | [] | improve_precision | 1.64 | 11.58 | 11.71 | 1.22 | |
89
- | check | 反 | [] | add_noise | 17.15 | 9.51 | 122.5 | 1 | |
90
- | fix | 前 | [] | improve_precision | 0.87 | 10.62 | 6.21 | 1.12 | |
91
-
92
- ### Interlm-7B
93
-
94
- NUM_LAYER:1,1卡,主要数据类型:FLOAT16,模型来源: ascend/ModelLink
95
-
96
- | 处理模式 | 前/反向 | 算子范围 | 扰动方式 | 耗时(s) | 显存峰值(GB) | 耗时膨胀倍数 | 显存峰值膨胀倍数 | 备注 |
97
- |--------------------------------|-----------------------------------|-----------------|----------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|
98
- | / | / | / | / | 0.13 | 10.76 | 1 | 1 | 混精模式基线 |
99
- | check | 前 | [] | improve_precision | 1.19 | 11.68 | 9.15 | 1.09 | |
100
- | check | 反 | [] | add_noise | 11.69 | 10.89 | 89.92 | 1.01 | |
101
- | fix | 前 | [] | improve_precision | 0.75 | 11.68 | 5.77 | 1.09 | |
102
-
103
- ### Qwen-7B
104
-
105
- NUM_LAYER:1,1卡,主要数据类型:FLOAT16,模型来源: ascend/ModelLink
106
-
107
- | 处理模式 | 前/反向 | 算子范围 | 扰动方式 | 耗时(s) | 显存峰值(GB) | 耗时膨胀倍数 | 显存峰值膨胀倍数 | 备注 |
108
- |--------------------------------|-----------------------------------|-----------------|----------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|
109
- | / | / | / | / | 0.28 | 18.41 | 1 | 1 | 混精模式基线 |
110
- | check | 前 | [] | improve_precision | 2.34 | 23.18 | 8.36 | 1.26 | |
111
- | check | 反 | [] | add_noise | 22.07 | 19.47 | 78.82 | 1.06 | |
112
- | fix | 前 | [] | improve_precision | 1.31 | 21.11 | 4.68 | 1.15 | |
113
-
114
- ### Gemma-7B
115
-
116
- NUM_LAYER:1,1卡,主要数据类型:FLOAT16,模型来源: ascend/ModelLink
117
-
118
- | 处理模式 | 前/反向 | 算子范围 | 扰动方式 | 耗时(s) | 显存峰值(GB) | 耗时膨胀倍数 | 显存峰值膨胀倍数 | 备注 |
119
- |--------------------------------|-----------------------------------|-----------------|----------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|
120
- | / | / | / | / | 0.15 | 11.06 | 1 | 1 | 混精模式基线 |
121
- | check | 前 | [] | improve_precision | 1.49 | 13.17 | 9.93 | 1.19 | |
122
- | check | 反 | [] | add_noise | 16.69 | 11.06 | 111.27 | 1 | |
123
- | fix | 前 | [] | improve_precision | 0.87 | 12.25 | 5.8 | 1.11 | |
124
-
125
- ### ResNet50-Cifar
126
- 1卡,主要数据类型:FLOAT16,模型来源: ascend/ModelZoo-PyTorch。
127
- 主要算子为conv2d,每个step有51个, 因此对conv2d进行检测。
128
- CV模型、依赖mmcv实现(如果不修改mmcv代码、工具无法获取step信息和反向信息)。
129
-
130
- | 处理模式 | 前/反向 | 算子范围 | 扰动方式 | 耗时(s) | 显存峰值(GB) | 耗时膨胀倍数 | 显存峰值膨胀倍数 | 备注 |
131
- |--------------------------------|-----------------------------------|-----------------|----------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|
132
- | / | / | / | / | 0.09 | 7.63 | 1 | 1 | 基线 |
133
- | check | 前 | ["conv2d"] | improve_precision | 0.889 | 7.94 | 9.81 | 1.04 | |
134
- | fix | 前 | ["conv2d"] | improve_precision | 0.328 | 7.47 | 3.64 | 0.91 | |
135
- | fix | 前 | ["conv2d"] | to_cpu | 12.23 | 7.47 | 135.88 | 0.91 | |
136
-
137
- ### OpenSora1.0
138
-
139
- 4卡,主要数据类型:FLOAT16,模型来源: ascend/ModelZoo-PyTorch
140
-
141
- 每张卡每个step中linear算子个数为257个,FA算子个数为83(FA算子反向无效)。
142
-
143
- | 处理模式 | 前/反向 | 算子范围 | 扰动方式 | 耗时(s) | 显存峰值(GB) | 耗时膨胀倍数 | 显存峰值膨胀倍数 | 备注 |
144
- |--------------------------------|-----------------------------------|-----------------|----------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|
145
- | / | / | / | / | 0.99 | 17.61 | 1 | 1 | 混精模式基线 |
146
- | check | 前 | ["linear","npu_fusion_attention"] | improve_precision | 3.88 | 17.61 | 3.92 | 1 | |
147
- | check | 前 | ["linear","npu_fusion_attention"] | add_noise | 3.46 | 17.61 | 3.49 | 1 | |
148
- | check | 反 | ["linear"] | improve_precision | 12.61 | 17.61 | 12.74 | 1 | |
149
- | check | 反 | ["linear"] | add_noise | 9.8 | 17.61 | 9.90 | 1 | |
150
- | fix | 前 | ["linear"] | to_cpu | 18.83 | 17.61 | 19.02 | 1 | |
151
- | fix | 前 | ["linear"] | improve_precision | 2.83 | 17.61 | 2.86 | 1 | |
File without changes
@@ -1,39 +0,0 @@
1
- import torch.nn as nn
2
- from msprobe.pytorch.common.log import logger
3
- from msprobe.core.common.const import Const
4
- from msprobe.pytorch.hook_module.api_registry import api_register
5
- from msprobe.pytorch.debugger.precision_debugger import PrecisionDebugger
6
- from msprobe.core.common.exceptions import MsprobeException
7
- from msprobe.core.data_dump.scope import BaseScope
8
-
9
- module_count = {}
10
-
11
-
12
- def module_dump(module, dump_name):
13
- if not isinstance(module, nn.Module):
14
- logger.error("The parameter:module in module_dump is not a Module subclass.")
15
- raise MsprobeException(MsprobeException.INVALID_PARAM_ERROR)
16
- if not isinstance(dump_name, str):
17
- logger.error("The parameter:dump_name in module_dump is not a str type.")
18
- raise MsprobeException(MsprobeException.INVALID_PARAM_ERROR)
19
- api_register.api_originality()
20
- if dump_name not in module_count:
21
- module_count[dump_name] = 0
22
- else:
23
- module_count[dump_name] += 1
24
- dump_name = dump_name + Const.SEP + str(module_count.get(dump_name)) + Const.SEP
25
-
26
- pdg = PrecisionDebugger()
27
- _, forward_hook, backward_hook, _ = pdg.service.build_hook(BaseScope.Module_Type_Module, dump_name)
28
- module.register_forward_hook(forward_hook, with_kwargs=True)
29
- module.register_full_backward_hook(backward_hook)
30
-
31
- module.register_forward_pre_hook(pdg.service.module_processor.node_hook(dump_name + Const.FORWARD, Const.START))
32
- module.register_forward_hook(pdg.service.module_processor.node_hook(dump_name + Const.FORWARD, Const.STOP))
33
- module.register_full_backward_pre_hook(
34
- pdg.service.module_processor.node_hook(dump_name + Const.BACKWARD, Const.START))
35
- module.register_full_backward_hook(pdg.service.module_processor.node_hook(dump_name + Const.BACKWARD, Const.STOP))
36
-
37
-
38
- def module_dump_end():
39
- api_register.api_modularity()