mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #835] [CLOSED] HIP gfx103x: the prompt path's 16-bit GEMMs in FP16 in and out (prompt reads ~2x on RX 6900 XT) #2859
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#2859
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/835
Author: @Vop3p
Created: 10/4/2026
Status: ❌ Closed
Base:
main← Head:hip-gfx103x-fp16-prompt📝 Commits (5)
f8a6f4aHIP gfx103x: the prompt path's 16-bit GEMMs in FP16 in and out (prompt reads ~2x on RX 6900 XT)ccbca8abench: where the FP16 prompt path's rounding moves, and what the distribution check does not showb5fd82edocs: AMD_HIP.md RDNA2 - the FP16 prompt GEMMs, their switch, the measured gain and the HIP ctest result4c6c9fetests: hip_prefill_gemm runs the FP16-io prompt GEMMs (set_f16_io) on any HIP card, and its BF16 inputs are no longer zeroe780c85hip gfx103x FP16 prompt: STRATA_F16_RANGE counts what enters and leaves FP16; the range measured (outputs peak at 410 of 65504) and the FP32 route compared📊 Changes
9 files changed (+469 additions, -19 deletions)
View changed files
➕
bench/results/2026-10-04-rdna2-fp16-prompt/README.md(+186 -0)📝
docs/AMD_HIP.md(+16 -0)📝
include/strata/hip_compat/cuda_runtime.h(+1 -0)📝
include/strata/prefill/gemm.hpp(+20 -0)📝
include/strata/prefill/kernels.hpp(+7 -0)📝
src/prefill/gemm.cu(+128 -0)📝
src/prefill/kernels.cu(+54 -9)📝
src/prefill/prefill.cpp(+15 -0)📝
tests/hip/prefill_gemm.cpp(+42 -10)📄 Description
Summary
On gfx103x (RDNA2) rocBLAS has tuned GEMM kernels for FP16 in / FP16 out only. The prompt path's 16-bit products run
FP16 in / FP32 out (
Gemm::f16,Gemm::native) and BF16 in / FP32 out (Gemm::bf16), which on gfx1030 fall back to generickernels: 5.6 and ~5.3 TFLOPS against 37.7 for FP16 out (N=10240, T=7313, K=2560). On a 7.3K prompt the FP16-in/FP32-out
fallback alone was 54% of the GPU time.
With this change, on gfx103x only:
Gemm::f16/Gemm::nativerun FP16 out into the start of each FP32 row of Y (ldc = 2·ldyhalves) andwiden_rows_f16widens each row in place from its end: no extra buffer, no host sync.Gemm::bf16converts W in row slices to FP16 through the existing dequantization scratch (asnative()does), and thekernels that write the BF16 GEMMs' activation images (
gr_*,to_bf16) write FP16 instead (saturated like theexisting FP16 images; a NaN stays a NaN). BF16X2 is off there.
Gemm::set_f16_io, turned on only byPrefill::init(withset_act_f16), soevery other caller - e.g.
gemm_bf16_parity- runs exactly what it ran.prompt_f16()is cached per device, since alayer split can mix cards.
STRATA_HIP_PROMPT_F16=0/1overrides. CUDA builds are unchanged.Not the same as #655 / #540 (FP16 tensor-core path below sm_80): that one keeps FP32 output, which on gfx1030 is the slow
case; HIP is untouched by it.
Measurements (2x RX 6900 XT, ROCm 10.0, IQ3_S; details in
bench/results/2026-10-04-rdna2-fp16-prompt/README.md)--layer-split auto, 8.3K / 33.6KDecode unchanged. Same binary,
STRATA_HIP_PROMPT_F16=0vs default.Checks
65504 and no infinity.
bit-identical on a rerun. Against a higher-precision reference (old path with
STRATA_PREFILL_BF16X2=1), the FP16 pathis closer than the old path: median KL 0.0034 / 0.0044 / 0.0038 vs 0.0092 / 0.0096 / 0.0055, argmax agreement
95.5 / 96.5 / 95.8% vs 93.1 / 93.3 / 93.8% (FP16 activations keep 10 mantissa bits where BF16 keeps 7).
Limits
One machine, one model (IQ3_S packed from a non-setup GGUF), one corpus. gfx1031/1032 share the
gfx103prefix but were not run.Validation and docs
-DSTRATA_BUILD_TESTS=ON, the same options as the engine build, gfx1030, ROCm 10.0): 60 of 65 pass, the same 60 as6f32ec0without this change. Skipped:hip_prompt_attn_wmma(no matrix cores on gfx1030),hip_prefill_hipblaslt_gemm(no hipBLASLt table). Failed for reasons outside the engine, identically with and without the change:ple_parity(a Q2_0 PLE file that is not on this machine),expert_multi_test(this Zen 3 CPU has no AVX-512),platform_memory_test(mlockat the shell's defaultulimit -l).docs/AMD_HIP.md's RDNA2 section: what changes, the switch, the measured numbers and the ctest result above.Developed with an AI coding assistant; every number above was measured on 2x RX 6900 XT (gfx1030; one card for the single-card rows) / Ryzen 5 5600X, ROCm 10.0.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.