From 1aee04e7df7da92b1ae5b89398755a24dab287ff Mon Sep 17 00:00:00 2001 From: Rahul Vijayaraghavan Date: Wed, 29 Apr 2026 08:14:48 +0530 Subject: [PATCH] [XPU] Support apply_router_weight_on_input for Llama4 for fused_experts (#22654) merge this one as it is xpu only change. --- python/sglang/srt/layers/quantization/unquant.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/sglang/srt/layers/quantization/unquant.py b/python/sglang/srt/layers/quantization/unquant.py index 1ade4ed9e..6bc946f71 100644 --- a/python/sglang/srt/layers/quantization/unquant.py +++ b/python/sglang/srt/layers/quantization/unquant.py @@ -584,6 +584,9 @@ class UnquantizedFusedMoEMethod(FusedMoEMethodBase, MultiPlatformOp): from sgl_kernel import fused_experts topk_weights, topk_ids, _ = topk_output + if moe_runner_config.apply_router_weight_on_input: + x = x * topk_weights.to(x.dtype) + topk_weights = torch.ones_like(topk_weights) output = fused_experts( x, layer.w13_weight,