Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
35 changes: 3 additions & 32 deletions tests/quantization/test_gfx950_moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
)
from vllm.model_executor.layers.fused_moe.oracle.mxfp4 import (
Mxfp4MoeBackend,
_requires_qwen38_tep8_emulation,
select_mxfp4_moe_backend,
)
from vllm.model_executor.layers.quantization.utils.quant_utils import (
Expand Down Expand Up @@ -104,36 +103,8 @@ def _make_qwen38_tep8_moe_config() -> FusedMoEConfig:
)


def test_qwen38_tep8_requires_emulation_only_on_gfx950(monkeypatch):
import vllm.model_executor.layers.fused_moe.oracle.mxfp4 as mxfp4_oracle

config = _make_qwen38_tep8_moe_config()
monkeypatch.setattr(current_platform, "is_rocm", lambda: True)
monkeypatch.setattr("vllm.platforms.rocm.on_gfx950", lambda: True)

assert _requires_qwen38_tep8_emulation(config, kMxfp4Dynamic)

config.moe_parallel_config.ep_size = 4
config.num_local_experts = 128
assert not _requires_qwen38_tep8_emulation(config, kMxfp4Dynamic)

config = _make_qwen38_tep8_moe_config()
monkeypatch.setattr(mxfp4_oracle.current_platform, "is_rocm", lambda: False)
assert not _requires_qwen38_tep8_emulation(config, kMxfp4Dynamic)


@pytest.mark.parametrize(
"requested_backend,expected_backend",
[
("auto", Mxfp4MoeBackend.EMULATION),
("aiter", Mxfp4MoeBackend.AITER_MXFP4_MXFP4),
],
)
def test_qwen38_tep8_auto_fallback_respects_explicit_backend(
requested_backend,
expected_backend,
monkeypatch,
):
@pytest.mark.parametrize("requested_backend", ["auto", "aiter"])
def test_qwen38_tep8_selects_native_aiter(requested_backend, monkeypatch):
import vllm.model_executor.layers.fused_moe.oracle.mxfp4 as mxfp4_oracle

class SupportedExperts:
Expand All @@ -154,7 +125,7 @@ def is_supported_config(*args, **kwargs):
config, activation_key=kMxfp4Dynamic
)

assert backend == expected_backend
assert backend == Mxfp4MoeBackend.AITER_MXFP4_MXFP4
assert experts_cls is SupportedExperts


Expand Down
48 changes: 0 additions & 48 deletions vllm/model_executor/layers/fused_moe/oracle/mxfp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,39 +578,6 @@ def _get_requested_backends(
return _filter_by_activation(backends, requested_activation_key)


def _requires_qwen38_tep8_emulation(
config: FusedMoEConfig,
activation_key: QuantKey | None,
) -> bool:
"""Avoid the inaccurate native gfx950 kernel for Qwen3.8 TEP8.

Qwen3.8 Flash Next's routed experts use the distinctive
``E=512, H=2560, N=640`` W4A4 shape. With eight-way expert parallelism,
AITER operates on 64 local experts and pads ``N`` to 768. That native path
is not numerically reliable on gfx950, while OCP MX emulation preserves
model accuracy. Keep this guard exact so other MXFP4 shapes and smaller EP
configurations retain the native backend.
"""
parallel = config.moe_parallel_config
if not (
activation_key == kMxfp4Dynamic
and parallel.use_ep
and parallel.ep_size == 8
and config.num_experts == 512
and config.num_local_experts == 64
and config.hidden_dim == 2560
and config.intermediate_size == 640
):
return False

if not current_platform.is_rocm():
return False

from vllm.platforms.rocm import on_gfx950

return on_gfx950()


def select_mxfp4_moe_backend(
config: FusedMoEConfig,
activation_key: QuantKey | None = None,
Expand Down Expand Up @@ -673,21 +640,6 @@ def select_mxfp4_moe_backend(
assert last_error is not None
raise last_error

if _requires_qwen38_tep8_emulation(config, requested_activation_key):
backend = Mxfp4MoeBackend.EMULATION
logger.warning_once(
"Using OCP MX emulation for the Qwen3.8 Flash Next TEP8 routed "
"experts on gfx950 because the native AITER W4A4 kernel is not "
"numerically reliable for this shape. Performance will be lower."
)
return _return_or_raise(
backend,
config,
kMxfp4Static,
requested_activation_key,
activation_format,
)

# Select kernels in order of backend.
AVAILABLE_BACKENDS = _filter_by_activation(
_get_priority_backends_for_gpt_oss(), requested_activation_key
Expand Down
Loading