Repository navigation
test(cuda.core): resume the Windows test run when the driver is stuck in OOM #3695
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
Merged
juenglin
merged 7 commits into
NVIDIA:main
from
juenglin:test/windows-restart-on-sticky-oom
Dec 3, 2026
+213
−1
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
18ca962
test(cuda.core): stop the run when a Windows driver is stuck in OOM
juenglin 7699eb2
ci: restart the core tests in a fresh process when the driver is stuc…
juenglin 2a9774b
test(cuda.core): drop unit tests for the temporary sticky-OOM workaround
juenglin 1a77afa
test(cuda.core): keep failures from earlier attempts when the run res…
juenglin e5b157f
test(cuda.core): address review findings on the sticky-OOM restart
juenglin 39ff0b7
test(cuda.core): rerun tests that failed with OOM before a sticky-OOM…
juenglin bf9bf51
test(cuda.core): raise if the sticky-OOM probe cannot query the context
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Stop the run, and let CI resume it, when the driver is stuck in OOM (NVBugs 7092346). | ||
|
|
||
| On Windows (WDDM and MCDM), a host pinned memory pool that has had device | ||
| access granted can leave the process in a permanent error state: later driver | ||
| calls return ``CUDA_ERROR_OUT_OF_MEMORY`` even though no resource is exhausted, | ||
| and ``cuCtxSynchronize`` and ``cuMemGetInfo`` fail the same way. The state is | ||
| per process and the test that trips it is arbitrary, so marking tests xfail | ||
| would hide real failures and name the wrong tests (issue #3472). | ||
|
|
||
| This module detects that state after a failing test and makes pytest stop with | ||
| :data:`STICKY_OOM_EXIT_CODE`. ``ci/tools/run-tests`` then starts a fresh process | ||
| that skips the tests which already finished. Both halves are inert outside | ||
| Windows, and in a process that is healthy the probe returns False, so a | ||
| genuine out-of-memory failure still fails the run. | ||
|
|
||
| Remove this module and its wiring once the fixed driver is the minimum CI | ||
| driver. | ||
| """ | ||
|
|
||
| import os | ||
| import pathlib | ||
|
|
||
| from cuda.bindings import driver | ||
| from cuda_python_test_helpers import IS_WINDOWS | ||
|
|
||
| from .contexts import current_context_handle | ||
|
|
||
| # Not a pytest exit code (0-5) and not a signal. Mirrored in ci/tools/run-tests. | ||
| STICKY_OOM_EXIT_CODE = 75 | ||
| DONE_FILE_ENV = "CUDA_CORE_TEST_DONE_FILE" | ||
| # Mirrored in ci/tools/run-tests. | ||
| FAILED_SUFFIX = ".failed" | ||
| OOM_MARKER = "CUDA_ERROR_OUT_OF_MEMORY" | ||
|
|
||
| _OOM = driver.CUresult.CUDA_ERROR_OUT_OF_MEMORY | ||
|
|
||
|
|
||
| def is_affected_platform(): | ||
| """True where NVBugs 7092346 can occur. | ||
|
|
||
| Linux is unaffected. TCC is unaffected too, but a healthy process never | ||
| passes :func:`process_is_stuck_in_oom`, so no driver-model check is needed. | ||
| """ | ||
| return IS_WINDOWS | ||
|
|
||
|
|
||
| def process_is_stuck_in_oom(): | ||
| """True if context-wide calls return OOM, which a genuine allocation failure never does. | ||
|
|
||
| Needs a current context; returns False without one, so the next failing | ||
| test (the cascade produces many) gets another chance. Never changes the | ||
| current context. A broken probe raises rather than reporting a healthy | ||
| driver; ``cuCtxGetCurrent`` still succeeds in the stuck state. | ||
| """ | ||
| if current_context_handle() == 0: | ||
| return False | ||
| (sync_err,) = driver.cuCtxSynchronize() | ||
| mem_err = driver.cuMemGetInfo()[0] | ||
| return sync_err == _OOM and mem_err == _OOM | ||
|
|
||
|
|
||
| def is_oom_failure(report, call): | ||
| """True if ``report`` is a failed setup or call phase whose exception mentions OOM.""" | ||
| if not report.failed or call.excinfo is None or call.when not in ("setup", "call"): | ||
| return False | ||
| return OOM_MARKER in str(call.excinfo.value) | ||
|
|
||
|
|
||
| def record_finished(nodeid, failed=False): | ||
| """Append a finished test to the resume file, if CI asked for one. | ||
|
|
||
| A failed test is also listed in ``<resume file>.failed``, so that | ||
| ``ci/tools/run-tests`` can fail the run even if the last attempt passes. | ||
| """ | ||
| path = os.environ.get(DONE_FILE_ENV) | ||
| if path: | ||
| # The failure first: if this raises, the test is not finished and reruns. | ||
| if failed: | ||
| with open(path + FAILED_SUFFIX, "a", encoding="utf-8") as f: | ||
| f.write(nodeid + "\n") | ||
| with open(path, "a", encoding="utf-8") as f: | ||
| f.write(nodeid + "\n") | ||
|
|
||
|
|
||
| def finished_nodeids(): | ||
| """Node IDs that earlier attempts of this run finished; empty on a first attempt.""" | ||
| path = os.environ.get(DONE_FILE_ENV) | ||
| if not path or not pathlib.Path(path).is_file(): | ||
| return set() | ||
| return {line.strip() for line in pathlib.Path(path).read_text(encoding="utf-8").splitlines() if line.strip()} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
important: Keep a non-OOM failure when a teardown OOM makes the test rerun.
In
cuda_core/tests/conftest.py:151-153, a test with a call-phase failure and a teardown OOM never reachesrecord_finished. Keeping the test unfinished is correct, since it must rerun after a restart. The call failure, however, stays only in the process-local_failed_nodeids. In the fresh process after the restart, the test can pass. The finished-test record then has no entry for the call failure, so the run can pass despite that failure. The PR states that a restart must not turn a genuine failure green.Persist a non-OOM failure in a form that survives the restart. Keep that failure separate from completion. Leave the test unfinished so it reruns. Tests whose failures are only OOM should keep their current treatment.