Skip to content

cuda.core: don't require a CUDA context for host-only memory - #2773

Open
Andy-Jost wants to merge 1 commit into
NVIDIA:mainfrom
Andy-Jost:ajost/issue-2769
Open

cuda.core: don't require a CUDA context for host-only memory#2773
Andy-Jost wants to merge 1 commit into
NVIDIA:mainfrom
Andy-Jost:ajost/issue-2769

Conversation

@Andy-Jost

@Andy-Jost Andy-Jost commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Since 1.2.0, Buffer.from_handle binds a default-stream deallocation token to the current CUDA context for every owning memory resource (#2526). A memory resource whose memory the device cannot access has no stream ordering to preserve, yet it could no longer create a Buffer in a process that never initialized CUDA. This is a regression from 1.1.x, reported against nvmath-python's NVPL-backed host APIs.

Changes

  • When mr.is_device_accessible is False, Buffer.from_handle records no deallocation stream and does not call the driver. mr.deallocate() still receives the default stream, as in 1.1.
  • The "no deallocation stream was recorded" warning is removed from the teardown path, because host-only buffers legitimately have none.
  • Tests cover a host-only resource with no current context and a spawned process that never initializes CUDA, using both a ctypes-backed resource and the reporter's NumPy-backed one.

Related Work

@Andy-Jost Andy-Jost added this to the cuda.core 1.3.0 milestone Sep 4, 2026
@Andy-Jost Andy-Jost added bug Something isn't working cuda.core Everything related to the cuda.core module labels Sep 4, 2026
@Andy-Jost Andy-Jost self-assigned this Sep 4, 2026
@copy-pr-bot

copy-pr-bot Bot commented Sep 4, 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.

Since 1.2.0, Buffer.from_handle binds a default-stream deallocation
token to the current context for every owning memory resource. Memory
the device cannot access has no stream ordering to preserve, so skip the
binding when mr.is_device_accessible is False. Such buffers record no
deallocation stream and never call the driver.

Fixes NVIDIA#2769

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@Andy-Jost
Andy-Jost requested a review from rparolin September 5, 2026 15:51
@Andy-Jost
Andy-Jost marked this pull request as ready for review September 5, 2026 15:57
@Andy-Jost
Andy-Jost requested a review from carterbox September 5, 2026 15:58
@Andy-Jost Andy-Jost added the P0 High priority - Must do! label Sep 5, 2026
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

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 P0 High priority - Must do!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: cuda-core 1.2.0 breaks Buffer use for non-CUDA memory implementations

1 participant