Skip to content
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

Fix tensor parallel distributed tests by requesting PyTorch not to destroy PG upon exit #1472

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions thunder/tests/distributed/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from functools import partial
from functools import wraps
from typing import ClassVar, TYPE_CHECKING
import inspect
import math
import os
import sys
Expand Down Expand Up @@ -112,6 +111,11 @@ def world_size(self) -> int:
def init_method(self):
return f"{common_utils.FILE_SCHEMA}{self.file_name}"

@property
def destroy_pg_upon_exit(self) -> bool:
# Overriding base test class: do not auto destroy PG upon exit.
return False

@classmethod
def _run(cls, rank, test_name, file_name, pipe, *, fake_pg=False):
assert not fake_pg, "Not yet supported here..."
Expand All @@ -130,14 +134,10 @@ def _run(cls, rank, test_name, file_name, pipe, *, fake_pg=False):
local_rank = self.rank % torch.cuda.device_count()
torch.cuda.set_device(local_rank)
os.environ["LOCAL_RANK"] = str(local_rank)
if "destroy_process_group" in inspect.signature(self.run_test).parameters:
run_test_kwargs = {"destroy_process_group": False}
else:
run_test_kwargs = {}

torch.distributed.barrier()
try:
self.run_test(test_name, pipe, **run_test_kwargs)
self.run_test(test_name, pipe)
except Exception:
raise
finally:
Expand Down
Loading