From 41a113356aade1e5f2fddf567d8d8da402a2f37a Mon Sep 17 00:00:00 2001 From: Shangming Cai Date: Tue, 28 Oct 2025 16:29:02 +0800 Subject: [PATCH] Fix potential eos bug on decode instance when PD is enabled (#12206) Signed-off-by: Shangming Cai --- python/sglang/srt/disaggregation/decode.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/python/sglang/srt/disaggregation/decode.py b/python/sglang/srt/disaggregation/decode.py index 840778ac2..15fd10467 100644 --- a/python/sglang/srt/disaggregation/decode.py +++ b/python/sglang/srt/disaggregation/decode.py @@ -773,8 +773,12 @@ class DecodeTransferQueue: indices_to_remove.add(i) decode_req.req.time_stats.wait_queue_entry_time = time.perf_counter() - # special handling for sampling_params.max_new_tokens == 1 - if decode_req.req.sampling_params.max_new_tokens == 1: + # special handling for corner cases + should_finish = ( + decode_req.req.sampling_params.max_new_tokens == 1 + or output_id in decode_req.req.eos_token_ids + ) + if should_finish: # finish immediately decode_req.req.time_stats.forward_entry_time = ( decode_req.req.time_stats.completion_time