Skip to content

Commit 25f53c4

Browse files
22quinnEricMarcus-aiyoukaichao
committed
gc fix
Signed-off-by: 22quinn <33176974+22quinn@users.noreply.github.com> Co-authored-by: Eric Marcus <eric.marcus@kaiko.ai> Co-authored-by: youkaichao <youkaichao@gmail.com>
1 parent 65197a5 commit 25f53c4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

vllm/device_allocator/cumem.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ def __init__(self):
152152
self.pointer_to_data: dict[int, AllocationData] = {}
153153
self.current_tag: str = CuMemAllocator.default_tag
154154
self.allocator_and_pools: dict[str, Any] = {}
155+
self.python_malloc_callback_ref = self.python_malloc_callback
156+
self.python_free_callback_ref = self.python_free_callback
155157

156158
def python_malloc_callback(self, allocation_handle: HandleType) -> None:
157159
"""
@@ -212,9 +214,9 @@ def sleep(
212214
def wake_up(self, tags: Optional[list[str]] = None) -> None:
213215
"""
214216
Wake up the allocator from sleep mode.
215-
All data that is previously offloaded will be loaded back to GPU
217+
All data that is previously offloaded will be loaded back to GPU
216218
memory, and the rest of the data will have empty memory.
217-
219+
218220
:param tags: The tags of the memory allocation that will be loaded
219221
back to GPU memory. If None, all memory allocation will be loaded
220222
back to GPU memory.
@@ -249,8 +251,9 @@ def use_memory_pool(self, tag: Optional[str] = None):
249251

250252
old_tag = self.current_tag
251253
self.current_tag = tag
252-
with use_memory_pool_with_allocator(self.python_malloc_callback,
253-
self.python_free_callback) as data:
254+
with use_memory_pool_with_allocator(
255+
self.python_malloc_callback_ref,
256+
self.python_free_callback_ref) as data:
254257
# start to hit another PyTorch bug in PyTorch 2.6,
255258
# possibly because of gc-related issue w.r.t. the allocator and
256259
# the memory pool.

0 commit comments

Comments
 (0)