in picotron/context_parallel/cp_communications.py [0:0]
def send_recv(self, tensor_to_send, recv_tensor=None):
if recv_tensor is None:
result_tensor = torch.zeros_like(tensor_to_send)
else:
result_tensor = recv_tensor
send_operation = dist.P2POp(dist.isend, tensor_to_send, self.send_rank, group=pgm.process_group_manager.cp_group)
recv_operation = dist.P2POp(dist.irecv, result_tensor, self.recv_rank, group=pgm.process_group_manager.cp_group)
self._pending_operations.extend([send_operation, recv_operation])
if VERBOSE:
print(f"RingComm | send_recv | STEP:{STEP} | RANK:{self.rank} | "f"ACTION:sending | TO:{self.send_rank} | TENSOR:{tensor_to_send}", flush=True)
print(f"RingComm | send_recv | STEP:{STEP} | RANK:{self.rank} | "f"ACTION:receiving | FROM:{self.recv_rank} | TENSOR:{result_tensor}", flush=True)
return result_tensor