[ROCm][Engine] Fix GPU memory leaks in engine shutdown and test workaround for async KV prefix cache reset (#38503)

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
This commit is contained in:
Andreas Karatzas
2026-04-25 05:25:20 +00:00
committed by GitHub
parent 07351e0883
commit 95995bbef8
8 changed files with 300 additions and 13 deletions
+7
View File
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import gc
import os
import queue
import signal
@@ -574,6 +575,12 @@ class EngineCore:
if self.scheduler:
self.scheduler.shutdown()
# Undo the gc.freeze() from __init__ so that the objects allocated
# during engine startup (model weights, KV caches, etc.) become
# visible to the garbage collector again. Without this, deleting
# the engine in-process (e.g. unit tests) leaks GPU memory.
gc.unfreeze()
def profile(self, is_start: bool = True, profile_prefix: str | None = None):
self.model_executor.profile(is_start, profile_prefix)