From 6a6b36367e16c44e0e1a22094baeb36ff79e3d99 Mon Sep 17 00:00:00 2001 From: Cheng Wan <54331508+ch-wan@users.noreply.github.com> Date: Thu, 29 Jan 2026 15:14:43 -0800 Subject: [PATCH] Fix logprob_start_len handling for prefill-only requests (#17395) --- python/sglang/srt/managers/scheduler.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/sglang/srt/managers/scheduler.py b/python/sglang/srt/managers/scheduler.py index af16c8192..3a06f92d9 100644 --- a/python/sglang/srt/managers/scheduler.py +++ b/python/sglang/srt/managers/scheduler.py @@ -1545,13 +1545,13 @@ class Scheduler( recv_req.logprob_start_len = -1 if recv_req.logprob_start_len == -1: - if req.is_prefill_only: + if recv_req.return_logprob: + # If return_logprob is True, return the logprobs for output tokens by default + req.logprob_start_len = len(req.origin_input_ids) - 1 + elif req.is_prefill_only: # For prefill-only requests with logprob_start_len == -1, set logprob_start_len # beyond input sequence to skip input logprob computation entirely req.logprob_start_len = len(req.origin_input_ids) - elif recv_req.return_logprob: - # If return_logprob is True, return the logprobs for output tokens by default - req.logprob_start_len = len(req.origin_input_ids) - 1 else: # If return_logprob is False, only the last token requires logprob computation req.logprob_start_len = -1