[ROCm][CI] Fix ROCm attention backend validation for head sizes, block sizes, and compute capability checks (#36292)

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
This commit is contained in:
Andreas Karatzas
2026-03-09 12:02:41 -05:00
committed by GitHub
parent 55d27cca55
commit c174d54f86
7 changed files with 55 additions and 9 deletions
@@ -29,11 +29,18 @@ def mock_vllm_config():
@pytest.fixture
def mock_on_gfx9():
"""Mock the on_gfx9 function to return True."""
"""Mock gfx9 arch detection to return True."""
with patch("vllm.platforms.rocm.on_gfx9", return_value=True):
yield
@pytest.fixture
def mock_on_mi3xx():
"""Mock mi3xx arch detection to return True."""
with patch("vllm.platforms.rocm.on_mi3xx", return_value=True):
yield
@pytest.mark.parametrize(
"env_vars, selected_backend, expected_backend_path",
[
@@ -122,6 +129,7 @@ def test_standard_attention_backend_selection(
expected_backend_path,
mock_vllm_config,
mock_on_gfx9,
mock_on_mi3xx,
monkeypatch,
):
"""Test standard attention backend selection with various configurations."""
@@ -313,16 +321,16 @@ def test_mla_backend_selection(
assert backend_path == expected_backend_path
def test_aiter_fa_requires_gfx9(mock_vllm_config):
"""Test that ROCM_AITER_FA requires gfx9 architecture."""
def test_aiter_fa_requires_mi3xx(mock_vllm_config):
"""Test that ROCM_AITER_FA requires mi3xx architecture."""
from vllm.platforms.rocm import RocmPlatform
# Mock on_gfx9 to return False
# Mock on_mi3xx to return False (used by supports_compute_capability)
with (
patch("vllm.platforms.rocm.on_gfx9", return_value=False),
patch("vllm.platforms.rocm.on_mi3xx", return_value=False),
pytest.raises(
ValueError,
match="only supported on gfx9",
match="compute capability not supported",
),
):
attn_selector_config = AttentionSelectorConfig(
@@ -342,11 +350,12 @@ def test_aiter_fa_requires_gfx9(mock_vllm_config):
def test_sparse_not_supported(mock_vllm_config):
"""Test that sparse attention is not supported on ROCm."""
"""Test that sparse MLA without use_mla flag raises an error."""
from vllm.platforms.rocm import RocmPlatform
with pytest.raises(
AssertionError, match="Sparse MLA backend on ROCm only supports block size 1"
ValueError,
match="No valid attention backend found",
):
attn_selector_config = AttentionSelectorConfig(
head_size=128,