mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1123] [CLOSED] HIP RDNA2 (gfx103x): prompt GEMMs as FP32 SGEMMs, a faster default that cannot overflow (RX 6800: 343 -> 534 tok/s) #3043
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#3043
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/1123
Author: @vallicgrr
Created: 10/6/2026
Status: ❌ Closed
Base:
main← Head:rdna2-sgemm-v2📝 Commits (4)
3bc2c74HIP RDNA2 (gfx103x): run the prompt path's 16-bit GEMMs as FP32 SGEMMs603fe9ddocs: RDNA2 prompt GEMMs as SGEMMs (measured on an RX 6800), and a Windows gfx1030 report456d003tests: hip_prefill_gemm crosses an RDNA2 SGEMM slice boundary (T 3300, K 10240; FP16 beta 1 with a padded ldy, and BF16)b38018cprefill gemm: a padded BF16 X (ldx, STRATA_PF_PAD) keeps the native call on the RDNA2 SGEMM route📊 Changes
4 files changed (+136 additions, -4 deletions)
View changed files
📝
docs/AMD_HIP.md(+33 -3)📝
include/strata/prefill/gemm.hpp(+5 -1)📝
src/prefill/gemm.cu(+93 -0)📝
tests/hip/prefill_gemm.cpp(+5 -0)📄 Description
Resubmission of #1006, which GitHub closed when
mainwas force-pushed. The branch is now on the newmain(82f46a8), so it sits beside #835'sSTRATA_HIP_PROMPT_F16.On gfx1030, the rocBLAS that setup installs (ROCm 10.2.0a20260930) has tuned kernels for FP16 -> FP16, int8 and FP32 -> FP32 only. The prompt path's dense GEMMs take FP16 or BF16 inputs and write FP32 (rocBLAS's HS / BS types), so they run fallback kernels at about 5 TFLOPS. That is why a default gfx103x install reads prompts at about half the speed
STRATA_HIP_PROMPT_F16=1reaches.This PR is meant as a faster default for gfx103x that does not depend on the FP16 range. It widens both inputs to FP32, which loses nothing, and runs SGEMM, which accumulates in FP32 like the native call. No value passes through FP16, so it cannot overflow. On the FP16 route, a GEMM output above 65504 becomes inf, and that can then spread through the layer as NaN. That is a hard failure rather than a rounding difference, and nothing bounds it for models that nobody has range-checked.
What it is not:
STRATA_HIP_PROMPT_F16=1.If you would rather keep the default bit-identical, I can make the route opt-in instead. It would then mainly serve as the overflow-free alternative to the FP16 route.
maindefault (STRATA_RDNA2_SGEMM=0)STRATA_HIP_PROMPT_F16=1Changes:
Gemm::rdna2_sgemm(src/prefill/gemm.cu) widens the weight once per call and the activations in slices of up to 128 MiB of FP32.Order in
Gemm::bf16/Gemm::f16:STRATA_HIP_PROMPT_F16=1;hipblasGemmEx.With the FP16 route on, this route only sees the products it leaves:
f16withbeta != 0.When it runs: it is on by default on gfx103x only. Other AMD architectures and CUDA are unchanged.
ldx,STRATA_PF_PAD) keeps the native call.STRATA_RDNA2_SGEMM=0/=1turns it off / on for any AMD card.docs/AMD_HIP.md, RDNA2 section: the measurements, how the two routes combine, and a Windows gfx1030 report.Measured on an RX 6800 16 GB over OCuLink (PCIe 4.0 x4, 7.1 GB/s), Ryzen 7 8845HS, 28.8 GB RAM, Windows 11.
tools/hip/build_windows.bat(STRATA_HIP_ARCHS=gfx1030); Coder IQ1_M with setup's arguments (64K context, MTP); fresh 12K-token prompts with no reuse.hipblasGemmEx: opA = T, opB = N, FP32 out, fp32 compute):STRATA_F16_RANGE=1on the Coder IQ1_M (four 12K prompts) peaked at 105.3 for activations and 424.8 for FP16 outputs, with nothing beyond 65504. SoSTRATA_HIP_PROMPT_F16=1is fine for this model. This route is for models nobody has checked, where an output past 65504 would become inf instead of a large finite number.tests/hip/prefill_gemm.cppgains two cases that cross the activation slice boundary (T 3300, K 10240): FP16 withbeta = 1and a paddedldy, and BF16.hip_prefill_gemmandhip_gemm_f16_io_paritypass on the RX 6800.HIP_VISIBLE_DEVICES=1): 72 passed, 7 skipped and 7 failed out of 86. None of the failures goes throughGemm:ple_parity,expert_parityandpool_testneed model fixtures that are not on this PC.expert_cache_segmented_test:--vram-elasticis CUDA-only.hip_handoffandhip_prefill_mmq_parityalso failed on the oldmain.hip_prefill_wmma_gemm_parity(new onmain) calls the WMMA kernel directly. Every case is declined on gfx1030, which has no WMMA, and the test counts that as a failure.Thanks to @xjc10 for #835 and for the comparison on #1006.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.