[Bugfix] DSv4 MXFP4 selector: stop narrowing explicit aliases to their BF16 variant (#53586)
Signed-off-by: Zihua Wu <zihuaw@nvidia.com> Signed-off-by: Zihua Wu <13583761+lucifer1004@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Jee Jee Li <pandaleefree@gmail.com> Co-authored-by: Yongye Zhu <zyy1102000@gmail.com>
Gabriel Wu committed
Sep 7, 2026 at 15:19 UTC
5893426b88f7b3cd21101d194eb1c6f0a6f0e27b
2 files changed
+36
-1
tests/kernels/moe/test_b12x.py
+29
@@ -464,6 +464,35 @@ def test_deepseek_v4_b12x_activation_selection(
464
assert experts_cls is B12xExperts
465
466
467
+def test_deepseek_v4_flashinfer_cutlass_falls_through_to_w4a8(
468
+ monkeypatch: pytest.MonkeyPatch,
469
+) -> None:
470
+ """Explicit flashinfer_cutlass must try the W4A8 variant when the BF16
471
+ variant is unsupported (the BF16 variant is gated to SM90)."""
472
+ from vllm.model_executor.layers.fused_moe.experts.flashinfer_cutlass_moe import (
473
+ FlashInferExperts,
474
+ )
475
+
476
+ monkeypatch.setattr(FlashInferExperts, "_supports_current_device", lambda: True)
477
+
478
+ def sm120_quant_gate(weight_key, activation_key):
479
+ return (weight_key, activation_key) == (
480
+ mxfp4_oracle.kMxfp4Static,
481
+ mxfp4_oracle.kMxfp8Dynamic,
482
+ )
483
+
484
+ monkeypatch.setattr(
485
+ FlashInferExperts, "_supports_quant_scheme", staticmethod(sm120_quant_gate)
486
+ )
487
+ config = make_dummy_moe_config(hidden_dim=256, intermediate_size=64)
488
+ config.moe_backend = "flashinfer_cutlass"
489
+
490
+ backend, experts_cls = select_deepseek_v4_mxfp4_moe_backend(config)
491
+
492
+ assert backend == Mxfp4MoeBackend.FLASHINFER_CUTLASS_MXFP4_MXFP8
493
+ assert experts_cls is FlashInferExperts
494
+
495
+
496
def test_compressed_tensors_mxfp4_preserves_checkpoint_packing(
497
monkeypatch: pytest.MonkeyPatch,
498
) -> None:
vllm/model_executor/layers/fused_moe/oracle/mxfp4.py
+7
-1
@@ -670,7 +670,13 @@ def select_deepseek_v4_mxfp4_moe_backend(
670
# falling back to the auto priority list.
671
runner_backend = config.moe_backend
672
if runner_backend != "auto":
673
- requested_backends = _get_requested_backends(runner_backend, None)
673
+ if runner_backend == "b12x":
674
+ requested_backends = _get_requested_backends(runner_backend, None)
675
+ else:
676
+ # Try every variant of the alias in priority order. Narrowing to
677
+ # the BF16 variant would drop SM100+ W4A8 variants on devices where
678
+ # the BF16 variant is gated to SM90.
679
+ requested_backends = map_mxfp4_backend(runner_backend)
680
if activation_format == mk.FusedMoEActivationFormat.BatchedExperts:
681
requested_backends = [
682
Mxfp4MoeBackend.BATCHED_MARLIN if b == Mxfp4MoeBackend.MARLIN else b