mindspore 2.7.0rc1__cp310-cp310-win_amd64.whl → 2.7.1__cp310-cp310-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 (370) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/__init__.py +5 -2
  3. mindspore/_c_dataengine.cp310-win_amd64.pyd +0 -0
  4. mindspore/_c_expression.cp310-win_amd64.pyd +0 -0
  5. mindspore/_c_mindrecord.cp310-win_amd64.pyd +0 -0
  6. mindspore/_checkparam.py +2 -2
  7. mindspore/_extends/builtin_operations.py +3 -3
  8. mindspore/_extends/parallel_compile/akg_compiler/custom.py +1109 -0
  9. mindspore/_extends/parallel_compile/akg_compiler/gen_custom_op_files.py +1 -1
  10. mindspore/_extends/parse/__init__.py +3 -3
  11. mindspore/_extends/parse/compile_config.py +24 -1
  12. mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +6 -3
  13. mindspore/_extends/parse/parser.py +28 -22
  14. mindspore/_extends/parse/resources.py +1 -1
  15. mindspore/_extends/parse/standard_method.py +23 -2
  16. mindspore/_extends/parse/trope.py +2 -1
  17. mindspore/_extends/pijit/pijit_func_white_list.py +9 -27
  18. mindspore/amp.py +0 -18
  19. mindspore/avcodec-59.dll +0 -0
  20. mindspore/avdevice-59.dll +0 -0
  21. mindspore/avfilter-8.dll +0 -0
  22. mindspore/avformat-59.dll +0 -0
  23. mindspore/avutil-57.dll +0 -0
  24. mindspore/boost/base.py +29 -2
  25. mindspore/common/__init__.py +18 -12
  26. mindspore/common/_decorator.py +3 -2
  27. mindspore/common/_grad_function.py +3 -1
  28. mindspore/common/_tensor_cpp_method.py +1 -1
  29. mindspore/common/_tensor_docs.py +371 -96
  30. mindspore/common/_utils.py +7 -43
  31. mindspore/common/api.py +434 -135
  32. mindspore/common/dtype.py +98 -57
  33. mindspore/common/dump.py +7 -108
  34. mindspore/common/dynamic_shape/__init__.py +0 -0
  35. mindspore/common/{auto_dynamic_shape.py → dynamic_shape/auto_dynamic_shape.py} +15 -23
  36. mindspore/common/dynamic_shape/enable_dynamic.py +197 -0
  37. mindspore/common/file_system.py +59 -9
  38. mindspore/common/hook_handle.py +82 -3
  39. mindspore/common/jit_config.py +5 -1
  40. mindspore/common/jit_trace.py +27 -12
  41. mindspore/common/lazy_inline.py +5 -3
  42. mindspore/common/np_dtype.py +3 -3
  43. mindspore/common/parameter.py +17 -127
  44. mindspore/common/recompute.py +4 -13
  45. mindspore/common/tensor.py +50 -217
  46. mindspore/communication/_comm_helper.py +11 -1
  47. mindspore/communication/comm_func.py +138 -4
  48. mindspore/communication/management.py +85 -1
  49. mindspore/config/op_info.config +0 -15
  50. mindspore/context.py +20 -106
  51. mindspore/dataset/__init__.py +1 -1
  52. mindspore/dataset/audio/transforms.py +1 -1
  53. mindspore/dataset/core/config.py +35 -1
  54. mindspore/dataset/engine/datasets.py +338 -319
  55. mindspore/dataset/engine/datasets_user_defined.py +38 -22
  56. mindspore/dataset/engine/datasets_vision.py +1 -1
  57. mindspore/dataset/engine/validators.py +1 -15
  58. mindspore/dataset/transforms/c_transforms.py +2 -2
  59. mindspore/dataset/transforms/transforms.py +3 -3
  60. mindspore/dataset/vision/__init__.py +1 -1
  61. mindspore/dataset/vision/py_transforms.py +8 -8
  62. mindspore/dataset/vision/transforms.py +17 -5
  63. mindspore/dataset/vision/utils.py +632 -21
  64. mindspore/device_context/ascend/op_tuning.py +35 -1
  65. mindspore/dnnl.dll +0 -0
  66. mindspore/{profiler/common/validator → graph}/__init__.py +9 -1
  67. mindspore/graph/custom_pass.py +55 -0
  68. mindspore/include/api/cell.h +28 -4
  69. mindspore/include/api/cfg.h +24 -7
  70. mindspore/include/api/context.h +1 -0
  71. mindspore/include/api/delegate.h +0 -2
  72. mindspore/include/api/dual_abi_helper.h +100 -19
  73. mindspore/include/api/graph.h +14 -1
  74. mindspore/include/api/kernel.h +16 -3
  75. mindspore/include/api/kernel_api.h +9 -1
  76. mindspore/include/api/metrics/accuracy.h +9 -0
  77. mindspore/include/api/model.h +5 -1
  78. mindspore/include/api/model_group.h +4 -0
  79. mindspore/include/api/model_parallel_runner.h +2 -0
  80. mindspore/include/api/status.h +48 -10
  81. mindspore/include/api/types.h +6 -1
  82. mindspore/include/dataset/constants.h +9 -0
  83. mindspore/include/dataset/execute.h +2 -2
  84. mindspore/jpeg62.dll +0 -0
  85. mindspore/mindrecord/__init__.py +3 -3
  86. mindspore/mindrecord/common/exceptions.py +1 -0
  87. mindspore/mindrecord/config.py +1 -1
  88. mindspore/{parallel/mpi → mindrecord/core}/__init__.py +4 -1
  89. mindspore/mindrecord/{shardheader.py → core/shardheader.py} +2 -1
  90. mindspore/mindrecord/{shardindexgenerator.py → core/shardindexgenerator.py} +1 -1
  91. mindspore/mindrecord/{shardreader.py → core/shardreader.py} +2 -1
  92. mindspore/mindrecord/{shardsegment.py → core/shardsegment.py} +2 -2
  93. mindspore/mindrecord/{shardutils.py → core/shardutils.py} +1 -1
  94. mindspore/mindrecord/{shardwriter.py → core/shardwriter.py} +1 -1
  95. mindspore/mindrecord/filereader.py +4 -4
  96. mindspore/mindrecord/filewriter.py +5 -5
  97. mindspore/mindrecord/mindpage.py +2 -2
  98. mindspore/mindrecord/tools/cifar10.py +4 -3
  99. mindspore/mindrecord/tools/cifar100.py +1 -1
  100. mindspore/mindrecord/tools/cifar100_to_mr.py +1 -1
  101. mindspore/mindrecord/tools/cifar10_to_mr.py +6 -6
  102. mindspore/mindrecord/tools/csv_to_mr.py +1 -1
  103. mindspore/mindrecord/tools/imagenet_to_mr.py +1 -1
  104. mindspore/mindrecord/tools/mnist_to_mr.py +1 -1
  105. mindspore/mindrecord/tools/tfrecord_to_mr.py +1 -1
  106. mindspore/mindspore_backend_common.dll +0 -0
  107. mindspore/mindspore_backend_manager.dll +0 -0
  108. mindspore/mindspore_cluster.dll +0 -0
  109. mindspore/mindspore_common.dll +0 -0
  110. mindspore/mindspore_core.dll +0 -0
  111. mindspore/mindspore_cpu.dll +0 -0
  112. mindspore/mindspore_dump.dll +0 -0
  113. mindspore/mindspore_frontend.dll +0 -0
  114. mindspore/mindspore_glog.dll +0 -0
  115. mindspore/mindspore_hardware_abstract.dll +0 -0
  116. mindspore/mindspore_memory_pool.dll +0 -0
  117. mindspore/mindspore_ms_backend.dll +0 -0
  118. mindspore/mindspore_ops.dll +0 -0
  119. mindspore/{mindspore_ops_host.dll → mindspore_ops_cpu.dll} +0 -0
  120. mindspore/mindspore_profiler.dll +0 -0
  121. mindspore/mindspore_pyboost.dll +0 -0
  122. mindspore/mindspore_pynative.dll +0 -0
  123. mindspore/mindspore_runtime_pipeline.dll +0 -0
  124. mindspore/mindspore_runtime_utils.dll +0 -0
  125. mindspore/mindspore_tools.dll +0 -0
  126. mindspore/mint/__init__.py +15 -10
  127. mindspore/mint/distributed/__init__.py +4 -0
  128. mindspore/mint/distributed/distributed.py +392 -69
  129. mindspore/mint/nn/__init__.py +2 -16
  130. mindspore/mint/nn/functional.py +4 -110
  131. mindspore/mint/nn/layer/__init__.py +0 -2
  132. mindspore/mint/nn/layer/_functions.py +1 -2
  133. mindspore/mint/nn/layer/activation.py +0 -6
  134. mindspore/mint/nn/layer/basic.py +0 -47
  135. mindspore/mint/nn/layer/conv.py +10 -10
  136. mindspore/mint/nn/layer/normalization.py +11 -16
  137. mindspore/mint/nn/layer/pooling.py +0 -4
  138. mindspore/nn/__init__.py +1 -3
  139. mindspore/nn/cell.py +231 -239
  140. mindspore/nn/layer/activation.py +4 -2
  141. mindspore/nn/layer/basic.py +56 -14
  142. mindspore/nn/layer/container.py +16 -0
  143. mindspore/nn/layer/embedding.py +4 -169
  144. mindspore/nn/layer/image.py +1 -1
  145. mindspore/nn/layer/normalization.py +2 -1
  146. mindspore/nn/layer/thor_layer.py +4 -85
  147. mindspore/nn/optim/ada_grad.py +0 -1
  148. mindspore/nn/optim/adafactor.py +0 -1
  149. mindspore/nn/optim/adam.py +32 -127
  150. mindspore/nn/optim/adamax.py +0 -1
  151. mindspore/nn/optim/asgd.py +0 -1
  152. mindspore/nn/optim/ftrl.py +8 -102
  153. mindspore/nn/optim/lamb.py +1 -4
  154. mindspore/nn/optim/lars.py +0 -3
  155. mindspore/nn/optim/lazyadam.py +25 -218
  156. mindspore/nn/optim/momentum.py +5 -43
  157. mindspore/nn/optim/optimizer.py +6 -55
  158. mindspore/nn/optim/proximal_ada_grad.py +0 -1
  159. mindspore/nn/optim/rmsprop.py +0 -1
  160. mindspore/nn/optim/rprop.py +0 -1
  161. mindspore/nn/optim/sgd.py +0 -1
  162. mindspore/nn/optim/tft_wrapper.py +2 -4
  163. mindspore/nn/optim/thor.py +0 -2
  164. mindspore/nn/probability/bijector/bijector.py +7 -8
  165. mindspore/nn/probability/bijector/gumbel_cdf.py +2 -2
  166. mindspore/nn/probability/bijector/power_transform.py +20 -21
  167. mindspore/nn/probability/bijector/scalar_affine.py +5 -5
  168. mindspore/nn/probability/bijector/softplus.py +13 -14
  169. mindspore/nn/probability/distribution/_utils/utils.py +2 -2
  170. mindspore/nn/wrap/cell_wrapper.py +39 -5
  171. mindspore/nn/wrap/grad_reducer.py +4 -89
  172. mindspore/numpy/array_creations.py +4 -4
  173. mindspore/numpy/fft.py +9 -9
  174. mindspore/numpy/utils_const.py +1 -1
  175. mindspore/{nn/reinforcement → onnx}/__init__.py +5 -8
  176. mindspore/onnx/onnx_export.py +137 -0
  177. mindspore/opencv_core4110.dll +0 -0
  178. mindspore/opencv_imgcodecs4110.dll +0 -0
  179. mindspore/{opencv_imgproc452.dll → opencv_imgproc4110.dll} +0 -0
  180. mindspore/ops/__init__.py +2 -0
  181. mindspore/ops/_grad_experimental/grad_comm_ops.py +38 -2
  182. mindspore/ops/_grad_experimental/grad_inner_ops.py +0 -9
  183. mindspore/ops/_op_impl/aicpu/__init__.py +0 -10
  184. mindspore/ops/_op_impl/cpu/__init__.py +1 -5
  185. mindspore/ops/_op_impl/cpu/{buffer_append.py → joinedstr_op.py} +8 -8
  186. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +28 -24
  187. mindspore/ops/auto_generate/gen_extend_func.py +6 -11
  188. mindspore/ops/auto_generate/gen_ops_def.py +385 -154
  189. mindspore/ops/auto_generate/gen_ops_prim.py +5676 -5167
  190. mindspore/ops/communication.py +97 -0
  191. mindspore/ops/composite/__init__.py +5 -2
  192. mindspore/ops/composite/base.py +16 -2
  193. mindspore/ops/composite/multitype_ops/__init__.py +3 -1
  194. mindspore/ops/composite/multitype_ops/_compile_utils.py +150 -8
  195. mindspore/ops/composite/multitype_ops/_constexpr_utils.py +1 -1
  196. mindspore/ops/composite/multitype_ops/add_impl.py +7 -0
  197. mindspore/ops/composite/multitype_ops/mod_impl.py +27 -0
  198. mindspore/ops/function/__init__.py +2 -0
  199. mindspore/ops/function/array_func.py +24 -18
  200. mindspore/ops/function/comm_func.py +3883 -0
  201. mindspore/ops/function/debug_func.py +7 -6
  202. mindspore/ops/function/grad/grad_func.py +4 -12
  203. mindspore/ops/function/math_func.py +89 -86
  204. mindspore/ops/function/nn_func.py +92 -313
  205. mindspore/ops/function/random_func.py +9 -18
  206. mindspore/ops/functional.py +4 -1
  207. mindspore/ops/functional_overload.py +377 -30
  208. mindspore/ops/operations/__init__.py +2 -5
  209. mindspore/ops/operations/_custom_ops_utils.py +7 -9
  210. mindspore/ops/operations/_inner_ops.py +12 -50
  211. mindspore/ops/operations/_rl_inner_ops.py +0 -933
  212. mindspore/ops/operations/array_ops.py +5 -50
  213. mindspore/ops/operations/comm_ops.py +95 -17
  214. mindspore/ops/operations/custom_ops.py +237 -22
  215. mindspore/ops/operations/debug_ops.py +33 -35
  216. mindspore/ops/operations/manually_defined/ops_def.py +39 -318
  217. mindspore/ops/operations/math_ops.py +5 -5
  218. mindspore/ops/operations/nn_ops.py +3 -3
  219. mindspore/ops/operations/sparse_ops.py +0 -83
  220. mindspore/ops/primitive.py +4 -27
  221. mindspore/ops/tensor_method.py +88 -10
  222. mindspore/ops_generate/aclnn/aclnn_kernel_register_auto_cc_generator.py +5 -5
  223. mindspore/ops_generate/aclnn/gen_aclnn_implement.py +8 -8
  224. mindspore/ops_generate/api/functions_cc_generator.py +53 -4
  225. mindspore/ops_generate/api/tensor_func_reg_cpp_generator.py +25 -11
  226. mindspore/ops_generate/common/gen_constants.py +11 -10
  227. mindspore/ops_generate/common/op_proto.py +18 -1
  228. mindspore/ops_generate/common/template.py +102 -245
  229. mindspore/ops_generate/common/template_utils.py +212 -0
  230. mindspore/ops_generate/gen_custom_ops.py +69 -0
  231. mindspore/ops_generate/op_def/ops_def_cc_generator.py +78 -7
  232. mindspore/ops_generate/op_def_py/base_op_prim_py_generator.py +360 -0
  233. mindspore/ops_generate/op_def_py/custom_op_prim_py_generator.py +140 -0
  234. mindspore/ops_generate/op_def_py/op_def_py_generator.py +54 -7
  235. mindspore/ops_generate/op_def_py/op_prim_py_generator.py +5 -312
  236. mindspore/ops_generate/pyboost/auto_grad_impl_cc_generator.py +74 -17
  237. mindspore/ops_generate/pyboost/auto_grad_reg_cc_generator.py +22 -5
  238. mindspore/ops_generate/pyboost/gen_pyboost_func.py +0 -16
  239. mindspore/ops_generate/pyboost/op_template_parser.py +3 -2
  240. mindspore/ops_generate/pyboost/pyboost_functions_cpp_generator.py +21 -5
  241. mindspore/ops_generate/pyboost/pyboost_functions_h_generator.py +2 -2
  242. mindspore/ops_generate/pyboost/pyboost_functions_impl_cpp_generator.py +30 -10
  243. mindspore/ops_generate/pyboost/pyboost_grad_function_cpp_generator.py +10 -3
  244. mindspore/ops_generate/pyboost/pyboost_internal_kernel_info_adapter_generator.py +1 -1
  245. mindspore/ops_generate/pyboost/pyboost_native_grad_functions_generator.py +19 -9
  246. mindspore/ops_generate/pyboost/pyboost_op_cpp_code_generator.py +71 -28
  247. mindspore/ops_generate/pyboost/pyboost_overload_functions_cpp_generator.py +10 -9
  248. mindspore/ops_generate/pyboost/pyboost_utils.py +27 -16
  249. mindspore/ops_generate/resources/yaml_loader.py +13 -0
  250. mindspore/ops_generate/tensor_py_cc_generator.py +2 -2
  251. mindspore/parallel/_auto_parallel_context.py +5 -15
  252. mindspore/parallel/_cell_wrapper.py +1 -1
  253. mindspore/parallel/_parallel_serialization.py +4 -6
  254. mindspore/parallel/_ps_context.py +2 -2
  255. mindspore/parallel/_utils.py +34 -17
  256. mindspore/parallel/auto_parallel.py +23 -9
  257. mindspore/parallel/checkpoint_transform.py +20 -2
  258. mindspore/parallel/cluster/process_entity/_api.py +28 -33
  259. mindspore/parallel/cluster/process_entity/_utils.py +9 -5
  260. mindspore/parallel/cluster/run.py +5 -3
  261. mindspore/{experimental/llm_boost/ascend_native → parallel/distributed}/__init__.py +21 -22
  262. mindspore/parallel/distributed/distributed_data_parallel.py +393 -0
  263. mindspore/parallel/distributed/flatten_grad_buffer.py +295 -0
  264. mindspore/parallel/function/reshard_func.py +6 -5
  265. mindspore/parallel/nn/parallel_cell_wrapper.py +40 -3
  266. mindspore/parallel/nn/parallel_grad_reducer.py +0 -8
  267. mindspore/parallel/shard.py +7 -21
  268. mindspore/parallel/strategy.py +336 -0
  269. mindspore/parallel/transform_safetensors.py +127 -20
  270. mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +13 -9
  271. mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +1 -1
  272. mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +1 -1
  273. mindspore/profiler/common/constant.py +5 -0
  274. mindspore/profiler/common/file_manager.py +9 -0
  275. mindspore/profiler/common/msprof_cmd_tool.py +40 -4
  276. mindspore/profiler/common/path_manager.py +65 -24
  277. mindspore/profiler/common/profiler_context.py +27 -14
  278. mindspore/profiler/common/profiler_info.py +3 -3
  279. mindspore/profiler/common/profiler_meta_data.py +1 -0
  280. mindspore/profiler/common/profiler_op_analyse.py +10 -6
  281. mindspore/profiler/common/profiler_path_manager.py +13 -0
  282. mindspore/profiler/common/util.py +30 -3
  283. mindspore/profiler/dynamic_profiler.py +91 -46
  284. mindspore/profiler/envprofiler.py +30 -5
  285. mindspore/profiler/experimental_config.py +18 -2
  286. mindspore/profiler/platform/cpu_profiler.py +10 -4
  287. mindspore/profiler/platform/npu_profiler.py +34 -7
  288. mindspore/profiler/profiler.py +193 -145
  289. mindspore/profiler/profiler_action_controller.py +1 -1
  290. mindspore/profiler/profiler_interface.py +2 -2
  291. mindspore/rewrite/symbol_tree/symbol_tree.py +1 -1
  292. mindspore/run_check/_check_version.py +108 -24
  293. mindspore/runtime/__init__.py +9 -6
  294. mindspore/runtime/executor.py +35 -0
  295. mindspore/runtime/memory.py +113 -0
  296. mindspore/runtime/thread_bind_core.py +1 -1
  297. mindspore/swresample-4.dll +0 -0
  298. mindspore/swscale-6.dll +0 -0
  299. mindspore/tinyxml2.dll +0 -0
  300. mindspore/{experimental/llm_boost → tools}/__init__.py +5 -5
  301. mindspore/tools/data_dump.py +130 -0
  302. mindspore/tools/sdc_detect.py +91 -0
  303. mindspore/tools/stress_detect.py +63 -0
  304. mindspore/train/__init__.py +6 -6
  305. mindspore/train/_utils.py +8 -21
  306. mindspore/train/amp.py +6 -7
  307. mindspore/train/callback/_callback.py +2 -1
  308. mindspore/train/callback/_checkpoint.py +1 -17
  309. mindspore/train/callback/_flops_collector.py +10 -6
  310. mindspore/train/callback/_train_fault_tolerance.py +72 -25
  311. mindspore/train/data_sink.py +5 -9
  312. mindspore/train/dataset_helper.py +5 -5
  313. mindspore/train/model.py +41 -230
  314. mindspore/train/serialization.py +160 -401
  315. mindspore/train/train_thor/model_thor.py +2 -2
  316. mindspore/turbojpeg.dll +0 -0
  317. mindspore/utils/__init__.py +6 -3
  318. mindspore/utils/dlpack.py +92 -0
  319. mindspore/utils/dryrun.py +1 -1
  320. mindspore/utils/runtime_execution_order_check.py +10 -0
  321. mindspore/utils/sdc_detect.py +14 -12
  322. mindspore/utils/stress_detect.py +43 -0
  323. mindspore/utils/utils.py +152 -16
  324. mindspore/version.py +1 -1
  325. {mindspore-2.7.0rc1.dist-info → mindspore-2.7.1.dist-info}/METADATA +3 -2
  326. {mindspore-2.7.0rc1.dist-info → mindspore-2.7.1.dist-info}/RECORD +330 -344
  327. mindspore/_extends/remote/kernel_build_server_ascend.py +0 -75
  328. mindspore/communication/_hccl_management.py +0 -297
  329. mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +0 -207
  330. mindspore/experimental/llm_boost/ascend_native/llm_boost.py +0 -52
  331. mindspore/experimental/llm_boost/atb/__init__.py +0 -23
  332. mindspore/experimental/llm_boost/atb/boost_base.py +0 -385
  333. mindspore/experimental/llm_boost/atb/llama_boost.py +0 -137
  334. mindspore/experimental/llm_boost/atb/qwen_boost.py +0 -124
  335. mindspore/experimental/llm_boost/register.py +0 -130
  336. mindspore/experimental/llm_boost/utils.py +0 -31
  337. mindspore/include/OWNERS +0 -7
  338. mindspore/mindspore_cpu_res_manager.dll +0 -0
  339. mindspore/mindspore_ops_kernel_common.dll +0 -0
  340. mindspore/mindspore_res_manager.dll +0 -0
  341. mindspore/nn/optim/_dist_optimizer_registry.py +0 -111
  342. mindspore/nn/reinforcement/_batch_read_write.py +0 -142
  343. mindspore/nn/reinforcement/_tensors_queue.py +0 -152
  344. mindspore/nn/reinforcement/tensor_array.py +0 -145
  345. mindspore/opencv_core452.dll +0 -0
  346. mindspore/opencv_imgcodecs452.dll +0 -0
  347. mindspore/ops/_op_impl/aicpu/priority_replay_buffer.py +0 -113
  348. mindspore/ops/_op_impl/aicpu/reservoir_replay_buffer.py +0 -96
  349. mindspore/ops/_op_impl/aicpu/sparse_cross.py +0 -42
  350. mindspore/ops/_op_impl/cpu/buffer_get.py +0 -28
  351. mindspore/ops/_op_impl/cpu/buffer_sample.py +0 -28
  352. mindspore/ops/_op_impl/cpu/priority_replay_buffer.py +0 -42
  353. mindspore/ops/operations/_tensor_array.py +0 -359
  354. mindspore/ops/operations/rl_ops.py +0 -288
  355. mindspore/parallel/_offload_context.py +0 -275
  356. mindspore/parallel/_recovery_context.py +0 -115
  357. mindspore/parallel/_transformer/__init__.py +0 -35
  358. mindspore/parallel/_transformer/layers.py +0 -765
  359. mindspore/parallel/_transformer/loss.py +0 -251
  360. mindspore/parallel/_transformer/moe.py +0 -693
  361. mindspore/parallel/_transformer/op_parallel_config.py +0 -222
  362. mindspore/parallel/_transformer/transformer.py +0 -3124
  363. mindspore/parallel/mpi/_mpi_config.py +0 -116
  364. mindspore/profiler/common/validator/validate_path.py +0 -84
  365. mindspore/train/memory_profiling_pb2.py +0 -298
  366. mindspore/utils/hooks.py +0 -81
  367. /mindspore/common/{_auto_dynamic.py → dynamic_shape/_auto_dynamic.py} +0 -0
  368. {mindspore-2.7.0rc1.dist-info → mindspore-2.7.1.dist-info}/WHEEL +0 -0
  369. {mindspore-2.7.0rc1.dist-info → mindspore-2.7.1.dist-info}/entry_points.txt +0 -0
  370. {mindspore-2.7.0rc1.dist-info → mindspore-2.7.1.dist-info}/top_level.txt +0 -0
@@ -44,6 +44,23 @@ class EnvChecker(metaclass=ABCMeta):
44
44
  def check_version(self):
45
45
  pass
46
46
 
47
+ @staticmethod
48
+ def _concat_variable(env_name, env_value):
49
+ """concat value to the beginning of env specified by env_name"""
50
+ if not os.getenv(env_name, ""):
51
+ os.environ[env_name] = env_value
52
+ else:
53
+ paths = os.environ[env_name].split(':')
54
+ if paths and paths[0] == env_value:
55
+ return
56
+ if env_value not in paths:
57
+ os.environ[env_name] = env_value + ':' + os.environ[env_name]
58
+ else:
59
+ # move env_value to beginning
60
+ new_paths = [p for p in paths if p != env_value]
61
+ new_paths.insert(0, env_value)
62
+ os.environ[env_name] = ':'.join(new_paths)
63
+
47
64
 
48
65
  class CPUEnvChecker(EnvChecker):
49
66
  """CPU environment check."""
@@ -61,10 +78,7 @@ class CPUEnvChecker(EnvChecker):
61
78
  """set env for cpu"""
62
79
  plugin_dir = os.path.dirname(self.library_path)
63
80
  akg_dir = os.path.join(plugin_dir, "plugin/cpu")
64
- if os.getenv('LD_LIBRARY_PATH'):
65
- os.environ['LD_LIBRARY_PATH'] = akg_dir + ":" + os.environ['LD_LIBRARY_PATH']
66
- else:
67
- os.environ['LD_LIBRARY_PATH'] = akg_dir
81
+ EnvChecker._concat_variable('LD_LIBRARY_PATH', akg_dir)
68
82
 
69
83
 
70
84
  class GPUEnvChecker(EnvChecker):
@@ -142,10 +156,7 @@ class GPUEnvChecker(EnvChecker):
142
156
  v_str = str(v.major) + "." + str(v.minor)
143
157
  plugin_dir = os.path.dirname(self.library_path)
144
158
  akg_dir = os.path.join(plugin_dir, "gpu" + v_str)
145
- if os.getenv('LD_LIBRARY_PATH'):
146
- os.environ['LD_LIBRARY_PATH'] = akg_dir + ":" + os.environ['LD_LIBRARY_PATH']
147
- else:
148
- os.environ['LD_LIBRARY_PATH'] = akg_dir
159
+ EnvChecker._concat_variable('LD_LIBRARY_PATH', akg_dir)
149
160
  os.environ['CUDA_CACHE_MAXSIZE'] = "4000000000"
150
161
 
151
162
  def _get_bin_path(self, bin_name):
@@ -258,7 +269,7 @@ class AscendEnvChecker(EnvChecker):
258
269
 
259
270
  def __init__(self, library_path):
260
271
  self.library_path = library_path
261
- self.version = ["7.7", "7.8", "8.2"]
272
+ self.version = ["7.8", "8.2", "8.3"]
262
273
 
263
274
  # env
264
275
  self.path = os.getenv("PATH")
@@ -278,13 +289,6 @@ class AscendEnvChecker(EnvChecker):
278
289
  self.ascend_opp_kernel_path_check = "/opp_kernel"
279
290
  self.v = ""
280
291
 
281
- @staticmethod
282
- def _concat_variable(env_name, env_value):
283
- if os.getenv(env_name) is None:
284
- os.environ[env_name] = env_value
285
- else:
286
- os.environ[env_name] = env_value + ":" + os.environ[env_name]
287
-
288
292
  def check_custom_version(self):
289
293
  """custom op version check"""
290
294
 
@@ -359,11 +363,6 @@ class AscendEnvChecker(EnvChecker):
359
363
  """
360
364
  opp kernel install check
361
365
  """
362
- from mindspore._c_expression import MSContext
363
- soc_version = MSContext.get_instance().get_ascend_soc_version()
364
- if soc_version == "ascend310":
365
- return
366
-
367
366
  opp_kernel_path = self.ascend_opp_path.replace("opp", "opp_kernel")
368
367
  if not os.path.exists(opp_kernel_path):
369
368
  logger.critical("MindSpore relies on \"Ascend opp_kernel\" folder of the Ascend AI software package ("
@@ -389,7 +388,7 @@ class AscendEnvChecker(EnvChecker):
389
388
  os.environ['IGNORE_INFER_ERROR'] = "1"
390
389
  plugin_dir = os.path.dirname(self.library_path)
391
390
  akg_dir = os.path.join(plugin_dir, "ascend")
392
- AscendEnvChecker._concat_variable('LD_LIBRARY_PATH', akg_dir)
391
+ EnvChecker._concat_variable('LD_LIBRARY_PATH', akg_dir)
393
392
 
394
393
  self._check_env()
395
394
 
@@ -493,6 +492,85 @@ def _set_pb_env():
493
492
  os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
494
493
 
495
494
 
495
+ def _check_dir_path_safety(dir_path):
496
+ """Check safety of env directory path."""
497
+ if not os.path.exists(dir_path):
498
+ logger.warning(f"Path {dir_path} not exists.")
499
+ return False
500
+
501
+ if not os.path.isdir(dir_path):
502
+ logger.warning(f"Path {dir_path} is not a directory.")
503
+ return False
504
+
505
+ # check if path is suspicious
506
+ suspicious_patterns = [
507
+ "/tmp/", "/var/tmp/", "/dev/", "/proc/",
508
+ "\\temp\\", "\\windows\\temp\\",
509
+ "appdata", "local\\temp"
510
+ ]
511
+ lower_path = dir_path.lower()
512
+ for pattern in suspicious_patterns:
513
+ if pattern in lower_path:
514
+ logger.warning(f"Path {dir_path} is suspicious.")
515
+ return False
516
+
517
+ # check whether the path points to a system-critical directory
518
+ critical_dirs = [
519
+ "/bin", "/sbin", "/usr/bin", "/usr/sbin",
520
+ "/windows", "/system32", "c:\\windows"
521
+ ]
522
+ for critical_dir in critical_dirs:
523
+ if critical_dir in lower_path:
524
+ logger.warning(f"Path {dir_path} points to a system-critical directory.")
525
+ return False
526
+
527
+ return True
528
+
529
+
530
+ def check_cuda_path_safety(cuda_path):
531
+ """Check safety of cuda path."""
532
+ if not _check_dir_path_safety(cuda_path):
533
+ return False
534
+
535
+ expected_files = ["nvcc", "cudart.dll", "cudart.so"]
536
+ has_expected_content = False
537
+ for expected_file in expected_files:
538
+ if os.path.exists(os.path.join(cuda_path, "bin", expected_file)):
539
+ has_expected_content = True
540
+ break
541
+
542
+ if not has_expected_content:
543
+ logger.warning(f"The directory {cuda_path} does not contain the typical file structure of CUDA")
544
+ return False
545
+
546
+ return True
547
+
548
+
549
+ def check_cudnn_path_safety(cudnn_path):
550
+ """Check safety of cudnn path."""
551
+ if not _check_dir_path_safety(cudnn_path):
552
+ return False
553
+
554
+ expected_files = [
555
+ "include/cudnn.h",
556
+ "lib64/libcudnn.so", # Linux
557
+ "lib/libcudnn.dylib", # macOS
558
+ "lib/x64/cudnn.lib", # Windows
559
+ "bin/cudnn64_7.dll" # Windows
560
+ ]
561
+ found_files = []
562
+ for expected_file in expected_files:
563
+ full_path = os.path.join(cudnn_path, expected_file)
564
+ if os.path.exists(full_path):
565
+ found_files.append(expected_file)
566
+
567
+ if not found_files:
568
+ logger.warning(f"The directory {cudnn_path} does not contain the typical file structure of CUDNN")
569
+ return False
570
+
571
+ return True
572
+
573
+
496
574
  def _add_cuda_path():
497
575
  """add cuda path on windows."""
498
576
  if platform.system().lower() == 'windows':
@@ -500,15 +578,21 @@ def _add_cuda_path():
500
578
  if cuda_home is None:
501
579
  pass
502
580
  else:
581
+ if not check_cuda_path_safety(cuda_home):
582
+ logger.error(f"CUDA_PATH {cuda_home} is not safe, skip add cuda path.")
583
+ return
503
584
  cuda_bin_path = os.path.join(os.environ['CUDA_PATH'], 'bin')
504
585
  if sys.version_info >= (3, 8):
505
586
  os.add_dll_directory(cuda_bin_path)
506
587
  else:
507
588
  os.environ['PATH'] += os.pathsep + cuda_bin_path
508
- cudann_home = os.environ.get('CUDNN_HOME')
509
- if cudann_home is None:
589
+ cudnn_home = os.environ.get('CUDNN_HOME')
590
+ if cudnn_home is None:
510
591
  pass
511
592
  else:
593
+ if not check_cudnn_path_safety(cudnn_home):
594
+ logger.error(f"CUDNN_HOME {cuda_home} is not safe, skip add cudnn home.")
595
+ return
512
596
  cuda_home_bin_path = os.path.join(os.environ['CUDNN_HOME'], 'bin')
513
597
  if sys.version_info >= (3, 8):
514
598
  os.add_dll_directory(cuda_home_bin_path)
@@ -17,21 +17,24 @@
17
17
  The runtime interface.
18
18
  """
19
19
 
20
- from mindspore.runtime.executor import launch_blocking, dispatch_threads_num, set_cpu_affinity, set_kernel_launch_group
21
- from mindspore.runtime.memory import set_memory, memory_stats, memory_reserved, max_memory_reserved, empty_cache, \
22
- memory_replay, reset_peak_memory_stats, memory_summary, memory_allocated, \
23
- max_memory_allocated, reset_max_memory_reserved, reset_max_memory_allocated
20
+ from mindspore.runtime.executor import launch_blocking, dispatch_threads_num, set_cpu_affinity,\
21
+ set_kernel_launch_group, set_kernel_launch_capture
22
+ from mindspore.runtime.memory import set_memory, memory_stats, memory_reserved, max_memory_reserved, empty_cache,\
23
+ memory_replay, reset_peak_memory_stats, memory_summary, memory_allocated,\
24
+ max_memory_allocated, reset_max_memory_reserved, reset_max_memory_allocated,\
25
+ PluggableAllocator, MemPool, use_mem_pool
24
26
  from mindspore.runtime.stream import Stream, synchronize, set_cur_stream, current_stream, \
25
27
  default_stream, communication_stream, StreamCtx
26
28
  from mindspore.runtime.event import Event
27
29
  from .executor import launch_blocking
28
30
 
29
31
  __all__ = [
30
- "launch_blocking", "dispatch_threads_num", "set_cpu_affinity", "set_kernel_launch_group",
32
+ "launch_blocking", "dispatch_threads_num", "set_cpu_affinity",
33
+ "set_kernel_launch_group", "set_kernel_launch_capture",
31
34
  "Stream", "communication_stream", "synchronize", "set_cur_stream", "current_stream", "default_stream", "StreamCtx",
32
35
  "set_memory", "memory_stats", "memory_reserved", "max_memory_reserved", "empty_cache", "memory_replay",
33
36
  "reset_peak_memory_stats", "memory_summary", "memory_allocated", "max_memory_allocated",
34
- "reset_max_memory_reserved", "reset_max_memory_allocated", "Event"
37
+ "reset_max_memory_reserved", "reset_max_memory_allocated", "Event", "PluggableAllocator", "MemPool", "use_mem_pool"
35
38
  ]
36
39
 
37
40
  __all__.sort()
@@ -179,6 +179,9 @@ def set_kernel_launch_group(thread_num=2, kernel_group_num=8):
179
179
  if RuntimeConf.get_instance().is_kernel_launch_group_configured():
180
180
  raise RuntimeError("The 'kernel_launch_group' can not be set repeatedly.")
181
181
 
182
+ if RuntimeConf.get_instance().get_enable_kernel_launch_capture():
183
+ raise RuntimeError("The kernel launch group and kernel launch capture can not be set together")
184
+
182
185
  if thread_num < 1:
183
186
  raise ValueError(f"The value of thread_num should be at least 1, but got {thread_num}")
184
187
 
@@ -190,3 +193,35 @@ def set_kernel_launch_group(thread_num=2, kernel_group_num=8):
190
193
  f"be evenly divisible by thread_num: {thread_num}")
191
194
 
192
195
  return RuntimeConf.get_instance().set_kernel_launch_group(thread_num, kernel_group_num)
196
+
197
+
198
+ @args_type_check(enable_capture_graph=bool)
199
+ def set_kernel_launch_capture(enable_capture_graph, op_capture_skip=None):
200
+ """
201
+ In O0/O1 mode, the incremental inference scenario supports graph capture.
202
+ By capturing the CPU-side operator dispatch behavior into a graph,
203
+ the performance of CPU-side operator dispatch is improved.
204
+
205
+ .. warning::
206
+ This is an experimental API that is subject to change or deletion.
207
+
208
+ Args:
209
+ enable_capture_graph (bool): Whether to enable graph capture.
210
+ It can be turned on or off at any position in the script.
211
+ op_capture_skip (list): Custom non-captured operator names. Default: ``None``.
212
+
213
+ Examples:
214
+ >>> import mindspore as ms
215
+ >>> op_capture_skip = ['matmul', 'addn']
216
+ >>> ms.runtime.set_kernel_launch_capture(True, op_capture_skip)
217
+ """
218
+ if RuntimeConf.get_instance().is_kernel_launch_group_configured():
219
+ raise RuntimeError("The kernel launch group and kernel launch capture can not be set together")
220
+
221
+ if op_capture_skip is None:
222
+ op_capture_skip = []
223
+
224
+ if not isinstance(op_capture_skip, list):
225
+ raise TypeError("op_capture_skip must be a list")
226
+
227
+ return RuntimeConf.get_instance().set_kernel_launch_capture(enable_capture_graph, op_capture_skip)
@@ -14,9 +14,15 @@
14
14
  # ============================================================================
15
15
 
16
16
  """Memory interfaces."""
17
+ import contextlib
18
+ import ctypes
17
19
  import os
18
20
  from mindspore._c_expression import RuntimeConf, DeviceManagerConf, _memory_stats, \
19
21
  _reset_max_mem_reserved, _reset_max_mem_allocated, DeviceContextManager, _empty_cache, _memory_replay
22
+ try:
23
+ from mindspore._c_expression import _enable_pluggable_allocator, _disable_pluggable_allocator
24
+ except ImportError:
25
+ pass
20
26
  from mindspore import _checkparam as Validator
21
27
  from mindspore._checkparam import args_type_check
22
28
  from mindspore import log as logger
@@ -50,6 +56,7 @@ def set_memory(init_size="2GB", increase_size="2GB", max_size="1024GB", optimize
50
56
  The format is "xxGB". Default is the maximum available memory of the device, expressed as ``1024GB``.
51
57
  optimize_level (str): The memory optimize level. The value must be in ['O0', 'O1']. Default: ``O0`` .
52
58
  huge_page_reserve_size (str): The reserved size of huge page memory. The format is "xxGB". Default: ``0GB``.
59
+ When virtual memory is enabled, reserve huge page function is not available and this parameter is ignored.
53
60
 
54
61
  Supported Platforms:
55
62
  ``Ascend`` ``GPU`` ``CPU``
@@ -405,3 +412,109 @@ def memory_replay(file_path):
405
412
  >>> ms.runtime.memory_replay("/data/memory_block.csv")
406
413
  """
407
414
  _memory_replay(os.path.realpath(file_path))
415
+
416
+
417
+ class PluggableAllocator():
418
+ r"""
419
+ Receive a .so file via ctypes, and dynamically load the alloc and free functions within it.
420
+ It needs to be used in conjunction with :class:`mindspore.runtime.MemPool` and
421
+ :func:`mindspore.runtime.use_mem_pool` to take over the memory allocation and free
422
+ in the MindSpore memory pool.
423
+
424
+ .. warning::
425
+ This is currently supported only in unix OSs.
426
+
427
+ Args:
428
+ path_to_so_file(str): Path in the file system to the `.so` file containing
429
+ the allocator functions.
430
+ alloc_fn_name(str): Name of the function to perform the memory allocation
431
+ in the so file. The signature must be:
432
+ `void* alloc_fn(size_t size, int device, aclrtStream stream);` .
433
+ free_fn_name(str): Name of the function to perform the memory release
434
+ in the so file. The signature must be:
435
+ `void free_fn(void* ptr, size_t size, aclrtStream stream);` .
436
+
437
+ Supported Platforms:
438
+ ``Ascend``
439
+ """
440
+
441
+ def __init__(self, path_to_so_file: str, alloc_fn_name: str, free_fn_name: str):
442
+ allocator = ctypes.CDLL(path_to_so_file)
443
+ alloc_fn = ctypes.cast(getattr(allocator, alloc_fn_name), ctypes.c_void_p).value
444
+ free_fn = ctypes.cast(getattr(allocator, free_fn_name), ctypes.c_void_p).value
445
+ if alloc_fn is None:
446
+ raise ValueError(f"Cannot find allocator function {alloc_fn_name} in {path_to_so_file}")
447
+ if free_fn is None:
448
+ raise ValueError(f"Cannot find free function {free_fn_name} in {path_to_so_file}")
449
+ self._alloc_fn = alloc_fn
450
+ self._free_fn = free_fn
451
+
452
+ @property
453
+ def alloc_fn_ptr(self) -> int:
454
+ """Function pointer of the allocator function."""
455
+ return self._alloc_fn
456
+
457
+ @property
458
+ def free_fn_ptr(self) -> int:
459
+ """Function pointer of the free function."""
460
+ return self._free_fn
461
+
462
+
463
+ class MemPool():
464
+ r"""
465
+ A MemPool warp a :class:`mindspore.runtime.PluggableAllocator`,
466
+ and pass it to :func:`mindspore.runtime.use_mem_pool`.
467
+
468
+ Args:
469
+ allocator(mindspore.runtime.PluggableAllocator): a mindspore.runtime.PluggableAllocator
470
+ that can be used to define how memory gets allocated and freed in the pool.
471
+
472
+ Supported Platforms:
473
+ ``Ascend``
474
+ """
475
+
476
+ def __init__(self, allocator: PluggableAllocator):
477
+ self._allocator = allocator
478
+
479
+ @property
480
+ def allocator(self) -> PluggableAllocator:
481
+ """The allocator used by the pool."""
482
+ return self._allocator
483
+
484
+
485
+ @contextlib.contextmanager
486
+ def use_mem_pool(pool: MemPool):
487
+ r"""
488
+ A context manager that routes allocations and deallocations to a given pool.
489
+
490
+ Note:
491
+ - This context manager makes only current thread's allocations route to the given pool.
492
+ - If a new thread is spawned inside the context manager the allocations in that thread
493
+ will not route to the given pool.
494
+ - Only by allocating Device memory inside the context manager, the allocation operation
495
+ can be routed to the given pool.
496
+ - Only Atlas A2 training series products support this interface.
497
+
498
+ Args:
499
+ pool(mindspore.runtime.MemPool): a MemPool object that warp a PluggableAllocator.
500
+
501
+ Supported Platforms:
502
+ ``Ascend``
503
+
504
+ Examples:
505
+ >>> import mindspore as ms
506
+ >>> path = "/path/to/allocator.so"
507
+ >>> allocator = ms.runtime.PluggableAllocator(path, "Alloc", "Free")
508
+ >>> mem_pool = ms.runtime.MemPool(allocator)
509
+ >>> shape = (1024, 1024)
510
+ >>> x = ms.ops.Ones()(shape, ms.float32)
511
+ >>> with ms.runtime.use_mem_pool(mem_pool):
512
+ >>> y = ms.ops.Ones()(shape, ms.float32)
513
+ >>> output = x + y
514
+ """
515
+ allocator = pool.allocator
516
+ _enable_pluggable_allocator(allocator.alloc_fn_ptr, allocator.free_fn_ptr)
517
+ try:
518
+ yield
519
+ finally:
520
+ _disable_pluggable_allocator()
@@ -38,7 +38,7 @@ def execute_command(cmd_list):
38
38
  out, _ = p.communicate(timeout=1000)
39
39
  res = out.decode()
40
40
  return res
41
- except FileNotFoundError as e:
41
+ except OSError as e:
42
42
  raise RuntimeError("Failed to execute command") from e
43
43
 
44
44
 
Binary file
mindspore/swscale-6.dll CHANGED
Binary file
mindspore/tinyxml2.dll CHANGED
Binary file
@@ -12,11 +12,11 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
  # ============================================================================
15
- """LlmBoost Register"""
15
+ """Tools module."""
16
16
  from __future__ import absolute_import
17
17
 
18
- from mindspore.experimental.llm_boost.atb import LlamaBoost, QwenBoost
19
- from mindspore.experimental.llm_boost.ascend_native import *
20
- from mindspore.experimental.llm_boost.register import LlmBoostRegister
18
+ __all__ = ["stress_detect", "sdc_detect_start", "sdc_detect_stop", "get_sdc_detect_result", "set_dump"]
21
19
 
22
- __all__ = ["LlmBoostRegister"]
20
+ from .stress_detect import stress_detect
21
+ from .sdc_detect import sdc_detect_start, sdc_detect_stop, get_sdc_detect_result
22
+ from .data_dump import set_dump
@@ -0,0 +1,130 @@
1
+ # Copyright 2021-2025 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
+ """Controlling dump behavior."""
16
+ from __future__ import absolute_import
17
+ from warnings import warn
18
+
19
+ import mindspore.context as context
20
+ from mindspore._c_expression import security
21
+
22
+
23
+ def set_dump(target, enabled=True):
24
+ """
25
+ Enable or disable dump for the `target` and its contents.
26
+
27
+ `target` should be an instance of :class:`mindspore.nn.Cell` or :class:`mindspore.ops.Primitive` .
28
+ Please note that this API takes effect only when the Dump function is enabled, and the `dump_mode`
29
+ field in the Dump configuration file is set to `"2"` with the `ms_backend` compilation backend
30
+ (please refer to the backend parameter in
31
+ `jit <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.jit.html>`_).
32
+ See the `dump document <https://www.mindspore.cn/tutorials/en/master/debug/dump.html>`_ for details.
33
+ By default, instances of :class:`mindspore.nn.Cell` and :class:`mindspore.ops.Primitive` do not enable
34
+ the Dump data feature.
35
+
36
+ Note:
37
+ 1. This API is only available for JIT compilation, requires 'Ascend' as the device_target and
38
+ `ms_backend` as the compilation backend (please refer to the backend parameter in
39
+ `jit <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.jit.html>`_),
40
+ and does not support fused operators.
41
+ 2. This API only supports being called before training starts.
42
+ If you call this API during training, it may not be effective.
43
+ 3. After using `set_dump(Cell, True)` , operators in forward and backward
44
+ computation (computation generated by the grad operations) of the
45
+ cell will be dumped.
46
+ 4. For :class:`mindspore.nn.SoftmaxCrossEntropyWithLogits` layer, the forward
47
+ computation and backward computation use the same set of
48
+ operators. So you can only see dump data from backward computation.
49
+ Please note that :class:`mindspore.nn.SoftmaxCrossEntropyWithLogits` layer will also use
50
+ the above operators internally when initialized with `sparse=True` and
51
+ `reduction="mean"` .
52
+
53
+ Args:
54
+ target (Union[Cell, Primitive]): The Cell instance or Primitive instance
55
+ to which the dump flag is set.
56
+ enabled (bool, optional): ``True`` indicates that the dump is enabled, and ``False`` indicates that
57
+ the dump is disabled.
58
+ Default: ``True`` .
59
+
60
+ Supported Platforms:
61
+ ``Ascend``
62
+
63
+ Examples:
64
+ .. note::
65
+ Please set environment variable `MINDSPORE_DUMP_CONFIG` to the dump config file and set `dump_mode` field
66
+ in dump config file to 2 before running this example.
67
+ See `dump document <https://www.mindspore.cn/tutorials/en/master/debug/dump.html>`_ for details.
68
+
69
+ >>> import numpy as np
70
+ >>> import mindspore as ms
71
+ >>> import mindspore.nn as nn
72
+ >>> from mindspore import Tensor, jit
73
+ >>> from mindspore.tools import set_dump
74
+ >>>
75
+ >>> ms.set_device(device_target="Ascend")
76
+ >>>
77
+ >>> class MyNet(nn.Cell):
78
+ ... def __init__(self):
79
+ ... super().__init__()
80
+ ... self.conv1 = nn.Conv2d(5, 6, 5, pad_mode='valid')
81
+ ... self.relu1 = nn.ReLU()
82
+ ...
83
+ ... @jit
84
+ ... def construct(self, x):
85
+ ... x = self.conv1(x)
86
+ ... x = self.relu1(x)
87
+ ... return x
88
+ >>>
89
+ >>> if __name__ == "__main__":
90
+ ... net = MyNet()
91
+ ... set_dump(net.conv1)
92
+ ... input_tensor = Tensor(np.ones([1, 5, 10, 10], dtype=np.float32))
93
+ ... output = net(input_tensor)
94
+ """
95
+ if security.enable_security():
96
+ raise ValueError('The set_dump API is not supported, please recompile '
97
+ 'source without "-s on".')
98
+
99
+ import mindspore.nn as nn # avoid circular import
100
+ from mindspore.ops import Primitive
101
+ if not isinstance(target, nn.Cell) and not isinstance(target, Primitive):
102
+ raise ValueError(f"The \"target\" parameter must be an instance of "
103
+ f"Cell or Primitive, "
104
+ f"but got an instance of {type(target)}.")
105
+
106
+ if not isinstance(enabled, bool):
107
+ raise ValueError("The \"enabled\" parameter must be bool.")
108
+
109
+ # Checking for device target and mode.
110
+ current_target = context.get_context("device_target")
111
+ if current_target != "Ascend":
112
+ # We will not return here in case user changed device_target later.
113
+ warn("Current device_target is {}, which is not supported by set_dump. "
114
+ "Only Ascend device target is supported currently. "
115
+ "If you have Ascend device, consider set device_target to Ascend "
116
+ "before calling set_dump.".format(current_target))
117
+
118
+ # The actual set dump logic.
119
+ if isinstance(target, nn.Cell):
120
+ target.add_flags(dump=enabled)
121
+ for cell in target.cells():
122
+ set_dump(cell, enabled)
123
+
124
+ primitives = getattr(target, "_primitives", {})
125
+ for value in primitives.values():
126
+ if value and "dump" in value.attrs:
127
+ set_dump(value, enabled)
128
+
129
+ if isinstance(target, Primitive):
130
+ target.add_prim_attr("dump", "true" if enabled else "false")
@@ -0,0 +1,91 @@
1
+ # Copyright 2025 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
+ """SDC detect."""
16
+ from mindspore import _c_expression
17
+
18
+
19
+ def sdc_detect_start():
20
+ """
21
+ Start silent data corruption detection. It will check the inputs and outputs of MatMul operations during the
22
+ forward and backward computations on the current device, which may increase execution time. The overhead of the
23
+ check time decreases as the matrix shapes increase. Starting sdc detection results in approximately 100%
24
+ performance degradation for a single 4096-sized MatMul computation, and approximately 90% degradation on the
25
+ Llama2-7B model (model parallel is 4, pipeline parallel is 2, and using qkv concatenation and ffn concatenation in
26
+ decoder layers).
27
+
28
+ Supported Platforms:
29
+ ``Ascend``
30
+
31
+ Examples:
32
+ >>> from mindspore.tools import sdc_detect_start
33
+ >>> sdc_detect_start()
34
+ """
35
+ _c_expression.sdc_detect_start()
36
+
37
+
38
+ def sdc_detect_stop():
39
+ """
40
+ Stop silent data corruption detection.
41
+
42
+ Supported Platforms:
43
+ ``Ascend``
44
+
45
+ Examples:
46
+ >>> from mindspore.tools import sdc_detect_stop
47
+ >>> sdc_detect_stop()
48
+ """
49
+ _c_expression.sdc_detect_stop()
50
+
51
+
52
+ def get_sdc_detect_result():
53
+ """
54
+ Get the result of silent data corruption detection.
55
+
56
+ Returns:
57
+ bool, indicating whether silent data corruption has occurred after detection start.
58
+
59
+ Supported Platforms:
60
+ ``Ascend``
61
+
62
+ Examples:
63
+ >>> from mindspore.tools import get_sdc_detect_result
64
+ >>> result = get_sdc_detect_result()
65
+ >>> print(result)
66
+ False
67
+ """
68
+ return _c_expression.get_sdc_detect_result()
69
+
70
+
71
+ class _SdcDetector:
72
+ """
73
+ Manager of feature value sampling for SDC detect
74
+ """
75
+ def __init__(self):
76
+ self.param_count = -1
77
+
78
+ def need_sample(self):
79
+ """"If need to sample feature value."""
80
+ if not _c_expression.is_silent_detect_enable():
81
+ return False
82
+ grad_sample_interval = _c_expression.get_silent_detect_config('grad_sample_interval')
83
+ self.param_count = (self.param_count + 1) % grad_sample_interval
84
+ return self.param_count == 0
85
+
86
+ @staticmethod
87
+ def get_dump_name(param_name):
88
+ """Get dump file name with sdc prefix."""
89
+ return _c_expression.get_silent_detect_feature_name(param_name)
90
+
91
+ _sdc_detector = _SdcDetector()