From 201ddeaba1462504d1fb7384436f843b530a4a54 Mon Sep 17 00:00:00 2001 From: fzyzcjy <5236035+fzyzcjy@users.noreply.github.com> Date: Wed, 15 Jul 2026 14:33:37 +0800 Subject: [PATCH] Avoid relaying per-step outputs through ScheduleBatch fields in disagg prefill and PP (#30677) --- python/sglang/srt/disaggregation/prefill.py | 10 ++++++---- python/sglang/srt/managers/scheduler_pp_mixin.py | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/python/sglang/srt/disaggregation/prefill.py b/python/sglang/srt/disaggregation/prefill.py index d8036d36f..7892ac940 100644 --- a/python/sglang/srt/disaggregation/prefill.py +++ b/python/sglang/srt/disaggregation/prefill.py @@ -620,6 +620,8 @@ class SchedulerDisaggregationPrefillMixin: result.indexer_topk_output = None logprob_pt = 0 + assert batch.spec_info is result.next_draft_input + draft_input = result.next_draft_input # Transfer kv for prefill completed requests and add it into disagg_prefill_inflight_queue next_token_ids = result.next_token_ids.tolist() self.batch_result_processor.move_logprobs_to_cpu( @@ -651,11 +653,11 @@ class SchedulerDisaggregationPrefillMixin: req.output_ids.append(next_token_id) maybe_cache_unfinished_req(req, self.tree_cache) self.disagg_prefill_inflight_queue.append(req) - if self.spec_algorithm.is_eagle() and batch.spec_info is not None: - req.output_topk_p = batch.spec_info.topk_p[i] - req.output_topk_index = batch.spec_info.topk_index[i] + if self.spec_algorithm.is_eagle() and draft_input is not None: + req.output_topk_p = draft_input.topk_p[i] + req.output_topk_index = draft_input.topk_index[i] req.hidden_states_tensor = ( - batch.spec_info.hidden_states[i].cpu().clone() + draft_input.hidden_states[i].cpu().clone() ) dsa_topk_indices = batch.spec_info.dsa_topk_indices if dsa_topk_indices is not None: diff --git a/python/sglang/srt/managers/scheduler_pp_mixin.py b/python/sglang/srt/managers/scheduler_pp_mixin.py index 30b5bf43e..ff440de77 100644 --- a/python/sglang/srt/managers/scheduler_pp_mixin.py +++ b/python/sglang/srt/managers/scheduler_pp_mixin.py @@ -1101,7 +1101,6 @@ class SchedulerPPMixin: # next_pp_outputs = None so non-last ranks skip forwarding # (pp_outputs is None gate). Placeholder carried in # batch_result.next_token_ids for process_batch_result_prefill. - batch.output_ids = placeholder batch_result = GenerationBatchResult( logits_output=None, pp_hidden_states_proxy_tensors=None, @@ -1133,13 +1132,14 @@ class SchedulerPPMixin: extend_input_len_per_req, extend_logprob_start_len_per_req, ) = get_logprob_from_pp_outputs(pp_outputs) - batch.input_ids = pp_outputs["next_token_ids"].to(torch.int64) + next_token_ids = pp_outputs["next_token_ids"].to(torch.int64) # PP rank 0 also relays into output_tokens_buf so the next iter's # resolve_forward_inputs finds these tokens for the decode portion # of mixed-chunk batches (which gather via mix_running_indices). self.future_map.stash( - batch.req_pool_indices, RelayPayload(bonus_tokens=batch.input_ids) + batch.req_pool_indices, RelayPayload(bonus_tokens=next_token_ids) ) + batch.input_ids = None output_result = GenerationBatchResult( logits_output=logits_output, pp_hidden_states_proxy_tensors=None,