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