Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions tests/kernels/test_pinned_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,21 @@ def test_host_device_ptr_is_identity_under_uva():
if not torch.cuda.is_available():
pytest.skip("needs CUDA")

from freetoken.kernel.pinned import _host_ptr_identity, _load_pinned_extension
from freetoken.kernel.pinned import (
_host_ptr_identity,
_load_pinned_extension,
alloc_pinned_tensor,
)

torch.cuda.init()
if not _host_ptr_identity():
pytest.skip("non-UVA platform: host_device_ptr rejects unregistered memory instead")
# Under UVA cudaHostGetDevicePointer degenerates to identity for any host pointer
# (no registration validation); rejection of pageable memory only exists on
# non-identity platforms (Windows/WDDM), where the translation is real.
pageable = torch.empty(64, dtype=torch.uint8)
# CUDA 13 rejects unregistered pageable pointers even on Linux/UVA. Exercise
# only the supported pinned + mapped contract; pageable-pointer behavior is
# outside host_device_ptr's contract.
pinned = alloc_pinned_tensor(64, dtype=torch.uint8)
ext = _load_pinned_extension()
assert ext.host_device_ptr(pageable.data_ptr()) == pageable.data_ptr()
assert ext.host_device_ptr(pinned.data_ptr()) == pinned.data_ptr()


def test_host_bank_pin_registers_and_translates():
Expand Down