mindspore.mint.distributed.scatter_object_list
- mindspore.mint.distributed.scatter_object_list(scatter_object_output_list, scatter_object_input_list, src=0, group=None)[source]
Scatters picklable objects in scatter_object_input_list to the whole group.
Note
Similar to
mindspore.mint.distributed.scatter()
, but Python objects can be passed in.Only the objects in process src (global rank) will do scatter.
Only support PyNative mode, Graph mode is not currently supported.
- Parameters
scatter_object_output_list (list[Any]) – Non-empty list whose first element will store the object scattered to this rank.
scatter_object_input_list (list[Any]) – List of python objects to scatter. it must be specified on the source rank.
src (int, optional) – Specifies the rank(global rank) of the process that send the tensor. And only process src will send the tensor. Default:
0
.group (str, optional) – The communication group to work on. If
None
, which means"hccl_world_group"
in Ascend. Default:None
.
- Raises
TypeError – If group is not a str or src is not an integer.
TypeError – If size of scatter_object_input_list is not equal to group size.
RuntimeError – If device target is invalid, or backend is invalid, or distributed initialization fails.
- Supported Platforms:
Ascend
Examples
Note
Before running the following examples, you need to configure the communication environment variables.
For Ascend devices, it is recommended to use the msrun startup method without any third-party or configuration file dependencies. Please see the msrun start up for more details.
This example should be run with 2 devices.
>>> from mindspore.mint.distributed import init_process_group, scatter_object_list >>> init_process_group() >>> obj = ["test", {1: 2}] >>> scatter_object_output_list=[None] >>> scatter_object_list(scatter_object_output_list, obj) >>> print(scatter_object_output_list) # rank_0 ['test'] # rank_1 [{1: 2}]