From 45cf57585262981ce42cfba63afc7ed2bb65c47a Mon Sep 17 00:00:00 2001 From: fzyzcjy <5236035+fzyzcjy@users.noreply.github.com> Date: Fri, 28 Nov 2025 18:15:56 +0800 Subject: [PATCH] Fix overlap scheduler not take effect when outputing logprobs (#14096) --- python/sglang/srt/managers/scheduler.py | 4 ++-- python/sglang/srt/managers/utils.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python/sglang/srt/managers/scheduler.py b/python/sglang/srt/managers/scheduler.py index 45c724e4f..30f754581 100644 --- a/python/sglang/srt/managers/scheduler.py +++ b/python/sglang/srt/managers/scheduler.py @@ -2003,7 +2003,7 @@ class Scheduler( ).Event() if batch_result.delay_sample_func is None: self.future_map.store_to_map(future_indices, batch_result) - batch_result.copy_to_cpu() + batch_result.copy_to_cpu(return_logprob=batch.return_logprob) else: batch_result.future_indices = future_indices @@ -2087,7 +2087,7 @@ class Scheduler( _batch_result = batch_result.delay_sample_func() assert _batch_result is batch_result self.future_map.store_to_map(batch_result.future_indices, batch_result) - batch_result.copy_to_cpu() + batch_result.copy_to_cpu(return_logprob=self.cur_batch.return_logprob) def process_batch_result( self, diff --git a/python/sglang/srt/managers/utils.py b/python/sglang/srt/managers/utils.py index 640994e70..5df932295 100644 --- a/python/sglang/srt/managers/utils.py +++ b/python/sglang/srt/managers/utils.py @@ -43,15 +43,15 @@ class GenerationBatchResult: # relay path: forward stream -> next step forward next_draft_input: Optional[EagleDraftInput] = None - def copy_to_cpu(self, return_logprob: bool = False): + def copy_to_cpu(self, return_logprob: bool): """Copy tensors to CPU in overlap scheduling. Only the tensors which are needed for processing results are copied, e.g., next_token_ids, logits outputs """ if return_logprob: - if self.logits_output.next_token_logits is not None: - self.logits_output.next_token_logits = ( - self.logits_output.next_token_logits.to("cpu", non_blocking=True) + if self.logits_output.next_token_logprobs is not None: + self.logits_output.next_token_logprobs = ( + self.logits_output.next_token_logprobs.to("cpu", non_blocking=True) ) if self.logits_output.input_token_logprobs is not None: self.logits_output.input_token_logprobs = (