Skip to content

Fix issues discovered during v0.6.0 integration testing - #1660

Merged
leofang merged 3 commits into
NVIDIA:mainfrom
Andy-Jost:restore-private-handle-attrs
Feb 20, 2026
Merged

Fix issues discovered during v0.6.0 integration testing#1660
leofang merged 3 commits into
NVIDIA:mainfrom
Andy-Jost:restore-private-handle-attrs

Conversation

@Andy-Jost

@Andy-JostAndy-Jost commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Restores _handle as a property on Context and Kernel that delegates to the public .handle property, providing backward compatibility for downstream projects (e.g., numba-cuda) that relied on the private attribute removed during the resource handles refactoring
  • Fixes pickle support for Cython cdef class types (ObjectCode, IPCEventDescriptor, IPCBufferDescriptor, Buffer) where @classmethod callables in __reduce__ fail pickle's identity check
  • Disables cuLibraryUnload in LibraryBox deleters to prevent potential segfaults when the owning context is destroyed before the library (to be re-enabled once LibraryBox tracks its owning context)
  • Adds 0.6.0 to the docs version switcher (nv-versions.json)
  • Guards ml_dtypes import in test_utils.py as an optional dependency

Changes

  • _context.pyx: Add _handle property that returns self.handle
  • _module.pyx: Add _handle property on Kernel that returns self.handle; convert ObjectCode._reduce_helper from @classmethod to @staticmethod
  • _event.pyx: Convert IPCEventDescriptor._init from @classmethod to @staticmethod
  • _memory/_buffer.pyx: Add @staticmethod _reduce_helper for Buffer.__reduce__
  • _memory/_ipc.pyx: Convert IPCBufferDescriptor._init from @classmethod to @staticmethod
  • _cpp/resource_handles.cpp: Comment out cuLibraryUnload calls in LibraryBox deleters
  • docs/nv-versions.json: Add 0.6.0 entry
  • tests/test_utils.py: Guard ml_dtypes import with try/except and add skip markers

Test Coverage

  • Pickle round-trip for ObjectCode verified manually
  • _handle property delegates to existing .handle which is already tested
  • numba-cuda's existing tests exercise the _handle path

Related Work

@Andy-JostAndy-Jost added this to the cuda.core v0.6.0 milestone Feb 19, 2026
@Andy-JostAndy-Jost added P0 High priority - Must do! cuda.core Everything related to the cuda.core module labels Feb 19, 2026
@Andy-JostAndy-Jost self-assigned this Feb 19, 2026
@copy-pr-bot

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.

@Andy-Jost

Copy link
Copy Markdown
ContributorAuthor

cc @brandon-b-miller — this restores the private _handle attributes so numba-cuda doesn't need version-gated access.

@Andy-Jost

Copy link
Copy Markdown
ContributorAuthor

/ok to test 68bd7fbd0c5de226dea9b39bebc3cc99da1076ac

Comment threadcuda_core/cuda/core/_context.pyx
@github-actions

This comment has been minimized.

@Andy-Jost

Copy link
Copy Markdown
ContributorAuthor

@mdboom Tried it — Cython rejects _handle = handle in a cdef class (compile error). Properties in cdef classes are implemented as C-level PyGetSetDef entries, not regular Python descriptors, so the alias trick doesn't work.

@leofang

Copy link
Copy Markdown
Member

Brandon will be verifying with numba-cuda locally.

@rparolin
rparolin self-requested a review February 19, 2026 19:49
…mpat
Adds _handle properties that delegate to .handle on Context and Kernel,
preserving backward compatibility for downstream projects (e.g., numba-cuda)
that relied on the private attribute.
Co-authored-by: Cursor <cursoragent@cursor.com>
@Andy-Jost
Andy-Jostforce-pushed the restore-private-handle-attrs branch from 68bd7fb to a6f091eCompareFebruary 19, 2026 21:55
@Andy-Jost

Copy link
Copy Markdown
ContributorAuthor

/ok to test a6f091e

Andy-Jostand others added 2 commits February 20, 2026 11:52
- Convert @classmethod to @staticmethod for pickle callables in
ObjectCode, IPCEventDescriptor, IPCBufferDescriptor, and Buffer
to fix pickle identity check failures in Cython cdef classes
- Comment out cuLibraryUnload calls in LibraryBox deleters to prevent
potential segfaults when owning context is destroyed before library
- Guard ml_dtypes import in test_utils.py as optional dependency
Co-authored-by: Cursor <cursoragent@cursor.com>
@Andy-JostAndy-Jost changed the title Restore private _handle attrs on Context and KernelFix v0.6.0 regressions: restore _handle attrs, fix pickling, disable cuLibraryUnloadFeb 20, 2026
@Andy-Jost

Copy link
Copy Markdown
ContributorAuthor

/ok to test 550c20e

@Andy-JostAndy-Jost changed the title Fix v0.6.0 regressions: restore _handle attrs, fix pickling, disable cuLibraryUnloadFix issues discovered during v0.6.0 integration testingFeb 20, 2026
Comment on lines -753 to +754
p_cuLibraryUnload(b->resource);
// TODO: re-enable once LibraryBox tracks its owning context
// p_cuLibraryUnload(b->resource);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note for posterity: This restores the old behavior since cuda.core 0.1.0 (this was changed when module/library was cythonized).

@leofangleofang added the bug Something isn't working label Feb 20, 2026
@leofang
leofang enabled auto-merge (squash) February 20, 2026 20:53
@leofang
leofang merged commit e44a83c into NVIDIA:mainFeb 20, 2026
88 checks passed
@Andy-Jost
Andy-Jost deleted the restore-private-handle-attrs branch February 20, 2026 21:46
@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

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

Andy-Jost added a commit to Andy-Jost/cuda-python that referenced this pull request Mar 23, 2026
Adds parametrized roundtrip tests covering both pickle and cloudpickle
for Device, ObjectCode, IPCBufferDescriptor, and IPCEventDescriptor.
These tests guard against the Cython @classmethod identity issue fixed
in NVIDIA#1660 (cloudpickle fails when __reduce__ references a @classmethod).
ClosesNVIDIA#1671
Made-with: Cursor
Andy-Jost added a commit that referenced this pull request Mar 23, 2026
Adds parametrized roundtrip tests covering both pickle and cloudpickle
for Device, ObjectCode, IPCBufferDescriptor, and IPCEventDescriptor.
These tests guard against the Cython @classmethod identity issue fixed
in #1660 (cloudpickle fails when __reduce__ references a @classmethod).
Closes#1671
Made-with: Cursor
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugSomething isn't workingcuda.coreEverything related to the cuda.core moduleP0High priority - Must do!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@Andy-Jost@leofang@mdboom@rparolin