mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1007] [CLOSED] hip: the QSA block scores on rocBLAS SGEMM, the solution measured on the card (opt-in; a 128K prompt +2.8% on gfx1030) #2961
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#2961
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/1007
Author: @Vop3p
Created: 10/6/2026
Status: ❌ Closed
Base:
main← Head:hip-qsa-select-sgemm📝 Commits (10+)
749d957setup (--backend hip): a system ROCm without the HIP development files falls back to the wheels (#446)5a30024calibrate: the engine's arguments come from the server's engine_args; a failed tuning says why (#447)9f60d13serve, setup: name the small split card that caps the prompt chunk; setup recommends the big card alone (#448)eb8da1d/metrics: each request's speculative draft counts, and their sums in the totals (#457)6a09387setup (--gguf-dir): GGUFs Strata cannot run are named as such, with the --family/--model to use (#444)d6a91e2docs: the Coder is weaker outside code, Chinese/CJK text included; the unpruned sizes for that (#438)d8d4ad3Merge branch 'f-135-eng' into rel-0.1.357b600d5Merge branch 'f-135-small' into rel-0.1.35d9ab843Engine 0.1.35: Windows AMD uses its bundled HIP runtime (#468 #461), the low-RAM resident mode on Windows 32 GB PCs (#467), fixes #460 #459 #446 #447 #457 #448 #444; setup requires it57bd713sycl: pipeline the expert cache's profile fill (model load 3-4x faster)📊 Changes
4 files changed (+70 additions, -24 deletions)
View changed files
📝
docs/AMD_HIP.md(+5 -5)📝
include/strata/kernels/qsa_select.hpp(+5 -0)📝
src/kernels/cuda/qsa_select.cu(+58 -19)📝
src/prefill/prefill.cpp(+2 -0)📄 Description
The QSA block scores - for every (query, KV block) the four indexer heads' relu(q . k) summed, K = 128 - run on sm_80+ as one GEMM (3xTF32 MMA) and on gfx12 as a WMMA GEMM (opt-in); every other HIP card runs the warp kernel, one warp per (query, block). On an RX 6900 XT (gfx1030, no matrix cores) that kernel is the prompt path's one term that grows with the context: 27 ms per 8K-token chunk at the start of a prompt, 752 ms per chunk at a 128K context (12 QSA layers x 32 batches of 256 queries x ~2 ms), 6.3 s of a 128K prompt's 66 s.
This PR gives those cards the same GEMM through rocBLAS SGEMM, opt-in (
STRATA_SELECT_SGEMM=1):rocblas_gemm_excomputesC[reach x nq] = pooled[reach x 128] . q_h^Tinto a scratch slab (nq x max_blocks floats, allocated once per device), a kernel adds relu(C) into the scores, and the tail block n_bid is scored byblock_scores_tail_kernelas the tensor-core paths do. FP32 throughout, rocBLAS's summation order: FP32-level and not bitwise the warp kernel, the class of accuracy the sm_80 path has.rocblas_gemm_ex_get_solutionslists once and the eight fastest three times, and keeps the fastest listed one - never rocBLAS's own choice, even when that is close at the bucket's top: a solution's time falls with the reach, the heuristic's choice changes with the exact shape (reach 65,536: 0.22 ms; reach 32,769, the same bucket: 1.6 ms). rocBLAS's choice is the fallback for a shape the solution refuses. The measurement is at the batch size of that call (the prompt path's full batch); a chunk's last, smaller batch reuses it (measured within 1.3x of that size's own best and a quarter of rocBLAS's choice), a larger batch measures again. It costs about 0.5 s per card, once per engine start, inside the first prompt's first chunk.STRATA_SELECT_SGEMM_TUNE=0keeps rocBLAS's choice;STRATA_SELECT_SGEMM_VERBOSE=1prints each bucket's measurement.find_package(rocblas)(quiet) when hipBLAS is 1.0 or newer setsSTRATA_ROCBLAS_AVAILABLE;strata_kernelslinksroc::rocblasthen. Builds without the package keep the warp kernel.Measured (RX 6900 XT 16 GB, gfx1030, ROCm 10.0.0, rocBLAS 5.6.0;
6f32ec0+ this):qsa_select_bench(synthetic, the repository's scorer-vs-scorer comparison and FP64 gate), 256 queries:End to end (2x RX 6900 XT layer split, Qwen3.8-Flash-Next GSQ-RCO IQ3_S,
--kv int8 --kv-resident 32768 --max-context 131072 --adapt-every 100000, temperature 0, 256 generated tokens, one run per arm, two engine starts;STRATA_PREFILL_TIMING=1;mainhas no rocBLAS table (#981), so these aremain's prompt speeds, not this rig's best):STRATA_SELECT_SGEMMunset=1qsa selectper 8K chunk at the prompt's endqsa selectThe selection scores are the one prompt term that grows with the context, so this is a long-context change: per 8K chunk the GPU timeline grows from 8.29 s (first chunk) to 9.42 s (the 16th) without it and from 8.42 to 8.95 s with it; at 50K the gain is about the size of the one-time measurement, below 16K there is nothing to gain. The larger part of what is left in
qsa selectat 128K is top-k, which this PR does not touch.Decode is unchanged (the decode path scores one query on the warp kernel and is not touched): 55-56 tok/s in both arms. The generated text is the same in both arms; the drafts accepted differ by a few (near-tie selections), as between the warp kernel and the sm_80 scorer.
Limits: one machine, one card family, one run per arm. The measurement picks by time alone; its result could differ between engine starts when two solutions tie, which changes near-tie selections, not the output's class of accuracy. Independent of #835 / #981 (the same rocBLAS kernel-choice problem on gfx1030, there with an offline table for the prompt path's fixed shapes; here the shape varies per call, so it is measured at run time - happy to move to one mechanism if preferred); the two add the same
find_package(rocblas)lines tocmake/hip_backend.cmakewith different comments, so whichever lands second needs a one-line rebase there. The relu-and-add pass runs once per head (0.7 of the 0.8 ms at 128K is these four passes and the tail kernel, the SGEMMs are 0.11); folding the four heads into one pass needs four scratch slabs (134 MB at a 128K context) and is a follow-up.Developed with an AI coding assistant; every number above was measured on 2x RX 6900 XT (gfx1030, PCIe 4.0 x8 each) / Ryzen 5 5600X, ROCm 10.0.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.