[Perf] preshuffle_gemm: vectorize scale_a epilogue load (4x32b -> 1x128b)#791
Open
coderfeli wants to merge 1 commit into
Open
[Perf] preshuffle_gemm: vectorize scale_a epilogue load (4x32b -> 1x128b)#791coderfeli wants to merge 1 commit into
coderfeli wants to merge 1 commit into
Conversation
The fp8/int8 epilogue loaded the 4 contiguous per-row scale_a values as 4 separate 32-bit buffer loads. IR diff vs the aiter reference showed this as the sole extra memory traffic (34 scalar i32 loads vs the reference's 16 vectorized; total buffer.load 69 vs 46). Load them as one 128b buffer_load (buffer_ops.buffer_load vec_width=4), matching the reference's 46 total loads. Verified on a 5cb28f6-based build (matching bindings), order-swapped A/B median-of-N, gfx950: - shape 256x6144x1536 : ~465 -> ~479 TFLOPS (+3%) - shape 32768x3072x1536: ~1628 -> ~1674 TFLOPS (+2.8%, won 4/4 rounds) - shape 2048x4096x512 : neutral (not load-bound) Correctness (verify_output + OOB) passes for fp8, int8, and ragged M=127. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
Summary
Vectorize the per-row
scale_aload in the fp8/int8 preshuffle GEMM epilogue:the 4 contiguous per-row scales (base offset is 4-aligned) now load as one
128-bit
buffer_loadinstead of four 32-bit loads.Why
An LLVM-IR diff of this kernel vs the aiter reference (matched config) showed the
compute is identical, and the only extra memory traffic was un-vectorized scale
loads: 34 scalar
i32buffer loads vs the reference's 16 vectorized<4 x i32>(total
raw.ptr.buffer.load69 vs 46). This change cuts our scalar scale loads to2 and brings the total
buffer.loadcount to 46 — matching the reference.Measurements (5cb28f6-based build, gfx950, order-swapped A/B, median)
Larger-M shapes benefit most (more epilogue tiles → the 23-fewer-loads compound).
Correctness (no threshold changes)
verify_output(rtol/atol 0.1) + OOB guard pass for fp8, int8 (shares the scalepath), and ragged M=127. Uses the same
buffer_ops.buffer_load(vec_width=4)pattern as
kernels/blockscale_preshuffle_gemm.py.🤖 Generated with Claude Code