Commit Graph
2 Commits
Author SHA1 Message Date
claudeandClaude Opus 5.5 5e44973a36 libxe2: quad prefill attention two 16-row groups a work-group, loops fully unrolled
Fewer query heads a work-group (more work-groups a core) lost badly -- 28.3 -> 16.5 TFLOPS at 64k
with two of six, 11.3 with one: the six heads' threads sharing each page through L1 matter more
than occupancy. So the other way: for gqa <= 6 a work-group is two 16-row groups (48 threads, 126
KiB of staged queries and swap area), walking to its later group's end so every thread joins
every barrier (the earlier group's extra keys are past its rows' positions: hidden, P = 0, the
same output). Queries read from global instead of staged cost ~10% and were dropped; three row
groups (72 threads) do not launch. #pragma unroll had left the score and value loops rolled (5
DPAS in the binary); clang loop unroll(full) gives the 64, worth ~1%.

Probe, 2048 rows over 2k / 8k / 32k / 64k: 18.8 / 28.0 / 28.5 / 28.1 -> 18.4 / 30.0 / 30.5 / 30.5
TFLOPS, output bit-identical. Fresh prompts (mtp4fc, MTP 6): ~2.1k 1426 -> 1425 tok/s, ~24k 1221
-> 1234, ~47k 1025 -> 1048. rad-kbench attn --all-rows 227/227, full replay 1410/1410, greedy 8/8.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 02:28:58 +01:00
claudeandClaude Opus 5.5 86955a62c5 libxe2: prefill flash attention four threads a (16 rows, query head), at the default register file
The 8-row form holds a thread's 8 x 256 f32 accumulator, which keeps it on the large register file
at 4 threads an EU; its stall samples were scoreboard waits, too few threads to cover the latency
of each step's loads and DPAS chains (paired threads sharing 16 rows showed it: 15 TFLOPS at one
work-group a core, 23.6 at two).

xe2_attn_flash_quad.cpp: a quad of threads takes 16 query rows of one head and 64 keys a step,
thread qd scoring page qd for all 16 rows (two DPAS chains on each key tile), the quad swapping row
maxima, then P and row sums, through local memory, and each thread running P V for its quarter of
the head dims. A 16 x 64 f32 accumulator: 128 registers with no spill, two work-groups (48
threads) a core. The softmax runs in the step's two 32-key halves in turn, so every value is the
8-row form's: probe output bit-identical at 2k..64k. It lives in libxe2 proper (the large-register
library would force it to 256); attn_paged_fast tries it first for rows >= 16, XE2_ATTN_NO_QUAD
skips it. (The query staging split four ways, by head-dim steps too, gave wrong output; two
threads stage a half each, not understood yet.)

Probe, 2048 rows over 2k / 8k / 16k / 32k / 64k of context: 16.7 / 25.0 / 24.0 / 23.4 / 22.3 ->
18.8 / 28.0 / 28.2 / 28.5 / 28.1 TFLOPS. Fresh prompts (mtp4fc, MTP 6), against 2da2eb0: ~2.1k
1419 -> 1426 tok/s, ~6.9k 1382 -> 1400, ~24k 1177 -> 1221, ~47k 952 -> 1025.
rad-kbench attn --all-rows 227/227, full replay 1410/1410, greedy 8/8.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 01:55:04 +01:00