[Triton/Gluon] [ASM] [HIP] MHA v4: support GQA, add gfx950 bf16, add gfx942 i8/fp8 - #4967
Conversation
Signed-off-by: jcaraban <jcaraban@amd.com>
Signed-off-by: jcaraban <jcaraban@amd.com>
Signed-off-by: jcaraban <jcaraban@amd.com>
Signed-off-by: jcaraban <jcaraban@amd.com>
Signed-off-by: jcaraban <jcaraban@amd.com>
Signed-off-by: jcaraban <jcaraban@amd.com>
Signed-off-by: jcaraban <jcaraban@amd.com>
Signed-off-by: jcaraban <jcaraban@amd.com>
Signed-off-by: jcaraban <jcaraban@amd.com>
Signed-off-by: jcaraban <jcaraban@amd.com>
Signed-off-by: jcaraban <jcaraban@amd.com>
Signed-off-by: jcaraban <jcaraban@amd.com>
Signed-off-by: jcaraban <jcaraban@amd.com>
Signed-off-by: jcaraban <jcaraban@amd.com>
Add raw BF16/NONE dispatch and the gfx950 block kernel to the MHA v4 manifest. Generalize launcher strides to byte units, preserve the v3 aiter_bf16 benchmark, rename v4 benchmark providers to mha4_*, and cover BF16 recipe, finite output, and compiled parity. Signed-off-by: jcaraban <jcaraban@amd.com>
Signed-off-by: jcaraban <jcaraban@amd.com>
Signed-off-by: jcaraban <jcaraban@amd.com>
Signed-off-by: jcaraban <jcaraban@amd.com>
Signed-off-by: jcaraban <jcaraban@amd.com>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags: |
Signed-off-by: jcaraban <jcaraban@amd.com>
Dense rotation kernels flatten all leading dimensions into rows, so their row stride is the last dimension width rather than stride(-2). PyTorch permits arbitrary stride metadata on singleton dimensions, which made contiguous [B, S, 1, D] inputs report a misleading head-axis stride and caused incorrect row addressing. Require contiguous dense inputs and outputs, use canonical input/output row widths, and validate output shapes, devices, auxiliary tensors, and empty inputs. Add regression coverage for singleton heads and rejected unsupported layouts.
90891d2 to
932fb80
Compare
There was a problem hiding this comment.
focus on you MHA v4 no changes to other part
There was a problem hiding this comment.
sorry, I vibed myself out of my own files... reverted and added rotate_activation_hd128() into MHA v4. Note however aiter.ops.quant.rotate_activation may segfault for H=1. For example:
import torch
from aiter.ops.quant import rotate_activation
# BHSD permuted to BSHD before rotation
source = torch.empty((1, 1, 512, 128), device="cuda", dtype=torch.bfloat16)
input = source.permute(0, 2, 1, 3)
out = torch.empty_like(input)
print(f"shape={tuple(input.shape)}", flush=True)
print(f"stride={input.stride()}, contiguous={input.is_contiguous()}", flush=True)
print(f"stride(-2)={input.stride(-2)}, actual row spacing={input.size(-1)}", flush=True)
rotate_activation(out, input)
torch.cuda.synchronize()
print("unexpectedly survived", flush=True)This reverts e79b1c8 and adds rotate_activation_hd128() to mha_v4 own .cu Signed-off-by: jcaraban <jcaraban@amd.com>
Motivation
Extend the MHA v4 ASM path to support GQA without expanding K/V heads. This enables inputs such as Q
[B, 32768, 64, 128]with K/V[B, 32768, 4, 128]. This PR also consolidates the related MHA v4 format, quantization, and gfx942/gfx950 kernel that were missing from the first PR --> #4627Technical Details
1, 2, 4, 8, 16in raw and packed MHA v4 APIs.The current scope remains dense, non-causal attention with head dimension 128 and BF16 output.
Test Plan
pytest -q op_tests/test_mha_v4.pyTest Result
Submission Checklist