From b89fbe00bffbe62f70b7fb35aa7615a18f22a772 Mon Sep 17 00:00:00 2001 From: Joe Runde Date: Mon, 9 Dec 2024 14:39:33 -0700 Subject: [PATCH] :bug: backport request id validation to v0 Signed-off-by: Joe Runde --- vllm/engine/multiprocessing/client.py | 4 ++++ vllm/v1/engine/async_llm.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/vllm/engine/multiprocessing/client.py b/vllm/engine/multiprocessing/client.py index 7e4f81b2cf8e2..df47e8f5f49eb 100644 --- a/vllm/engine/multiprocessing/client.py +++ b/vllm/engine/multiprocessing/client.py @@ -576,6 +576,10 @@ async def _process_request( if self._errored_with is not None: raise ENGINE_DEAD_ERROR(self._errored_with) + # Ensure the request id is unique among running requests + if request_id in self.output_queues: + raise ValueError(f"Request {request_id} already exists") + # Constructing guided decoding logits processors is expensive, so we do # it here to avoid contending with cpu resources and the GIL on the # backend process. diff --git a/vllm/v1/engine/async_llm.py b/vllm/v1/engine/async_llm.py index 0bcccda2bf329..e96d76ab757e8 100644 --- a/vllm/v1/engine/async_llm.py +++ b/vllm/v1/engine/async_llm.py @@ -142,7 +142,7 @@ async def add_request( """Add new request to the AsyncLLM.""" if self.detokenizer.is_request_active(request_id): - raise KeyError(f"Request {request_id} already exists.") + raise ValueError(f"Request {request_id} already exists.") # 1) Create a new AsyncStream for the request. stream = self._add_request_to_streams(request_id)