-
Notifications
You must be signed in to change notification settings - Fork 24
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
Saeed Maleki
committed
Apr 28, 2023
1 parent
c59f276
commit db171e0
Showing
2 changed files
with
47 additions
and
5 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,42 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
import argparse | ||
from msccl.language import * | ||
from msccl.topologies import * | ||
from msccl.language.collectives import AllGather | ||
|
||
# Allpairs allgather for A100 | ||
def allgather_allpairs(gpus, instances, protocol): | ||
size = gpus | ||
chunksperloop = 1 | ||
topology = fully_connected(gpus) | ||
collective = AllGather(size, chunksperloop, True) | ||
|
||
with MSCCLProgram("allgather_hierarchical", topology, collective, instances, protocol=protocol, | ||
interleaved_replication=True, dependence_nop=True): | ||
for chnk in range(2): | ||
for r in range(size): | ||
if ((r % 2) == chnk): | ||
c = chunk(r, Buffer.input, 0) | ||
c.copy(r + 1 - 2 * chnk, Buffer.output, r) | ||
for r in range(size): | ||
if ((r % 2) == chnk): | ||
c = chunk(r, Buffer.input, 0) | ||
c.copy((r+2) % size, Buffer.output, r) | ||
for r in range(size): | ||
if ((r % 2) == chnk): | ||
c = chunk(r, Buffer.output, (r+2) % size) | ||
c.copy(r + 1 - 2 * chnk, Buffer.output, (r+2) % size) | ||
|
||
XML() | ||
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') | ||
parser.add_argument('--protocol', type=str, default='LL128', choices=['Simple', 'LL', 'LL128'], help ='NCCL protocol. Default: Simple') | ||
args = parser.parse_args() | ||
|
||
allgather_allpairs(args.num_gpus, args.instances, args.protocol) |
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