Skip to content
Merged
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
29 changes: 29 additions & 0 deletions tests/kernels/moe/test_b12x.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,35 @@ def test_deepseek_v4_b12x_activation_selection(
assert experts_cls is B12xExperts


def test_deepseek_v4_flashinfer_cutlass_falls_through_to_w4a8(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""Explicit flashinfer_cutlass must try the W4A8 variant when the BF16
variant is unsupported (the BF16 variant is gated to SM90)."""
from vllm.model_executor.layers.fused_moe.experts.flashinfer_cutlass_moe import (
FlashInferExperts,
)

monkeypatch.setattr(FlashInferExperts, "_supports_current_device", lambda: True)

def sm120_quant_gate(weight_key, activation_key):
return (weight_key, activation_key) == (
mxfp4_oracle.kMxfp4Static,
mxfp4_oracle.kMxfp8Dynamic,
)

monkeypatch.setattr(
FlashInferExperts, "_supports_quant_scheme", staticmethod(sm120_quant_gate)
)
config = make_dummy_moe_config(hidden_dim=256, intermediate_size=64)
config.moe_backend = "flashinfer_cutlass"

backend, experts_cls = select_deepseek_v4_mxfp4_moe_backend(config)

assert backend == Mxfp4MoeBackend.FLASHINFER_CUTLASS_MXFP4_MXFP8
assert experts_cls is FlashInferExperts


def test_compressed_tensors_mxfp4_preserves_checkpoint_packing(
monkeypatch: pytest.MonkeyPatch,
) -> None:
Expand Down
8 changes: 7 additions & 1 deletion vllm/model_executor/layers/fused_moe/oracle/mxfp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,13 @@ def select_deepseek_v4_mxfp4_moe_backend(
# falling back to the auto priority list.
runner_backend = config.moe_backend
if runner_backend != "auto":
requested_backends = _get_requested_backends(runner_backend, None)
if runner_backend == "b12x":
requested_backends = _get_requested_backends(runner_backend, None)
else:
# Try every variant of the alias in priority order. Narrowing to
# the BF16 variant would drop SM100+ W4A8 variants on devices where
# the BF16 variant is gated to SM90.
requested_backends = map_mxfp4_backend(runner_backend)
if activation_format == mk.FusedMoEActivationFormat.BatchedExperts:
requested_backends = [
Mxfp4MoeBackend.BATCHED_MARLIN if b == Mxfp4MoeBackend.MARLIN else b
Expand Down
Loading