From 22d33baca2c0c639cfd45c48e99803e56c3efa74 Mon Sep 17 00:00:00 2001 From: Nick Hill Date: Wed, 19 Mar 2025 14:04:41 -0700 Subject: [PATCH] [FrontEnd][Perf] `merge_async_iterators` fast-path for single-prompt requests (#15150) Signed-off-by: Nick Hill --- vllm/utils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vllm/utils.py b/vllm/utils.py index 79787303af5bc..9bc081890bcb7 100644 --- a/vllm/utils.py +++ b/vllm/utils.py @@ -411,6 +411,11 @@ async def merge_async_iterators( When it yields, it yields a tuple (i, item) where i is the index of the iterator that yields the item. """ + if len(iterators) == 1: + # Fast-path single iterator case. + async for item in iterators[0]: + yield 0, item + return loop = asyncio.get_running_loop()