mindspore.mint.distributed.gather_object
- mindspore.mint.distributed.gather_object(obj, object_gather_list=None, dst=0, group=None)[source]
Gathers python objects from the whole group in a single process.
Note
Similar to
mindspore.mint.distributed.gather()
, but Python objects can be passed in.Only support PyNative mode, Graph mode is not currently supported.
- Parameters
obj (Any) – The python objects to be gathered.
object_gather_list (list[Any], optional) – List of same-sized tensors to use for gathered data. On the
dst
rank, it should be correctly sized as the size of the group for this collective and will contain the output. Default:None
.dst (int, optional) – Specifies the rank(global rank) of the process that receive the tensor. And only process dst will receive the gathered 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 dst is not an integer, or group is not a string.
TypeError – If size of object_gather_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, gather_object, get_rank >>> init_process_group() >>> rank = get_rank() >>> obj = ["test", {1: 2}] >>> object_gather_list=[None, None] >>> gather_object(obj[rank], object_gather_list) >>> print(object_gather_list) # rank_0 ['test', {1: 2}]