From 31a6bfa216ff89e7b829e5b25fe3e3bb327083c2 Mon Sep 17 00:00:00 2001 From: qianlihuang Date: Wed, 13 May 2026 14:21:10 +0800 Subject: [PATCH 1/3] using fused kernel Signed-off-by: qianlihuang --- .../layers/fused_moe/experts/triton_moe.py | 43 +++++++++++++------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/vllm/model_executor/layers/fused_moe/experts/triton_moe.py b/vllm/model_executor/layers/fused_moe/experts/triton_moe.py index e99f307ec0ec..a03ccba43313 100644 --- a/vllm/model_executor/layers/fused_moe/experts/triton_moe.py +++ b/vllm/model_executor/layers/fused_moe/experts/triton_moe.py @@ -18,6 +18,9 @@ invoke_fused_moe_wna16_triton_kernel, try_get_optimal_moe_config, ) +from vllm.model_executor.layers.quantization.utils.fp8_utils import ( + is_deep_gemm_e8m0_used, +) from vllm.model_executor.layers.fused_moe.lora_experts_mixin import ( LoRAExpertsMixin, ) @@ -283,20 +286,36 @@ def apply( top_k_num=top_k_num, ) - self.activation( - activation, intermediate_cache2, intermediate_cache1.view(-1, N) - ) - a2q_scale: torch.Tensor | None = None - qintermediate_cache2, a2q_scale = moe_kernel_quantize_input( - intermediate_cache2, - a2_scale, - self.quant_dtype, - self.per_act_token_quant, - self.block_shape, - quantization_emulation=self.quantization_emulation, - ) + # Fuse SiLU+Mul + FP8 block quantize into a single kernel + # when conditions permit (gated SiLU, fp8 block quant with + # group_size=128, no LoRA requiring the BF16 intermediate). + if ( + activation == MoEActivation.SILU + and self.quant_config.use_fp8_w8a8 + and list(self.block_shape) == [128, 128] + and lora_context is None + and not is_deep_gemm_e8m0_used() + ): + qintermediate_cache2, a2q_scale = ops.silu_and_mul_per_block_quant( + intermediate_cache1.view(-1, N), + group_size=128, + quant_dtype=current_platform.fp8_dtype(), + ) + else: + self.activation( + activation, intermediate_cache2, intermediate_cache1.view(-1, N) + ) + + qintermediate_cache2, a2q_scale = moe_kernel_quantize_input( + intermediate_cache2, + a2_scale, + self.quant_dtype, + self.per_act_token_quant, + self.block_shape, + quantization_emulation=self.quantization_emulation, + ) invoke_fused_moe_triton_kernel( qintermediate_cache2, From 051b391437fdf6c3ac25e1baec3b1384aeee3cbf Mon Sep 17 00:00:00 2001 From: qianlihuang Date: Thu, 14 May 2026 11:06:33 +0800 Subject: [PATCH 2/3] fix Signed-off-by: qianlihuang --- vllm/model_executor/layers/fused_moe/experts/triton_moe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vllm/model_executor/layers/fused_moe/experts/triton_moe.py b/vllm/model_executor/layers/fused_moe/experts/triton_moe.py index 3113b11709e2..2e546a4abdb1 100644 --- a/vllm/model_executor/layers/fused_moe/experts/triton_moe.py +++ b/vllm/model_executor/layers/fused_moe/experts/triton_moe.py @@ -294,7 +294,7 @@ def apply( if ( activation == MoEActivation.SILU and self.quant_config.use_fp8_w8a8 - and list(self.block_shape) == [128, 128] + and self.block_shape == [128, 128] and lora_context is None and not is_deep_gemm_e8m0_used() ): From f9f71831eadafdea10413f026e0e84b2f6720303 Mon Sep 17 00:00:00 2001 From: qianlihuang Date: Fri, 15 May 2026 10:28:56 +0800 Subject: [PATCH 3/3] reorder imports Signed-off-by: qianlihuang --- vllm/model_executor/layers/fused_moe/experts/triton_moe.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vllm/model_executor/layers/fused_moe/experts/triton_moe.py b/vllm/model_executor/layers/fused_moe/experts/triton_moe.py index 2e546a4abdb1..442f5aa1273e 100644 --- a/vllm/model_executor/layers/fused_moe/experts/triton_moe.py +++ b/vllm/model_executor/layers/fused_moe/experts/triton_moe.py @@ -21,9 +21,6 @@ invoke_fused_moe_wna16_triton_kernel, try_get_optimal_moe_config, ) -from vllm.model_executor.layers.quantization.utils.fp8_utils import ( - is_deep_gemm_e8m0_used, -) from vllm.model_executor.layers.fused_moe.moe_align_block_size import ( moe_align_block_size, ) @@ -34,6 +31,9 @@ _resize_cache, moe_kernel_quantize_input, ) +from vllm.model_executor.layers.quantization.utils.fp8_utils import ( + is_deep_gemm_e8m0_used, +) from vllm.model_executor.layers.quantization.utils.quant_utils import ( QuantKey, kFp8Dynamic128Sym,