2525
2626ROCM_AVAILABLE = current_platform .is_rocm ()
2727ROCM_GFX950 = False
28- ROCM_AITER_AVAILABLE = False
28+ ROCM_AITER_SUPPORTED = False
2929
3030if ROCM_AVAILABLE :
31- from vllm ._aiter_ops import rocm_aiter_ops
31+ from vllm ._aiter_ops import is_aiter_found_and_supported , rocm_aiter_ops
3232 from vllm .platforms .rocm import on_gfx950
3333
3434 ROCM_GFX950 = on_gfx950 ()
35- ROCM_AITER_AVAILABLE = rocm_aiter_ops .is_fused_moe_enabled ()
35+ ROCM_AITER_SUPPORTED = is_aiter_found_and_supported ()
36+
37+
38+ def set_rocm_aiter (monkeypatch : pytest .MonkeyPatch , enabled : bool ) -> None :
39+ value = "1" if enabled else "0"
40+ monkeypatch .setenv ("VLLM_ROCM_USE_AITER" , value )
41+ monkeypatch .setenv ("VLLM_ROCM_USE_AITER_MOE" , value )
42+ monkeypatch .setattr (rocm_aiter_ops , "_AITER_ENABLED" , enabled )
43+ monkeypatch .setattr (rocm_aiter_ops , "_FMOE_ENABLED" , enabled )
44+
45+
46+ @pytest .fixture
47+ def enable_rocm_aiter (monkeypatch : pytest .MonkeyPatch ):
48+ set_rocm_aiter (monkeypatch , True )
49+
50+
51+ @pytest .fixture
52+ def disable_rocm_aiter (monkeypatch : pytest .MonkeyPatch ):
53+ set_rocm_aiter (monkeypatch , False )
3654
3755
3856def _make_w4a4_moe_config (moe_backend : str = "auto" ) -> FusedMoEConfig :
@@ -68,8 +86,8 @@ def mxfp4_oracle_config():
6886
6987
7088@pytest .mark .skipif (not ROCM_GFX950 , reason = "Requires GFX950 (mi355x)" )
71- @pytest .mark .skipif (not ROCM_AITER_AVAILABLE , reason = "Requires AITER enabled " )
72- def test_w4a4_dispatches_to_aiter (mxfp4_oracle_config ):
89+ @pytest .mark .skipif (not ROCM_AITER_SUPPORTED , reason = "Requires supported AITER " )
90+ def test_w4a4_dispatches_to_aiter (mxfp4_oracle_config , enable_rocm_aiter ):
7391 """With AITER enabled + GFX950, W4A4 selects AITER_MXFP4_MXFP4."""
7492 config = _make_w4a4_moe_config ()
7593 backend , experts_cls = select_mxfp4_moe_backend (
@@ -79,6 +97,19 @@ def test_w4a4_dispatches_to_aiter(mxfp4_oracle_config):
7997 assert experts_cls is not None
8098
8199
100+ @pytest .mark .skipif (not ROCM_GFX950 , reason = "Requires GFX950 (mi355x)" )
101+ def test_w4a4_falls_back_without_aiter (
102+ mxfp4_oracle_config ,
103+ disable_rocm_aiter ,
104+ ):
105+ config = _make_w4a4_moe_config ()
106+ backend , experts_cls = select_mxfp4_moe_backend (
107+ config , activation_key = kMxfp4Dynamic
108+ )
109+ assert backend == Mxfp4MoeBackend .EMULATION
110+ assert experts_cls is not None
111+
112+
82113@pytest .mark .skipif (not ROCM_GFX950 , reason = "Requires GFX950 (mi355x)" )
83114def test_w4a4_dispatches_to_emulation_with_moe_backend (mxfp4_oracle_config ):
84115 """With --moe-backend emulation, W4A4 selects EMULATION."""
0 commit comments