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 (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>
- 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>
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>
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
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
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
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 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
- 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
For head_k = 128 each lane keeps its value column's 128 state values in registers (the 256-entry
register file, grf_size<256>), k and q spread over the sub-group and read by compile-time
broadcasts; every chain over d is libref's, in order. rad-kbench on the 27B's geometry (48 heads,
128 x 128, anchor form, q_len 1..16): rel_l2 0. gdn_conv_recurrent_update 243 -> 173 us a call in
plain decode, ~1000 -> 651 us at the verify width. XE2_GDN_SLM=1 keeps the local-memory form.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
- 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
- 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
Kernels, each libref's arithmetic in libref's order:
- gemm_nt_q at m2xfp4 (xe2_gemm_m2.cpp) with libref's m2 layout hooks, and givens_dense_quant
(xe2_givens.cpp, the rotation in double as libref's)
- the gated delta net (xe2_gdn.cpp): gdn_conv_prep, gdn_conv_update, gdn_kkt_solve, gdn_chunk_scan,
gdn_recurrent_update (per-candidate and anchor state forms), gdn_gated_rmsnorm,
gdn_conv_recurrent_update; each work-item one iteration of libref's parallel loop, the
per-(sequence, head) workspaces in a shared device workspace (xe2_common: workspace())
- rope's multi-component modes (mrope, imrope, axial) and rope_table
- logits_gemm over an fp8 128x128 joined head, gemm_nt_bias with its epilogue
- mul, sigmoid, scatter_rows, layernorm, grid_embed, attn_dense (the vision tower)
- dflash_conv and logit_rerank (plain and joined head) for the DFlash2 drafter
libref's gemm_m2 gains the parts (pb1/pb2) every other ParoQuant grid and libr4d's mx_parts
already define -- weight rows [0, e1), [e1, e2), [e2, N) read activation copies 0, 1, 2 side by
side -- since this model's fused projections are rotated per piece and the oracle declined them;
its shape hook widens a and a_scale by the part count. Both m2 arms now take the stored
codes-then-meta blob as the engine describes it, u8 [N, K], beside the shape hook's rank-1 form
(libref refused the engine's launch; only libr4d had been run on it).
rad-kbench on the fixture: every new row at rel_l2 0 (90 gdn/givens cases, 108 rope, 80
elementwise, 20 attn_dense, the drafter's and the heads'). On the B65 the model starts with every
op on the card and answers "The capital of France is" -> " Paris.\nThe capital of Germany is
Berlin.\nThe capital of Italy is" (greedy), at 0.1 tok/s: the correctness-first kernels.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1