TensorDictBase.recv#
- TensorDictBase.recv(src: int | 'TensorDictPipe' | None = None, *, group: 'torch.distributed.ProcessGroup' | None = None, group_src: int | None = None, init_tag: int = 0, pseudo_rand: bool = False, consolidated: bool = False) int#
Receives the content of a tensordict and updates content with it.
Check the example in the send method for context.
- Parameters:
src (int or TensorDictPipe, optional) – the global rank of the source worker, or a
TensorDictPipefor UCXX-based transport. When a pipe is passed, the data is received in-place into this tensordict’s consolidated storage (if available and its layout matches the received data); otherwise the pipe returns a tensordict of its own, so use the returned value. Mutually exclusive withgroup_src; exactly one of the two must be provided.- Keyword Arguments:
group (torch.distributed.ProcessGroup, optional) – if set, the specified process group will be used for communication. Otherwise, the default process group will be used. Defaults to
None.group_src (int, optional) – the rank of the source worker relative to
group. Requiresgroupto be passed and is mutually exclusive withsrc. When set, the p2p calls are issued directly on the group’s backend, sogroupmay be a standaloneProcessGroupbuilt against a store (never registered throughinit_process_group()ornew_group()). Defaults toNone.init_tag (int) – the
init_tagused by the source worker.pseudo_rand (bool) – if True, the sequence of tags will be pseudo- random, allowing to send multiple data from different nodes without overlap. Notice that the generation of these pseudo-random numbers is expensive (1e-5 sec/number), meaning that it could slow down the runtime of your algorithm. This value must match the one passed to
send(). Defaults toFalse.consolidated (bool) – if True, receives a single consolidated storage tensor directly into
self._consolidated["storage"]. The tensordict must already be consolidated (e.g. from a priorfrom_remote_init()call). All leaf tensor views update in-place automatically. Defaults toFalse.
Every tensordict class and every tensorclass has this method. For the other methods, see Methods by task.