MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / remote_send

Function remote_send

imperative/python/megengine/distributed/functional.py:822–852  ·  view source on GitHub ↗

r"""Send tensor to another process. Args: inp: Tensor to send. dest_rank: Rank of destination process. Returns: None. Examples: .. code-block:: if rank == 0: data = mge.tensor(1) # Tensor(1) F.dis

(inp: Tensor, dest_rank: int)

Source from the content-addressed store, hash-verified

820
821
822def remote_send(inp: Tensor, dest_rank: int):
823 r"""Send tensor to another process.
824
825 Args:
826 inp: Tensor to send.
827 dest_rank: Rank of destination process.
828
829 Returns:
830 None.
831
832 Examples:
833 .. code-block::
834
835 if rank == 0:
836 data = mge.tensor(1)
837 # Tensor(1)
838 F.distributed.remote_send(data, 1) # return None
839 else:
840 data = F.distributed.remote_recv(0)
841 # Tensor(1)
842 """
843 group = _SendRecvGroup(get_rank(), dest_rank)
844 _bcast_shape_dtype(group, inp)
845 _bcast_tracer_state(group, inp)
846 op = RemoteSend()
847 op.key = group.key
848 op.addr, op.port = get_mm_server_addr()
849 op.rank_to = dest_rank
850 op.backend = _backend()
851 out = _RemoteSend(op)(inp)
852 _save_output_for_autodiff(inp, out)
853
854
855def remote_recv(src_rank: int, device: Optional[str] = None, inp=None) -> Tensor:

Callers 3

workerFunction · 0.90
workerFunction · 0.90
backwardMethod · 0.85

Calls 8

_SendRecvGroupClass · 0.85
get_rankFunction · 0.85
_bcast_shape_dtypeFunction · 0.85
_bcast_tracer_stateFunction · 0.85
get_mm_server_addrFunction · 0.85
_backendFunction · 0.85
_RemoteSendClass · 0.85

Tested by 2

workerFunction · 0.72
workerFunction · 0.72