Skip to content

cuda.core: initialize context in graph shutdown test#2375

Draft
rwgk wants to merge 1 commit into
NVIDIA:mainfrom
rwgk:fix-test_graph_definition_lifetime.py
Draft

cuda.core: initialize context in graph shutdown test#2375
rwgk wants to merge 1 commit into
NVIDIA:mainfrom
rwgk:fix-test_graph_definition_lifetime.py

Conversation

@rwgk

@rwgk rwgk commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Establish a current CUDA context in the isolated graph-shutdown probe.
  • Ensure the test reaches the interpreter-shutdown cleanup behavior it is
    intended to exercise.

Root Cause

test_pending_cleanup_is_safe_during_python_shutdown, added in #2371, runs
its probe in a fresh Python subprocess. The parent test's init_cuda fixture
does not provide a CUDA context to that subprocess. Constructing Device()
initializes CUDA, but does not make the device context current, so adding the
host callback node can fail with CUDA_ERROR_INVALID_VALUE before the shutdown
behavior is tested.

Explicitly call device.set_current() before constructing the graph.

Testing

  • Focused graph-shutdown test passed.
  • Full CUDA 13.4 Linux test run passed.
  • Full CUDA 13.4 Windows test run passed.
  • pre-commit run --all-files passed.

The subprocess does not inherit the pytest init_cuda fixture context. Set its device current before adding the host callback node so the probe reaches the shutdown-cleanup behavior it is intended to test.
@rwgk rwgk added this to the cuda.core next milestone Jul 15, 2026
@rwgk rwgk added bug Something isn't working test Improvements or additions to tests cuda.core Everything related to the cuda.core module labels Jul 15, 2026
@copy-pr-bot

copy-pr-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cuda.core Everything related to the cuda.core module test Improvements or additions to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant