-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
315 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
import argparse | ||
from msccl.language import * | ||
from msccl.topologies import * | ||
from msccl.language.collectives import AllReduce | ||
|
||
|
||
def allreduce_allpairs(gpus, instances): | ||
size = gpus | ||
chunksperloop = gpus | ||
topology = fully_connected(size) | ||
collective = AllReduce(size, chunksperloop, True) | ||
with MSCCLPPProgram( | ||
"allreduce_nvls", | ||
topology, | ||
collective, | ||
instances, | ||
): | ||
# Each rank sends the nth chunk to the nth rank into scratch space | ||
for rank in range(size): | ||
index = rank | ||
c = chunk(rank, Buffer.input, index) | ||
reduce_chunks = [] | ||
# make sure the data is ready | ||
for nghr in range(size): | ||
if rank != nghr: | ||
c_peer = chunk(nghr, Buffer.input, index) | ||
reduce_chunks.append(c_peer) | ||
c.signal(nghr, Buffer.input, index, sendtb=0) | ||
for nghr in range(size): | ||
if rank != nghr: | ||
c.wait(nghr, Buffer.input, index, recvtb=0) | ||
c = c.group_load_reduce(reduce_chunks, recvtb=0) | ||
ngbrs = [nghr for nghr in range(size) if nghr != rank] | ||
c.group_store(ngbrs, sendtb=0) | ||
|
||
Json() | ||
Check() | ||
|
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("num_gpus", type=int, help="number of gpus") | ||
parser.add_argument("instances", type=int, help="number of instances") | ||
|
||
args = parser.parse_args() | ||
|
||
allreduce_allpairs(args.num_gpus, args.instances) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.