Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .sync/vllm-sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
82ae4164ee016d4daecd2033c26f5c0827984a80
5233368daccd3d84293bab7b04bacae1433ea0e4
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,15 @@ def __init__(
self.quantization_emulation = True

if self.ocp_mx_scheme in {
OCP_MX_Scheme.w_mxfp4,
OCP_MX_Scheme.w_mxfp6_e3m2,
OCP_MX_Scheme.w_mxfp6_e2m3,
}:
# Weight-only schemes leave activations unquantized.
self._quant_dtype = None
elif self.ocp_mx_scheme in {
OCP_MX_Scheme.w_mxfp4_a_mxfp4,
}:
# Weight has to be dequantized for mxfp4 emulation.
self._quant_dtype = "mxfp4"
elif self.ocp_mx_scheme in [
OCP_MX_Scheme.w_mxfp4_a_mxfp6_e3m2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def _supports_activation(activation: MoEActivation) -> bool:
MoEActivation.SILU,
MoEActivation.GELU,
MoEActivation.GELU_TANH,
MoEActivation.SITU,
MoEActivation.SWIGLUOAI,
MoEActivation.SWIGLUOAI_UNINTERLEAVE,
MoEActivation.SWIGLUSTEP,
Expand Down
15 changes: 11 additions & 4 deletions aphrodite/model_executor/layers/fused_moe/oracle/mxfp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,10 @@ def _get_priority_backends() -> list[Mxfp4MoeBackend]:
backend-level ``is_supported_config`` check filters by device capability).
"""
if current_platform.is_rocm():
return [Mxfp4MoeBackend.AITER_MXFP4_BF16]
return [
Mxfp4MoeBackend.AITER_MXFP4_BF16,
Mxfp4MoeBackend.EMULATION,
]
if current_platform.is_xpu():
return [Mxfp4MoeBackend.XPU]
_AVAILABLE_BACKENDS = [
Expand Down Expand Up @@ -1091,8 +1094,12 @@ def swap_every_two_rows(x, axis=-1):
w13_bias,
w2_bias,
)
elif mxfp4_backend == Mxfp4MoeBackend.XPU:
# No additional transformation needed for XPU backend
elif mxfp4_backend in (
Mxfp4MoeBackend.XPU,
Mxfp4MoeBackend.EMULATION,
):
# No additional transformation is needed: XPU consumes the checkpoint
# layout directly, while emulation dequantizes that layout at runtime.
return (
w13_weight,
w2_weight,
Expand Down Expand Up @@ -1460,7 +1467,7 @@ def shuffle_weight(w: torch.Tensor) -> torch.Tensor:
else:
raise ValueError(
f"Unsupported mxfp4_backend for Mxfp4MoEMethod: {mxfp4_backend}. "
f"Expected TRTLLM, Triton, AITER, or XPU backend."
f"Expected TRTLLM, Triton, AITER, XPU, or emulation backend."
)


Expand Down
15 changes: 15 additions & 0 deletions aphrodite/model_executor/layers/quantization/mxfp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
SharedExperts,
)
from aphrodite.model_executor.layers.fused_moe import modular_kernel as mk
from aphrodite.model_executor.layers.fused_moe.config import (
mxfp4_w4a16_moe_quant_config,
)
from aphrodite.model_executor.layers.fused_moe.oracle.mxfp4 import (
TRITON_BACKENDS,
Mxfp4MoeBackend,
Expand Down Expand Up @@ -832,6 +835,18 @@ def get_fused_moe_quant_config(
w1_scale = layer.w13_weight_scale
w2_scale = layer.w2_weight_scale

if self.mxfp4_backend == Mxfp4MoeBackend.EMULATION:
# Canonical ``mxfp4`` checkpoints are weight-only W4A16. The
# generic EMULATION config is W4A4, so preserve BF16 activations
# while the fallback dequantizes only the weights.
return mxfp4_w4a16_moe_quant_config(
w1_scale=w1_scale,
w2_scale=w2_scale,
w1_bias=w1_bias,
w2_bias=w2_bias,
gemm1_clamp_limit=swiglu_limit,
)

return make_mxfp4_moe_quant_config(
mxfp4_backend=self.mxfp4_backend,
w1_scale=w1_scale,
Expand Down
Loading