Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 31 additions & 12 deletions vllm/model_executor/layers/fused_moe/experts/triton_moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,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.moe_align_block_size import (
moe_align_block_size,
)
Expand Down Expand Up @@ -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 self.block_shape == [128, 128]
Comment thread
qianlihuang marked this conversation as resolved.
Resolved
and lora_context is None
and not is_deep_gemm_e8m0_used()
):
Comment thread
qianlihuang marked this conversation as resolved.
Resolved
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(),
)
Comment thread
qianlihuang marked this conversation as resolved.
Resolved
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,
Expand Down
Loading