Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialization all the chuncks in AllGather Collective #26

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
12 changes: 9 additions & 3 deletions msccl/language/collectives.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ def check(self, prog):


class AllGather(Collective):
def __init__(self, num_ranks, chunk_factor, inplace):
def __init__(self, num_ranks, chunk_factor, inplace, create_all_chunks=False):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we don't need create_all_chunks? For all-gather, in-place case, we can assume the output buffer is already allocated.

Collective.__init__(self, num_ranks, chunk_factor, inplace)
self.name = "allgather"
self.create_all_chunks = create_all_chunks

# Initializes input buffer for an allgather
def init_buffers(self):
Expand All @@ -73,8 +74,13 @@ def init_buffers(self):
# Inplace AllGather only uses the output buffer
for r in range(self.num_ranks):
output_buffer = [None] * (self.num_ranks * self.chunk_factor)
for ch in range(self.chunk_factor):
output_buffer[r * self.chunk_factor + ch] = Chunk(r, ch, -1, r * self.chunk_factor + ch)
if not self.create_all_chunks:
for ch in range(self.chunk_factor):
output_buffer[r * self.chunk_factor + ch] = Chunk(r, ch, -1, r * self.chunk_factor + ch)
else:
for rank in range(self.num_ranks):
for ch in range(self.chunk_factor):
output_buffer[rank * self.chunk_factor + ch] = Chunk(rank, ch, -1, rank * self.chunk_factor + ch)
buffers = {
Buffer.input: output_buffer[r * self.chunk_factor : (r + 1) * self.chunk_factor],
Buffer.output: output_buffer,
Expand Down
Loading