Repository navigation
dense_gemv_bf16_batchm on HIP: stage the activation k-tile in LDS (Flash-Next C4/C8 +12%, byte-identical) - #298
Merged
Merged
Conversation
…row cache-set aliasing; 1.45-3.4x, byte-identical) With the M activation rows read straight from global memory, rows K * 2 bytes apart, every iteration's M lines land in one cache set whenever that stride is a multiple of 4 KiB. Framework f147 (M = 8, N = 2560): - K 4096 / 6144 / 8192: 55 GB/s - K 6400 / 6656: ~170 GB/s - at K 6144: M 1 166, M 2 139, M 4 66, M 8 56 GB/s The HIP path now stages each k-tile of every row in LDS once per block, shared by the block's 4 outputs. Each thread still walks kv = lane, lane + 64, ... in the same accumulation order. M == 1 keeps the direct loads (the barriers cost it ~12%). The gb10 path is untouched. f148, engine-built code objects, 200 cold launches, C byte-compared on random A/B, every shape IDENTICAL: - N 16384 K 2560 M 8 (Flash-Next GDN qkvz): 0.524 -> 0.362 ms (x1.45) - N 2560 K 6144 M 8 (GDN out_proj): 0.565 -> 0.225 ms (x2.5) - N 2560 K 2560 M 8: x1.45 - N 16384 K 6144 M 8: x3.4 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Author
|
27B no-regression (strix s173, main-292 vs a621fe5, AR ×2): C1 9.55 → 9.6; C4 26.0 → 25.7; C8 32.55 → 32.85 (within round noise); solo text identical 8/8; identity 5/8 both; 0 faults. CI + DevLab 41233022277 green. Merging. |
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.
Cause: the batched BF16 decode GEMV read its M activation rows straight from global memory, K × 2 bytes apart. When that stride is a multiple of 4 KiB, every iteration's M lines land in one cache set.
Framework f147 (engine-built code object, M = 8, N = 2560):
Flash-Next's GDN out_proj is K = 6144, and it was 11% of the C8 decode window (f141).
Fix: the HIP path stages each k-tile of every row in LDS once per block, shared by the block's 4 outputs. Each thread still walks
kv = lane, lane + 64, …in the same accumulation order. M == 1 keeps the direct loads (the barriers cost it ~12%). The gb10 path is untouched (#if defined(__HIP_PLATFORM_AMD__)).Kernel (f148, orig vs staged, 200 cold launches, C byte-compared on random A/B, every shape IDENTICAL):
End to end (framework f149, main-292 170c3ed vs a621fe5, Flash-Next NVFP4 via serve-amd MAX_BATCH 8, lane on, AR, Gufo protocol ×2):
The same staging in the FP8
w8a16_gemv_batch8_dyn_vl2_n2tier measured only +5..17% at M 8 and −6% at M 5 (f150, also byte-identical). FP8 rows are half as wide, so the aliasing bites less. Left out of this PR.🤖 Generated with Claude Code