[ROCm][CI] Mirror split kernel groups on MI355 and fix exposed tests (#58654)
Signed-off-by: Andreas Karatzas <andreas.karatzas@protonmail.com> Signed-off-by: Codex <codex@openai.com> Signed-off-by: Andreas Karatzas <akaratza@amd.com> Co-authored-by: OpenAI Codex <noreply@openai.com>
This commit is contained in:
co-authored by
OpenAI Codex
parent
0ae480ff1a
commit
69d5c81fcd
@@ -269,6 +269,9 @@ def test_kda_overlap_configs_match_measured_table() -> None:
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
not current_platform.is_cuda(), reason="KDA CuTeDSL helper requires CUDA"
|
||||
)
|
||||
@pytest.mark.parametrize(
|
||||
"compute_capability,supported",
|
||||
[((9, 0), False), ((10, 0), True), ((10, 3), True), ((12, 0), True)],
|
||||
|
||||
@@ -2182,7 +2182,9 @@ def test_v41_rocm_csa2_full_pipeline():
|
||||
)
|
||||
|
||||
q_out, kv_out, index_q_out, index_q_scale_out, index_weights_out_out = result
|
||||
assert torch.equal(q_out, q)
|
||||
assert torch.equal(
|
||||
q_out, q.view(num_tokens, attention.n_local_heads, attention.head_dim)
|
||||
)
|
||||
assert torch.equal(kv_out, kv)
|
||||
assert torch.equal(index_q_out, index_q)
|
||||
assert torch.equal(index_q_scale_out, index_q_scale)
|
||||
@@ -2273,7 +2275,9 @@ def test_v41_rocm_csa2_reindex_pipeline():
|
||||
)
|
||||
|
||||
q_out, kv_out, index_q_out, index_q_scale_out, index_weights_out_out = result
|
||||
assert torch.equal(q_out, q)
|
||||
assert torch.equal(
|
||||
q_out, q.view(num_tokens, attention.n_local_heads, attention.head_dim)
|
||||
)
|
||||
assert torch.equal(kv_out, kv)
|
||||
assert torch.equal(index_q_out, index_q)
|
||||
assert torch.equal(index_q_scale_out, index_q_scale)
|
||||
|
||||
@@ -233,6 +233,26 @@ def _assert_eq(r_ref, r_kern):
|
||||
)
|
||||
|
||||
|
||||
def _cache_pool_bytes(kv_cache: torch.Tensor, pool_slot: int) -> torch.Tensor:
|
||||
"""Read a logical pool's K and scale bytes from the platform cache layout."""
|
||||
page_size = kv_cache.shape[1]
|
||||
head_dim = kv_cache.shape[2] - 4
|
||||
page_idx, token_offset = divmod(pool_slot, page_size)
|
||||
flat = kv_cache[page_idx].reshape(-1)
|
||||
dims = torch.arange(head_dim, device=kv_cache.device)
|
||||
if current_platform.is_rocm() and page_size > 1:
|
||||
k_offsets = (
|
||||
(token_offset // 16) * 16 * head_dim
|
||||
+ (dims // 16) * 16 * 16
|
||||
+ (token_offset % 16) * 16
|
||||
+ dims % 16
|
||||
)
|
||||
else:
|
||||
k_offsets = token_offset * head_dim + dims
|
||||
scale_offset = page_size * head_dim + 4 * token_offset
|
||||
return torch.cat((flat[k_offsets], flat[scale_offset : scale_offset + 4]))
|
||||
|
||||
|
||||
@pytest.mark.skipif(not current_platform.is_rocm(), reason="ROCm required")
|
||||
def test_amd_prefill_writer_uses_preshuffled_cache_layout():
|
||||
from vllm.models.glm5next.amd.ops.kpool_compress import (
|
||||
@@ -343,7 +363,7 @@ def test_decode_writer_matches_prefill_writer(pool_size, ring_pools):
|
||||
p
|
||||
for p in range(n_pools)
|
||||
if not torch.equal(
|
||||
kv_prefill[p // page, p % page], kv_decode[p // page, p % page]
|
||||
_cache_pool_bytes(kv_prefill, p), _cache_pool_bytes(kv_decode, p)
|
||||
)
|
||||
]
|
||||
assert not differing, (
|
||||
@@ -379,13 +399,6 @@ def test_rejected_draft_redo_needs_ring_slots(ring_pools):
|
||||
kv = torch.zeros_like(kv_ref)
|
||||
tail = torch.zeros(nblk, 2, ring, HEAD_DIM, dtype=torch.bfloat16, device=dev)
|
||||
|
||||
def pool_bytes(cache, p):
|
||||
# Page layout: [page * HEAD_DIM bytes of K rows | page * 4 bytes of scales].
|
||||
flat = cache[0].reshape(-1)
|
||||
k_bytes = flat[p * HEAD_DIM : (p + 1) * HEAD_DIM]
|
||||
s_bytes = flat[page * HEAD_DIM + 4 * p : page * HEAD_DIM + 4 * (p + 1)]
|
||||
return torch.cat([k_bytes, s_bytes])
|
||||
|
||||
def step(positions, keys, scores):
|
||||
pos = torch.tensor([positions], dtype=torch.int32, device=dev)
|
||||
slots = [(p // pool) if p % pool == pool - 1 else -1 for p in positions]
|
||||
@@ -415,7 +428,7 @@ def test_rejected_draft_redo_needs_ring_slots(ring_pools):
|
||||
)
|
||||
step([8, 9, 10, 11], k[8:12], score[8:12]) # all drafts rejected
|
||||
for p in (1, 2):
|
||||
assert torch.equal(pool_bytes(kv, p), pool_bytes(kv_ref, p)), p
|
||||
assert torch.equal(_cache_pool_bytes(kv, p), _cache_pool_bytes(kv_ref, p)), p
|
||||
|
||||
# Draft 7 completes pool 1 and is rejected. With a one-pool ring, drafts
|
||||
# 8 and 9 overwrite the slots of positions 4 and 5, which are read by the
|
||||
@@ -430,7 +443,7 @@ def test_rejected_draft_redo_needs_ring_slots(ring_pools):
|
||||
torch.cat([score[6:7], draft_scores]),
|
||||
)
|
||||
step([7, 8, 9, 10], k[7:11], score[7:11])
|
||||
pool1_ok = torch.equal(pool_bytes(kv, 1), pool_bytes(kv_ref, 1))
|
||||
pool1_ok = torch.equal(_cache_pool_bytes(kv, 1), _cache_pool_bytes(kv_ref, 1))
|
||||
if ring_pools == 1:
|
||||
assert not pool1_ok, "expected a one-pool ring to corrupt pool 1"
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user