mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-05-25 14:17:57 +08:00
[Bugfix] Add strong reference to CUDA pluggable allocator callbacks (#23477)
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com> Signed-off-by: youkaichao <youkaichao@gmail.com> Co-authored-by: Eric Marcus <eric.marcus@kaiko.ai> Co-authored-by: youkaichao <youkaichao@gmail.com>
This commit is contained in:
parent
053278a5dc
commit
9dc30b7068
@ -152,8 +152,13 @@ class CuMemAllocator:
|
|||||||
self.pointer_to_data: dict[int, AllocationData] = {}
|
self.pointer_to_data: dict[int, AllocationData] = {}
|
||||||
self.current_tag: str = CuMemAllocator.default_tag
|
self.current_tag: str = CuMemAllocator.default_tag
|
||||||
self.allocator_and_pools: dict[str, Any] = {}
|
self.allocator_and_pools: dict[str, Any] = {}
|
||||||
|
# Creating strong references to the two callbacks here to prevent
|
||||||
|
# these ephemeral bound-method objects being garbage collected.
|
||||||
|
# See discussions in https://github.com/vllm-project/vllm/pull/22724
|
||||||
|
self.python_malloc_callback = self._python_malloc_callback
|
||||||
|
self.python_free_callback = self._python_free_callback
|
||||||
|
|
||||||
def python_malloc_callback(self, allocation_handle: HandleType) -> None:
|
def _python_malloc_callback(self, allocation_handle: HandleType) -> None:
|
||||||
"""
|
"""
|
||||||
Internal method to store the allocation data
|
Internal method to store the allocation data
|
||||||
when memory is allocated in the memory pool."""
|
when memory is allocated in the memory pool."""
|
||||||
@ -162,7 +167,7 @@ class CuMemAllocator:
|
|||||||
allocation_handle, self.current_tag)
|
allocation_handle, self.current_tag)
|
||||||
return
|
return
|
||||||
|
|
||||||
def python_free_callback(self, ptr: int) -> HandleType:
|
def _python_free_callback(self, ptr: int) -> HandleType:
|
||||||
"""
|
"""
|
||||||
Internal method to look up the allocation data
|
Internal method to look up the allocation data
|
||||||
when memory is freed in the memory pool."""
|
when memory is freed in the memory pool."""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user