Skip to content

Fix conditional graph lifetime tests to use supported nodes - #3469

Merged
Andy-Jost merged 3 commits into
mainfrom
rwgk/fix-conditional-graph-lifetime-tests
Nov 17, 2026
Merged

Andy-Jost merged 3 commits into
mainfrom
rwgk/fix-conditional-graph-lifetime-tests

Conversation

@rwgk

@rwgk rwgk commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

— codex on behalf of Ralf —

Description

Two graph lifetime tests populate conditional bodies with host callback nodes, which violate CUDA's documented body-graph requirements. A development driver rejects this setup with CUDA_ERROR_INVALID_VALUE, so all eight parameterized cases fail before reaching their lifetime assertions.

Use memset nodes with explicit sentinel owners to check attachment retention and release, and empty nodes to check graph and node-handle invalidation. The tests continue to cover if, if_else, while, and switch. The device allocation stays alive until body-node destruction and deferred owner cleanup complete.

Validation

Tested locally on Ubuntu 24.04 x86_64 with Python 3.12:

  • Before the change: all eight affected cases reproduce the setup failure.
  • After the change: all eight pass without skips.
  • Complete graph test suite: 551 passed, 24 skipped.
  • Full pre-commit: all hooks pass except lychee, which reports three existing GitHub 404 links in release notes.

Checklist

  • I have read the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

rwgk added 2 commits November 16, 2026 08:31
Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the cuda.core Everything related to the cuda.core module label Nov 16, 2026
@rwgk rwgk self-assigned this Nov 16, 2026
@rwgk rwgk added this to the cuda.core 1.3.1 milestone Nov 16, 2026
@rwgk
rwgk marked this pull request as ready for review November 16, 2026 16:51
@rwgk rwgk added the P0 High priority - Must do! label Nov 16, 2026
@rwgk
rwgk requested a review from Andy-Jost November 16, 2026 16:52
@rwgk

rwgk commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 9082ea9

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9082ea9 and 94f2721.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Updated coverage for attachment lifetimes in conditional branches, including release after destroying the parent node.
    • Adjusted branch-handle invalidation tests to use empty nodes.

The conditional-branch lifetime tests now use sentinel owners retained by branch memset attachments and empty branch nodes. They verify that destroying the parent ConditionalNode releases the owners and invalidates the branch nodes.

Changes: Graph definition lifetime tests

Layer / File(s) Summary
Conditional branch lifetime checks
cuda_core/tests/graph/test_graph_definition_lifetime.py
The attachment-release test checks that sentinel owners remain alive before parent destruction and are released afterward. The invalidation test uses empty branch nodes and retains its invalidation assertions.

Suggested labels: test

Suggested reviewers: andy-jost

Change: Other

Merge Risk: Minimal · previous review 9082e

This updates two conditional graph lifetime tests to use supported node types. It does not change production behavior, and no merge-blocking risk was found.

Security architecture risk: Minimal · up to 9082e

The change replaces unsupported test fixtures without changing production graph behavior or security boundaries. No introduced or worsened architecture risk was identified.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ba7dcd0 and 9082ea9.

Files selected for processing: 1

  • cuda_core/tests/graph/test_graph_definition_lifetime.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

@Andy-Jost Andy-Jost added the to-be-backported Trigger the bot to raise a backport PR upon merge label Nov 16, 2026
@Andy-Jost
Andy-Jost enabled auto-merge (squash) November 17, 2026 00:13
@Andy-Jost

Copy link
Copy Markdown
Contributor

/ok to test 94f2721

@github-actions

github-actions Bot commented Nov 17, 2026 •

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

@Andy-Jost
Andy-Jost merged commit b80866b into main Nov 17, 2026
122 checks passed
@Andy-Jost
Andy-Jost deleted the rwgk/fix-conditional-graph-lifetime-tests branch November 17, 2026 05:50
Andy-Jost added a commit to Andy-Jost/cuda-python that referenced this pull request Nov 17, 2026
)

* Fix conditional graph lifetime tests to use supported nodes

Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>

* ci: require manual copy-pr-bot approval

Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>

---------

Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
Co-authored-by: Andy Jost <ajost@nvidia.com>
(cherry picked from commit b80866b)
Andy-Jost added a commit that referenced this pull request Nov 18, 2026
* [doc-only] docs(cuda.core): fix the floor-move wording; advise against pinning cuda-bindings (#3441)

* docs(cuda.core): drop the Breaking Changes section name from the floor policy

The release notes no longer have a Breaking Changes section for a floor
move; 1.3.0 lists it under Highlights. Say only that the release notes
list every move.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(cuda.core): advise against pinning cuda-bindings next to cuda-core

Users who pin cuda-bindings themselves can conflict with the floor of a
later cuda-core release. Tell them to depend on cuda-core with the cu12
or cu13 extra and let cuda-core choose the cuda-bindings version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 83a3422)

* Mark cuda-gdb source-line test thread_unsafe (#3433)

Signed-off-by: Ralf Juengling <rjuengling@nvidia.com>
(cherry picked from commit 1a22eec)

* fix(cuda.core): serialize pinned-memory kernel-access test on Windows (#3436)

* fix(cuda.core): serialize pinned-memory kernel-access test on Windows

closes #3426

Add @thread_unsafe_on_windows to the pinned-memory kernel-access test.
The test accesses host memory while parallel workers may execute GPU
work; synchronizing its own stream does not coordinate those workers.

This follows the guard used by similar tests on Windows and WSL.
Windows CI is needed to confirm it resolves the reported crashes.
The separate OOM failures remain under investigation.

Validation: Ruff and git diff --check pass.

* fix(cuda.core): report CUDA synchronization errors during test teardown

Check the cuCtxSynchronize result in init_cuda so asynchronous errors
surface during the triggering test's teardown instead of going unnoticed
until a later test. Always attempt context cleanup via finally.

Related to #3426.

* fix(cuda.core): synchronize the bound context during test teardown

Use device.sync() because the test wrapper may pop the current context
before init_cuda teardown. This avoids spurious INVALID_CONTEXT errors
while preserving synchronization error reporting and context cleanup.

Add regression coverage for a missing current context and cleanup after
synchronization failures.

Related to #3426.

* fix(cuda.core): serialize memory-pool watermark reset tests

Mark test_mempool_watermark_reset thread_unsafe, matching test_mempool_trim.
Both exercise the pool teardown and synchronization sequence associated
with the suspected driver race in #3350.

* fix(cuda.core): bypass access revocation when destroying host pools

Skip peer-access revocation for locally created HOST and HOST_NUMA pools
to investigate pinned-pool teardown OOMs and crashes. Continue destroying
the pools and preserve cleanup for device, managed, and imported pools.

This is a diagnostic workaround pending Windows CI validation.

Related to #3426.

* fix(cuda.core): preserve the first exception during fixture cleanup

Keep setup or synchronization failures primary and attach subsequent
cleanup failures as exception notes. Always attempt to pop the context.

Add regression coverage for combined failures, including interrupts.

* fix(cuda.core): limit host-pool cleanup workaround to pinned allocations

HOST and HOST_NUMA also describe managed-pool preferences. Check the allocation type so the pinned-memory workaround preserves managed-pool peer-access revocation.

Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>

* test(cuda.core): expose pinned allocation OOM and retain its traceback

Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>

* ci: diagnose PR3436 pinned pool teardown on Windows

Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>

* ci: move watermark investigation out of PR3436

Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>

* test(cuda.core): restore expected pinned allocation OOM handling

Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>

* revert(cuda.core): defer pinned host pool cleanup workaround

Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>

---------

Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
(cherry picked from commit b715078)

* [no-ci] ci: exclude unavailable historical GitHub references (#3471)

* ci: exclude unavailable historical GitHub references

Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>

* ci: require manual copy-pr-bot approval

Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>

---------

Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
(cherry picked from commit 3991a69)

* cuda.core: map ml_dtypes bfloat16 to kDLBfloat in DLPack export (#3359)

_smv_dtype_numpy_to_dlpack dispatched on numpy dtype kind, but
ml_dtypes.bfloat16 has kind "V", so bf16 views fell through to the
unsupported-dtype BufferError and could not be re-exported, even though
the DLPack import path already accepts kDLBfloat and _tensor_map.pyx
maps bfloat16. Detect bfloat16 up front and export it as kDLBfloat
(16 bits).

The new round-trip test goes through StridedMemoryView.from_dlpack so
it cannot skip on stacks where NumPy's own DLPack support for extended
dtypes is unavailable, unlike the existing parametrized round-trip
test's NumPy-consumer probe.

Signed-off-by: Sainath-Reddy7 <180950590+Sainath-Reddy7@users.noreply.github.com>
Co-authored-by: Sainath-Reddy7 <180950590+Sainath-Reddy7@users.noreply.github.com>
Co-authored-by: Sebastian Berg <sebastianb@nvidia.com>
(cherry picked from commit d1d1457)

* fix(cuda.core): make IPC imports wait for a pending release of the same descriptor (#3450)

* fix(cuda.core): make IPC imports wait for a pending release of the same descriptor

deviceptr_import_ipc() shares one handle per descriptor because the
driver's first free of an imported pointer unmaps every import of it
(nvbug 5570902). The handle's deleter took ipc_import_mutex only after
the last reference was gone. In that gap an import found the cache entry
expired, re-imported the still-mapped pointer and registered a new entry.
The deleter then erased that new entry and freed the pointer, which
unmapped it under the new Buffer.

The cache entry now outlives the last reference and only its own deleter
erases it, under the mutex, together with the free. An import that finds
an expired entry waits on a condition variable until that release is
done, then imports fresh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Use CTAD for the ipc_import_mutex locks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 2f1185e)

* test(cuda.core): skip HOST graph allocation before CUDA 13 (#3446)

(cherry picked from commit 11cc666)

* test(cuda.core): query green stream contexts with v2 (#3448)

Signed-off-by: Rui Luo <ruluo@nvidia.com>
(cherry picked from commit 7076a67)

* test(cuda.core): skip the VMM RDMA policy test on WSL (#3478)

GPUDirect RDMA is not supported on WSL, but some drivers report the
capability there, and the RDMA-enabled VMM allocation in
test_vmm_allocator_policy_configuration then fails. Skip the test on
WSL; the capability checks stay as they are.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 36bc530)

* docs(cuda.core): add 1.3.0 release note for the IPC import/release race fix (#3479)

* docs(cuda.core): add 1.3.0 release note for the IPC import/release race fix

Follow-up to #3450, which merged without a release note.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(cuda.core): scope the IPC race release note to memory pool buffers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit de4c60d)

* Fix conditional graph lifetime tests to use supported nodes (#3469)

* Fix conditional graph lifetime tests to use supported nodes

Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>

* ci: require manual copy-pr-bot approval

Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>

---------

Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
Co-authored-by: Andy Jost <ajost@nvidia.com>
(cherry picked from commit b80866b)

* fix(cuda.core): run cuMemPoolSetAccess in relaxed mode in PinnedMemoryResource (#3475)

Since #3405, PinnedMemoryResource.__init__ without options calls
cuMemPoolSetAccess to grant the current device read/write access to
the driver's default pool.  The driver refuses that call, and
invalidates the capture, while a global-mode capture is active on any
thread.  Users of PyTorch's torch.cuda.graph (which defaults to global
mode) therefore see CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED on
construction and CUDA_ERROR_STREAM_CAPTURE_INVALIDATED on end_building.

Fix: introduce MP_set_access in _memory_pool.pyx, wrapping
cuMemPoolSetAccess in the existing _enter_relaxed_capture_mode /
_exit_relaxed_capture_mode helpers, following the identical pattern
used by pool attribute reads and writes and trim() since #2834.
Call it from _PMR_init instead of the bare with-nogil block.

The with-options path (cuMemPoolCreate) is unaffected; that call is
still refused under global capture as documented in the 1.3.0 notes.

Add tests for the three capture combinations (global+same_thread,
global+other_thread, thread_local+same_thread) and a capture-mode
restore check modelled on test_dmr_init_restores_capture_mode.

Closes #3451

Co-authored-by: Andy Jost <ajost@nvidia.com>
(cherry picked from commit d94f19c)

* cuda.core: carry the cuda-bindings floors through minimal-sysctk12/13 extras (#3460)

* cuda.core: carry the cuda-bindings floors through minimal-sysctk extras

The floors lived only in the cu12/cu13 extras, so a package that depends
on plain cuda-core never passed them to pip or uv, and an older
cuda-bindings failed only at import (#3459).

Declare the floors in new minimal-sysctk12/13 extras, include them from
cu12/cu13, and depend on cuda-bindings without a version. The floor
parser, the CI wheel-floor reader, the pre-commit hook and the docs read
the new extras.

* cuda.core: read cu<N> floors through the minimal-sysctk self-reference

Drop the unversioned cuda-bindings from the base dependencies, so a
plain cuda-core install keeps asking for an extra.

Keep the floor readers on the cu<N> extras, as before, and teach them
to follow a cuda-core[...] self-reference and to skip an unversioned
cuda-bindings[all]. The cu<N> layout then yields the floor written in
minimal-sysctk<N>, and the existing tests of the cu<N> form stay as
they are. New tests cover the self-reference.

---------

Co-authored-by: Andy Jost <ajost@nvidia.com>
(cherry picked from commit ad38141)

---------

Signed-off-by: Ralf Juengling <rjuengling@nvidia.com>
Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
Signed-off-by: Sainath-Reddy7 <180950590+Sainath-Reddy7@users.noreply.github.com>
Signed-off-by: Rui Luo <ruluo@nvidia.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Ralf Juengling <rjuengling@nvidia.com>
Co-authored-by: jpascucci-nv <jpascucci@nvidia.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgkio@gmail.com>
Co-authored-by: B Sainath Reddy <bsainathreddy4@gmail.com>
Co-authored-by: Sainath-Reddy7 <180950590+Sainath-Reddy7@users.noreply.github.com>
Co-authored-by: Sebastian Berg <sebastianb@nvidia.com>
Co-authored-by: Rob Parolin <rparolin@users.noreply.github.com>
Co-authored-by: Rui Luo <ruluo@nvidia.com>
Co-authored-by: Leo Fang <leof@nvidia.com>
github-actions Bot pushed a commit that referenced this pull request Nov 18, 2026
Removed preview folders for the following PRs:
- PR #3460
- PR #3469
- PR #3473
- PR #3474
- PR #3475
- PR #3485
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.core Everything related to the cuda.core module P0 High priority - Must do! to-be-backported Trigger the bot to raise a backport PR upon merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants