gemm_nt_q at w4a16_asym (M <= 64) ran 8-row blocks, each reading and decoding the whole 4-bit weight:
16 rows paid twice, 64 rows eight times. launch16x2 takes two 8-row bands against each group's codes,
loaded and decoded once, the activation loaded 32 columns at a time so both bands fit the default
register file (no spill). The per-row arithmetic is launch16<8>'s. XE2_W4_RB8=1 keeps 8-row blocks.
Qwen3.8-27B int4 (RedHatAI, as shipped), MTP depth 3, Arc Pro B65: 4 concurrent 256-token streams
97.6-99.2 -> 109.4-110.0 tok/s aggregate (+12%); one stream unchanged (43.1 -> 43.2). XE2_W4_CHECK=50
against libref's loop on the host: rel_l2 <= 6.6e-5 on every shape, tens of ties in ~10^5 outputs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
At 9 <= M <= 16 the bf16 skinny GEMM (gemm_nt, logits_gemm) fell to the SIMT kernel's one column a
sub-group, 6-8x the 8-row DPAS kernel's time on the same weight. The ESIMD kernel gains RC = 16: two
8-row DPAS on each transposed weight tile, rows past M clamped by the 2D load and not stored.
MiniCPM5-2B bf16 on the Arc Pro B65 (rad-kbench --bench, cold weights, M = 16): gate_up
712 -> 104 us, down 465 -> 61, qkv 148 -> 29, o 145 -> 25. Twelve concurrent 256-token streams:
198 -> 654 tok/s aggregate. rad-kbench gemm_nt + logits_gemm: MiniCPM5 360/360, fixture 686/686.
XE2_GEMV_SIMT=1 keeps the SIMT form.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
attn_flash_esimd (decode / verify and prefill) and attn_flash_quad (prefill) were written over HD
but gated to head_dim 256 (Qwen3.8's full attention); every other model fell to the SIMT kernel.
Both now dispatch 64, 128 and 256; the decode merge takes HD / 16 values a lane.
MiniCPM5-2B bf16 (head_dim 128, gqa 8) on the Arc Pro B65, same build, XE2_ATTN_SIMT=1 as before:
decode 69.3 -> 83.1 tok/s, prefill at ~2k tokens 1806 -> 8080 tok/s. rad-kbench attn_paged:
fixture 207/207, MiniCPM5 160/160, Qwen3.8-27B 160/160. KL against XE2_EXACT=1 over the
12-document corpus: mean 0.00060, top-1 98.59% (the SIMT kernel: 0.00060, 98.59%).
Qwen3.8-27B int4 unchanged (30.1 tok/s, 1361 tok/s prefill).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts, both sides kept:
- abi: RAD_ABI_VERSION 37 (upstream); the fork's RadBuildCtx.plain_norm after upstream's
expert_file_tier, widened to int64_t so it starts past ABI 37's 208-byte struct instead of in
its tail padding (abi_layout_test); RadSyclStream rows after RadShapeGen*.
- arch/common/rad_block_gdn_fp8.h: upstream's q8_rot guard and the fork's o_plain guard
combined; the decode-row q_o.step only where q_o is declared (!o_plain).
- docs/OPS.md: upstream's optional params on sample_logprobs, the fork's q_temp on
mtp_couple_propose.
Also ignores /baseline-models/ (local model copies).
Host tests: arch_test's MTP lint/graph-pin failures are unchanged from before the merge (the
fork's mtp.fc LinearFP8, 10a99a5); avx_check's hand-built moe_gemm_q w4a8 case also fails on
upstream's own files; images/videos need FFmpeg; three binaries over their CPU budget on this VM.
SYCL card tests 3/3.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The score tile is now keys by query rows: K is the A operand (plain 2D loads instead of the
transposed one), Q^T the B operand, staged once a work-group by a transposed load. With the 16
query rows across the lanes, a row's max is a vertical max over the page's 16 key rows instead of
32 horizontal reductions a thread a step, exp(S - base) one subtract a key row, and a row's sum is
taken in reduce<>'s own order (lanes i and i + 8, then i + 4, i + 2, i + 1 -- key rows here), so
every value is the old one: probe output bit-identical, 64 x 64 through 64k. P goes to the swap
area as [query][key], two keys a 32-bit scatter lane, the layout the P V step already reads.
XE2_FAQ_KA=0 at build time keeps the S = Q K^T form.
Probe, 2048 rows over 2k / 16k / 64k: 16.9 / 30.6 / 30.5 -> 18.8 / 32.9 / 32.5 TFLOPS. Fresh
prompts (mtp4fc, MTP 6), against 5e44973: ~2.1k 1425 -> 1427 tok/s, ~24k 1234 -> 1249, ~47k 1048 ->
1066. rad-kbench attn --all-rows 227/227, full replay 1410/1410, greedy 8/8.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
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>
At depth the kernel fell from 18 to 13.6 TFLOPS (a 2048-row chunk of Qwen3.8-27B's 24/4 heads,
head_dim 256, over 8k -> 64k of context): every 8-row work-group streamed its kv head's whole history,
and the stall samples were scoreboard waits on each step's loads, issued just before their DPAS.
- gqa <= 8: four 8-row blocks a work-group (the threads of one Xe-core walk the same pages, so a
page comes from L2 once for 32 rows; 128 KiB of staged queries), and two of its threads prefetch
the next step's two pages to L1 (one gather lane a 64-byte line). Each alone was worth little or
lost (prefetch from 8-row work-groups: 7.9 TFLOPS at 64k); together 13.6 -> 19.6.
- the value loop's 2D loads 8 at a time before their DPAS (2, 4, 16 measured; the score loop's
batched the same way spilled and lost).
- the accumulator rescale skipped when no row's max moved (x * 1.0f is x).
Every sum is in the order it was, so the output is unchanged: probe output bit-identical at
2k..64k, rad-kbench attn --all-rows 227/227, full replay 1410/1410, greedy 8/8.
Probe, 2048 rows over a context of 2k / 8k / 16k / 32k / 64k: 13.9 / 18.3 / 16.8 / 15.2 / 13.6 ->
16.7 / 25.0 / 24.0 / 23.4 / 22.3 TFLOPS. Fresh prompts (mtp4fc, MTP 6): ~2.1k 1423 tok/s, ~24k 1177,
~47k 952 (bench-standard's 32k / 64k depths measured 1077 / 806 at 7f95c56).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vec8 gave a work-item 8 channels of one token and reloaded the channels' taps and the whole window
every token. The 4-tap form (the conv width of Qwen3.5/3.8's delta-net layers) takes 8 tokens: the
taps and bias once, the window slid a row a token within a sequence and loaded whole at a
sequence's start. Each output is vec8's, tap for tap; XE2_GDN_CONV_TOK1 keeps the one-token form.
qwen3.8-27b-w4a16 (mtp4fc), a ~2.1k-token prefill: the convolution 434 -> 361 us a call (48 a
prompt). rad-kbench gdn --all-rows 90/90; greedy 8/8 identical.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8fced2e turned on -ze-intel-enable-auto-large-GRF-mode for all of libxe2, which gave the flash
attention kernels the 256 registers their grf_size<256> asks for (AOT never honours the property:
sycl-post-link records it on the image, and only the runtime's JIT reads it). The auto mode also
moved ~25 SIMT kernels that never spilled at 128 to 256 and half their threads: gdn_conv_prep
434 -> 687 us a call at a 2k prefill.
The attention source is now its own shared library, xe2_grf256, linked with
-ze-opt-large-register-file, and the rest of libxe2 is back on the default it was tuned under.
libxe2 needs it from kernels/libxe2.d ($ORIGIN rpath; beside the plugins, not among them, where
the loader would take it for one); both installs carry it. refuse() is exported from libxe2 so the
helper's refusals still reach last_refusal().
rad-kbench replay (libxe2, libref, spechub) 1410/1410, attn --all-rows 227/227, and from an
installed tree. qwen3.8-27b-w4a16 (mtp4fc), fresh prompts, against the auto mode: prefill ~2.1k
tokens 1381 -> 1407 tok/s, ~6.9k 1326 -> 1347; decode 24 corpus prompts 90.4 -> 90.6; greedy 8/8.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
S = Q K^T for a step's two pages ran as two chains of 16 DPAS, one after the other, each DPAS
waiting on the last's accumulator. With both pages mapped they now advance together a head-dim
step at a time, the same sums in the same order; a step with one page keeps the single chain.
(Tried before the large-GRF fix it was slower: the extra K operand spilled.)
Probe fa.cpp (24/4 heads, head_dim 256): 8192 tokens 15.6 -> 18.9 TFLOPS, 2048 tokens 13.4 ->
13.5; output identical. rad-kbench attn --all-rows 227/227. qwen3.8-27b-w4a16 (mtp4fc), fresh
prompts: prefill ~6.9k tokens 1301 -> 1326 tok/s, ~2.1k 1376 -> 1381; greedy 8/8 identical.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No kernel's grf_size<256> property reached the card: sycl-post-link records it on the device image
(sycl-grf-size=256 in the image's properties), but only the runtime's JIT path reads that and adds
the large-register option, and this build compiles AOT at link time with the -options string alone.
Every kernel ran with 128 registers; prefill attention spilled 4 KiB a thread and spent 66% of its
stall samples on the scoreboard. -ze-intel-enable-auto-large-GRF-mode gives a kernel the large file
when it needs it: the flash attention kernels get 256 with no spill, the w4 GEMMs keep 128.
Probe fa.cpp (24/4 heads, head_dim 256): 2048 tokens 7.3 -> 13.5 TFLOPS, 8192 tokens 8.3 -> 17.8,
output identical. rad-kbench replay (libxe2, libref, spechub): 1410/1410. qwen3.8-27b-w4a16
(mtp4fc), fresh prompts: prefill ~2.1k tokens 1346 -> 1376 tok/s, ~6.9k tokens 1177 -> 1301; decode
over 24 corpus prompts 90.2 -> 90.4; greedy 8/8 identical.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
down's shape (N <= 8192, K >= 16384) kept the SLM-staged form. It now takes the per-thread L1 form
too, with the work-groups in bands of 32 row groups: rows fastest made every 256-column slice read
all of A from memory (35 MiB at M = 2048, twenty slices), where a band's A stays in L2 across its
slices. The SLM form had no other user and is gone.
Probe w4p.cpp, down 5120 x 17408, int8 TOPS: M = 1024 61 -> 70, M = 2048 76 -> 79, M = 4096
80 -> 86; every output identical (M = 517 and 2048, all six shapes). rad-kbench gemm_nt_q
--all-rows 371/371. qwen3.8-27b-w4a16 (mtp4fc), fresh ~2.1k-token prompts: prefill ~1314 ->
~1345 tok/s; greedy 8/8 identical.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The activation was staged in SLM a work-group, a group (128 of K) at a time, double-buffered
behind a barrier. Each thread now loads its own A operands with 2D block loads, which hit L1 (the
work-group's threads read the same rows): no staging store and no barrier a group, and the grid
goes rows fastest at every width. A long K over a narrow output (down's 5120 x 17408) keeps the
SLM form, where staging still pays.
Probe w4p.cpp at M = 2048, int8 TOPS: gate_up 97 -> 115, inz 81 -> 96, qg 73 -> 80..98, out
90 -> 108, kv 72 -> 92, down unchanged; every output hash identical at M = 100, 517, 2048 and
4096. qwen3.8-27b-w4a16 (mtp4fc), fresh ~2.1k-token prompts: prefill ~1236 -> ~1314 tok/s;
greedy 8/8 identical. Shape-only rule, so every w4a16 model's prefill takes it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mtp.fc was declared plain bf16 and run by gemm_nt. It now goes through LinearFP8 over the
bf16 concat plane, so its form follows the stored encoding like every other linear: bf16 as
before (the same gemm_nt op, greedy output identical on qwen3.8-27b-w4a16-rtn-mtp4, 8/8), or a
4-bit weight with a zero point on the w4a16 / w4a8i8 GEMMs. Applies to every arch built on
MtpBlockFP8.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The helper's walk over the 1024-slot candidate row (mostly pads) was a dependent global load
a step; a work-group stages the row first and the helper reads it there, arithmetic unchanged.
Seeded coupled decode 98.3 -> 98.5 tok/s, the same draft trajectory.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sample_topk walked the whole vocabulary top_k times with one work-group a row (2.3 ms at
8 rows); each 4096-logit chunk now takes its own top k from registers and a row's merge takes
the top k of those -- the same keys, the order being total. narrow and sample_pick stage a
row's 1024 candidates (mostly pads) in local memory and compute the exps a lane each before
the serial walk; logit_rerank spreads a candidate over up to 16 sub-groups (290 -> 72 us).
Outputs unchanged (kbench; the same draft trajectory). Coupled MTP decode of a seeded code
prompt 90.5 -> 98.3 tok/s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The loop is ALU-bound and rebuilding each load's 64-bit address was a third of its
instructions. Probe at M = 2048, int8 TOPS: gate_up 91 -> 98, inz 74 -> 81, down 64 -> 76,
out 86 -> 90; outputs bit-identical. A 2234-token prefill 1063 -> 1127 tok/s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 128-wide broadcast copies of the row base and correction overflowed the register file;
per-row selects compute the same values (bit-identical output) and the 2048-token call
drops from 7.8 to 6.6 ms.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- arch: under --draft-coupling the MtpBlockFP8 draft head keeps the 2-bit logits' top 8,
rescores them against the trunk's head (logit_rerank) and runs one mtp_couple_propose a
round, as the Flash-Next head does; qwen35_fp8 declares the draw/state planes and a
pitch-8 proposal. Off, nothing changes.
- libxe2: device rows for mtp_couple_propose / mtp_couple_verify, a work-item a row over
spechub's own row helpers and argument readers (built into xe2_couple.cpp).
- spechub: mtp_couple_propose takes an optional q_temp (Q = softmax(score / q_temp)); exact at
any value. RADIANCE_MTP_Q_TEMP sets it on qwen35_fp8 (default 1: 1.0 > 0.7 > 0.5 here).
w4a16-rtn-mtp4, depth 7 adaptive, temperature 0.7: decode proxy 76.9 -> 78.8 tok/s,
BetterBench decode 80.5 -> 81.7; greedy 8/8 identical with coupling on. Host tests
(spechub|couple|abi|mtp) 7/7.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63.0 us a call from 71.4 (unitrace, decode at depth 5); greedy 8/8 and the 2234-token
continuation identical.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Under Geom::plain_norm the ssm_out projection is probed; when it reads no codes, the recurrent
epilogue gets no code pair (its fp8 group and the re-read of o drop out) and the prefill
quantiser is not declared. Greedy 8/8 and the 2234-token continuation identical; 1902 -> 1854
declared ops; 2234-token prompt 1039 -> 1054 tok/s; decode proxy 83.1 -> 83.6.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The DPAS now leaves sum - zero * asum directly (int16 operands, |zero * asum| <= 15*127*128),
so the epilogue is a convert and the two scalings: no zero-init move, no f32 multiply and
subtract an element. The same integer, so the same output (2234-token continuation and greedy
8/8 identical).
Probe at M = 2048: gate_up 83 -> 91, inz 81 -> 88, qg 80 -> 87, out 80 -> 86 int8 TOPS.
2234-token prompt 1001 -> 1039 tok/s. (A blocked work-group order and an L1 prefetch of the
codes were tried: neither helps; down at K = 17408 stays at ~66.)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The scalar elementwise kernels spent their prefill time in int64 divides and generic
accessors (silu_mul ~0.7 ms a call). bf16 rows now take a 2-D range of eight columns a
work-item with 16-byte loads and stores, the same per-element arithmetic. sigmoid with a bf16
output takes the float exp, libref's double chain again only near a bf16 tie (as silu does).
kbench add/mul/sigmoid bit-exact; greedy 8/8 and the 2234-token prompt's continuation
identical. 2234-token prompt 960 -> 1001 tok/s; decode proxy 82.5 -> 83.1.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The (token, channel) form spent ~1.8 ms a 2048-token chunk in int64 divides and per-channel
branches. A work-item now takes eight channels of one head in 32-bit index math with 16-byte
loads and one 16-byte store, each output computed tap for tap as before; the scalar form
remains for other layouts (XE2_GDN_SCALAR_CONV=1 forces it).
2234-token prompt 877 -> 960 tok/s, its 96-token greedy continuation identical to the scalar
form's; greedy set 8/8 identical.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The stall samples put ~75% of the prefill GEMM in its per-group epilogue (128-wide broadcast
copies and int32 multiplies), not the DPAS. sum, zero * asum and their difference are integers
under 2^24, so forming them in f32 a row at a time gives the same values: byte-identical output
(kbench 2676/2676, greedy 8/8 identical).
Probe at M=2048: gate_up 76 -> 83, inz 75 -> 81, qg 74 -> 80 int8 TOPS. BetterBench prefill
@2000 931 -> 957 tok/s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- libxe2 serves `add_rmsnorm` (device-only; libxe2 now publishes its schema, libr4d's spelling):
x += a then rmsnorm of the x written in one pass, at rmsnorm's own bf16 partition, so both
outputs are byte-identical to the pair here. NormQuantFP8's plain form takes it where it
resolves (one launch instead of `add` + `rmsnorm`, ~150 a round).
- AttnGatedFP8: under the plain norm an out projection that reads no codes skips the
quantiser after the gate's sigmoid + mul.
Greedy output 8/8 identical to the previous commit; decode proxy 81.2 -> 82.5 tok/s; declared
ops 2046 -> 1902.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Under Geom::plain_norm a down projection that reads the bf16 plane and no codes (w4a16 /
w4a8i8 quantise their own activation) takes `silu_mul` instead of gated_quant_fp8 (the E4M3
pass nobody read: 17 us a call, 64 a round).
- silu_mul: float exp, libref's double chain again only near a bf16 tie (near_bf16_tie, as the
gdn activations): op oracle 300/300 bit-identical at tolerance 0.
- rmsnorm's bf16 head rows (n = 128..512): a lane its contiguous slice by 16-byte loads (16 us ->
a few us a q / k norm call). rad-kbench rmsnorm 240/240.
- the flash kernel's staged queries sized for gqa <= 8 (24 of 64 KiB a work-group).
Greedy decode proxy (depth 5, mtp4, draft vocab 131072): 74.3 -> 81.2 tok/s. KL against the
exact reference 0.00231 (was 0.00239), top-1 96.70%.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
attn_paged_fast's single-sequence calls under 16 rows took the SIMT kernel (a lane a key, full
256-wide dots: ~137 us a verify call at ~400 tokens). The flash kernel now has a split form: a
work-group a (row block, kv head, partition), partitions past the context exit at once, each
partition's unnormalised (m, l, O) to scratch and a merge pass a sub-group a (row, head).
XE2_ATTN_DEC_SIMT=1 keeps the SIMT kernel. rad-kbench -m mtp4 --op attn_paged: 240/240; greedy
against SIMT 5/8 identical, the others diverge late at near-ties.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- gdn_kkt_solve on DPAS (~0.4 ms at 2048 tokens against 7.7), the int8 head's DPAS forms at 9-16
rows (verify past depth 7), the plain block norm (RadBuildCtx::plain_norm, set on the SYCL
backend: `add` + `rmsnorm` where no reader takes the E4M3 codes) with the fast rmsnorm rows.
- rmsnorm's bf16 rows up to 8192 wide: a work-item eight elements by one 16-byte load (the generic
form walked 20 dependent loads a work-item): 24.7 -> 3.3 us a decode norm, ~3.5 ms a round.
- w4a16: a bf16 activation narrowed to fp16 at the kernel's own load (the separate cast launch
before every GEMM is gone), bit for bit the same.
- RADIANCE_MTP_DRAFT_VOCAB=N: the 2-bit draft head over the vocabulary's first N ids (a prefix
shortlist, GRIMOIRE's idea); the u2 layout hook takes an op N below the weight's rows. 131072:
greedy acceptance identical on the decode proxy, draft head 650 -> 351 us a pass.
KL against the exact-kernel reference (2002 positions): 0.002386, top-1 97.30% (was 0.002376 /
96.80%). Decode proxy (greedy, depth 5, mtp4): 72.0 -> 74.3 tok/s with the prefix.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts from the old m2xfp branch take upstream's version. Two libxe2 fixes the merge needs:
- rad_plugin_abi_layout: the plugin now exports the ABI layout hash the loader checks.
- gemm_nt_q_w4a16: upstream 492d33c sends bf16 activations to the w4a16 GEMM (the separate cast
is gone); the fast kernel took only f16, so every call fell back to the exact path (decode
~2.5 tok/s). A bf16 activation is narrowed to f16 (round to nearest even) into a workspace first,
the dropped cast bit for bit; decode back to ~57 tok/s on one request.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Benchmarks: 5ed4ff8 (49.4 / 491.5), 8e8b435 at depth 5 on the rtn file (51.4 / 688.8) and on the
int4-MTP file (54.2 / 691.4). The session's prefill work, the chunk scan's KL check, the ESIMD
private-memory trap, the int4 MTP block's conversion and results, and the work left uncommitted in
the tree when the user asked to stop: the DPAS kkt solve, fast rmsnorm rows, the head at 9-16 rows
(rad-kbench fixture 201/201) and the plain block norm (untested), each with what it still needs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The exact scan runs libref's chains one work-item each: ~12.8 GFLOP of a 2234-token prefill of
Qwen3.8-27B took 1.1 s. xe2_gdn_esimd.cpp is the chunked delta rule in flash-linear-attention's
form, in two ESIMD launches:
prep every (sequence, chunk, v head) at once: U = A beta V (f32), W = -A beta e^g K,
Q' = scale e^g Q, R = scale e^{g_i - g_j} Q K^T (j <= i), KT = (e^{g_last - g} K)^T (bf16)
scan a work-group a (sequence, v head, 32 value columns), the f32 state slice in registers:
V' = U + W S, O = Q' S + R V', S = e^{g_last} S + KT V', S and V' passed between the
threads through local memory as DPAS B tiles
bf16 operands into f32, and V' regrouped (A beta V - A beta e^g K S), so it is a fast row held to
rad-kbench's gdn_chunk_scan tolerance (D13); XE2_EXACT=1 (or XE2_GDN_SCAN1=1) keeps the exact
kernel, as does any layout its 2D loads cannot take.
Checks: probe gdnp.cpp against a host copy of libref (partial chunks, 3 sequences, grouped k
heads, h0/ht): o rel_l2 3.2-3.8e-3, ht 0.5-3.0e-3 (tol 2e-2). rad-kbench fixture 30/30, worst
4.8e-3. KL against an XE2_EXACT=1 reference over the 12-document corpus (2002 positions, 2048-token
batches): mean 0.002376, top-1 96.80%, PPL x0.9991 -- with the exact scan 0.002380, 96.65%,
x0.9982. ctest -L sycl 3/3.
An ESIMD note: Lin::off indexes its shape and stride arrays at run time, which puts a private copy
of the kernel argument in memory, and a kernel that does not spill gets no scratch for it -- the
card faulted at stray addresses (device lost). cu goes in as base and stride.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libref takes exp in double and rounds once; on the B65 that is ~3x the rest of an activation.
Rounded to bf16, two f32 values a few ulps apart give the same bf16 unless they straddle a
rounding tie, so the activation runs with a float exp and repeats libref's double chain only
where the f32 result lies within 16 ulps of a tie (near_bf16_tie, xe2_common.h). Probe silu.cpp:
0 of 21M bf16 outputs differ from libref's (the float chain alone: 85), at a third of the time.
- gated_quant_fp8: the gate's sigmoid this way.
- gdn_conv_prep: the convolution's silu this way.
- gdn_gated_rmsnorm: 128-channel rows with a bf16 output take a sub-group a row (8 rows a
work-group): the squares added in index order by lane broadcasts (libref's chain), the gate as
above. The 128-item work-group a row left 127 items waiting on one's ordered sum.
rad-kbench gdn + gated_quant: fixture 165/165, container 440/440, every libxe2 row of these ops
at rel_l2 0; op oracle on live operands (tolerance 1e-9): 60/60 agree.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first form ran a thread a (tile, split) and a separate reduction launch over partials in global
memory, and kept narrow-N shapes on one split (too few threads to fill the card). Now a tile's splits
are one work-group whose partial sums meet in local memory, added in split order, and S is the
divisor of the group count closest to 8 groups a thread. Probe w4d.cpp at M = 4: gate_up 190-208 ->
162 us, N 16384 125-147 -> 79, N 12288 108-117 -> 61, down 148 -> 83, N 5120 K 6144 35 (+ reduce)
-> 32, N 1024 10 (+) -> 7.4 -- the weights at the card's ~560 GB/s.
XE2_W4_CHECK on the 27B (M = 5): 10 of 81920, 6 of 25600 and 14 of 174080 bf16 outputs differ from
libref's loop (ties; rel_l2 <= 1.8e-5); greedy text unchanged; dec_quick.py 46.3 -> 48.5 tok/s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A thread a (16-column tile, K split): W^T comes straight from the weight rows by one transposed 2D
load a 16-column step (the bf16 DPAS's VNNI B operand as it arrives), the activation by a 2D load
(rows past M as zeros), one DPAS of RC = 1, 2, 4 or 8 rows; a work-group is one tile's splits,
summed in split order in local memory. S is the smallest divisor of K/16 giving ~8192 threads, at
most 40. Probe bfg.cpp: the DeltaNet's N = 96 projection at M = 4 38.6 -> 4.7 us (launch_dpas8
staged all 8 rows x K in each of 6 work-groups); the MTP block at M = 1, N 5120 K 6144 ~206 -> 110,
N 5120 K 10240 ~370 -> 180, N 12288 ~375 -> 214, N 34816 ~682 -> 595 (synthetic bf16, which
compresses a little).
rad-kbench: fixture gemm_nt + logits_gemm 686/686; qwen3.8-27b-w4a16-rtn gemm_nt 622/622 (the new
rows' worst rel_l2 1.5e-4, tolerance 8e-3). A first version reduced only rows below S, so rows 4-7
of an 8-row call over 4 splits were never stored (kbench caught it: rel_l2 0.71). Decode proxy
(dec_quick.py): a round ~2-3 ms shorter, 45.5 -> 46.3 tok/s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SYCL_PROGRESS.md: the gdn fusion and row_topk commits, the repository's move (build trees, venv,
fonts.conf), the w4a16 model's kernels and their checks, the ESIMD compiler's mad fusion, how to
measure on this model (unitrace's v2-adapter blind spot, the v1 adapter, --profile-ops, the
BetterBench proxy), where a decode round goes, the acceptance analysis, next steps. README: the
current numbers and to-dos.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The SIMT kernel gives each (query row, kv head) a work-group and scores keys with f32
multiply-adds, so at a 2048-token chunk every row re-reads its keys and values: Qwen3.8-27B's 32
full-attention calls of a 2234-token prompt took 1.41 s (--profile-ops). The ESIMD form takes a work-
group per (8 query rows, kv head), a thread per query head, and shares each page of keys and values
among the 8 rows of all of them: Q K^T on bf16 DPAS with K^T from a transposed 2D load of the page
(a 16-token page is a DPAS's 16 keys), the online softmax in f32 over 32 keys a step, P rounded to
bf16 and P V on DPAS with V by a VNNI-transforming load. Q waits in local memory so the registers
hold the 8 x 256 f32 accumulator. Served for a single sequence's prefill (16+ rows), causal without
a window, bf16 query, cache and output, pages of 16, head_dim 256; everything else keeps the SIMT
kernel (XE2_ATTN_SIMT=1 forces it).
rad-kbench: qwen3.8-27b-w4a16-rtn 240/240 (the flash cases rel_l2 1.6-2.3e-3, tolerance 2e-2),
fixture attn* 237/237. Prefill: 2234 tokens 5.90 -> 4.78 s, 2475 tokens 481 tok/s; the summary of
a 2000-token prompt reads as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first form gave each thread 32 rows by 32 columns in 256 registers and its own 2D loads of the
activation: 23-29 TOPS at M = 2048 (probe w4p.cpp), and the probe's breakdown put the time in the
activation loads, then the group epilogue (DPAS alone ran 120 TOPS). Now a work-group of 8 threads
shares 16 rows: each group's activation is staged in local memory once, double-buffered, a step
a 2D load; a thread owns 16 rows by 32 columns in 128 registers (8 threads an EU) and runs the
group's epilogue on whole [8 rows][16] blocks against factors broadcast once; for outputs wider than
8192 the work-groups go rows fastest, so one 256-column slice of the weight stays in L2 while every
row block uses it. TOPS at M = 2048: gate_up 27 -> 78, N 16384 K 5120 27 -> 75, down 24 -> 62,
N 5120 K 6144 29 -> 78. The chain is unchanged: still libref's result bit for bit (XE2_W4_CHECK on
the 27B: 0 of 349568, 327680 and 445696 outputs differ).
quant_act_i8g for bf16 rows in groups of 128 reads a lane's 8 values in one 16-byte load and stores
its 8 codes in one 8-byte store, typed (677 us a call at 2048 x 5120 through the generic accessors);
the same floats and rounding: rad-kbench fixture 153/153 and the 27B 96/96, rel_l2 0.
Prefill, 2234 tokens: 7.68 -> 5.90 s (378 tok/s).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An int4 release's head is int8 codes with a bf16 scale per (row, 128 of K), joined. head_dpas
reads E4M3 only, and its fallback walked a column a lane in f32: 96 ms a call, 35 of a decode
token's 61 ms (profile_decode.sh). The ESIMD form reads 16 columns' rows 16 bytes a lane (d32x4
gathers), turns a byte into fp16 exactly as (b ^ 0x80) | 0x6400 less 1152, paired (0, 2) and (1, 3)
as the fp8 path pairs its bytes so the prepass's activation serves both, and sums a 128-block on
fp16 DPAS scaled once. head_dpas leaves exactly this form to it (head_i8_fast); both read the
planes on the card.
rad-kbench on qwen3.8-27b-w4a16-rtn: logits_gemm 28/28 (worst rel_l2 1.7e-3, tolerance 8e-3).
Decode, story prompt with the MTP drafter: 15.0 -> 43.2 tok/s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
For qwen3.8-27b-w4a16-rtn (u4 codes, f16 scale and u4 zero per 128 of K): the engine casts a
linear's input to f16 for gemm_nt_q at w4a16_asym up to 64 rows a step, and quantises it with
quant_act_i8g for w4a8i8_asym above. None had a device kernel.
- The planes are stored tiled at load (xe2_ops.h, w4_tiled): a 16-column tile's codes side by
side, the even codes of each dword in its low half so (w >> 4s) & 0x000F000F is a VNNI pair, and
the scale with f16(1024 + zero) one dword a (column, group). unrelayout inverts both exactly.
- gemm_nt_q_w4: libref's gemm_zp loop per output, the exact form (XE2_EXACT=1, XE2_W4_EXACT=1).
- w4a16_asym, M <= 64: ESIMD, a thread a tile; (code | 0x6400) less f16(1024 + zero) is
code - zero exactly; eight fp16 DPAS of RC = 1, 2, 4 or 8 rows a group, scaled in f32 a group.
Narrow outputs split K. Probe w4d.cpp, incompressible codes: gate_up (N 34816, K 5120) 173 us at
M = 1 (546 GB/s), 190 us at M = 4.
- w4a8i8_asym: int8 DPAS takes the tiled codes as its u4 B operand (nibble i meets A's byte i), so
a prepass reorders the activation's bytes of each 8 evens first and forms each group's sum of
codes; the group's integer sum is exact and its term ((sum - zero * asum) * a_scale) * scale is
added in group order.
- quant_act_i8g: quant_act_fp8's form at libref's int8 rule (top 127).
rad-kbench and the op oracle cannot draw the zero-point grids, so XE2_W4_CHECK=n checks the first
n calls of each form against libref's loop on the host, on the engine's operands. On the 27B: the
exact form 0 of 81920 and 0 of 25600 outputs differ; w4a8i8 (M = 2048) 0 of 349568 and 0 of 327680;
w4a16 (M = 4) 0 of 65536 and 2 of 20480 (bf16 ties, rel_l2 5e-9). quant_act_i8g: rad-kbench
fixture 153/153 (quant_act*), the 27B 96/96, rel_l2 0. ctest -L sycl 3/3; the host tier's five
failures are the baseline's (FFmpeg, CPU budgets).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The vector compiler that builds ESIMD kernels forms a mad from a multiply and an add unless its
own API option says strict, whatever the front end's -ffp-contract: probe fmac.cpp's
t = (s * a) * b; c += t came back fused in 14062 of 65536 lanes, 0 with the option, and the SIMT
kernels are unaffected either way. An ESIMD epilogue that copies libref's chain (the w2a8 head's
group terms) was therefore exact only where no fusion happened to change a rounding.
ctest -L sycl on the B65: 3/3 (device_test_sycl, kbench, kbench_moe).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The R-th largest of a row's 64 sub-group maxima is a lower bound on its R-th largest key (those
maxima are R distinct elements), so the row's top R are among the keys at or above it -- a few
dozen on real logits. A second read gathers them into local memory, and a survivor's place is the
count of survivors above it: the keys carry the column and are distinct, so that is the order the
serial passes produce. More than 4096 survivors (a row of equal values) takes the passes over the
row. bf16 rows are read 8 values a 16-byte load. XE2_TOPK_CHUNKS=1 keeps the two-stage form.
The two-stage form was 846 + 86 us a round (unitrace, M = 15, N = 248320, R = 32); this one 37 us.
rad-kbench against libref: fixture 21/21, Qwen3.8-27B-DFLASH2-PARO-M2XFP4 (R = 32) 14/14 and
qwen3.8-27b-w4a16-rtn (R = 1) 12/12, all at rel_l2 0; greedy output identical (8/8).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A work-group a (sequence, v head), its V / 16 sub-groups the column blocks: the replay and the
token pass are ordered by a work-group barrier instead of a launch boundary, the replayed state
stays in registers instead of going to its slot and back, the gates are formed in the kernel and
the gated norm and fp8 group run at the end over outputs kept in local memory. Four launches a
layer (4.31 ms a round) -> one (3.76 ms). XE2_GDN_SPLIT=1 keeps the split form.
rad-kbench on the 27B: gdn_recurrent_update anchor q_len 4/8/16 rel_l2 0 against libref, 90/90 gdn
cases passed; greedy output identical (8/8).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
One wave of Tk * Hv threads with a row's V columns in each lane's registers, instead of a 128-item
work-group a row (~2.4 waves). The sum over e is the same chain in e order; the amax a maximum.
Greedy output identical (8/8).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
The 16-row block staged through local memory took 8.3 KB a 16-lane work-group, so only ~300 of the
384 work-groups fit the card at once and each phase ran in two waves (probe rec2.cpp: 39.6 vs 24.7
us for the 8-token pass). Same values into the same registers: greedy output identical (8/8); a
round's device time 75.8 -> 72.8 ms (unitrace, story prompt).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
Work-groups of 16 threads staged the 40 KB activation into local memory for 16 tiles each; 64
threads amortise it over four times the columns (16: 1.66 ms, 32: 0.96), and a group of 128 reads
its four steps' codes as one 512-byte block load (32: 0.77, 64: 0.74 ms in the round, unitrace -d).
Checked as before: 20 calls on the engine's inputs against the SIMT GEMV, 0 of 1738240 outputs
differ each; greedy output identical.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
This card's DPAS takes 2-bit B operands against s8 A, 16 codes a dword from the low end (probe
dpas_u2.cpp), so the drafter's 2-bit vocabulary head needs no decode: gemm_zp_layout stores the u2
codes tiled ("xe2.zp.u2.t16": a 16-column tile's 32-column step is 128 bytes, [dword][lane],
each dword the column's codes at the activation's stored positions -- quant_act_i8's step order is
folded into the layout), and an ESIMD kernel (xe2_gemm_zp_esimd.cpp) feeds them to DPAS as they
lie, against the activation staged in local memory as the A operand. Each group's sum is exact
in int32 and the terms are added in group order, as zp_dpas and libref do. The exact kernel and
the SIMT GEMV read the tiled form too.
Checked: 20 calls on the engine's real inputs, the ESIMD kernel against the SIMT GEMV on the same
bytes, 0 of 1738240 outputs differ each; greedy output identical (rad-kbench has no w2a8 recipe
on this container).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
A row's work-group walked its groups sixteen at a time, ~5 us a group of dependent loads,
reduction and stores. The groups are independent, so each sub-group now takes one (as
gated_quant_fp8 already does); the arithmetic is unchanged. rad-kbench against libref: 45 checked,
45 passed, rel_l2 0. Greedy output identical.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
Where N % 16 == 0 and K % 512 == 0 the meta bytes (in the codes blob) and the E8M0 plane (b_scale,
tag "xe2.m2.e8m0.t16") are stored in chunks of a tile's 16 groups, [dword][lane], so the ESIMD
kernel reads four steps of them with one block load each instead of gathers across 16 rows. The
exponent plane's stored form appends each column's largest exponent (int32), computed once at
load, so the prepass no longer scans the plane on every call; unrelayout drops it and untiles the
exponents exactly. Every m2 reader reads the tiled forms.
rad-kbench against libref: 70 checked, 70 passed (worst rel_l2 1.2e-3). M = 8: gate_up 222 -> 205,
down 119 -> 113 us; prefill shapes flat to -5%. Greedy output identical; 512-token decode 33.3 ->
33.9 tok/s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
Where N % 16 == 0 and K % 128 == 0 the layout hook asks for "xe2.m2.tiled16": a 16-column tile's
128-column step is 1 KiB, dword w of its columns side by side, the ESIMD kernel's [word][lane]
registers as they lie (four block loads in place of four d32x4 gathers). M = 1 goes to the same
kernel when tiled. Every m2 reader in libxe2 (exact, SIMT GEMV, jm and SIMT DPAS forms, prefill
decode) reads the tiled form; unrelayout inverts it for the oracle.
rad-kbench against libref: 70 checked, 70 passed (worst rel_l2 1.2e-3). M = 8: gate_up 240 -> 222,
down 140 -> 119, N=1024 50 -> 25 us. Greedy output identical (8 prompts x 64 tokens); 512-token
decode 31.8 -> 33.3 tok/s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
EU stall sampling (unitrace --stall-sampling) put 43% of the kernel's samples on send stalls, the
memory request queue full, not on waits for data: 4-byte gathers of the exponents and metadata
were a third of its cache-line requests for an eighth of its bytes. 16 bytes a lane now cover
four steps; a split's tail keeps the per-step gathers, so the arithmetic and splits are as
before. rad-kbench against libref 50/50; greedy output identical.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
The pair-a-step staging loaded through a generic pointer after each local store, one round trip
an iteration. Same arithmetic; greedy text and speculative round count unchanged (rad-kbench has
no recipe for the shape).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
The step upload's range kernel read its range list and sources from pinned host memory, a link
round trip a load (PCIe x1 on the B65): 3 calls a speculative round at 650 us. Their span and the
list now cross in one transfer each into a per-stream device buffer. device_test_sycl passes;
greedy output identical.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
The per-column largest exponent was a kernel of its own for split-K shapes (7.8 us a launch, 260
a round) and an in-kernel scan otherwise; extra work-groups of the activation prepass now form it
and the ESIMD kernel gathers it. rad-kbench against libref 50/50; greedy output identical.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
A thread owns 16 columns as [word][lane] registers, so a decoded weight pair is one SIMD32 fp16
multiply instead of SIMT's ~10 instructions; the step's activation blocks load with the code
lines, so no DPAS waits on its own A load. rad-kbench against libref 50/50; greedy output
identical. XE2_M2_SIMT=1 keeps the SIMT kernel.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
The conv takes typed loads and stores when its operands are bf16 (the engine's), and the l2 norm
over each 128-wide q/k head is a sub-group's: its values loaded 8 a lane, the squares added in d
order by lane broadcasts -- libref's chain -- instead of a work-item walking the head twice through
the generic accessors. Fixture 90/90 at rel_l2 0. Prefill 336 tok/s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
conv_prep walked each channel through every token (10240 chains of 1882) and the gate cumsum on 48
work-items; every (token, channel) output is independent and the cumsum restarts each chunk, so
they now take a work-item a (token, channel) and a (head, chunk). The gated RMS norm's work-item 0
summed its row from global memory one load at a time; the row is staged in local memory first.
Same expressions and order: fixture 90/90 at rel_l2 0.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
A sub-group now loads the 128-groups it later quantises, so the normed inputs and the gain stay in
its registers between the ordered sum and the codes; only the squares go to local memory. Three
n-wide arrays (60 KB at n = 5120) allowed two rows on a Xe core at once, and a row's sum is a
serial chain, so the prefill's 941-row calls ran as ~24 waves of it. Bit-identical: fixture 20/20
and 400/400 live oracle issues at rel 0.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
The prefill rotation ran three passes (an fp16 copy of the input, a strided batch GEMM, the
quantiser) over sizeable intermediates. The decode form -- a (part, group)'s rotation on dpas_f16
with the quantiser after it -- now takes any row count, a work-group a 16-row block. The same
arithmetic as the batched form (fp16 input, f32 sums): 200/200 live oracle issues agree (rel at
most 4.5e-3, p99 5.6e-4). XE2_GIVENS_BATCHED=1 keeps the three-pass form. Prefill 316 tok/s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
oneMKL's SYCL GEMM (part of oneAPI; libxe2 links it when CMake finds it, RAD_XE2_MKL=OFF or
XE2_NO_MKL=1 keep the hand-written kernels) runs the fp16 prefill GEMMs at 85-91 TFLOPS on random
data at the 27B's shapes, deterministic run to run, against ~23-30 for the hand-tiled XMX kernel:
xmx_f16_scaled (the m2xfp4 prefill) and xmx_f16_batched (the rotation's) go to its gemm and
gemm_batch, and bf16 gemm_nt at M >= 17 to its bf16 GEMM (N = 96 had fallen to the exact kernel,
5 ms a call). The m2xfp4 weight decode to fp16 now takes a (column, 32-group) a work-item. fp16 or
bf16 products with f32 accumulation, as before: the 27B's cases 133/133 (rel_l2 <= 1.42e-3), the
fixture 1410/1410. Prefill GEMMs over a 1882-token prompt 4.06 -> 1.66 s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
The chain-parallel scan's ~124 KB of local memory leaves one work-group a Xe core, and at 256
work-items that left three quarters of the core's threads idle. Every phase is a set of independent
chains strided by the work-group size, so the work-group is now the core's 1024: the same chains in
the same order, fixture 90/90 and 72/72 on the 27B at rel_l2 0.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
kkt walked a head's chunks and rows in turn on 48 work-groups, its working rows in global
memory. Chunks are independent here: a work-group now takes one (sequence, head, chunk) with the
chunk's k rows in local memory, forms every row term beta_i (k_i . k_j) e^{g_i - g_j} first (each
its sum over d in order, 256 work-items), then solves row by row from local memory. libref's chains
and order: fixture 90/90 at rel_l2 0. (Measured on the way: the double exp is not the cost; k as
f32 in local memory halves the resident work-groups and is slower.)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
The chain-parallel scan staged each chunk's k, q, v, A, g and beta through the generic accessors
(a dtype switch an element); bf16 q/k/v/A/o with f32 g, beta and states now take typed loads and
stores. Same arithmetic: fixture 90/90 at rel_l2 0. 27B prefill 131 -> 153 tok/s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
dpas_s8u8 (xe2_common.h: SPV_INTEL_subgroup_matrix_multiply_accumulate's int8 form, K = 32, A
signed, B unsigned; layout checked in a probe) takes a lane's column of codes as B straight from
registers, so the group sums no longer go through a local-memory tile and two sub-group barriers a
step; the activation is staged once a work-group as A columns, and a step's codes are one 8- or
16-byte load. The group terms are libref's, in order, as before: bit-identical to the
libref-checked sub-group form on 50/50 live calls (a temporary cross-check), fixture 228/228.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
At a verify's 8 rows and a ~300-token context the 32 partitions held ~10 keys each, and every one
loaded the query, wrote a full state and was merged. A partition now takes at least 64 keys; the
ones past a row's keys write only an end marker (l = -1) and return, and the merge stops at it.
Tolerance-held as before: fixture 158/158 (rel_l2 <= 2.9e-4), the 27B 124/124.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
The conv's per-element generic accessors (a dtype switch each) cost it ~60 us at 8 tokens; the
engine's operands are all bf16, which now take a typed copy of the same loop (libref's double exp
in silu kept). Bit-identical: 252/252 live gdn_conv_recurrent_update and 48/48 gdn_conv_prep oracle
issues at tolerance 1e-9, fixture 90/90. XE2_GDN_GENERIC=1 keeps the generic forms.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
The register form spent ~60 us a call in launches around it: e_max over the weight's exponents, a
finalize over the partials, and an activation prepass on 8 work-groups. A lane now reads its
column's exponents for e_max, an unsplit launch stores y with its factors directly, and the
prepass runs a work-group a (row, 2048 columns). N=34816 463 -> 400 us, N=5120 K=17408 249 ->
207, N=16384 247 -> 216, N=5120 K=25600 373 -> 303. Same arithmetic: 185/185 model cases, worst
rel_l2 1.46e-3 as before. Tried and slower: the activation staged in local memory a split at a time
(96 KiB a work-group starves occupancy: 1585 us) or a step at a time behind a barrier (506 us).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
At a verify's 8 rows the float-pair form ran 80 work-groups (n=5120, two parts), each walking its
rows in turn. A (part, group)'s rotation is now one small GEMM on dpas_f16: the rows' inputs
fp16(x / D) in local memory as A columns, a lane's B column its output's row of T, T read once for
every row; then libref's quantiser. The prefill form's arithmetic (fp16 activation, f32 sums), held
to the same tolerance: 400/400 live oracle issues agree (rel at most 4.5e-3, p99 4e-4). Per
speculative round 18.5 -> ~5.5 ms. XE2_GIVENS_PAIR=1 keeps the float-pair form (rel 0).
Also: the BetterBench row for b0e34c6 (decode 28.9, prefill 131.3 @2000) and the round's notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
SPV_INTEL_subgroup_matrix_multiply_accumulate gives DPAS on operands in registers (dpas_f16 in
xe2_common.h; libxe2's link enables the extension). Its B operand is a lane's column as dwords of
fp16 pairs, which is what a lane decodes from its codes, so the 2 <= M <= 16 m2xfp4 GEMM no longer
writes the decoded weights to local memory and reads them back as a joint_matrix tile; the
activation is transposed once so a lane's A column is one 16-byte load. 15-20% a call at M = 8
(N=34816 K=5120 518 -> 463 us, N=5120 K=17408 312 -> 249 us). Same products: rel_l2 at most
1.46e-3 as before (185/185 model cases). XE2_M2_JM=1 keeps the local-memory form.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
The register kernel read every element through the dtype-switching accessors, so a row's 128
state loads did not issue together, and a lane stored its own row 512 bytes from its neighbours.
It is now templated on the staged q/k/v type and, for an f32 state with contiguous rows, moves a
work-group's 16 rows through local memory in coalesced lines. The anchor replay's decays are
taken one token a lane. At the speculative verify (8 tokens): the 8-token pass 408 -> 101 us, the
replay 222 -> 110 us; 48 calls a round, 32.7 -> ~13 ms. Bit-identical to libref (fixture 90/90 at
rel_l2 0, 400/400 live oracle issues).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
Half the norm's time was its per-element loads of x, the residual and the gain. bf16 rows (gain
bf16 or f32) now load and store 8 values at a time and a 128-group's codes go out 8 bytes a lane;
the arithmetic and the ordered sum are the general form's. Bit-identical to libref (kbench rel_l2
0; 408/408 live oracle issues). 128 calls a speculative round: 17 -> 6.5 ms.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
At M <= 8 the bf16 GEMV re-read the activation for every column; it now stages 8 rows in local
memory and runs bf16 DPAS against the weight, K split to fill the card: N=96 164 -> 20 us. The
joined E4M3 head decodes its codes by bits into a packed fp16 tile and runs fp16 DPAS, a scale
block's sum scaled per column in f32: 9.7 -> 3.5 ms at M = 8, and 3.9 -> 3.4 ms at M = 1, so decode
takes it too. Held to the gemm tolerance (rel_l2 1.6e-3, as before).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
The DFlash2 drafter's 2-bit vocabulary head (N=248320) forms each group's integer sum on int8 DPAS
(8 x 32 by 32 x 16), the u2 codes unpacked straight into the packed B tile; a lane owns a column
and adds libref's group terms in order: 24.0 -> 4.2 ms a round, bit-identical to the libref-checked
sub-group form on 63 live calls. dflash_select scores the 16 candidates in parallel lanes, each in
libref's order, lane 0 taking the first strict maximum: 11.6 -> 0.5 ms. row_topk takes each of 128
chunks' top R, then the top R of the winners: 3.2 -> 0.95 ms. Both exact against libref (fixture,
engine oracle).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
The lane-per-key attention read bf16 value rows with 16-byte loads only at head_dim 128; at 256
(Qwen3.8's full attention, 16 dims a lane) every element went through the generic loader. Two
16-byte loads a lane now. rad-kbench 138/138 on the fixture and 33/33 on the 27B (worst rel_l2
1.5e-4). SYCL_PROGRESS records the first 27B BetterBench run (5720a95): decode median 19.1 tok/s,
prefill 113.4 tok/s at 2000.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
For 17 or more rows the rotation is a batch of GEMMs, one a (part, 128-column group): the input
fp16(x / D) per part, the f16 rotation as B, a batched form of the tiled fp16 XMX kernel
(xmx_f16_batched) into f32, then libref's quantiser a (row, part, group). The input rounded once
to fp16 where libref sums in double: a fast kernel. KL against the exact reference: mean 0.0037,
top-1 97.2% (0.0035 / 95.6% before: within the noise of 250 positions). Up to 16 rows the float-pair
kernel stays.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
xmx_f16_tiled: a 128 x 128 work-group tile, 4 x 2 sub-groups of 32 x 64 (16 accumulators, the
large register file), K in steps of 32 with A and a VNNI B staged in local memory, double
buffered, each sub-group's A tiles loaded once a K16 step; the accumulators stored straight to an
f32 scratch and scaled into y by a second kernel (a generic store in the epilogue spilled them and
ran 3x slower than the old tiling). ~30 TFLOPS on the 27B's prefill shapes in a standalone probe
against ~18 / ~11 for the previous per-sub-group tiling (the card's measured fp16 DPAS peak: ~98).
gemm_nt_q over a 1792-token prefill 6.4 -> 3.7 s. KL against the exact reference unchanged (mean
0.0035, top-1 95.6%): the same products.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
- gdn_chunk_scan for head_k = 128, chunk 64: a work-group of 256 a (sequence, head, block of 32
value columns), the chunk's k, q (rows padded), the block's slices of v, S, W, V' and the sA rows
in local memory (~124 KB); every phase of a chunk is thousands of independent chains -- W[j][e],
V'[i][e], R[i][j], O[i][e], S[d][e] -- each one work-item's, in libref's order, A staged in local
memory, the decays e^{g_i - g_j} (libref's double exp) once a call. Still bit-identical (rel_l2 0,
the 27B's geometry, 1..32 rows and multi-chunk). 233 -> 96 ms a call at 1792 tokens.
- m2xfp4 at M >= 17 now fp16 on XMX: the weight times 2^(127 - e_max(n)), exact in fp16; the
activation fp16(a * a_scale / R_m); y = acc * R_m * 2^(e_max - 127) in a new scaled fp16 XMX
kernel (xmx_f16_scaled). fp16's 2^-11 step instead of bf16's 2^-8.
KL on the 27B against an XE2_EXACT=1 reference (every kernel exact, each matched to libref bit for
bit; 250 positions, full vocabulary): mean 0.0041 -> 0.0035, p99 0.027 -> 0.021, top-1 96.8% ->
95.6%, PPL ratio 0.998. The fast set's KL is dominated by the model's own fp8 activation quantiser
re-rounding small upstream differences.
27B prefill of 1792 tokens: 26.3 -> 19.7 s (68 -> 91 tok/s).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1