mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #820] [CLOSED] prefill: the dense GGUF projections through MMQ on HIP (opt-in STRATA_DENSE_MMQ=1) #2849
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#2849
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/820
Author: @xendak
Created: 10/4/2026
Status: ❌ Closed
Base:
main← Head:mmq-gfx1030-main📝 Commits (1)
07629b0prefill: the dense GGUF projections through MMQ on HIP (opt-in STRATA_DENSE_MMQ=1), the K-quant instances on the HIP build📊 Changes
6 files changed (+168 additions, -8 deletions)
View changed files
📝
CMakeLists.txt(+12 -4)📝
include/strata/prefill/gemm.hpp(+8 -1)📝
include/strata/prefill/moe_mmq.hpp(+8 -2)📝
src/prefill/gemm.cu(+77 -0)📝
src/prefill/moe_mmq.cu(+23 -1)📝
tests/hip/prefill_mmq_parity.cpp(+40 -0)📄 Description
Notes
This repository is being on the move constantly so its hard to catch up to the
currentbranch, but i'll be trying to keep this up to date.. i don't have anai subscription though so sometimes the update speed is too demanding :')
What
The prompt path's dense GGUF projections run dequantize-to-FP16 + cuBLAS. On the
AMD cards (checked with rocprof on an RX 6900 XT) that is 68% of the prefill GPU
time at ~25% of the card's fp32-accumulate rate, while the same shapes through
llama.cpp's int8 MMQ run ~7x faster. This PR wires them through the MMQ path the
MoE experts already take, opt-in:
Gemm::native'sbeta == 0products with a covered type, a K that is amultiple of 256 values, and a matrix whose tile fits the card's shared memory
run
mmq::quantize+ onemul_mat_qper 1024-row chunk (the FP16 activationsare widened to FP32 in the dequant scratch, which the old path only fills
afterwards).
STRATA_DENSE_MMQ=1opts in; unset, nothing changes. Thefirst dense call prints
prefill gemm: dense MMQ on.STRATA_MMQ_KQUANTSnow also compiles theq4_k q5_k q5_1 q6_kinstances anddefines
STRATA_MMQ_KQUANTSon the HIP branch (the mixed-quant packs' densetensors are K-quants: this model's attention/PLE matrices are
IQ4_XS/IQ3_S/Q4_K/Q5_K/Q6_K), and adds
q6_kto the CUDA list (the usualattention weight of plain i-quant GGUFs).
moe_mmqgrows two small helpers:f16_to_f32and a{0, rows}boundswriter.
hip_prefill_mmq_paritygains synthetic Q4_K/Q5_K/Q6_K/Q5_1 passes (skippedwhen the build does not have the instances).
Why K must be a full 256-value multiple
llama.cpp's MMQ loads the weights in 256-value K chunks; the chunk past a
partial row reads bytes past the row - the next row's, or, for the last weight
row, past the whole tensor. The MoE path is safe because its expert gather
buffers end in a zeroed tail; a dense GGUF tensor is passed as-is, so what
follows it is the next tensor's blocks in the mapping. On swift-1.5-iq3_xxs the
640-value IQ4_NL shared-expert down picked a NaN scale out of those bytes and
produced a whole NaN output column, which zeroed the model output - found and
minimized with a type-bisect env knob and an operand-capture replay harness. The
odd shapes stay on the dequantize + cuBLAS path.
Testing (RX 6900 XT, gfx1030, ROCm 7.2.3, i7-13700KF)
-DSTRATA_MMQ_KQUANTS=ON -DSTRATA_ENABLE_HIP=ON, swift-1.5-iq3_xxs, the user'sknobs
(
--pool-workers 15 --adapt-every 1 --prefill 8192 --kv-resident 32768 --vram-reserve-mib 1024),bench_prefill.pyfresh medians of two ~4K and two ~8K trials:+73-74% fresh prefill; decode within noise. Greedy output is bit-identical for
the first 200 tokens of a short prompt; longer greedy runs diverge around token
~26 (the q8_1 activation rounding) and stay coherent.
hip_prefill_mmq_paritypasses with the new K-quant passes (rel_l2 ≤ 0.005 vs ggml's own dequantizer on
the host).
Not tested: CUDA builds (the instance list change is mechanical), other AMD
archs, the q6_k CUDA instance end to end.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.