mindspore 2.4.1__cp39-cp39-win_amd64.whl → 2.5.0__cp39-cp39-win_amd64.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.

Potentially problematic release.


This version of mindspore might be problematic. Click here for more details.

Files changed (395) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/Microsoft.VisualStudio.Telemetry.dll +0 -0
  3. mindspore/Newtonsoft.Json.dll +0 -0
  4. mindspore/__init__.py +8 -3
  5. mindspore/_c_dataengine.cp39-win_amd64.pyd +0 -0
  6. mindspore/_c_expression.cp39-win_amd64.pyd +0 -0
  7. mindspore/_c_mindrecord.cp39-win_amd64.pyd +0 -0
  8. mindspore/_checkparam.py +0 -5
  9. mindspore/_extends/parallel_compile/akg_compiler/gen_custom_op_files.py +1 -1
  10. mindspore/_extends/parse/compile_config.py +64 -0
  11. mindspore/_extends/parse/deprecated/__init__.py +0 -0
  12. mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +375 -0
  13. mindspore/_extends/parse/parser.py +23 -5
  14. mindspore/_extends/parse/standard_method.py +123 -27
  15. mindspore/_extends/pijit/pijit_func_white_list.py +1 -1
  16. mindspore/amp.py +7 -1
  17. mindspore/atlprov.dll +0 -0
  18. mindspore/avcodec-59.dll +0 -0
  19. mindspore/avdevice-59.dll +0 -0
  20. mindspore/avfilter-8.dll +0 -0
  21. mindspore/avformat-59.dll +0 -0
  22. mindspore/avutil-57.dll +0 -0
  23. mindspore/boost/boost_cell_wrapper.py +136 -41
  24. mindspore/c1.dll +0 -0
  25. mindspore/c1xx.dll +0 -0
  26. mindspore/c2.dll +0 -0
  27. mindspore/common/__init__.py +3 -1
  28. mindspore/common/_register_for_tensor.py +0 -1
  29. mindspore/common/_stub_tensor.py +25 -4
  30. mindspore/common/_tensor_cpp_method.py +17 -0
  31. mindspore/common/_tensor_docs.py +6132 -0
  32. mindspore/common/api.py +99 -25
  33. mindspore/common/dtype.py +34 -34
  34. mindspore/common/dump.py +2 -1
  35. mindspore/common/file_system.py +8 -1
  36. mindspore/common/generator.py +2 -0
  37. mindspore/common/hook_handle.py +3 -1
  38. mindspore/common/initializer.py +3 -4
  39. mindspore/common/lazy_inline.py +8 -2
  40. mindspore/common/mindir_util.py +10 -2
  41. mindspore/common/parameter.py +30 -27
  42. mindspore/common/tensor.py +713 -1337
  43. mindspore/communication/__init__.py +1 -1
  44. mindspore/communication/_comm_helper.py +10 -0
  45. mindspore/communication/comm_func.py +215 -173
  46. mindspore/communication/management.py +23 -20
  47. mindspore/context.py +292 -193
  48. mindspore/dataset/__init__.py +23 -19
  49. mindspore/dataset/callback/ds_callback.py +2 -1
  50. mindspore/dataset/core/config.py +84 -3
  51. mindspore/dataset/engine/cache_admin.py +3 -3
  52. mindspore/dataset/engine/cache_client.py +5 -4
  53. mindspore/dataset/engine/datasets.py +192 -149
  54. mindspore/dataset/engine/datasets_audio.py +14 -0
  55. mindspore/dataset/engine/datasets_standard_format.py +28 -11
  56. mindspore/dataset/engine/datasets_text.py +38 -1
  57. mindspore/dataset/engine/datasets_user_defined.py +125 -65
  58. mindspore/dataset/engine/datasets_vision.py +81 -8
  59. mindspore/dataset/engine/iterators.py +281 -63
  60. mindspore/dataset/engine/obs/util.py +8 -0
  61. mindspore/dataset/engine/queue.py +40 -0
  62. mindspore/dataset/engine/samplers.py +26 -2
  63. mindspore/dataset/engine/serializer_deserializer.py +1 -1
  64. mindspore/dataset/engine/validators.py +43 -11
  65. mindspore/dataset/transforms/py_transforms_util.py +17 -0
  66. mindspore/dataset/transforms/transforms.py +29 -12
  67. mindspore/dataset/vision/validators.py +1 -2
  68. mindspore/device_context/__init__.py +21 -0
  69. mindspore/device_context/ascend/__init__.py +25 -0
  70. mindspore/device_context/ascend/device.py +72 -0
  71. mindspore/device_context/ascend/op_debug.py +94 -0
  72. mindspore/device_context/ascend/op_precision.py +193 -0
  73. mindspore/device_context/ascend/op_tuning.py +127 -0
  74. mindspore/device_context/cpu/__init__.py +25 -0
  75. mindspore/device_context/cpu/device.py +62 -0
  76. mindspore/device_context/cpu/op_tuning.py +43 -0
  77. mindspore/device_context/gpu/__init__.py +21 -0
  78. mindspore/device_context/gpu/device.py +70 -0
  79. mindspore/device_context/gpu/op_precision.py +67 -0
  80. mindspore/device_context/gpu/op_tuning.py +175 -0
  81. mindspore/device_manager.py +134 -0
  82. mindspore/dnnl.dll +0 -0
  83. mindspore/dpcmi.dll +0 -0
  84. mindspore/experimental/llm_boost/__init__.py +3 -2
  85. mindspore/experimental/llm_boost/ascend_native/__init__.py +22 -0
  86. mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +211 -0
  87. mindspore/experimental/llm_boost/ascend_native/llm_boost.py +52 -0
  88. mindspore/experimental/llm_boost/atb/boost_base.py +239 -64
  89. mindspore/experimental/llm_boost/atb/llama_boost.py +52 -30
  90. mindspore/experimental/llm_boost/atb/qwen_boost.py +47 -24
  91. mindspore/experimental/llm_boost/register.py +1 -0
  92. mindspore/experimental/optim/adadelta.py +26 -22
  93. mindspore/experimental/optim/adam.py +3 -0
  94. mindspore/experimental/optim/lr_scheduler.py +33 -24
  95. mindspore/experimental/optim/radam.py +33 -30
  96. mindspore/hal/device.py +28 -0
  97. mindspore/hal/event.py +17 -0
  98. mindspore/hal/memory.py +94 -3
  99. mindspore/hal/stream.py +91 -6
  100. mindspore/include/api/context.h +1 -2
  101. mindspore/include/dataset/constants.h +2 -2
  102. mindspore/jpeg62.dll +0 -0
  103. mindspore/log.py +12 -0
  104. mindspore/mindrecord/__init__.py +1 -1
  105. mindspore/mindrecord/config.py +17 -316
  106. mindspore/mindrecord/filereader.py +1 -9
  107. mindspore/mindrecord/filewriter.py +5 -15
  108. mindspore/mindrecord/mindpage.py +1 -9
  109. mindspore/mindspore_backend.dll +0 -0
  110. mindspore/mindspore_common.dll +0 -0
  111. mindspore/mindspore_core.dll +0 -0
  112. mindspore/mindspore_glog.dll +0 -0
  113. mindspore/mindspore_ops.dll +0 -0
  114. mindspore/mint/__init__.py +824 -218
  115. mindspore/mint/distributed/__init__.py +66 -4
  116. mindspore/mint/distributed/distributed.py +2594 -44
  117. mindspore/mint/linalg/__init__.py +6 -0
  118. mindspore/mint/nn/__init__.py +473 -14
  119. mindspore/mint/nn/functional.py +486 -11
  120. mindspore/mint/nn/layer/__init__.py +17 -4
  121. mindspore/mint/nn/layer/_functions.py +330 -0
  122. mindspore/mint/nn/layer/activation.py +169 -1
  123. mindspore/mint/nn/layer/basic.py +123 -0
  124. mindspore/mint/nn/layer/conv.py +727 -0
  125. mindspore/mint/nn/layer/normalization.py +215 -19
  126. mindspore/mint/nn/layer/padding.py +797 -0
  127. mindspore/mint/nn/layer/pooling.py +170 -0
  128. mindspore/mint/optim/__init__.py +2 -1
  129. mindspore/mint/optim/adam.py +223 -0
  130. mindspore/mint/optim/adamw.py +26 -19
  131. mindspore/mint/special/__init__.py +2 -1
  132. mindspore/msobj140.dll +0 -0
  133. mindspore/mspdb140.dll +0 -0
  134. mindspore/mspdbcore.dll +0 -0
  135. mindspore/mspdbst.dll +0 -0
  136. mindspore/mspft140.dll +0 -0
  137. mindspore/msvcdis140.dll +0 -0
  138. mindspore/msvcp140_1.dll +0 -0
  139. mindspore/msvcp140_2.dll +0 -0
  140. mindspore/msvcp140_atomic_wait.dll +0 -0
  141. mindspore/msvcp140_codecvt_ids.dll +0 -0
  142. mindspore/multiprocessing/__init__.py +5 -0
  143. mindspore/nn/__init__.py +2 -0
  144. mindspore/nn/cell.py +142 -21
  145. mindspore/nn/dynamic_lr.py +2 -1
  146. mindspore/nn/layer/activation.py +6 -6
  147. mindspore/nn/layer/basic.py +35 -25
  148. mindspore/nn/layer/channel_shuffle.py +3 -3
  149. mindspore/nn/layer/conv.py +3 -0
  150. mindspore/nn/layer/embedding.py +3 -3
  151. mindspore/nn/layer/normalization.py +8 -7
  152. mindspore/nn/layer/padding.py +4 -3
  153. mindspore/nn/layer/pooling.py +55 -23
  154. mindspore/nn/layer/rnn_cells.py +1 -1
  155. mindspore/nn/layer/rnns.py +2 -1
  156. mindspore/nn/layer/timedistributed.py +5 -5
  157. mindspore/nn/layer/transformer.py +48 -26
  158. mindspore/nn/learning_rate_schedule.py +5 -3
  159. mindspore/nn/loss/loss.py +31 -36
  160. mindspore/nn/optim/ada_grad.py +1 -0
  161. mindspore/nn/optim/adadelta.py +2 -2
  162. mindspore/nn/optim/adam.py +1 -1
  163. mindspore/nn/optim/lars.py +1 -4
  164. mindspore/nn/optim/optimizer.py +1 -1
  165. mindspore/nn/optim/rprop.py +2 -2
  166. mindspore/nn/optim/thor.py +2 -1
  167. mindspore/nn/utils/__init__.py +22 -0
  168. mindspore/nn/utils/init.py +73 -0
  169. mindspore/nn/wrap/cell_wrapper.py +4 -6
  170. mindspore/nn/wrap/loss_scale.py +3 -4
  171. mindspore/numpy/array_creations.py +60 -62
  172. mindspore/numpy/array_ops.py +148 -143
  173. mindspore/numpy/logic_ops.py +41 -42
  174. mindspore/numpy/math_ops.py +361 -359
  175. mindspore/numpy/utils.py +16 -16
  176. mindspore/numpy/utils_const.py +4 -4
  177. mindspore/opencv_core452.dll +0 -0
  178. mindspore/opencv_imgcodecs452.dll +0 -0
  179. mindspore/opencv_imgproc452.dll +0 -0
  180. mindspore/ops/__init__.py +2 -1
  181. mindspore/ops/_grad_experimental/grad_comm_ops.py +107 -8
  182. mindspore/ops/_grad_experimental/grad_debug_ops.py +6 -1
  183. mindspore/ops/_grad_experimental/grad_inner_ops.py +9 -0
  184. mindspore/ops/_grad_experimental/grad_math_ops.py +2 -1
  185. mindspore/ops/_op_impl/cpu/__init__.py +1 -0
  186. mindspore/ops/_op_impl/cpu/raise_op.py +28 -0
  187. mindspore/ops/_vmap/vmap_array_ops.py +20 -19
  188. mindspore/ops/_vmap/vmap_base.py +0 -2
  189. mindspore/ops/_vmap/vmap_grad_nn_ops.py +19 -13
  190. mindspore/ops/_vmap/vmap_math_ops.py +11 -9
  191. mindspore/ops/_vmap/vmap_nn_ops.py +20 -34
  192. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +149 -12
  193. mindspore/ops/auto_generate/gen_arg_handler.py +0 -61
  194. mindspore/ops/auto_generate/gen_extend_func.py +554 -60
  195. mindspore/ops/auto_generate/gen_ops_def.py +1621 -115
  196. mindspore/ops/auto_generate/gen_ops_prim.py +8027 -3411
  197. mindspore/ops/auto_generate/pyboost_inner_prim.py +183 -79
  198. mindspore/ops/composite/base.py +1 -1
  199. mindspore/ops/composite/multitype_ops/_compile_utils.py +229 -30
  200. mindspore/ops/composite/multitype_ops/pow_impl.py +0 -29
  201. mindspore/ops/function/__init__.py +12 -0
  202. mindspore/ops/function/array_func.py +561 -159
  203. mindspore/ops/function/clip_func.py +64 -0
  204. mindspore/ops/function/debug_func.py +28 -20
  205. mindspore/ops/function/image_func.py +1 -1
  206. mindspore/ops/function/linalg_func.py +5 -4
  207. mindspore/ops/function/math_func.py +1664 -294
  208. mindspore/ops/function/nn_func.py +988 -317
  209. mindspore/ops/function/parameter_func.py +3 -56
  210. mindspore/ops/function/random_func.py +243 -33
  211. mindspore/ops/function/sparse_unary_func.py +1 -1
  212. mindspore/ops/functional.py +18 -5
  213. mindspore/ops/functional_overload.py +897 -0
  214. mindspore/ops/operations/__init__.py +3 -2
  215. mindspore/ops/operations/_embedding_cache_ops.py +4 -4
  216. mindspore/ops/operations/_grad_ops.py +2 -34
  217. mindspore/ops/operations/_infer_ops.py +2 -1
  218. mindspore/ops/operations/_inner_ops.py +38 -8
  219. mindspore/ops/operations/array_ops.py +45 -303
  220. mindspore/ops/operations/comm_ops.py +23 -17
  221. mindspore/ops/operations/custom_ops.py +7 -49
  222. mindspore/ops/operations/debug_ops.py +42 -47
  223. mindspore/ops/operations/inner_ops.py +6 -4
  224. mindspore/ops/operations/linalg_ops.py +3 -2
  225. mindspore/ops/operations/manually_defined/ops_def.py +185 -104
  226. mindspore/ops/operations/math_ops.py +11 -216
  227. mindspore/ops/operations/nn_ops.py +153 -310
  228. mindspore/ops/primitive.py +23 -21
  229. mindspore/ops/tensor_method.py +1669 -0
  230. mindspore/ops_generate/aclnn_kernel_register_auto_cc_generator.py +110 -0
  231. mindspore/ops_generate/add_tensor_docs_generator.py +54 -0
  232. mindspore/ops_generate/arg_handler.py +0 -61
  233. mindspore/ops_generate/auto_grad_impl_cc_generator.py +135 -0
  234. mindspore/ops_generate/auto_grad_reg_cc_generator.py +93 -0
  235. mindspore/ops_generate/base_generator.py +11 -0
  236. mindspore/ops_generate/cpp_create_prim_instance_helper_generator.py +108 -0
  237. mindspore/ops_generate/functional_map_cpp_generator.py +491 -0
  238. mindspore/ops_generate/functional_overload_py_generator.py +110 -0
  239. mindspore/ops_generate/functions_cc_generator.py +233 -0
  240. mindspore/ops_generate/gen_aclnn_implement.py +110 -114
  241. mindspore/ops_generate/gen_constants.py +157 -3
  242. mindspore/ops_generate/gen_ops.py +245 -990
  243. mindspore/ops_generate/gen_pyboost_func.py +97 -998
  244. mindspore/ops_generate/gen_utils.py +119 -33
  245. mindspore/ops_generate/lite_ops_cpp_generator.py +155 -0
  246. mindspore/ops_generate/op_api_proto.py +206 -0
  247. mindspore/ops_generate/op_def_py_generator.py +131 -0
  248. mindspore/ops_generate/op_prim_py_generator.py +480 -0
  249. mindspore/ops_generate/op_proto.py +373 -108
  250. mindspore/ops_generate/op_template_parser.py +436 -0
  251. mindspore/ops_generate/ops_def_cc_generator.py +288 -0
  252. mindspore/ops_generate/ops_def_h_generator.py +74 -0
  253. mindspore/ops_generate/ops_name_h_generator.py +68 -0
  254. mindspore/ops_generate/ops_primitive_h_generator.py +81 -0
  255. mindspore/ops_generate/pyboost_functions_cpp_generator.py +370 -0
  256. mindspore/ops_generate/pyboost_functions_h_generator.py +68 -0
  257. mindspore/ops_generate/pyboost_functions_py_generator.py +148 -0
  258. mindspore/ops_generate/pyboost_grad_function_cpp_generator.py +154 -0
  259. mindspore/ops_generate/pyboost_inner_prim_generator.py +131 -0
  260. mindspore/ops_generate/pyboost_native_grad_functions_generator.py +268 -0
  261. mindspore/ops_generate/pyboost_op_cpp_code_generator.py +851 -0
  262. mindspore/ops_generate/pyboost_overload_functions_cpp_generator.py +344 -0
  263. mindspore/ops_generate/pyboost_utils.py +92 -33
  264. mindspore/ops_generate/template.py +294 -44
  265. mindspore/ops_generate/tensor_func_reg_cpp_generator.py +422 -0
  266. mindspore/parallel/__init__.py +3 -3
  267. mindspore/parallel/_auto_parallel_context.py +44 -34
  268. mindspore/parallel/_cell_wrapper.py +22 -3
  269. mindspore/parallel/_parallel_serialization.py +13 -2
  270. mindspore/parallel/_utils.py +4 -2
  271. mindspore/parallel/algo_parameter_config.py +1 -1
  272. mindspore/parallel/checkpoint_transform.py +44 -0
  273. mindspore/parallel/cluster/process_entity/_api.py +131 -37
  274. mindspore/parallel/cluster/process_entity/_utils.py +41 -6
  275. mindspore/parallel/cluster/run.py +20 -3
  276. mindspore/parallel/parameter_broadcast.py +1 -1
  277. mindspore/parallel/shard.py +3 -0
  278. mindspore/parallel/transform_safetensors.py +119 -253
  279. mindspore/pgodb140.dll +0 -0
  280. mindspore/pgort140.dll +0 -0
  281. mindspore/profiler/__init__.py +17 -4
  282. mindspore/profiler/analysis/__init__.py +0 -0
  283. mindspore/profiler/analysis/parser/__init__.py +0 -0
  284. mindspore/profiler/analysis/parser/ascend_cann_parser.py +166 -0
  285. mindspore/profiler/analysis/parser/base_parser.py +158 -0
  286. mindspore/profiler/analysis/parser/framework_cann_relation_parser.py +45 -0
  287. mindspore/profiler/analysis/parser/ms_framework_parser.py +142 -0
  288. mindspore/profiler/analysis/parser/ms_minddata_parser.py +145 -0
  289. mindspore/profiler/analysis/parser/timeline_assembly_factory/__init__.py +0 -0
  290. mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +261 -0
  291. mindspore/profiler/analysis/parser/timeline_assembly_factory/base_timeline_assembler.py +40 -0
  292. mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +84 -0
  293. mindspore/profiler/analysis/parser/timeline_creator/__init__.py +0 -0
  294. mindspore/profiler/analysis/parser/timeline_creator/base_timeline_creator.py +44 -0
  295. mindspore/profiler/analysis/parser/timeline_creator/cpu_op_timeline_creator.py +90 -0
  296. mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +76 -0
  297. mindspore/profiler/analysis/parser/timeline_creator/msprof_timeline_creator.py +103 -0
  298. mindspore/profiler/analysis/parser/timeline_creator/scope_layer_timeline_creator.py +134 -0
  299. mindspore/profiler/analysis/parser/timeline_event/__init__.py +0 -0
  300. mindspore/profiler/analysis/parser/timeline_event/base_event.py +233 -0
  301. mindspore/profiler/analysis/parser/timeline_event/cpu_op_event.py +47 -0
  302. mindspore/profiler/analysis/parser/timeline_event/flow_event.py +36 -0
  303. mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +260 -0
  304. mindspore/profiler/analysis/parser/timeline_event/msprof_event.py +73 -0
  305. mindspore/profiler/analysis/parser/timeline_event/scope_layer_event.py +53 -0
  306. mindspore/profiler/analysis/parser/timeline_event/timeline_event_pool.py +146 -0
  307. mindspore/profiler/analysis/task_manager.py +131 -0
  308. mindspore/profiler/analysis/time_converter.py +84 -0
  309. mindspore/profiler/analysis/viewer/__init__.py +0 -0
  310. mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +333 -0
  311. mindspore/profiler/analysis/viewer/ascend_integrate_viewer.py +87 -0
  312. mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +252 -0
  313. mindspore/profiler/analysis/viewer/ascend_memory_viewer.py +313 -0
  314. mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +322 -0
  315. mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +265 -0
  316. mindspore/profiler/analysis/viewer/ascend_timeline_viewer.py +58 -0
  317. mindspore/profiler/analysis/viewer/base_viewer.py +26 -0
  318. mindspore/profiler/analysis/viewer/ms_dataset_viewer.py +97 -0
  319. mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +581 -0
  320. mindspore/profiler/analysis/work_flow.py +73 -0
  321. mindspore/profiler/common/ascend_msprof_exporter.py +138 -0
  322. mindspore/profiler/common/command_executor.py +90 -0
  323. mindspore/profiler/common/constant.py +174 -3
  324. mindspore/profiler/common/file_manager.py +208 -0
  325. mindspore/profiler/common/log.py +130 -0
  326. mindspore/profiler/common/msprof_cmd_tool.py +202 -0
  327. mindspore/profiler/common/path_manager.py +371 -0
  328. mindspore/profiler/common/process_bar.py +168 -0
  329. mindspore/profiler/common/process_pool.py +9 -3
  330. mindspore/profiler/common/profiler_context.py +476 -0
  331. mindspore/profiler/common/profiler_info.py +304 -0
  332. mindspore/profiler/common/profiler_output_path.py +284 -0
  333. mindspore/profiler/common/profiler_parameters.py +210 -0
  334. mindspore/profiler/common/profiler_path_manager.py +120 -0
  335. mindspore/profiler/common/record_function.py +76 -0
  336. mindspore/profiler/common/tlv_decoder.py +76 -0
  337. mindspore/profiler/common/util.py +75 -2
  338. mindspore/profiler/dynamic_profiler.py +270 -37
  339. mindspore/profiler/envprofiler.py +138 -0
  340. mindspore/profiler/mstx.py +199 -0
  341. mindspore/profiler/platform/__init__.py +21 -0
  342. mindspore/profiler/platform/base_profiler.py +40 -0
  343. mindspore/profiler/platform/cpu_profiler.py +124 -0
  344. mindspore/profiler/platform/gpu_profiler.py +74 -0
  345. mindspore/profiler/platform/npu_profiler.py +309 -0
  346. mindspore/profiler/profiler.py +580 -93
  347. mindspore/profiler/profiler_action_controller.py +187 -0
  348. mindspore/profiler/profiler_interface.py +114 -0
  349. mindspore/profiler/schedule.py +208 -0
  350. mindspore/rewrite/api/symbol_tree.py +1 -2
  351. mindspore/run_check/_check_version.py +18 -13
  352. mindspore/runtime/__init__.py +37 -0
  353. mindspore/runtime/device.py +27 -0
  354. mindspore/runtime/event.py +209 -0
  355. mindspore/runtime/executor.py +148 -0
  356. mindspore/runtime/memory.py +392 -0
  357. mindspore/runtime/stream.py +460 -0
  358. mindspore/runtime/thread_bind_core.py +401 -0
  359. mindspore/swresample-4.dll +0 -0
  360. mindspore/swscale-6.dll +0 -0
  361. mindspore/tbbmalloc.dll +0 -0
  362. mindspore/tinyxml2.dll +0 -0
  363. mindspore/train/__init__.py +2 -2
  364. mindspore/train/_utils.py +53 -18
  365. mindspore/train/amp.py +8 -4
  366. mindspore/train/callback/_checkpoint.py +32 -18
  367. mindspore/train/callback/_early_stop.py +1 -1
  368. mindspore/train/callback/_flops_collector.py +105 -69
  369. mindspore/train/callback/_history.py +1 -1
  370. mindspore/train/callback/_summary_collector.py +44 -6
  371. mindspore/train/callback/_tft_register.py +37 -15
  372. mindspore/train/dataset_helper.py +11 -11
  373. mindspore/train/metrics/precision.py +4 -5
  374. mindspore/train/mind_ir_pb2.py +167 -46
  375. mindspore/train/model.py +13 -14
  376. mindspore/train/serialization.py +461 -72
  377. mindspore/train/summary/summary_record.py +1 -2
  378. mindspore/train/train_thor/model_thor.py +1 -1
  379. mindspore/turbojpeg.dll +0 -0
  380. mindspore/utils/__init__.py +4 -2
  381. mindspore/utils/dryrun.py +138 -0
  382. mindspore/utils/runtime_execution_order_check.py +550 -0
  383. mindspore/vcmeta.dll +0 -0
  384. mindspore/vcruntime140.dll +0 -0
  385. mindspore/vcruntime140_1.dll +0 -0
  386. mindspore/version.py +1 -1
  387. {mindspore-2.4.1.dist-info → mindspore-2.5.0.dist-info}/METADATA +3 -4
  388. {mindspore-2.4.1.dist-info → mindspore-2.5.0.dist-info}/RECORD +391 -265
  389. {mindspore-2.4.1.dist-info → mindspore-2.5.0.dist-info}/entry_points.txt +1 -1
  390. mindspore/common/_tensor_overload.py +0 -139
  391. mindspore/mindspore_np_dtype.dll +0 -0
  392. mindspore/profiler/envprofiling.py +0 -254
  393. mindspore/profiler/profiling.py +0 -1926
  394. {mindspore-2.4.1.dist-info → mindspore-2.5.0.dist-info}/WHEEL +0 -0
  395. {mindspore-2.4.1.dist-info → mindspore-2.5.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,422 @@
1
+ # Copyright 2024 Huawei Technologies Co., Ltd
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ # ============================================================================
15
+ """
16
+ This module defines the PyboostInnerPrimGenerator class, which is responsible for generating Python primitive
17
+ wrappers for Pyboost operations. The generator constructs Python function definitions based on operator prototypes,
18
+ generates necessary import statements, and writes the generated content into Python source files.
19
+
20
+ The primary functionality is to take operator prototypes, extract relevant fields, and create Python function wrappers
21
+ that can be used to call the Pyboost primitive implementations.
22
+ """
23
+
24
+ import os
25
+
26
+ import template
27
+ from template import Template
28
+ import gen_constants as K
29
+ import pyboost_utils
30
+ import op_api_proto
31
+ from gen_utils import save_file
32
+ from base_generator import BaseGenerator
33
+ from op_proto import OpProto
34
+ from op_template_parser import OpTemplateParser
35
+
36
+
37
+ class TensorFuncRegCppGenerator(BaseGenerator):
38
+ """
39
+ Generates C++ tensor function registration code for different backends (Ascend, CPU, GPU).
40
+
41
+ This class is responsible for generating header and implementation files required to register
42
+ tensor functions, including device-specific dispatchers and function definitions.
43
+ """
44
+
45
+ def __init__(self):
46
+ self.TENSOR_FUNC_CC_REG = template.TENSOR_FUNC_CC_REG
47
+ self.TENSOR_FUNC_CALL_BODY = template.TENSOR_FUNC_CALL_BODY
48
+ self.TENSOR_FUNC_OVERLOAD_CALL_BODY = template.TENSOR_FUNC_OVERLOAD_CALL_BODY
49
+ self.TENSOR_API_HEADER = template.TENSOR_API_HEADER
50
+ self.TENSOR_API_SOURCE = template.TENSOR_API_SOURCE
51
+ self.TENSOR_FUNC_UTILS = template.TENSOR_FUNC_UTILS
52
+ self.TENSOR_FUNC_UT_BODY = template.TENSOR_FUNC_UT_BODY
53
+ self.TENSOR_FUNC_UT_OVERLOAD_BODY = template.TENSOR_FUNC_UT_OVERLOAD_BODY
54
+ self.TENSOR_CPP_METHOD = template.TENSOR_CPP_METHOD
55
+
56
+ self.func_def_reg = Template("tensor_class->def(\"${func_name}\", TensorMethod${cpp_func_name});\n")
57
+ self.single_case_template = Template(
58
+ 'case ${case_id}:\n'
59
+ ' ${device_dispatcher}\n'
60
+ ' break;\n'
61
+ )
62
+ self.single_case_in_ut_template = Template(
63
+ 'case ${case_id}:\n'
64
+ ' ${device_dispatcher}\n'
65
+ )
66
+ self.device_dispatcher_template = Template(
67
+ 'if (backend == kAscendDevice || backend == kDavinciDevice) {\n'
68
+ ' ${ascend_dispatcher}\n'
69
+ '} else if (backend == kCPUDevice) {\n'
70
+ ' ${cpu_dispatcher}\n'
71
+ '} else if (backend == kGPUDevice) {\n'
72
+ ' ${gpu_dispatcher}\n'
73
+ '} else {\n'
74
+ ' MS_LOG(ERROR) << "Device target is not supported!";\n'
75
+ ' return py::none();\n'
76
+ '}'
77
+ )
78
+ self.pyboost_return_template = Template(
79
+ '${arg_handler_processor}\n'
80
+ 'MS_LOG(INFO) << "Call Tensor${class_name}";\n'
81
+ 'return ToPython(TensorPyboostMethodRegister::'
82
+ 'GetOp(tensor::TensorPyboostMethod::k${class_name}Reg)(arg_list));\n'
83
+ )
84
+ self.callback_python_template = Template(
85
+ 'MS_LOG(INFO) << "Callback python method: ${py_method}";\n'
86
+ 'py::function fn = python_adapter::GetPyFn(\"mindspore.ops.tensor_method\", \"${py_method}\");\n'
87
+ 'py::object res = fn(self, *py_args, **py_kwargs);\n'
88
+ 'return res;\n'
89
+ )
90
+ self.callback_python_in_ut_template = Template(
91
+ 'MS_LOG(INFO) << "Callback python method in UT: ${py_method}";\n'
92
+ 'fn = python_adapter::GetPyFn(\"mindspore.ops.tensor_method\", \"${py_method}\");\n'
93
+ 'res = fn(self, *py_args, **py_kwargs);\n'
94
+ 'break;\n'
95
+ )
96
+ self.header_func_header_template = Template(
97
+ "py::object TensorMethod${cpp_func_name}"
98
+ "(const py::object &self, const py::args &py_args, const py::kwargs &py_kwargs);\n"
99
+ )
100
+
101
+ def generate(self, work_path, op_protos, func_protos_data, alias_func_mapping):
102
+ """
103
+ Generates C++ header and source files for tensor function registrations.
104
+
105
+ Args:
106
+ work_path (str): The directory where the generated files will be saved.
107
+ op_protos (list): A list of tensor op prototypes.
108
+ func_protos_data (dict): Dictionary mapping function names to lists of TensorFuncProto objects.
109
+ alias_func_mapping (dict): A dictionary mapping function name to its alias function names.
110
+ """
111
+
112
+ all_op_func_data, single_op_func_data, overload_op_func_data = op_api_proto.categorize_func_data(
113
+ func_protos_data)
114
+
115
+ tensor_method_list = self._get_op_enum_name_list(op_protos)
116
+ func_call_body_list = []
117
+ self._create_single_op_source_files(single_op_func_data, func_call_body_list)
118
+ self._create_overload_op_source_files(overload_op_func_data, func_call_body_list)
119
+ merge_func_call_body = pyboost_utils.merge_strings_by_chunk_size(func_call_body_list)
120
+
121
+ for i, func_body_chunk_str in enumerate(merge_func_call_body):
122
+ tensor_api_source = self.TENSOR_API_SOURCE.replace(tenosr_func_call_body=func_body_chunk_str)
123
+ save_file(os.path.join(work_path, K.TENSOR_API_PATH), f"tensor_api_{i}.cc",
124
+ tensor_api_source)
125
+
126
+ func_def_body_list, tensor_cpp_methods_list, tensor_api_declaration_list = self._get_sorted_func_def_body(
127
+ all_op_func_data, alias_func_mapping)
128
+ tensor_api_header = self.TENSOR_API_HEADER.replace(tensor_api_declaration_list=tensor_api_declaration_list)
129
+ save_file(os.path.join(work_path, K.TENSOR_API_PATH), f"tensor_api.h",
130
+ tensor_api_header)
131
+ self._generate_func_name_for_stub_tensor(work_path, tensor_cpp_methods_list)
132
+ func_cc_reg = self.TENSOR_FUNC_CC_REG.replace(func_def_body=func_def_body_list)
133
+ tensor_methods = self.TENSOR_FUNC_UTILS.replace(tensor_methods=tensor_method_list)
134
+
135
+ save_file(os.path.join(work_path, K.TENSOR_FUNC_REGISTER_PATH), "tensor_func_utils.h", tensor_methods)
136
+ save_file(os.path.join(work_path, K.TENSOR_FUNC_REGISTER_PATH), "tensor_func_reg.cc", func_cc_reg)
137
+
138
+ def _get_op_enum_name_list(self, op_protos):
139
+ """
140
+ Extracts operation class names and returns them as a formatted list.
141
+
142
+ Args:
143
+ op_protos (list): A list of operation prototype objects, where each object has an `op_class`
144
+ with a `name` attribute.
145
+
146
+ Returns:
147
+ str: A list of formatted strings, where each string is of the form 'k<name>,\n', where <name>
148
+ is the class name from the `op_class` attribute.
149
+
150
+ """
151
+ tensor_method_list = ""
152
+ for op_proto in op_protos:
153
+ if op_proto.op_dispatch is None or not op_proto.op_dispatch.enable:
154
+ continue
155
+ class_name = op_proto.op_class.name
156
+ tensor_method_list += f"k{class_name}Reg,\n"
157
+ return tensor_method_list
158
+
159
+ def _generate_func_name_for_stub_tensor(self, work_path, tensor_cpp_methods_list):
160
+ """
161
+ Generates a Python file containing tensor C++ function methods list and saves it to the specified path.
162
+
163
+ This function takes a list of C++ tensor methods, formats them into a Python script as a string,
164
+ and writes this script to a file named `_tensor_cpp_method.py` under the provided working path.
165
+
166
+ Args:
167
+ work_path (str): The base directory where the generated file will be saved.
168
+ tensor_cpp_methods_list (list): A list of tensor C++ method definitions to be included in the Python file.
169
+ """
170
+ tensor_cpp_methods_str = self.TENSOR_CPP_METHOD.replace(
171
+ tensor_cpp_methods_list_str=str(tensor_cpp_methods_list))
172
+ save_file(os.path.join(work_path, K.ADD_TENSOR_DOCS_PY_PATH), "_tensor_cpp_method.py", tensor_cpp_methods_str)
173
+
174
+ def _get_sorted_func_def_body(self, all_op_func_data, alias_func_mapping):
175
+ """
176
+ Generate sorted function definitions and headers for operations.
177
+
178
+ This function processes a dictionary of operation function data and an alias mapping,
179
+ producing two lists: one containing function definition bodies and another containing
180
+ function header definitions.
181
+
182
+ Args:
183
+ all_op_func_data (dict): A dictionary where keys are function API names (str), and
184
+ values are lists of function prototypes.
185
+ alias_func_mapping (dict): A mapping of function names to a list of their alias names.
186
+
187
+ Returns:
188
+ tuple: A tuple containing two lists:
189
+ - func_def_body_list (list of str): A list of formatted function definition strings.
190
+ - tensor_cpp_methods_list (list of str): A list of formatted function header strings.
191
+ """
192
+ func_def_body_list = []
193
+ tensor_cpp_methods_list = []
194
+ tensor_api_declaration_list = ""
195
+ for func_api_name, func_protos in all_op_func_data.items():
196
+ cpp_func_name = pyboost_utils.format_func_api_name(func_api_name)
197
+ if len(func_protos) == 1:
198
+ func_proto = func_protos[0]
199
+ func_name = func_proto.func_name
200
+ func_def_body_list.append(self.func_def_reg.replace(func_name=func_name, cpp_func_name=cpp_func_name))
201
+ tensor_cpp_methods_list.append(func_name)
202
+ tensor_api_declaration_list += self.header_func_header_template.replace(cpp_func_name=cpp_func_name)
203
+ if func_name in alias_func_mapping:
204
+ for alias_func_name in alias_func_mapping[func_name]:
205
+ func_def_body_list.append(
206
+ self.func_def_reg.replace(func_name=alias_func_name, cpp_func_name=cpp_func_name))
207
+ tensor_cpp_methods_list.append(alias_func_name)
208
+ elif len(func_protos) > 1:
209
+ func_def_body_list.append(
210
+ self.func_def_reg.replace(func_name=func_api_name, cpp_func_name=cpp_func_name))
211
+ tensor_cpp_methods_list.append(func_api_name)
212
+ tensor_api_declaration_list += self.header_func_header_template.replace(cpp_func_name=cpp_func_name)
213
+ if func_api_name in alias_func_mapping:
214
+ for alias_func_name in alias_func_mapping[func_api_name]:
215
+ func_def_body_list.append(self.func_def_reg.replace(func_name=alias_func_name,
216
+ cpp_func_name=cpp_func_name))
217
+ tensor_cpp_methods_list.append(alias_func_name)
218
+ return func_def_body_list, tensor_cpp_methods_list, tensor_api_declaration_list
219
+
220
+ def _create_single_op_source_files(self, single_op_func_data, func_call_body_list):
221
+ """
222
+ Generates the list of call body strings for single operation functions.
223
+
224
+ Args:
225
+ single_op_func_data (dict): Dictionary of tensor function prototypes with only one definition.
226
+
227
+ Returns:
228
+ list: Updated str list for generating C++ function call bodies.
229
+ """
230
+ for func_api_name, func_proto in single_op_func_data.items():
231
+ func_name = func_proto.func_name
232
+ cpp_func_name = pyboost_utils.format_func_api_name(func_api_name)
233
+ device_dispatcher_str = self._get_device_dispatchers_str(func_proto)
234
+ signature_str = self._generate_single_signature_str(
235
+ func_proto.op_proto, func_proto.kw_only_args, func_proto.varargs
236
+ )
237
+ op_args = func_proto.op_proto.op_args
238
+ max_size = len(op_args)
239
+ self_index = self._get_input_tensor_index(func_proto)
240
+ ut_body = self.TENSOR_FUNC_UT_BODY.replace(py_method=func_proto.py_method)
241
+ tensor_func_single_call_body = self.TENSOR_FUNC_CALL_BODY.replace(cpp_func_name=cpp_func_name,
242
+ func_name=func_name,
243
+ device_dispatcher=device_dispatcher_str,
244
+ signatures=signature_str,
245
+ max_args=max_size,
246
+ self_index=self_index,
247
+ ut_body=ut_body)
248
+ func_call_body_list.append(tensor_func_single_call_body)
249
+
250
+ def _create_overload_op_source_files(self, overload_op_func_data, func_call_body_list):
251
+ """
252
+ Generates the list of call body strings for overloaded operation functions.
253
+
254
+ Args:
255
+ overload_op_func_data (dict): Dictionary of tensor function prototypes with overloaded definitions.
256
+
257
+ Returns:
258
+ list: Updated str list for generating C++ function call bodies.
259
+ """
260
+ for func_api_name, func_protos in overload_op_func_data.items():
261
+ tensor_func_overload_call_body = self._get_overload_func_call_str(func_api_name, func_protos)
262
+ func_call_body_list.append(tensor_func_overload_call_body)
263
+
264
+ def _get_overload_func_call_str(self, func_api_name, func_protos):
265
+ """
266
+ Generates C++ call body string for overloaded tensor functions.
267
+
268
+ Args:
269
+ func_api_name (str): Name of the function API.
270
+ func_protos (list): List of TensorFuncProto objects representing the function prototypes.
271
+
272
+ Returns:
273
+ str: Generated call body string for the overloaded functions.
274
+ """
275
+ signatures_str = self._generate_func_signatures_list_str(func_protos)
276
+ dispatch_cases = self._get_dispatch_cases(func_protos)
277
+ ut_dispatch_cases = self._get_ut_dispatch_cases(func_protos)
278
+ ut_overload_body = self.TENSOR_FUNC_UT_OVERLOAD_BODY.replace(ut_dispatch_cases=ut_dispatch_cases)
279
+
280
+ max_size = 0
281
+ self_index = 0
282
+ for tensor_proto in func_protos:
283
+ op_proto = tensor_proto.op_proto
284
+ op_args = op_proto.op_args
285
+ max_size = max(len(op_args), max_size)
286
+ self_index = self._get_input_tensor_index(tensor_proto)
287
+ cpp_func_name = pyboost_utils.format_func_api_name(func_api_name)
288
+ overload_func_call_str = self.TENSOR_FUNC_OVERLOAD_CALL_BODY.replace(cpp_func_name=cpp_func_name,
289
+ func_name=func_api_name,
290
+ signatures=signatures_str,
291
+ dispatch_cases=dispatch_cases,
292
+ max_args=max_size,
293
+ self_index=self_index,
294
+ ut_overload_body=ut_overload_body)
295
+ return overload_func_call_str
296
+
297
+ def _generate_func_signatures_list_str(self, func_protos) -> str:
298
+ """
299
+ Generates function signatures as a string from the given prototypes.
300
+
301
+ Args:
302
+ func_protos (list): List of TensorFuncProto objects representing the function prototypes.
303
+
304
+ Returns:
305
+ str: Generated function signatures string.
306
+ """
307
+ sig_str = ''
308
+ first_sig = True
309
+ for tensor_proto in func_protos:
310
+ op_proto = tensor_proto.op_proto
311
+ if not first_sig:
312
+ sig_str += ',\n'
313
+ first_sig = False
314
+ sig_str += self._generate_single_signature_str(op_proto, tensor_proto.kw_only_args, tensor_proto.varargs)
315
+ return sig_str
316
+
317
+ def _generate_single_signature_str(self, op_proto: OpProto, kw_only_args, varargs) -> str:
318
+ op_parser = OpTemplateParser(op_proto)
319
+ return op_parser.generate_signature_str(kw_only_args, varargs, is_tensor_api=True)
320
+
321
+ def _get_input_tensor_index(self, func_proto):
322
+ """
323
+ Get index of input.
324
+
325
+ Args:
326
+ func_proto (TensorFuncProto): Function prototype to generate dispatch strings for.
327
+
328
+ Returns:
329
+ int: Index of input.
330
+ """
331
+ op_name = func_proto.op_proto.op_class.name
332
+ op_args = func_proto.op_proto.op_args
333
+ if op_name in K.INPUT_NAME_MAP:
334
+ self_index = [i for i in range(len(op_args)) if op_args[i].arg_name == K.INPUT_NAME_MAP[op_name]]
335
+ else:
336
+ self_index = [i for i in range(len(op_args)) if op_args[i].arg_name in K.INPUT_ARGS_NAME]
337
+ if len(self_index) != 1:
338
+ raise ValueError(
339
+ f'There must be only one field named \'input\'. But got {len(self_index)} in {op_name}')
340
+ return self_index
341
+
342
+ def _get_dispatch_cases(self, func_protos):
343
+ """
344
+ Generates C++ switch-case statements for dispatching tensor function calls.
345
+
346
+ Args:
347
+ func_protos (list): List of TensorFuncProto objects representing the function prototypes.
348
+
349
+ Returns:
350
+ str: Generated switch-case dispatch statements.
351
+ """
352
+ dispatch_cases_str = ''
353
+ for idx, func_proto in enumerate(func_protos):
354
+ device_dispatcher_str = self._get_device_dispatchers_str(func_proto)
355
+ dispatch_cases_str += self.single_case_template.replace(case_id=idx,
356
+ device_dispatcher=device_dispatcher_str)
357
+ dispatch_cases_str += 'default:\n'
358
+ dispatch_cases_str += ' return py::none();'
359
+ return dispatch_cases_str
360
+
361
+ def _get_ut_dispatch_cases(self, func_protos):
362
+ """
363
+ Generates C++ switch-case statements for dispatching tensor function calls.
364
+
365
+ Args:
366
+ func_protos (list): List of TensorFuncProto objects representing the function prototypes.
367
+
368
+ Returns:
369
+ str: Generated switch-case dispatch statements.
370
+ """
371
+ dispatch_cases_str = ''
372
+ for idx, func_proto in enumerate(func_protos):
373
+ device_dispatcher_str = self.callback_python_in_ut_template.replace(py_method=func_proto.py_method)
374
+ dispatch_cases_str += self.single_case_in_ut_template.replace(case_id=idx,
375
+ device_dispatcher=device_dispatcher_str)
376
+ dispatch_cases_str += 'default:\n'
377
+ dispatch_cases_str += ' res = py::none();'
378
+ return dispatch_cases_str
379
+
380
+ def _get_device_dispatchers_str(self, func_proto):
381
+ """
382
+ Generates device-specific dispatch strings for the given function prototype.
383
+
384
+ Args:
385
+ func_proto (TensorFuncProto): Function prototype to generate dispatch strings for.
386
+
387
+ Returns:
388
+ str: Generated device-specific dispatch string.
389
+ """
390
+ ascend_dispatcher_str = self._get_single_device_dispatcher_str(func_proto, 'ascend')
391
+ cpu_dispatcher_str = self._get_single_device_dispatcher_str(func_proto, 'cpu')
392
+ gpu_dispatcher_str = self._get_single_device_dispatcher_str(func_proto, 'gpu')
393
+ device_dispatcher_str = self.device_dispatcher_template.replace(ascend_dispatcher=ascend_dispatcher_str,
394
+ cpu_dispatcher=cpu_dispatcher_str,
395
+ gpu_dispatcher=gpu_dispatcher_str)
396
+ return device_dispatcher_str
397
+
398
+ def _get_single_device_dispatcher_str(self, func_proto, device):
399
+ """
400
+ Generates the dispatch string for a specific device.
401
+
402
+ Args:
403
+ func_proto (TensorFuncProto): Function prototype to generate the dispatcher for.
404
+ device (str): Device type ('ascend', 'cpu', 'gpu').
405
+
406
+ Returns:
407
+ str: Generated device dispatcher string.
408
+ """
409
+ func_proto_device = getattr(func_proto, device)
410
+ if func_proto_device == 'pyboost':
411
+ arg_handler_processor_str = self._get_arg_handler_processor(func_proto.func_name, func_proto.op_proto)
412
+ return self.pyboost_return_template.replace(arg_handler_processor=arg_handler_processor_str,
413
+ class_name=func_proto.op_proto.op_class.name)
414
+
415
+ if func_proto_device == 'py_method':
416
+ return self.callback_python_template.replace(py_method=func_proto.py_method)
417
+
418
+ raise TypeError("Only support pyboost or python_method.")
419
+
420
+ def _get_arg_handler_processor(self, func_name, op_proto):
421
+ op_parser = OpTemplateParser(op_proto)
422
+ return op_parser.get_arg_handler_processor(func_name, op_proto, is_tensor_api=True)
@@ -19,12 +19,12 @@ from mindspore.parallel.algo_parameter_config import get_algo_parameters, reset_
19
19
  set_algo_parameters
20
20
  from mindspore.parallel.checkpoint_transform import rank_list_for_transform, transform_checkpoint_by_rank, \
21
21
  transform_checkpoints, merge_pipeline_strategys, sync_pipeline_shared_parameters, \
22
- load_segmented_checkpoints
22
+ load_segmented_checkpoints, set_op_strategy_config
23
23
  from mindspore.parallel.parameter_broadcast import parameter_broadcast
24
24
  from mindspore.parallel.shard import shard, Layout
25
- from mindspore.parallel.transform_safetensors import safetensors_to_ckpt, ckpt_to_safetensors, unified_safetensors
25
+ from mindspore.parallel.transform_safetensors import unified_safetensors
26
26
 
27
27
  __all__ = ["set_algo_parameters", "reset_algo_parameters", "get_algo_parameters", "rank_list_for_transform",
28
28
  "transform_checkpoint_by_rank", "transform_checkpoints", "merge_pipeline_strategys", "shard",
29
29
  "sync_pipeline_shared_parameters", "Layout", "parameter_broadcast", "load_segmented_checkpoints",
30
- "safetensors_to_ckpt", "ckpt_to_safetensors", "unified_safetensors"]
30
+ "unified_safetensors", "set_op_strategy_config"]
@@ -187,6 +187,44 @@ class _AutoParallelContext:
187
187
  self.check_context_handle()
188
188
  return self._context_handle.get_dump_local_norm()
189
189
 
190
+ def set_dump_local_norm_path(self, dump_local_norm_path):
191
+ """
192
+ Set dump local norm path for auto parallel.
193
+
194
+ Args:
195
+ dump_local_norm_path (str): User need to specify the path to save dump files
196
+ if he want to dump local norm. Default: ''
197
+
198
+ Raises:
199
+ KeyError: When the value of dump_local_norm_path is not a str value.
200
+ """
201
+ self.check_context_handle()
202
+ self._context_handle.set_dump_local_norm_path(dump_local_norm_path)
203
+
204
+ def get_dump_local_norm_path(self):
205
+ """Get dump local norm path."""
206
+ self.check_context_handle()
207
+ return self._context_handle.get_dump_local_norm_path()
208
+
209
+ def set_dump_device_local_norm(self, dump_device_local_norm):
210
+ """
211
+ Set dump device local norm for auto parallel.
212
+
213
+ Args:
214
+ dump_device_local_norm (bool): User need to specify if he want to dump device local norm. Default: False
215
+
216
+ Raises:
217
+ ValueError: If the dump_device_local_norm is not a bool value.
218
+ """
219
+ self.check_context_handle()
220
+ self._context_handle.set_dump_device_local_norm(dump_device_local_norm)
221
+
222
+ def get_dump_device_local_norm(self):
223
+ """Get dump device local norm."""
224
+ self.check_context_handle()
225
+ return self._context_handle.get_dump_device_local_norm()
226
+
227
+
190
228
  def set_fusion_threshold_mb(self, fusion_threshold=64, comm_type="allreduce"):
191
229
  """
192
230
  Set fusion threshold (MB) for auto parallel.
@@ -1070,13 +1108,6 @@ class _AutoParallelContext:
1070
1108
  self.check_context_handle()
1071
1109
  return self._context_handle.get_optimizer_weight_shard_size()
1072
1110
 
1073
- def set_ops_strategy_json_config(self, type, path, mode):
1074
- """
1075
- Set configuration of saving ops strategy in file .json.
1076
- """
1077
- self.check_context_handle()
1078
- self._context_handle.set_ops_strategy_json_config(type, path, mode)
1079
-
1080
1111
  def set_optimizer_weight_shard_aggregated_save(self, optimizer_weight_shard_aggregated_save):
1081
1112
  """
1082
1113
  Set optimizer_weight_shard_aggregated_save.
@@ -1214,31 +1245,6 @@ class _AutoParallelContext:
1214
1245
  self.set_enable_all_gather_fusion(openstate)
1215
1246
  self.set_enable_reduce_scatter_fusion(openstate)
1216
1247
 
1217
-
1218
- def _set_ops_strategy_json_config(type="SAVE", path="", mode="all"):
1219
- """
1220
- Set strategy json configuration.
1221
-
1222
- Args:
1223
- type (str): The parameter for choosing save or load .json file.
1224
- path (str): Path to save or load parallel strategy json.
1225
- mode (str): The parameter for choosing save all or important operators.
1226
-
1227
- Raises:
1228
- KeyError: When type is not 'SAVE' or 'LOAD'.
1229
- KeyError: When mode is not 'all' or 'principal'.
1230
- """
1231
- dir_path = os.path.dirname(path)
1232
- if dir_path and not os.path.exists(dir_path):
1233
- os.makedirs(dir_path, mode=0o700, exist_ok=True)
1234
- check_type = ["SAVE", "LOAD"]
1235
- check_mode = ["all", "principal"]
1236
- if type in check_type and mode in check_mode:
1237
- auto_parallel_context().set_ops_strategy_json_config(type, path, mode)
1238
- else:
1239
- raise KeyError("Type must be 'SAVE' or 'LOAD' and mode must be 'all' or 'principal'")
1240
-
1241
-
1242
1248
  _AUTO_PARALLEL_CONTEXT = None
1243
1249
 
1244
1250
 
@@ -1287,7 +1293,9 @@ _set_auto_parallel_context_func_map = {
1287
1293
  "enable_alltoall": auto_parallel_context().set_enable_alltoall,
1288
1294
  "strategy_ckpt_config": auto_parallel_context().set_strategy_ckpt_config,
1289
1295
  "comm_fusion": auto_parallel_context().set_comm_fusion,
1290
- "dump_local_norm": auto_parallel_context().set_dump_local_norm}
1296
+ "dump_local_norm": auto_parallel_context().set_dump_local_norm,
1297
+ "dump_local_norm_path": auto_parallel_context().set_dump_local_norm_path,
1298
+ "dump_device_local_norm": auto_parallel_context().set_dump_device_local_norm}
1291
1299
 
1292
1300
  _get_auto_parallel_context_func_map = {
1293
1301
  "device_num": auto_parallel_context().get_device_num,
@@ -1320,7 +1328,9 @@ _get_auto_parallel_context_func_map = {
1320
1328
  "comm_fusion": auto_parallel_context().get_comm_fusion,
1321
1329
  "strategy_ckpt_config": auto_parallel_context().get_strategy_ckpt_config,
1322
1330
  "full_batch_is_set": auto_parallel_context().get_full_batch_is_set,
1323
- "dump_local_norm": auto_parallel_context().get_dump_local_norm}
1331
+ "dump_local_norm": auto_parallel_context().get_dump_local_norm,
1332
+ "dump_local_norm_path": auto_parallel_context().get_dump_local_norm_path,
1333
+ "dump_device_local_norm": auto_parallel_context().get_dump_device_local_norm}
1324
1334
 
1325
1335
 
1326
1336
  @args_type_check(device_num=int, global_rank=int, gradients_mean=bool, gradient_fp32_sync=bool,
@@ -24,7 +24,8 @@ from mindspore.ops import operations as P
24
24
  from mindspore.ops.operations.comm_ops import AllGather
25
25
  from mindspore.communication import GlobalComm
26
26
  from mindspore.common import jit
27
- from mindspore.communication import create_group
27
+ from mindspore.communication import create_group, destroy_group
28
+ from mindspore.communication._comm_helper import _get_group_map
28
29
  from mindspore.train._utils import get_parameter_redundancy, remove_param_redundancy
29
30
 
30
31
  _ALLGATHER_CELL = None
@@ -131,6 +132,21 @@ def _restore_parallel_context(origin_parallel_mode, origin_dataset_strategy):
131
132
  context.set_auto_parallel_context(dataset_strategy=origin_dataset_strategy)
132
133
 
133
134
 
135
+ def _get_group_name(group_map, group):
136
+ """get group name"""
137
+ group_name = str(group)
138
+ is_manual_communication_group = True
139
+ if group_map:
140
+ for name, rank_list in group_map.items():
141
+ if list(group) == rank_list:
142
+ group_name = name
143
+ is_manual_communication_group = False
144
+ break
145
+ if is_manual_communication_group:
146
+ create_group(str(group), list(group))
147
+ return group_name, is_manual_communication_group
148
+
149
+
134
150
  def _single_parameter_broadcast(net, layout, cur_rank=0, initial_rank=0):
135
151
  """
136
152
  Broadcast single parameter to other rank in data parallel dimension.
@@ -158,8 +174,9 @@ def _single_parameter_broadcast(net, layout, cur_rank=0, initial_rank=0):
158
174
  return
159
175
  net_param_dict = net.parameters_dict()
160
176
  _chang_parallel_context(origin_dataset_strategy)
177
+ group_map = _get_group_map()
161
178
  for group, params in param_redundancy_reversed.items():
162
- create_group(str(group), list(group))
179
+ group_name, is_manual_communication_group = _get_group_name(group_map, group)
163
180
  allreduce_input = []
164
181
  for param in params:
165
182
  if param not in net_param_dict:
@@ -170,7 +187,9 @@ def _single_parameter_broadcast(net, layout, cur_rank=0, initial_rank=0):
170
187
  allreduce_input.append(real_param)
171
188
  if not allreduce_input:
172
189
  continue
173
- communicator = SingleCommunicator(str(group))
190
+ communicator = SingleCommunicator(group_name)
174
191
  for real_param in allreduce_input:
175
192
  real_param.set_data(communicator(real_param), real_param.sliced)
193
+ if is_manual_communication_group:
194
+ destroy_group(group_name)
176
195
  _restore_parallel_context(origin_parallel_mode, origin_dataset_strategy)
@@ -115,11 +115,15 @@ def _check_strategy_file(strategy_filename):
115
115
  f"be empty. Please check whether the 'strategy_filename' is correct.")
116
116
 
117
117
 
118
- def _load_protobuf_strategy(strategy_filename):
118
+ def _load_protobuf_strategy(strategy_filename, strategy_set=None):
119
119
  """load strategy from protobuf file"""
120
120
  parallel_strategy_map = ms.train.node_strategy_pb2.ParallelStrategyMap()
121
121
  with open(strategy_filename, 'rb') as f:
122
122
  pb_content = f.read()
123
+ if strategy_set is not None:
124
+ if pb_content in strategy_set:
125
+ return {}
126
+ strategy_set.add(pb_content)
123
127
  try:
124
128
  parallel_strategy_map.ParseFromString(pb_content)
125
129
  except BaseException as e:
@@ -188,8 +192,11 @@ def _merge_protobuf_strategy(src_strategy_files, dst_strategy_file):
188
192
  """merge protobuf strategy"""
189
193
  dst_parallel_strategy_map = ms.train.node_strategy_pb2.ParallelStrategyMap()
190
194
  merged_stage = []
195
+ strategy_set = set()
191
196
  for src_strategy_file in src_strategy_files:
192
- src_parallel_strategy_map = _load_protobuf_strategy(src_strategy_file)
197
+ src_parallel_strategy_map = _load_protobuf_strategy(src_strategy_file, strategy_set=strategy_set)
198
+ if not src_parallel_strategy_map:
199
+ continue
193
200
  strategy_items = src_parallel_strategy_map.parallel_strategy_item
194
201
  layout_items = src_parallel_strategy_map.parallel_layout_item
195
202
  if not strategy_items or not layout_items:
@@ -339,6 +346,9 @@ def _get_device_num_from_strategy(strategy_file=None):
339
346
  src_strategy = strategy_file
340
347
  strategy_list = _convert_to_list(src_strategy)
341
348
  device_mat = list(strategy_list.values())[0][0]
349
+ if not device_mat:
350
+ raise ValueError("The parallel strategy file only contains pipeline-parallelism, which is not supported for "
351
+ "parallel strategy conversion now.")
342
352
  return np.prod(device_mat)
343
353
 
344
354
 
@@ -559,3 +569,4 @@ def _get_param_list_when_first_dim_sharded(device_arrangement, first_dim_sharded
559
569
  start = rank - offset
560
570
  param_total_list = list(range(start, start + range_size))
561
571
  return param_total_list
572
+
@@ -30,7 +30,7 @@ from mindspore.common.seed import get_seed
30
30
  from mindspore._c_expression import GraphExecutor_
31
31
  from mindspore.parallel._tensor import _load_tensor_by_layout, _load_tensor_shape_by_layout
32
32
 
33
- SUPPORTED_TUPLE_IN_TUPLE_STRATEGY = ["GroupedMatmul", "FusedInferAttentionScore", "Custom"]
33
+ SUPPORTED_TUPLE_IN_TUPLE_STRATEGY = ["GroupedMatmul", "FusedInferAttentionScore", "Custom", "Index"]
34
34
 
35
35
 
36
36
  def _get_parallel_mode():
@@ -127,7 +127,6 @@ class ParallelParamInitProfCtx:
127
127
 
128
128
  def _slice_parameter(parameter, phase, layout):
129
129
  """Slice python parameter obj according to the layout."""
130
- # graph_executor.updata_param_node_default_input(phase, {parameter.name: parameter})
131
130
  if getattr(parameter, "init_param", False):
132
131
  if layout is None:
133
132
  parameter.sliced = True
@@ -136,6 +135,9 @@ def _slice_parameter(parameter, phase, layout):
136
135
  rank = get_rank()
137
136
  new_tensor_shape = _load_tensor_shape_by_layout(parameter, layout, rank)
138
137
  parameter.shape = new_tensor_shape
138
+ if hasattr(parameter.init_mode, "shape") and parameter.init_mode.shape != parameter.shape:
139
+ parameter.init_mode.shape = new_tensor_shape
140
+ parameter.sliced = True
139
141
  else:
140
142
  graph_executor = GraphExecutor_.get_instance()
141
143
  new_param = parameter.init_data(layout, set_sliced=True)