[Bugfix][ROCm][MiniMax-M3] Reject unbuilt index-head counts in the AITER indexer (#60990)
Signed-off-by: Andreas Karatzas <akaratza@amd.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude
parent
21e207efa1
commit
e96c822660
@@ -1833,6 +1833,35 @@ def test_aiter_indexer_requires_the_aiter_attend(monkeypatch):
|
||||
assert reason is None or "AITER sparse PA attend" not in reason
|
||||
|
||||
|
||||
def test_aiter_indexer_rejects_unbuilt_index_heads(monkeypatch):
|
||||
"""AITER builds the MSA score kernels for 1 or 2 index heads only.
|
||||
|
||||
MiniMax-M3 has 4, so at attention TP=1 the indexer has to fall back at load
|
||||
time rather than fail at the first forward.
|
||||
"""
|
||||
import vllm.models.minimax_m3.amd.indexer_aiter as indexer_aiter_mod
|
||||
|
||||
monkeypatch.setattr(indexer_aiter_mod.current_platform, "is_rocm", lambda: True)
|
||||
monkeypatch.setattr(
|
||||
indexer_aiter_mod, "_minimax_m3_aiter_sparse_pa_requested", lambda: True
|
||||
)
|
||||
|
||||
def unsupported_reason(num_index_heads: int) -> str | None:
|
||||
return indexer_aiter_mod.aiter_indexer_unsupported_reason(
|
||||
topk_blocks=TOPK,
|
||||
sparse_block_size=BLOCK_SIZE,
|
||||
num_index_heads=num_index_heads,
|
||||
index_head_dim=HEAD_DIM,
|
||||
indexer_kv_dtype="fp8",
|
||||
max_model_len=8192,
|
||||
)
|
||||
|
||||
if reason := unsupported_reason(2):
|
||||
pytest.skip(f"AITER MSA indexer unavailable: {reason}")
|
||||
reason = unsupported_reason(4)
|
||||
assert reason is not None and "num_index_heads" in reason
|
||||
|
||||
|
||||
def test_aiter_consolidated_qknorm_enabled(monkeypatch):
|
||||
from vllm._aiter_ops import rocm_aiter_ops
|
||||
|
||||
|
||||
@@ -67,6 +67,8 @@ MSA_TOPK_BLOCKS = 16
|
||||
MSA_SCORE_TYPE = "max"
|
||||
MSA_SPARSE_BLOCK_SIZE = 128
|
||||
MSA_INDEX_HEAD_DIM = 128
|
||||
# Index head counts the score kernels are instantiated for.
|
||||
MSA_NUM_INDEX_HEADS = (1, 2)
|
||||
# Wave width the top-k is written against: it gives one lane per output slot and
|
||||
# reads the score row in wave-wide strips.
|
||||
WAVE_SIZE = 64
|
||||
@@ -181,8 +183,11 @@ def aiter_indexer_unsupported_reason(
|
||||
f"needs index_head_dim={MSA_INDEX_HEAD_DIM}, "
|
||||
f"got index_head_dim={index_head_dim}"
|
||||
)
|
||||
if num_index_heads > MFMA_COLS:
|
||||
return f"num_index_heads={num_index_heads} exceeds the {MFMA_COLS} MFMA columns"
|
||||
if num_index_heads not in MSA_NUM_INDEX_HEADS:
|
||||
return (
|
||||
f"needs num_index_heads in {MSA_NUM_INDEX_HEADS}, "
|
||||
f"got num_index_heads={num_index_heads}"
|
||||
)
|
||||
# A decode row's whole query shares one MFMA tile, one column per (token,
|
||||
# head) pair, so spec decode trades columns against the head count.
|
||||
if num_index_heads * max_decode_query_len > MFMA_COLS:
|
||||
|
||||
@@ -125,7 +125,9 @@ def minimax_m3_use_aiter_sparse_pa(
|
||||
raise ValueError(
|
||||
"MiniMax M3 AITER sparse paged attention requires "
|
||||
f"num_kv_heads == 1 per tensor-parallel rank, got {num_kv_heads}, "
|
||||
"unless the indexer emits the attend's page table."
|
||||
"unless the AITER indexer emits the attend's page table. It is not "
|
||||
"in use here; the 'MiniMax M3 indexer: AITER unavailable' log line "
|
||||
"says why."
|
||||
)
|
||||
return requested
|
||||
|
||||
|
||||
Reference in New Issue
Block a user