diff --git a/python/sglang/srt/hardware_backend/npu/moe/topk.py b/python/sglang/srt/hardware_backend/npu/moe/topk.py index d59498038..ffe772b04 100644 --- a/python/sglang/srt/hardware_backend/npu/moe/topk.py +++ b/python/sglang/srt/hardware_backend/npu/moe/topk.py @@ -98,7 +98,7 @@ def fused_topk_npu( group_select_mode=(1 if use_grouped_topk else 0), renorm=0, # 1 for sigmoid, 0 for softmax - norm_type=1, + norm_type=(0 if topk_config.scoring_func == "softmax" else 1), routed_scaling_factor=( topk_config.routed_scaling_factor if topk_config.apply_routed_scaling_factor_on_output diff --git a/python/sglang/srt/models/glm4_moe_lite.py b/python/sglang/srt/models/glm4_moe_lite.py index c650585a5..68f9dea7c 100644 --- a/python/sglang/srt/models/glm4_moe_lite.py +++ b/python/sglang/srt/models/glm4_moe_lite.py @@ -85,12 +85,14 @@ from sglang.srt.utils import ( LazyValue, add_prefix, is_non_idle_and_non_empty, + is_npu, log_info_on_rank0, make_layers, ) from sglang.srt.utils.hf_transformers_utils import get_rope_config logger = logging.getLogger(__name__) +_is_npu = is_npu() class Glm4MoeLiteMLP(nn.Module): @@ -242,6 +244,7 @@ class Glm4MoeLiteSparseMoeBlock(nn.Module): # Some Fp4 MoE backends require the output format to be bypassed but the MTP layers are unquantized # and requires the output format to be standard. We use quant_config to determine the output format. output_format=TopKOutputFormat.STANDARD if quant_config is None else None, + **({"scoring_func": "sigmoid"} if _is_npu else {}), ) self.shared_experts_is_int8 = False