[ROCm][Bugfix] Gate AITER MXFP8 MoE on the aiter enable flag (#57426)
Signed-off-by: Rohan Potdar <rohan.potdar@amd.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2,10 +2,11 @@
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
"""MXFP8 MoE backend selection for the AITER FlyDSL kernel (gfx950).
|
||||
|
||||
GPU-free: mocks the platform (gfx950) and the ``flydsl`` package check, then
|
||||
GPU-free: mocks the platform (gfx950) and the aiter fused-MoE enable flag, then
|
||||
exercises the oracle so the FlyDSL backend is auto-picked when usable (including
|
||||
under expert parallelism, since apply() forwards the expert_map as aiter's
|
||||
expert_mask) and skipped (native fallback) when the device/package is missing.
|
||||
expert_mask) and skipped (native fallback) when the device is unsupported or the
|
||||
aiter runtime is disabled.
|
||||
"""
|
||||
|
||||
import dataclasses
|
||||
@@ -48,6 +49,8 @@ from vllm.model_executor.layers.quantization.utils.quant_utils import ( # noqa:
|
||||
kMxfp8Static,
|
||||
)
|
||||
|
||||
from vllm._aiter_ops import rocm_aiter_ops # noqa: E402 # isort: skip
|
||||
|
||||
_AITER_MOD = "vllm.model_executor.layers.fused_moe.experts.aiter_mxfp8_moe"
|
||||
|
||||
|
||||
@@ -82,8 +85,8 @@ def _gfx950():
|
||||
)
|
||||
|
||||
|
||||
def _flydsl_installed(present: bool):
|
||||
return patch(f"{_AITER_MOD}.is_aiter_mxfp8_moe_available", return_value=present)
|
||||
def _aiter_moe_enabled(present: bool):
|
||||
return patch.object(rocm_aiter_ops, "is_fused_moe_enabled", return_value=present)
|
||||
|
||||
|
||||
def test_aiter_mxfp8_registered():
|
||||
@@ -109,13 +112,18 @@ def test_ep_supported(ep_size):
|
||||
@pytest.mark.parametrize(
|
||||
"present,ep_size,supported,reason_substr",
|
||||
[
|
||||
(True, 1, True, None), # gfx950 + flydsl + TP -> selectable
|
||||
(True, 2, True, None), # gfx950 + flydsl + EP -> selectable (expert_mask)
|
||||
(False, 1, False, "flydsl package"), # package missing -> clear reason
|
||||
(True, 1, True, None), # gfx950 + aiter MoE + TP -> selectable
|
||||
(True, 2, True, None), # gfx950 + aiter MoE + EP -> selectable (expert_mask)
|
||||
(
|
||||
False,
|
||||
1,
|
||||
False,
|
||||
"does not support current device",
|
||||
), # disabled -> not selected
|
||||
],
|
||||
)
|
||||
def test_is_supported_config(present, ep_size, supported, reason_substr):
|
||||
with _gfx950(), _flydsl_installed(present):
|
||||
with _gfx950(), _aiter_moe_enabled(present):
|
||||
ok, reason = AiterMxfp8Experts.is_supported_config(
|
||||
AiterMxfp8Experts,
|
||||
_config(ep_size),
|
||||
@@ -130,8 +138,8 @@ def test_is_supported_config(present, ep_size, supported, reason_substr):
|
||||
|
||||
def test_explicit_moe_backend_aiter():
|
||||
"""--moe-backend aiter: returns FlyDSL when usable (TP or EP), else a clear
|
||||
ValueError when the flydsl package is missing."""
|
||||
with _gfx950(), _flydsl_installed(True):
|
||||
ValueError when the aiter MoE runtime is disabled."""
|
||||
with _gfx950(), _aiter_moe_enabled(True):
|
||||
assert (
|
||||
_select_kernel_cls(Fp8MoeBackend.AITER_MXFP8, _config(1))
|
||||
is AiterMxfp8Experts
|
||||
@@ -142,18 +150,17 @@ def test_explicit_moe_backend_aiter():
|
||||
)
|
||||
with (
|
||||
_gfx950(),
|
||||
_flydsl_installed(False),
|
||||
pytest.raises(ValueError, match="flydsl package"),
|
||||
_aiter_moe_enabled(False),
|
||||
pytest.raises(ValueError, match="does not support current device"),
|
||||
):
|
||||
_select_kernel_cls(Fp8MoeBackend.AITER_MXFP8, _config(1))
|
||||
|
||||
|
||||
def test_gfx950_picks_aiter():
|
||||
"""Auto-select on real ROCm hardware with flydsl usable -> FlyDSL wins."""
|
||||
# NOTE: Fp8MoeBackend.AITER_MXFP8 does not require VLLM_ROCM_USE_AITER=1
|
||||
"""Auto-select on real ROCm hardware with aiter MoE enabled -> FlyDSL wins."""
|
||||
with (
|
||||
patch(f"{_AITER_MOD}.current_platform.supports_mx", return_value=True),
|
||||
_flydsl_installed(True),
|
||||
_aiter_moe_enabled(True),
|
||||
):
|
||||
backend, experts_cls = select_mxfp8_moe_backend(_config())
|
||||
assert backend is Fp8MoeBackend.AITER_MXFP8
|
||||
|
||||
@@ -111,11 +111,6 @@ def test_mxfp8_aiter_requires_swigluoai_activation(
|
||||
"_supports_current_device",
|
||||
staticmethod(lambda: True),
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
aiter_mxfp8_moe,
|
||||
"is_aiter_mxfp8_moe_available",
|
||||
lambda: True,
|
||||
)
|
||||
|
||||
config = FusedMoEConfig(
|
||||
num_experts=8,
|
||||
@@ -164,11 +159,6 @@ def test_mxfp8_aiter_requires_swigluoai_params(
|
||||
"_supports_current_device",
|
||||
staticmethod(lambda: True),
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
aiter_mxfp8_moe,
|
||||
"is_aiter_mxfp8_moe_available",
|
||||
lambda: True,
|
||||
)
|
||||
|
||||
config = FusedMoEConfig(
|
||||
num_experts=8,
|
||||
@@ -218,11 +208,6 @@ def test_mxfp8_aiter_accepts_swigluoai_params(
|
||||
"_supports_current_device",
|
||||
staticmethod(lambda: True),
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
aiter_mxfp8_moe,
|
||||
"is_aiter_mxfp8_moe_available",
|
||||
lambda: True,
|
||||
)
|
||||
|
||||
config = FusedMoEConfig(
|
||||
num_experts=8,
|
||||
|
||||
@@ -11,6 +11,7 @@ import math
|
||||
import torch
|
||||
|
||||
import vllm.model_executor.layers.fused_moe.modular_kernel as mk
|
||||
from vllm._aiter_ops import rocm_aiter_ops
|
||||
from vllm.logger import init_logger
|
||||
from vllm.model_executor.layers.fused_moe.activation import MoEActivation
|
||||
from vllm.model_executor.layers.fused_moe.experts.mxfp8_emulation_moe import (
|
||||
@@ -24,41 +25,6 @@ _AITER_SWIGLU_ALPHA = 1.702
|
||||
_AITER_SWIGLU_BETA = 1.0
|
||||
|
||||
|
||||
def is_aiter_mxfp8_moe_available() -> bool:
|
||||
"""True when the FlyDSL MXFP8 MoE can run here: gfx950, the ``flydsl``
|
||||
package is importable, AND the installed aiter carries the mxfp8 FlyDSL
|
||||
2-stage support from ROCm/aiter#3811.
|
||||
|
||||
``flydsl`` and ``aiter`` are separate packages, so ``is_flydsl_available()``
|
||||
(flydsl pkg + arch) is necessary but not sufficient: an older aiter without
|
||||
#3811 still ships the flydsl pkg and the ``aiter.ops.flydsl`` module but a
|
||||
broken/missing ``per_1x32 + fp8`` 2-stage path. Without this extra gate a
|
||||
nightly lacking #3811 would wrongly select FlyDSL instead of falling back to
|
||||
the native Triton dot_scaled path. #3811 added no probe-able public symbol,
|
||||
so detect the ``minimax_m3_mxfp8`` tuned config it shipped. Every check fails
|
||||
closed (returns False -> triton dot_scaled), which is always safe."""
|
||||
if not (current_platform.is_rocm() and current_platform.supports_mx()):
|
||||
return False
|
||||
try:
|
||||
import os
|
||||
|
||||
import aiter
|
||||
from aiter.ops.flydsl.utils import is_flydsl_available
|
||||
|
||||
if not is_flydsl_available():
|
||||
return False
|
||||
return os.path.exists(
|
||||
os.path.join(
|
||||
os.path.dirname(aiter.__file__),
|
||||
"configs",
|
||||
"model_configs",
|
||||
"minimax_m3_mxfp8_tuned_fmoe.csv",
|
||||
)
|
||||
)
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
class AiterMxfp8Experts(Mxfp8TritonExpertsBase):
|
||||
"""MXFP8 MoE through AITER's FlyDSL two-stage grouped GEMM (gfx950)."""
|
||||
|
||||
@@ -79,10 +45,7 @@ class AiterMxfp8Experts(Mxfp8TritonExpertsBase):
|
||||
|
||||
@staticmethod
|
||||
def _supports_current_device() -> bool:
|
||||
# Device capability only (gfx950 / MX-capable ROCm). The flydsl package
|
||||
# check lives in is_supported_config so a missing package is reported
|
||||
# distinctly from an unsupported device.
|
||||
return current_platform.is_rocm() and current_platform.supports_mx()
|
||||
return current_platform.supports_mx() and rocm_aiter_ops.is_fused_moe_enabled()
|
||||
|
||||
@staticmethod
|
||||
def _supports_parallel_config(moe_parallel_config) -> bool:
|
||||
@@ -95,12 +58,6 @@ class AiterMxfp8Experts(Mxfp8TritonExpertsBase):
|
||||
is_supported, reason = super().is_supported_config(
|
||||
cls, moe_config, weight_key, activation_key, activation_format
|
||||
)
|
||||
# _supports_current_device() only gates on the device; surface a clear
|
||||
# reason when the device is fine but the flydsl package is missing.
|
||||
if is_supported and not is_aiter_mxfp8_moe_available():
|
||||
return False, (
|
||||
"kernel requires the aiter flydsl package, which is not installed"
|
||||
)
|
||||
if (
|
||||
is_supported
|
||||
and moe_config.activation != MoEActivation.SWIGLUOAI_UNINTERLEAVE
|
||||
|
||||
Reference in New Issue
Block a user