Skip to content

Conversation

@Andy-Jost
Copy link
Contributor

Summary

Enable weak referencing for core API classes that were previously not weak-referenceable.

Changes

  • Add object __weakref__ to Cython cdef classes: Stream, Event, Context, Buffer, LaunchConfig
  • Add "__weakref__" to __slots__ for Python classes: Device, ObjectCode
  • Add test_weakref.py with parameterized tests verifying all 8 core API classes are weak-referenceable

Note: Kernel already had __weakref__ in its __slots__, and memory resource classes inherit from _MemPool which already supports weak references.

Test Plan

  • New test_weakref.py covers Device, Stream, Event, Context, Buffer, LaunchConfig, ObjectCode, Kernel
  • All existing tests pass locally

Enable weak referencing for Cython cdef classes:
- Stream, Event, Context (cdef classes via pxd)
- Buffer, LaunchConfig (cdef classes via pxd)

Enable weak referencing for Python classes with __slots__:
- Device, ObjectCode (added __weakref__ to __slots__)

Note: Kernel already had __weakref__ in its __slots__.
Memory resource classes inherit __weakref__ from _MemPool.

Add test_weakref.py to verify all core API classes are
weak-referenceable.
@Andy-Jost Andy-Jost added this to the cuda.core beta 12 milestone Jan 25, 2026
@Andy-Jost Andy-Jost added enhancement Any code-related improvements P1 Medium priority - Should do cuda.core Everything related to the cuda.core module labels Jan 25, 2026
@Andy-Jost Andy-Jost self-assigned this Jan 25, 2026
@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Jan 25, 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
Copy link
Contributor Author

/ok to test 7cd2618

@github-actions
Copy link

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 enhancement Any code-related improvements P1 Medium priority - Should do

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant