-
Notifications
You must be signed in to change notification settings - Fork 104
Add switch-channel NVLS cross-rank barrier #843
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
Open
RJ Souza (Empyreus)
wants to merge
22
commits into
main
Choose a base branch
from
rjsouza/nvls-barrier
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
b2da14a
runtime implementation
Empyreus e111b29
initial test
Empyreus 66c81e1
make relaxed
Empyreus 67a6b6f
add memory_order options to barrier
Empyreus c90bdc1
fix formatting
Empyreus becaf3c
Merge branch 'main' into rjsouza/nvls-barrier
Empyreus 4f557dc
rework signal & wait
Empyreus 8495ada
formatting fixes
Empyreus b16764d
Merge branch 'main' into rjsouza/nvls-barrier
Binyang2014 19b6137
switch to using semaphore class
Empyreus 2a9dca9
Merge branch 'rjsouza/nvls-barrier' of github.com:microsoft/mscclpp i…
Empyreus 541e325
add unit & perf tests
Empyreus d0cec32
add relexed switch channel barrier perf test
Empyreus 1379c2f
remove redudent makeConnection barrier
Empyreus e8b6201
convert to uint64 for consistency
Empyreus 8f82e5c
modify dsl algorithm
Empyreus f3713ef
use minimum granularity
Empyreus 949ad32
add debugging to min gran
Empyreus a314479
use semaphore object
Empyreus 4e4c3a5
remove sync
Empyreus 783d241
formatting
Empyreus bd18768
data_sync
Empyreus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
|
Empyreus marked this conversation as resolved.
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
70 changes: 70 additions & 0 deletions
70
python/mscclpp/language/tests/single_node/allgather_nvls_zero_copy_barrier.py
This file contains hidden or 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,70 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
|
|
||
| import argparse | ||
| from mscclpp.language.channel import * | ||
| from mscclpp.language.rank import * | ||
| from mscclpp.language.general import * | ||
| from mscclpp.language.program import * | ||
| from mscclpp.language.collectives import * | ||
|
|
||
|
|
||
| def allgather_example(name, gpu_size, num_threads_per_block, min_message_size, max_message_size, instances): | ||
| # Defaults instances=8, num_threads_per_block=256 are tuned for 64-GPU (4x GB200) MNNVL NVLS: | ||
| # they give the best busbw across 1MB-1GB (instances saturate at 8; tpb=256 beats 512/1024). | ||
| chunksperloop = 1 | ||
| collective = AllGather(gpu_size, chunksperloop, True) | ||
| with CollectiveProgram( | ||
| name, | ||
| collective, | ||
| gpu_size, | ||
| instances=instances, | ||
| protocol="Simple", | ||
| num_threads_per_block=num_threads_per_block, | ||
| use_double_scratch_buffer=False, | ||
| min_message_size=min_message_size, | ||
| max_message_size=max_message_size, | ||
| ): | ||
| # NVLS multicast channel over the output buffer. For Allgather each | ||
| # rank stores its own chunk to all ranks' output buffers via the switch. | ||
| nvls_chan = SwitchChannel(rank_list=[gpu for gpu in range(gpu_size)], buffer_type=BufferType.output) | ||
|
|
||
| # Synchronization to ensure all the GPUs are ready. A single switch-native | ||
| # barrier over the NVLS channel replaces the O(n^2) MemoryChannel signal/wait mesh. | ||
| for gpu in range(gpu_size): | ||
| nvls_chan.at_rank(gpu).barrier(tb_list=[0]) | ||
|
|
||
| # Broadcasting each rank's chunk to every rank via NVLS multimem store. | ||
| # Rank `gpu` owns output chunk `gpu` (its input under in-place AllGather) and | ||
| # stores it to offset `gpu` across all ranks in the switch group. | ||
| for gpu in range(gpu_size): | ||
| rank = Rank(gpu) | ||
| output_buffer = rank.get_output_buffer() | ||
| nvls_chan.at_rank(gpu).broadcast(src_chunk=output_buffer[gpu : gpu + 1], buffer_offset=gpu, size=1, tb=0) | ||
|
|
||
| # Synchronization to ensure the GPUs finished | ||
| for gpu in range(gpu_size): | ||
| nvls_chan.at_rank(gpu).barrier(tb_list=[0]) | ||
|
|
||
| print(JSON()) | ||
|
|
||
|
|
||
| parser = argparse.ArgumentParser() | ||
|
|
||
| parser.add_argument("--name", type=str, help="name of the program") | ||
| parser.add_argument("--num_gpus", type=int, help="number of gpus") | ||
| parser.add_argument("--num_threads_per_block", type=int, default=256, help="number of threads per block") | ||
| parser.add_argument("--min_message_size", type=int, default=0, help="minimum message size") | ||
| parser.add_argument("--max_message_size", type=int, default=2**64 - 1, help="maximum message size") | ||
| parser.add_argument("--instances", type=int, default=8, help="number of instances (parallel threadblocks)") | ||
|
|
||
| args = parser.parse_args() | ||
|
|
||
| allgather_example( | ||
| args.name, | ||
| args.num_gpus, | ||
| args.num_threads_per_block, | ||
| args.min_message_size, | ||
| args.max_message_size, | ||
| args.instances, | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.