mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2514] [CLOSED] HIP: decode QSA top-k on the register kernel at 262K capacity #4088
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#4088
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/2514
Author: @rindi-ismail
Created: 10/14/2026
Status: ❌ Closed
Base:
main← Head:hip-decode-topk-register📝 Commits (1)
785cee5HIP: decode QSA top-k on the register kernel at 262K capacity📊 Changes
1 file changed (+9 additions, -0 deletions)
View changed files
📝
src/kernels/cuda/qsa_select.cu(+9 -0)📄 Description
Title
HIP: decode QSA top-k on the register kernel at 262K capacity
Summary
On HIP with
--max-context 262144, every decode window runs the QSA top-k on the one-workgroup reference kernel. TheTK_PER_MAXregister kernel exists on AMD for exactly this capacity (its comment says so), but only the prompt path reached it. This sends decode there too.Measured with the repo's own tests (
qsa_topk_parity):End to end, on an R9700 + 7900 XTX split, decode at 157K context goes from 66.8 / 64.7 to 69.8 / 68.6 tok/s (two pairs), and short context is unchanged.
What changed
src/kernels/cuda/qsa_select.cu,qsa_block_topk, HIP only (9 lines):fit = TK_T * TK_PER= 33,792 blocks. With a 262,144 capacity (max_blocks= 65,538), every decode call went toqsa_block_topk_ref. That kernel is one 256-thread workgroup per query, rereading the keys on each of its four radix passes, so a decode window with 2-6 queries ran its selection on 2-6 compute units.TK_T * TK_PER_MAX(66 per thread, 67,584 blocks), so decode runsblock_topk_reg_kernel<TK_PER_MAX>. That kernel reads only the liven_bid + 1blocks and returns the same ids.STRATA_TOPK_DECODE_REG=0restores the old dispatch. It is read once, like the other switches here.Left alone:
#if defined(__HIPCC__); the#elsebranch is the original line)countedrule andkRegMinBlocksHow I checked
Ids.
src/kernels/qsa_topk_parity.cppwas built against this change and run on each card withHIP_VISIBLE_DEVICES:--selftest: PASS on both.COUNT=0, capacity 262,144) at 2,500 / 4,096 / 8,192 / 16,384 / 24,576 / 32,768 / 98,304 / 160,965 / 262,144: PASS, with identical ids for continuous, 64-level and all-equal scores.Kernel time (the parity test's
dispatchedtime, 4 queries, before -> after; 30-50 reps):Below about 4K cells the register kernel's fixed cost is 3-4 µs more per call. Over 12 QSA layers that is under 0.2% of a ~26 ms window, and short-context decode measured the same.
Where it showed up. A decode profile (
STRATA_VERIFY_PROFILE=1 STRATA_DECODE_TIMING=1 STRATA_SPLIT_TIMING=1) at 1K / 64K / 157K showed the same ~2 tokens per window at every length. The QSAscores+topkper window grew as follows:End to end.
--pipeline-windows 2(the default), Core Ultra 7 270K Plus, 125 GiB RAM, Ubuntu 26.04.1, ROCm 7.2.4.--max-context 262144, int8 KV,--kv-resident 32768,--spec 4 --mtp.decode timingline.STRATA_TOPK_DECODE_REG=0(before)Tokens per window were 2.17-2.38 in every arm.
Builds:
gfx1100;gfx1201).Extra Notes
block_topk_reg_kernel. It is another 10-25% on the kernel and showed no visible end-to-end change. It is on my fork'sxtx-r9700-tuningbranch with the raw logs and scripts (docs/XTX_R9700_SPLIT.md).🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.