Repository navigation
test(cuda.core): retry all failed tests after confirmed sticky OOM #3704
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
Open
juenglin
wants to merge
4
commits into
NVIDIA:main
Choose a base branch
from
juenglin:test/sticky-oom-rerun-oom-failures
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+132
−52
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1f353c3
test(cuda.core): keep non-OOM failures across a sticky-OOM restart
juenglin 2fb7827
test(cuda.core): classify sticky OOM from exceptions
juenglin 3749c99
test(cuda.core): clarify sticky OOM checks and regressions
juenglin ae847a3
test(cuda.core): retry all failures after confirmed sticky OOM
juenglin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import os | ||
| import pathlib | ||
| import subprocess | ||
| import sys | ||
| from types import SimpleNamespace | ||
|
|
||
| import pytest | ||
| from helpers import sticky_oom | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("probe_confirms_sticky_oom", "failure_repeats"), | ||
| [(True, False), (True, True), (False, False)], | ||
| ids=["clears", "repeats", "no-restart"], | ||
| ) | ||
| @pytest.mark.agent_authored(model="gpt-6.2-sol") | ||
| def test_sticky_oom_retries_non_oom_failure(tmp_path, probe_confirms_sticky_oom, failure_repeats): | ||
| # Run the actual hooks in separate processes with no live driver probes. | ||
| test_file = tmp_path / "test_retry.py" | ||
| test_file.write_text( | ||
| f"""\ | ||
| import os | ||
|
|
||
| from helpers import oom_diagnostics, sticky_oom | ||
|
|
||
| restarting = os.environ["STICKY_OOM_TEST_RESTART"] == "1" | ||
| sticky_oom.IS_WINDOWS = True | ||
| sticky_oom.process_is_stuck_in_oom = lambda: {probe_confirms_sticky_oom!r} | ||
| oom_diagnostics.record_if_oom = lambda *args: None | ||
|
|
||
| def test_already_passed(): | ||
| assert not restarting, "a completed test should be skipped" | ||
|
|
||
| def test_non_oom(): | ||
| if not restarting or {failure_repeats!r}: | ||
| raise AssertionError("non-OOM failure") # Not CUDA_ERROR_OUT_OF_MEMORY | ||
|
|
||
| def test_trigger(): | ||
| if not restarting: | ||
| raise RuntimeError("CUDA_ERROR_OUT_OF_MEMORY: restart trigger") | ||
| """, | ||
| encoding="utf-8", | ||
| ) | ||
| done_file = tmp_path / "finished.txt" | ||
| tests_dir = pathlib.Path(__file__).parent | ||
| env = { | ||
| **os.environ, | ||
| sticky_oom.DONE_FILE_ENV: str(done_file), | ||
| "PYTEST_ADDOPTS": "", | ||
| "PYTEST_DISABLE_PLUGIN_AUTOLOAD": "1", | ||
| "PYTHONPATH": os.pathsep.join(filter(None, (str(tests_dir), os.environ.get("PYTHONPATH")))), | ||
| } | ||
|
|
||
| def run_pytest(restart): | ||
| return subprocess.run( # noqa: S603 - trusted interpreter and test-owned arguments | ||
| [sys.executable, "-m", "pytest", "--noconftest", "-p", "conftest", "-q", test_file.name], | ||
| capture_output=True, | ||
| cwd=tmp_path, | ||
| env={**env, "STICKY_OOM_TEST_RESTART": str(int(restart))}, | ||
| text=True, | ||
| timeout=30, | ||
| ) | ||
|
|
||
| first = run_pytest(restart=False) | ||
| expected = sticky_oom.STICKY_OOM_EXIT_CODE if probe_confirms_sticky_oom else pytest.ExitCode.TESTS_FAILED | ||
| assert first.returncode == expected, first.stdout + first.stderr | ||
| assert "non-OOM failure" in first.stdout | ||
| assert "CUDA_ERROR_OUT_OF_MEMORY: restart trigger" in first.stdout | ||
| assert done_file.read_text(encoding="utf-8").splitlines() == ["test_retry.py::test_already_passed"] | ||
|
|
||
| if probe_confirms_sticky_oom: | ||
| second = run_pytest(restart=True) | ||
| expected = pytest.ExitCode.TESTS_FAILED if failure_repeats else pytest.ExitCode.OK | ||
| assert second.returncode == expected, second.stdout + second.stderr | ||
| assert ("non-OOM failure" in second.stdout) is failure_repeats | ||
| finished = ["test_retry.py::test_already_passed", "test_retry.py::test_trigger"] | ||
| if not failure_repeats: | ||
| finished.append("test_retry.py::test_non_oom") | ||
| assert sorted(done_file.read_text(encoding="utf-8").splitlines()) == sorted(finished) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("second_error", "is_oom"), | ||
| [(sticky_oom.OOM_MARKER, True), ("unrelated failure", False)], | ||
| ids=["oom-only", "mixed"], | ||
| ) | ||
| @pytest.mark.agent_authored(model="gpt-6.2-sol") | ||
| def test_sticky_oom_classifies_grouped_failures(second_error, is_oom): | ||
| with pytest.raises(ExceptionGroup) as excinfo: | ||
| raise ExceptionGroup("teardown", [RuntimeError(sticky_oom.OOM_MARKER), RuntimeError(second_error)]) | ||
|
|
||
| report = SimpleNamespace(failed=True) | ||
| call = SimpleNamespace(excinfo=excinfo) | ||
| assert sticky_oom.is_oom_failure(report, call) is is_oom |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.