mindspore.mint.distributed.all_gather_object

View Source On Gitee
mindspore.mint.distributed.all_gather_object(object_list, obj, group=None)[source]

Aggregates Python objects in a specified communication group.

Note

Similar to mindspore.mint.distributed.all_gather(), but Python objects can be passed in.

Parameters
  • object_list (list[Any]) – Output Python object list.

  • obj (Any) – Python object to be broadcast from current process.

  • group (str, optional) – The communication group to work on. If None, which means "hccl_world_group" in Ascend. Default: None.

Raises
  • TypeErrorgroup is not a str.

  • TypeError – If size of object_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, get_rank
>>> from mindspore.mint.distributed import all_gather_object
>>> init_process_group()
>>> rank = get_rank()
>>> obj = ["test", {1: 2}]
>>> object_gather_list=[None, None]
>>> all_gather_object(object_gather_list, obj[rank])
>>> print(object_gather_list)
# rank_0
['test', {1: 2}]
# rank_1
['test', {1: 2}]