8000 changes · pytorch/pytorch@3f58427 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3f58427

Browse files
committed
changes
1 parent 437e729 commit 3f58427

File tree

3 files changed

+58
-33
lines changed

3 files changed

+58
-33
lines changed

.github/workflows/_mac-test-arm64.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
# shellcheck disable=SC1090
4848
. ~/miniconda3/etc/profile.d/conda.sh
4949
set -ex
50-
conda create -yp "${ENV_NAME}" "python=${PY_VERS}" numpy expecttest pyyaml
50+
conda create -yp "${ENV_NAME}" "python=${PY_VERS}" numpy expecttest pyyaml pytest
5151
# As wheels are cross-compiled they are reported as x86_64 ones
5252
ORIG_WHLNAME=$(ls -1 dist/*.whl); ARM_WHLNAME=${ORIG_WHLNAME/x86_64/arm64}; mv ${ORIG_WHLNAME} ${ARM_WHLNAME}
5353
conda run -p "${ENV_NAME}" python3 -mpip install dist/*.whl

test/run_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,7 @@ def main():
904904

905905
has_failed = False
906906
failure_messages = []
907+
selected_tests = ['test_ops', 'test_ops_gradients', 'test_ops_jit']
907908
try:
908909
for test in selected_tests:
909910
options_clone = copy.deepcopy(options)

torch/testing/_internal/common_utils.py

Lines changed: 56 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -695,39 +695,63 @@ def addSkip(self, test, reason):
695695
test_report_path = TEST_SAVE_XML + LOG_SUFFIX
696696
test_report_path = os.path.join(test_report_path, test_filename)
697697
if test_filename in PYTEST_FILES and not IS_SANDCASTLE:
698-
# exclude linux cuda tests because we run into memory issues when running in parallel
699-
import pytest
700-
os.environ["NO_COLOR"] = "1"
701-
os.environ["USING_PYTEST"] = "1"
702-
pytest_report_path = test_report_path.replace('python-unittest', 'python-pytest')
703-
os.makedirs(pytest_report_path, exist_ok=True)
704-
# part of our xml parsing looks for grandparent folder names
705-
pytest_report_path_parallel = os.path.join(pytest_report_path, f"{test_filename}-parallel.xml")
706-
pytest_report_path_serial = os.path.join(pytest_report_path, f"{test_filename}-serial.xml")
707-
print(f'Test results will be stored in {pytest_report_path_parallel}')
708-
# mac slower on 4 proc than 3
709-
num_procs = 2
710-
exit_code = pytest.main(args=[inspect.getfile(sys._getframe(1)), f'-n={num_procs}', '-vv', '-x', '-m=not serial',
711-
'--reruns=2', '-rfEsX', f'--junit-xml-reruns={pytest_report_path_parallel}'])
712-
sanitize_pytest_xml(f'{pytest_report_path_parallel}')
713-
# exitcode of 5 means no tests were found, which happens for some test configs
714-
if exit_code != 0 and exit_code != 5:
715-
del os.environ["USING_PYTEST"]
716-
exit(exit_code)
717-
718-
exit_code = pytest.main(args=[inspect.getfile(sys._getframe(1)), '-vv', '-x', '-m=serial',
719-
'--reruns=2', '-rfEsX', f'--junit-xml-reruns={pytest_report_path_serial}'])
720-
sanitize_pytest_xml(f'{pytest_report_path_serial}')
698+
if os.environ["SHARD_NUMBER"] == "1":
699+
os.makedirs(test_report_path, exist_ok=True)
700+
verbose = '--verbose' in argv or '-v' in argv
701+
unittest.main(argv=argv, testRunner=xmlrunner.XMLTestRunner(
702+
output=test_report_path,
703+
verbosity=2 if verbose else 1,
704+
resultclass=XMLTestResultVerbose))
705+
if os.environ["SHARD_NUMBER"] == "2":
706+
import pytest
707+
os.environ["NO_COLOR"] = "1"
708+
os.environ["USING_PYTEST"] = "1"
709+
pytest_report_path = test_report_path.replace('python-unittest', 'python-pytest')
710+
os.makedirs(pytest_report_path, exist_ok=True)
711+
# part of our xml parsing looks for grandparent folder names
712+
pytest_report_path_parallel = os.path.join(pytest_report_path, f"{test_filename}-parallel.xml")
713+
pytest_report_path_serial = os.path.join(pytest_report_path, f"{test_filename}-serial.xml")
714+
print(f'Test results will be stored in {pytest_report_path_parallel}')
715+
# mac slower on 4 proc than 3
716+
num_procs = 2
717+
exit_code = pytest.main(args=[inspect.getfile(sys._getframe(1)), f'-n={num_procs}', '-vv', '-x', '-m=not serial',
718+
'--reruns=2', '-rfEsX', f'--junit-xml-reruns={pytest_report_path_parallel}'])
719+
sanitize_pytest_xml(f'{pytest_report_path_parallel}')
720+
# exitcode of 5 means no tests were found, which happens for some test configs
721+
if exit_code != 0 and exit_code != 5:
722+
del os.environ["USING_PYTEST"]
723+
exit(exit_code)
724+
725+
exit_code = pytest.main(args=[inspect.getfile(sys._getframe(1)), '-vv', '-x', '-m=serial',
726+
'--reruns=2', '-rfEsX', f'--junit-xml-reruns={pytest_report_path_serial}'])
727+
sanitize_pytest_xml(f'{pytest_report_path_serial}')
721728

722-
del os.environ["USING_PYTEST"]
723-
os.makedirs(test_report_path, exist_ok=True)
724-
verbose = '--verbose' in argv or '-v' in argv
725-
unittest.main(argv=argv, testRunner=xmlrunner.XMLTestRunner(
726-
output=test_report_path,
727-
verbosity=2 if verbose else 1,
728-
resultclass=XMLTestResultVerbose))
729+
del os.environ["USING_PYTEST"]
730+
if os.environ["SHARD_NUMBER"] == "3":
731+
import pytest
732+
os.environ["NO_COLOR"] = "1"
733+
os.environ["USING_PYTEST"] = "1"
734+
pytest_report_path = test_report_path.replace('python-unittest', 'python-pytest')
735+
os.makedirs(pytest_report_path, exist_ok=True)
736+
# part of our xml parsing looks for grandparent folder names
737+
pytest_report_path_parallel = os.path.join(pytest_report_path, f"{test_filename}-parallel.xml")
738+
pytest_report_path_serial = os.path.join(pytest_report_path, f"{test_filename}-serial.xml")
739+
print(f'Test results will be stored in {pytest_report_path_parallel}')
740+
# mac slower on 4 proc than 3
741+
num_procs = 3
742+
exit_code = pytest.main(args=[inspect.getfile(sys._getframe(1)), f'-n={num_procs}', '-vv', '-x', '-m=not serial',
743+
'--reruns=2', '-rfEsX', f'--junit-xml-reruns={pytest_report_path_parallel}'])
744+
sanitize_pytest_xml(f'{pytest_report_path_parallel}')
745+
# exitcode of 5 means no tests were found, which happens for some test configs
746+
if exit_code != 0 and exit_code != 5:
747+
del os.environ["USING_PYTEST"]
748+
exit(exit_code)
749+
750+
exit_code = pytest.main(args=[inspect.getfile(sys._getframe(1)), '-vv', '-x', '-m=serial',
751+
'--reruns=2', '-rfEsX', f'--junit-xml-reruns={pytest_report_path_serial}'])
752+
sanitize_pytest_xml(f'{pytest_report_path_serial}')
729753

730-
exit(0 if exit_code == 5 else exit_code)
754+
del os.environ["USING_PYTEST"]
731755
else:
732756
os.makedirs(test_report_path, exist_ok=True)
733757
verbose = '--verbose' in argv or '-v' in argv
@@ -858,8 +882,8 @@ def _check_module_exists(name: str) -> bool:
858882

859883
if (
860884
os.getenv("USING_PYTEST") == "1"
861-
and "cuda" in os.environ["BUILD_ENVIRONMENT"]
862885
and "linux" in os.environ["BUILD_ENVIRONMENT"]
886+
and TEST_CUDA
863887
):
864888
torch.cuda.set_per_process_memory_fraction(0.35)
865889

0 commit comments

Comments
 (0)
0