HIP: use upstream rows_per_warp() on RDNA3.5 - #106
Open
liangliangchang wants to merge 1 commit into
Open
liangliangchang wants to merge 1 commit into
liangliangchang wants to merge 1 commit into
Conversation
The RDNA3.5 override returns 32 for J>=64 && J%32==0, with carve-outs holding
q4_0/q8_0/q4_K/q5_K at 16. rows_per_warp/16 is ntx, so 32 selects the ntx=2
schedule, and for every type without a carve-out that schedule is several times
slower on gfx1151.
test-backend-ops perf on gfx1151, m in {1024,4096}, k=4096, percent faster with
upstream's unconditional 16:
type n=48 n=64 n=96 n=128
iq4_nl +0.0 +553.1 +441.8 +2.0
iq4_xs -0.0 +543.1 +484.2 +2.4
mxfp4 -0.0 +539.6 +437.1 +2.6
q5_0 +0.1 +448.6 +418.1 +6.4
iq2_xxs -0.0 +414.9 +314.5 +1.6
iq3_s +0.1 +409.5 +291.6 +1.9
q5_1 -0.0 +15.5 +18.2 +8.3
q4_1 -0.0 +3.1 +0.6 +22.7
q6_K -0.2 +3.5 +0.0 +2.0
q3_K +0.1 +2.1 +0.1 -0.3
q4_K +0.0 +0.4 -0.2 +1.3
q5_K -0.0 +0.8 +0.8 +0.2
q2_K -0.2 -0.1 -0.1 +0.1
n=48 is a control, since both variants return 16 there. q4_0 and q8_0 are a
second control, already 16 at every width. All four control columns stay within
+-0.2%. Every effect above 5% reproduces on a second board with the same sign
and within 2x, at a per-shape noise floor of 0.06-0.74%.
The stock perf list jumps from n=32 to n=128, so J=64 and J=96 are not covered
by it; these numbers come from an added n in {48,64,96,128} grid. Q4_K_M models
are unaffected end to end (+-0.5%), because q4_K/q5_K/q6_K are exactly the types
whose deltas are under 3.5%; the large wins are in the iq*, mxfp4, q5_0 and q5_1
families.
One shape prefers 32, q4_K m=4096 n=96 at -1.1%, against 35 shapes where 16 wins
by more than 5%, so keeping a per-type rule is not worth re-creating the hazard.
Correctness: 1510/1510 MUL_MAT on both arms.
Assisted-by: Claude Opus 5
Co-authored-by: Cursor <cursoragent@cursor.com>
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.
The RDNA3.5 override returns 32 for
J>=64 && J%32==0, with carve-outs holding q4_0/q8_0/q4_K/q5_K at 16.rows_per_warp/16isntx, so 32 selects the ntx=2 schedule, and for every type without a carve-out that schedule is several times slower on gfx1151.This drops the override so RDNA3.5 uses upstream's unconditional 16. The resulting function is byte-identical to
ggml-org/llama.cppmaster.Measurements
test-backend-ops perfon gfx1151, m in {1024, 4096}, k=4096. Percent faster with upstream's 16:Six types run 4-7x slower today at n=64 and n=96.
Controls and reproducibility
Coverage note
The stock perf list jumps from n=32 straight to n=128, so J=64 and J=96 - the only widths where q4_K/q5_K differ - are not covered by it. These numbers come from an added n in {48, 64, 96, 128} grid; that harness change is not part of this PR.
Q4_K_M models are unaffected end to end (+-0.5% on Qwen3-8B, Qwen3.5-9B, LFM2-8B-A1B), because q4_K/q5_K/q6_K are exactly the types whose deltas are under 3.5%. The large wins land in the iq*, mxfp4, q5_0 and q5_1 families.
Why not a finer-grained rule
One shape prefers 32 - q4_K m=4096 n=96, at -1.1% - against 35 shapes where 16 wins by more than 5%. Keeping a per-type rule is not worth re-creating the hazard.
Correctness
1510/1510 MUL_MAT on both arms.
Assisted-by: Claude Opus 5
Co-authored-by: Cursor cursoragent@cursor.com