mindstudio-probe 8.2.1__py3-none-any.whl → 8.3.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 (40) hide show
  1. {mindstudio_probe-8.2.1.dist-info → mindstudio_probe-8.3.1.dist-info}/METADATA +1 -1
  2. {mindstudio_probe-8.2.1.dist-info → mindstudio_probe-8.3.1.dist-info}/RECORD +39 -40
  3. msprobe/README.md +7 -2
  4. msprobe/core/common/const.py +17 -3
  5. msprobe/core/common/file_utils.py +138 -32
  6. msprobe/core/common/framework_adapter.py +16 -6
  7. msprobe/core/common/utils.py +17 -0
  8. msprobe/core/compare/diff_analyze/first_diff_analyze.py +4 -16
  9. msprobe/core/compare/find_first/utils.py +1 -1
  10. msprobe/core/config_check/ckpt_compare/ckpt_comparator.py +6 -1
  11. msprobe/core/hook_manager.py +0 -1
  12. msprobe/docs/01.installation.md +2 -0
  13. msprobe/docs/02.config_introduction.md +1 -1
  14. msprobe/docs/14.data_parse_PyTorch.md +2 -0
  15. msprobe/docs/15.free_benchmarking_PyTorch.md +1 -1
  16. msprobe/docs/21.visualization_PyTorch.md +1 -1
  17. msprobe/docs/26.data_dump_PyTorch_baseline.md +3 -3
  18. msprobe/docs/32.ckpt_compare.md +5 -5
  19. msprobe/mindspore/api_accuracy_checker/generate_op_script/op_generator.py +1 -1
  20. msprobe/mindspore/compare/utils.py +1 -2
  21. msprobe/mindspore/monitor/module_hook.py +17 -20
  22. msprobe/msprobe.py +6 -4
  23. msprobe/pytorch/api_accuracy_checker/generate_op_script/op_generator.py +1 -1
  24. msprobe/pytorch/api_accuracy_checker/run_ut/multi_run_ut.py +34 -5
  25. msprobe/pytorch/common/utils.py +2 -52
  26. msprobe/pytorch/compare/utils.py +1 -2
  27. msprobe/pytorch/dump/module_dump/hook_wrapper.py +24 -0
  28. msprobe/pytorch/dump/module_dump/module_processer.py +27 -6
  29. msprobe/pytorch/hook_module/api_register.py +11 -2
  30. msprobe/pytorch/monitor/module_hook.py +16 -34
  31. msprobe/pytorch/pt_config.py +6 -0
  32. msprobe/visualization/builder/graph_builder.py +3 -2
  33. msprobe/visualization/builder/graph_merger.py +13 -0
  34. msprobe/visualization/graph/graph.py +13 -9
  35. msprobe/visualization/utils.py +11 -1
  36. msprobe/core/compare/diff_analyze/ignore_op_list.yaml +0 -3
  37. {mindstudio_probe-8.2.1.dist-info → mindstudio_probe-8.3.1.dist-info}/LICENSE +0 -0
  38. {mindstudio_probe-8.2.1.dist-info → mindstudio_probe-8.3.1.dist-info}/WHEEL +0 -0
  39. {mindstudio_probe-8.2.1.dist-info → mindstudio_probe-8.3.1.dist-info}/entry_points.txt +0 -0
  40. {mindstudio_probe-8.2.1.dist-info → mindstudio_probe-8.3.1.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mindstudio-probe
3
- Version: 8.2.1
3
+ Version: 8.3.1
4
4
  Summary: Ascend Probe Utils
5
5
  Home-page: https://gitcode.com/Ascend/mstt/tree/master/debug/accuracy_tools/msprobe
6
6
  Author: Ascend Team
@@ -1,21 +1,21 @@
1
1
  msprobe/CMakeLists.txt,sha256=Cx_WsHVxbX2gWZ6Hxah2zYXz2eamSb4CgIlzKm9OQGA,125
2
- msprobe/README.md,sha256=eIoPDZlbJi14BGR1BfJrtY-prviPZdgXrIFHUOhw67w,8611
2
+ msprobe/README.md,sha256=avO7tZ2lPArJMF12rlrZ0SYOD0PXR1x2eWkPE2RLcx4,9060
3
3
  msprobe/__init__.py,sha256=q2S8b3VTSn1wTMrkf8Gm79OOq9EerMIK6Y26gFdu_0s,688
4
4
  msprobe/config.json,sha256=QS37x2t0D-grehkpHLLxRAEZqOrkNe40GwwOaVMx3Yc,1061
5
- msprobe/msprobe.py,sha256=pWQYbbADJ-uydeyIqga2tznOCC-spY5r_gr5m75XBC0,8146
5
+ msprobe/msprobe.py,sha256=KHFMop_Tm9hHKTd1c-_HaVZjkT8DQ6Kx6PejIkrClME,8228
6
6
  msprobe/core/__init__.py,sha256=X_OkpIz42vnqhGy6WCeuEvYK4IFx4BwCT5bQj7tuuwI,757
7
7
  msprobe/core/common_config.py,sha256=0kzhosc3FIE0_JfAnOYx8lYLbno7j0rmH0ST9On1jpQ,7182
8
- msprobe/core/hook_manager.py,sha256=Bqo9T_Wn_rCriTfs5BaKfdrW-WuRbkQVBcPLK_CG_P8,13742
8
+ msprobe/core/hook_manager.py,sha256=PyOZjK3UrwV-Tmn_3J_Ydjia83TasgrP3hWeEU9YL_E,13693
9
9
  msprobe/core/service.py,sha256=FIYuVyHVVysFED5L3wPVZi8y8aT8ObiXtkfnhSnBGQo,13586
10
10
  msprobe/core/advisor/advisor.py,sha256=WP8rBF2F9pcSphZONJDgNfz9c6GiRxbkWwPS9wRU4Tc,5900
11
11
  msprobe/core/advisor/advisor_const.py,sha256=thEEVYKPimv9WGxxaC4vBXQ-Coq6yBlZ394T_b49Ibw,2624
12
12
  msprobe/core/advisor/advisor_result.py,sha256=yM78n6NXLP1bjTsGeSddwb1bWQwtg1ZqjnPHmTzVxHE,2359
13
- msprobe/core/common/const.py,sha256=r2wKstNjzjZOmGDw_q3jlN56hqA3tv5CtNNrdl8jZMk,27799
13
+ msprobe/core/common/const.py,sha256=2W9F588W134_ebIIIXpo7vup0TocUNJBELUH84Y2kKo,28099
14
14
  msprobe/core/common/db_manager.py,sha256=OjC7Gr_4CKmrlLcODsLkeTv1dU-VU93fmLU0xMfiPzg,9088
15
15
  msprobe/core/common/decorator.py,sha256=lj1upkAkGYeIV3tnH0bFqp7VDIKqTkFVaE5GUOFUNUE,1785
16
16
  msprobe/core/common/exceptions.py,sha256=PJB4UTxT5VxyUE9aTCgwxiEExcuQZCcbu5V7tFdLVrY,4045
17
- msprobe/core/common/file_utils.py,sha256=WTa9u07a1IiWkWBOAWpTVW7GPQ_7r9t9BldBZ5WIaSA,38564
18
- msprobe/core/common/framework_adapter.py,sha256=xwOOc0cbDt_nIqHsHYT8G6uqhvZywLcOnB0w5UzATFk,6255
17
+ msprobe/core/common/file_utils.py,sha256=G3tY0xu5A4RM2skYJXdIH93F52mjjx76qoBKDp0h0_s,42180
18
+ msprobe/core/common/framework_adapter.py,sha256=86tGwDOvX_3UCwZhmfK3Y2EebTpSDpH9MbMkUG06__A,6842
19
19
  msprobe/core/common/global_lock.py,sha256=MQedbRCzJTLAYGeNeeD1T7Vmn349r7ymGKt8d-U3m2Y,2721
20
20
  msprobe/core/common/inplace_op_checker.py,sha256=gwxpddOtPS2dRGbI2JB5ZixgoPLCYyDICb_07N9XVaM,1864
21
21
  msprobe/core/common/inplace_ops.yaml,sha256=Ta1zh6eF0A_Trd345gts2xlhFsU0-ZTXKEQOqUHT-54,3178
@@ -23,7 +23,7 @@ msprobe/core/common/log.py,sha256=VrecAUbJNfhm8tKtg-dGmLcOm3gM5XJth2tpeW6DsDo,33
23
23
  msprobe/core/common/megatron_utils.py,sha256=BALTlzSdHYsQ83s9XhHKo9Ub6CQGWeOqGF4SphXEDps,1864
24
24
  msprobe/core/common/parallel_state.py,sha256=WUfPtp4tfiV1E_oVkmQF2FZxO-sTgJtOsvDdSn4mdvY,8305
25
25
  msprobe/core/common/runtime.py,sha256=KpPoWIvIWSGjD-xnldxtZQXcEB6Ip2qj1hVIcZG4tWg,844
26
- msprobe/core/common/utils.py,sha256=v4qYIn833GCdcfjICpiEq4Keuc88IOEugNvwUyhIDI0,27410
26
+ msprobe/core/common/utils.py,sha256=8WsZVFPSifCahQ_REEZl85up_vQflZF6Tg1hoKBdxhY,27794
27
27
  msprobe/core/compare/acc_compare.py,sha256=M_Ie7Xtc8stbKNFVKZsLlp7R3i0RIu95vqzXYbX5sE0,38484
28
28
  msprobe/core/compare/check.py,sha256=L4sq90oXdNfqiM7BzxsCXU6zD55K1-0zjFTDKwII9Y0,4384
29
29
  msprobe/core/compare/compare_cli.py,sha256=B0WoZVAnWCKRAyRwDkYIKgIsTbKc4HA_8I8m2McO_OU,6940
@@ -35,13 +35,12 @@ msprobe/core/compare/npy_compare.py,sha256=aCylTUJuLUEsqqm-KySnY24egh5b36rTFh_dX
35
35
  msprobe/core/compare/utils.py,sha256=8vWFoqgqBY8XRc7eDOX2Lzaln26aPmaLF8Vs_xBQovk,35416
36
36
  msprobe/core/compare/diff_analyze/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  msprobe/core/compare/diff_analyze/diff_analyze_threshold.yaml,sha256=77K_1RM8ICVuDSNVTFIRdeBu15HyzR2Kw9YjhHaoaT0,193
38
- msprobe/core/compare/diff_analyze/first_diff_analyze.py,sha256=806wUTMhtfgzCH_Kbx4iZcJempzMjK26KcfS-R2F4Oo,5373
39
- msprobe/core/compare/diff_analyze/ignore_op_list.yaml,sha256=OOTJqiUqvMxH1O4jD9zXIz88Tg4U9XOa1gJp_MuvYYs,33
38
+ msprobe/core/compare/diff_analyze/first_diff_analyze.py,sha256=zXfaVYuMwA-y0upjQaycuQ2Q7dc2kqH8kAgWcWqXkVs,4755
40
39
  msprobe/core/compare/find_first/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
40
  msprobe/core/compare/find_first/analyzer.py,sha256=pfvg4wvgdFT0KdtdiTRYhqihTBTWMaer1Q_h0rAxq1M,12803
42
41
  msprobe/core/compare/find_first/data_processor.py,sha256=C286RlYVHH_2BzFxLHni7C2V4Z3tJJ9L4ZQhMGtxqMA,1485
43
42
  msprobe/core/compare/find_first/graph.py,sha256=2TaXfRUl8YLXM0wosdgz8nwNz5OxQ7gpmdfZWJ7JyG0,8024
44
- msprobe/core/compare/find_first/utils.py,sha256=awFmw4BDzbIHMG9fx8mJn9orBET3ofd1KJiXjHR9Cn0,6979
43
+ msprobe/core/compare/find_first/utils.py,sha256=-RyNXSIs6YHX77e7GgmvUJYJmSCj2t9uAqHmqBHw1kg,6984
45
44
  msprobe/core/compare/layer_mapping/__init__.py,sha256=MLMlb-zcaZCmG7Ykh6cY28kBTw-3_waNBRKbajwQc74,776
46
45
  msprobe/core/compare/layer_mapping/data_scope_parser.py,sha256=WU9nelUpbkPa7RH_G3QAHRUhiWSHQ7Bt7TTMGFy51eM,9429
47
46
  msprobe/core/compare/layer_mapping/layer_mapping.py,sha256=h6E6V0Kyb-Z_-7FCGHH8Qiqj1KopVO0c_8zeDvqiCrU,10586
@@ -60,7 +59,7 @@ msprobe/core/config_check/checkers/hyperparameter_checker.py,sha256=JIbEMTlfM-YN
60
59
  msprobe/core/config_check/checkers/pip_checker.py,sha256=r7PMSjwCODypcxk_yEhjZy2ydvd_sj3YkP0KKwgZlSE,3441
61
60
  msprobe/core/config_check/checkers/random_checker.py,sha256=hR6qJu18dtAcFvZokNcW6qzUxnaUz6U-XeCavyY0e-c,13158
62
61
  msprobe/core/config_check/checkers/weights_checker.py,sha256=ObjwgiNyB4nLKPFIhL71kNmjekaWZAXJtvwoyQatsoU,5825
63
- msprobe/core/config_check/ckpt_compare/ckpt_comparator.py,sha256=HEtfNU14vN8qpv7Rcr91zMn_-RqilJAgca35LAstaDc,3095
62
+ msprobe/core/config_check/ckpt_compare/ckpt_comparator.py,sha256=NxzmK4KT836tUZX91xs6kKXmjoHarUuI4J-MqgbtnWM,3511
64
63
  msprobe/core/config_check/ckpt_compare/megatron_loader.py,sha256=0HUEGsQQBBl-hI2CCZsPU7F-tqDwkG2miTjLYPA4zqo,12057
65
64
  msprobe/core/config_check/ckpt_compare/metrics.py,sha256=EDRLEFA_difzZWAfD-Y9-0qlk3Veu0IyKrpixrVCamo,2010
66
65
  msprobe/core/config_check/ckpt_compare/name_mapping.yaml,sha256=dC6SX0qYcOfgAw1wRhic_MxQFC5YNkogFajNszDIHUk,379
@@ -98,8 +97,8 @@ msprobe/core/overflow_check/utils.py,sha256=1j5p2qWBOmOoat1v_Zi8krLOWz2NMCdUjrnD
98
97
  msprobe/core/single_save/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
99
98
  msprobe/core/single_save/single_comparator.py,sha256=faYvqjvZNpA0GrtpI5pXTYOlvV8x5toKFdKVv5Nzk60,10827
100
99
  msprobe/core/single_save/single_saver.py,sha256=IVS7fsG5CWmZNCeUenNwtVxhAmpIWSYHK7az2NpZ678,5562
101
- msprobe/docs/01.installation.md,sha256=QmJlZPTVzoC1h9Ikgg7nB_u7Ay16Aoi9ZwiirC5mfdc,10845
102
- msprobe/docs/02.config_introduction.md,sha256=zUgDHk7WkfZkQZ2QdFv1DIdcN62i18fe1AR1zf6BHP0,32190
100
+ msprobe/docs/01.installation.md,sha256=I4iA214liJglmn7T6moGlipnWNy2y1aKNWAoHsU0BFE,11369
101
+ msprobe/docs/02.config_introduction.md,sha256=EVzpOM38ZsFde3PTQkR2LYepix-lpLbYIr9uKZuBNtU,32272
103
102
  msprobe/docs/03.config_examples.md,sha256=lHv_HLaCxk1nlSPIUF7wQVO0RR6_Q5b9XrSp96fr1FE,4408
104
103
  msprobe/docs/04.kernel_dump_PyTorch.md,sha256=1qXNBrdkO2r8FJjHObr1r2XGy7gIzhvZ3DWC0JjDPng,3034
105
104
  msprobe/docs/05.data_dump_PyTorch.md,sha256=0ZLkESAFa_HBlo8nndc7cWXQ0O1l7BuNCCy7eARTcm8,22242
@@ -110,26 +109,26 @@ msprobe/docs/10.accuracy_compare_PyTorch.md,sha256=3H_fHJBMRweqAxEOT6trHSQPAMjP3
110
109
  msprobe/docs/11.accuracy_compare_MindSpore.md,sha256=9zalk8EiYA_ex5kkiGEIn8yaNygLmJPplUoUEPs-C5w,40792
111
110
  msprobe/docs/12.overflow_check_PyTorch.md,sha256=VE76J_rFAFm0pw_bQEnKIV4FdXek4x7cenxTQQz2FK0,3793
112
111
  msprobe/docs/13.overflow_check_MindSpore.md,sha256=G67GjHo2VERAKsr1_uX0m67eNuG8E9aN6tmZiO1c_zg,2799
113
- msprobe/docs/14.data_parse_PyTorch.md,sha256=g1Hx3RFG7SIYTpTI2uySZjDIXwsF7LhVVghvITSp0L0,19125
114
- msprobe/docs/15.free_benchmarking_PyTorch.md,sha256=Dh4j8OKAqvMdNg4P7JPJnvbIrtLjku841HT_V5OrSTs,9732
112
+ msprobe/docs/14.data_parse_PyTorch.md,sha256=YWFj32k4L0n6D1-j9c-COvcUEczn-a-TxV4DJ7n2n_A,19394
113
+ msprobe/docs/15.free_benchmarking_PyTorch.md,sha256=6pIpLXx5lUu45_kdL31rhj9zV3Ew8X-yyqZXrJ_gZPk,9888
115
114
  msprobe/docs/16.free_benchmarking_MindSpore.md,sha256=swCOrnBSzU6Q5I0AHVwi2r0JfKp3VE1DgNHripyE01M,8195
116
115
  msprobe/docs/17.grad_probe.md,sha256=9g1aq6FettgpvzBxKj5C5W8bTsENPtt2itYaNOLcBk8,9624
117
116
  msprobe/docs/18.online_dispatch.md,sha256=Ae9ONIXF3wA2u0tikuDxV0nea_n5TIGug-PKTI9c7Ws,4170
118
117
  msprobe/docs/19.monitor.md,sha256=ogaecwFA5vpEyEEKuXaWmbaoClnPdtRedYhntppTAYo,57192
119
118
  msprobe/docs/20.monitor_performance_baseline.md,sha256=t-aM1s7BqEE8ls47gL1wmipkhdmB6CSPI90-r4abyXY,3672
120
- msprobe/docs/21.visualization_PyTorch.md,sha256=Mds0wPfD9XjNJstj-SZshhpFvUFYjh7ZZ-Zpefo3K4E,27666
119
+ msprobe/docs/21.visualization_PyTorch.md,sha256=lEt72aqsT5voRk38vAapXSJA_nzbu3DWq3-mEYKZowU,27678
121
120
  msprobe/docs/22.visualization_MindSpore.md,sha256=jtMgasjacyNEevhmrMT5Y8IOsAgEuDzBN7vvZYBJl7s,26605
122
121
  msprobe/docs/23.generate_operator_PyTorch.md,sha256=Tu_Jik6zWBIdf2ePOBeUAKnPMFnwcNdw1cuZg-Jfxbc,10289
123
122
  msprobe/docs/24.code_mapping_Mindspore.md,sha256=pFGY7uvNnaBqUDLQBDEay0In04nrpP2mFCzYfYYQEcs,2068
124
123
  msprobe/docs/25.tool_function_introduction.md,sha256=tqXbsW1xTbVBgke5bDd0B5NFxVGXmyqQkr63b9AtdFY,15668
125
- msprobe/docs/26.data_dump_PyTorch_baseline.md,sha256=nzBpiCcgvnuKKDD0CTS4k-htVnT45GFMG_rZH31NcLs,2554
124
+ msprobe/docs/26.data_dump_PyTorch_baseline.md,sha256=Di-qxaT7TckS4ggAJOk3R99DGlJ67i9Vw7Jl9fIoJNA,2551
126
125
  msprobe/docs/27.dump_json_instruction.md,sha256=YW6q4U0ccoFwax_fZ5Gqr1CQo5PFlKaxr9S-4ocycZs,21025
127
126
  msprobe/docs/28.debugger_save_instruction.md,sha256=pxvLlc2GmR8tmapZ8IKZyIFGwt1tEKXU4jy8Ao4MwrI,10173
128
127
  msprobe/docs/28.kernel_dump_MindSpore.md,sha256=USVxSPdhuaiw6dlWGu02GVNMXgaryHzy9dQPBUd1FfE,2540
129
128
  msprobe/docs/29.data_dump_MSAdapter.md,sha256=lWZaqR4ClAGW-YUj5jKZlJJqgOz2iIXgro3gq95VvMw,11615
130
129
  msprobe/docs/30.overflow_check_MSAdapter.md,sha256=leiJqnUR3L93K3-kDDeEPTcG5UeIl-Gjbq9GCzFjXNw,2208
131
130
  msprobe/docs/31.config_check.md,sha256=HsqOL1DHmnM-fR-QlrPVF0N2E5Aey9sFlLBTCG-1Us4,4171
132
- msprobe/docs/32.ckpt_compare.md,sha256=iPCUAC17GChf2_h4e2x4PaponRQYKcqZ-0jMoi2dS6c,2519
131
+ msprobe/docs/32.ckpt_compare.md,sha256=bne2nbNuX5Mz5UGVxOcy0VKHE-7PpIDk5qgGFstcZ8I,2956
133
132
  msprobe/docs/33.generate_operator_MindSpore.md,sha256=Q95U1T1g1p3OGDaFHKIA6Xb7h986SBrugKy6jaCQmjU,10005
134
133
  msprobe/docs/34.RL_collect.md,sha256=fC1nDBAFjEBnMbDOYvzujQjvpRCZK2wrRhl9odKInQ8,4430
135
134
  msprobe/docs/35.nan_analyze.md,sha256=YaY0v_n64JfSIdUVk_MYEJgPJukGBlWUV5qE1TLC9-w,3301
@@ -237,7 +236,7 @@ msprobe/mindspore/api_accuracy_checker/type_mapping.py,sha256=FL5SIQ3dJRKVmicvOO
237
236
  msprobe/mindspore/api_accuracy_checker/utils.py,sha256=uREcuxnIOy0Zeuqeo8wP4g33dcyqND_VtUIzKQBY2kQ,3951
238
237
  msprobe/mindspore/api_accuracy_checker/bench_functions/flash_attention_score.py,sha256=QJAveBVaeYN0Tmc75I-x4iA6nKpmk1Td_X3M76ClczA,23323
239
238
  msprobe/mindspore/api_accuracy_checker/bench_functions/fusion_operator.py,sha256=NXMgBWA8GW7NK7utftc5X-6aPp0c4uf_99kOUY1fwgA,1464
240
- msprobe/mindspore/api_accuracy_checker/generate_op_script/op_generator.py,sha256=lpHr1c1XesCNOfwFqTr97zqyPaE3H1cYY1SurYkzp_E,19490
239
+ msprobe/mindspore/api_accuracy_checker/generate_op_script/op_generator.py,sha256=GQxcUdKovpBbWuNtJtdvrlUQm05rj0RlV9RlpysZC7U,19491
241
240
  msprobe/mindspore/api_accuracy_checker/generate_op_script/operator_replication.template,sha256=ni56NrjDH0Qj-w13pDNw2XCqE-MOOmnq3jW2AuGm--I,81379
242
241
  msprobe/mindspore/code_mapping/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
243
242
  msprobe/mindspore/code_mapping/bind.py,sha256=oXxuSOmLN-qqcAyHC5gonw_PZMwEwGvTSW-ws5H5FiM,9549
@@ -253,7 +252,7 @@ msprobe/mindspore/compare/common_dir_compare.py,sha256=1vRos0zyadCmJefBjsvqVw5Xg
253
252
  msprobe/mindspore/compare/distributed_compare.py,sha256=H8zdjBBFyifyl3Nx21jtdoma6qN1duclPsJaArpAW1s,1556
254
253
  msprobe/mindspore/compare/ms_compare.py,sha256=yXs8wutN8fm_tcP39NQmNP5skai2CwfQScRhTTiUsM0,2237
255
254
  msprobe/mindspore/compare/ms_graph_compare.py,sha256=qph-gpAY0l5ApvQZ_xmq0SbUDVsuD8PtnD0jS7b6yRA,19949
256
- msprobe/mindspore/compare/utils.py,sha256=dNoyXNP7K5U68__flBLunmGVtog0OO21MP6aerpcwhI,1742
255
+ msprobe/mindspore/compare/utils.py,sha256=ZMJlIagUZKPv3HIhgCKG4MreRYFpsZtVMmZwUOOzOoI,1704
257
256
  msprobe/mindspore/debugger/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
258
257
  msprobe/mindspore/debugger/debugger_config.py,sha256=7DQ-g8KBOECCNXzsxvAqUU0ivCAsOcpduC6SUGs2JD0,8544
259
258
  msprobe/mindspore/debugger/precision_debugger.py,sha256=cTYWXfsZd4QbPvTqbSPkrWr7QSrMJvEgmHOz-W8fpQQ,10092
@@ -308,7 +307,7 @@ msprobe/mindspore/mindtorch/mindtorch_adaptor.py,sha256=M_1uX4Yc29Owz46diRsUbtRI
308
307
  msprobe/mindspore/monitor/common_func.py,sha256=L-t_w1nl---0T4W80Rtp0YijNx1GwFHkuhg9IV0wpbw,1549
309
308
  msprobe/mindspore/monitor/data_writers.py,sha256=xBj_kv1MpFH3DpB1mdl39vH-1_M81uz4rMJiz4ptKkw,8782
310
309
  msprobe/mindspore/monitor/features.py,sha256=l7PSxsEy7fwJJkzYW68CcUvtiW1Q4mq9N2j2d9pEAnw,4510
311
- msprobe/mindspore/monitor/module_hook.py,sha256=U4SDazoBsJttpUzyy_tsRfgL3QWbO8vFS-dJxEtcgAE,48326
310
+ msprobe/mindspore/monitor/module_hook.py,sha256=vFBztQ0IgzQ6UZCouWTGbaoZdfNmKG09fuBWYxpbo-Y,48081
312
311
  msprobe/mindspore/monitor/optimizer_collect.py,sha256=B_WsSnuX5LDAY2LTwuwwC8mMtVcR3X1iautlNzaxCSE,14419
313
312
  msprobe/mindspore/monitor/utils.py,sha256=Rnb0BOf1mFdhNfIkAL1cG0IzCsznaHYLBGInZbVFjXQ,3412
314
313
  msprobe/mindspore/monitor/distributed/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -324,7 +323,7 @@ msprobe/nan_analyze/graph.py,sha256=uSEYUC4I1KhGPUyi3E1BblNNpxUY3fjpf_sNnaaY7w4,
324
323
  msprobe/nan_analyze/utils.py,sha256=jwpnHcfluzBlytAcUuyAotj0Hw3zmi7e8ncf7rME2JU,7666
325
324
  msprobe/pytorch/__init__.py,sha256=qIvhnAk61oSpvPU0QI0YAC4zyLKYyOcfNzdXJxN7Klo,1035
326
325
  msprobe/pytorch/function_factory.py,sha256=Fi4w0zfO64Sd2IU9z45mBbDgS8k_CQEiZ9vRpC_TkVk,4031
327
- msprobe/pytorch/pt_config.py,sha256=xFge7ZvoObdvC3Bov45DgZQr4obEmmNVih1jQdQbEIY,11970
326
+ msprobe/pytorch/pt_config.py,sha256=1A6RhK6BBdMxXdYfLIcvtkOFUSXEaRMuNvaK6stjl7o,12284
328
327
  msprobe/pytorch/pytorch_service.py,sha256=f_ItlE28Ruhr1GgMjHA4iqg1sAqRthi129gfsFZFVDQ,2590
329
328
  msprobe/pytorch/api_accuracy_checker/.keep,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
330
329
  msprobe/pytorch/api_accuracy_checker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -343,7 +342,7 @@ msprobe/pytorch/api_accuracy_checker/compare/compare_column.py,sha256=2bQBWg8qVo
343
342
  msprobe/pytorch/api_accuracy_checker/compare/compare_input.py,sha256=OG83KTsDpc-NzUCjtMj5SnzuBmOHaQaJYPoyPaaxKfU,2059
344
343
  msprobe/pytorch/api_accuracy_checker/compare/compare_utils.py,sha256=o64RKRmaMe-8E3qsASZJOxI_SBT15O9SDB_Lz59iW28,9817
345
344
  msprobe/pytorch/api_accuracy_checker/generate_op_script/config_op.json,sha256=qIwrmgYSnO08FFrfIPhTWwB5XssHfWWsoRFzKIQYHxc,195
346
- msprobe/pytorch/api_accuracy_checker/generate_op_script/op_generator.py,sha256=zD8QPEDEXmZOUfpU_5wpXd4f60mZg6grN4H7favRNBM,24049
345
+ msprobe/pytorch/api_accuracy_checker/generate_op_script/op_generator.py,sha256=FLN9gRL6vmWcaRv2pvLU6t_tZTS-oJivHtcsvNOhkhI,24050
347
346
  msprobe/pytorch/api_accuracy_checker/generate_op_script/operator_replication.template,sha256=Qbv1_maNROMVcJAZgwemw42TZPfgkLP5CAWmjBJDAlk,25286
348
347
  msprobe/pytorch/api_accuracy_checker/precision_standard/absolute_threshold.py,sha256=4vtifRSecvSeTPjX_GVLDH75_phtfbkbhXUh2Y5H4O8,5535
349
348
  msprobe/pytorch/api_accuracy_checker/precision_standard/accumulative_error_compare.py,sha256=e0qANZpdGFsiezICAkLnULA9GmP3kjdCMEq1Y1wTgxI,5662
@@ -357,7 +356,7 @@ msprobe/pytorch/api_accuracy_checker/precision_standard/ulp_compare.py,sha256=pE
357
356
  msprobe/pytorch/api_accuracy_checker/run_ut/.keep,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
358
357
  msprobe/pytorch/api_accuracy_checker/run_ut/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
359
358
  msprobe/pytorch/api_accuracy_checker/run_ut/data_generate.py,sha256=t8DbR13Sna4d8ovyVmrrMw0xMEI9gueEHexLPKwrv8g,17599
360
- msprobe/pytorch/api_accuracy_checker/run_ut/multi_run_ut.py,sha256=vZUt-7zJ0RXSQrQFKMENFwi8Zhu8mUmHm1yifMIHLOY,10436
359
+ msprobe/pytorch/api_accuracy_checker/run_ut/multi_run_ut.py,sha256=kCssWavWUyZS7n4-mHK2JvJTng4xWUM4_LnzmOFqou8,12169
361
360
  msprobe/pytorch/api_accuracy_checker/run_ut/run_overflow_check.py,sha256=cl9Avx5-_ihF4KPuofGrhPw6dzQqHJLbZslluVPC-LQ,8060
362
361
  msprobe/pytorch/api_accuracy_checker/run_ut/run_ut.py,sha256=4f4Vh1oXGDzYKcTDFnS-ID5jxa1_bgO7q3H-cSKeF6c,22983
363
362
  msprobe/pytorch/api_accuracy_checker/run_ut/run_ut_utils.py,sha256=iZMGFpzQfK94Zxj7IJn0ldvcLHS5XVW63SCyK93doAo,11428
@@ -383,20 +382,20 @@ msprobe/pytorch/common/__init__.py,sha256=87H-l6y1gbEL2EQiSbPceeJwKJdcsS6zv-9Nmr
383
382
  msprobe/pytorch/common/compare_script.template,sha256=CsfmJ5IuPycAYa0-IfVPXrXVu-o6g8BeEF9v17UK_1w,286
384
383
  msprobe/pytorch/common/log.py,sha256=yGLpZ6mGfB-s9sHj_gcL5_PMq_Ai4BJxumA0F0knAso,1121
385
384
  msprobe/pytorch/common/parse_json.py,sha256=7HbrBdVCX8umYqa4u8JPHETAxUO1246jl7qhcE4FG1s,2286
386
- msprobe/pytorch/common/utils.py,sha256=KCjq5AbFoJKXH0JxTB8tCibhJbnv9A0riY7sMXC9k9I,17871
385
+ msprobe/pytorch/common/utils.py,sha256=3PShpmPAfGP4G-_CAPsLL0_XA6QMDeTwEUkkH14AKSE,16082
387
386
  msprobe/pytorch/compare/distributed_compare.py,sha256=uUMMB4cTsnxHUG8e8TyG5rcrqvip8-lo0DyMA0wB0zQ,916
388
387
  msprobe/pytorch/compare/mapping.yaml,sha256=Udlbf1dWDAdnTs8VcDTiSkqsMNj93o2qFUU2ocFgt2k,11697
389
388
  msprobe/pytorch/compare/match.py,sha256=j6ydfhs9zNMu6vzxsp_qMei-7-zDMuPO8Uj9i_OIhSA,1886
390
389
  msprobe/pytorch/compare/pt_compare.py,sha256=wUsLvx4lVPy3SbAeadO5Uw7kjDQhDJ7ZMx0UgBEFH38,2013
391
390
  msprobe/pytorch/compare/pt_diff_analyze.py,sha256=KG_7Diri1Nrl64FigVvAjMekSZ9SMWy3BqtqMpP75xE,893
392
- msprobe/pytorch/compare/utils.py,sha256=4F-CphKurzxAlMJezF-ELw5l-PFr8ZWPAB-htTc225g,1959
391
+ msprobe/pytorch/compare/utils.py,sha256=X_IsirhkQo1iH652WaJsnERsjYZaJ3DiP18RZr8EQ3c,1921
393
392
  msprobe/pytorch/debugger/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
394
393
  msprobe/pytorch/debugger/debugger_config.py,sha256=jP_xdwF1zV2YbvTrI8dB2PM1PQD0YGPOFSB9cIq_x1E,7993
395
394
  msprobe/pytorch/debugger/precision_debugger.py,sha256=pKAFBu1MIgG4sM27unnRRJolyj6eFpgs1O4JLKxaUTo,6718
396
395
  msprobe/pytorch/dump/module_dump/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
397
- msprobe/pytorch/dump/module_dump/hook_wrapper.py,sha256=0L8c2gYv0V8KHiNttYZMpAhSSxFtCuDaR_yFdWMoChs,3746
396
+ msprobe/pytorch/dump/module_dump/hook_wrapper.py,sha256=gVu8COEsGDRitROcFHK5AgQrQ4MydHNkdwAptQ2PMq4,4619
398
397
  msprobe/pytorch/dump/module_dump/module_dump.py,sha256=yHKVkDaxayrbanUkxc8Wo7crHc1KNPQAXpLFpbcybjY,1767
399
- msprobe/pytorch/dump/module_dump/module_processer.py,sha256=N-FPVJGEDYJM-59fAqrc5NssIRwtQ2yiU_HFqrY6zvI,13756
398
+ msprobe/pytorch/dump/module_dump/module_processer.py,sha256=i_Mevm4zlo48KB8sJtG1CVIhQMcpnuADoWB1ndsDTo4,14512
400
399
  msprobe/pytorch/free_benchmark/__init__.py,sha256=N2xdPic80U-Rl1B_6c8j09EMuU5Xn0knJjgmKQ5uiXQ,904
401
400
  msprobe/pytorch/free_benchmark/main.py,sha256=n-Q55NNoI0o7jhyhAUri68Fq-kyBa9xNLh5az5zBbaY,4802
402
401
  msprobe/pytorch/free_benchmark/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -428,7 +427,7 @@ msprobe/pytorch/grad_probe/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
428
427
  msprobe/pytorch/grad_probe/grad_monitor.py,sha256=xb3M1XguMxVsSgZuYwyB08tz_jno1-43cURs2pG1FYU,4910
429
428
  msprobe/pytorch/grad_probe/grad_stat_csv.py,sha256=k0YesT0Jy-2LsUlSYEDt8eRuhhfFhpSGv4ImtE74NH0,4940
430
429
  msprobe/pytorch/hook_module/__init__.py,sha256=ktS1W-6hBa1q8wF-DGz8kFsfVhiIPWBOj6C3kSatgno,679
431
- msprobe/pytorch/hook_module/api_register.py,sha256=PtTeEAMSoae5naegb6KjRG315b6_7UZc4gE8JiZlpSM,7037
430
+ msprobe/pytorch/hook_module/api_register.py,sha256=Vfdh-t0zBWinbzuXFqZ4WCSTTKexOFpaGAuEz2gUMgU,7313
432
431
  msprobe/pytorch/hook_module/hook_module.py,sha256=I1i_vISgVcLPd4uEYMMfr7Xfz76c3ASO0-XOcIoKxVA,3738
433
432
  msprobe/pytorch/hook_module/pt_hook_manager.py,sha256=x77ZU_YNYs5PB9snbopxSgyBmDNBEDQD5JeK1bcano4,5199
434
433
  msprobe/pytorch/hook_module/register_optimizer_hook.py,sha256=3JS0VqHAswQ7SlGXQ9gS9o4kGQYZflFAwOrJhUpB5gk,2539
@@ -440,7 +439,7 @@ msprobe/pytorch/monitor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
440
439
  msprobe/pytorch/monitor/csv2tb.py,sha256=OCsOtZ6G423Gu-WicF0eWijGeJ6TFY9Zefe-3SlAVI0,6557
441
440
  msprobe/pytorch/monitor/data_writers.py,sha256=ieJTuN7hSzusUqq-Pi251Xwtq1B6iwnIkmpuNIDq41w,9713
442
441
  msprobe/pytorch/monitor/features.py,sha256=BShZU-f5oQLc4zIfoRax_JHVMv79-hN18RS1at40IyY,6281
443
- msprobe/pytorch/monitor/module_hook.py,sha256=loTsPucohyS6w0tHtRoenq-XpErBFPafQ5CH2qNpU38,59817
442
+ msprobe/pytorch/monitor/module_hook.py,sha256=MuBB6JgZrgAuc_-v-t09bMN2BmzJXIoT6n6uNSSWlOE,59227
444
443
  msprobe/pytorch/monitor/module_metric.py,sha256=khxcepVffT0B7pvI0c80NCOFMwxX23tLimElyJ3Rls0,6328
445
444
  msprobe/pytorch/monitor/optimizer_collect.py,sha256=-ai9XAXP4gTsuTQ3cecVZySWS8Zb3PABuxcJSm9XGPw,19947
446
445
  msprobe/pytorch/monitor/utils.py,sha256=uBSJfpYRbi3YJRy0fHyIoY3bAnmIRF2kErdvZ1R2HSo,1641
@@ -470,10 +469,10 @@ msprobe/pytorch/parse_tool/lib/visualization.py,sha256=_M1R4kiyc3zdxyoHRqFoxMEfm
470
469
  msprobe/visualization/__init__.py,sha256=rEvJTAx-jTGHBM7-bB6VZ7fwfWwYA961M1eZJj4sRcY,622
471
470
  msprobe/visualization/db_utils.py,sha256=GhazcnqNQ27n-kpfxcuW8nK83_uC336S3-C0zpoNZ2I,9449
472
471
  msprobe/visualization/graph_service.py,sha256=_GfTbRtutN5Yk25cvV9kzD5kVWrgcHD5t6gkSbX5P5o,26302
473
- msprobe/visualization/utils.py,sha256=w40WEx16RrEh43h48KV2R1T48ydAZT08FNb6OUoB_3s,11899
472
+ msprobe/visualization/utils.py,sha256=P5Ds9uMRoMPRNft8XTSiqDrGAbEG7bQbIZD6qJy3Lvs,12620
474
473
  msprobe/visualization/builder/__init__.py,sha256=rEvJTAx-jTGHBM7-bB6VZ7fwfWwYA961M1eZJj4sRcY,622
475
- msprobe/visualization/builder/graph_builder.py,sha256=Sw3_weDDVJ5JT7Hs9YBNIH8xsGbIlbiLazl24IfZshk,20430
476
- msprobe/visualization/builder/graph_merger.py,sha256=RbNJ8yFPwJDmMwtTRfccskqSxBGixzOsh6wRQ-LK_40,50849
474
+ msprobe/visualization/builder/graph_builder.py,sha256=yL7rHq4F94zWYBYJCyQvY3gLwzhLWnV6oLsVfUZ8AZo,20535
475
+ msprobe/visualization/builder/graph_merger.py,sha256=Zpk0Kg54Ad2dKZqwxN5wE0A1MCdgoX31O9WIRv0Z9UU,51901
477
476
  msprobe/visualization/builder/msprobe_adapter.py,sha256=V-K90RqY02hmRJL_lxiyJjZIkwE-843hM1ruc6N2Wdc,9125
478
477
  msprobe/visualization/compare/__init__.py,sha256=vd0u6IEpGE1r-HC4CEhs3csiMaa0bxuFcHtyRlAX0kU,618
479
478
  msprobe/visualization/compare/graph_comparator.py,sha256=v1YbN5oIqcmnZZ7oZBJEH_EXen1Y9bvh9Itul7erb8o,10282
@@ -481,12 +480,12 @@ msprobe/visualization/compare/mode_adapter.py,sha256=d7yjHzL1rwAg0E8RJRU0B0s7S90
481
480
  msprobe/visualization/graph/__init__.py,sha256=rEvJTAx-jTGHBM7-bB6VZ7fwfWwYA961M1eZJj4sRcY,622
482
481
  msprobe/visualization/graph/base_node.py,sha256=tai40AZ_0PXkpPgEQbnTAcf8K0XSMWfKkrnJF7VMrCc,3725
483
482
  msprobe/visualization/graph/distributed_analyzer.py,sha256=IVPaA6Z3uZxuOob7fibgc9zGFMjtC-LaqQBzaragWbw,19046
484
- msprobe/visualization/graph/graph.py,sha256=5AokyZE1nGZD_grRJZL8_gmpH3zkns9WOeHyuc1r75g,8607
483
+ msprobe/visualization/graph/graph.py,sha256=SFf_x4a3e5ejUe6PntPeEqnGCPaR6gUWpak6w_hyIBE,8776
485
484
  msprobe/visualization/graph/node_colors.py,sha256=7LpurTuE3edKGilwLVsXD7Ue4bMT7Maz63Udq_6CADM,4504
486
485
  msprobe/visualization/graph/node_op.py,sha256=qkbw3ZJkKGQH071C1CLIXi4kavvsLxBTzt0KXncz6fY,1368
487
- mindstudio_probe-8.2.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
488
- mindstudio_probe-8.2.1.dist-info/METADATA,sha256=mokGkctgy0FweYXTJ44Fs2qSncnlBKN7hod2hXFAzlY,1437
489
- mindstudio_probe-8.2.1.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
490
- mindstudio_probe-8.2.1.dist-info/entry_points.txt,sha256=4ob3a9L018EBZFdlfgMW1lbgeIOhc4F-HCR8gBksaCQ,49
491
- mindstudio_probe-8.2.1.dist-info/top_level.txt,sha256=LxFEFqelENSyWmRtocCiEUF04IE8aZvwTl7ADB598Tk,8
492
- mindstudio_probe-8.2.1.dist-info/RECORD,,
486
+ mindstudio_probe-8.3.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
487
+ mindstudio_probe-8.3.1.dist-info/METADATA,sha256=r3DZB8reM8qZOOrmbvMGNGFRKXQaH5y86T4GWCcgQ_M,1437
488
+ mindstudio_probe-8.3.1.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
489
+ mindstudio_probe-8.3.1.dist-info/entry_points.txt,sha256=4ob3a9L018EBZFdlfgMW1lbgeIOhc4F-HCR8gBksaCQ,49
490
+ mindstudio_probe-8.3.1.dist-info/top_level.txt,sha256=LxFEFqelENSyWmRtocCiEUF04IE8aZvwTl7ADB598Tk,8
491
+ mindstudio_probe-8.3.1.dist-info/RECORD,,
msprobe/README.md CHANGED
@@ -50,9 +50,14 @@ export MSPROBE_LOG_LEVEL={x}
50
50
 
51
51
  ## 🚨 工具限制与注意事项
52
52
 
53
- **1. Pytorch 框架下,工具暂不支持 Fully Sharded Data Parallel(FSDP)。**
53
+ **1. 工具读写的所有路径,如config_path、dump_path等,只允许包含大小写字母、数字、下划线、斜杠、点和短横线。**
54
+
55
+ **2. 出于安全性及权限最小化角度考虑,msprobe工具不应使用root等高权限账户使用,建议使用普通用户权限安装执行。**
56
+
57
+ **3. 使用msprobe工具前请确保执行用户的umask值大于等于0027,否则可能会导致工具生成的精度数据文件和目录权限过大。**
58
+
59
+ **4. 用户须自行保证使用最小权限原则,如给工具输入的文件要求other用户不可写,在一些对安全要求更严格的功能场景下还需确保输入的文件group用户不可写。**
54
60
 
55
- **2. 工具读写的所有路径,如config_path、dump_path等,只允许包含大小写字母、数字、下划线、斜杠、点和短横线。**
56
61
 
57
62
  ## ⚙️ 安装
58
63
 
@@ -691,9 +691,23 @@ class FileCheckConst:
691
691
  """
692
692
  Class for file check const
693
693
  """
694
- READ_ABLE = "read"
695
- WRITE_ABLE = "write"
696
- READ_WRITE_ABLE = "read and write"
694
+ READ_ABLE = "r"
695
+ WRITE_ABLE = "w"
696
+ EXECUTE_ABLE = "x"
697
+ READ_WRITE_ABLE = "rw"
698
+ READ_EXECUTE_ABLE = "rx"
699
+ WRITE_EXECUTE_ABLE = "wx"
700
+ READ_WRITE_EXECUTE_ABLE = "rwx"
701
+ PERM_OPTIONS = [
702
+ READ_ABLE,
703
+ WRITE_ABLE,
704
+ EXECUTE_ABLE,
705
+ READ_WRITE_ABLE,
706
+ READ_EXECUTE_ABLE,
707
+ WRITE_EXECUTE_ABLE,
708
+ READ_WRITE_EXECUTE_ABLE
709
+ ]
710
+
697
711
  DIRECTORY_LENGTH = 4096
698
712
  FILE_NAME_LENGTH = 255
699
713
  FILE_VALID_PATTERN = r"^[a-zA-Z0-9_.:/-]+$"
@@ -12,29 +12,31 @@
12
12
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
+
15
16
  import atexit
16
17
  import csv
17
18
  import fcntl
18
19
  import io
20
+ import json
21
+ import multiprocessing
19
22
  import os
20
23
  import pickle
21
- from multiprocessing import shared_memory
22
- import stat
23
- import json
24
24
  import re
25
25
  import shutil
26
+ import stat
26
27
  import sys
27
28
  import zipfile
28
- import multiprocessing
29
- import yaml
29
+ from multiprocessing import shared_memory
30
+
30
31
  import numpy as np
31
32
  import pandas as pd
33
+ import yaml
32
34
 
35
+ from msprobe.core.common.const import FileCheckConst, CompareConst, Const
33
36
  from msprobe.core.common.decorator import recursion_depth_decorator
34
- from msprobe.core.common.log import logger
35
37
  from msprobe.core.common.exceptions import FileCheckException
36
- from msprobe.core.common.const import FileCheckConst, CompareConst, Const
37
38
  from msprobe.core.common.global_lock import global_lock, is_main_process
39
+ from msprobe.core.common.log import logger
38
40
 
39
41
  proc_lock = multiprocessing.Lock()
40
42
 
@@ -44,18 +46,23 @@ class FileChecker:
44
46
  The class for check file.
45
47
 
46
48
  Attributes:
47
- file_path: The file or dictionary path to be verified.
48
- path_type: file or dictionary
49
- ability(str): FileCheckConst.WRITE_ABLE or FileCheckConst.READ_ABLE to set file has writability or readability
49
+ file_path: The file or dictionary path to be verified
50
+ path_type: file or dictionary type
51
+ ability(str): one of ["r", "w", "x", "rw", "rx", "wx", "rwx"], r: read, w: write, x: execute
50
52
  file_type(str): The correct file type for file
51
53
  """
52
54
 
53
- def __init__(self, file_path, path_type, ability=None, file_type=None, is_script=True):
55
+ def __init__(
56
+ self,
57
+ file_path,
58
+ path_type,
59
+ ability=None,
60
+ file_type=None
61
+ ):
54
62
  self.file_path = file_path
55
63
  self.path_type = self._check_path_type(path_type)
56
- self.ability = ability
64
+ self.ability = self._check_ability_type(ability)
57
65
  self.file_type = file_type
58
- self.is_script = is_script
59
66
 
60
67
  @staticmethod
61
68
  def _check_path_type(path_type):
@@ -64,9 +71,16 @@ class FileChecker:
64
71
  raise FileCheckException(FileCheckException.ILLEGAL_PARAM_ERROR)
65
72
  return path_type
66
73
 
74
+ @staticmethod
75
+ def _check_ability_type(ability):
76
+ if ability and ability not in FileCheckConst.PERM_OPTIONS:
77
+ logger.error(f'The ability must be one of {FileCheckConst.PERM_OPTIONS}.')
78
+ raise FileCheckException(FileCheckException.ILLEGAL_PARAM_ERROR)
79
+ return ability
80
+
67
81
  def common_check(self):
68
82
  """
69
- 功能:用户校验基本文件权限:软连接、文件长度、是否存在、读写权限、文件属组、文件特殊字符
83
+ 功能:基本文件权限校验,包括文件存在性、软连接、文件长度、文件类型、文件读写权限、文件属组、文件路径特殊字符、文件后缀名等
70
84
  注意:文件后缀的合法性,非通用操作,可使用其他独立接口实现
71
85
  """
72
86
  check_path_exists(self.file_path)
@@ -75,23 +89,25 @@ class FileChecker:
75
89
  check_path_length(self.file_path)
76
90
  check_path_type(self.file_path, self.path_type)
77
91
  self.check_path_ability()
78
- if self.is_script:
79
- check_path_owner_consistent(self.file_path)
92
+ check_path_owner_consistent(self.file_path)
80
93
  check_path_pattern_valid(self.file_path)
81
94
  check_common_file_size(self.file_path)
82
95
  check_file_suffix(self.file_path, self.file_type)
96
+ check_path_no_others_write(self.file_path)
83
97
  if self.path_type == FileCheckConst.FILE:
84
- check_dirpath_before_read(self.file_path)
98
+ check_dirpath_permission(self.file_path)
85
99
  return self.file_path
86
100
 
87
101
  def check_path_ability(self):
88
- if self.ability == FileCheckConst.WRITE_ABLE:
89
- check_path_writability(self.file_path)
90
- if self.ability == FileCheckConst.READ_ABLE:
91
- check_path_readability(self.file_path)
92
- if self.ability == FileCheckConst.READ_WRITE_ABLE:
102
+ if not self.ability:
103
+ return
104
+
105
+ if FileCheckConst.READ_ABLE in self.ability:
93
106
  check_path_readability(self.file_path)
107
+ if FileCheckConst.WRITE_ABLE in self.ability:
94
108
  check_path_writability(self.file_path)
109
+ if FileCheckConst.EXECUTE_ABLE in self.ability:
110
+ check_path_executable(self.file_path)
95
111
 
96
112
 
97
113
  class FileOpen:
@@ -137,7 +153,8 @@ class FileOpen:
137
153
  check_path_pattern_valid(self.file_path)
138
154
  if os.path.exists(self.file_path):
139
155
  check_common_file_size(self.file_path)
140
- check_dirpath_before_read(self.file_path)
156
+ check_path_no_others_write(self.file_path)
157
+ check_dirpath_permission(self.file_path)
141
158
 
142
159
  def check_ability_and_owner(self):
143
160
  if self.mode in self.SUPPORT_READ_MODE:
@@ -256,12 +273,15 @@ def check_path_type(file_path, file_type):
256
273
  raise FileCheckException(FileCheckException.INVALID_FILE_ERROR)
257
274
 
258
275
 
259
- def check_others_writable(directory):
260
- dir_stat = os.stat(directory)
261
- is_writable = (
262
- bool(dir_stat.st_mode & stat.S_IWGRP) or # 组可写
263
- bool(dir_stat.st_mode & stat.S_IWOTH) # 其他用户可写
264
- )
276
+ def check_group_writable(file_path):
277
+ path_stat = os.stat(file_path)
278
+ is_writable = bool(path_stat.st_mode & stat.S_IWGRP)
279
+ return is_writable
280
+
281
+
282
+ def check_others_writable(file_path):
283
+ path_stat = os.stat(file_path)
284
+ is_writable = bool(path_stat.st_mode & stat.S_IWOTH)
265
285
  return is_writable
266
286
 
267
287
 
@@ -309,7 +329,7 @@ def check_path_before_create(path):
309
329
  'The file path {} contains special characters.'.format(path))
310
330
 
311
331
 
312
- def check_dirpath_before_read(path):
332
+ def check_dirpath_permission(path):
313
333
  path = os.path.realpath(path)
314
334
  dirpath = os.path.dirname(path)
315
335
  if dedup_log('check_dirpath_before_read', dirpath):
@@ -321,13 +341,14 @@ def check_dirpath_before_read(path):
321
341
  logger.warning(f"The directory {dirpath} is not yours.")
322
342
 
323
343
 
324
- def check_file_or_directory_path(path, isdir=False):
344
+ def check_file_or_directory_path(path, isdir=False, is_strict=False):
325
345
  """
326
346
  Function Description:
327
347
  check whether the path is valid
328
348
  Parameter:
329
349
  path: the path to check
330
350
  isdir: the path is dir or file
351
+ is_strict: whether to perform stricter validation (e.g., verify group cannot write to path)
331
352
  Exception Description:
332
353
  when invalid data throw exception
333
354
  """
@@ -337,6 +358,33 @@ def check_file_or_directory_path(path, isdir=False):
337
358
  path_checker = FileChecker(path, FileCheckConst.FILE, FileCheckConst.READ_ABLE)
338
359
  path_checker.common_check()
339
360
 
361
+ if is_strict:
362
+ if check_group_writable(path):
363
+ raise FileCheckException(
364
+ FileCheckException.FILE_PERMISSION_ERROR,
365
+ f"The directory/file must not allow write access to group. Directory/File path: {path}"
366
+ )
367
+
368
+
369
+ def check_path_no_others_write(file_path):
370
+ if dedup_log('check_path_no_others_write', file_path):
371
+ if check_group_writable(file_path):
372
+ logger.warning(f"The directory/file path is writable by group: {file_path}.")
373
+
374
+ if check_others_writable(file_path):
375
+ raise FileCheckException(
376
+ FileCheckException.FILE_PERMISSION_ERROR,
377
+ f"The directory/file must not allow write access to others. Directory/File path: {file_path}"
378
+ )
379
+
380
+
381
+ def check_path_no_group_others_write(file_path):
382
+ if check_group_writable(file_path) or check_others_writable(file_path):
383
+ raise FileCheckException(
384
+ FileCheckException.FILE_PERMISSION_ERROR,
385
+ f"The directory/file must not allow write access to group or others. Directory/File path: {file_path}"
386
+ )
387
+
340
388
 
341
389
  def change_mode(path, mode):
342
390
  if not os.path.exists(path) or os.path.islink(path):
@@ -388,6 +436,14 @@ def check_file_type(path):
388
436
  raise FileCheckException(FileCheckException.INVALID_FILE_ERROR)
389
437
 
390
438
 
439
+ def root_privilege_warning():
440
+ if os.getuid() == 0:
441
+ logger.warning(
442
+ "msprobe is being run as root. "
443
+ "To avoid security risks, it is recommended to switch to a regular user to run it."
444
+ )
445
+
446
+
391
447
  def load_yaml(yaml_path):
392
448
  path_checker = FileChecker(yaml_path, FileCheckConst.FILE, FileCheckConst.READ_ABLE, FileCheckConst.YAML_SUFFIX)
393
449
  checked_path = path_checker.common_check()
@@ -968,7 +1024,13 @@ class SharedDict:
968
1024
  def _safe_load(self):
969
1025
  with io.BytesIO(self._shm.buf[:]) as buff:
970
1026
  try:
971
- self._dict = SafeUnpickler(buff).load()
1027
+ data = SafeUnpickler(buff).load()
1028
+ if not isinstance(data, dict):
1029
+ logger.debug(f"Data from shared memory is '{type(data)}' type, expected 'dict'.")
1030
+ self._dict = {}
1031
+ self._changed = True
1032
+ else:
1033
+ self._dict = data
972
1034
  except Exception as e:
973
1035
  logger.debug(f'shared dict is unreadable, reason: {e}, create new dict.')
974
1036
  self._dict = {}
@@ -985,4 +1047,48 @@ class SafeUnpickler(pickle.Unpickler):
985
1047
  raise pickle.PicklingError(f'Unpickling {module}.{name} is illegal!')
986
1048
 
987
1049
 
1050
+ class DeserializationScanner:
1051
+ """反序列化风险扫描器"""
1052
+
1053
+ DANGEROUS_METHODS = {
1054
+ '__reduce__', '__reduce_ex__', '__setstate__', '__getstate__',
1055
+ '__new__', '__init__', '__del__',
1056
+ '__call__', '__enter__', '__exit__',
1057
+ 'eval', 'exec', 'compile', '__import__', 'open'
1058
+ 'os.system', 'os.popen', 'subprocess.call', 'subprocess.Popen',
1059
+ }
1060
+
1061
+ DANGEROUS_MODULES = {
1062
+ 'os', 'sys', 'subprocess', 'shutil', 'socket',
1063
+ 'requests', 'urllib', 'ftplib', 'smtplib',
1064
+ }
1065
+
1066
+ @classmethod
1067
+ def scan_pickle_content(cls, filepath: str) -> bool:
1068
+ with FileOpen(filepath, 'rb') as f:
1069
+ content = f.read()
1070
+
1071
+ try:
1072
+ text_content = content.decode('latin-1')
1073
+ except Exception as e:
1074
+ text_content = str(content)
1075
+
1076
+ for method in cls.DANGEROUS_METHODS:
1077
+ if re.fullmatch(method, text_content):
1078
+ logger.warning(f"Insecure method found: {method}")
1079
+ return False
1080
+
1081
+ for module in cls.DANGEROUS_MODULES:
1082
+ patterns = [
1083
+ f"import {module}",
1084
+ f"from {module} import",
1085
+ f"{module}.",
1086
+ ]
1087
+ for pattern in patterns:
1088
+ if pattern in text_content:
1089
+ logger.warning(f"Insecure module found: {module}")
1090
+ return False
1091
+ return True
1092
+
1093
+
988
1094
  atexit.register(SharedDict.destroy_shared_memory)
@@ -12,10 +12,13 @@
12
12
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.import functools
15
+
15
16
  import functools
17
+
16
18
  from msprobe.core.common.const import Const
17
- from msprobe.core.common.file_utils import check_file_or_directory_path
18
- from msprobe.core.common.file_utils import save_npy
19
+ from msprobe.core.common.file_utils import check_file_or_directory_path, save_npy, DeserializationScanner
20
+ from msprobe.core.common.log import logger
21
+ from msprobe.core.common.utils import confirm
19
22
 
20
23
 
21
24
  class FrameworkDescriptor:
@@ -103,7 +106,7 @@ class FmkAdp:
103
106
  @classmethod
104
107
  def tensor_norm(cls, tensor):
105
108
  return cls.process_tensor(tensor, lambda x: x.norm())
106
-
109
+
107
110
  @classmethod
108
111
  def save_tensor(cls, tensor, filepath):
109
112
  if cls.fmk == Const.PT_FRAMEWORK:
@@ -151,9 +154,16 @@ class FmkAdp:
151
154
 
152
155
  @classmethod
153
156
  def load_checkpoint(cls, path, to_cpu=True, weights_only=True):
154
- check_file_or_directory_path(path)
157
+ check_file_or_directory_path(path, is_strict=not weights_only)
155
158
  if cls.fmk == Const.PT_FRAMEWORK:
156
159
  try:
160
+ if not weights_only:
161
+ if not DeserializationScanner.scan_pickle_content(path):
162
+ if not confirm(
163
+ f"Some insecure methods or modules are detected in {path}, "
164
+ f"input yes to ignore and continue, otherwise exit", False):
165
+ logger.error("Insecure risks found and exit!")
166
+ raise Exception("Insecure risks found and exit!")
157
167
  if to_cpu:
158
168
  return cls.framework.load(path, map_location=cls.framework.device("cpu"), weights_only=weights_only)
159
169
  else:
@@ -161,9 +171,9 @@ class FmkAdp:
161
171
  except Exception as e:
162
172
  raise RuntimeError(f"load pt file {path} failed: {e}") from e
163
173
  return mindspore.load_checkpoint(path)
164
-
174
+
165
175
  @classmethod
166
176
  def asnumpy(cls, tensor):
167
177
  if cls.fmk == Const.PT_FRAMEWORK:
168
178
  return tensor.float().numpy()
169
- return tensor.float().asnumpy()
179
+ return tensor.float().asnumpy()