Skip to content

[doc-only] cuda.core: initialize context in graph shutdown test#2375

Merged
rwgk merged 2 commits into
NVIDIA:mainfrom
rwgk:fix-test_graph_definition_lifetime.py
Jul 17, 2026
Merged

[doc-only] cuda.core: initialize context in graph shutdown test#2375
rwgk merged 2 commits 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.

@Andy-Jost
Andy-Jost self-requested a review July 16, 2026 17:17

@Andy-Jost Andy-Jost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified this locally. It passed full CI in #2357

@rwgk rwgk changed the title cuda.core: initialize context in graph shutdown test [doc-only] cuda.core: initialize context in graph shutdown test Jul 16, 2026
@rwgk
rwgk marked this pull request as ready for review July 16, 2026 22:57
@rwgk

rwgk commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @Andy-Jost!

@rwgk
rwgk enabled auto-merge (squash) July 16, 2026 22:57
@github-actions

This comment has been minimized.

@rwgk
rwgk merged commit 58f8733 into NVIDIA:main Jul 17, 2026
42 of 45 checks passed
@github-actions

Copy link
Copy Markdown
Doc Preview CI
Preview removed because the pull request was closed or merged.

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.

2 participants