[Platform] Route pin memory availability through current_platform (#28113)

Co-authored-by: N3u0ns <N3u0ns@users.noreply.github.com>
Co-authored-by: Alex Nails <alex.nails@radixark.ai>
This commit is contained in:
N3ur0ns
2026-07-13 11:37:59 -07:00
committed by GitHub
co-authored by N3u0ns Alex Nails
parent afaa17a7f2
commit 11a82af5f8
7 changed files with 156 additions and 18 deletions
+3 -3
View File
@@ -125,9 +125,9 @@ class CpuSRTPlatform(CpuDeviceMixin, SRTPlatform):
supports_fp8 / support_cuda_graph / support_piecewise_cuda_graph keep the
conservative SRTPlatform defaults (all False), so they are not repeated
here. Only is_pin_memory_available is overridden: the base defaults to
True, but CPU has no GPU to pin host memory to.
here. is_pin_memory_available is repeated for explicitness: CPU has no GPU
to pin host memory to.
"""
def is_pin_memory_available(self) -> bool:
def is_pin_memory_available(self, device=None) -> bool:
return False
+5
View File
@@ -52,6 +52,11 @@ class CudaDeviceMixin(DeviceMixin):
def get_available_memory(self, device_id: int = 0) -> tuple[int, int]:
return torch.cuda.mem_get_info(device_id)
def is_pin_memory_available(self, device=None) -> bool:
if device is not None and str(device) == "cpu":
return False
return True
def get_torch_distributed_backend_str(self) -> str:
return "nccl"
@@ -159,6 +159,10 @@ class DeviceMixin:
"""[Active] Get current peak memory usage in bytes."""
raise NotImplementedError
def is_pin_memory_available(self, device=None) -> bool:
"""[Active] Whether pinned host memory is available for a target device."""
return False
# ------------------------------------------------------------------
# Planned methods — reserved interface. Core still uses hardcoded
# calls (e.g. torch.cuda.*). OOT implementations will NOT take
-4
View File
@@ -103,10 +103,6 @@ class SRTPlatform(DeviceMixin):
"""Whether this platform supports FP8 quantization."""
return False
def is_pin_memory_available(self) -> bool:
"""Whether pinned memory is available on this platform."""
return True
def support_cuda_graph(self) -> bool:
"""Whether this platform supports device graph capture and replay.
Controls CUDA graph (CudaGraphRunner) for the decode path.
+1 -5
View File
@@ -539,11 +539,7 @@ def get_available_gpu_memory(
def is_pin_memory_available(device=None) -> bool:
if not torch.cuda.is_available():
return False
if device is not None and str(device) == "cpu":
return False
return True
return current_platform.is_pin_memory_available(device)
def get_dispatch_device_backend():