- 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>
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>
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>
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 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