Skip to content

Comments

Fix issues discovered during v0.6.0 integration testing#1660

Merged
leofang merged 3 commits intoNVIDIA: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 intoNVIDIA:mainfrom
Andy-Jost:restore-private-handle-attrs

Conversation

@Andy-Jost
Copy link
Contributor

@Andy-Jost Andy-Jost commented Feb 19, 2026

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-Jost Andy-Jost added this to the cuda.core v0.6.0 milestone Feb 19, 2026
@Andy-Jost Andy-Jost added P0 High priority - Must do! cuda.core Everything related to the cuda.core module labels Feb 19, 2026
@Andy-Jost Andy-Jost self-assigned this Feb 19, 2026
@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Feb 19, 2026

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 Andy-Jost requested a review from leofang February 19, 2026 17:55
@Andy-Jost
Copy link
Contributor Author

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

@Andy-Jost
Copy link
Contributor Author

/ok to test 68bd7fb

@github-actions

This comment has been minimized.

@Andy-Jost
Copy link
Contributor Author

@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
Member

leofang commented Feb 19, 2026

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-Jost force-pushed the restore-private-handle-attrs branch from 68bd7fb to a6f091e Compare February 19, 2026 21:55
@Andy-Jost
Copy link
Contributor Author

/ok to test a6f091e

Andy-Jost and 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-Jost Andy-Jost changed the title Restore private _handle attrs on Context and Kernel Fix v0.6.0 regressions: restore _handle attrs, fix pickling, disable cuLibraryUnload Feb 20, 2026
@Andy-Jost
Copy link
Contributor Author

/ok to test 550c20e

@Andy-Jost Andy-Jost changed the title Fix v0.6.0 regressions: restore _handle attrs, fix pickling, disable cuLibraryUnload Fix issues discovered during v0.6.0 integration testing Feb 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
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).

@leofang leofang 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:main Feb 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
Copy link

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants