From 6167c0e5d2a18fb4c4d14be3b4e9f5e35b712b76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=87?= Date: Thu, 24 Apr 2025 11:25:37 +0800 Subject: [PATCH] =?UTF-8?q?[Bugfix][Core]=20add=20seq=5Fid=5Fto=5Fseq=5Fgr?= =?UTF-8?q?oup=20clearing=20to=20avoid=20memory=20leak=20when=20s=E2=80=A6?= =?UTF-8?q?=20(#16472)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 开哲 Co-authored-by: 开哲 --- vllm/outputs.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vllm/outputs.py b/vllm/outputs.py index c8b9be5424e4b..65a6ed01451dd 100644 --- a/vllm/outputs.py +++ b/vllm/outputs.py @@ -179,6 +179,13 @@ class RequestOutput: group.finish_seq(seq_group) if assembled_seq_group is None: return None + + # clear finished seq in seq_id_to_seq_group + if len(group.to_be_finished) == 0: + for sub_request_id in list(group.seq_id_to_index.keys()): + if sub_request_id in seq_id_to_seq_group: + del seq_id_to_seq_group[sub_request_id] + return cls.from_seq_group(assembled_seq_group, use_cache, seq_id_to_seq_group)