From 09e9c4fde3b4326c4a66fbb014d9c7a6b8995b30 Mon Sep 17 00:00:00 2001 From: littleyellowbicycle <1021593619@qq.com> Date: Mon, 15 Jun 2026 21:31:39 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90bugfix=E3=80=91The=20NPU's=20forward?= =?UTF-8?q?=5Fdsa=5Fprepare=5Fnpu=20also=20needs=20special=20handling=20fo?= =?UTF-8?q?r=20is=5Fnextn=20(#28118)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../npu/modules/deepseek_v2_attention_mla_npu.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/sglang/srt/hardware_backend/npu/modules/deepseek_v2_attention_mla_npu.py b/python/sglang/srt/hardware_backend/npu/modules/deepseek_v2_attention_mla_npu.py index 24fbb4708..21c6f6e16 100644 --- a/python/sglang/srt/hardware_backend/npu/modules/deepseek_v2_attention_mla_npu.py +++ b/python/sglang/srt/hardware_backend/npu/modules/deepseek_v2_attention_mla_npu.py @@ -403,9 +403,7 @@ def forward_dsa_prepare_npu( latent_cache, forward_batch, k_nope, k_pe ) - if m.skip_topk: - topk_indices = prev_topk_indices - else: + if not m.skip_topk or (m.is_nextn and prev_topk_indices is None): topk_indices = m.indexer( hidden_states, q_lora, @@ -415,6 +413,8 @@ def forward_dsa_prepare_npu( layer_scatter_modes, dynamic_scale, ) + else: + topk_indices = prev_topk_indices return ( q_pe,