-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add example files for NCCL all_to_all_v/all_gather_v (#222)
- Loading branch information
1 parent
c2b2271
commit fdf6e59
Showing
4 changed files
with
61 additions
and
2 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT license. | ||
|
||
import torch | ||
from tutel import system, net | ||
|
||
parallel_env = system.init_data_model_parallel(backend='nccl', group_count=1) | ||
local_device = parallel_env.local_device | ||
|
||
assert parallel_env.global_size == 2, "This test case is set for World Size == 2 only" | ||
|
||
if parallel_env.global_rank == 0: | ||
input = torch.tensor([10, 10, 10, 10, 10], device=local_device) | ||
else: | ||
input = torch.tensor([20, 20, 20], device=local_device) | ||
|
||
print(f'Device-{parallel_env.global_rank} sends: {[input,]}') | ||
|
||
net.barrier() | ||
|
||
print(f'Device-{parallel_env.global_rank} recvs: {net.batch_all_gather_v([input,])[0]}') |
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,24 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT license. | ||
|
||
import torch | ||
from tutel import system, net | ||
|
||
parallel_env = system.init_data_model_parallel(backend='nccl', group_count=1) | ||
local_device = parallel_env.local_device | ||
|
||
assert parallel_env.global_size == 2, "This test case is set for World Size == 2 only" | ||
|
||
if parallel_env.global_rank == 0: | ||
input = torch.tensor([10, 10, 10, 10, 10], device=local_device) | ||
send_counts = torch.tensor([1, 4], dtype=torch.int32, device=local_device) | ||
else: | ||
input = torch.tensor([20, 20, 20], device=local_device) | ||
send_counts = torch.tensor([2, 1], dtype=torch.int32, device=local_device) | ||
|
||
print(f'Device-{parallel_env.global_rank} sends: {[input,]}') | ||
|
||
net.barrier() | ||
|
||
print(f'Device-{parallel_env.global_rank} recvs: {net.batch_all_to_all_v([input,], send_counts)[0]}') |