mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #260] [CLOSED] RDNA3 WMMA kernels for the gfx1100 prefill (dense GEMMs and prompt attention) #2533
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2533
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/260
Author: @StevenChenSE
Created: 9/30/2026
Status: ❌ Closed
Base:
main← Head:pr-wmma📝 Commits (1)
bd534a5RDNA3 WMMA kernels for the gfx1100 prefill (dense GEMMs, prompt attention, parity test)📊 Changes
10 files changed (+1216 additions, -6 deletions)
View changed files
📝
CMakeLists.txt(+12 -2)📝
cmake/hip_backend.cmake(+6 -0)📝
docs/AMD_HIP.md(+32 -0)📝
include/strata/hip_compat/cuda_runtime.h(+8 -0)➕
include/strata/hip_compat/math_constants.h(+8 -0)📝
src/kernels/cuda/qsa_prompt_attn.cu(+381 -4)📝
src/prefill/gemm.cu(+26 -0)➕
src/prefill/wmma_gemm.cu(+280 -0)➕
src/prefill/wmma_gemm.h(+22 -0)➕
tests/hip/prefill_wmma_gemm_parity.cpp(+441 -0)📄 Description
gfx11's matrix instructions (
v_wmma_*) are unused by this backend: dense projections reach BLAS, and the promptattention uses the ordered FP32 fallback, which exists because the QSA matrix instructions it was written for are
CUDA-only. This adds two native paths for gfx1100.
What
src/prefill/wmma_gemm.{cu,h}- dense GEMM over the RDNA3 WMMA fragment layout (16x16x16, wave32 "doubled"inputs), templated for
_Float16and__bfloat16, dispatched fromGemm::f16andGemm::bf16ahead of theBLAS fallback.
src/kernels/cuda/qsa_prompt_attn.cu- the prompt attention itself on WMMA (scores 16x32 in two waves, outputfour warps over 64 dimensions) instead of the emulated scalar path.
tests/hip/prefill_wmma_gemm_parity.cpp- parity against a double-precision host reference over 440 shapes x 4beta/ldy configurations x 2 dtypes, including partial tiles, padding columns, end guards and the declined
shapes; registered for ctest like the neighbouring
hip_*tests.A/B switches
STRATA_WMMA_GEMM=0(both dense GEMMs),STRATA_WMMA_BF16=0(bf16 only),STRATA_PA_WMMA=0(attention).Measured
Against an unmodified build of this branch with the same flags, one RX 7900 XTX, 6-core host, PCIe 4.0 x16, using
the documented measured configuration (
--prefill 8192 --spec 4 --kv int8 --kv-resident 32768 --adapt-every 0 --pcie-frac 0,STRATA_PREFILL_MMQ=1):Decode is unchanged inside the noise. The gain is prefill and it grows with context, which is where the dense
projections and the attention dominate. Under the kernels' own switches (1K prompt, 32 generated tokens): 616.5
tok/s with both on, 597.6 with the attention off, 387.1 with the dense GEMMs off, 369.0 with both off.
Numerical note
The fp16 parity comparison allows 4 ULP: the matrix core accumulates in fp32 but rounds toward zero, while a host
reference rounds to nearest. Every delta observed on this hardware is <= 1 ULP and toward zero, and bf16 compares
exactly;
STRATA_WMMA_PARITY_EXACT=1demands bit equality instead. The fp16 and bf16 paths both leave an 8-tokenseed run bit-identical, and the decode side is unaffected.
Three integration details
Without these the kernels compile but never run, so they are part of the change:
STRATA_USE_HIP. The kernels were written against a privateSTRATA_BACKEND_HIP, andwith it undefined the WMMA dispatch was silently compiled out.
cmake/hip_backend.cmakesuppliesSTRATA_WMMA_GFX11, because the host pass of a HIP compile does notdefine
__gfx1100__even though it does define__HIP_DEVICE_COMPILE__. A compiler-macro guard thereforebuilt the returning-false stubs for the symbol the engine links and the WMMA path never ran.
hip_compatneedsCUDART_INF_F, CUDA'smath_constants.hspelling, mapped toHIP_INF_F- in theforce-included
cuda_runtime.hand in a standalone header for sources that include it by name.Not claimed
table's version guard rejects this one); the BLAS fallback here is
hipblasGemmEx.PCIe and a 6-core CPU are part of the configuration.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.