Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions varuna/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import os, sys
import time

P2P_TAG_ACTIONS = 1
P2P_TAG_GRADS = 2

class Pipeline:
""" Pipeline parallelism for Varuna """

Expand Down Expand Up @@ -131,7 +134,7 @@ def acts_receiver(self):
for d in self.fwd_inp_shape_changes:
fwd_inp_shape[d] = self.last_chunk_size
acts_tensor = torch.ones(fwd_inp_shape, dtype=dtype)
handle = dist.irecv(acts_tensor, src=self.receive_rank)
handle = dist.irecv(acts_tensor, src=self.receive_rank, tag=P2P_TAG_ACTIONS)
recv_handles.put((handle, acts_tensor))
if recv_handles.qsize()>4:
handle, tensor = recv_handles.get()
Expand All @@ -156,7 +159,7 @@ def grads_receiver(self):
for d in self.bwd_grad_shape_changes:
bwd_grad_shape[d] = self.last_chunk_size
grads_tensor = torch.ones(bwd_grad_shape, dtype=dtype)
handle = dist.irecv(grads_tensor, src=self.send_rank)
handle = dist.irecv(grads_tensor, src=self.send_rank, tag=P2P_TAG_GRADS)
recv_handles.put((handle, grads_tensor))
if recv_handles.qsize()>4:
handle, tensor = recv_handles.get()
Expand All @@ -176,7 +179,7 @@ def acts_sender(self):
send_handles = Queue()
while count > 0:
output_acts = self.acts_send_queue.get()
handle = dist.isend(output_acts, dst=self.send_rank)
handle = dist.isend(output_acts, dst=self.send_rank, tag=P2P_TAG_ACTIONS)
send_handles.put(handle)
if send_handles.qsize()>4:
handle = send_handles.get()
Expand All @@ -197,7 +200,7 @@ def grads_sender(self):
while count > 0:
input_grads = self.grads_send_queue.get()
# TODO: why is this contiguous needed ???
handle = dist.isend(input_grads.contiguous(), dst=self.receive_rank)
handle = dist.isend(input_grads.contiguous(), dst=self.receive_rank, tag=P2P_TAG_GRADS)
send_handles.put(handle)
if send_handles.qsize()>4:
handle = send_handles.get()
Expand Down