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

This reverts commit 310f901a71e53688866b14bb2f2b4c8eef9979b3.

Reverted https://github.com/pytorch/pytorch/pull/156703 on behalf of https://github.com/izaitsevfb due to breaking tests internally with `assert common_utils.SEED is not None` ([comment](https://github.com/pytorch/pytorch/pull/156703#issuecomment-3152337518))
This commit is contained in:
PyTorch MergeBot
2025-08-04 20:37:39 +00:00
parent d4109a0f99
commit 356ac3103a
16 changed files with 109 additions and 255 deletions

View File

@ -3,13 +3,6 @@
import torch
if __name__ == '__main__':
from torch.testing._internal.common_utils import parse_cmd_line_args
# The value of GRAPH_EXECUTOR and SEED depend on command line arguments so make sure they're parsed
# before instantiating tests.
parse_cmd_line_args()
# This is how we include tests located in test/jit/...
# They are included here so that they are invoked when you call `test_jit.py`,
# do not run these test files directly.
@ -104,7 +97,7 @@ import torch.nn.functional as F
from torch.testing._internal import jit_utils
from torch.testing._internal.common_jit import check_against_reference
from torch.testing._internal.common_utils import run_tests, IS_WINDOWS, \
GRAPH_EXECUTOR, suppress_warnings, IS_SANDCASTLE, ProfilingMode, \
suppress_warnings, IS_SANDCASTLE, GRAPH_EXECUTOR, ProfilingMode, \
TestCase, freeze_rng_state, slowTest, TemporaryFileName, \
enable_profiling_mode_for_profiling_tests, TEST_MKL, set_default_dtype, num_profiled_runs, \
skipIfCrossRef, skipIfTorchDynamo
@ -165,7 +158,6 @@ def doAutodiffCheck(testname):
if "test_t_" in testname or testname == "test_t":
return False
assert GRAPH_EXECUTOR
if GRAPH_EXECUTOR == ProfilingMode.SIMPLE:
return False
@ -209,7 +201,6 @@ def doAutodiffCheck(testname):
return testname not in test_exceptions
assert GRAPH_EXECUTOR
# TODO: enable TE in PE when all tests are fixed
torch._C._jit_set_texpr_fuser_enabled(GRAPH_EXECUTOR == ProfilingMode.PROFILING)
torch._C._jit_set_profiling_executor(GRAPH_EXECUTOR != ProfilingMode.LEGACY)