mindspore.mint.distributed.recv_object_list

View Source On AtomGit
mindspore.mint.distributed.recv_object_list(object_list, src=0, group=None, device=None)[source]

Receive picklable objects from src synchronously.

Note

Warning

This interface will implicitly use the pickle module, which is not secure. The core reason is that deserialization can execute arbitrary code, and attackers can trigger system command execution by constructing malicious objects. Therefore, the caller must ensure the security of the data used by the interface on their own.

Parameters
  • object_list (list[Any]) – List of objects to receive into. Must provide a list of sizes equal to the size of the list being sent.

  • src (int, optional) – A required integer identifying the source global rank. Default: 0.

  • group (str, optional) – The process group to work on. If None, the Ascend platform is "hccl_world_group". Default: None.

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

Returns

int. If successful, it will return 0.

Raises
  • TypeError – If src is not of type int, group is not of type str, or object_ist is not of type list.

  • ValueError – If the src process rank id is same as the current process.

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 startup for more details.

This example should be run with 2 devices.

>>> from mindspore.mint.distributed import init_process_group, send_object_list, recv_object_list, get_rank
>>> init_process_group()
>>> this_rank = get_rank()
>>> if this_rank == 0:
...     objects = ["foo", 12, {1: 2}]  # any picklable object
...     send_object_list(objects, dst=1)
>>> else:
...     objects = [None, None, None]
...     recv_object_list(objects, src=0)
...     print(objects)
['foo', 12, {1: 2}]