mindspore 2.6.0rc1__cp311-cp311-win_amd64.whl → 2.7.0__cp311-cp311-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 (458) 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 +2 -2
  5. mindspore/_c_dataengine.cp311-win_amd64.pyd +0 -0
  6. mindspore/_c_expression.cp311-win_amd64.pyd +0 -0
  7. mindspore/_c_mindrecord.cp311-win_amd64.pyd +0 -0
  8. mindspore/_checkparam.py +42 -11
  9. mindspore/_extends/builtin_operations.py +3 -3
  10. mindspore/{_deprecated → _extends/optimize}/__init__.py +9 -3
  11. mindspore/_extends/optimize/cell_utils.py +96 -0
  12. mindspore/_extends/parallel_compile/akg_compiler/custom.py +1109 -0
  13. mindspore/_extends/parallel_compile/akg_compiler/gen_custom_op_files.py +1 -1
  14. mindspore/_extends/parse/__init__.py +3 -3
  15. mindspore/_extends/parse/compile_config.py +44 -22
  16. mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +1 -2
  17. mindspore/_extends/parse/parser.py +65 -84
  18. mindspore/_extends/parse/resources.py +39 -0
  19. mindspore/_extends/parse/standard_method.py +58 -14
  20. mindspore/_extends/parse/trope.py +8 -1
  21. mindspore/_extends/pijit/__init__.py +1 -2
  22. mindspore/_extends/pijit/pijit_func_white_list.py +2 -5
  23. mindspore/amp.py +4 -22
  24. mindspore/atlprov.dll +0 -0
  25. mindspore/avcodec-59.dll +0 -0
  26. mindspore/avdevice-59.dll +0 -0
  27. mindspore/avfilter-8.dll +0 -0
  28. mindspore/avformat-59.dll +0 -0
  29. mindspore/avutil-57.dll +0 -0
  30. mindspore/boost/adasum.py +1 -1
  31. mindspore/boost/boost_cell_wrapper.py +4 -4
  32. mindspore/c1.dll +0 -0
  33. mindspore/c1xx.dll +0 -0
  34. mindspore/c2.dll +0 -0
  35. mindspore/common/__init__.py +43 -12
  36. mindspore/common/_grad_function.py +2 -1
  37. mindspore/common/_pijit_context.py +28 -7
  38. mindspore/common/_stub_tensor.py +1 -209
  39. mindspore/common/_tensor_cpp_method.py +1 -1
  40. mindspore/common/_tensor_docs.py +178 -53
  41. mindspore/common/_utils.py +9 -1
  42. mindspore/common/api.py +377 -203
  43. mindspore/common/dtype.py +108 -57
  44. mindspore/common/dump.py +11 -16
  45. mindspore/common/dynamic_shape/__init__.py +0 -0
  46. mindspore/common/{auto_dynamic_shape.py → dynamic_shape/auto_dynamic_shape.py} +17 -23
  47. mindspore/common/dynamic_shape/enable_dynamic.py +197 -0
  48. mindspore/common/file_system.py +59 -9
  49. mindspore/common/generator.py +5 -3
  50. mindspore/common/hook_handle.py +33 -5
  51. mindspore/common/jit_config.py +1 -1
  52. mindspore/common/jit_trace.py +84 -105
  53. mindspore/common/np_dtype.py +3 -3
  54. mindspore/common/parameter.py +27 -29
  55. mindspore/common/recompute.py +5 -7
  56. mindspore/common/sparse_tensor.py +0 -3
  57. mindspore/common/symbol.py +0 -1
  58. mindspore/common/tensor.py +117 -131
  59. mindspore/communication/_comm_helper.py +46 -4
  60. mindspore/communication/management.py +79 -7
  61. mindspore/context.py +67 -55
  62. mindspore/dataset/__init__.py +1 -1
  63. mindspore/dataset/audio/transforms.py +1 -1
  64. mindspore/dataset/core/config.py +38 -4
  65. mindspore/dataset/engine/datasets.py +350 -322
  66. mindspore/dataset/engine/datasets_user_defined.py +70 -24
  67. mindspore/dataset/engine/iterators.py +2 -2
  68. mindspore/dataset/engine/obs/config_loader.py +2 -2
  69. mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +8 -0
  70. mindspore/dataset/transforms/c_transforms.py +2 -2
  71. mindspore/dataset/transforms/py_transforms.py +7 -3
  72. mindspore/dataset/transforms/transforms.py +10 -6
  73. mindspore/dataset/vision/__init__.py +1 -1
  74. mindspore/dataset/vision/py_transforms.py +8 -8
  75. mindspore/dataset/vision/transforms.py +17 -5
  76. mindspore/dataset/vision/utils.py +632 -21
  77. mindspore/dataset/vision/validators.py +1 -0
  78. mindspore/device_context/ascend/device.py +1 -1
  79. mindspore/device_context/ascend/op_tuning.py +35 -1
  80. mindspore/device_context/gpu/__init__.py +2 -2
  81. mindspore/device_context/gpu/device.py +1 -1
  82. mindspore/device_context/gpu/op_precision.py +4 -2
  83. mindspore/device_context/gpu/op_tuning.py +6 -3
  84. mindspore/device_manager.py +16 -9
  85. mindspore/dnnl.dll +0 -0
  86. mindspore/dpcmi.dll +0 -0
  87. mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +3 -4
  88. mindspore/experimental/llm_boost/atb/boost_base.py +2 -3
  89. mindspore/experimental/optim/adadelta.py +13 -20
  90. mindspore/experimental/optim/adagrad.py +15 -22
  91. mindspore/experimental/optim/adam.py +17 -24
  92. mindspore/experimental/optim/adamax.py +14 -22
  93. mindspore/experimental/optim/adamw.py +28 -34
  94. mindspore/experimental/optim/asgd.py +15 -25
  95. mindspore/experimental/optim/lr_scheduler.py +27 -45
  96. mindspore/experimental/optim/nadam.py +14 -24
  97. mindspore/experimental/optim/optimizer.py +13 -23
  98. mindspore/experimental/optim/radam.py +18 -24
  99. mindspore/experimental/optim/rmsprop.py +14 -25
  100. mindspore/experimental/optim/rprop.py +15 -26
  101. mindspore/experimental/optim/sgd.py +9 -19
  102. mindspore/hal/__init__.py +4 -4
  103. mindspore/hal/contiguous_tensors_handle.py +2 -2
  104. mindspore/hal/memory.py +27 -7
  105. mindspore/include/api/cell.h +65 -5
  106. mindspore/include/api/cfg.h +24 -7
  107. mindspore/include/api/context.h +1 -0
  108. mindspore/include/api/delegate.h +10 -2
  109. mindspore/include/api/dual_abi_helper.h +100 -19
  110. mindspore/include/api/graph.h +14 -1
  111. mindspore/include/api/kernel.h +16 -3
  112. mindspore/include/api/kernel_api.h +9 -1
  113. mindspore/include/api/metrics/accuracy.h +9 -0
  114. mindspore/include/api/model.h +8 -1
  115. mindspore/include/api/model_group.h +4 -0
  116. mindspore/include/api/model_parallel_runner.h +2 -0
  117. mindspore/include/api/status.h +48 -10
  118. mindspore/include/api/types.h +8 -3
  119. mindspore/include/c_api/model_c.h +0 -58
  120. mindspore/include/c_api/tensor_c.h +0 -26
  121. mindspore/include/dataset/constants.h +9 -0
  122. mindspore/include/dataset/vision_ascend.h +1 -1
  123. mindspore/jpeg62.dll +0 -0
  124. mindspore/mindrecord/tools/cifar10.py +61 -11
  125. mindspore/mindrecord/tools/cifar10_to_mr.py +5 -0
  126. mindspore/mindspore_backend_common.dll +0 -0
  127. mindspore/mindspore_backend_manager.dll +0 -0
  128. mindspore/mindspore_common.dll +0 -0
  129. mindspore/mindspore_core.dll +0 -0
  130. mindspore/mindspore_cpu_res_manager.dll +0 -0
  131. mindspore/mindspore_dump.dll +0 -0
  132. mindspore/mindspore_frontend.dll +0 -0
  133. mindspore/mindspore_glog.dll +0 -0
  134. mindspore/mindspore_memory_pool.dll +0 -0
  135. mindspore/mindspore_ms_backend.dll +0 -0
  136. mindspore/mindspore_ops.dll +0 -0
  137. mindspore/mindspore_ops_host.dll +0 -0
  138. mindspore/mindspore_ops_kernel_common.dll +0 -0
  139. mindspore/mindspore_profiler.dll +0 -0
  140. mindspore/mindspore_pyboost.dll +0 -0
  141. mindspore/mindspore_pynative.dll +0 -0
  142. mindspore/mindspore_res_manager.dll +0 -0
  143. mindspore/mindspore_runtime_pipeline.dll +0 -0
  144. mindspore/mint/__init__.py +6 -46
  145. mindspore/mint/distributed/__init__.py +5 -0
  146. mindspore/mint/distributed/distributed.py +429 -23
  147. mindspore/mint/nn/__init__.py +1 -1
  148. mindspore/mint/nn/functional.py +53 -6
  149. mindspore/mint/nn/layer/_functions.py +163 -294
  150. mindspore/mint/nn/layer/activation.py +8 -6
  151. mindspore/mint/nn/layer/conv.py +140 -104
  152. mindspore/mint/nn/layer/normalization.py +11 -25
  153. mindspore/mint/optim/adam.py +19 -18
  154. mindspore/mint/optim/adamw.py +14 -8
  155. mindspore/mint/optim/sgd.py +5 -5
  156. mindspore/msobj140.dll +0 -0
  157. mindspore/mspdb140.dll +0 -0
  158. mindspore/mspdbcore.dll +0 -0
  159. mindspore/mspdbst.dll +0 -0
  160. mindspore/mspft140.dll +0 -0
  161. mindspore/msvcdis140.dll +0 -0
  162. mindspore/msvcp140_1.dll +0 -0
  163. mindspore/msvcp140_2.dll +0 -0
  164. mindspore/msvcp140_atomic_wait.dll +0 -0
  165. mindspore/msvcp140_codecvt_ids.dll +0 -0
  166. mindspore/nn/cell.py +491 -623
  167. mindspore/nn/grad/cell_grad.py +11 -12
  168. mindspore/nn/layer/activation.py +36 -36
  169. mindspore/nn/layer/basic.py +74 -77
  170. mindspore/nn/layer/channel_shuffle.py +4 -4
  171. mindspore/nn/layer/combined.py +4 -2
  172. mindspore/nn/layer/conv.py +117 -110
  173. mindspore/nn/layer/dense.py +9 -7
  174. mindspore/nn/layer/embedding.py +50 -52
  175. mindspore/nn/layer/image.py +38 -40
  176. mindspore/nn/layer/math.py +111 -112
  177. mindspore/nn/layer/normalization.py +56 -44
  178. mindspore/nn/layer/pooling.py +58 -63
  179. mindspore/nn/layer/rnn_cells.py +33 -33
  180. mindspore/nn/layer/rnns.py +56 -56
  181. mindspore/nn/layer/thor_layer.py +74 -73
  182. mindspore/nn/layer/transformer.py +11 -1
  183. mindspore/nn/learning_rate_schedule.py +20 -20
  184. mindspore/nn/loss/loss.py +79 -81
  185. mindspore/nn/optim/adam.py +4 -6
  186. mindspore/nn/optim/adasum.py +2 -2
  187. mindspore/nn/optim/asgd.py +2 -0
  188. mindspore/nn/optim/lamb.py +1 -3
  189. mindspore/nn/optim/optimizer.py +1 -1
  190. mindspore/nn/optim/tft_wrapper.py +2 -3
  191. mindspore/nn/optim/thor.py +2 -2
  192. mindspore/nn/probability/distribution/_utils/utils.py +2 -2
  193. mindspore/nn/probability/distribution/exponential.py +2 -1
  194. mindspore/nn/probability/distribution/poisson.py +2 -1
  195. mindspore/nn/sparse/sparse.py +3 -3
  196. mindspore/nn/wrap/cell_wrapper.py +73 -42
  197. mindspore/nn/wrap/grad_reducer.py +37 -52
  198. mindspore/nn/wrap/loss_scale.py +72 -74
  199. mindspore/numpy/array_creations.py +7 -7
  200. mindspore/numpy/fft.py +1 -1
  201. mindspore/numpy/math_ops.py +5 -5
  202. mindspore/numpy/utils_const.py +1 -1
  203. mindspore/opencv_core452.dll +0 -0
  204. mindspore/opencv_imgcodecs452.dll +0 -0
  205. mindspore/opencv_imgproc452.dll +0 -0
  206. mindspore/ops/_grad_experimental/grad_comm_ops.py +51 -13
  207. mindspore/ops/_grad_experimental/grad_debug_ops.py +14 -0
  208. mindspore/ops/_grad_experimental/grad_inner_ops.py +0 -9
  209. mindspore/ops/_op_impl/cpu/__init__.py +1 -0
  210. mindspore/{experimental/es/__init__.py → ops/_op_impl/cpu/joinedstr_op.py} +12 -6
  211. mindspore/ops/_vmap/vmap_array_ops.py +31 -13
  212. mindspore/ops/_vmap/vmap_nn_ops.py +8 -16
  213. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +54 -13
  214. mindspore/ops/auto_generate/gen_extend_func.py +27 -145
  215. mindspore/ops/auto_generate/gen_ops_def.py +1027 -347
  216. mindspore/ops/auto_generate/gen_ops_prim.py +2341 -1117
  217. mindspore/ops/auto_generate/pyboost_inner_prim.py +31 -1
  218. mindspore/ops/composite/__init__.py +10 -0
  219. mindspore/ops/composite/base.py +9 -5
  220. mindspore/ops/composite/multitype_ops/__init__.py +12 -1
  221. mindspore/ops/composite/multitype_ops/_compile_utils.py +133 -109
  222. mindspore/ops/composite/multitype_ops/_constexpr_utils.py +1 -1
  223. mindspore/ops/composite/multitype_ops/add_impl.py +70 -2
  224. mindspore/ops/composite/multitype_ops/div_impl.py +49 -0
  225. mindspore/ops/composite/multitype_ops/floordiv_impl.py +29 -0
  226. mindspore/ops/composite/multitype_ops/getitem_impl.py +11 -0
  227. mindspore/ops/composite/multitype_ops/mod_impl.py +5 -3
  228. mindspore/ops/composite/multitype_ops/mul_impl.py +49 -0
  229. mindspore/ops/composite/multitype_ops/setitem_impl.py +57 -0
  230. mindspore/ops/composite/multitype_ops/sub_impl.py +34 -0
  231. mindspore/ops/composite/multitype_ops/zeros_like_impl.py +14 -0
  232. mindspore/ops/function/__init__.py +4 -1
  233. mindspore/ops/function/_add_attr_func.py +11 -6
  234. mindspore/ops/function/array_func.py +19 -102
  235. mindspore/ops/function/debug_func.py +8 -5
  236. mindspore/ops/function/grad/grad_func.py +5 -13
  237. mindspore/ops/function/math_func.py +77 -572
  238. mindspore/ops/function/nn_func.py +46 -94
  239. mindspore/ops/function/other_func.py +4 -1
  240. mindspore/ops/function/random_func.py +44 -5
  241. mindspore/ops/function/vmap_func.py +2 -1
  242. mindspore/ops/functional.py +4 -4
  243. mindspore/ops/functional_overload.py +594 -18
  244. mindspore/ops/op_info_register.py +21 -0
  245. mindspore/ops/operations/__init__.py +16 -11
  246. mindspore/ops/operations/_custom_ops_utils.py +689 -34
  247. mindspore/ops/operations/_inner_ops.py +14 -18
  248. mindspore/ops/operations/_sequence_ops.py +1 -1
  249. mindspore/ops/operations/array_ops.py +5 -51
  250. mindspore/ops/operations/comm_ops.py +186 -41
  251. mindspore/ops/operations/custom_ops.py +303 -177
  252. mindspore/ops/operations/debug_ops.py +59 -4
  253. mindspore/ops/operations/image_ops.py +13 -13
  254. mindspore/ops/operations/manually_defined/ops_def.py +27 -28
  255. mindspore/ops/operations/math_ops.py +8 -9
  256. mindspore/ops/operations/nn_ops.py +8 -40
  257. mindspore/ops/primitive.py +9 -20
  258. mindspore/ops/tensor_method.py +63 -15
  259. mindspore/ops_generate/api/cpp_create_prim_instance_helper_generator.py +1 -1
  260. mindspore/ops_generate/api/functional_map_cpp_generator.py +10 -9
  261. mindspore/ops_generate/api/functions_cc_generator.py +58 -10
  262. mindspore/ops_generate/api/tensor_func_reg_cpp_generator.py +1 -1
  263. mindspore/ops_generate/common/base_generator.py +14 -0
  264. mindspore/ops_generate/common/gen_constants.py +8 -3
  265. mindspore/ops_generate/common/gen_utils.py +0 -19
  266. mindspore/ops_generate/common/op_proto.py +11 -4
  267. mindspore/ops_generate/common/template.py +88 -11
  268. mindspore/ops_generate/gen_ops.py +1 -1
  269. mindspore/ops_generate/op_def/lite_ops_cpp_generator.py +4 -4
  270. mindspore/ops_generate/op_def/ops_def_cc_generator.py +0 -3
  271. mindspore/ops_generate/op_def/ops_name_h_generator.py +0 -3
  272. mindspore/ops_generate/op_def/ops_primitive_h_generator.py +0 -4
  273. mindspore/ops_generate/op_def_py/op_prim_py_generator.py +5 -2
  274. mindspore/ops_generate/pyboost/auto_grad_impl_cc_generator.py +49 -8
  275. mindspore/ops_generate/pyboost/auto_grad_reg_cc_generator.py +2 -2
  276. mindspore/ops_generate/pyboost/gen_pyboost_func.py +31 -16
  277. mindspore/ops_generate/pyboost/op_template_parser.py +98 -72
  278. mindspore/ops_generate/pyboost/pyboost_functions_cpp_generator.py +70 -273
  279. mindspore/ops_generate/pyboost/pyboost_functions_h_generator.py +14 -6
  280. mindspore/ops_generate/pyboost/pyboost_functions_impl_cpp_generator.py +316 -0
  281. mindspore/ops_generate/pyboost/pyboost_functions_py_generator.py +1 -1
  282. mindspore/ops_generate/pyboost/pyboost_grad_function_cpp_generator.py +5 -3
  283. mindspore/ops_generate/pyboost/pyboost_inner_prim_generator.py +1 -1
  284. mindspore/ops_generate/pyboost/pyboost_internal_functions_cpp_generator.py +76 -0
  285. mindspore/ops_generate/pyboost/pyboost_internal_functions_h_generator.py +76 -0
  286. mindspore/ops_generate/pyboost/pyboost_internal_kernel_info_adapter_generator.py +125 -0
  287. mindspore/ops_generate/pyboost/pyboost_native_grad_functions_generator.py +4 -3
  288. mindspore/ops_generate/pyboost/pyboost_op_cpp_code_generator.py +348 -61
  289. mindspore/ops_generate/pyboost/pyboost_overload_functions_cpp_generator.py +1 -1
  290. mindspore/ops_generate/pyboost/pyboost_utils.py +118 -9
  291. mindspore/ops_generate/tensor_py_cc_generator.py +1 -24
  292. mindspore/parallel/_auto_parallel_context.py +16 -23
  293. mindspore/parallel/_cell_wrapper.py +113 -45
  294. mindspore/parallel/_parallel_serialization.py +4 -3
  295. mindspore/parallel/_ps_context.py +4 -6
  296. mindspore/parallel/_tensor.py +167 -12
  297. mindspore/parallel/_transformer/moe.py +1 -1
  298. mindspore/parallel/_transformer/transformer.py +17 -12
  299. mindspore/parallel/_utils.py +5 -11
  300. mindspore/parallel/auto_parallel.py +35 -14
  301. mindspore/parallel/checkpoint_convert.py +3 -3
  302. mindspore/parallel/checkpoint_transform.py +13 -7
  303. mindspore/parallel/cluster/process_entity/_api.py +88 -49
  304. mindspore/parallel/cluster/process_entity/_utils.py +95 -7
  305. mindspore/parallel/cluster/run.py +48 -7
  306. mindspore/parallel/function/__init__.py +8 -1
  307. mindspore/parallel/function/reshard_func.py +12 -12
  308. mindspore/parallel/nn/__init__.py +15 -2
  309. mindspore/parallel/nn/parallel_cell_wrapper.py +50 -14
  310. mindspore/parallel/nn/parallel_grad_reducer.py +7 -14
  311. mindspore/parallel/shard.py +10 -25
  312. mindspore/parallel/transform_safetensors.py +469 -174
  313. mindspore/pgodb140.dll +0 -0
  314. mindspore/pgort140.dll +0 -0
  315. mindspore/profiler/__init__.py +2 -1
  316. mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +7 -7
  317. mindspore/profiler/analysis/parser/timeline_assembly_factory/base_timeline_assembler.py +3 -0
  318. mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +12 -6
  319. mindspore/profiler/analysis/parser/timeline_creator/cpu_op_timeline_creator.py +3 -3
  320. mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +3 -3
  321. mindspore/profiler/analysis/parser/timeline_creator/msprof_timeline_creator.py +4 -4
  322. mindspore/profiler/analysis/parser/timeline_creator/scope_layer_timeline_creator.py +3 -3
  323. mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +4 -1
  324. mindspore/profiler/analysis/parser/timeline_event/timeline_event_pool.py +2 -1
  325. mindspore/profiler/analysis/task_manager.py +1 -1
  326. mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +5 -1
  327. mindspore/profiler/analysis/viewer/ascend_integrate_viewer.py +2 -1
  328. mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +10 -9
  329. mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +43 -23
  330. mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +3 -2
  331. mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +9 -5
  332. mindspore/profiler/analysis/viewer/ms_operator_details_viewer.py +132 -0
  333. mindspore/profiler/common/constant.py +16 -0
  334. mindspore/profiler/common/msprof_cmd_tool.py +2 -2
  335. mindspore/profiler/common/path_manager.py +9 -0
  336. mindspore/profiler/common/profiler_context.py +50 -29
  337. mindspore/profiler/common/profiler_info.py +0 -16
  338. mindspore/profiler/common/profiler_meta_data.py +1 -0
  339. mindspore/profiler/common/profiler_op_analyse.py +239 -0
  340. mindspore/profiler/common/profiler_output_path.py +23 -8
  341. mindspore/profiler/common/profiler_parameters.py +128 -35
  342. mindspore/profiler/dynamic_profile/__init__.py +0 -0
  343. mindspore/profiler/dynamic_profile/dynamic_monitor_proxy.py +39 -0
  344. mindspore/profiler/dynamic_profile/dynamic_profiler_config_context.py +666 -0
  345. mindspore/profiler/dynamic_profile/dynamic_profiler_utils.py +62 -0
  346. mindspore/profiler/dynamic_profiler.py +374 -338
  347. mindspore/profiler/envprofiler.py +42 -12
  348. mindspore/profiler/experimental_config.py +112 -7
  349. mindspore/profiler/mstx.py +33 -12
  350. mindspore/profiler/platform/__init__.py +2 -3
  351. mindspore/profiler/platform/cpu_profiler.py +10 -4
  352. mindspore/profiler/platform/npu_profiler.py +30 -20
  353. mindspore/profiler/profiler.py +218 -154
  354. mindspore/profiler/profiler_action_controller.py +65 -77
  355. mindspore/profiler/profiler_interface.py +2 -2
  356. mindspore/profiler/schedule.py +10 -4
  357. mindspore/rewrite/common/config.py +1 -0
  358. mindspore/rewrite/common/namer.py +1 -0
  359. mindspore/rewrite/common/namespace.py +1 -0
  360. mindspore/rewrite/node/node.py +31 -11
  361. mindspore/rewrite/parsers/assign_parser.py +1 -1
  362. mindspore/rewrite/symbol_tree/symbol_tree.py +2 -2
  363. mindspore/run_check/_check_version.py +7 -10
  364. mindspore/runtime/__init__.py +8 -6
  365. mindspore/runtime/event.py +10 -4
  366. mindspore/runtime/executor.py +87 -45
  367. mindspore/runtime/memory.py +31 -32
  368. mindspore/runtime/thread_bind_core.py +299 -165
  369. mindspore/safeguard/rewrite_obfuscation.py +12 -13
  370. mindspore/swresample-4.dll +0 -0
  371. mindspore/swscale-6.dll +0 -0
  372. mindspore/tbbmalloc.dll +0 -0
  373. mindspore/tinyxml2.dll +0 -0
  374. mindspore/train/_utils.py +17 -7
  375. mindspore/train/amp.py +43 -23
  376. mindspore/train/callback/__init__.py +5 -5
  377. mindspore/train/callback/_callback.py +2 -1
  378. mindspore/train/callback/_checkpoint.py +4 -14
  379. mindspore/train/callback/_flops_collector.py +11 -7
  380. mindspore/train/callback/_landscape.py +0 -1
  381. mindspore/train/callback/_train_fault_tolerance.py +98 -21
  382. mindspore/train/data_sink.py +15 -6
  383. mindspore/train/dataset_helper.py +14 -5
  384. mindspore/train/model.py +133 -69
  385. mindspore/train/serialization.py +168 -126
  386. mindspore/train/summary/summary_record.py +13 -2
  387. mindspore/train/train_thor/model_thor.py +2 -2
  388. mindspore/turbojpeg.dll +0 -0
  389. mindspore/utils/__init__.py +3 -2
  390. mindspore/utils/dryrun.py +0 -6
  391. mindspore/utils/runtime_execution_order_check.py +163 -77
  392. mindspore/utils/sdc_detect.py +68 -0
  393. mindspore/utils/utils.py +14 -17
  394. mindspore/vcmeta.dll +0 -0
  395. mindspore/vcruntime140.dll +0 -0
  396. mindspore/vcruntime140_1.dll +0 -0
  397. mindspore/version.py +1 -1
  398. {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0.dist-info}/METADATA +5 -4
  399. {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0.dist-info}/RECORD +403 -442
  400. mindspore/_deprecated/jit.py +0 -198
  401. mindspore/_extends/remote/kernel_build_server_ascend.py +0 -75
  402. mindspore/communication/_hccl_management.py +0 -297
  403. mindspore/experimental/es/embedding_service.py +0 -891
  404. mindspore/experimental/es/embedding_service_layer.py +0 -581
  405. mindspore/profiler/common/validator/__init__.py +0 -14
  406. mindspore/profiler/common/validator/validate_path.py +0 -84
  407. mindspore/profiler/parser/__init__.py +0 -14
  408. mindspore/profiler/parser/aicpu_data_parser.py +0 -272
  409. mindspore/profiler/parser/ascend_analysis/__init__.py +0 -14
  410. mindspore/profiler/parser/ascend_analysis/constant.py +0 -71
  411. mindspore/profiler/parser/ascend_analysis/file_manager.py +0 -180
  412. mindspore/profiler/parser/ascend_analysis/function_event.py +0 -185
  413. mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +0 -136
  414. mindspore/profiler/parser/ascend_analysis/fwk_file_parser.py +0 -131
  415. mindspore/profiler/parser/ascend_analysis/msprof_timeline_parser.py +0 -104
  416. mindspore/profiler/parser/ascend_analysis/path_manager.py +0 -313
  417. mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +0 -123
  418. mindspore/profiler/parser/ascend_analysis/tlv_decoder.py +0 -86
  419. mindspore/profiler/parser/ascend_analysis/trace_event_manager.py +0 -75
  420. mindspore/profiler/parser/ascend_cluster_generator.py +0 -116
  421. mindspore/profiler/parser/ascend_communicate_generator.py +0 -314
  422. mindspore/profiler/parser/ascend_flops_generator.py +0 -116
  423. mindspore/profiler/parser/ascend_fpbp_generator.py +0 -82
  424. mindspore/profiler/parser/ascend_hccl_generator.py +0 -271
  425. mindspore/profiler/parser/ascend_integrate_generator.py +0 -42
  426. mindspore/profiler/parser/ascend_memory_generator.py +0 -185
  427. mindspore/profiler/parser/ascend_msprof_exporter.py +0 -282
  428. mindspore/profiler/parser/ascend_msprof_generator.py +0 -187
  429. mindspore/profiler/parser/ascend_op_generator.py +0 -334
  430. mindspore/profiler/parser/ascend_steptrace_generator.py +0 -94
  431. mindspore/profiler/parser/ascend_timeline_generator.py +0 -545
  432. mindspore/profiler/parser/base_timeline_generator.py +0 -483
  433. mindspore/profiler/parser/container.py +0 -229
  434. mindspore/profiler/parser/cpu_gpu_timeline_generator.py +0 -697
  435. mindspore/profiler/parser/flops_parser.py +0 -531
  436. mindspore/profiler/parser/framework_enum.py +0 -111
  437. mindspore/profiler/parser/framework_parser.py +0 -464
  438. mindspore/profiler/parser/framework_struct.py +0 -61
  439. mindspore/profiler/parser/gpu_analysis/__init__.py +0 -14
  440. mindspore/profiler/parser/gpu_analysis/function_event.py +0 -44
  441. mindspore/profiler/parser/gpu_analysis/fwk_file_parser.py +0 -89
  442. mindspore/profiler/parser/gpu_analysis/profiler_info_parser.py +0 -72
  443. mindspore/profiler/parser/hccl_parser.py +0 -573
  444. mindspore/profiler/parser/hwts_log_parser.py +0 -122
  445. mindspore/profiler/parser/integrator.py +0 -526
  446. mindspore/profiler/parser/memory_usage_parser.py +0 -277
  447. mindspore/profiler/parser/minddata_analyzer.py +0 -800
  448. mindspore/profiler/parser/minddata_parser.py +0 -186
  449. mindspore/profiler/parser/minddata_pipeline_parser.py +0 -299
  450. mindspore/profiler/parser/op_intermediate_parser.py +0 -149
  451. mindspore/profiler/parser/optime_parser.py +0 -250
  452. mindspore/profiler/parser/profiler_info.py +0 -213
  453. mindspore/profiler/parser/step_trace_parser.py +0 -666
  454. mindspore/utils/hooks.py +0 -81
  455. /mindspore/common/{_auto_dynamic.py → dynamic_shape/_auto_dynamic.py} +0 -0
  456. {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0.dist-info}/WHEEL +0 -0
  457. {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0.dist-info}/entry_points.txt +0 -0
  458. {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0.dist-info}/top_level.txt +0 -0
@@ -58,9 +58,11 @@ from mindspore.ops.auto_generate.gen_ops_prim import (
58
58
  dist_comm_isend_op,
59
59
  dist_comm_all_to_all_v_op,
60
60
  dist_comm_reduce_scatter_tensor_op,
61
+ dist_comm_reduce_scatter_tensor_uneven_op,
61
62
  dist_comm_all_to_all_v_single_op,
62
63
  dist_comm_broadcast_op,
63
64
  dist_comm_all_gather_into_tensor_op,
65
+ dist_comm_all_gather_into_tensor_uneven_op,
64
66
  dist_comm_irecv_op,
65
67
  dist_comm_scatter_tensor_op,
66
68
  dist_comm_gather_into_tensor_op,
@@ -70,6 +72,7 @@ from mindspore.ops.auto_generate.gen_ops_prim import (
70
72
  dist_comm_barrier_op,
71
73
  dist_comm_batch_isend_irecv_op,
72
74
  )
75
+ from mindspore._c_expression import TCPStoreClient, GroupOptions
73
76
 
74
77
  _pickler = pickle.Pickler
75
78
  _unpickler = pickle.Unpickler
@@ -137,6 +140,193 @@ def _tensor_to_object(tensor, tensor_size):
137
140
  return restricted_loads(buf)
138
141
 
139
142
 
143
+ class TCPStore:
144
+ """
145
+ A TCP-based distributed key-value store implementation.
146
+
147
+ Note:
148
+ - The function is implemented by CPU and does not involve any hardware operations related to Ascend.
149
+ - Currently, all parameters provided by the TCPStore class constructor are not supported.
150
+ The master node and port number are uniformly specified by the MindSpore framework.
151
+ The following parameters are provided, currently not supported and settings are invalid.
152
+ - The current TcpStore function is limited and only supports scenarios where the key is
153
+ less than 4k and the value is less than 1G. Complex scenarios are to be supported.
154
+ - The timeout interval for message sending and receiving in the TcpStore function is controlled by
155
+ the `MS_RECEIVE_MSG_TIMEOUT` environment variable, in seconds, with a default value of ``15``.
156
+ If a timeout occurs, the user needs to increase the configuration value.
157
+
158
+ Args:
159
+ host_name (str, invalid, optional): The hostname or IP Address the server store should run on.
160
+ Default is ``None``.
161
+ port (int, invalid, optional): The port on which the server store should listen for incoming requests.
162
+ Default is ``None``.
163
+ world_size (int, invalid, optional): The total number of store users (number of clients + 1 for the server).
164
+ Default is ``None`` (``None`` indicates a non-fixed number of store users).
165
+ is_master (bool, invalid, optional): True when initializing the server store and False for client stores.
166
+ Default is ``False``.
167
+ timeout (timedelta, invalid, optional): Timeout used by the store during initialization, Unit: seconds.
168
+ Default is ``300``.
169
+ wait_for_workers (bool, invalid, optional): Whether to wait for all the workers to connect with the server
170
+ store. This is only applicable when `world_size` is a fixed value. Default is ``True``.
171
+ multi_tenant (bool, invalid, optional): If ``True``, all ``TCPStore`` instances in the current process with
172
+ the same host/port will use the same underlying ``TCPServer``. Default is ``False``.
173
+ master_listen_fd (int, invalid, optional): If specified, the underlying ``TCPServer`` will listen on this file
174
+ descriptor, which must be a socket already bound to ``port``. Useful to avoid port assignment races
175
+ in some scenarios. Default is ``None`` (meaning the server creates a new socket and attempts to bind it
176
+ to ``port``).
177
+ use_libuv (bool, invalid, optional): If True, use libuv for ``TCPServer`` backend. Default is ``True``.
178
+
179
+ Returns:
180
+ TCPStore Object.
181
+
182
+ Supported Platforms:
183
+ ``Ascend``
184
+
185
+ Examples:
186
+ .. note::
187
+ Before running the following examples, you need to configure the communication environment variables.
188
+
189
+ For Ascend devices, it is recommended to use the msrun startup method
190
+ without any third-party or configuration file dependencies.
191
+ Please see the `msrun start up
192
+ <https://www.mindspore.cn/tutorials/en/master/parallel/msrun_launcher.html>`_
193
+ for more details.
194
+
195
+ >>> from mindspore.mint.distributed import TCPStore
196
+ >>> store = TCPStore()
197
+ """
198
+
199
+ def __init__(self, host_name=None, port=None, world_size=None, is_master=False, timeout=300,
200
+ wait_for_workers=True, multi_tenant=False, master_listen_fd=None, use_libuv=True):
201
+ self.instance = TCPStoreClient.get_instance()
202
+
203
+
204
+ def set(self, key, value):
205
+ """
206
+ Inserts the key-value pair into the store based on the supplied `key` and
207
+ `value`. If `key` already exists in the store, it will overwrite the old
208
+ value with the new supplied `value`.
209
+
210
+ Args:
211
+ key (str): The key to be added to the store.
212
+ value (Union[bytes, str]): The value associated with `key` to be added to the store.
213
+
214
+ Raises:
215
+ TypeError: If `key` is not string.
216
+ TypeError: If `value` is not string or bytes.
217
+
218
+ Supported Platforms:
219
+ ``Ascend``
220
+
221
+ Examples:
222
+ .. note::
223
+ Before running the following examples, you need to configure the communication environment variables.
224
+
225
+ For Ascend devices, it is recommended to use the msrun startup method
226
+ without any third-party or configuration file dependencies.
227
+ Please see the `msrun start up
228
+ <https://www.mindspore.cn/tutorials/en/master/parallel/msrun_launcher.html>`_
229
+ for more details.
230
+
231
+ >>> from mindspore.mint.distributed import TCPStore
232
+ >>> store = TCPStore()
233
+ >>> store.set("first_key", "first_value")
234
+ """
235
+ if not isinstance(key, str):
236
+ raise TypeError(
237
+ "For 'TCPStore.set', the argument 'key' must be type of string, "
238
+ "but got 'key' type : {}.".format(type(key))
239
+ )
240
+ if not isinstance(value, (str, bytes)):
241
+ raise TypeError(
242
+ "For 'TCPStore.set', the argument 'value' must be type of string or bytes, "
243
+ "but got 'value' type : {}.".format(type(value))
244
+ )
245
+ return self.instance.set(key, value)
246
+
247
+
248
+ def get(self, key):
249
+ """
250
+ Retrieves the value associated with the given `key` in the store. If `key` is not
251
+ present in the store, the function will return "".
252
+
253
+ Args:
254
+ key (str): The function will return the value associated with this key.
255
+
256
+ Returns:
257
+ bytes, Value associated with `key` if `key` is in the store.
258
+
259
+ Raises:
260
+ TypeError: If `key` is not string.
261
+
262
+ Supported Platforms:
263
+ ``Ascend``
264
+
265
+ Examples:
266
+ .. note::
267
+ Before running the following examples, you need to configure the communication environment variables.
268
+
269
+ For Ascend devices, it is recommended to use the msrun startup method
270
+ without any third-party or configuration file dependencies.
271
+ Please see the `msrun start up
272
+ <https://www.mindspore.cn/tutorials/en/master/parallel/msrun_launcher.html>`_
273
+ for more details.
274
+
275
+ >>> from mindspore.mint.distributed import TCPStore
276
+ >>> store = TCPStore()
277
+ >>> store.set("first_key", "first_value")
278
+ >>> data = store.get("first_key")
279
+ >>> print(data)
280
+ """
281
+ if not isinstance(key, str):
282
+ raise TypeError(
283
+ "For 'TCPStore.get', the argument 'key' must be type of string, "
284
+ "but got 'key' type : {}.".format(type(key))
285
+ )
286
+ byte_data = self.instance.get(key)
287
+ return byte_data
288
+
289
+
290
+ def delete_key(self, key):
291
+ """
292
+ Deletes the key-value pair associated with `key` from the store.
293
+
294
+ Args:
295
+ key (str): The key to be deleted from the store.
296
+
297
+ Returns:
298
+ bool, ``True`` if `key` was deleted, otherwise ``False``.
299
+
300
+ Raises:
301
+ TypeError: If `key` is not string.
302
+
303
+ Supported Platforms:
304
+ ``CPU``
305
+
306
+ Examples:
307
+ .. note::
308
+ Before running the following examples, you need to configure the communication environment variables.
309
+
310
+ For Ascend devices, it is recommended to use the msrun startup method
311
+ without any third-party or configuration file dependencies.
312
+ Please see the `msrun start up
313
+ <https://www.mindspore.cn/tutorials/en/master/parallel/msrun_launcher.html>`_
314
+ for more details.
315
+
316
+ >>> from mindspore.mint.distributed import TCPStore
317
+ >>> store = TCPStore()
318
+ >>> store.set("first_key", "first_value")
319
+ >>> # This should return true
320
+ >>> store.delete_key("first_key")
321
+ """
322
+ if not isinstance(key, str):
323
+ raise TypeError(
324
+ "For 'TCPStore.delete_key', the argument 'key' must be type of string, "
325
+ "but got 'key' type : {}.".format(type(key))
326
+ )
327
+ return self.instance.delete_key(key)
328
+
329
+
140
330
  def is_available():
141
331
  """
142
332
  Checks if distributed module is available.
@@ -470,7 +660,19 @@ def new_group(ranks=None,
470
660
  when backend is ``"hccl"`` will use Huawei Collective Communication Library(HCCL).
471
661
  when backend is ``"mccl"`` will use MindSpore Collective Communication Library(MCCL).
472
662
  If ``None``, which means ``"hccl"`` in Ascend. Default is ``None``.
473
- pg_options (str, invalid): Currently it is a reserved parameter.
663
+ pg_options (GroupOptions, optional): Additional communication group configuration parameters.
664
+ The backend will automatically select supported parameters and apply them during group
665
+ initialization. i.e. for the ``HCCL`` backend, ``hccl_config`` can be specified so that
666
+ group initialization configurations can be applied. Default is ``None``.
667
+
668
+ `GroupOptions` is defined as a class that can be instantiated as a python object.
669
+
670
+ .. code-block::
671
+
672
+ GroupOptions {
673
+ hccl_config(dict)
674
+ }
675
+
474
676
  use_local_synchronization (bool, invalid): Currently it is a reserved parameter.
475
677
  group_desc (str, invalid): Currently it is a reserved parameter.
476
678
 
@@ -511,8 +713,11 @@ def new_group(ranks=None,
511
713
  if not isinstance(backend, str) or backend not in ("hccl", "mccl"):
512
714
  raise TypeError(f"the input backend must be hccl or mccl, but got {backend}")
513
715
  group = backend + "_" + str(len(ranks)) + "_" + hashlib.sha1(bytes("_".join(map(str, ranks)), "utf-8")).hexdigest()
716
+ if pg_options is not None:
717
+ if not isinstance(pg_options, GroupOptions):
718
+ raise TypeError("pg_options must be type GroupOptions, but got {}".format(type(pg_options)))
514
719
  try:
515
- create_group(group, ranks)
720
+ create_group(group, ranks, pg_options)
516
721
  except RuntimeError as e:
517
722
  logger.warning(e)
518
723
  group = ""
@@ -786,6 +991,22 @@ def _check_all_tensor_same_dtype_and_shape(*tensor_lists):
786
991
  )
787
992
 
788
993
 
994
+ @_primexpr
995
+ def _check_output_shape(output, expected_shape, op_name):
996
+ if output.shape != expected_shape:
997
+ raise TypeError(
998
+ f"For {op_name}, the output shape should be {expected_shape}, "
999
+ f"but got {output.shape}.")
1000
+
1001
+
1002
+ @_primexpr
1003
+ def _check_output_dtype(output, expected_dtype, op_name):
1004
+ if output.dtype != expected_dtype:
1005
+ raise TypeError(
1006
+ f"For {op_name}, the output dtype should be {expected_dtype}, "
1007
+ f"but got {output.dtype}.")
1008
+
1009
+
789
1010
  def all_reduce(tensor, op=ReduceOp.SUM, group=None, async_op=False):
790
1011
  """
791
1012
  Reduce tensors across all devices in such a way that all deviceswill get the same final result,
@@ -813,7 +1034,7 @@ def all_reduce(tensor, op=ReduceOp.SUM, group=None, async_op=False):
813
1034
  RuntimeError: If device target is invalid, or backend is invalid, or distributed initialization fails.
814
1035
 
815
1036
  Supported Platforms:
816
- ``Ascend``
1037
+ ``Ascend`` ``CPU``
817
1038
 
818
1039
  Examples:
819
1040
  .. note::
@@ -950,6 +1171,91 @@ def all_gather_into_tensor(output_tensor, input_tensor, group=None, async_op=Fal
950
1171
  return handle
951
1172
 
952
1173
 
1174
+ def all_gather_into_tensor_uneven(output, input, output_split_sizes=None, group=None, async_op=False):
1175
+ r"""
1176
+ Gathers and concatenates tensors across devices with uneven first dimensions.
1177
+
1178
+ Note:
1179
+ - Input tensors must have identical shapes except for the first dimension.
1180
+ - Output tensor's first dimension should equal to the sum of all devices' input first dimensions.
1181
+
1182
+ Args:
1183
+ output (Tensor): Concatenated output tensor with shape :math:`(\sum_{i=0}^{N-1} x_{i1}, x_2, ..., x_R)`,
1184
+ where N is the number of devices in the group.
1185
+ input (Tensor): Local input tensor with shape :math:`(x_{k1}, x_2, ..., x_R)`, where k is current device's rank.
1186
+ output_split_sizes (list[int], optional): Specifies first dimension sizes from each device.
1187
+ Must match actual input dimensions when provided.
1188
+ If ``None``, assumes equal split sizes across devices. Default: ``None``.
1189
+ group (str, optional): The communication group to work on. If ``None``,
1190
+ which means ``"hccl_world_group"`` in Ascend. Default: ``None``.
1191
+ async_op (bool, optional): Whether this operator should be an async operator. Default: ``False``.
1192
+
1193
+ Returns:
1194
+ CommHandle, CommHandle is an async work handle, if `async_op` is set to True.
1195
+ CommHandle will be None, when `async_op` is False.
1196
+
1197
+ Raises:
1198
+ ValueError: If the shape of `input` does not match the constraints of `output_split_sizes`.
1199
+ RuntimeError: If device target is invalid, or backend is invalid, or distributed initialization fails.
1200
+
1201
+ Supported Platforms:
1202
+ ``Ascend``
1203
+
1204
+ Examples:
1205
+ .. note::
1206
+ Before running the following examples, you need to configure the communication environment variables.
1207
+
1208
+ For Ascend devices, it is recommended to use the msrun startup method
1209
+ without any third-party or configuration file dependencies.
1210
+ Please see the `msrun start up
1211
+ <https://www.mindspore.cn/tutorials/en/master/parallel/msrun_launcher.html>`_
1212
+ for more details.
1213
+
1214
+ This example should be run with 2 devices.
1215
+
1216
+ >>> import numpy as np
1217
+ >>> import mindspore as ms
1218
+ >>> from mindspore import ops
1219
+ >>> from mindspore.mint.distributed import init_process_group, get_rank
1220
+ >>> from mindspore.mint.distributed import all_gather_into_tensor_uneven
1221
+ >>> from mindspore import Tensor
1222
+ >>>
1223
+ >>> ms.set_device(device_target="Ascend")
1224
+ >>> init_process_group()
1225
+ >>> if get_rank() == 0:
1226
+ >>> input_tensor = Tensor(np.ones([3, 4]).astype(np.float32))
1227
+ >>> else:
1228
+ >>> input_tensor = Tensor(np.ones([2, 4]).astype(np.float32))
1229
+ >>> out_tensor = Tensor(np.zeros([5, 4]).astype(np.float32))
1230
+ >>> output_split_sizes = [3, 2]
1231
+ >>> output = all_gather_into_tensor_uneven(out_tensor, input_tensor, output_split_sizes)
1232
+ >>> print(out_tensor)
1233
+ [[1. 1. 1. 1.]
1234
+ [1. 1. 1. 1.]
1235
+ [1. 1. 1. 1.]
1236
+ [1. 1. 1. 1.]
1237
+ [1. 1. 1. 1.]]
1238
+ """
1239
+ if group is None:
1240
+ group = GlobalComm.WORLD_COMM_GROUP
1241
+ if not isinstance(group, str):
1242
+ raise TypeError(
1243
+ "The argument 'group' must be type of string, "
1244
+ "but got 'group' type : {}.".format(type(group))
1245
+ )
1246
+ if not isinstance(async_op, bool):
1247
+ raise TypeError(
1248
+ f"The argument 'async_op' must be a bool, but got {type(async_op)}."
1249
+ )
1250
+ group_size = get_cache_group_size(group)
1251
+ output_split_sizes = [] if output_split_sizes is None else output_split_sizes
1252
+ result = dist_comm_all_gather_into_tensor_uneven_op(
1253
+ output, input, output_split_sizes, group_size, group
1254
+ )
1255
+ _, handle = _deal_comm_outputs(result, async_op)
1256
+ return handle
1257
+
1258
+
953
1259
  def reduce_scatter_tensor(output, input, op=ReduceOp.SUM, group=None, async_op=False):
954
1260
  r"""
955
1261
  Reduces and scatters tensors from the specified communication group and
@@ -1040,6 +1346,101 @@ def reduce_scatter_tensor(output, input, op=ReduceOp.SUM, group=None, async_op=F
1040
1346
  return handle
1041
1347
 
1042
1348
 
1349
+ def reduce_scatter_tensor_uneven(output, input, input_split_sizes=None, op=ReduceOp.SUM, group=None, async_op=False):
1350
+ r"""
1351
+ Reduce tensors from the specified communication group and scatter to the output tensor
1352
+ according to `input_split_sizes`.
1353
+
1354
+ Note:
1355
+ - The input tensor must have identical shape and format across all processes.
1356
+ - The first dimension of input tensor should equal to the sum of `input_split_sizes`.
1357
+
1358
+ Args:
1359
+ output(Tensor): the output tensor has the same dtype as `input` with a shape of
1360
+ :math:`(input_split_sizes[rank], *)`, where rank is the local rank id of the device.
1361
+ input(Tensor): The input tensor to be reduced and scattered, Expected shape :math:`(N, *)`, where `*`
1362
+ means any number of additional dimensions. N must equal the sum of `input_split_sizes` across ranks.
1363
+ input_split_sizes (list[int], optional): List specifying how to split the first dimension of input tensor.
1364
+ If ``None``, splits evenly according to group size. Default: ``None``.
1365
+ op (str, optional): Specifies an operation used for element-wise reductions,
1366
+ One of ReduceOp: 'SUM', 'MIN', 'MAX'. Default: ``ReduceOp.SUM``.
1367
+ group (str, optional): The communication group to work on. If ``None``, which means ``"hccl_world_group"`` in
1368
+ Ascend. Default: ``None``.
1369
+ async_op (bool, optional): Whether this operator should be an async operator. Default: ``False``.
1370
+
1371
+ Returns:
1372
+ CommHandle, CommHandle is an async work handle, if `async_op` is set to True.
1373
+ CommHandle will be None, when `async_op` is False.
1374
+
1375
+ Raises:
1376
+ ValueError: If the shape of `output` does not match the constraints of `input_split_sizes`.
1377
+ RuntimeError: If device target is invalid, or backend is invalid, or distributed initialization fails.
1378
+
1379
+ Supported Platforms:
1380
+ ``Ascend``
1381
+
1382
+ Examples:
1383
+ .. note::
1384
+ Before running the following examples, you need to configure the communication environment variables.
1385
+
1386
+ For Ascend devices, it is recommended to use the msrun startup method
1387
+ without any third-party or configuration file dependencies.
1388
+ Please see the `msrun start up
1389
+ <https://www.mindspore.cn/tutorials/en/master/parallel/msrun_launcher.html>`_
1390
+ for more details.
1391
+
1392
+ This example should be run with 2 devices.
1393
+
1394
+ >>> import mindspore as ms
1395
+ >>> from mindspore import Tensor
1396
+ >>> from mindspore.mint.distributed import init_process_group, get_rank
1397
+ >>> from mindspore.mint.distributed import reduce_scatter_tensor_uneven
1398
+ >>> import numpy as np
1399
+ >>>
1400
+ >>> ms.set_device(device_target="Ascend")
1401
+ >>> init_process_group()
1402
+ >>> input_tensor = Tensor(np.ones([5, 8]).astype(np.float32))
1403
+ >>> if get_rank() == 0:
1404
+ >>> output_tensor = Tensor(np.ones([2, 8]).astype(np.float32))
1405
+ >>> else:
1406
+ >>> output_tensor = Tensor(np.ones([3, 8]).astype(np.float32))
1407
+ >>> input_split_sizes = [2, 3]
1408
+ >>> output = reduce_scatter_tensor_uneven(output_tensor, input_tensor, input_split_sizes)
1409
+ >>> print(output_tensor)
1410
+ rank 0:
1411
+ [[2. 2. 2. 2. 2. 2. 2. 2.]
1412
+ [2. 2. 2. 2. 2. 2. 2. 2.]]
1413
+ rank 1:
1414
+ [[2. 2. 2. 2. 2. 2. 2. 2.]
1415
+ [2. 2. 2. 2. 2. 2. 2. 2.]
1416
+ [2. 2. 2. 2. 2. 2. 2. 2.]]
1417
+ """
1418
+ if not isinstance(op, str):
1419
+ raise TypeError("For reduce_scatter_tensor_uneven, the input op type must be str")
1420
+ if op not in ("sum", "min", "max"):
1421
+ raise TypeError(
1422
+ "For reduce_scatter_tensor_uneven, the input op value must be one of sum, prod, min, max"
1423
+ )
1424
+ if group is None:
1425
+ group = GlobalComm.WORLD_COMM_GROUP
1426
+ if not isinstance(group, str):
1427
+ raise TypeError(
1428
+ "The argument 'group' must be type of string, "
1429
+ "but got 'group' type : {}.".format(type(group))
1430
+ )
1431
+ if not isinstance(async_op, bool):
1432
+ raise TypeError(
1433
+ f"The argument 'async_op' must be a bool, but got {type(async_op)}."
1434
+ )
1435
+ input_split_sizes = [] if input_split_sizes is None else input_split_sizes
1436
+ rank_size = get_cache_group_size(group)
1437
+ result = dist_comm_reduce_scatter_tensor_uneven_op(
1438
+ output, input, input_split_sizes, rank_size, op, group
1439
+ )
1440
+ _, handle = _deal_comm_outputs(result, async_op)
1441
+ return handle
1442
+
1443
+
1043
1444
  def reduce(tensor, dst, op=ReduceOp.SUM, group=None, async_op=False):
1044
1445
  """
1045
1446
  Reduces tensors across the processes in the specified communication group, sends the result
@@ -1589,7 +1990,7 @@ def barrier(group=None, async_op=False, device_ids=None):
1589
1990
  RuntimeError: If backend is invalid, or distributed initialization fails.
1590
1991
 
1591
1992
  Supported Platforms:
1592
- ``Ascend``
1993
+ ``Ascend`` ``CPU``
1593
1994
 
1594
1995
  Examples:
1595
1996
  .. note::
@@ -1647,7 +2048,7 @@ def send(tensor, dst=0, group=None, tag=0):
1647
2048
  ValueError: If the `dst` process rank id is same as the current process.
1648
2049
 
1649
2050
  Supported Platforms:
1650
- ``Ascend``
2051
+ ``Ascend`` ``CPU``
1651
2052
 
1652
2053
  Examples:
1653
2054
  .. note::
@@ -1725,7 +2126,7 @@ def recv(tensor, src=0, group=None, tag=0):
1725
2126
  ValueError: If the rank ID of the process is greater than the rank size of the communication group.
1726
2127
 
1727
2128
  Supported Platforms:
1728
- ``Ascend``
2129
+ ``Ascend`` ``CPU``
1729
2130
 
1730
2131
  Examples:
1731
2132
  .. note::
@@ -2018,10 +2419,10 @@ def all_to_all(output_tensor_list, input_tensor_list, group=None, async_op=False
2018
2419
  recv_shape_list = []
2019
2420
 
2020
2421
  for tensor in input_tensor_list:
2021
- send_numel_list.append(tensor.size)
2422
+ send_numel_list.append(tensor.numel())
2022
2423
  send_flatten_tensor.append(tensor.reshape(-1))
2023
2424
  for tensor in output_tensor_list:
2024
- recv_numel_list.append(tensor.size)
2425
+ recv_numel_list.append(tensor.numel())
2025
2426
  recv_shape_list.append(tensor.shape)
2026
2427
 
2027
2428
  send_flatten_tensor = cat(send_flatten_tensor)
@@ -2183,10 +2584,7 @@ def all_to_all_single(output,
2183
2584
 
2184
2585
  def _check_tensor_list(tensor_list, tensor, group_size):
2185
2586
  """check all elements in tensor_list are type of Tensor or tuple or list"""
2186
- if not tensor_list or len(tensor_list) != group_size:
2187
- raise TypeError(
2188
- f"The argument list tensor len must be equal to group rank size, but got {len(tensor_list)}."
2189
- )
2587
+ _check_group_tensor_list(tensor_list, group_size)
2190
2588
  if tensor.dtype != tensor_list[0].dtype:
2191
2589
  raise TypeError(
2192
2590
  f"The argument list tensor type must be equal to tensor type, but got {tensor_list[0].dtype}."
@@ -2197,13 +2595,17 @@ def _check_tensor_list(tensor_list, tensor, group_size):
2197
2595
  )
2198
2596
 
2199
2597
 
2598
+ def _check_group_tensor_list(tensor_list, group_size):
2599
+ if not tensor_list or len(tensor_list) != group_size:
2600
+ raise TypeError(
2601
+ f"The argument list tensor len must be equal to group rank size, but got {len(tensor_list)}."
2602
+ )
2603
+
2604
+
2200
2605
  def all_gather(tensor_list, tensor, group=None, async_op=False):
2201
2606
  """
2202
2607
  Gathers tensors from the specified communication group and returns the tensor list which is all gathered.
2203
2608
 
2204
- Note:
2205
- The tensors must have the same shape and format in all processes of the collection.
2206
-
2207
2609
  Args:
2208
2610
  tensor_list (list[Tensor]): Output list.
2209
2611
  tensor (Tensor): The input tensor to be all gathered into tensor.
@@ -2258,7 +2660,7 @@ def all_gather(tensor_list, tensor, group=None, async_op=False):
2258
2660
 
2259
2661
  """
2260
2662
  _check_all_tensors(tensor_list)
2261
- _check_all_tensor_same_dtype_and_shape(tensor_list)
2663
+ _check_all_tensor_same_dtype(tensor_list)
2262
2664
  if not isinstance(tensor, (Tensor, Tensor_)):
2263
2665
  raise TypeError("For all_gather_into_tensor, the input tensor must be tensor")
2264
2666
  if group is None:
@@ -2273,7 +2675,10 @@ def all_gather(tensor_list, tensor, group=None, async_op=False):
2273
2675
  f"The argument 'async_op' must be a bool, but got {type(async_op)}."
2274
2676
  )
2275
2677
  group_size = get_cache_group_size(group)
2276
- _check_tensor_list(tensor_list, tensor, group_size)
2678
+ _check_group_tensor_list(tensor_list, group_size)
2679
+ rank_id = get_group_rank_from_world_rank(get_rank(), group)
2680
+ _check_output_shape(tensor, tensor_list[rank_id].shape, "all_gather")
2681
+ _check_output_dtype(tensor, tensor_list[0].dtype, "all_gather")
2277
2682
  result = dist_comm_all_gather_op(tensor_list, tensor, group_size, group)
2278
2683
  _, handle = _deal_comm_outputs(result, async_op)
2279
2684
  return handle
@@ -2284,9 +2689,6 @@ def reduce_scatter(output, input_list, op=ReduceOp.SUM, group=None, async_op=Fal
2284
2689
  Reduces and scatters tensors from the specified communication group and
2285
2690
  returns the tensor which is reduced and scattered.
2286
2691
 
2287
- Note:
2288
- The tensors must have the same shape and format in all processes of the collection.
2289
-
2290
2692
  Args:
2291
2693
  output (Tensor): the output tensor.
2292
2694
  input_list (list[Tensor]): List of tensors to reduce and scatter.
@@ -2340,7 +2742,7 @@ def reduce_scatter(output, input_list, op=ReduceOp.SUM, group=None, async_op=Fal
2340
2742
  """
2341
2743
 
2342
2744
  _check_all_tensors(input_list)
2343
- _check_all_tensor_same_dtype_and_shape(input_list)
2745
+ _check_all_tensor_same_dtype(input_list)
2344
2746
  if not isinstance(output, (Tensor, Tensor_)):
2345
2747
  raise TypeError("For reduce_scatter, the output tensor must be tensor")
2346
2748
  if group is None:
@@ -2361,7 +2763,11 @@ def reduce_scatter(output, input_list, op=ReduceOp.SUM, group=None, async_op=Fal
2361
2763
  "For reduce_scatter, the input op value must be one of sum, prod, min, max"
2362
2764
  )
2363
2765
  rank_size = get_cache_group_size(group)
2364
- _check_tensor_list(input_list, output, rank_size)
2766
+ _check_group_tensor_list(input_list, rank_size)
2767
+
2768
+ rank_id = get_group_rank_from_world_rank(get_rank(), group)
2769
+ _check_output_shape(output, input_list[rank_id].shape, "reduce_scatter")
2770
+ _check_output_dtype(output, input_list[0].dtype, "reduce_scatter")
2365
2771
  result = dist_comm_reduce_scatter_op(output, input_list, rank_size, op, group)
2366
2772
  _, handle = _deal_comm_outputs(result, async_op)
2367
2773
  return handle
@@ -2810,7 +3216,7 @@ def broadcast_object_list(object_list, src=0, group=None, device=None):
2810
3216
  offset = 0
2811
3217
  for i, item in enumerate(object_size):
2812
3218
  obj_size = item
2813
- obj_view = object_tensor[offset : offset + obj_size]
3219
+ obj_view = object_tensor[offset: offset + obj_size]
2814
3220
  offset += obj_size
2815
3221
  object_list[i] = _tensor_to_object(obj_view, obj_size)
2816
3222
 
@@ -1189,7 +1189,7 @@ class PixelShuffle(Cell):
1189
1189
  >>> pixel_shuffle = mint.nn.PixelShuffle(3)
1190
1190
  >>> input = mint.randn(1, 9, 4, 4)
1191
1191
  >>> output = pixel_shuffle(input)
1192
- >>> print(output.shape())
1192
+ >>> print(output.shape)
1193
1193
  [1, 1, 12, 12]
1194
1194
  """
1195
1195