From 2ced88238aed99b8709ce15e207b1c39dcf9a397 Mon Sep 17 00:00:00 2001 From: gjsheu Date: Tue, 14 Jul 2026 14:16:24 +0800 Subject: [PATCH] [NPU] [BUGFIX] Fix input parameters of swiglu_oai operator (#30458) --- python/sglang/srt/layers/quantization/unquant.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/python/sglang/srt/layers/quantization/unquant.py b/python/sglang/srt/layers/quantization/unquant.py index 82a3d77f0..10da8b562 100644 --- a/python/sglang/srt/layers/quantization/unquant.py +++ b/python/sglang/srt/layers/quantization/unquant.py @@ -769,9 +769,20 @@ class UnquantizedFusedMoEMethod(FusedMoEMethodBase, MultiPlatformOp): # act_fn: if self.moe_runner_config.activation == "npu_swiglu_oai": - from sgl_kernel_npu.activation.swiglu_oai import swiglu_oai + from sgl_kernel_npu.activation.swiglu_oai import swiglu_oai_triton - hidden_states = swiglu_oai(layer, hidden_states) + # `hidden_states` is the gmm1 output of shape [num_tokens, 2 * inter]. + # Pass the gate_up dim from the activation itself instead of letting + # swiglu_oai() derive it from layer.w13_weight.shape[2]: w13_weight is + # now stored un-transposed (transposed on the fly for the grouped + # matmuls above), so shape[2] is `hidden`, not the gate_up dim, which + # makes the kernel's view(-1, dim) reshape fail. + hidden_states = swiglu_oai_triton( + hidden_states, + hidden_states.shape[-1], + self.moe_runner_config.gemm1_alpha, + self.moe_runner_config.gemm1_clamp_limit, + ) elif self.moe_runner_config.activation == "silu": if self.moe_runner_config.gemm1_clamp_limit is not None: from sgl_kernel_npu.activation.swiglu_quant import swiglu_quant