From 67b2a9ed0cfba8ec625d3f26548e502646fd914d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9C=8B=E6=B5=B7=E7=9A=84=E4=BA=BA?= <37328560+zhsurpass@users.noreply.github.com> Date: Thu, 25 Jun 2026 09:14:32 +0800 Subject: [PATCH] [NPU] Fix the DeepSeek-V2-Coder model accuracy issue (#29042) --- python/sglang/srt/hardware_backend/npu/moe/topk.py | 3 ++- python/sglang/srt/models/deepseek_v2.py | 1 + python/sglang/srt/models/llada2.py | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/python/sglang/srt/hardware_backend/npu/moe/topk.py b/python/sglang/srt/hardware_backend/npu/moe/topk.py index 887c25a21..2ed6bae45 100644 --- a/python/sglang/srt/hardware_backend/npu/moe/topk.py +++ b/python/sglang/srt/hardware_backend/npu/moe/topk.py @@ -83,7 +83,8 @@ def fused_topk_npu( group_count=topk_config.num_expert_group if use_grouped_topk else 1, group_select_mode=(1 if use_grouped_topk else 0), renorm=0, - norm_type=1, # 1 for sigmoid, 0 for softmax + # 1 for sigmoid, 0 for softmax + norm_type=(0 if topk_config.scoring_func == "softmax" else 1), routed_scaling_factor=( 1 if renormalize else topk_config.routed_scaling_factor ), diff --git a/python/sglang/srt/models/deepseek_v2.py b/python/sglang/srt/models/deepseek_v2.py index 46e162e9a..e6663cc51 100644 --- a/python/sglang/srt/models/deepseek_v2.py +++ b/python/sglang/srt/models/deepseek_v2.py @@ -658,6 +658,7 @@ class DeepseekV2MoE(nn.Module): num_expert_group=config.n_group, num_fused_shared_experts=self.num_fused_shared_experts, topk_group=config.topk_group, + scoring_func=config.scoring_func, correction_bias=self.gate.e_score_correction_bias, quant_config=quant_config, routed_scaling_factor=self.routed_scaling_factor, diff --git a/python/sglang/srt/models/llada2.py b/python/sglang/srt/models/llada2.py index fafde609d..2c0601dac 100644 --- a/python/sglang/srt/models/llada2.py +++ b/python/sglang/srt/models/llada2.py @@ -262,6 +262,7 @@ class LLaDA2MoeSparseMoeBlock(nn.Module): # num_fused_shared_experts=self.num_fused_shared_experts, topk_group=self.topk_group, correction_bias=self.correction_bias, + scoring_func=self.score_function, routed_scaling_factor=self.routed_scaling_factor, )