From e1f0835ae0c784a56bbbb060b2e7c9842dbe7696 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Fri, 7 Mar 2025 20:36:16 +0000 Subject: [PATCH] [V1][Metrics] Fix traceback with preemptions+LoRA (#14220) Signed-off-by: Mark McLoughlin --- vllm/v1/metrics/stats.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vllm/v1/metrics/stats.py b/vllm/v1/metrics/stats.py index 14ec7d2d7463f..36317fc9aeee7 100644 --- a/vllm/v1/metrics/stats.py +++ b/vllm/v1/metrics/stats.py @@ -150,6 +150,7 @@ class IterationStats: LoRARequestStates.scheduled_request(lora_stats, req_id) elif event.type == EngineCoreEventType.PREEMPTED: self.num_preempted_reqs += 1 + LoRARequestStates.preempted_request(lora_stats, req_id) def update_from_finished_request(self, finish_reason: "FinishReason", num_prompt_tokens: int, @@ -224,6 +225,13 @@ class LoRARequestStates: lora_stats.waiting_requests.remove(request_id) lora_stats.running_requests.add(request_id) + @staticmethod + def preempted_request(lora_stats: Optional[LoRAStats], request_id: str): + if lora_stats is None: + return + lora_stats.running_requests.remove(request_id) + lora_stats.waiting_requests.add(request_id) + def update_iteration_stats(self, iteration_stats: Optional[IterationStats]): if iteration_stats is None: