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