Skip to content

Commit 735d1fb

Browse files
docs(cuda.core): document subclass deallocate routing (NVIDIA#2615)
Document MemoryResource subclass teardown behavior and add a 1.2.0 release note for pool-backed MR deallocate consistency. Signed-off-by: Omar Atie <[email protected]> Co-authored-by: Cursor <[email protected]>
1 parent c92f9b7 commit 735d1fb

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

‎cuda_core/cuda/core/_memory/_buffer.pyx‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,15 @@ cdef class MemoryResource:
607607
returned by the :meth:`allocate` method would hold a reference to self, the
608608
buffer properties are retrieved simply by looking up the underlying memory
609609
resource's respective property.)
610+
611+
Notes
612+
-----
613+
Python subclasses of pool-backed memory resources
614+
(:class:`~_memory.DeviceMemoryResource`, :class:`~_memory.PinnedMemoryResource`,
615+
:class:`~_memory.ManagedMemoryResource`) and :class:`~_memory.GraphMemoryResource`
616+
route buffer teardown through :meth:`deallocate`, including for buffers
617+
returned by :meth:`allocate`. Built-in resource types use a direct C++
618+
deallocation path that bypasses Python during interpreter shutdown.
610619
"""
611620

612621
def allocate(self, size_t size, *, stream: Stream | GraphBuilder) -> Buffer:
@@ -653,6 +662,11 @@ cdef class MemoryResource:
653662
Keyword-only. The stream on which to perform the deallocation
654663
asynchronously. Must be passed explicitly; pass
655664
``device.default_stream`` to use the default stream.
665+
666+
Notes
667+
-----
668+
For memory resources that own buffer pointers, this method is also
669+
invoked when a :class:`Buffer` is closed or garbage-collected.
656670
"""
657671
raise TypeError("MemoryResource.deallocate must be implemented by subclasses.")
658672

‎cuda_core/docs/source/release/1.2.0-notes.rst‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ Fixes and enhancements
4040
free operation. Previously, these errors could be suppressed. Automatic
4141
buffer cleanup remains non-raising and reports failures as warnings.
4242

43+
- Python subclasses of pool-backed memory resources and
44+
:class:`GraphMemoryResource` now route buffer teardown from
45+
:meth:`MemoryResource.allocate` through :meth:`MemoryResource.deallocate`,
46+
matching :meth:`Buffer.from_handle` behavior. Built-in resource types keep
47+
the direct C++ deallocation path for interpreter-shutdown safety.
48+
(`#2615 <https://github.com/NVIDIA/cuda-python/issues/2615>`__)
49+
4350
- Graph node resources are now retained independently across graph clones,
4451
executable graphs, updates, node deletion, and in-flight launches. Previously,
4552
modifying a graph definition could release resources still used by an

0 commit comments

Comments
 (0)