Skip to content

Commit 384c5c5

Browse files
cpcloudclaude
andcommitted
Fix is_managed reporting for pool-allocated managed memory
Pool-allocated managed memory via cuMemAllocFromPoolAsync (from a pool created with CU_MEM_ALLOCATION_TYPE_MANAGED) does not set CU_POINTER_ATTRIBUTE_IS_MANAGED=1. _query_memory_attrs therefore classified the allocation as pinned host memory, causing classify_dl_device to return kDLCUDAHost instead of kDLCUDAManaged. CCCL's make_tma_descriptor only accepts kDLCUDA or kDLCUDAManaged, so as_tensor_map() failed with "Device type must be kDLCUDA or kDLCUDAManaged" on managed buffers. Buffer.is_device_accessible / is_host_accessible already delegate to the memory resource when one is attached. Apply the same pattern to is_managed, and expose is_managed on the MemoryResource base (defaulting to False) with ManagedMemoryResource overriding it to True. Also ignore .claude/settings.local.json in .gitignore. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a8805e5 commit 384c5c5

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,4 @@ cython_debug/
196196

197197
# Cursor
198198
.cursorrules
199+
.claude/settings.local.json

cuda_core/cuda/core/_memory/_buffer.pyx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,8 @@ cdef class Buffer:
390390
@property
391391
def is_managed(self) -> bool:
392392
"""Return True if this buffer is CUDA managed (unified) memory, otherwise False."""
393+
if self._memory_resource is not None:
394+
return self._memory_resource.is_managed
393395
_init_mem_attrs(self)
394396
return self._mem_attrs.is_managed
395397

@@ -535,6 +537,11 @@ cdef class MemoryResource:
535537
"""Whether buffers allocated by this resource are host-accessible."""
536538
raise TypeError("MemoryResource.is_host_accessible must be implemented by subclasses.")
537539

540+
@property
541+
def is_managed(self) -> bool:
542+
"""Whether buffers allocated by this resource are CUDA managed (unified) memory."""
543+
return False
544+
538545
@property
539546
def device_id(self) -> int:
540547
"""Device ID associated with this memory resource, or -1 if not applicable."""

cuda_core/cuda/core/_memory/_managed_memory_resource.pyx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ cdef class ManagedMemoryResource(_MemPool):
121121
"""Return True. This memory resource provides host-accessible buffers."""
122122
return True
123123

124+
@property
125+
def is_managed(self) -> bool:
126+
"""Return True. This memory resource provides managed (unified) memory buffers."""
127+
return True
128+
124129

125130
IF CUDA_CORE_BUILD_MAJOR >= 13:
126131
cdef tuple _VALID_LOCATION_TYPES = ("device", "host", "host_numa")

0 commit comments

Comments
 (0)