-
Notifications
You must be signed in to change notification settings - Fork 54
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
Call init/destroy_process_group once. #3143
Changes from 3 commits
3d91902
fc42a53
6f9e66e
eb58a40
07b0898
77f3e2e
b1b87e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,21 @@ class ComputeType(Enum): | |
BACKWARD = auto() | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def setup_process_group(mpi_test) -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe move to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll do that if I have to duplicate the code. This test is an exception -- normally we want nvFuser to set up process groups. |
||
os.environ["MASTER_ADDR"] = "localhost" | ||
# The default port as used by https://github.com/pytorch/pytorch/blob/45a8b5682eb69d865cbf68c7f2f689b56b4efd53/torch/csrc/distributed/c10d/TCPStore.hpp#L51. | ||
os.environ["MASTER_PORT"] = "29500" | ||
dist.init_process_group( | ||
backend="nccl", | ||
init_method="env://", | ||
samnordmann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
world_size=mpi_test.size, | ||
rank=mpi_test.rank, | ||
) | ||
yield | ||
dist.destroy_process_group() | ||
|
||
|
||
# This benchmark is instrumented with cudaProfilerStart/Stop. Therefore, one | ||
# can collect stats of the first few non-warmup benchmark iterations using | ||
# | ||
|
@@ -32,13 +47,10 @@ class ComputeType(Enum): | |
@pytest.mark.mpi | ||
@pytest.mark.parametrize( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure but it might work to specify There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand your suggestion. AFAIK, |
||
"compute_type", | ||
# TODO(#3119): add the backward test back. | ||
# [ComputeType.FORWARD, ComputeType.BACKWARD], | ||
# ids=["forward", "backward"], | ||
[ComputeType.FORWARD], | ||
ids=["forward"], | ||
[ComputeType.FORWARD, ComputeType.BACKWARD], | ||
ids=["forward", "backward"], | ||
) | ||
def test_transformer_layer(mpi_test, benchmark, compute_type): | ||
def test_transformer_layer(mpi_test, setup_process_group, benchmark, compute_type): | ||
# Hyperparameters for GPT-3 | ||
hidden_size = 12288 | ||
num_heads = 96 | ||
|
@@ -51,15 +63,6 @@ def test_transformer_layer(mpi_test, benchmark, compute_type): | |
rank = mpi_test.rank | ||
wujingyue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
torch.cuda.set_device(rank) | ||
os.environ["MASTER_ADDR"] = "localhost" | ||
# The default port as used by https://github.com/pytorch/pytorch/blob/45a8b5682eb69d865cbf68c7f2f689b56b4efd53/torch/csrc/distributed/c10d/TCPStore.hpp#L51. | ||
os.environ["MASTER_PORT"] = "29500" | ||
dist.init_process_group( | ||
backend="nccl", | ||
init_method="env://", | ||
world_size=size, | ||
rank=rank, | ||
) | ||
tp_group = dist.new_group() | ||
wujingyue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
transformer_layer = te.TransformerLayer( | ||
|
@@ -132,4 +135,4 @@ def benchmark_fn(y, dy, profile): | |
rounds=5, | ||
) | ||
|
||
dist.destroy_process_group() | ||
dist.destroy_process_group(group=tp_group) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because setup_process_group, has module scope, uses mpi_test, mpi_test must have module or session scope.