Commit Graph
1080 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
aneinanderandClaude Opus 5.5 e1d612b29d docs: SYCL_PROGRESS -- change 11's commit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 20:55:06 +01:00
aneinanderandClaude Opus 5.5 0a1fed0bcf libxe2: GDN recurrent state store through local memory, out as whole lines
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>
2026-11-11 20:55:00 +01:00
aneinanderandClaude Opus 5.5 0aad575475 docs: SYCL_PROGRESS -- generic change 10 (gated prologue), 27B re-bench
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 11:51:00 +01:00
aneinanderandClaude Opus 5.5 9aef29661b libxe2: fused gated-attention prologue (qk_norm_rope_gate, qk_norm_rope_gate_kv_store)
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>
2026-11-09 11:50:39 +01:00
aneinanderandClaude Opus 5.5 47d1a952e9 docs: SYCL_PROGRESS -- Gemma 4 E2B on Intel, changes 6-9
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:10:37 +01:00
aneinanderandClaude Opus 5.5 dd20835f18 libxe2: sliding-window attention on the DPAS kernels
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>
2026-11-08 21:08:31 +01:00
aneinanderandClaude Opus 5.5 d35027aaf7 libxe2: split-KV paged attention up to head_dim 512
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>
2026-11-08 20:29:25 +01:00
aneinanderandClaude Opus 5.5 0c7606423b libxe2: fused attention prologue (qkv_norm_rope, qkv_norm_rope_kv_store)
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>
2026-11-08 20:29:25 +01:00
aneinanderandClaude Opus 5.5 25c8fbd136 libxe2: qk_norm_rope, conv1d_dw, conv2d, attn_local_rel rows
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>
2026-11-08 14:28:38 +01:00
aneinanderandClaude Opus 5.5 ff4b7c9fb4 libxe2: rmsnorm_p, relu, logit_softcap, rel_sinusoid, pool_rows rows; rope to head_dim 512
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>
2026-11-08 14:15:31 +01:00
aneinanderandClaude Opus 5.5 e1e21935cc docs: SYCL_PROGRESS, generic backend work of 2026-11-08 (changes 1-5, op coverage, gdn analysis)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:28:22 +01:00
aneinanderandClaude Opus 5.5 b0ac7fd42c libxe2: device rows for gelu, silu, gelu_tanh, scale, mul_weight, clamp, fill, iota, act_mul, gelu_mul
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>
2026-11-08 13:15:46 +01:00
aneinanderandClaude Opus 5.5 d04a27fad3 libxe2: gemm_nt_bias on the fast GEMMs, the epilogue in libref's order
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>
2026-11-08 12:54:54 +01:00
claudeandClaude Opus 5.5 6abca01f17 libxe2: w4a16 decode GEMM in 16-row blocks, each group's codes decoded once
gemm_nt_q at w4a16_asym (M <= 64) ran 8-row blocks, each reading and decoding the whole 4-bit weight:
16 rows paid twice, 64 rows eight times. launch16x2 takes two 8-row bands against each group's codes,
loaded and decoded once, the activation loaded 32 columns at a time so both bands fit the default
register file (no spill). The per-row arithmetic is launch16<8>'s. XE2_W4_RB8=1 keeps 8-row blocks.

Qwen3.8-27B int4 (RedHatAI, as shipped), MTP depth 3, Arc Pro B65: 4 concurrent 256-token streams
97.6-99.2 -> 109.4-110.0 tok/s aggregate (+12%); one stream unchanged (43.1 -> 43.2). XE2_W4_CHECK=50
against libref's loop on the host: rel_l2 <= 6.6e-5 on every shape, tens of ties in ~10^5 outputs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 01:53:59 +01:00
claudeandClaude Opus 5.5 2f1fdd4d11 libxe2: bf16 GEMV at 9-16 rows on DPAS, the weight read once
At 9 <= M <= 16 the bf16 skinny GEMM (gemm_nt, logits_gemm) fell to the SIMT kernel's one column a
sub-group, 6-8x the 8-row DPAS kernel's time on the same weight. The ESIMD kernel gains RC = 16: two
8-row DPAS on each transposed weight tile, rows past M clamped by the 2D load and not stored.

MiniCPM5-2B bf16 on the Arc Pro B65 (rad-kbench --bench, cold weights, M = 16): gate_up
712 -> 104 us, down 465 -> 61, qkv 148 -> 29, o 145 -> 25. Twelve concurrent 256-token streams:
198 -> 654 tok/s aggregate. rad-kbench gemm_nt + logits_gemm: MiniCPM5 360/360, fixture 686/686.
XE2_GEMV_SIMT=1 keeps the SIMT form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 01:38:14 +01:00
claudeandClaude Opus 5.5 3582900903 libxe2: DPAS flash attention at head_dim 64 and 128, not only 256
attn_flash_esimd (decode / verify and prefill) and attn_flash_quad (prefill) were written over HD
but gated to head_dim 256 (Qwen3.8's full attention); every other model fell to the SIMT kernel.
Both now dispatch 64, 128 and 256; the decode merge takes HD / 16 values a lane.

MiniCPM5-2B bf16 (head_dim 128, gqa 8) on the Arc Pro B65, same build, XE2_ATTN_SIMT=1 as before:
decode 69.3 -> 83.1 tok/s, prefill at ~2k tokens 1806 -> 8080 tok/s. rad-kbench attn_paged:
fixture 207/207, MiniCPM5 160/160, Qwen3.8-27B 160/160. KL against XE2_EXACT=1 over the
12-document corpus: mean 0.00060, top-1 98.59% (the SIMT kernel: 0.00060, 98.59%).
Qwen3.8-27B int4 unchanged (30.1 tok/s, 1361 tok/s prefill).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 01:16:14 +01:00
claudeandClaude Opus 5.5 989db71bfc docs: the engine baseline, RedHatAI Qwen3.8-27B-INT4 as shipped, with and without MTP, beside stock vLLM 0.33
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 00:45:10 +01:00
claudeandClaude Opus 5.5 098b1779fc docs: the PARO-M2XFP4 baseline on the v1.17 merge (bench-standard quick)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 22:46:43 +01:00
claudeandClaude Opus 5.5 45f3b510c7 Merge upstream main (v1.15.1 -> v1.17.0, 152 commits) into the SYCL port
Conflicts, both sides kept:
- abi: RAD_ABI_VERSION 37 (upstream); the fork's RadBuildCtx.plain_norm after upstream's
  expert_file_tier, widened to int64_t so it starts past ABI 37's 208-byte struct instead of in
  its tail padding (abi_layout_test); RadSyclStream rows after RadShapeGen*.
- arch/common/rad_block_gdn_fp8.h: upstream's q8_rot guard and the fork's o_plain guard
  combined; the decode-row q_o.step only where q_o is declared (!o_plain).
- docs/OPS.md: upstream's optional params on sample_logprobs, the fork's q_temp on
  mtp_couple_propose.

Also ignores /baseline-models/ (local model copies).

Host tests: arch_test's MTP lint/graph-pin failures are unchanged from before the merge (the
fork's mtp.fc LinearFP8, 10a99a5); avx_check's hand-built moe_gemm_q w4a8 case also fails on
upstream's own files; images/videos need FFmpeg; three binaries over their CPU budget on this VM.
SYCL card tests 3/3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 22:13:08 +01:00
claude 2bb2f7bacc current work 2026-11-06 20:41:14 +01:00
Code000 451b136874 tests: the preemption cases pin --prefill-interleave 0
The served default --prefill-interleave auto:1 (previous commit) follows measured step times, so the
four sequences of preemption_by_recompute_continues_each_stream_exactly sometimes never overlapped
enough to preempt and the test's CHECK(n > 0) failed in about half the runs under a loaded host
(plain main: 6/6 pass). The cases are sized for the fixed schedule they were written against;
small_pool_args() now pins it. Nothing they check is loosened: the streams must still match and
preemption still happen. With the flag: 6/6 alone and 3/3 beside 40 busy threads, and the case
takes 3 s again instead of 5-12 s.
2026-11-05 20:37:24 +01:00
Code000 a58304632a scheduler: --prefill-interleave defaults to auto:1 where nothing pins the schedule
Cause: with --prefill-interleave 0 every step carries a chunk while a prompt prefills, so a
sequence already decoding gets one token group per chunk step. On Qwen3.8-Flash-Next fp8 (TP2,
MTP 3 drafts) with 8 sessions decoding while 64K-token prompts prefill, that is 12.3 tokens/s a
session against ~83 alone; with 4 such prompts at once, 5.4.

Change: not given, engine bring-up now serves --prefill-interleave auto:1: after a prefill chunk
that ran beside decoding sequences, decode-only steps follow for as long as the chunk step took.
--deterministic keeps 0 (a schedule that follows timing is not reproducible), as do KL mode and
generators (nothing decodes beside a prefill there); an explicit --prefill-interleave N|auto[:SHARE]
wins. Startup names the decision with its reason. The Config default stays 0, so a Scheduler built
directly (tests) keeps today's schedule; Config::prefill_interleave_set records the flag.

Evidence (decode tokens/s a decoding session / aggregate prefill tokens/s / TTFT), 8 sessions
decoding beside 64K prompts:
  --prefill-interleave 0       12.3 / 3,664 / 17.3 s
  auto (0.25)                  23   / 3,181 / 20 s
  auto:1                       40.9 / 1,823 / 35.5 s
  auto:2                       50   / 1,166 / 56 s
with 4 concurrent 64K prefills: 0 5.4 / 2,934 / 64 s; auto 14.8 / 2,545 / 74 s; auto:1 33 / 1,395 /
137 s. auto:1 roughly triples a decoding session's rate for twice the prompt's time to first token.
BetterBench quick (short prompts, concurrency 1/2/4/8) shows no reliable difference between 0 and
auto: a short prompt is one chunk, after which nothing is held. config_test: the flag records that
it was given.
2026-11-05 20:20:13 +01:00
Code000 6e134fc15f sched_test: the burst simulation starts with sequences decoding, and takes auto:SHARE
Cause: the device measurements of --prefill-interleave were taken with sessions already decoding
when the long prompts arrive (8 decoders beside 64K prompts); the simulation only had the burst's
own prompts, which decode after their first token, and could not set auto's share.

Change: SIM_DECODERS sequences of 64-token prompts (SIM_DEC_OUT tokens each, default 4096) decode
for 16 steps before the burst arrives and count as decoders while it prefills; the run ends with
the burst's last prompt. SIM_SHARE is auto's share (SIM_IL=-1 SIM_SHARE=1 is auto:1). The summary
adds the decoders, the steps that carried a chunk per checkpoint interval prefilled, and prints
the interleave as given (N or auto:SHARE).

Evidence: RAD_SCHED_SIM=1 SIM_N=1 SIM_LEN=65536 SIM_DECODERS=8 SIM_SEQS=16, SIM_IL 0 / auto /
auto:1 / auto:2: TTFT 17 / 20 / 33 / 51 s, decode while the prompt waits 9.7 / 17.0 / 37.0 / 47.1
tokens/s a sequence, against the device's 17.3 / 20 / 35.5 / 56 s and 12.3 / 23 / 40.9 / 50
(Qwen3.8-Flash-Next fp8, TP2, MTP 3). SIM_N=4: TTFT max 56 / 67 / 109 s at 0 / auto / auto:1,
decode 6.7 / 15.6 / 34.5, against the device's 64 / 74 / 137 s and 5.4 / 14.8 / 33.
2026-11-05 20:20:13 +01:00
Code000 c00b882b96 scheduler: --prefill-interleave auto:SHARE sets the decode-only share of a chunk step's time
auto gave decode-only steps a fixed quarter of a chunk step's time. On the device (8 decoding
sessions beside 64K prefills, MTP on) that left decode at 23 tokens/s a session against 83 alone,
with 0.45 s gaps: two or three decode steps of ~40 ms per 0.45 s chunk. auto:SHARE makes the share a
choice (0 < SHARE <= 4); auto stays 0.25. The cap on decode-only steps rises from 16 to 64 so a
larger share is not cut off. config_test parses it, sched_test checks auto:1.
2026-11-05 20:20:13 +01:00
Code000 5a8c5533d1 sched_test: an opt-in timed simulation of a burst of long prompts
Cause: scheduling policy for many long prompts arriving at once (how chunks share steps,
admission, decode rows beside chunks, interleaving) was judged on the device only, where a
run of 32 x 128K prompts takes 40 minutes and the device is shared.

Change: sim_burst_of_long_prompts drives the real Scheduler through such a burst (prompts,
decode with three drafts a step, the stager floor, --prefix-resume exact) and times each
step with a cost model whose defaults are fitted to Flash-Next at TP2 (a lone prefill and
decode alone). It checks nothing and returns at once unless RAD_SCHED_SIM is set; the
workload, the flags and the model's terms come from SIM_* variables (see the comment).

Evidence (defaults, 128K prompts, 512 tokens out): the schedule keeps ~1984-2048 prefill
tokens in nearly every step at 4, 16 and 32 prompts (two prompts share a step at 1024 each
until the first decodes, then a chunk of 2048 less the decode rows with the next prompt
filling the rest), so the model predicts ~5.1K tokens/s aggregate at every burst size:
TTFT p95 100 / 412 / 814 s at 4 / 16 / 32 prompts against the device's 158 / 966 / 2456 s.
The gap grows with the burst size, so it is the device's cost of the steps a burst runs
(two-sequence and mixed steps), not the number of tokens the scheduler plans per step.
2026-11-05 20:20:13 +01:00
Code000 f87d03d304 scheduler: --prefill-interleave auto sizes the decode-only steps from measured step times
Cause: while prompts prefill, a sequence that is already decoding gets one token group per
step that carries a chunk. On Qwen3.8-Flash-Next at TP2 such a step takes a 2048-token
chunk's time (~0.4 s, more on the device under load), so decoders crawl at a few tokens/s
until the queue of prompts drains. --prefill-interleave N inserts N decode-only steps after
each chunk, but a fixed N costs the prefill whatever N decode steps cost, which grows with
the number of decoders, and is too few where decode steps are cheap.

Change: --prefill-interleave auto (default stays 0). After a chunk that ran beside decoding
sequences with its prompt continuing, as many decode-only steps follow as fit in a quarter
of a chunk step's time at a decode step's (running means of both, fed by step_finished from
the step wall times; at most 16; 1 until a decode step has been timed; 0 where a decode step
costs more than that quarter). The prefill gives up at most a fifth of its rate however
many sequences decode. The hold mechanics (no admission while held, steps issued ahead
count, the stager not armed for a held chunk) are --prefill-interleave N's, unchanged.
Under auto which steps carry a chunk follows the device's timing; a number keeps a
reproducible schedule. A chunk's cut and every row's computation are unchanged.

Evidence: sched_test interleave_auto_* (the count from given costs, the step shapes it
produces, nothing held for a lone prefill or when decode steps are too dear); config_test
parses auto. Host simulation of the scheduler (next commit), 32 x 128K prompts sent at
once, 512 tokens each, MTP 3, step costs fitted to a lone 2048-token prefill and to decode
alone: decode of the sequences decoding while prompts wait 6.5 -> 31 tokens/s each, last
first token 826 -> 875 s (+6 %), TTFT p50 453 -> 480 s; fixed N=2 gives 18 tokens/s at
the same cost. Device numbers: the commit that makes auto:1 the served default.
2026-11-05 20:20:13 +01:00
AnimusNull f713f449c2 glm5next: the width split is for all-MXFP4 experts
The layout rule chose the width split at four ranks and up before it knew the
weights' format. MoeFP8 refuses to slice a plain bf16 expert, so a container
of bf16 experts, or of MXFP4 with protected bf16 ones, that main serves at TP4
was refused unless --weights-disk-tier was set.

Read the container's encodings first, on every rank alike, and take the width
split only when every routed expert is MXFP4. The check declares no name map,
so no pinned graph moves.
2026-11-05 14:25:05 +00:00
AnimusNull e0c386ee85 docs: GLM-5.3-Flash lays its experts out by what the deployment needs 2026-11-05 14:24:14 +00:00
AnimusNull 8ef50a7708 glm5next: experts split by width at four ranks and up, whole for the file tier
Whole experts on their rank let the routed weights live on the drive, which
a two-card host needs, but at four and eight ranks they leave the shapes the
MXFP4 kernels are tuned for: glm_prefill wants 288 experts an op and finds 72.
On 4 x R9700 that cost prefill two thirds and four-stream throughput 37%.

Keep the width split at four ranks and up, as the kernels expect, and take
whole experts at two ranks or when --weights-disk-tier needs them (ABI 37,
RadBuildCtx::expert_file_tier). The file tier's graph at eight ranks keeps
main's pin, and the route-count fix that came with expert parallelism stays.
2026-11-05 14:19:17 +00:00
AnimusNull b954585f9f moe_mxfp4: the small-M form at GLM's TP4 slices too
At TP4 the launcher fell back to the expert-major form for every decode step. The small-M form
now takes gate_up from 9 to 384 routed rows (past one token's 8, where it reads 5 % slower) and
down up to 384 at the K256 x4 tiles. perfmx --perfmx-tp 4, cold, gfx1201, output byte-identical:
gate_up 3 to 18 % faster from 2 to 48 tokens, down 37 % at one token and 4 % at 48.

Served at TP4 with --vision-tower-placement ram, BetterBench against the same tree without it:
decode 52.3 -> 55.7 tok/s, 1/2/3/4 conversations 49.8/73.5/85.6/91.1 -> 52.7/76.5/90.0/96.4,
prefill unchanged. Temp-0 replies identical, needles 8/8 at 4 x 119k.
2026-11-05 14:18:21 +00:00
AnimusNull 220cb3f12c moe_mxfp4: a pin for the small-M form, and --perfmx-tp 4 to time it at the TP4 slices
r4d_moe_mxfp4_pin_small takes the small-M form where the rule does not (any GLM slice up to
384 routed rows, at either tiling) or keeps it off. r4d_selftest --perfmx-tp 4 times GLM's TP4
slices, gate_up 1024 x 4096 and down 4096 x 512, the rule's form beside the pinned ones, and
fails if their outputs differ by a byte. The rule itself is unchanged.
2026-11-05 14:17:44 +00:00
AnimusNull be623ba1dc glm indexer: a step that takes all its blocks does not split
A prefill chunk past the row threshold split the indexer over the ranks
even when every row's history fit the selection, so it scored rows whose
selection was already decided and gathered the result. Such a step now
takes the unsplit take-all path on every rank: zeros into a plane of its
own, [max_tok, topk + 1] (the score plane holds only a run of rows where
a step may split), and a selection over the whole step, with no query
side, scorer or gathers.

Temp-0 replies byte-identical to the scoring path; 114/114 tests.
2026-11-05 14:17:07 +00:00
AnimusNull c9e34d534c glm5next_test: the indexer's tests take both paths, scored and taking all
The fixtures' sixteen- and eight-column tables reach fewer blocks than the
selection, so their steps now take all (DsaCache::takes_all). Where a test is
about the scored path, its batch carries enough history to score; the steps
that take all assert that no query side or scorer runs and that the selection
reads the fill. The pinned graph adds the fill.
2026-11-05 14:16:30 +00:00
AnimusNull 8fa226e620 glm indexer: a step whose every row takes all its blocks skips the query side
With topk or fewer live blocks a row, qsa_select takes every live block in
block order whatever the finite scores, so the query projection, its copy,
the head gates, dsa_query and dsa_score decide nothing. Such a step fills the
score columns with zeros instead; the key side still runs, so the index cache
stays current. The decision reads the host bound splits() reads, so every rank
and every recorded pass agrees. Split steps keep scoring, since their
selection's rebased bounds come off the scorer.
2026-11-05 14:15:00 +00:00
AnimusNull bd38e7eced dma lane: the room check drops a reused fence slot and keeps what it once knew read
dma_read takes the end of the last finished list from ends[k % kDmaEnds]. The lane can have
more than kDmaEnds lists behind the engine (the prefill stager and the mover queue far more
than the prefetch's three), and once a later list has taken list k's slot that value would
overstate what the engine has read, letting the host write over a part of the ring not yet
read. The slot is now used only while fewer than kDmaEnds lists are behind it.

The check also keeps the most it has known read, so a list number it can no longer use does
not send it back to a stale written-back read pointer and wedge a ring that has room.
2026-11-05 14:14:24 +00:00
AnimusNull 8c389c02e7 docs: glm5next serves an fp8 latent cache
GUIDE.md no longer says glm5next refuses --kv-cache-dtype fp8: it narrows the latent-attention
cache alone. ARCHITECTURES.md's KV group table gives kv_latent's E4M3 form and its host-tier size.
2026-11-05 14:13:48 +00:00
AnimusNull d858aa722b glm5next: --kv-cache-dtype fp8 narrows the latent attention cache to E4M3
The plugin refused fp8. It now takes bf16 or fp8 and applies it to kv_latent alone: Geom::kv_dtype
is the configured cache dtype, kv_latent is declared in it, and GlmMla's kv_store and
kv_store_streamed name it, as does every mla_attn over the latent (head form, row form and the
MTP layer's), which then resolves to the fp8kv rows. The store keeps kv_store's default descale of
1, which the attention reads, as vLLM's fp8 cache does. kv_index_tail, kv_dsa_index and the KDA
groups keep their dtypes; the indexer reads only the latent group's tables. Host-tier, streamed
and replicated sizing follow the group dtype already. Under bf16 the attention states no
kv_dtype and the graph is the one declared before.

At 4 x 262144 tokens the latent cache is 12 layers of 512 bytes a token instead of 1024.

glm5next_test: fp8 declares the latent group E4M3 and the other four unchanged, every latent store
and attention names fp8_e4m3, and bf16 (stated or default) leaves the attention without kv_dtype;
the refusal test now refuses f16.
2026-11-05 14:13:11 +00:00
AnimusNull f776ecbf2e r4d_selftest: the mla_attn fp8kv rows against libref
mla_check states kv_dtype fp8_e4m3 for an *_fp8kv row and fills the cache with E4M3 codes over most
exponents, subnormals included; libref reads the same codes. Cases per twin cover its kernel forms:
the wave row, the matrix row's pairings (union, positional, element-wise load) and the rows row's
forms (rule, pinned rows kernel, element-wise load, 32 heads a workgroup).
2026-11-05 14:12:36 +00:00
AnimusNull e494369ed9 libref, libavx mla_attn: an optional kv_dtype, the cache shaped from it
Both schemas take `kv_dtype` beside `dtype`; libref's shape gives the cache operand that dtype when
it is named, the query's otherwise. The kernels already read the cache through ldt, so an E4M3
cache is read as its codes' values. ref_test covers an E4M3 cache under a bf16 query.
2026-11-05 14:10:58 +00:00
AnimusNull 17f0eae420 r4d mla_attn: E4M3 latent cache twins of the three rows
mla_attn takes an optional `kv_dtype`; at fp8_e4m3 the cache is E4M3 as kv_store_fp8 writes it at its
default descale of 1. mla_attn_fp8kv, mla_attn_matrix_fp8kv and mla_attn_rows_fp8kv are the bf16
rows' kernels with the cache element as a template parameter: the key load decodes E4M3 to bf16
(v_cvt_pk_f32_fp8, then the high half), which is exact since every E4M3 value is a bf16, so the
tiles and all arithmetic past the load are the bf16 instance's. The twins carry the bf16 rows'
constraints plus kv_dtype fp8_e4m3 and rank above all three bf16 rows, in their order. At uint16_t
the loads are the plain loads the bf16 kernels made; their launchers still refuse any cache that
is not bf16.

r4d_emu test_mla runs every kernel form (wave, matrix and its element load, rows forms 0-3) on E4M3
codes against its bf16 instance on the decoded cache: bit-identical on all 23 form/case pairs, and
each launcher refuses the other cache dtype.
2026-11-05 14:09:13 +00:00
mici81andClaude Opus 5.5 b632c72f5d sched: an overdue preempted prefill keeps its place ahead of the queue
A preempted request waiting for its whole-recompute gate (kAdmitWait) let the admission walk ask the
next request in the queue. For an overdue one that undoes the overdue path: the room it made in this
step went to a request queued behind it. With preempted prompts published, the victim forced off for
it needs almost nothing to come back, so it was re-admitted at once and forced off again on the next
step. Under KV pressure the same victim was forced off and re-admitted 26 times in 16 s while the
overdue request waited. An overdue preempted request that is still refused now stops the walk, as a
refused fresh request already does.

2x R9700, Qwen3.8-Flash-Next TP2, production flags with the KV cache cut to 6.45 GiB a card
(--gpu-headroom-mib 3072), 16 concurrent 58.6k-token prompts with 4000-token answers:
- without publishing preempted prompts:  wall 390.6 s, mean 338.5 s, 9 preemptions, 1 forced
- publishing them:                       wall 346.4 / 344.1 s, mean 306.6 / 299.8 s, 36 / 32 preemptions, 28 / 26 forced
- publishing them, with this change:     wall 331.0 / 324.4 s, mean 289.4 / 284.0 s, 8 / 9 preemptions, 1 / 1 forced

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 14:59:28 +01:00
mici81andClaude Opus 5.5 12b7b7889b sched: an overdue preempted prefill is failed only when waiting cannot help
On an idle engine the overdue path failed a preempted prefill on any refusal. A restore waiting a step
for a deferred release is a wait, and so is a refusal behind requests this step already admitted (the
budget or a card went to them); both clear by the next step. With preempted prompts published, the
restore path is common: under KV pressure two of ten preempted requests failed with "overdue
preempted prefill could not be admitted with nothing running", the debug log showing "the restore
waits a step for 1 deferred release(s)" right before. The path now fails only when nothing was
admitted this step and the refusal is not such a wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 14:59:28 +01:00
mici81andClaude Opus 5.5 01c7a3334a sched: a preempted request publishes its prefix; the recompute adopts it
Scheduler::preempt_back dropped everything a request had computed: unlike
close_request it published nothing, so a preempted 96.6k-token prompt was
computed again from its first token. The publish block of close_request is
now Scheduler::publish_prefix, called by both. Its blocks stay in the cache,
so a preemption that published gives eviction its rounds back (the decode
ensure loop and the overdue path) and the cache gives them back, the newest
last, before another request is preempted. preempted_can_prefill counts the
blocks the recompute adopts from the cache (pc_->lookup), so a preempted
request is not held back for room its own cached prompt already covers.

Shared KV with RADIANCE_KV_GUARANTEE=1 (nine Qwen requests preempted for
TranslateGemma's start pool): Qwen 587 -> 458 s, TranslateGemma 139 -> 80 s;
without the guarantee unchanged (340 / 58 vs 339 / 56). Test:
a_preempted_request_publishes_its_prefix; sched 187, engine_e2e and the
related suites pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 14:59:28 +01:00
Asim Siddiqui e3d65f3a7c libr3d: fix the w4a4 activation row pitch (strides are elements, not bytes)
The launcher passed a->stride[0] straight as the byte pitch, but strides are
in elements (abi/rad_types.h): an int4 row of K nibbles is K/2 bytes. The
kernel read row 2*src instead of row src (row 0 correct, every other row from
the wrong source, and past the plane for larger M). The weight side already
converts (r3d_tab_of's s0 = stride*bits/8, the kernel uses w_ld/2); the
activation now does too. The libref reference had the same bug and is fixed on
the w4a4-libref-wip branch, so the two now agree on the correct row.

Missed because r3d_selftest checks finiteness only and ref_test checks status
only on the libref sweep geometries.
2026-11-05 14:59:08 +01:00
Asim Siddiqui 28939a99df libref: fix the w4a4 activation row pitch and the dequant_w4 wq extent
Two layout bugs found in pre-PR review:

1. ref_moe_gemm_w4a4 treated A->stride[0] as a byte pitch. Strides are in
   elements (abi/rad_types.h), and an int4 row of K nibbles is K/2 bytes, so
   the reference read row 2*src instead of row src (and ran past the plane
   for M > ~4). The weight side already converts (w_ld / 2); the activation
   now does too. The kernel has the same bug (separate libr3d fix).

2. ref_dequant_w4_shape declared wq as {N*K/8} I4 elements = N*K/16 bytes,
   but the packed plane is N*K nibbles = N*K/2 bytes (the kernel and the
   reference both read N*K/8 dwords). Declared extent is now {N*K}.

Both were invisible to the harness: ref_test checks status only, and the
64-byte poison margin absorbed the over-read at sweep sizes.
2026-11-05 14:59:08 +01:00
Asim Siddiqui df4e2ea889 ref_test: sweep geometries for w4a8/w4a4 moe_gemm_q and the dequant_w4 zero-point arm
Four moe_gemm_q geometries (dtype w4a8 and w4a4, token- and sorted-order a) so the
w4a8/w4a4 reference GEMMs run against the kernels, and a dequant_w4 geometry at
K=128/group=128 with twos=0 for the zero-point decode arm.
2026-11-05 14:59:08 +01:00
Asim Siddiqui b87010c7dd libref: w4a4 reference implementation and dequant_w4 op
libref side of the w4a4 work; the libr3d kernels ship separately (submitted as PR 403).
- ref_moe_gemm_w4a4_shape; ref_moe_gemm_w4a8_shape now N_odd/K_odd-aware (ref_shapes.cpp)
- dequant_w4 schema with pDequantW4/oDequantW4 (ref_registry.cpp)
- ref_dequant_w4 zero-row guard (ref_quant.cpp)
- w4a4 reference GEMM and op declarations (ref_moe.cpp, ref_ops.h)
- dequant_w4 in kOps plus sweep geometry (tests/ref_test.cpp)
2026-11-05 14:59:08 +01:00
Asim Siddiqui 4bd9c39728 libr3d: accept a null params in sample_logprobs, per the canonical schema
The canonical sample_logprobs schema declares params optional (an absent
optional operand arrives as null data, rad_abi.h), and libr4d's kernel
already honours that (no params = every row). libr3d's launcher refused a
null params and its kernel dereferenced it unconditionally, so since the
canonical schema went optional (3b278dc) the engine refuses the whole
libr3d plugin at load: op 'sample_logprobs' has two different schemas.

Mirror libr4d: the kernel's flag test gains a null guard (no params:
every row runs), the launcher no longer refuses null, and the row's spec
marks the operand optional.
2026-11-05 21:18:00 +11:00
mici81 7f5218ee5f qwen4exp: decode, verify and draft passes are recorded, keyed by their split cap (issue #402)
pass_key() answered 0 for every draft and verify pass, and with a callback present the core neither
records such a pass nor gives its launches the keyed context bound, so with the MTP drafter nearly
every decode pass was issued op by op (1.17.0: 206 passes played and 508,236 issued unkeyed, where
1.15.1 played 492,894). Dropping the export would record them with the cores bucketed bound, which
2026-11-05 09:50:02 +01:00