diff --git a/tests/quantization/test_compressed_tensors.py b/tests/quantization/test_compressed_tensors.py index de906a861b..d51505a700 100644 --- a/tests/quantization/test_compressed_tensors.py +++ b/tests/quantization/test_compressed_tensors.py @@ -5,6 +5,7 @@ Run `pytest tests/quantization/test_compressed_tensors.py`. """ +from contextlib import contextmanager from unittest.mock import Mock import pytest @@ -370,6 +371,27 @@ def test_compressed_tensors_kv_cache_fp8_per_attn_head(vllm_runner): assert output +@contextmanager +def _nvfp4_marlin_error_context(model, capfd): + is_rocm_and_unsupported = ( + model == "nm-testing/TinyLlama-1.1B-Chat-v1.0-NVFP4A16" + and current_platform.is_rocm() + ) + + if is_rocm_and_unsupported: + expected_error = ( + "ValueError: Forced NVFP4 kernel MarlinNvFp4LinearKernel is not " + "supported: Marlin FP4 not available" + ) + with pytest.raises(RuntimeError, match="Engine core initialization failed"): + yield + + captured = capfd.readouterr() + assert expected_error in captured.out + captured.err + else: + yield + + @pytest.mark.parametrize( "args", [ @@ -377,9 +399,12 @@ def test_compressed_tensors_kv_cache_fp8_per_attn_head(vllm_runner): ("nm-testing/TinyLlama-1.1B-Chat-v1.0-NVFP4", False), ], ) -def test_compressed_tensors_nvfp4(vllm_runner, args): +def test_compressed_tensors_nvfp4(vllm_runner, args, capfd): model, use_a16 = args - with vllm_runner(model, enforce_eager=True) as llm: + with ( + _nvfp4_marlin_error_context(model, capfd), + vllm_runner(model, enforce_eager=True) as llm, + ): def check_model(model): layer = model.model.layers[0] diff --git a/tests/quantization/test_modelopt.py b/tests/quantization/test_modelopt.py index 2655295c85..0b54bcdbdf 100644 --- a/tests/quantization/test_modelopt.py +++ b/tests/quantization/test_modelopt.py @@ -25,6 +25,7 @@ from vllm.model_executor.layers.vocab_parallel_embedding import ( ParallelLMHead, VocabParallelEmbedding, ) +from vllm.platforms import current_platform @pytest.fixture(scope="function", autouse=True) @@ -467,6 +468,12 @@ def test_modelopt_mixed_precision_dispatches_w4a16_layer( from vllm.model_executor.layers.linear import LinearBase from vllm.model_executor.layers.quantization import modelopt as m + if ( + expected_linear_cls_name == "ModelOptNvFp4W4A16LinearMethod" + and current_platform.is_rocm() + ): + pytest.skip("ModelOptNvFp4W4A16LinearMethod is not supported with rocm") + hf_quant_config: dict[str, Any] = { "quantization": { "quant_algo": "MIXED_PRECISION",