[PR #38] [MERGED] HIP: wave32 WMMA prompt attention on RDNA4 (R9700 prompts +8-10%) #293

Closed
opened 2026-10-29 21:23:53 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/38
Author: @boxwrench
Created: 10/9/2026
Status: ✅ Merged
Merged: 10/9/2026
Merged by: @mw00

Base: main ← Head: amd/hip-wmma-attention-v2


📝 Commits (2)

  • f0163b3 HIP: map the device-query names #44 uses (v1.0.21 does not build on HIP without them)
  • b7b8d75 HIP GLM prefill attention: wave32 WMMA path with INT8 latent loads

📊 Changes

5 files changed (+326 additions, -25 deletions)

View changed files

📝 include/strata/hip_compat/cuda_runtime.h (+3 -0)
📝 include/strata/kernels/glm_batch.hpp (+9 -0)
📝 src/core/glm_prefill.cu (+26 -5)
📝 src/kernels/cuda/glm_batch.cu (+170 -0)
📝 tests/hip/glm_prefill_attention.cpp (+118 -20)

📄 Description

A second HIP prompt-attention kernel for RDNA4, next to #16's. On a single Radeon AI PRO R9700 it reads prompts ~8-10% faster. CUDA is unchanged (HIP-only code).

What changes

  • wmma2 prompt attention (src/kernels/cuda/glm_batch.cu): a wave32 WMMA kernel with FP16 high/residual products and FP32 accumulation and softmax. It sits alongside #16's rocWMMA mla_attn_f16q; #16's FP16 MLA products are kept.
  • Default per architecture: wmma2 on gfx12 (R9700 / RX 9070), #16's f16q on gfx11 (RX 7900 XT, Strix Halo), where f16q measured as fast or faster. STRATA_GLM_PREFILL_ATTN=wmma2|f16q|f32 forces one; STRATA_GLM_MLA_WMMA=0 still means the F32 kernel.
  • Test: tests/hip/glm_prefill_attention.cpp checks wmma2 against the F32 kernel on random data (partial chunks, several head groups).

Checked

  • hip_glm_prefill_attention on RX 7900 XT and R9700: wmma2 vs F32 rel L2 3.4e-7 / 1.6e-7 (worst head 1.5e-6 / 5.0e-7); f16q unchanged (9.8e-5); F32 max abs error 3.9e-8.
  • glm_layer_parity --selftest passes on both cards with each of wmma2, f16q, f32 and the default; glm_model_test --selftest passes on both.

Measured, single R9700, v1.0.16, prompt tok/s (2 requests each)

prompt f16q (#16) wmma2 (this PR's default on gfx12)
~4K tokens 680 / 719 749 / 801
~8K tokens 767 / 764 828 / 830

On Strix Halo (gfx1151) #16's kernel stays the default: there it measured 251 tok/s against 237-247 for this kernel at 4-7K prompts.

Not tested: CUDA (no NVIDIA toolchain here; all new code is under STRATA_USE_HIP).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mw00/project-maya/pull/38 **Author:** [@boxwrench](https://github.com/boxwrench) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/9/2026 **Merged by:** [@mw00](https://github.com/mw00) **Base:** `main` ← **Head:** `amd/hip-wmma-attention-v2` --- ### 📝 Commits (2) - [`f0163b3`](https://github.com/mw00/project-maya/commit/f0163b372f0f493d758c801bb5995eb826f4fcdb) HIP: map the device-query names #44 uses (v1.0.21 does not build on HIP without them) - [`b7b8d75`](https://github.com/mw00/project-maya/commit/b7b8d750ac98aec3f2337fe8767e00bff893cce0) HIP GLM prefill attention: wave32 WMMA path with INT8 latent loads ### 📊 Changes **5 files changed** (+326 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/hip_compat/cuda_runtime.h` (+3 -0) 📝 `include/strata/kernels/glm_batch.hpp` (+9 -0) 📝 `src/core/glm_prefill.cu` (+26 -5) 📝 `src/kernels/cuda/glm_batch.cu` (+170 -0) 📝 `tests/hip/glm_prefill_attention.cpp` (+118 -20) </details> ### 📄 Description A second HIP prompt-attention kernel for RDNA4, next to #16's. On a single Radeon AI PRO R9700 it reads prompts ~8-10% faster. CUDA is unchanged (HIP-only code). ### What changes - **`wmma2` prompt attention** (`src/kernels/cuda/glm_batch.cu`): a wave32 WMMA kernel with FP16 high/residual products and FP32 accumulation and softmax. It sits alongside #16's rocWMMA `mla_attn_f16q`; #16's FP16 MLA products are kept. - **Default per architecture:** `wmma2` on gfx12 (R9700 / RX 9070), #16's `f16q` on gfx11 (RX 7900 XT, Strix Halo), where `f16q` measured as fast or faster. `STRATA_GLM_PREFILL_ATTN=wmma2|f16q|f32` forces one; `STRATA_GLM_MLA_WMMA=0` still means the F32 kernel. - **Test:** `tests/hip/glm_prefill_attention.cpp` checks `wmma2` against the F32 kernel on random data (partial chunks, several head groups). ### Checked - `hip_glm_prefill_attention` on RX 7900 XT and R9700: `wmma2` vs F32 rel L2 3.4e-7 / 1.6e-7 (worst head 1.5e-6 / 5.0e-7); `f16q` unchanged (9.8e-5); F32 max abs error 3.9e-8. - `glm_layer_parity --selftest` passes on both cards with each of `wmma2`, `f16q`, `f32` and the default; `glm_model_test --selftest` passes on both. ### Measured, single R9700, v1.0.16, prompt tok/s (2 requests each) | prompt | `f16q` (#16) | `wmma2` (this PR's default on gfx12) | |---|---|---| | ~4K tokens | 680 / 719 | 749 / 801 | | ~8K tokens | 767 / 764 | 828 / 830 | On Strix Halo (gfx1151) #16's kernel stays the default: there it measured 251 tok/s against 237-247 for this kernel at 4-7K prompts. **Not tested:** CUDA (no NVIDIA toolchain here; all new code is under `STRATA_USE_HIP`). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:23:53 +07:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#293
No description provided.