10 Commits
Author SHA1 Message Date
claudeandClaude Opus 5.5 dad30c6b59 libxe2: m2xfp4 meta and exponents tiled too, each column's max exponent stored at load -- gate_up 222 -> 205 us
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
2026-10-26 02:06:52 +01:00
claudeandClaude Opus 5.5 68d510b1f4 libxe2: m2xfp4 codes stored tiled at load -- the verify GEMM's step one block load, gate_up 240 -> 222 us
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
2026-10-26 01:47:12 +01:00
claudeandClaude Opus 5.5 36b8941096 libxe2: the verify GEMM's e_max in the prepass launch -- down 156 -> 142 us at M=8
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
2026-10-25 13:12:30 +01:00
claudeandClaude Opus 5.5 fc1f2bba59 libxe2: the m2xfp4 verify GEMM in ESIMD -- gate_up 403 -> 256 us at M=8
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
2026-10-25 11:13:28 +01:00
claudeandClaude Opus 5.5 9da46ab7fe libxe2: prefill GEMMs on oneMKL -- 27B prefill 208 -> 305 tok/s
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
2026-10-24 17:49:44 +02:00
claudeandClaude Opus 5.5 c036bfcb88 libxe2: m2xfp4 verify GEMM reads e_max itself and stores y when K is not split
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
2026-10-24 14:51:18 +02:00
claudeandClaude Opus 5.5 c55ca689fe libxe2: m2xfp4 verify GEMM on register DPAS -- no local-memory round trip
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
2026-10-24 13:56:02 +02:00
claudeandClaude Opus 5.5 e9b2714081 libxe2: chain-parallel gdn_chunk_scan and an fp16 m2xfp4 prefill -- 27B prefill 68 -> 91 tok/s
- 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
2026-10-24 05:33:08 +02:00
claudeandClaude Opus 5.5 bce0f4db70 libxe2: the DFlash2 path fast -- exact draft head, DPAS verify GEMV, parallel rerank
- gemm_nt_q over the zero-point grids at M <= 16 (the drafter's 2-bit vocabulary head, N=248320):
  a sub-group a column, the group sums exact integers in f32, libref's group terms added in group
  order through lane broadcasts -- bit-identical to the exact kernel on the live head (checked in
  the engine: 0 differing bytes of 3.5 MB, every round). 252 ms -> well under 1 ms a call.
- m2xfp4 at 2 <= M <= 16 (the verify width) on XMX: a lane a column decodes its codes a 64-byte line
  at a time into its sub-group's VNNI slice of local memory (subnormal-bit fp16 pairs times
  (1 + k/4) * 2^(e - e_max + 14)), eight K16 DPAS a step against the permuted fp16 activation,
  K split for narrow N, partials added in order. On the vector ALUs M = 8 cost five times M = 1;
  gate_up at M = 8 1159 -> ~490 us. rad-kbench on the 27B: 50/50, rel_l2 ~8.5e-4 (tol 4e-2).
- logit_rerank: a work-group a row, a sub-group a candidate along K, libref's double sum as a float
  pair (two-product, two-sum, a fixed lane tree), libref's selection; 136 ms -> negligible a call.
- the gated delta net's gate, beta and decay (libref's double exp / log1p) once a (token, head)
  in a prepass instead of once a column block; still bit-identical (10/10 at rel_l2 0).
- profile_decode.sh: KEEP=DIR keeps the per-geometry tables.

27B on the B65, greedy: 12.1 tok/s plain, 13.2 tok/s with the drafter (device time a token
217 -> 76 ms under speculation). The drafter's text now departs from plain decoding at a
near-tie (byte 246 of 256 tokens): the verify forward runs the M = 8 DPAS path and plain decoding
the M = 1 GEMV, whose roundings differ (~1e-3); with the exact kernels the two were identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
2026-10-24 04:37:16 +02:00
claudeandClaude Opus 5.5 15944be7e3 libxe2: fast decode kernels for Qwen3.8-27B-PARO-M2XFP4 -- 0.1 -> 12.1 tok/s on the B65
- m2xfp4 GEMV (M <= 16): e2m1 decoded to fp16 by bits alone ((mag << 9) | sign << 15 is exactly
  e2m1 * 2^-14; the card keeps fp16 subnormals), K permuted (u, u + 4) inside each 8 so a code
  pair is one shift and mask, the activation as fp16(a * a_scale / R * 2^14) in that order, half2
  subgroup and group sums, f32 across groups; four columns a sub-group at decode. The scalar
  form was ALU-bound (~10 ops a weight, 80 ms a token); this one runs at 415-525 GB/s on the
  27B's shapes in a standalone probe. rad-kbench against libref on the container: rel_l2 ~5e-5 to
  ~3e-3, tolerance 4e-2.
- m2xfp4 prefill (M >= 17): the weight decoded to bf16 (exact) and the activation to
  bf16(e4m3 * scale), then the bf16 XMX GEMM per part.
- givens_dense_quant: a sub-group an output, the rotation row read coalesced, libref's double sum
  as a float pair (two-product and two-sum, ~48 bits); the double form stays for XE2_EXACT=1.
  146 -> 5.4 ms a token.
- the joined fp8 head (logits_gemm, M <= 16): E4M3 to fp16 by bits ((b & 0x7F) << 7 is E4M3 *
  2^-8), bytes (0, 2), (1, 3) as half pairs; an i8 head or a narrow scale block element by element.
  43 -> 3.9 ms.
- gated delta net, still bit-identical to libref: the decode step split over 16-column blocks
  (384 work-groups, not 48) with the gated norm in a second kernel and the anchor replay its own
  launch (block 0 rewrites the factors other blocks read); the chunked scan and the kkt solve
  work-group parallel; persistent staging (workspace slots) instead of a malloc and a wait a call.
- rmsnorm_quant_fp8: the row in local memory, loads issued before stores, the ordered sum fed by
  sub-group broadcasts -- still libref's chain (a probe puts that chain's floor at ~32 us for 5120).
- round_dt converts the float dtypes directly.

rad-kbench: 1410/1410 on the fixture; the 27B container's M <= 32 bands 77/77. Decode (greedy, no
speculation) 12.1 tok/s, coherent text; with the DFlash2 drafter 5.3 tok/s and the same text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
2026-10-24 03:22:48 +02:00