Skip to content

Commit 5b7c9b1

Browse files
committed
cuda.core: tighten pinned host pool capability check
Drop the unnecessary CUDA 12 fence around host_memory_pools_supported, raise RuntimeError instead of a synthetic CUDAError, and keep the regression test hardware-gated for devices without host memory pools.
1 parent 198cbb1 commit 5b7c9b1

2 files changed

Lines changed: 14 additions & 22 deletions

File tree

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import platform # no-cython-lint
2121
import uuid
2222

2323
from cuda.core._utils.cuda_utils import check_multiprocessing_start_method
24-
from cuda.core._utils.cuda_utils import CUDAError # no-cython-lint
2524

2625
from typing import TYPE_CHECKING
2726

@@ -113,21 +112,17 @@ cdef class PinnedMemoryResource(_MemPool):
113112
raise TypeError("Cannot allocate from a mapped IPC-enabled memory resource")
114113
cdef Stream s = Stream_accept(stream)
115114
device = s.device
116-
117-
cdef bint supported
118-
if self._numa_id >= 0:
119-
supported = device.properties.host_numa_memory_pools_supported
120-
else:
121-
IF CUDA_CORE_BUILD_MAJOR >= 13:
122-
supported = device.properties.host_memory_pools_supported
123-
ELSE:
124-
supported = True
115+
cdef bint supported = (
116+
device.properties.host_numa_memory_pools_supported
117+
if self._numa_id >= 0
118+
else device.properties.host_memory_pools_supported
119+
)
125120

126121
if not supported:
127-
raise CUDAError(
128-
f"CUDA_ERROR_NOT_SUPPORTED: CUDA device {device.device_id} does not "
129-
"support the requested host memory pool for PinnedMemoryResource. "
130-
"Use LegacyPinnedMemoryResource if memory-pool features are not required."
122+
raise RuntimeError(
123+
f"CUDA device {device.device_id} does not support the requested "
124+
"host memory pool for PinnedMemoryResource. Use "
125+
"LegacyPinnedMemoryResource if memory-pool features are not required."
131126
)
132127
return _MP_allocate(self, size, s)
133128

‎cuda_core/tests/test_memory.py‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -751,19 +751,16 @@ def test_pinned_memory_resource_initialization(init_cuda):
751751
buffer.close()
752752

753753

754-
@pytest.mark.agent_authored(model="gpt-5.6")
754+
@pytest.mark.agent_authored(model="cursor-grok-4.5")
755755
def test_pinned_memory_resource_rejects_unsupported_host_pool(init_cuda):
756+
"""allocate() must fail on devices without host memory pool support (see #2486)."""
756757
device = init_cuda
757-
try:
758-
supported = device.properties.host_memory_pools_supported
759-
except AttributeError:
760-
pytest.skip("Host memory pool capability query requires CUDA 13.0 or later")
761-
if supported:
758+
if device.properties.host_memory_pools_supported:
762759
pytest.skip("Device supports host memory pools")
763760

764-
mr = PinnedMemoryResource()
761+
mr = PinnedMemoryResource(PinnedMemoryResourceOptions(max_size=POOL_SIZE))
765762
try:
766-
with pytest.raises(CUDAError, match="CUDA_ERROR_NOT_SUPPORTED.*LegacyPinnedMemoryResource"):
763+
with pytest.raises(RuntimeError, match="does not support.*LegacyPinnedMemoryResource"):
767764
mr.allocate(1024, stream=device.default_stream)
768765
finally:
769766
mr.close()

0 commit comments

Comments
 (0)