diff --git a/python/sglang/srt/mem_cache/memory_pool_host.py b/python/sglang/srt/mem_cache/memory_pool_host.py index a872e24ea..d5d9d5655 100644 --- a/python/sglang/srt/mem_cache/memory_pool_host.py +++ b/python/sglang/srt/mem_cache/memory_pool_host.py @@ -187,9 +187,11 @@ def alloc_with_host_register( """ buffer = allocator.allocate(dims, dtype=dtype, device=device) if pin_memory: - torch.cuda.cudart().cudaHostRegister( + ret = torch.cuda.cudart().cudaHostRegister( buffer.data_ptr(), buffer.numel() * buffer.element_size(), 0 ) + if ret != 0: + raise RuntimeError(f"cudaHostRegister failed with error code {ret}") return buffer