Revert "Stop parsing command line arguments every time common_utils is imported. (#156703)"

This reverts commit ac7b4e7fe4d233dcd7f6343d42b4fa3d64bce548.

Reverted https://github.com/pytorch/pytorch/pull/156703 on behalf of https://github.com/clee2000 due to failing internally D80206253, see above comment for details ([comment](https://github.com/pytorch/pytorch/pull/156703#issuecomment-3362156908))
This commit is contained in:
PyTorch MergeBot
2025-10-02 16:54:21 +00:00
parent 235b995ce1
commit 39189592fd
13 changed files with 104 additions and 226 deletions

View File

@ -33,7 +33,6 @@ import torch.nn as nn
from torch._C._autograd import DeviceType
from torch._C._distributed_c10d import _SymmetricMemory
from torch._logging._internal import trace_log
from torch.testing._internal import common_utils
from torch.testing._internal.common_utils import (
FILE_SCHEMA,
find_free_port,
@ -773,12 +772,7 @@ class MultiProcessTestCase(TestCase):
process = proc(
target=self.__class__._run,
name="process " + str(rank),
args=(
rank,
self._current_test_name(),
self.file_name,
child_conn,
),
args=(rank, self._current_test_name(), self.file_name, child_conn),
kwargs={
"fake_pg": getattr(self, "fake_pg", False),
},
@ -855,7 +849,6 @@ class MultiProcessTestCase(TestCase):
torch._C._set_print_stack_traces_on_fatal_signal(True)
# Show full C++ stacktraces when a Python error originating from C++ is raised.
os.environ["TORCH_SHOW_CPP_STACKTRACES"] = "1"
common_utils.set_rng_seed()
# self.id() == e.g. '__main__.TestDistributed.test_get_rank'
# We're retrieving a corresponding test and executing it.
@ -1677,10 +1670,6 @@ class MultiProcContinuousTest(TestCase):
self.rank = cls.rank
self.world_size = cls.world_size
test_fn = getattr(self, test_name)
# Ensure all the ranks use the same seed.
common_utils.set_rng_seed()
# Run the test function
test_fn(**kwargs)