mindspore.mint.distributed.broadcast_object_list

mindspore.mint.distributed.broadcast_object_list(object_list, src=0, group=None, device=None)[source]

Broadcasts the entire group of input Python objects.

Note

Parameters
  • object_list (list[Any]) – list of input to be sent if src is the rank of current process, and list to be used to save received data otherwise.

  • src (int, optional) – Specifies the rank(global rank) of the process that broadcast the Python objects. And only process src will broadcast the Python objects. Default: 0 .

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

  • device (str, optional) – Currently it is a reserved parameter. Default: None.

Raises
  • TypeError – If src is not an integer or group is not a string.

  • 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, broadcast_object_list, get_rank
>>> init_process_group()
>>> rank = get_rank()
>>> obj = ["test", 12, {1: 2}]
>>> if rank == 1:
>>>     obj = [None, None, None]
>>> broadcast_object_list(obj)
>>> print(obj)
['test', 12, {1: 2}]