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
@@ -0,0 +1,99 @@
1
+ # 安装
2
+
3
+ 推荐使用 [miniconda](https://docs.anaconda.com/miniconda/) 管理环境依赖。
4
+
5
+ ```bash
6
+ conda create -n msprobe python
7
+ conda activate msprobe
8
+ ```
9
+
10
+ ## 1 从 PyPI 安装
11
+ ```shell
12
+ pip install mindstudio-probe
13
+ ```
14
+
15
+ ## 2 下载 whl 包安装
16
+
17
+ |版本|发布日期|支持 PyTorch 版本|支持 MindSpore 版本|下载链接|校验码|
18
+ |:--:|:--:|:--:|:--:|:--:|:--:|
19
+ |1.0.4|2024.09.09|1.11/2.0/2.1/2.2|2.4.0|[mindstudio_probe-1.0.4-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/1.0/mindstudio_probe-1.0.4-py3-none-any.whl)|4e1909566a71a855b356597750c20ee43d964a22b2c2b02ac08312a5def75fd6|
20
+ | 1.0.3 | 2024.08.23 | 1.11/2.0/2.1/2.2 | 2.4.0 | [mindstudio_probe-1.0.3-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/1.0/mindstudio_probe-1.0.3-py3-none-any.whl) | 7060cc141a5b98ef770cd9220995d299393f32a61938261e632c7e8b5160bef2 |
21
+ | 1.0.2 | 2024.08.09 | 1.11/2.0/2.1/2.2 | 2.4.0 | [mindstudio_probe-1.0.2-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/1.0/mindstudio_probe-1.0.2-py3-none-any.whl) | e4a980e5d98c426ce5ce9842520d9bc031d3b3de621c74b3d59414cc6e238e0e |
22
+ | 1.0.1 | 2024.07.25 | 2.0/2.1/2.2 | 2.4.0 | [mindstudio_probe-1.0.1-py3-none-any.whl](https://ptdbg.obs.myhuaweicloud.com/msprobe/1.0/mindstudio_probe-1.0.1-py3-none-any.whl) | b699e224e4d4e3bcf9412c54fa858a1ee370f0d7a2bc69cb3f1273ac14a6dc82 |
23
+
24
+
25
+ ```bash
26
+ sha256sum {name}.whl # 验证whl包,若校验码一致,则whl包在下载中没有受损
27
+ ```
28
+
29
+ ```bash
30
+ pip install ./mindstudio_probe-{version}-py3-none-any.whl # 安装whl包
31
+ ```
32
+
33
+ 若覆盖安装,请在命令行末尾添加 `--force-reinstall` 参数。
34
+
35
+ ## 3 从源码安装
36
+
37
+ ```shell
38
+ git clone https://gitee.com/ascend/mstt.git
39
+ cd mstt/debug/accuracy_tools
40
+
41
+ pip install setuptools wheel
42
+
43
+ python setup.py bdist_wheel
44
+ cd ./dist
45
+ pip install ./mindstudio_probe*.whl
46
+ ```
47
+
48
+ # 历史版本特性
49
+
50
+ <table>
51
+ <tr><th>版本</th><th>特性</th></tr>
52
+ <tr><td rowspan="2">1.0.3</td><td>【精度预检】</br>1. 落盘数据小;</br>2. 支持随机生成模式和真实数据模式;</br>3. 单 API 测试,排除整网中的累计误差问题。</td></tr>
53
+ <tr><td>【梯度检测】</br>1. 使用便捷,无需在训练流程里插入代码。</br>2. 可以精准定位问题出现的 step。</td></tr>
54
+ </table>
55
+
56
+ # 查看 msprobe 工具信息
57
+
58
+ ```bash
59
+ pip show mindstudio-probe
60
+ ```
61
+
62
+ 示例如下:
63
+
64
+ ```bash
65
+ Name: mindstudio-probe
66
+ Version: 1.0.x
67
+ Summary: Pytorch Ascend Probe Utils
68
+ Home-page: https://gitee.com/ascend/mstt/tree/master/debug/accuracy_tools/msprobe
69
+ Author: Ascend Team
70
+ Author-email: pmail_mindstudio@huawei.com
71
+ License: Apache License 2.0
72
+ Location: /home/xxx/miniconda3/envs/xxx/lib/python3.x/site-packages/mindstudio_probe-1.0.x-py3.x.egg
73
+ Requires: einops, matplotlib, numpy, openpyxl, pandas, pyOpenSSL, pyyaml, rich, tqdm, twisted, wheel
74
+ Required-by:
75
+ ```
76
+
77
+ # Ascend 生态链接
78
+
79
+ ## 1 安装 CANN 包
80
+
81
+ 1.1 根据 CPU 架构和 NPU 型号选择 toolkit 和 kernel,可以参考 [CANN 软件安装指南](https://gitee.com/link?target=https%3A%2F%2Fwww.hiascend.com%2Fdocument%2Fdetail%2Fzh%2Fcanncommercial%2F700%2Fenvdeployment%2Finstg%2Finstg_0001.html)和[昇腾社区](https://www.hiascend.cn/developer/download/community/result?module=cann)。
82
+
83
+ 1.2 运行示例
84
+ ```bash
85
+ Ascend-cann-toolkit_x.x.x_linux-xxxx.run --full --install-path={cann_path}
86
+ Ascend-cann-kernels_x.x.x_linux.run --install --install-path={cann_path}
87
+ ```
88
+
89
+ 1.3 配置环境变量
90
+ ```bash
91
+ source {cann_path}/ascend-toolkit/set_env.sh
92
+ ```
93
+ ## 2 安装 PyTorch_NPU
94
+
95
+ 链接:[https://gitee.com/ascend/pytorch](https://gitee.com/ascend/pytorch)。
96
+
97
+ ## 3 安装 ModelLink
98
+
99
+ 链接:[https://gitee.com/ascend/ModelLink](https://gitee.com/ascend/ModelLink)。
@@ -0,0 +1,137 @@
1
+ # 配置文件介绍
2
+
3
+ - 当调用 **PrecisionDebugger** 接口执行 dump 或其他操作时,需要使用 [config.json](../config.json) 文件;当未指定 config.json 时,将使用默认配置。
4
+ - msprobe 成功安装后,config.json 一般位于如下目录:
5
+ ```
6
+ /home/xxx/miniconda3/envs/xxx/lib/python3.xx/site-packages/msprobe/
7
+ ```
8
+
9
+ ## 1 参数介绍
10
+
11
+ ### 1.1 通用配置
12
+
13
+ | 参数 | 解释 | 是否必选 |
14
+ | ----------------- | ---------------- | -------- |
15
+ | task | dump 的任务类型,str 类型。可选参数:<br/> "statistics":仅采集统计信息,默认值;<br/> "tensor":采集统计信息和完全复刻整网的真实数据;<br/> "run_ut":精度预检,仅 PyTorch 场景支持,采集数据时勿选;<br/> "overflow_check":溢出检测;<br/> "free_benchmark":无标杆比对。<br/> 根据 task 参数取值的不同,可以配置不同场景参数,详见:<br/>[1.2 task 配置为 statistics](#12-task-配置为-statistics),<br/>[1.3 task 配置为 tensor](#13-task-配置为-tensor),<br/>[1.4 task 配置为 run_ut](#14-task-配置为-run_ut),<br/>[1.5 task 配置为 overflow_check](#15-task-配置为-overflow_check),<br/>[1.6 task 配置为 free_benchmark](#16-task-配置为-free_benchmark)。 <br/> **配置示例**:"task": "tensor"。 | 否 |
16
+ | dump_path | 设置 dump 数据目录路径,str 类型。<br/> **配置示例**:"dump_path": "./dump_path"。 | 是 |
17
+ | rank | 指定对某张卡上的数据进行采集,list[Union[int, str]] 类型,默认未配置(表示采集所有卡的数据),应配置元素为 ≥0 的整数或类似"4-6"的字符串,且须配置实际可用的 Rank ID。<br/> PyTorch 场景: Rank ID 从 0 开始计数,最大取值为所有节点可用卡总数-1,若所配置的值大于实际训练所运行的卡的 Rank ID,则 dump 数据为空,比如当前环境 Rank ID 为 0 到 7,实际训练运行 0 到 3 卡,此时若配置 Rank ID 为 4 或不存在的 10 等其他值,dump 数据为空。<br/> MindSpore 场景:所有节点的 Rank ID 均从 0 开始计数,最大取值为每个节点可用卡总数-1,config.json 配置一次 rank 参数对所有节点同时生效。<br/>**配置示例**:"rank": [1, "4-6"]。 | 否 |
18
+ | step | 指定采集某个 step 的数据,list[Union[int, str]] 类型。默认未配置,表示采集所有 step 数据。采集特定 step 时,须指定为训练脚本中存在的 step,可逐个配置,也可以指定范围。<br/> **配置示例**:"step": [0, 1 , 2, "4-6"]。 | 否 |
19
+ | level | dump 级别,str 类型,根据不同级别采集不同数据。可选参数:<br/>"L0":dump 模块级精度数据,仅 PyTorch 与 MindSpore 动态图场景支持,使用背景详见 [1.1.1 模块级精度数据 dump 说明](#111-模块级精度数据-dump-说明);<br/>"L1":dump API 级精度数据,默认值,仅 PyTorch 与 MindSpore 动态图场景支持;<br/>"L2":dump kernel 级精度数据,PyTorch 场景下须配置 acl_config 参数;<br/>"mix":dump module 模块级和 API 级精度数据,即"L0"+"L1",仅 PyTorch 与 MindSpore 动态图场景支持。<br/> **配置示例**:"level": "L1"。 | 否 |
20
+ | acl_config | kernel dump 的配置文件,str 类型。当 PyTorch 场景的 level 取"L2"时,该参数必选;level 为其他值时,该参数不选。<br/> **配置示例**:acl_config="./acl_config.json"。具体配置见[ acl_config 示例](./04.acl_config_examples.md)。 | 否 |
21
+ | enable_dataloader | 自动控制开关,bool 类型,仅 PyTorch 场景支持。可选参数 true(开启)或 false(关闭),默认为 false。配置为 true 后自动识别 step 参数指定的迭代,并在该迭代执行完成后退出训练,此时 start、stop 和 step 函数可不配置,开启该开关要求训练脚本是通过 torch.utils.data.dataloader 方式加载数据。仅支持 PyTorch 单卡训练使用,分布式训练场景下存在数据 dump 不全问题。 | 否 |
22
+
23
+ #### 1.1.1 模块级精度数据 dump 说明
24
+
25
+ 仅 PyTorch 与 MindSpore 动态图场景支持。
26
+
27
+ 大模型场景下,通常不是简单的利用自动迁移能力实现从 GPU 到 NPU 的训练脚本迁移,而是会对 NPU 网络进行一系列针对性的适配,因此,常常会造成迁移后的 NPU 模型存在部分子结构不能与 GPU 原始模型完全对应。模型结构不一致导致 API 调用类型及数量不一致,若直接按照 API 粒度进行精度数据 dump 和比对,则无法完全比对所有的 API。
28
+
29
+ 本小节介绍的功能是对模型中的大粒度模块进行数据 dump,使其比对时,对于无法以 API 粒度比对的模块可以直接以模块粒度进行比对。
30
+
31
+ 模块指的是继承 nn.Module 类(PyTorch场景)或 nn.Cell 类(MindSpore场景)的子类,通常情况下这类模块就是一个小模型,可以被视为一个整体,dump 数据时以模块为粒度进行 dump。
32
+
33
+ ### 1.2 task 配置为 statistics
34
+
35
+ <table>
36
+ <tr><th>参数</th><th>解释</th><th>是否必选</th></tr>
37
+ <tr><td>scope</td><td>PyTorch 和 MindSpore 动态图场景 dump 范围,list[str] 类型,默认未配置(list 也未配置时表示 dump 所有 API 的数据)。该参数可以在 [ ] 内配置两个模块名或 API 名,用于锁定区间,dump 该范围内的数据;也可以在 [ ] 内配置一个模块名,表示dump此模块内部的API或子模块数据(仅level配置为mix时支持配置一个模块名)。<br/><b>配置示例</b>:"scope": ["MyModuleOP1", "MyModuleOP2"]或"scope": ["MyModuleOP1"]。与 level 参数取值相关,level 为 L0 和 mix 级别时,可配置模块名;level 为 L1 级别时,可配置 API 名。</td><td>否</td></tr>
38
+ <tr><td rowspan="4">list</td><td>自定义采集的算子列表,list[str] 类型,默认未配置(scope 也未配置时表示 dump 所有 API 的数据),包含以下配置方法:</td><td rowspan="4">否</td></tr>
39
+ <tr><td>PyTorch 和 MindSpore 动态图场景配置具体的 API 全称,dump 该 API 数据。<br/><b>配置示例</b>:"list": ["Tensor.permute.1.forward", "Tensor.transpose.2.forward", "Torch.relu.3.backward"]。</td></tr>
40
+ <tr><td>PyTorch 和 MindSpore 动态图场景指定某一类 API,dump 某一类的 API 级别输入输出数据。<br/><b>配置示例</b>:"list": ["relu"]。</td></tr>
41
+ <tr><td>MindSpore 静态图场景配置 kernel_name,可以是算子的名称列表,也可以指定算子类型("level": "L2"时不支持),还可以配置算子名称的正则表达式(当字符串符合“name-regex(xxx)”格式时,后台则会将其作为正则表达式。<br/><b>配置示例</b>:list: ["name-regex(Default/.+)"]<br/>可匹配算子名称以“Default/”开头的所有算子。</td></tr>
42
+ <tr><td rowspan="3">data_mode</td><td>dump 数据过滤,str 类型。</td><td rowspan="3">否</td></tr>
43
+ <tr><td>PyTorch 场景:支持"all"、"forward"、"backward"、"input"和"output",表示仅采集包含"forward"、"backward"、"input"和"output"字段的数据。<br/> <b>配置示例</b>:"data_mode": ["backward"] 或 "data_mode": ["forward", "backward"]。默认为["all"],即保存所有 dump 的数据。除了 all 参数只能单独配置外,其他参数可以自由组合。</td></tr>
44
+ <tr><td>MindSpore 场景:仅支持"all"、"input"和"output"参数,且各参数只能单独配置,不支持自由组合。<br/><b>配置示例</b>:"data_mode": ["all"]。</td></tr>
45
+ <tr><td>summary_mode</td><td>控制 dump 文件输出的模式,str 类型,仅 PyTorch 场景支持,可选参数:<br/> md5:dump 输出包含 md5 值以及 API 统计信息的 dump.json 文件,用于验证数据的完整性;<br/> statistics:dump 仅输出包含 API 统计信息的 dump.json 文件,默认值。<br/><b>配置示例</b>:"summary_mode": "md5"。</td><td>否</td></tr>
46
+ </table>
47
+
48
+
49
+
50
+
51
+ ### 1.3 task 配置为 tensor
52
+
53
+ | 参数 | 解释 | 是否必选 |
54
+ | -------------- | ---------------------- | -------- |
55
+ | scope | 与[ 1.2 task 配置为 statistics ](#12-task-配置为-statistics)中的解释相同。 | 否 |
56
+ | list | 与[ 1.2 task 配置为 statistics ](#12-task-配置为-statistics)中的解释相同。 | 否 |
57
+ | backward_input | 首次运行训练采集得到反向 API 输入的 dump 文件,list[str] 类型,仅支持 PyTorch 场景的 kernel dump,默认未配置。例如,若需要采集 Functional.conv2d.1 API 反向过程的输入输出,则需要在 dump 目录下查找命名包含 Functional.conv2d.1、backward 和 input 字段的 dump 文件。<br/>**配置示例**:"backward_input": ["./npu_dump/step0/rank0/dump_tensor_data/Functional.conv2d.1.backward.input.0.pt"] | 否 |
58
+ | list | 与[ 1.2 task 配置为 statistics ](#12-task-配置为-statistics)中的解释相同。另外,<br/> PyTorch 和 MindSpore 动态图场景配置 kernel_api,dump 前向和反向 API 的kernel_api 级别数据,其中 dump 反向 API 时需要配置 **backward_input** 参数。<br/>**前向 API 配置示例**:"list": ["Tensor.permute.1.forward"];<br/>**反向 API 配置示例**:"list": ["Tensor.permute.1.forward"], "backward.input": ["./npu_dump/step0/rank0/Functional.conv2d.1.backward.input.0.pt"]。<br/> | 否 |
59
+ | backward_input | 该输入文件为首次运行训练 dump 得到反向 API 输入的 dump 文件,list[str] 类型,仅 PyTorch 场景支持,默认未配置。例如若需要 dump Functional.conv2d.1 API 的反向过程的输入输出,则需要在 dump 目录下查找命名包含 Functional.conv2d.1、backward 和 input 字段的 dump 文件。<br/>**配置示例**:"backward_input": ["./npu_dump/step0/rank0/Functional.conv2d.1.backward.input.0.pt"] | 否 |
60
+ | data_mode | 与[ 1.2 task 配置为 statistics ](#12-task-配置为-statistics)中的解释相同 | 否 |
61
+ | file_format | tensor 数据的保存格式,str 类型,仅支持 MindSpore 静态图场景的 L2,不支持 L0 和 L1。可选参数:<br/> "bin":dump 的 tensor 文件为二进制格式;<br/>"npy":dump 的 tensor 文件后缀为 .npy,默认值。 | 否 |
62
+ | online_run_ut<sup>a</sup> | 在线预检模式开关,bool 类型,可选参数 true(开启)、false(关闭),默认未配置,表示关闭。配置为 true 表示开启在线预检。| 否 |
63
+ | nfs_path<sup>a</sup> | 在线预检模式共享存储目录路径,str 类型,用于 GPU 设备和 NPU 设备间进行通信。仅在 online_run_ut 字段配置为 true 时生效,配置该参数后 host 和 port 不生效。 | 否 |
64
+ | host<sup>a</sup> | 在线预检模式局域网场景信息接收端 IP,str 类型,用于 GPU 设备和 NPU 设备间进行通信,NPU 侧须配置为 GPU 侧的局域网 IP 地址。仅在 online_run_ut 字段配置为 true 时生效,局域网场景时,不能配置 nfs_path 参数,否则局域网场景不生效。 | 否 |
65
+ | port<sup>a</sup> | 在线预检模式局域网场景信息接收端端口号,int 类型,用于 GPU 设备和 NPU 设备间进行通信,NPU 侧须配置为 GPU 侧的端口号。仅在 online_run_ut 字段配置为 true 时生效,局域网场景时,不能配置 nfs_path 参数,否则局域网场景不生效。| 否 |
66
+
67
+ **a**:online_run_ut、nfs_path、host、port 等字段仅在线预检场景 NPU 机器生效。
68
+
69
+ ### 1.4 task 配置为 run_ut
70
+
71
+ | 参数 | 解释 | 是否必选 |
72
+ | --------------- | ------------------------ | ------------ |
73
+ | white_list<sup>a</sup> | API dump 白名单,仅对指定的 API 进行 dump。<br/>**配置示例**:"white_list": ["conv1d", "conv2d"]。默认未配置白名单,即 dump 全量 API 数据。 | 否 |
74
+ | black_list<sup>a</sup> | API dump 黑名单,被指定的 API 不进行 dump。<br/>**配置示例**:"black_list": ["conv1d", "conv2d"]。默认未配置黑名单,即 dump 全量 API 数据。 | 否 |
75
+ | error_data_path | 配置保存精度未达标的 API 输入输出数据路径,默认为当前路径。<br/>**配置示例**:"error_data_path": "./"。 | 否 |
76
+ | is_online<sup>b</sup> | 在线预检模式开关,bool 类型,可选参数 true(开启)、false(关闭),默认关闭。 | 否 |
77
+ | nfs_path<sup>b</sup> | 在线预检模式共享存储目录路径,str 类型,用于 GPU 设备和 NPU 设备间进行通信。配置该参数后 host 和 port 不生效,仅在 is_online 字段配置为 true 时生效。 | 否 |
78
+ | host<sup>b</sup> | 在线预检模式局域网场景信息接收端 IP,str 类型,用于 GPU 设备和 NPU 设备间进行通信,GPU 侧配置为本机地址 127.0.0.1 或本机局域网 IP。局域网场景时,不能配置 nfs_path 参数,否则局域网场景不生效。仅在 is_online 字段配置为 true 时生效。 | 否 |
79
+ | port<sup>b</sup> | 在线预检模式局域网场景信息接收端端口号,int 类型,用于 GPU 设备和 NPU 设备间进行通信,GPU 侧配置为本机可用端口。局域网场景时,不能配置 nfs_path 参数,否则局域网场景不生效。仅在 is_online 字段配置为 true 时生效。| 否 |
80
+ | rank_list<sup>b</sup> | 指定在线预检的 Rank ID,默认值为 [0],list[int] 类型,应配置为大于等于 0 的整数,且须根据实际卡的 Rank ID 配置,若所配置的值大于实际训练所运行的卡的 Rank ID,则在线预检输出数据为空。GPU 和 NPU 须配置一致。仅在 is_online 字段配置为 true 时生效。 | 否 |
81
+
82
+ **a**:white_list 和 black_list 同时配置时,二者配置的 API 名单若无交集,则白名单生效,若 API 名单存在交集,则白名单排除的部分以及交集的 API 不进行 dump。
83
+
84
+ **b**:is_online、nfs_path、host、port、rank_list 等字段仅在线预检场景 GPU 机器生效。
85
+
86
+ ### 1.5 task 配置为 overflow_check
87
+
88
+ PyTorch 与 MindSpore 动态图场景下,"level"须为"L1";MindSpore 静态图场景下,"level"须为"L2",且模型编译优化等级(jit_level)须为"O2"。
89
+
90
+ | 参数 | 解释 | 是否必选 |
91
+ | ------------- | ---------------------- | -------- |
92
+ | overflow_nums | 最大溢出次数,int 类型,默认为 1,仅 PyTorch 与 MindSpore 动态图场景支持。表示第 N 次溢出后,不再进行溢出检测。过程中检测到溢出 API 对应的 输入输出 数据均 dump。<br/>**配置示例**:"overflow_nums": 3。配置为 -1 时,表示持续检测溢出直到训练结束。 | 否 |
93
+ | check_mode | 溢出类型,str 类型,仅 MindSpore 场景支持,可选参数:<br/>"aicore":开启 AI Core 的溢出检测,不支持 MindSpore v2.3.0 以上版本;<br/>"atomic":开启 Atomic 的溢出检测,不支持 MindSpore v2.3.0 以上版本;<br/>"all":开启算子的溢出检测,默认值。<br/>**配置示例**:"check_mode": "all"。 | 否 |
94
+
95
+ ### 1.6 task 配置为 free_benchmark
96
+
97
+ 仅 PyTorch 场景与 MindSpore 动态图场景支持,且"level"为"L1"。
98
+
99
+ - task 配置为 free_benchmark 时,开启**无标杆比对**,在 NPU 环境下通过对当前模型 API 的输入添加扰动因子,二次执行,将得到的输出与未添加扰动因子前的输出进行比对,从而**得出该模型中可能存在因迁移等变化导致精度降低的 API**。
100
+
101
+ - 无标杆比对优势在于省去了从 CPU/GPU 环境获取标杆数据的步骤,也省去了在 NPU 环境执行 dump 的操作,降低了精度比对的操作难度。
102
+
103
+ - 建议配置白名单(配置 scope 或 list)控制少量 API 进行无标杆比对,一次对过多 API 执行无标杆比对可能导致显存溢出或性能膨胀。
104
+
105
+ <table>
106
+ <tr><th>参数</th><th>解释</th><th>是否必选</th></tr>
107
+ <tr><td>scope</td><td>自定义检测 API 列表(仅 PyTorch 场景支持),list[str] 类型,默认值为空列表,当 list 也为空列表时,表示检测所有 API。需要在 [ ] 内配置具体 API 名(在 dump 的结果中查看)。与 list 参数不能同时配置。<br/><b>配置示例</b>:"scope": ["Torch.matmul.0.forward", "Tensor.pow.4.forward"]。</td><td>否</td></tr>
108
+ <tr><td rowspan="3">list</td><td>自定义检测 API 类型或 API 名称,list[str] 类型,默认值为空列表,表示检测所有 API(PyTorch 场景下还需 scope 也为空列表)。与 scope 参数不能同时配置。</td><td rowspan="3">否</td></tr>
109
+ <tr><td>PyTorch 场景:指定某一类 API,对某一类的 API 进行无标杆比对。<br/><b>配置示例</b>:"list": ["relu"]。</td></tr>
110
+ <tr><td>MindSpore 场景:指定 API 名称,对列表中的 API 进行检测。<br/><b>配置示例</b>:"list": ["mindspore.mint.div", "mindspore.ops.bmm", "mindspore.Tensor.__add__"]。</td></tr>
111
+ <tr><td>fuzz_device</td><td>标杆设备,str 类型。可选参数:<br/> "npu":无标杆,通过添加扰动因子进行比对,默认值;<br/> "cpu":以 CPU 为标杆,pert_mode 须配置为"to_cpu"(仅 PyTorch 场景支持)。<br/><b>配置示例</b>:"fuzz_device": "npu"。</td><td>否</td></tr>
112
+ <tr><td>pert_mode</td><td>无标杆扰动因子,str 类型。可选参数:<br/> "improve_precision":对输入做升精度,默认值;<br/> "add_noise":对输入增加噪声;<br/> "no_change":不加扰动直接二次执行;<br/> "bit_noise":输入的末位比特翻转,MindSpore 场景不支持 BF16 类型的向量;<br/> "change_value":输入的张量首尾值调换;<br/> "to_cpu":在 CPU 等价执行(仅 PyTorch 场景支持)。<br/><b>配置示例</b>:"pert_mode": "improve_precision"。</td><td>否</td></tr>
113
+ <tr><td>handler_type</td><td>处理类型,可选参数:<br/> "check":进行无标杆比对检查,默认值;<br/> "fix":将扰动后的 API 输出结果覆盖原始 API 输出结果,尝试将 Loss 曲线恢复正常,该模式下不支持预热功能与反向过程,且仅支持"improve_precision"、"to_cpu"( PyTorch 场景)两种扰动因子。<br/> <b>配置示例</b>:"handler_type": "check"。</td><td>否</td></tr>
114
+ <tr><td>fuzz_level</td><td>无标杆数据 dump 级别,即选择比对结果文件应输出的表头属性,当前仅支持取值为:"L1"。输出结果详见 <a href="#161-无标杆比对数据存盘格式">1.6.1 无标杆比对数据存盘格式</a>。</td><td>否</td></tr>
115
+ <tr><td>fuzz_stage</td><td>比对过程,选择对 API 前向或反向进行无标杆比对,可选参数:<br/> "forward":前向,默认值;<br/> "backward":反向, 仅 PyTorch 场景支持。当 fuzz_stage 为 "backward" 时,handler_type 只能为 "check"。<br/> <b>配置示例</b>:"fuzz_stage": "backward"。</td><td>否</td></tr>
116
+ <tr><td>if_preheat</td><td>预热功能(仅 PyTorch 场景支持),bool 类型。开启功能后工具可以根据每次迭代的输出调整精度算法的阈值,从而更准确地找出存在精度问题的 API。当"handler_type": "fix"时,不支持预热。可选参数:<br/> true(开启)或 false(关闭),默认关闭。<br/> <b>配置示例</b>:"if_preheat": "true"。</td><td>否</td></tr>
117
+ <tr><td>preheat_step</td><td>开启预热的迭代数量(仅 PyTorch 场景支持),int 类型,默认值为 15。须配置 "if_preheat": "true"。</td><td>否</td></tr>
118
+ <tr><td>max_sample</td><td>每个算子预热的采样次数的最大阈值(仅 PyTorch 场景支持),int 类型,默认值为 20。须配置 "if_preheat": "true"。</td><td>否</td></tr>
119
+ </table>
120
+
121
+ #### 1.6.1 无标杆比对数据存盘格式
122
+
123
+ 无标杆比对在 dump_path 目录下输出结果文件 `free_benchmark.csv`,如下示例:
124
+
125
+ ![free_benchmark](./img/free_benchmark.png)
126
+
127
+ | 字段 | 解释 |
128
+ | ------------ | --------------------- |
129
+ | rank | Rank ID,int 类型。 |
130
+ | pert_mode | 扰动因子的类型,string 类型。 |
131
+ | stage | 前向或反向,string 类型。 |
132
+ | step | 迭代数,int 类型。 |
133
+ | api_name | API 名称,string 类型。 |
134
+ | max_rel | 输出对比最大相对误差,float 类型。 |
135
+ | dtype | 输入的 dtype,string 类型。 |
136
+ | shape | 输入的 shape,tuple 类型。 |
137
+ | output_index | 如果输出为列表或元组,其中一个元素检测不一致,则会有该元素的 index,否则为空,int 类型。 |
@@ -0,0 +1,237 @@
1
+ # config.json 配置示例
2
+
3
+ 以下示例包含当前支持的所有场景可配置的完整参数。
4
+
5
+ ## 1 PyTorch 场景
6
+
7
+ ### 1.1 task 配置为 statistics
8
+
9
+ ```json
10
+ {
11
+ "task": "statistics",
12
+ "dump_path": "/home/data_dump",
13
+ "rank": [],
14
+ "step": [],
15
+ "level": "L1",
16
+ "enable_dataloader": false,
17
+
18
+ "statistics": {
19
+ "scope": [],
20
+ "list": [],
21
+ "data_mode": ["all"],
22
+ "summary_mode": "statistics"
23
+ }
24
+ }
25
+ ```
26
+
27
+ ### 1.2 task 配置为 tensor
28
+
29
+ ```json
30
+ {
31
+ "task": "tensor",
32
+ "dump_path": "/home/data_dump",
33
+ "rank": [],
34
+ "step": [],
35
+ "level": "L1",
36
+ "enable_dataloader": false,
37
+
38
+ "tensor": {
39
+ "scope": [],
40
+ "list":[],
41
+ "data_mode": ["all"],
42
+ "backward_input": []
43
+ }
44
+ }
45
+ ```
46
+
47
+ ### 1.3 task 配置为 run_ut
48
+
49
+ ```json
50
+ {
51
+ "task": "run_ut",
52
+ "dump_path": "/home/data_dump",
53
+ "rank": [],
54
+ "step": [],
55
+ "level": "L1",
56
+ "enable_dataloader": false,
57
+
58
+ "run_ut": {
59
+ "white_list": [],
60
+ "black_list": [],
61
+ "error_data_path": "./"
62
+ }
63
+ }
64
+ ```
65
+
66
+ ### 1.4 task 配置为 overflow_check
67
+
68
+ ```json
69
+ {
70
+ "task": "overflow_check",
71
+ "dump_path": "/home/data_dump",
72
+ "rank": [],
73
+ "step": [],
74
+ "level": "L1",
75
+ "enable_dataloader": false,
76
+
77
+ "overflow_check": {
78
+ "overflow_nums": 1
79
+ }
80
+ }
81
+ ```
82
+
83
+ ### 1.5 task 配置为 free_benchmark
84
+
85
+ ```json
86
+ {
87
+ "task": "free_benchmark",
88
+ "dump_path": "/home/data_dump",
89
+ "rank": [],
90
+ "step": [],
91
+ "level": "L1",
92
+ "enable_dataloader": false,
93
+
94
+ "free_benchmark": {
95
+ "scope": [],
96
+ "list": ["conv2d"],
97
+ "fuzz_device": "npu",
98
+ "pert_mode": "improve_precision",
99
+ "handler_type": "check",
100
+ "fuzz_level": "L1",
101
+ "fuzz_stage": "forward",
102
+ "if_preheat": false,
103
+ "preheat_step": 15,
104
+ "max_sample": 20
105
+ }
106
+ }
107
+ ```
108
+
109
+ ## 2 MindSpore 静态图场景
110
+
111
+ ### 2.1 task 配置为 statistics
112
+
113
+ ```json
114
+ {
115
+ "task": "statistics",
116
+ "dump_path": "/home/data_dump",
117
+ "rank": [],
118
+ "step": [],
119
+ "level": "L2",
120
+
121
+ "statistics": {
122
+ "list": [],
123
+ "data_mode": ["all"],
124
+ "summary_mode": "statistics"
125
+ }
126
+ }
127
+ ```
128
+
129
+ ### 2.2 task 配置为 tensor
130
+
131
+ ```json
132
+ {
133
+ "task": "tensor",
134
+ "dump_path": "/home/data_dump",
135
+ "rank": [],
136
+ "step": [],
137
+ "level": "L2",
138
+
139
+ "tensor": {
140
+ "list":[],
141
+ "data_mode": ["all"],
142
+ "backward_input": []
143
+ }
144
+ }
145
+ ```
146
+
147
+ ### 2.3 task 配置为 overflow_check
148
+
149
+ ```json
150
+ {
151
+ "task": "overflow_check",
152
+ "dump_path": "/home/data_dump",
153
+ "rank": [],
154
+ "step": [],
155
+ "level": "L2",
156
+
157
+ "overflow_check": {
158
+ "check_mode": "all"
159
+ }
160
+ }
161
+ ```
162
+
163
+ ## 3 MindSpore 动态图场景
164
+
165
+ ### 3.1 task 配置为 statistics
166
+
167
+ ```json
168
+ {
169
+ "task": "statistics",
170
+ "dump_path": "/home/data_dump",
171
+ "rank": [],
172
+ "step": [],
173
+ "level": "L1",
174
+
175
+ "statistics": {
176
+ "scope": [],
177
+ "list": [],
178
+ "data_mode": ["all"],
179
+ "summary_mode": "statistics"
180
+ }
181
+ }
182
+ ```
183
+
184
+ ### 3.2 task 配置为 tensor
185
+
186
+ ```json
187
+ {
188
+ "task": "tensor",
189
+ "dump_path": "/home/data_dump",
190
+ "rank": [],
191
+ "step": [],
192
+ "level": "L1",
193
+
194
+ "tensor": {
195
+ "scope": [],
196
+ "list":[],
197
+ "data_mode": ["all"]
198
+ }
199
+ }
200
+ ```
201
+
202
+ ### 3.3 task 配置为 overflow_check
203
+
204
+ ```json
205
+ {
206
+ "task": "overflow_check",
207
+ "dump_path": "/home/data_dump",
208
+ "rank": [],
209
+ "step": [],
210
+ "level": "L1",
211
+
212
+ "overflow_check": {
213
+ "overflow_nums": 1
214
+ }
215
+ }
216
+ ```
217
+
218
+ ### 3.4 task 配置为 free_benchmark
219
+
220
+ ```json
221
+ {
222
+ "task": "free_benchmark",
223
+ "dump_path": "/home/data_dump",
224
+ "rank": [],
225
+ "step": [],
226
+ "level": "L1",
227
+
228
+ "free_benchmark": {
229
+ "list": ["mindspore.ops.add"],
230
+ "fuzz_device": "npu",
231
+ "pert_mode": "improve_precision",
232
+ "handler_type": "check",
233
+ "fuzz_level": "L1",
234
+ "fuzz_stage": "forward"
235
+ }
236
+ }
237
+ ```
@@ -0,0 +1,78 @@
1
+ # acl_config.json 配置文件说明
2
+
3
+ 当 PyTorch 场景 level 取"L2"时,须配置 acl_config 参数,并指定 acl_config.json 文件(用于指定 L2 kernel 级 dump 的配置),此时 **config.json** 文件配置示例如下:
4
+
5
+ ## 1 前向 kernel dump 配置示例
6
+
7
+ "scope"配置为前向 API 名称,仅支持配置一个 API。
8
+
9
+ ```json
10
+ {
11
+ "task": "tensor",
12
+ "dump_path": "/home/data_dump",
13
+ "level": "L2",
14
+ "rank": [0],
15
+ "step": [0],
16
+ "is_deterministic": false,
17
+
18
+ "tensor": {
19
+ "scope": ["Tensor.__mul__.10.forward"],
20
+ "list":[],
21
+ "data_mode": ["all"],
22
+ "backward_input": [""],
23
+ "file_format": "npy"
24
+ },
25
+ "acl_config": "acl_config.json"
26
+ }
27
+ ```
28
+
29
+ ## 2 反向 kernel dump 配置示例
30
+
31
+ 执行反向 kernel dump 前需要先使用工具 dump 该 API 的反向输入,保存 pt 文件,"backward_input"参数中传入该 pt 文件路径。
32
+
33
+ "scope"配置为反向 API 名称,仅支持配置一个 API。
34
+
35
+ ```json
36
+ {
37
+ "task": "tensor",
38
+ "dump_path": "/home/data_dump",
39
+ "level": "L2",
40
+ "rank": [0],
41
+ "step": [0],
42
+ "is_deterministic": false,
43
+
44
+ "tensor": {
45
+ "scope": ["Tensor.__mul__.10.backward"],
46
+ "list":[],
47
+ "data_mode": ["all"],
48
+ "backward_input": ["Tensor.__mul__.10.backward.input.0.pt"],
49
+ "file_format": "npy"
50
+ },
51
+ "acl_config": "acl_config.json"
52
+ }
53
+ ```
54
+
55
+ ## 3 acl_config.json 配置示例
56
+
57
+ 该文件须自行创建,配置示例如下:
58
+
59
+ ```json
60
+ {
61
+ "dump":
62
+ {
63
+ "dump_list":[],
64
+ "dump_path":"./dump/output",
65
+ "dump_mode":"all",
66
+ "dump_op_switch":"on"
67
+ }
68
+ }
69
+ ```
70
+
71
+ **acl_config.json 参数说明**
72
+
73
+ | 字段名 | 解释 |
74
+ | -------------- | ------------------------------------------------------------ |
75
+ | dump_list | 待 dump 数据的 API 模型。为空,无需配置。 |
76
+ | dump_path | dump 数据文件存储到运行环境的目录,主要配置的是 kernel 级数据的存放路径。支持配置绝对路径或相对路径。dump_path 须为已存在目录。 |
77
+ | dump_mode | dump 数据模式,可取值,<br/> output:dump API 的输出数据,默认值;<br/> input:dump API 的输入数据;<br/> all:dump API 的输入、输出数据。 |
78
+ | dump_op_switch | 单 API 模型 dump 数据开关,可取值,<br> off:关闭单 API 模型 dump,默认值;<br> on:开启单 API 模型 dump。 |