[xegpu] Performance enhancements for fused attention kernel. - #259
Merged
Conversation
Contributor
Author
tkarna
approved these changes
Aug 13, 2026
| initial_load_nd_ops = match_and_split( | ||
| gpu_func, ops={"xegpu.load_nd"}, nhandles=3 | ||
| ) | ||
| for load_op in initial_load_nd_ops[1:]: |
Contributor
There was a problem hiding this comment.
Since you only need to add prefetch ops to the loads inside the loop, you could first match the scf.for and then match load ops within the scf.for. The more semantics we can bake into the matching the more robust the schedules become.
Contributor
Author
There was a problem hiding this comment.
makes sense. I fixed it.
Contributor
Author
|
@tkarna please merge if no further comments. |
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.
This PR adds several perf improvements for the xegpu fused attention example.
<fastmath>flag formath.expfor faster exponentiation.Performance
Intel Data Center GPU Max 1100,
Z=2 H=8 n_ctx=4096 n_head=64f16,wg_rows=128 sg_rows=16 inner_loop_tile_size=64. Mean of 50 runs after 20 warmup (median of 3such runs). FLOPs =
4 * Z * H * n_ctx^2 * n_head= 68.72 GFLOP, i.e. the twomatmuls only, as in the flash attention tutorials.
main— K/V split into 4 chunks interleaved with 8 DPAS, f16 softmaxfastmath<fast>and without prefetchRows 2-4 all use a single full-tile K/V load with 2 DPAS ops and an f32 softmax /
f32 accumulators; row 2 adds nothing else, row 3 adds
fastmath<fast>on the twomath.expops, row 4 adds the K/Vxegpu.insert_prefetch(nb_prefetch=1).None of rows 1-4 spill; the intermediate f16-softmax version of row 2 spilled
3584 B per thread inside the loop, which is what moving the softmax to f32 fixed.
Reproduce:
Assisted by: Claude