CUDA : add warp-per-row WKV7 kernel for single-token decode#26111
Open
123123213weqw wants to merge 1 commit into
Open
CUDA : add warp-per-row WKV7 kernel for single-token decode#26111123123213weqw wants to merge 1 commit into
123123213weqw wants to merge 1 commit into
Conversation
|
Hi @123123213weqw, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
Author
done |
123123213weqw
force-pushed
the
wangyue/rwkv7-cuda-t1
branch
from
July 26, 2026 01:33
f35ee11 to
33c0a39
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Follow-up to #26080.
This one speeds up the T/B == 1, C/H == 64 case of WKV7 — basically single-token decode on head size 64 models.
Right now each state row is handled by a single thread that keeps its own float state[64] and does the two 64-wide reductions serially. That's a pretty heavy thread, and there's no parallelism in the reduction. So I wrote a new kernel (rwkv_wkv7_f32_t1_warp_row) where a whole warp works on one row — each lane takes care of two columns, and reductions just use warp shuffles.
If the shape doesn't match, it falls back to the existing kernel, nothing changes there.
Additional information
How it's launched:
The kernel is templated on rows_per_block and carries launch_bounds(WARP_SIZE * rows_per_block, 2).
I tried rows_per_block = 2, 4 and 8 on my 4080 and got 293.1 / 293.3 / 293.4 tok/s, so it's basically noise — stuck with 4.
What changed:
Checked against the CPU backend with F32 inputs (NMSE < 1e-7):
The T=32/T=128 ones go through the old kernel, so the fallback path gets a bit of coverage too.
Benchmarks on RWKV7 1.5B Q4_K_M (gen 128, 10 runs, ngl 999, no prompt):
HIP shares this .cu file but I don't have any AMD hardware, so no ROCm numbers unfortunately.
Requirements