[ROCm][Quantization] Add Quark W4A8 (INT4-FP8) MoE CI coverage (#48050)
Signed-off-by: amd-sourjya <amd-sourjya@users.noreply.github.com> Co-authored-by: amd-sourjya <amd-sourjya@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Andreas Karatzas <akaratza@amd.com>
amd-sourjya committed
Jul 23, 2026 at 19:56 UTC
80c9d5d5e0448ddee3097a687fcbdbb427a8e9ee
1 file changed
+37
-1
tests/quantization/test_quark.py
+37
-1
@@ -23,6 +23,7 @@ from vllm.model_executor.layers.quantization.quark.quark import ( # noqa: E501
23
QuarkW8A8Int8,
24
)
25
from vllm.model_executor.layers.quantization.quark.quark_moe import ( # noqa: E501
26
+ QuarkW4A8Fp8MoEMethod,
27
QuarkW8A8Int8MoEMethod,
28
)
29
from vllm.model_executor.layers.quantization.utils.quant_utils import (
@@ -31,9 +32,12 @@ from vllm.model_executor.layers.quantization.utils.quant_utils import (
32
from vllm.platforms import current_platform
33
34
if current_platform.is_rocm():
34
- from vllm.platforms.rocm import on_gfx950
35
+ from vllm.platforms.rocm import on_gfx942, on_gfx950
36
else:
37
38
+ def on_gfx942() -> bool:
39
+ return False
40
+
41
def on_gfx950() -> bool:
42
return False
43
@@ -170,6 +174,38 @@ def test_quark_int8_w8a8_moe(vllm_runner, tp):
174
assert output
175
176
177
+@pytest.mark.skipif(
178
+ not (on_gfx950() or on_gfx942()),
179
+ reason="Quark W4A8 (INT4-FP8) MoE requires the AITER kernel on gfx942/gfx950",
180
+)
181
+@pytest.mark.parametrize("tp", [1])
182
+def test_quark_w4a8_fp8_moe(vllm_runner, monkeypatch, tp):
183
+ """Test W4A8 (INT4 weight + FP8 activation) MoE with a tiny Qwen3 MoE model.
184
+
185
+ W4A8 dispatches through the AITER fused MoE kernel, so AITER must be on.
186
+ """
187
+ monkeypatch.setenv("VLLM_ROCM_USE_AITER", "1")
188
+ monkeypatch.setenv("VLLM_ROCM_USE_AITER_MOE", "1")
189
+ model_path = "amd/tiny-qwen3-moe-w4a8"
190
+ with vllm_runner(
191
+ model_path,
192
+ enforce_eager=True,
193
+ tensor_parallel_size=tp,
194
+ gpu_memory_utilization=0.1,
195
+ ) as llm:
196
+
197
+ def check_model(model):
198
+ moe = model.model.layers[0].mlp.experts
199
+ assert isinstance(moe._quant_method, QuarkW4A8Fp8MoEMethod), (
200
+ f"Expected QuarkW4A8Fp8MoEMethod, got {type(moe._quant_method)}"
201
+ )
202
+
203
+ llm.apply_model(check_model)
204
+
205
+ output = llm.generate_greedy("Hello", max_tokens=4)
206
+ assert output
207
+
208
+
209
def test_quark_fp8_parity(vllm_runner):
210
quark_model_id = "amd-quark/llama-tiny-fp8-quark-quant-method"
211
fp8_model_id = "amd-quark/llama-tiny-fp8-quant-method"