in dualpipe/dualpipe.py [0:0]
def _send_backward(self, phase: int) -> None:
if self.forward_only:
return
phase ^= self.is_in_second_half
is_first_stage = (self.is_first_rank and phase == 0) or (self.is_last_rank and phase == 1)
if is_first_stage:
return
chunk_id = self.current_send_b_chunk_id[phase]
self.current_send_b_chunk_id[phase] += 1
tensors = self.input_grad_chunks[phase][chunk_id]
self.input_grad_chunks[phase][chunk_id] = None
comm.append_isend(self.comm_ops, tensors, self.prev_rank if phase == 0 else self.next_rank, self.group)