From 18a27cc9a3641cc1dd3eae5113b75c7ccc029b5f Mon Sep 17 00:00:00 2001 From: qizixi <22851944+zixi-qi@users.noreply.github.com> Date: Thu, 21 May 2026 20:36:22 -0700 Subject: [PATCH] [Bugfix] Make CuMemAllocator free callback stream-aware (#43020) Signed-off-by: zixi-qi Co-authored-by: Claude --- vllm/device_allocator/cumem.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vllm/device_allocator/cumem.py b/vllm/device_allocator/cumem.py index b2202b7d08..6edd69a949 100644 --- a/vllm/device_allocator/cumem.py +++ b/vllm/device_allocator/cumem.py @@ -160,6 +160,12 @@ class CuMemAllocator: data = self.pointer_to_data.pop(ptr) if data.cpu_backup_tensor is not None: data.cpu_backup_tensor = None + # Drain pending kernels before the C extension's cuMemUnmap. + # The pluggable allocator path doesn't defer reclaim like the + # regular caching allocator, so without this, in-flight work + # (e.g. quant helpers' transient tensors during weight loading) + # races the unmap and surfaces as CUDA_ERROR_ILLEGAL_ADDRESS. + torch.cuda.synchronize(data.handle[0]) logger.debug( "Freed %s bytes for %s with address %s from cumem allocator", data.handle[1],