TensorDictBase.broadcast#
- TensorDictBase.broadcast(src: int, *, group: 'torch.distributed.ProcessGroup' | None = None, device: device | str | None = None, _tensorclass_type: str | None = None) Self#
Broadcasts a tensordict from
srcto all ranks.Uses consolidated transport: the source rank consolidates the tensordict and broadcasts metadata (via
broadcast_object_list) followed by the contiguous storage tensor (viadist.broadcast). Receiving ranks allocate a buffer and reconstruct the full tensordict.- Parameters:
src (int) – The rank of the source process.
- Keyword Arguments:
group (torch.distributed.ProcessGroup, optional) – The process group to use. Defaults to
None(default group).device (device or str, optional) – The device on which to allocate the receive buffer. If
None, the device is inferred from the source’s consolidated storage (transmitted via metadata). Useful when the backend isnccland buffers must live on CUDA. Defaults toNone.
- Returns:
the broadcast tensordict on all ranks (consolidated).
- Return type:
Every tensordict class and every tensorclass has this method. For the other methods, see Methods by task.