16 Commits
Author SHA1 Message Date
aneinanderandClaude Opus 5.5 ca793ea99a libxe2: gate_quant_fp8 (output gate, multiply and quantiser in one launch)
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>
2026-11-18 09:09:46 +01:00
claudeandClaude Opus 5.5 4511822138 libxe2: add_rmsnorm (schema and row); arch/common: the plain norm and the attention gate without unread work
- 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>
2026-11-02 03:17:05 +01:00
claudeandClaude Opus 5.5 f26eec2633 libxe2, arch/common: silu_mul for 4-bit down projections, float exp at the tie rule; head-row norms vectorized; attention SLM by gqa
- 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>
2026-11-02 02:32:05 +01:00
claudeandClaude Opus 5.5 726e532114 libxe2, arch/common: the 28 Oct pending set, the bf16 cast fused, the vectorized norm, a draft-vocab prefix
- 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>
2026-11-02 01:52:01 +01:00
claudeandClaude Opus 5.5 6969fcf8cb libxe2: libref's sigmoid and silu at a third of the cost, bit-identical -- gated norm 230 -> 37 ms, gated_quant 320 -> 254 ms at 2234 tokens
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>
2026-10-28 09:56:34 +01:00
claudeandClaude Opus 5.5 2365a2ae51 libxe2: the w4a8i8 prefill GEMM tiled through local memory -- 27 -> 62-78 int8 TOPS, prefill 291 -> 378 tok/s
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>
2026-10-28 00:52:58 +01:00
claudeandClaude Opus 5.5 efdfc4a570 libxe2: the int4 W4A16 release's GEMMs -- w4a16_asym on fp16 DPAS, w4a8i8_asym on int8 DPAS, quant_act_i8g
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>
2026-10-28 00:06:22 +01:00
claudeandClaude Opus 5.5 ed8e26c2fc libxe2: quant_act_fp8 a sub-group a (row, group) -- 49.6 -> 8.0 us at n=17408
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
2026-10-26 02:20:16 +01:00
claudeandClaude Opus 5.5 bbc7607222 libxe2: rmsnorm_quant_fp8 keeps a row's values in registers -- 0.30 -> 0.16 s a 1882-token prefill
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
2026-10-24 17:57:05 +02:00
claudeandClaude Opus 5.5 71356b773e libxe2: rmsnorm_quant_fp8 with 16-byte loads for bf16 rows -- 112 -> 44 us a call
Half the norm's time was its per-element loads of x, the residual and the gain. bf16 rows (gain
bf16 or f32) now load and store 8 values at a time and a 128-group's codes go out 8 bytes a lane;
the arithmetic and the ordered sum are the general form's. Bit-identical to libref (kbench rel_l2
0; 408/408 live oracle issues). 128 calls a speculative round: 17 -> 6.5 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
2026-10-24 12:01:34 +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 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
claudeandClaude Opus 5.5 a71783806a libxe2: the norm and the fp8 quantisers 3-4x faster at decode, still bit-identical to libref
At one row a work-group, rmsnorm_quant_fp8 took 108 us and gated_quant_fp8 84 us a call (26% and 10%
of a decode step at a 1.8k context). The ordered sum of squares now reads its squares eight at a
time and adds them in the same order; quant_group computes a group's values once into registers and
writes out_bf16 itself; gated_quant_fp8 spreads a row's independent groups over ceil(groups/16)
work-groups. rad-kbench: 208/208 and 206/206 at rel_l2 0.

scripts/sycl/profile_decode.sh isolates decode steps' per-op device time (two profiled runs of the
same request, 1 and 1 + STEPS tokens, differenced). Decode at 1.8k context: 34.8 -> 26.6 ms of
device time a step; the two ops 9.1 -> 3.7 and 3.5 -> 0.9 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
2026-10-23 20:47:13 +02:00
claudeandClaude Opus 5.5 a65ab54213 libxe2: Phase 4 step 1 -- a bandwidth-bound decode GEMV and an ordered sum from local memory
The profile of a MiniCPM5-2B decode step on the B65 (232.8 ms) was 79% gemm_nt, reading its
weights at 62 GB/s, and 13% the norms' serial sum of squares.

- xe2_gemm_nt_gemv / xe2_logits_gemm_gemv (priority 10, M <= 16, bf16): a sub-group an output
  column, 16-byte coalesced weight loads, a tree reduction. Not libref's order: rad-kbench passes
  them at the gemm tolerance (fixture 361/361, MiniCPM5 180/180, worst rel_l2 1.6e-4), and
  XE2_EXACT=1 sends every launch to the exact kernel for bisecting.
- The norms form their squares in parallel into local memory and add them in index order: still
  bit-identical to libref.

Decode 4.2 -> 35.5 tok/s. Against a libref-only host build, over 1914 positions of the repo's docs
with every position through the GEMV: KL mean 5.9e-4, p99 3.5e-3, top-1 98.5% -- libavx's own
distance from libref is 5.7e-4 / 3.0e-3 / 98.6%. The exact path scores KL 0, top-1 100%.

docs/SYCL_PROGRESS.md: the profile, the KL bound (D13), and the user's decision to use the bf16
container for Milestone B instead of the fp8 one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
2026-10-23 19:48:40 +02:00
claudeandClaude Opus 5.5 8db5b6efff libxe2: strided cast and libref's sigmoid -- MiniCPM5-2B serves on the B65, greedy-identical
Serving MiniCPM5-2B bf16 on the Arc Pro B65 found two things rad-kbench's dense operands did not:

- cast is handed the q slice of the fused qkv row (2048 of every 2560 elements) and refused it,
  stopping the first step by name. It now walks any strides in libref's offlin order.
- gated_quant_fp8 took sigmoid with an f32 exp, within rad-kbench's tolerance but not libref's
  double exp: now and then an ulp in silu moved the bf16 narrowing and one E4M3 code, in some of
  the 42 layers, enough to flip a greedy near-tie tokens later. The engine's own op oracle
  (RADIANCE_OP_ORACLE='*', which runs libref on the operands the device kernel was handed) found
  it: 9 of 600 issues before, 600 of 600 bit-identical after, over a 26-token prefill.

With both, a greedy run on the B65 matches a libref-only host server token for token on all eight
prompts of scripts/sycl/greedy_compare.py (64 tokens each), and the top-5 logprobs agree exactly
over 96 decode steps. /v1/chat/completions answers coherently, reasoning split out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
2026-10-23 16:49:14 +02:00
claudeandClaude Opus 5.5 0e81041881 libxe2: rmsnorm, rmsnorm_quant_fp8, quant_act_fp8, gated_quant_fp8
One work-group a row; a quantisation group a sub-group. The arithmetic is libref's step for step,
and two things made it so on the card:

- Device code is generated at link time (AOT), so the flags that shape it now go to the link as
  well as the compile: -ffp-contract=off, -ffp-model=precise, and -foffload-fp32-prec-div/-sqrt.
  Without correctly rounded division a group's scale amax * (1/448) came out one ulp off, and
  bf16 inputs sit exactly on E4M3 rounding ties often enough that 1780 of 524288 codes moved
  (a standalone host/device comparison showed it; with the flags, none).
- The sum of squares is libref's ascending f32 sum, by one work-item. A tree reduction moved
  normed values across bf16 ties on MiniCPM5-2B's real weights and failed rmsnorm_quant_fp8 at
  M=1 (rel 7.7e-3 against its 4e-3 tolerance).

rad-kbench against libref: the fixture 228/228 and MiniCPM5-2B's container 140/140, worst rel_l2
1e-7, inside guarded allocations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
2026-10-23 16:02:58 +02:00