From 2d088b85d936cbb4375ae032589f0615adcfca60 Mon Sep 17 00:00:00 2001 From: YAMY <74099316+YAMY1234@users.noreply.github.com> Date: Sat, 10 Jan 2026 02:14:30 -0800 Subject: [PATCH] [IDLE FORWARD][Indexer] Fix forward_idle bs mismatch issue in DeepseekV3.2's NSAIndexer (#15227) --- python/sglang/srt/model_executor/model_runner.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/sglang/srt/model_executor/model_runner.py b/python/sglang/srt/model_executor/model_runner.py index ac7c44569..677d71d8c 100644 --- a/python/sglang/srt/model_executor/model_runner.py +++ b/python/sglang/srt/model_executor/model_runner.py @@ -2164,6 +2164,12 @@ class ModelRunner(ModelRunnerKVCacheMixin): def forward_idle( self, forward_batch: ForwardBatch, pp_proxy_tensors=None ) -> Union[LogitsProcessorOutput, PPProxyTensors]: + # In DP Attention, IDLE batches are padded (batch_size > 0) for MLP sync. + # in this case, we need to reinit the forward metadata, otherwise the stale + # metadata causes batch_size mismatch in attention kernel(e.g. NSA Indexer). + if forward_batch.batch_size > 0: + self.attn_backend.init_forward_metadata(forward_batch) + kwargs = {} if self.support_pp: kwargs["pp_proxy_tensors"] = pp_proxy_tensors