Skip to content

Commit 490917d

Browse files
rathijitRathijit Sen
andauthored
added check to only shuffle non-empty partitions (#265)
Co-authored-by: Rathijit Sen <rathijit@MI300X-000000.kp5nb3zj3y4e1j4jepvvdyf0mb.zx.internal.cloudapp.net>
1 parent f87a31f commit 490917d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tutel/custom/custom_kernel.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,10 @@ static void batch_all_to_all_v(const std::vector<torch::Tensor> &ins, const std:
489489

490490
unsigned long long in_offset = 0, out_offset = 0;
491491
for (int i = 0; i < shared_world_size; ++i) {
492-
ncclSend((char*)in_buff + in_offset, in_sizes[i] * size, ncclInt8, i, (ncclComm_t)shared_nccl_comm, stream);
493-
ncclRecv((char*)out_buff + out_offset, out_sizes[i] * size, ncclInt8, i, (ncclComm_t)shared_nccl_comm, stream);
492+
if(in_sizes[i]) // only send if partition is non-empty
493+
ncclSend((char*)in_buff + in_offset, in_sizes[i] * size, ncclInt8, i, (ncclComm_t)shared_nccl_comm, stream);
494+
if(out_sizes[i]) // only receive if partition is non-empty
495+
ncclRecv((char*)out_buff + out_offset, out_sizes[i] * size, ncclInt8, i, (ncclComm_t)shared_nccl_comm, stream);
494496
in_offset += in_sizes[i] * size;
495497
out_offset += out_sizes[i] * size;
496498
}

0 commit comments

Comments
 (0)