[ROCm][CI] Move ROCm AITER quantization tests (#40938)
Signed-off-by: Andreas Karatzas <akaratza@amd.com> Signed-off-by: Andreas Karatzas <Andreas.Karatzas@amd.com> Co-authored-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
co-authored by
OpenAI Codex
parent
d785eb51ce
commit
5fa8ca971a
@@ -0,0 +1,137 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
"""Tests for ROCm AITER MLA FP8 support detection."""
|
||||
|
||||
import sys
|
||||
import types
|
||||
from typing import Any
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from vllm.platforms import current_platform
|
||||
|
||||
_SKIP_UNSUPPORTED_AITER_HARDWARE = True
|
||||
if current_platform.is_rocm():
|
||||
from vllm.platforms.rocm import get_cdna_version
|
||||
|
||||
_SKIP_UNSUPPORTED_AITER_HARDWARE = get_cdna_version() <= 2
|
||||
|
||||
pytestmark = pytest.mark.skipif(
|
||||
not current_platform.is_rocm(), reason="ROCm-specific tests"
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def reset_aiter_mla_support_cache(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
import vllm._aiter_ops as aiter_ops
|
||||
|
||||
monkeypatch.setattr(aiter_ops, "_AITER_MLA_SUPPORTS_FP8", None)
|
||||
|
||||
|
||||
def _install_fake_aiter_modules(
|
||||
monkeypatch: pytest.MonkeyPatch, *, supports_fp8: bool
|
||||
) -> None:
|
||||
aiter_mod: Any = types.ModuleType("aiter")
|
||||
mla_mod: Any = types.ModuleType("aiter.mla")
|
||||
|
||||
if supports_fp8:
|
||||
|
||||
def mla_decode_fwd_with_fp8(
|
||||
q,
|
||||
kv_buffer,
|
||||
kv_indptr,
|
||||
kv_indices,
|
||||
o,
|
||||
sm_scale,
|
||||
q_scale=None,
|
||||
kv_scale=None,
|
||||
):
|
||||
return None
|
||||
|
||||
mla_decode_fwd: Any = mla_decode_fwd_with_fp8
|
||||
|
||||
else:
|
||||
|
||||
def mla_decode_fwd_without_fp8(
|
||||
q,
|
||||
kv_buffer,
|
||||
kv_indptr,
|
||||
kv_indices,
|
||||
o,
|
||||
sm_scale,
|
||||
):
|
||||
return None
|
||||
|
||||
mla_decode_fwd = mla_decode_fwd_without_fp8
|
||||
|
||||
mla_mod.mla_decode_fwd = mla_decode_fwd
|
||||
aiter_mod.mla = mla_mod
|
||||
|
||||
monkeypatch.setitem(sys.modules, "aiter", aiter_mod)
|
||||
monkeypatch.setitem(sys.modules, "aiter.mla", mla_mod)
|
||||
|
||||
|
||||
def test_aiter_mla_fp8_support_detects_fp8_signature(monkeypatch):
|
||||
"""The support check should detect q_scale and kv_scale parameters."""
|
||||
from vllm._aiter_ops import _check_aiter_mla_fp8_support
|
||||
|
||||
_install_fake_aiter_modules(monkeypatch, supports_fp8=True)
|
||||
|
||||
assert _check_aiter_mla_fp8_support() is True
|
||||
|
||||
|
||||
def test_aiter_mla_fp8_support_rejects_missing_fp8_signature(monkeypatch):
|
||||
"""The support check should return False when FP8 params are absent."""
|
||||
from vllm._aiter_ops import _check_aiter_mla_fp8_support
|
||||
|
||||
_install_fake_aiter_modules(monkeypatch, supports_fp8=False)
|
||||
|
||||
assert _check_aiter_mla_fp8_support() is False
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
_SKIP_UNSUPPORTED_AITER_HARDWARE,
|
||||
reason="Installed AITER MLA FP8 check requires CDNA 3 or newer",
|
||||
)
|
||||
def test_installed_aiter_mla_supports_fp8():
|
||||
"""Supported ROCm CI must provide AITER with MLA FP8 scaling."""
|
||||
from vllm._aiter_ops import (
|
||||
_check_aiter_mla_fp8_support,
|
||||
is_aiter_found_and_supported,
|
||||
)
|
||||
|
||||
assert is_aiter_found_and_supported(), (
|
||||
"AITER must be installed on supported ROCm hardware"
|
||||
)
|
||||
assert _check_aiter_mla_fp8_support() is True
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"error_type",
|
||||
[ImportError, ModuleNotFoundError, AttributeError, ValueError, TypeError],
|
||||
)
|
||||
def test_aiter_mla_fp8_support_handles_signature_errors(monkeypatch, error_type):
|
||||
"""The support check should fail closed on import or signature problems."""
|
||||
import vllm._aiter_ops as aiter_ops
|
||||
from vllm._aiter_ops import _check_aiter_mla_fp8_support
|
||||
|
||||
_install_fake_aiter_modules(monkeypatch, supports_fp8=True)
|
||||
|
||||
with patch("inspect.signature", side_effect=error_type("boom")):
|
||||
assert _check_aiter_mla_fp8_support() is False
|
||||
assert aiter_ops._AITER_MLA_SUPPORTS_FP8 is False
|
||||
|
||||
|
||||
def test_aiter_mla_fp8_support_result_is_cached(monkeypatch):
|
||||
"""The support check should reuse the cached result on later calls."""
|
||||
import inspect
|
||||
|
||||
from vllm._aiter_ops import _check_aiter_mla_fp8_support
|
||||
|
||||
_install_fake_aiter_modules(monkeypatch, supports_fp8=True)
|
||||
|
||||
with patch("inspect.signature", wraps=inspect.signature) as signature_mock:
|
||||
assert _check_aiter_mla_fp8_support() is True
|
||||
assert _check_aiter_mla_fp8_support() is True
|
||||
assert signature_mock.call_count == 1
|
||||
Reference in New Issue
Block a user