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>
The launch floor and the read-bandwidth probe needed a gate and gave up
without one, which withheld every device timing on SYCL once its gates
were removed (8931aae8). Both now run ungated there: the read probe's
launches move megabytes each, so the queue stays ahead of the host; the
floor then includes the host's submission time where that is longer,
and the header says so. Gated backends are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>