[PR #16] [MERGED] HIP prompt path: MLA products in FP16 and rocWMMA attention (Strix Halo +16% prompts) #281

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

📋 Pull Request Information

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

Base: main ← Head: amd/hip-prompt-attention


📝 Commits (1)

  • ffde3ca HIP prompt attention: MLA products in FP16 and a rocWMMA tensor-core attention kernel

📊 Changes

4 files changed (+289 additions, -1 deletions)

View changed files

📝 include/strata/kernels/glm_batch.hpp (+6 -0)
📝 src/core/glm_prefill.cu (+80 -1)
📝 src/kernels/cuda/glm_batch.cu (+148 -0)
📝 tests/hip/glm_prefill_attention.cpp (+55 -0)

📄 Description

The second AMD prompt-speed PR mentioned in #6/#7: the prompt path's MLA products in FP16 and a rocWMMA tensor-core prompt attention kernel on HIP. CUDA is unchanged (all new code is under STRATA_USE_HIP).

What changes

  • MLA products in FP16 (glm_prefill.cu): the q_abs and MLA-output batched GEMMs run with FP16 operands and F32 accumulation, heads packed per head, reusing existing buffers (Q packs into B.attn, the context into B.q_abs). w16_elems grows on HIP so the FP16 copy of wk_b/wv_b fits.
  • rocWMMA prompt attention (glm_batch.cu, mla_attn_f16q): the tensor-core attention for HIP, 57 KB of LDS (under RDNA's 64 KiB). The rocWMMA include is wrapped in push_macro/#undef/pop_macro, since HIP's bf16/fp8 headers clash with the force-included hip_compat shuffle macros.
  • On by default on HIP; STRATA_GLM_MLA_WMMA=0 falls back to the F32 mla_attn kernel, STRATA_GLM_MLA_F16=0 to the F32 products.
  • Test (tests/hip/glm_prefill_attention.cpp): the rocWMMA kernel against the F32 kernel on random data (T=48, 32 heads, up to 700 cells, partial chunks).

Checked

  • hip_glm_prefill_attention: F32 kernel max abs error 3.9e-8; rocWMMA vs F32 relative L2 9.8e-5 (worst head 2.4e-4), identical on RX 7900 XT and R9700.
  • glm_layer_parity, glm_dsa_parity, glm_model_test pass on both cards; 7 smoke checks pass on the full model.

Measured (prompt tok/s, v1.0.11 vs this branch, same prompts)

v1.0.11 this branch
Strix Halo 8060S (gfx1151), ~3.4K-token prompts, median of 3 212 247 (+16%)
RX 7900 XT, 4K-token prompts ~414 ~432 (+4%)
RX 7900 XT, 2K-token prompts ~275 ~276

Decode is unchanged. The gain is largest where attention is a bigger share of the prompt time (the iGPU). The Strix runs are noisy (n=3; one baseline run at 184).

Not tested: CUDA (no NVIDIA toolchain here); nothing outside STRATA_USE_HIP changes.


🔄 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/16 **Author:** [@boxwrench](https://github.com/boxwrench) **Created:** 10/8/2026 **Status:** ✅ Merged **Merged:** 10/8/2026 **Merged by:** [@mw00](https://github.com/mw00) **Base:** `main` ← **Head:** `amd/hip-prompt-attention` --- ### 📝 Commits (1) - [`ffde3ca`](https://github.com/mw00/project-maya/commit/ffde3caff1eb426fc1cb3083795f3790eb6481af) HIP prompt attention: MLA products in FP16 and a rocWMMA tensor-core attention kernel ### 📊 Changes **4 files changed** (+289 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/kernels/glm_batch.hpp` (+6 -0) 📝 `src/core/glm_prefill.cu` (+80 -1) 📝 `src/kernels/cuda/glm_batch.cu` (+148 -0) 📝 `tests/hip/glm_prefill_attention.cpp` (+55 -0) </details> ### 📄 Description The second AMD prompt-speed PR mentioned in #6/#7: the prompt path's MLA products in FP16 and a rocWMMA tensor-core prompt attention kernel on HIP. CUDA is unchanged (all new code is under `STRATA_USE_HIP`). ### What changes - **MLA products in FP16** (`glm_prefill.cu`): the `q_abs` and MLA-output batched GEMMs run with FP16 operands and F32 accumulation, heads packed per head, reusing existing buffers (Q packs into `B.attn`, the context into `B.q_abs`). `w16_elems` grows on HIP so the FP16 copy of `wk_b`/`wv_b` fits. - **rocWMMA prompt attention** (`glm_batch.cu`, `mla_attn_f16q`): the tensor-core attention for HIP, 57 KB of LDS (under RDNA's 64 KiB). The rocWMMA include is wrapped in `push_macro`/`#undef`/`pop_macro`, since HIP's bf16/fp8 headers clash with the force-included `hip_compat` shuffle macros. - On by default on HIP; `STRATA_GLM_MLA_WMMA=0` falls back to the F32 `mla_attn` kernel, `STRATA_GLM_MLA_F16=0` to the F32 products. - **Test** (`tests/hip/glm_prefill_attention.cpp`): the rocWMMA kernel against the F32 kernel on random data (T=48, 32 heads, up to 700 cells, partial chunks). ### Checked - `hip_glm_prefill_attention`: F32 kernel max abs error 3.9e-8; rocWMMA vs F32 relative L2 9.8e-5 (worst head 2.4e-4), identical on RX 7900 XT and R9700. - `glm_layer_parity`, `glm_dsa_parity`, `glm_model_test` pass on both cards; 7 smoke checks pass on the full model. ### Measured (prompt tok/s, v1.0.11 vs this branch, same prompts) | | v1.0.11 | this branch | |---|---|---| | Strix Halo 8060S (gfx1151), ~3.4K-token prompts, median of 3 | 212 | 247 (+16%) | | RX 7900 XT, 4K-token prompts | ~414 | ~432 (+4%) | | RX 7900 XT, 2K-token prompts | ~275 | ~276 | Decode is unchanged. The gain is largest where attention is a bigger share of the prompt time (the iGPU). The Strix runs are noisy (n=3; one baseline run at 184). **Not tested:** CUDA (no NVIDIA toolchain here); nothing outside `STRATA_USE_HIP` changes. --- <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:44 +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#281
No description provided.