Fix CUDA 13.0 VMM handle type compatibility (#34431)
This commit is contained in:
@@ -159,6 +159,46 @@ def test_default_handle_type_fallback(monkeypatch, rejected, expected) -> None:
|
||||
get_device_allocation_handle_type.cache_clear()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("handle_types", "expected"),
|
||||
[
|
||||
(None, drv.CUmemAllocationHandleType.CU_MEM_HANDLE_TYPE_NONE),
|
||||
(0, drv.CUmemAllocationHandleType.CU_MEM_HANDLE_TYPE_NONE),
|
||||
(_POSIX_FD, _POSIX_FD),
|
||||
(_FABRIC, _FABRIC),
|
||||
],
|
||||
)
|
||||
def test_allocation_prop_assigns_handle_type_enum(
|
||||
monkeypatch, handle_types, expected
|
||||
) -> None:
|
||||
"""CUDA bindings 13.0.x reject integer VMM handle types at assignment."""
|
||||
|
||||
class Fields:
|
||||
pass
|
||||
|
||||
class StrictAllocationProp:
|
||||
def __init__(self):
|
||||
self.location = Fields()
|
||||
self.allocFlags = Fields()
|
||||
self._requested_handle_types = None
|
||||
|
||||
@property
|
||||
def requestedHandleTypes(self):
|
||||
return self._requested_handle_types
|
||||
|
||||
@requestedHandleTypes.setter
|
||||
def requestedHandleTypes(self, value):
|
||||
if not isinstance(value, drv.CUmemAllocationHandleType):
|
||||
raise TypeError("requestedHandleTypes requires a CUDA enum")
|
||||
self._requested_handle_types = value
|
||||
|
||||
monkeypatch.setattr(drv, "CUmemAllocationProp", StrictAllocationProp)
|
||||
|
||||
prop = make_device_allocation_prop(0, handle_types=handle_types)
|
||||
|
||||
assert prop.requestedHandleTypes is expected
|
||||
|
||||
|
||||
def test_granularity_defaults_to_recommended(monkeypatch) -> None:
|
||||
prop = make_device_allocation_prop(0, handle_types=None)
|
||||
seen = []
|
||||
|
||||
Reference in New Issue
Block a user