recv_object_list

paddle.distributed. recv_object_list ( object_list: list[Any], src: int | None = None, group: Group | None = None, src_in_group: int | None = None ) [source]

Receive a list of Python objects from the sender.

Parameters
  • object_list (list) – The list to store received objects. Must be pre-allocated with correct size.

  • src (int, optional) – The source rank id. Default: 0.

  • group (Group, optional) – The group instance return by new_group or None for global default group. Default: None.

  • src_in_group (int, optional) – The source rank within the group. Cannot be specified together with src. Default: None.

Returns

This function does not return any value.

Examples

>>> 
>>> import paddle
>>> import paddle.distributed as dist

>>> dist.init_parallel_env()
>>> if dist.get_rank() == 0:
...     data = ["hello", {"key": 100}, [1, 2, 3]]
...     dist.send_object_list(data, dst=1)
>>> else:
...     data = [None] * 3  # type: ignore
...     dist.recv_object_list(data, src=0)
>>> print(data)
>>> # ["hello", {"key": 100}, [1, 2, 3]] (2 GPUs)