106 Commits
Author SHA1 Message Date
aneinanderandClaude Opus 5.5 b52a180141 libxe2: split the ESIMD GEMV along K for wide outputs too
gemv_esimd_splits only aimed at ~8192 threads, so an output wide enough to
fill the card at one split (the lm head, N = 248320) ran S = 1: each thread
walked all of K alone and was latency-bound at ~350-530 GB/s. The split now
also keeps K a thread at ~1024 or less.

rad-kbench, B65, cold weights (us):
  logits_gemm n_vocab 248320 n_embd 5120 M=1  4710 -> 4255   M=4 4674 -> 4289
  logits_gemm n_vocab 248320 n_embd 4096 M=1  3652 -> 3418
  gemm_nt N 34816 K 5120 M=1                   621 ->  605
other gemm_nt shapes unchanged. kbench 1989/1989 replay, model checks pass;
Qwen3.8-27B greedy output unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 21:20:16 +01:00
aneinanderandClaude Opus 5.5 8931aae8b2 sycl: keep the device out of plain system memory
On kernel 7.0 the xe driver can oops (drm_pagemap_zdd_destroy from
__drm_pagemap_migrate_to_ram) when the CPU faults on a page its shared
virtual memory had migrated into VRAM. The backend reached plain system
memory in several ways; each now uses USM the runtime knows:

- RAD_MEM_HOST_PINNED/_MAPPED are sycl::aligned_alloc_host, not
  posix_memalign + prepare_for_device_copy. O_DIRECT cannot target those
  pages (EFAULT), so DirectFile bounces such transfers through an 8 MiB
  buffer. The 27B load is not slower (10.8 s read, disk-bound).
- Copies with a pageable side are staged through a host-USM bounce,
  synchronously (rare: startup and tests). The ranged copy stages a host
  range list even when its source is on the card, and refuses a pageable
  destination, which its kernel would write.
- scatter_rows' bad-index flag is host USM, not shared.
- Gates are gone (the documented state): a spinning kernel never sees a
  host store to host USM, and a device flag opened by a copy from another
  queue deadlocks behind copies queued past the gate. rad-kbench times
  ungated; the gate tests skip on backends without gates.

Checked: device_test (sycl) 70 cases, 0 failed; rad-kbench fixture
1989/1989; 27B int4 chat output byte-identical (c4c5ba5e727c) at
30.6 tok/s; no xe messages in the kernel log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 17:56:05 +01:00
aneinanderandClaude Opus 5.5 4b70a96378 Merge upstream main (v1.17.0 -> v2.1.0) into the SYCL port
102 upstream commits. Nine conflicts resolved. Fork side of the merge:
- libxe2: declare the givens_dense_quant schema (upstream 2.0 dropped it
  from libavx and libref; the device libraries now each carry it).
- plain_norm becomes an ABI 42 append to RadBuildCtx; abi layout table
  regenerated, kTableAbi = 42.

Known before the PR: arch_test (MTP lint and pinned graph hashes for
qwen35_fp8, qwen35moe_fp8, qwen4exp with MTP).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 15:06:17 +01:00
aneinanderandClaude Opus 5.5 ca793ea99a libxe2: gate_quant_fp8 (output gate, multiply and quantiser in one launch)
The gated attention block (qwen35 family, Qwen4exp, lfm2, krea2) takes
gate_quant_fp8 when a library declares it, otherwise sigmoid + mul (+
quant_act_fp8). One sub-group per (row, 128-column group), the sigmoid
rounded to bf16 before the multiply, xe2_sigmoid's float exp with the
double one near a bf16 tie (always double under XE2_EXACT): byte-identical
to libxe2's sigmoid -> mul -> quant_act_fp8, which the row declares as its
chain (.replaces) for rad-kbench's fusion oracle. out_bf16 may alias x.

xe2_sigmoid and xe2_mul get [M, n] shape hooks (libr4d's unary/binary),
which the oracle sizes the chain's temporaries from.
XE2_NO_FUSED_GATE=1 hides the row for an A/B.

kbench: fixture 2144/2144; fusion oracle 40/40 byte-identical on the 9B,
the 27B, and the 9B under XE2_EXACT. 27B int4, spec off: 646 -> 630
launches a decode step, same output hash, decode 30.6 tok/s either way
(the saving is ~16 dispatch gaps, ~0.3%), prefill 2.4k 1387 -> 1400 tok/s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 09:09:46 +01:00
aneinanderandClaude Opus 5.5 0a1fed0bcf libxe2: GDN recurrent state store through local memory, out as whole lines
The register kernel stored a lane's own 512-byte state row, so each float4 store
touched 16 cache lines. A sub-group's 16 rows now go through a 9-float4-pitch tile,
32 columns at a time, and out coalesced. Bit-identical (rad-kbench gdn rows rel_l2 0,
greedy hashes unchanged). 9B 58.9 -> 59.2 tok/s, 27B 30.4 -> 30.6 (spec off).
XE2_GDN_ROWSTORE=1 restores the row store.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 20:55:00 +01:00
aneinanderandClaude Opus 5.5 9aef29661b libxe2: fused gated-attention prologue (qk_norm_rope_gate, qk_norm_rope_gate_kv_store)
The one-launch prologue that the qwen35 family (Qwen3.5, Qwen3.8), Qwen4-Exp, FishOmni and the MTP
heads request where a kernel library declares it (libr4d did; libxe2 did not, so those models ran
q_norm, k_norm, rope_q, rope_k and kv_store: five launches an attention layer). It splits the
interleaved [q|gate] projection per head, norms q and k, applies the partial NeoX rotary from the
cos/sin table rope_table already fills each step, and with _kv_store stores k and v.

docs/OPS.md requires it byte-identical to the unfused chain, so each step is libxe2's own:
xe2_rmsnorm's bf16 head-row norm (XE2_EXACT=1: libref's ascending sum, as xe2_rmsnorm then takes),
the bf16 rounding the norm stores, cos/sin as xe2_rope_table wrote them (xe2_rope's arithmetic), and
xe2_kv_store's conversion. A sub-group a (token, head), as qkv_norm_rope; that kernel is untouched.
The schemas are libr4d's. The _kv_store row declares its chain (qk_norm_rope_gate, kv_store) and both
rows describe their operands, so rad-kbench draws them and checks the fold byte for byte.
XE2_NO_FUSED_PROLOGUE=1 now hides these two rows as well: the A/B and an escape hatch.

rad-kbench fusion oracle: 28/28 byte-identical on Qwen3.5-9B and on Qwen3.8-27B; default fixture
2144/2144. Greedy A/B (400-token story, 2.4k and 382-token prompts), twice each, spec off: outputs
identical; Qwen3.5-9B w4a16 decode 58.3 -> 58.9 tok/s, Qwen3.8-27B int4 30.1 -> 30.4. Prefill
unchanged (the fused rows serve steps up to 64 tokens).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 11:50:39 +01:00
aneinanderandClaude Opus 5.5 dd20835f18 libxe2: sliding-window attention on the DPAS kernels
attn_paged_fast sent any window > 0 to the SIMT split-KV kernel, so every sliding-window layer
(Gemma 2/3/4, Mistral-style and gpt-oss models) missed the DPAS decode and prefill kernels. They now
take the window: each 8-row block starts at its first row's bound (pos - window + 1, on a whole
32-key step; the split decode form partitions from there) and the mask hides keys below each row's
own bound, as libref's attn_paged. The window form is its own instantiation (WIN), so the window-0
kernels are unchanged: the Qwen3.5-9B's attention times match a rebuild of the old code to 0.5%.
The quad prefill form keeps window 0; a windowed prefill takes the esimd prefill form.

rad-kbench, Gemma 4 E2B (head_dim 256, window 512): decode 101 -> 23.5 us and 23 -> 18 us;
q_len 128 757 -> 92 us; q_len 512 2833 -> 98 us; 320/320 within tolerance. Qwen3.5-9B 160/160,
default fixture 2144/2144.

Gemma 4 E2B end to end: decode 63.0 -> 74.4 tok/s, 2.4k-token prefill 1537 -> 1886 tok/s; a story,
a 120-paragraph count and a password at paragraph 77 of 120 answered correctly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:08:31 +01:00
aneinanderandClaude Opus 5.5 d35027aaf7 libxe2: split-KV paged attention up to head_dim 512
attn_paged_fast stopped at head_dim 256 (16 values a lane) and sent wider heads to the exact
kernel, so Gemma 4's global layers (head_dim 512) ran xe2_attn_paged_ref at decode and prefill.
The kernel is now instantiated at 16 values a lane (head_dim <= 256: unchanged, its times match
to 0.1%) and at 32 (head_dim 512, four 16-byte value loads a lane).

rad-kbench on the Gemma 4 E2B container, head_dim 512: decode 192 -> 43 us (short context) and
2040 -> 256 us (long); q_len 256 55.4 -> 19.6 ms; 320/320 cases within tolerance. Gemma 4 E2B
end to end: decode 58.6 -> 63.0 tok/s, 2.4k-token prefill 724 -> 1537 tok/s, decode at that
context 29 -> 59 tok/s; answers checked (a story, a 120-paragraph count).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 20:29:25 +01:00
aneinanderandClaude Opus 5.5 0c7606423b libxe2: fused attention prologue (qkv_norm_rope, qkv_norm_rope_kv_store)
The one-launch prologue that Gemma 3, Gemma 4, Hunyuan v3 and the DFlash2 drafter use where a
kernel library declares it (libr4d did; libxe2 did not, so those models ran the unfused five or six
launches a layer). docs/OPS.md requires it byte-identical to the unfused ops, so each step is
libxe2's own: xe2_rmsnorm's bf16 head-row norm (its partition and reduce_over_group; XE2_EXACT=1
libref's ascending sum, as xe2_rmsnorm then takes), the bf16 rounding the norm stores, xe2_rope's
arithmetic on its frequency table, xe2_kv_store's conversion. A sub-group a (token, head), the head
staged in local memory for the rotary pairs. The schemas are libr4d's.

XE2_NO_FUSED_PROLOGUE=1 leaves the two rows undeclared, so an architecture takes its unfused chain:
the A/B, and an escape hatch.

Gemma 4 E2B: greedy outputs identical with and without (4 requests), decode 58.0 -> 58.6 tok/s.
A random Gemma 3 (v_norm 0): identical, 1570 -> 1600 tok/s. Default fixture 2144/2144.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 20:29:25 +01:00
aneinanderandClaude Opus 5.5 25c8fbd136 libxe2: qk_norm_rope, conv1d_dw, conv2d, attn_local_rel rows
The encoder towers' ops that had only a host kernel: on the SYCL backend every op runs on the card,
so a container carrying Gemma 4's vision tower (qk_norm_rope, blocks mode, v_norm) or its audio
conformer (conv2d subsampler, conv1d_dw, attn_local_rel) refused to start. qk_norm_rope also serves
GLM's vision tower (axial) and any QK-norm model that declares the fused op.

Each is libref's loop, a work-item an output (a (row, head) for qk_norm_rope and attn_local_rel),
for passes that run once a picture or clip. cu_seqlens stays on the card, so each work-item finds
its own segment.

rad-kbench, Gemma 4 E2B container: qk_norm_rope 80/80, conv1d_dw 64/64, conv2d 34/34,
attn_local_rel 64/64; default fixture 2144/2144. Gemma 4 E2B now serves on Intel: text and an
image request answer correctly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 14:28:38 +01:00
aneinanderandClaude Opus 5.5 ff4b7c9fb4 libxe2: rmsnorm_p, relu, logit_softcap, rel_sinusoid, pool_rows rows; rope to head_dim 512
Gemma 4 E2B did not start on Intel: five weightless ops had no device row (rmsnorm_p, the bare
value norm, in 15 bands; relu; logit_softcap; rel_sinusoid; pool_rows), and xe2_rope was selected
for its global layers (head_dim 512, proportional rope widened to the full head) and refused them
at launch: the frequency table held head_dim <= 256. It now holds 512, its component index as int8
so the by-value table stays at 1.25 KB.

rmsnorm_p is xe2_rmsnorm with the gain absent; the others are libref's chains (tanh, exp, sin, cos
in double rounded once; pool_rows' f32 sum in row order, rounded, times mult, rounded).

rad-kbench on the Gemma 4 E2B container: rmsnorm_p 20, relu 20, logit_softcap 4, rel_sinusoid 5,
pool_rows 6 cases ok, rope 300/300; default fixture rope 162/162.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 14:15:31 +01:00
aneinanderandClaude Opus 5.5 b0ac7fd42c libxe2: device rows for gelu, silu, gelu_tanh, scale, mul_weight, clamp, fill, iota, act_mul, gelu_mul
These weightless elementwise ops had no libxe2 row, and an op with no weights cannot be placed on
the host, so a model whose graph declares one refused to start on Intel ("no device kernel for op
'gelu_mul' in any plugin"). libr4d serves them; the architectures that use them include Gemma 3
and 4, the embedding models (nomic-bert, embgemma, nemotron-embed), Qwen3-ASR, LFM2's SigLIP2,
Nemotron-H and the diffusion and audio models.

Each is libref's chain element by element (xe2_elem_act.cpp): erf, tanh and exp in double rounded
once to float; silu (alone or in act_mul) to a bf16 result takes the float exp and libref's chain
again near a rounding tie, as silu_mul and sigmoid do. gelu and gelu_tanh stay in double: 1 +
erf(x) cancels for negative x, so a float erf's error is not bounded by the result's.

rad-kbench: the nemotronh + moe + default fixtures, 339/339 (act_mul 60, mul_weight 10, iota 9,
silu 20); a random-weight 2-layer Gemma3 converted to .rad, every resolved kernel agrees with
libref (gelu_mul 10 cases). That Gemma3 now serves (1.5k tok/s decode on the B65); without these
rows it does not start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:15:46 +01:00
aneinanderandClaude Opus 5.5 d04a27fad3 libxe2: gemm_nt_bias on the fast GEMMs, the epilogue in libref's order
gemm_nt_bias (Y = A B^T + bias, then gelu / gelu_tanh and a residual) had only the
correctness-first row: one work-item an output over ascending k. 22 architectures use it
(the ViT, SigLIP2, GLM-vision, SAM and Gemma4-audio blocks, Qwen3-ASR, nomic-bert, the
diffusion VAEs and UNets). The new row forms A B^T on the existing bf16 kernels (the skinny
GEMV at M <= 16, XMX above; each falls back to the exact kernel where its layout is refused)
into an f32 workspace, and gemm_plain runs only its epilogue on it, so the bias, activation,
residual and their roundings are the reference row's. XE2_EXACT=1 keeps the ref row.

rad-kbench: fixture 210/210 (worst rel_l2 1.7e-4), full fixture 2144/2144; the
Qwen3.5-9B vision tower's shapes all agree with libref. N = K = 4608 + gelu on the B65:
M = 1 1,627 -> 81 us, M = 16 8,221 -> 104, M = 128 74,573 -> 253, M = 512 302,924 -> 721.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:54:54 +01:00
claudeandClaude Opus 5.5 6abca01f17 libxe2: w4a16 decode GEMM in 16-row blocks, each group's codes decoded once
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>
2026-11-08 01:53:59 +01:00
claudeandClaude Opus 5.5 2f1fdd4d11 libxe2: bf16 GEMV at 9-16 rows on DPAS, the weight read once
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>
2026-11-08 01:38:14 +01:00
claudeandClaude Opus 5.5 3582900903 libxe2: DPAS flash attention at head_dim 64 and 128, not only 256
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>
2026-11-08 01:16:14 +01:00
claudeandClaude Opus 5.5 fc5f00a169 libxe2: quad prefill attention scores as S^T = K Q^T, softmax vertical across key rows
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>
2026-11-03 02:41:45 +01:00
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
claudeandClaude Opus 5.5 2da2eb0b6c libxe2: prefill flash attention four row blocks a work-group, the next pages prefetched, V loads in batches of 8
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>
2026-11-03 01:29:41 +01:00
claudeandClaude Opus 5.5 7f95c567ad libxe2: gdn_conv_prep's 4-tap convolution a block of 8 tokens a work-item
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>
2026-11-02 13:59:02 +01:00
claudeandClaude Opus 5.5 c3145b08e8 libxe2: the large-register kernels in a device link of their own (xe2_grf256), auto GRF mode off
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>
2026-11-02 12:57:13 +01:00
claudeandClaude Opus 5.5 c5fe770657 libxe2: prefill flash attention's two pages' score chains interleaved
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>
2026-11-02 12:26:55 +01:00
claudeandClaude Opus 5.5 8fced2e79f libxe2: auto large-GRF mode on the AOT backend line, so grf_size<256> kernels get 256 registers
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>
2026-11-02 12:20:10 +01:00
claudeandClaude Opus 5.5 84af4ef2f9 libxe2: w4a8i8 prefill GEMM's long-K form in row bands instead of A staged in SLM
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>
2026-11-02 11:47:13 +01:00
claudeandClaude Opus 5.5 9a1633596f libxe2: w4a8i8 prefill GEMM reads A per thread from L1, rows fastest, except a long K
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>
2026-11-02 11:25:58 +01:00
claudeandClaude Opus 5.5 b9fdfc0a79 libxe2: mtp_couple_verify reads a row's candidates staged in local memory
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>
2026-11-02 07:55:08 +01:00
claudeandClaude Opus 5.5 8f84939aa2 libxe2: sample_topk in chunks and a merge, the candidate walks staged in local memory, rerank's K split
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>
2026-11-02 07:31:15 +01:00
claudeandClaude Opus 5.5 b5f116e797 libxe2: w4a8i8 prefill GEMM's load addresses in a 2D payload and moving pointers
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>
2026-11-02 06:40:58 +01:00
claudeandClaude Opus 5.5 d63b985161 libxe2: prefill flash attention's softmax and rescale a row at a time against scalar factors
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>
2026-11-02 06:29:31 +01:00
claudeandClaude Opus 5.5 175f0bbd33 MTP coupling on qwen35_fp8's 2-bit draft head; libxe2 rows for the coupling ops
- 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>
2026-11-02 05:45:50 +01:00
claudeandClaude Opus 5.5 bfb1ebd1dd libxe2: the fused gdn epilogue's output gate on a float exp, libref's chain near a bf16 tie
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>
2026-11-02 04:51:07 +01:00
claudeandClaude Opus 5.5 8bc5366045 libxe2: w4a8i8 accumulators start at -zero * asum
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>
2026-11-02 04:30:16 +01:00
claudeandClaude Opus 5.5 531fda7313 libxe2: silu_mul, add, mul and sigmoid eight bf16 values a work-item; sigmoid's float exp
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>
2026-11-02 04:20:05 +01:00
claudeandClaude Opus 5.5 e6f4862c7e libxe2: gdn_conv_prep's convolution eight channels a work-item
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>
2026-11-02 04:08:52 +01:00
claudeandClaude Opus 5.5 49d7d0b238 libxe2: w4a8i8 prefill epilogue in f32 against scalar row factors
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>
2026-11-02 04:00:41 +01:00
claudeandClaude Opus 5.5 4511822138 libxe2: add_rmsnorm (schema and row); arch/common: the plain norm and the attention gate without unread work
- 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>
2026-11-02 03:17:05 +01:00
claudeandClaude Opus 5.5 f26eec2633 libxe2, arch/common: silu_mul for 4-bit down projections, float exp at the tie rule; head-row norms vectorized; attention SLM by gqa
- 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>
2026-11-02 02:32:05 +01:00
claudeandClaude Opus 5.5 2d2356ad4b libxe2: decode / verify attention on DPAS, the keys split 32 ways
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>
2026-11-02 01:52:01 +01:00
claudeandClaude Opus 5.5 726e532114 libxe2, arch/common: the 28 Oct pending set, the bf16 cast fused, the vectorized norm, a draft-vocab prefix
- 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>
2026-11-02 01:52:01 +01:00
claudeandClaude Opus 5.5 7580ec3d17 Merge upstream main (v1.12 -> v1.15.1, 408 commits) into the SYCL port
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>
2026-11-02 00:25:57 +01:00
claudeandClaude Opus 5.5 8e8b4352a1 libxe2: gdn_chunk_scan on DPAS -- 1100 -> 60 ms at a 2234-token prefill, KL unchanged
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>
2026-10-28 09:56:47 +01:00
claudeandClaude Opus 5.5 6969fcf8cb libxe2: libref's sigmoid and silu at a third of the cost, bit-identical -- gated norm 230 -> 37 ms, gated_quant 320 -> 254 ms at 2234 tokens
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>
2026-10-28 09:56:34 +01:00
claudeandClaude Opus 5.5 5ed4ff847e libxe2: the w4a16 decode GEMM a tile's K splits a work-group, reduced in local memory -- decode proxy 46.3 -> 48.5 tok/s
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>
2026-10-28 01:51:00 +01:00
claudeandClaude Opus 5.5 d63d1bc8a5 libxe2: the skinny bf16 GEMM at M <= 8 in ESIMD -- ssm_ab 38.6 -> 4.7 us, the MTP block's GEMVs up to 2x
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>
2026-10-28 01:41:37 +01:00
claudeandClaude Opus 5.5 13c64a3d78 libxe2: prefill attention on DPAS (flash attention) -- prefill 378 -> 468 tok/s at 2234 tokens
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>
2026-10-28 01:08:41 +01:00
claudeandClaude Opus 5.5 2365a2ae51 libxe2: the w4a8i8 prefill GEMM tiled through local memory -- 27 -> 62-78 int8 TOPS, prefill 291 -> 378 tok/s
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>
2026-10-28 00:52:58 +01:00
claudeandClaude Opus 5.5 e85124c0f0 libxe2: the int8 lm_head in ESIMD -- 96 ms -> ~2.5 ms a call at N = 248320, K = 5120
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>
2026-10-28 00:06:22 +01:00
claudeandClaude Opus 5.5 efdfc4a570 libxe2: the int4 W4A16 release's GEMMs -- w4a16_asym on fp16 DPAS, w4a8i8_asym on int8 DPAS, quant_act_i8g
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>
2026-10-28 00:06:22 +01:00
claudeandClaude Opus 5.5 ab0175564b libxe2: ESIMD kernels compiled with the vector compiler's -ffp-contract=off
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>
2026-10-28 00:06:22 +01:00