Change only the per-128-scale load-time expert layout to 16-column/64-K fragment tiles. Add the register-loaded one-row kernel, keep staged prefill compatible, and leave subgroup-scaled codebooks row-major.
Update the stored-layout hashes atomically with the layout and add independent canonical-nibble address checks.
Add the TP1 HYV3 expert geometry to the timing harness while keeping the Flash-Next mode. Rotate actively addressed codes and scales and check all output bytes across dispatch forms.
Keep WMMA, group and split arithmetic unchanged, but stage and reduce only the live row. Add byte parity, guard and canonical-arithmetic cases over legal launch geometries.
Extend registry bounds for the existing qkv_norm_rope_kv_store implementation and exercise the head-128 GQA-8/16 shapes numerically. No HYV3 architecture hook is included in this kernel-only branch.
isa_tools (fast tier) runs libr4d/isa/selftest.sh: no build tree, no card, no
ROCm. rows.awk at the nine 24-VGPR boundaries and at the wave64 quantum;
waterfall.awk on a forward branch after a movrel (not a loop), a real back-edge
(a loop), a movrel with no branch, and a kernel with no movrel after a kernel
that has one.
Against the code this replaces, five of the nine occupancy checks fail (97,
121, 145, 241, 256) and the forward-branch case counts a loop where there is
none. The rest pin behaviour that is right today: the movrel-with-no-branch row
and the empty kernel stay as they are, and the seen-flag reset in flush() has no
observable case in this tree -- waterfall.awk resets it per kernel so a later
edit cannot reintroduce one.
Both instruments could report a clean tree after inspecting nothing.
res.sh and waterfall.sh skipped an object whose code object would not extract
(`|| continue`), skipped a disassembly that failed, and then printed a header
and a short table and exited 0. waterfall.sh additionally counted every
s_cbranch_exec* after a movrel -- a forward branch is not the loop that re-runs
the movrel -- and carried that flag across kernels, because flush() reset n and
loops but not seen.
Now: no .hip.o under BUILD, a code object that will not extract, a
llvm-readelf/llvm-objdump that fails, or not one kernel inspected all exit 1. A
HIP translation unit with no kernels carries no .hip_fatbin and is skipped, not
failed -- one exists in this tree (r4d_ar_entry), which is why "every object must
extract" was not an option. The parse is waterfall.awk, and a branch counts only
when its target label was already defined above it, i.e. is a back-edge.
Measured over every kernel this tree builds (761 movrels): 199 loops become 101,
19 rows change, and 12 of them are r4d_ar_twoshot_Nrank_exact reporting 7 where
it has no back-edge at all:
r4d_ar_twoshot_Nrank_exact 7 -> 0 (x12)
r4d_hc_bf16 6 -> 1
xprefetch 4 -> 3
r4d_ple_gate_bf16 3 -> 0
r4d_ngram_ids 2 -> 1
spechub 9 -> 8, 2 -> 0
r4d_encoder_bf16 1 -> 0
A model with snapshots (recurrent state, or a sliding window the cache does not index) resumes a
hit only at a snapshot, and those are taken on the checkpoint interval and at each prompt's tail.
A head every request starts with -- the same system prompt or instructions in front of a different
text, as a translation service sends its pieces -- is usually shorter than an interval, and each
tail is its own, so the head was computed again by every request.
The cache now counts the blocks published right after each block (Entry::n_children) and reports
where a lookup leaves a head that at least two cached prompts already left differently
(CacheHit::branch_at; one is not enough, the next prompt could be the same conversation going on).
When nothing resumes within kSharedHeadMin (256) tokens of that point, admission sets the request's
own checkpoint there (Request::checkpoint_at, which n > 1 already uses), and the requests after it
skip the head.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
--request REQ.json --rad MODEL.rad renders an OpenAI request through parse_chat_request with the
server's own adapters (the container's vocabulary, --override-chat-template, --chat-template-kwargs,
the architecture plugin's declared reply format from --home or the template's analysis with
--no-plugin), and reads each --reply file as the model's tokens: stopped at end of generation,
detokenised with the request's preserved tokens, parsed whole (the non-streaming body) and through
the SSE emitter (reassembled as a client does), with the tool-call grammar run over the tokens as
the sampler masks them. --render-raw renders a template with any JSON context through the vendored
jinja engine, for message shapes a request cannot carry. One JSON object on stdout.
rad-chatparse is now a plugin host: rad_core whole-archive with exports, the legacy parser's sources
compiled in.
RadChatFormat/ChatFormat gain arg_json_value_prefix, a second value prefix written in place of
arg_value_prefix before a JSON value (DeepSeek-V4.1's DSML: string="false" before JSON,
string="true" before text). The tag the reply writes decides how its value is read, for declared
and undeclared names alike, and JSON that does not parse is kept as its text; the grammar writes
the tag each argument's schema calls for and either for an undeclared name. The field sits at the
end of the struct, so an older plugin's shorter struct reads as unset and nothing changes for it.
chat_format_check refuses a typed format without both prefixes, with prefixes not told apart, or
with string-typed other values.
Tests: reading, streaming at every truncation, grammar arms per schema, refusals, ABI tail.
ChatTemplate::load ran the thinking probe, the first full render, outside any handler; a template
that compiles but fails in the reply-format analysis (here llama.cpp's own DeepSeek-V4.1 template,
which calls dict()) threw out of load and ended the process. It is now RAD_E_FORMAT with the
template's words, as a failing render already is per request.
llama.cpp names each imatrix entry by its tensor (blk.0.attn_q.weight.in_sum2); importance_for
stripped .weight from the weight's name and looked up only the bare stem, so --imatrix matched
no weight from a llama.cpp file: the codebook types that need it (iq1_s, iq2_xxs, iq2_xs) were
refused and every other type was quantised without its importances. Both spellings are found now,
per-expert rows included, and the row is read under the entry's own name.
Tests: format_test a_converter_weight_name_finds_llama_cpps_spelling (a dense and a stacked expert
entry spelled .weight.in_sum2, a missing expert, a wrong width) fails without the change and
passes with it; a_converter_weight_name_finds_its_imatrix_row (the bare spelling) is unchanged.
res.sh rounded the VGPR count up to a multiple of 8 before dividing the SIMD's
1536 registers, so 128 VGPRs reported 12 waves where the hardware allows 10, and
256 reported 6 where it allows 5. gfx1201 wave32 allocates in multiples of 24;
wave64 keeps the 8 the script used for both, which nothing measured says is
wrong.
gfx1201 Wave32, 1536 VGPRs/SIMD, measured over every kernel this tree builds
(3369 rows, ROCm 7.15 / clang 23, -O3) -- 755 rows change:
6 -> 5 214 rows (256 VGPRs)
11 -> 10 119 rows
14 -> 12 118 rows
10 -> 9 112 rows
13 -> 12 96 rows
12 -> 10 96 rows
The parse moved into rows.awk so selftest.sh can check it at the boundaries
(96/97, 120/121, 144/145, 240/241) without a build tree. Five of those nine
boundary checks fail on the arithmetic this replaces.
The row was only ever run at M = 256, which is a whole number of tile heights,
so no test entered the guarded epilogue. Every tile height the prefill arms
dispatch (64, 96, 128, 256 -- tile_bmbn) now gets the rows just past its tile
and one row past that, which is the shape that reads Ascale[M].
Smoke coverage: the harness checks the return code and the stream sync, not the
numbers, so this catches a fault or a rejected launch, not a wrong tail.
The epilogue computed $v = acc * Ascale[m]$ before the store guard, so on the
last row tile of an M that is not a multiple of the tile height it named
Ascale[M] -- a row the caller does not own. The read is under the guard now.
inside is STFAST && (m0 + BM <= M), so it implies m < M for every row of the
tile, and n < N holds unconditionally because the launch rejects N % BN != 0.
No behaviour change is claimed: on gfx1201 at -O3 the compiler already
predicates the whole scale-and-store block (s_and_saveexec + s_cbranch_execz
around both the global_load_b32 of the scale and the store), so the published
binary does not issue the invalid load. This keeps the source honest for
compilers and ISA levels that do not.
New models:
- Tencent Hy-Memory (HYV3) from its BF16, FP8 and GGUF checkpoints, with its native tool calls
- M2XFP4: metadata-augmented MXFP4 weights for Qwen3.8-27B and its DFlash2 drafter (top-1 89.1% ->
92.4% against plain MXFP4), its quantiser and recipe, and ParoQuant's M2XFP4 checkpoints
- Gemma 4 E2B/E4B audio input; NVIDIA-Nemotron-3.5-Bolt-E4B in int8 and 4-bit, on two cards by
default; Ornith-1.5-122B compose files
Speed:
- Weight reads beside the decode all-reduces (qwen35_fp8, gemma3; --weight-prefetch, on by default):
the 27B MXFP4 with DFlash2 61.2 -> 67.9 tok/s at c1, TranslateGemma 27B +13%
- Head-256 split-KV decode attention at 256 workgroups and without bank conflicts (27B: +3-5% a
step at 25-41K context), and the prefill KV split for small launches (a short turn over a long
context decodes the other sequences 27% faster in that step)
- MXFP4 decode gate_up, activation and fp8 quantiser in one launch (27B, Gemma 3 up to 64 rows:
TranslateGemma +2-5% at 2-8 streams)
- ParoQuant int4/int5 tiled GEMMs 6-9% faster
- Speculation: a step's tokens are sent before the drafter's passes end, no step waits behind one
that ends its requests, and the MTP head's first draft no longer collapses after short chats in
the prefix cache
Features:
- --kv-resident N: KV streaming for a context bigger than VRAM (qwen4exp_fp8, GLM-5.3)
- MiniMax-H3: reference media and keyframe conditioning with the VAE encoders
- Krea 2 rebalance presets balanced, detail and subtle
- The dashboard's request history; a stall watch that reports a frozen step's thread and stack
- rad-tune at the served configuration, collectives measured as the exchange; Gemma 4 E2B/E4B's
per-layer embeddings read ahead off the step path
- A GPTQ calibration tap and recipe for Gemma 4 31B's w4a8 container
Fixes:
- The two-rank all-reduce checks that a peer's push has landed before reducing it
- z-lab's DFlash drafter on Gemma 4 31B keeps drafting after a prefix-cache hit
- MiniMax-H3's modulation rows
Changes: Plugin ABI 31: out-of-tree plugins must be rebuilt. RADIANCE_PREFETCH_BESIDE is
--weight-prefetch now; RADIANCE_NO_HUGE_PAGES, RADIANCE_IDS_EARLY, RADIANCE_ATTN_BAND_SPLIT,
R4D_PREFILL_SPLITS, RAD_PLE_TIMING and RAD_PLE_CACHE_ROWS are gone.
q38-27b-paro-mxfp4-df2.recipe for a paroquant_m2xfp4 checkpoint: the trunk is imported as it
ships, rotations included, and the drafter's linears go to M2XFP4 as in q38-27b-m2xfp4-df2.recipe.
TOOLS.md names the import beside rad-convert's other imports.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A paroquant_m2xfp4 checkpoint (format m2xfp4, groups of 32, subgroups of 8, rotation groups of
128) is imported as ParoQuant's MXFP4 is: the codes, exponents and weight_meta bytes become the
m2xfp4 scheme's three planes byte for byte, joined row by row, with the learned rotations beside
them as the givens tables. LinearFP8 declares the rotated form like the rotated MXFP4 one, through
givens_dense_quant into its own E4M3 pair, and libr4d's layout hook and both m2xfp4 rows accept
it, the rows running a fused projection's parts (pb1/pb2) one launch a part as the mxfp4a8 rows
do. libref accepts the rotated planes and runs the parts as its mxfp4a8 arm does; libavx serves
no M2XFP4. checkpoint_test covers the import, quant_m2xfp_test libref's parts and r4d_selftest
libr4d's.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The gate_up GEMM + gelu_mul + quant_act_fp8 fold ran only up to 8 rows; at 2-8 concurrent translations with
speculation a step is 16-64 rows and the three kernels ran apart. gemm_mxfp4a8_gated_gemv_wide (9 <= M <= 64,
K >= 2688) is gemv_wide at two column tiles a block, the gate tile j and its up tile n/16 + j: each K-wave loads both
tiles' weights and reads the activation once; the wave partials are summed in gemv_wide's order and the narrow fold's
epilogue quantises, so codes and scales are byte-identical to the unfused path. No spill (96-196 VGPRs, RT 1-4).
RADIANCE_G3_FOLD_ROWS (0 = today's 8) sets the fold band; RADIANCE_G3_PF_ROWS / _PF_MIB / _PF_EARLY expose the
prefetch beside the all-reduces (measured: no gain, defaults unchanged). Unset knobs keep the pinned graph and steps.
Measured on 2x Radeon AI PRO R9700, TranslateGemma 27B (MXFP4 GPTQ, DFlash2 drafter, speculation 7), greedy held-out
translations, aggregate tok/s, 2 interleaved rounds:
| fold ceiling | x2 | x4 | x8 |
| 8 (today) | 289.9 | 521.2 | 686.3 |
| 16 | 298.6 (+3.0 %) | 521.0 (-0.0 %) | 686.9 (+0.1 %) |
| 32 | 296.9 (+2.4 %) | 541.6 (+3.9 %) | 682.7 (-0.5 %) |
| 64 | 297.8 (+2.7 %) | 549.0 (+5.3 %) | 700.0 (+2.0 %) |
Tests: r4d_selftest gated wide fold byte-for-byte against gemv_wide + gelu_mul + quant_act_fp8 (or gated_quant_fp8)
for TranslateGemma's 21504x5376 at M 9-64 and other shapes (156 ok, 0 FAIL on gfx1201); arch_test gemma3 16/16
(defaults keep the pinned graph and steps, knobs move only what they name).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The KV split of the head-256 / GQA-6 prefill kernel (few workgroups -> split the KV walk into segments,
f32 partials, the split-KV merge with a cu span) now serves every head-256 prefill row: GQA 12
(4-token pages: fp8, bf16, fp8_v4, k6_v4), GQA 6 with 4-token pages (the same four), GQA 8, GQA 4 and
GQA 2 (fp8, bf16). The fewer KV heads a rank holds, the more it matters: at TP 2 Qwen4-Exp (GQA 12) and
Qwen3.5-35B-A3B (GQA 8) keep one KV head per rank, so a 53-row tail runs 2 workgroups on 32 WGPs.
The host side (the law, the scratch sweep, the scratch-capped count, R4D_PREFILL_SPLITS, the merge
launch) moves into r4d_attn_prefill_split.h; each unit passes its own geometry (query rows per workgroup
= 24 * 16 / gqa, tile 48). The GQA-6 unit is refactored onto it with the same law (Qwen3.8-27B in the
engine: greedy top-5 logprobs bit-identical before and after at 300 positions after 25k and 41k prompts).
Left unsplit: GQA-2 launches with a sliding window (the partition has no window floor; a 1024 window
walks at most ~26 tiles), the lossy e4m3 legs, and the head-128 / head-64 legs sharing the bodies.
Split count, one sequence, N query rows -> S: GQA 12 with 1 KV head: 1-32 -> 32, 53 -> 16, 160 -> 6,
1024 -> 1; GQA 8 with 1 KV head: 53 -> 16, 345 -> 4; GQA 2 with 4 KV heads: up to 160 -> 8. Scratch at
declare at most 25.4 MB per row. Split vs unsplit: at most 0.000488 (fp8 KV) and 0.0039 (bf16, fp8_v4,
k6_v4; about 1 bf16 ulp).
Tests: the split tests generalised over geometry for all 18 split rows (query lengths 1-640 over 8k-20k
keys, empty segments, ragged batches, pipelined pieces, poisoned scratch, oracle rows at each tile edge,
declare-time scratch): 1782 ok; the mixed-step case over 9 geometry x cache pairs: 54 ok. Every kernel
that existed before is byte-identical (311 of 311).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
DenseFP8, the drafter's linear, reads a plain m2xfp4 encoding as LinearFP8 does: the weight view
takes the codes and meta planes together, the E8M0 plane is b_scale and b_ref, and gemm() issues
gemm_nt_q at dtype m2xfp4 over the same E4M3 pair. declare_slice stays block fp8 and clears the
flag. The DFlash2 block keeps an M2XFP4 gate_up off the fp8a8 gated fold, as it does an MXFP4 one.
The recipe is q38-27b-mxfp4-df2.recipe with its 4-bit trunk and drafter rules at m2xfp4.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LinearFP8 recognises a plain m2xfp4 encoding (codes, E8M0 exponent and one meta byte per group of
32, no transform) and declares gemm_nt_q at dtype m2xfp4 over the producer's E4M3 pair: the weight
view selects codes and meta together, the exponent plane is b_scale and b_ref as for MXFP4, and the
row-part, shape and column-shard rules are the MXFP4 ones. Like the other non-block-fp8 forms it
refuses a stored view. step() issues it in a block of its own with the MXFP4 GEMM's operands, and
MlpFP8 keeps it off the fp8a8 gated fold, so an M2XFP4 gate_up takes the GEMM and gated quantiser pair.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two gemm_nt_q rows at dtype m2xfp4: a split-K decode kernel that stages the weight through LDS,
and a tiled prefill kernel after the mxfp4a8 one. The relayout appends the [K/32][N] meta plane to
the fragment-order codes and r4d_m2xfp4.h's e4m3 staging table takes the subgroup multiplier as a
second index, so the WMMAs and the epilogue are the mxfp4 kernels'. The decode row keeps its own
per-output arrival counters, as mxd_out_ctr does. r4d_emu_m2xfp4 runs both kernels on the host,
and r4d_selftest and kbench (a 4e-2 tolerance for the k = 3 rounding) cover the rows. The raw
entry points are declared in r4d_m2xfp4.h, beside the table.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libref serves gemm_nt_q at dtype m2xfp4 against the E4M3 activation and its per-128 scales, from
ref_m2xfp4.cpp: libref keeps one row an op, so the gemm_nt_q row takes its launch, shape and
layout hooks from there, each answering m2xfp4 and passing every other dtype to the hook it had.
The layout joins the codes and meta planes into one U8 operand (codes rows, then meta rows) and
the GEMM decodes it element by element. libavx refuses the encoding, so the host backend falls
through to libref. The core's selection reader hands out the same codes+meta form for an m2xfp4
encoding, so the oracle and fixtures can build the operand. quant_m2xfp_test runs the row over the
quantiser's planes; OPS.md gains the operand.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
M2XFP (arXiv 2601.19213) keeps OCP MXFP4's codes and E8M0 exponent and adds one metadata byte a
group of 32: four 2-bit extra mantissas, each refining the shared scale of a subgroup of 8 to
(1 + k/4) . 2^E. The quantiser searches each subgroup's k and the exponent's bias by least squared
error (the paper's Sg-EM), stores codes, scale and meta as three planes of scheme "m2xfp4" and
supplies the decode hook the core needs for a scheme it cannot follow. spec.md gains the
encoding and quantiser rows; quant_m2xfp_test covers the planes, determinism and quality.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rounded to nearest, the 31B's w4a8 trunk leaves streamed tool calls inside their string arguments:
after `sku:<|"|>MS-110` it prefers `**,` (58%) to the string's close (41%; bf16 ~1.0), and
BetterBench's order request stalled in 10 of 20 tries. This adds what it takes to make the same
container (same grid, kernels and size) with the trunk's int4 codes chosen by GPTQ against the bf16
model's own activations.
- arch/gemma4: with RADIANCE_CALIB_DIR set, the plugin serving the 31B's bf16 checkpoint sums the
Gram of every dense linear's bf16 input over the corpus a server is fed (gram_accum into a
PERSIST [K, K] f32 buffer a tap) and writes the files at RADIANCE_CALIB_TOKENS, as arch/gemma3's
tap does: q|k|v's and gate|up's input whole from rank 0, o_proj's and down's this rank's columns
as `<stem>.part`, which libquant places on the diagonal. The files carry the names the w4a8
container gives the weights (gemma4_bf16's attn_qkv, attn_o, ffn_gate_up, ffn_down), so a GPTQ
recipe converting that container reads them with calib=DIR. RADIANCE_G4_CALIB_LAYERS=lo:hi records
a slice of layers (the 31B's taps are ~364 MiB a layer a rank at --tp 4, and 60 layers of them do
not fit beside the bf16 weights). Under the tap a step runs whole and on one lane; without
RADIANCE_CALIB_DIR nothing changes.
- data/recipes/gemma4-31b-dense-bf16-w4a8g-df2.recipe: the -df2 recipe with `gptq codes=i4
group=128 scale=f16 rule=search calib=$CALIB` on the trunk's four linears.
- docs/GEMMA4-31B-GPTQ.md: the route, the corpus, how to run it, and the measurements.
Measured (1.11.0, the same tap and recipe): by GPTQ the close is 99.8% and no try stalls; KL against
bf16 on the model's own turns falls from 0.341 to 0.251 (the w8a8 container 0.226), at the same
speed. The convert takes 75 minutes with OpenBLAS in the image (#220; an estimated days without). A
container made this way is on Hugging Face as Ashlyn4202025/gemma4-31b-w4a8-gptq-dflash2, and with
the block-16 drafter as Ashlyn4202025/gemma4-31b-w4a8-gptq-dflash2-b16.
Tests: engine_e2e takes the tiny Gemma 4 (shaped like the 31B) through the whole route at --tp 2:
the tap's files, by name and width on each rank; rad-convert with the two shipped recipes, every
trunk linear fitted and none rounded to nearest; and the GPTQ container's KL against the bf16 model
on held-out documents more than three times below the round-to-nearest one's (0.0018 against
0.0105). With rank 0's and rank 1's .part blocks swapped the margin is 2.2 times, which fails.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On Gemma 4 (sliding layers the prefix cache does not index, no linear state) a hit resumes the
trunk's window from a window snapshot. The check for a hole in a block drafter's own KV after a
hit counted every paged group the prefix cache does not index, the trunk's windowed one included,
so it found a hole the snapshot fills. z-lab's DFlash drafter keeps a full-attention cache, which
the prefix cache indexes; with that false hole its floor sat at the hit, and with no window to
slide it was declined for the rest of every turn after a hit (on the 31B: 1.00 tokens a step on
those turns, 4.25 with this). The scheduler now counts a group the snapshot restores
(IKVManager::window_snapshot, the KV manager's KVGroupPlan::win_snap) as no hole, and the startup
line says how many: `draft floor: 3 paged group(s), 2 prefix-cached, 1 in the window snapshot -> a
hit leaves no hole`. A drafter's own windowed group is not in the snapshot, so DFlash2 and every
model with linear state are unchanged.
Tests: sched_test (a full-attention drafter drafts at once after a hit the window snapshot resumes,
and with the trunk's window counted as a hole never drafts again that turn; the fixture gains a
full-attention trunk).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A step that mixes decoding sequences with a prefill chunk issued the dense attention once, at band
max_q_len, so the decode rows ran through the prefill kernel: one workgroup per KV head walking the
decoder's whole context. With a decoder at 188k beside a 2048-row chunk that tail set the step time.
In a MIXED step the attention is now issued twice:
- the decode half at the decode band (served by the split-KV decode row); at most max_seqs - 1
sequences of at most the decode band's rows, which its declared scratch covers;
- the prefill half always at the op's top band, which selects the query-tiled prefill row built for
launches over part of a step (absolute cu from entry D, as the GDN block issues its prefill half and
as ArPieces issues its pieces); the kernels read exact lengths from cu. At its own query length a
chunk of 10 rows or fewer would select the decode row, which sizes its partials from the whole
step's rows and has no cu span.
A chunk no longer than the verify blocks beside it keeps the single launch (the step is decode-
shaped). Pure decode and pure prefill steps issue exactly as before (graph pins unchanged; only the
pinned steps that contain a mixed step move).
RADIANCE_ATTN_BAND_SPLIT=0 restores the single issue.
Measured on 2x Radeon AI PRO R9700, Qwen3.8-27B MXFP4, TP 2: one sequence decoding after a 188k
prompt while a fresh 25k prompt arrives (2 rounds each):
- mixed step 510 / 508 ms -> 211 / 211 ms
- the new prompt's prefill 11.3 / 11.3 s -> 5.0 / 5.0 s (the same as beside a 0.7k decoder)
- the decoder's rate over the window 85 / 82 -> 109 / 103 tok/s
30 minutes of mixed serving load (12 decoding streams with speculation, fresh 25k / 41k prompts,
cached re-sends that prefill a few-row suffix, TranslateGemma beside): 0 errors, 0 restarts.
Tests: arch_test qwen35_fp8_issues_a_mixed_steps_attention_once_per_band (both halves' operands, the
prefill half at the top band for a short chunk, the single launch when the chunk is not longer than
the verify blocks, one issue per layer for pure steps); r4d_selftest attn_mixed_step (production
per-rank geometry, scratch bound exactly as the engine binds it per band, 15 decode sequences of 8-10
rows beside chunks of 1 to 640 rows).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The prefill attention kernel gives each workgroup 64 query rows of one KV head and walks the whole
causal context serially. A launch with few query rows therefore has few workgroups: the tail chunk
of a prompt (53 rows) or a follow-up turn of a few hundred tokens runs 2-10 workgroups on 32 WGPs,
each walking up to 188k keys (17.7 ms per layer at 188k).
When kv_heads * qtiles * seqs is below the WGP count, the launch now splits the KV range into S
segments (blockIdx.x = qtile * S + segment), writes unnormalised f32 partials (O, m, l) in the
decode partial layout and merges them with the existing split-KV combine. S is the smaller of one or
two rounds of workgroups, capped by the context's tiles and the declared scratch. A segment past a
workgroup's causal end still writes an empty partial; the merge reads every segment it counts.
The merges take a SPAN parameter so a launch over part of a step (pipelined pieces) only rewrites its
own rows; the decode instances are unchanged (identical ISA).
R4D_PREFILL_SPLITS: unset/0 = the law, 1 = off, N = force N (debug/tuning).
Measured on 2x Radeon AI PRO R9700, Qwen3.8-27B MXFP4, TP 2, k6_v4 KV:
- r4d_selftest --perfpaged, off -> on: 53 rows over 40k 3.71 -> 0.47 ms, 80 rows 3.64 -> 0.68 ms,
345 rows 3.80 -> 1.79 ms, 1024 rows 4.29 -> 4.29 ms (no split).
- Engine, 188k prompt, time to first token: 62.78 -> 62.54 s (the tail chunk).
- KLD vs the bf16 reference: chunk 64 0.040384 -> 0.040337, chunk 2048 0.040237 -> 0.040220;
top-1 agreement 93.985 -> 93.998 %. Split vs unsplit outputs differ by at most 1 bf16 ulp.
- With R4D_PREFILL_SPLITS=1 the engine is bit-identical to before (top-5 logprobs, 100 positions).
Tests: attn_split_case / attn_split_scratch_case for k6_v4, fp8_v4, fp8 and bf16 KV (q 1-345 over
8k-20k keys, empty segments, ragged batches, pipelined pieces), scratch poisoned; 410/410 ok.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The history pass has a row for every position a verify could commit; rows past the last
committed one repeat it, and the run's last row is draft round 1's input. The card gave that pass
the run's whole length as its context. Attention places row j of a q_len-row run at
seqused - q_len + j and reads keys up to there, so after a verify that accepted acc < n_spec
drafts, round 1 also read the n_spec - acc positions after its own: slots the head's layer had
not written for this sequence (last step's speculative rounds, or whatever the block held before
it was handed out). Its proposal then followed those bytes. Positions 2 and on were right: each
round is one row whose context ends at its own position.
This fits #221 (Qwen3.8-Flash-Next, position-1 acceptance 0.01-0.16 after a
few short conversations sit in the prefix cache, healthy with --no-prefix-cache, after a restart
and on long conversations): with the default lending cache the pool hands out blocks it lent the
expert slab once cached blocks pass the live mark, and their unwritten slots hold expert bytes;
above 2051 tokens the head's QSA path bounds each query by its own position. On the reporter's
model (TP2, their flags, 32 distinct short chats on a fresh engine) 1.12.0 falls to p1 0.352 from
request 9; with this change p1 is 0.953, as with --no-prefix-cache (0.955), replies identical.
The context now ends at the last committed position. Earlier rows of the pass count lower than
their positions, but nothing reads their output (the head goes on with draft_out_ids only), and
every row's K and V still store at its own position's slot.
Tests: advance_test (no row of a history pass or a round counts past its own position, and the
run's last row sits exactly at it, for every acceptance and lead; fails before: the last row at
204 for a head at 201; and right after a 1-2 token prompt, where the rows nothing reads count
before the sequence's start, every row still stores at its own position and the last sits at
the committed one); ref_test (rows of a paged-attention run that sit before the context's start
return zeros, not NaN, and the rows after them stay exact).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since 1.11.0 a block drafter's context and query passes (DFlash, DFlash2), like a serial drafter's
rounds (MTP), are queued behind the step before its readback, and the host waited for all of them
before it read the sampled ids. The ids' copy was already issued ahead of the passes, but the
commit that streams the tokens came only after the passes had run: every token, the first one
included, reached the client a drafter's passes late.
The copy now has an event of its own (tok_end_). collect_step waits on it, the commit streams the
tokens while the card runs the passes, and the step loop waits for the step's end (step_end_)
right after the commit, before finish_*_drafter reads the slots and before anything else is
issued. The commit issues no device work, so whatever it releases is in use only by the passes
that wait covers, and the next work that could reuse it is issued after the wait. KL mode and
embedding programs keep the old wait; RADIANCE_IDS_EARLY=0 restores it, for an A/B.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pipelined engine issues each step's successor before the step is read back: block drafters
(DFlash, DFlash2) since 1.11.0, serial MTP and decoding without a drafter since 1.0.0. The step that
emits a request's last token therefore had one more step queued behind it, for a request its commit
then finishes. That step verifies nothing, yet the card runs its whole forward pass and the
drafter's context pass behind it, and a request that arrives once the last token is out -- a
single-stream client's next turn, sent as the reply ends -- waits for all of it before its prefill
starts. On Qwen3.8-27B ParoQuant int5 with DFlash2 on one R9700 that is about one decode step (34-53
ms) of TTFT on every back-to-back request (#225: 105 -> 139 ms); for 127 requests 1.12.0 ran 806
decode steps, all issued ahead, against 1.8.1's 680.
Scheduler::step_next_locked, beside the other rules for issuing ahead and before the next step's KV
is reserved, now issues nothing when the step just issued ends every request it carries: when it can
bring each to its max_tokens (certainly with the token it emits, possibly with the drafts it
verifies: output + 1 + drafts >= max_tokens), or, most likely, when those drafts hold an
end-of-generation id (ignore_eos requests excepted). The engine hands the scheduler the
end-of-generation ids at start (set_eog), the sorted list the card's acceptance reads. A guess that
misses (a drafted end the verify rejects, too few drafts accepted to reach max_tokens) costs one
step built after the commit instead of before it. Ends it does not predict still leave one step
behind: an end the verify chose itself, a stop string, the context limit. Without a drafter only
max_tokens ends are caught, exactly. At -v the commit names each request that ended with a step
issued ahead behind it (finish reason, its last step's tokens and accepted drafts, output against
max_tokens, whether its drafts held an end).
Tests: sched_test pins both halves (a drafted end issues and reserves nothing; a request whose next
token is its last, or whose token and accepted drafts could reach max_tokens, issues nothing; an
ignore_eos request's drafted end, drafts without an end, and a request that every draft accepted
would leave a token short still issue ahead; of two requests one going on, both issue ahead); the
test of a request finishing under a step issued ahead now ends it on an end of text the scheduler
cannot see coming. engine_e2e_test: two 32-token replies without a drafter are 62 decode steps, all
issued ahead, not 64.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since #239 the E4B form runs at two ranks. The three compose files now
use --tp 2 and name the audio encoder; the one-card profiles move to
nemotron-3.5-bolt-e4b-{bf16,i8g,a4}-tp1.yaml.
Declared after the vision tower when the container carries it. Audio rows
take the media scatter before the embedding all-reduce, and the per-layer
inputs of their positions use the pad row, as image rows do. The probe states
30 s of frames.
Gemma 4 E2B/E4B keep their feature extractor settings there, not in a
preprocessor_config.json. AudioConfig reads preprocessor.* first, as before,
then processor.feature_extractor.*.
The USM conformer moves out of embgemma2 unchanged, with the checkpoint
prefix and the plugin name as parameters, so a Gemma 4 conditional-generation
checkpoint (model.audio_tower) can declare it too. The feature size comes
from preprocessor_config.json or, failing that, from processor_config.json's
feature_extractor. embgemma2 declares the same graph (arch_test pins).
With fewer KV heads than ranks, each rank keeps one head and reads the
rows of k and v of that head (as one span, or the k and v parts of a fused
q|k|v, with the scale plane alongside); q stays an even share. Both classes,
as geom_from already counts it for the sliding class. The attention
junction keeps every row where the per-layer branch follows. Gemma 4 E4B
(two KV heads) then runs at four ranks.
As #197 did for gemm_mxfp4a8_tiled (a85f87e): the weight words a thread stages (the nibbles, the
fifth bits, the zero word) are loaded into registers a slab ahead, right after the staging
barrier, so their DRAM round trip runs under the slab's WMMAs instead of in front of the next
unpack. The slab's weight scales are loaded after the WMMAs, just before the fold: held from the
top of the slab next to the words they need 248/251 VGPRs (int4/int5), 5 waves a SIMD instead of
6, and the kernel ran 4-8 % slower than before; loaded late it is 224/227 VGPRs (was 235/237),
no spills. Same fold, same WMMA order: bit for bit.
r4d_selftest --perfwpa (new: warmed min/median and an FNV hash of the output), one R9700 at
230 W, M = 1024, old and new interleaved, 12 rounds, median: int5 gate_up 34816x5120 2769 ->
2572 us, down 5120x17408 1394 -> 1310, delta-net qkv|z 1297 -> 1219, ssm_out 461 -> 430,
q|gate 937 -> 889 (int4 -6..-9 %). Hashes equal the old kernel's on ten shapes at 1024 and 2048
rows. End to end, Qwen3.8-27B PARO int5 at tp 1 with 1024-token chunks (BetterBench, old / new /
old): 23.5k-token prompt 2096 / 2151 / 2085 tok/s, 47k 1934 / 1979 / 1927.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A request is listed in the Requests card only while it exists. The engine
drops it from /stats within roughly 20 ms of its last token on a one-token
reply, and within half a second on a long one, so the per-request figures an
operator actually compares runs on -- average tok/s, time to first token,
context at finish -- are gone before a reader who looked away gets back to
them.
The card now keeps the last 200 completed requests, per browser, in
localStorage, under the live table: prompt, completion and context tokens,
ttft, prefill throughput derived from the uncached prompt and the time to
first token, decode throughput, and age, plus the averages of those rates and
the median time to first token.
Capture is by sighting. A request is recorded the moment a poll catches its
state as done, or, since the engine usually drops it before that happens,
from its last sighting once it leaves the payload. What began and ended
between two polls was never seen, so it is counted in a grey row rather than
invented. The poll runs at 100 ms while something is in flight and 500 ms
when idle; the idle rate is what the page had before, and the faster rate is
what makes capture work at all.
Ids are the history's own, not the engine's. The engine renumbers 1..N and
restarts at 1, so each row carries a unique storage key (engine id plus a
running offset persisted across restarts) and a separate history id shown in
the # column: it starts at 0, and clear writes that counter back to 0, so a
cleared table begins again at #0. Rows are shared by every dashboard tab: a
save unions with what is stored, deduplicates by key, and a clear is a
timestamp every tab honours. clear and json sit in the section header.
The card is 459 px -- one and a half times the stock 306 -- to give the
history rows; the live table stays fixed at the top and only the history
scrolls, under a column header that stays pinned. On a phone the history list
chains its scroll to the document, as the request table already did.
The stamps are one line a dispatch; what they are taken for is a pass's idle time and the gaps a
barrier leaves, which need the union over the queues and the kinds of pass told apart. Standard
library only, beside cardclock.py and statsdump.py.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every dispatch of one recorded pass in N on card 0 gets a completion signal of its own, into which
the packet processor writes its start and end. The barrier bit and the chain are decided as
without the signal, so the queues run the pass as unstamped; --profile-ops, the instrument so
far, plays no recorded pass and puts two barriers around every op. A pass is the plays of a tape
from its record 0, since a pass is played in stretches between host ops. A dispatch a record or a
ride rides on is stamped from that signal, held out of the pool until its times are read.
Nothing waits: a later play reads the signals that reached 0 and appends one CSV line a dispatch
(pass, record, queue, kernel, ordered, chained, start and end in ns, play, tape length) to
RADIANCE_AQL_STAMP_OUT. Unset, nothing changes.
The engine never hands a kernel the issued value of a ranged parameter: the oracle
binds it to the matched band's bound, and ref_common.h's band_rows spells the rule
out -- the parameter stays a ceiling where one is stated -- which is why every
existing kernel derives its counts from its operands. vtile_plan/crop/join were the
first to read M as the row count of the call, so the first real tiled encode refused
on device: a 512 keyframe's 3 x 3 plan, issued under the band bound 33, tripped the
wrapper's rows-of-y < M clause, which answered RAD_E_STRIDE -- and the strerror
insisted, wrongly, that a non-contiguous operand was the problem. Crop and join
carried the same latent bug: crop would have launched 33 blocks over a ~590k-row
cut, and both would have refused every canvas under their bands' real bounds.
All three tiers now count from the operands and treat the passed M as the ceiling it
is -- y longer than the ceiling is refused, equality never demanded. The reference
and host tiers take the count from geom through band_rows; the device wrappers take
it from y's rows and pass that count in the kernel's M slot, which the kernels' own
operand-row guards make safe. OPS.md says the rule once at the head of the tiled
encoder section: an M written in a shape is an operand's row count, the ranged M
argument a ceiling only.
The host gates missed the bug precisely because they drove an exact M. ref_test's
three vtile cases now pass the band's bound -- 33, 33 * 256 * 256, 320 * 320 -- and
demand the same exact output, plus short-operand cases that must refuse E_SHAPE
under the over-declared ceiling; r4d_selftest drives the same bounds on device.
Verified: ref_test 264 cases, device vtile plan 4 / crop 8 / join 5 / gather 2 /
stitch 8 all exact, full ctest 123/123; and the FL2VA render that used to die in
tiled encode now runs its 25 steps with both keyframes visible in the decoded clip.
Co-Authored-By: Claude <noreply@anthropic.com>
8a6a118 gave the rms_mod family an optional trailing colmap -- sequences that share
one modulation cell read the shift/scale (and gate) table through that cell's COLUMN,
so the prompt's vision-pad runs share the video cell's row across non-contiguous
boundaries. It taught the device kernel and libref's implementation to follow the map,
but the operand itself reached only the driver's issue: none of the three operand
tables listed it. The schema is what the loader and the engine check against, and all
three declaring libs must agree, so the battery's first serve died at step 1 --
`rms_mod_quant_i8 ... issued with 10 operands; the op's schema declares 9`.
All three tables now list `colmap` as the trailing optional operand of rms_mod and
both quant producers (past every other arch's last operand), and libref's shape
describers answer an explicit skip for it -- the sweep passes no map. libavx's
rms_mod_run was missing the feature outright: it now reads the tables through the
map's column and drops the `s` and `g` row-count checks when a map is bound -- the
table is sized by columns, not by sequences -- while the map's own bound stays the
issuer's. OPS.md's rows and prose regenerated against the dumped schemas.
Verified: ref_test full suite (the rms_mod sweeps run mapless through the new skip),
rad-avx-check on the plain and quant rows, the device rms_mod and rms_mod_quant_fp8
cases, ops_doc, and full ctest 123/123; on device a serve that died at step 1 now
boots and renders the keyframe tasks end to end.
Co-Authored-By: Claude <noreply@anthropic.com>
vae.py's tiled_encode cuts a picture bigger than tile_size (256 px, 16
latents) into overlapping tiles, encodes each tile alone, and blends every
tile's RAW moments with its raw top and left neighbours -- top first, then
left, never an already-blended neighbour -- into the whole latent canvas.
GroupNorm normalises inside the volume it sees, so the tile seams are
observable: our port ran the whole canvas through the trunk at once, and a
photo or keyframe over 256 px a side drifted from the reference's look.
Three ops, libref/avx/r4d alike. vtile_plan lays each tile's geometry rows
the way vae.py splits -- round-robin slack, and one short tile on an axis
no longer than a tile. vtile_crop cuts the picture's pixels tile-major.
vtile_join blends the tile-major moments into the plain pass's b_eq2 with
vae.py's weights, every product and sum rounding through x's dtype. The
split carries one structural gift: with the slack fully distributed,
start[last] = len - tile, so every band is exactly a tile, and a short
band exists only in the single-band branch -- whose axis has no neighbour
to blend against. The join can therefore fetch the left neighbour always
at the full tile width while own and top fetch at the owner's own column
width, and vae.py's min() clamp inside blend is provably dead code.
step_venc_tiled runs the plain trunk once a tile: pixels from b_vtile,
moments out to one slice of b_eqt, the tile's six level geometries read
back off b_tplan (PERSIST) through raw pointers, exactly as every clip's
geometries come off enc_geom_d. The arena packs by declared lifetime, so
op_ve_q moved ahead of the trunk and the tiled ops sit last: b_vtile must
span op_ve_pix's first read to op_vt_crop at the tail and b_eqt must span
op_ve_q to op_vt_join, bracketing every trunk op the tiled pass re-runs.
b_vtile and b_eqt size tile-major at the declared tile cap; a picture
splitting past the cap step-fails by name. Clips never tile -- their
volume forces each side back to kEncMaxSide. OPS.md documents all three.
Verified: ref_test 264 cases (plan pins the round-robin overlaps {6,5,5}
and a short lone row with column neighbours; crop walks a short band at
ratio 4; join checks a 6x9 canvas with uneven round-robin splits point by
point, and a 32x32 eighths-exact f32 blend that must land bit-identical);
rad-avx-check scalar/avx/avx2 on all three ops; device r4d_selftest plan
4 / crop 8 (f32+bf16) / join 5 cases ok. Full ctest 123/123. ABI
unchanged at 28.
Co-Authored-By: Claude <noreply@anthropic.com>
The reference's _cond_video_rows runs every visual conditioning latent through
x = aug x + (1 - aug) z at VISUAL_COND_TIMESTEP 0.999, its generator restarted
per item, while audio conditioning is untouched (its aug is 1.0, a no-op). We
staged the clean latent instead, so every image-, keyframe- and reference-
conditioned render started from un-augmented conditioning.
New op cond_aug: x = f32(f32(a x) + f32(oma z)), a the aug parameter and oma
the f32 of the double 1 - aug -- the reference subtracts in double and rounds
once -- with z the (seed, stream) normal stream at element k n + c on stream
2, the reference's noise never sharing the generator that fills x. Seed words
0-1 of the video's seed, per-item restart by per-row offset. Issued once at
the end of step_venc over the conditioning rows: staging once at encode-build
time is equivalent to the reference's per-call restart because each item's
rows are exactly its own, and the driver's build_encode now re-stages the
seed, where a stale lane's words used to ride through.
Reference RNG is MT19937 and ours Philox, so the noise is distributionally
faithful, not bit-exact. ABI unchanged at 28. Device: r4d_selftest 0 failures,
cond_aug rows 1.13e-9/4.42e-8 rel_l2 against libref.
Co-Authored-By: Claude <noreply@anthropic.com>
The merge took libref's older conv1d_f32 case list over the PIN commit's:
five stride-2/4/8 success cases came back on top of the entry that refuses
them. The contract is the PIN's — the strided form lives on the bf16 rows
(the DAC encoder it serves runs there) and the f32 vocoder is stride 1, so
r4d_rad_conv1d_f32 refuses a stride or an explicit pad as a dtype choice,
and the refusal cases (even k, stride without pad, two sequences, f32)
stand. The perf path never noticed: it sends strided upsampling to
conv_t1d_f32, which owns that form at f32.
Device-verified: all eight surviving conv1d_f32 cases ok filtered
(rel_l2 <= 1.6e-6 against the bound of 2e-5).
Co-Authored-By: Claude <noreply@anthropic.com>
A stage copy is handed to the DMA queue and normally waited for by the next
kvstage_wait or consumed by kvstage_next. A staged pass can end with a list
still in flight. The transition back to the ring then clears the residency
maps, and the first ring pass refills layer 0 from the host mirror; a list that
lands after that refill leaves res calling another layer's bytes resident --
the same silent wrong output the clear exists to prevent, now sticky for layer
0 until the next prefill.
Wait the list out before the memsets. Normally nothing is in flight. Also
correct the comment on the slots < blocks guard: it is the invariant that a
stage exists (bringup gives a stream whose ring covers its context no mirror,
no resolve and no stage), not an identity claim -- a stage row is per layer and
always starts at offset 0.
Measured after the change, exact compose flags, ring 32768, spec 0 and 3:
four rounds of seed -> arithmetic -> passcode -> colors -> json each, 15:55 on
every round and the 3k passphrase on every turn.
The reference modulates by a per-token TAG: token_tags_from_embeds_info tags
every image embed span (with one flanking token on each side) 0 -- video --
inside the prompt, while audio pads keep tag 1 (parallel PR #236, point 3).
Our port modulated the whole prompt span as text, so every reference photo's
pad tokens read the text ada projection where the reference reads the video
one. The tags arrive in the prompt itself and nothing else carries them, so
the denoiser could not know, and the look drifted with the reference count.
The driver now writes each image item's token span into a tail of ref_tab --
one count, then {start, length} per run, audio items excluded (the reference
tags images only). The tail rides inert through the pack and ref_parts, and
is present exactly when the reference table is, so an i2va request keeps its
old bytes. ref2va_mod_groups grows a runs argument: it cuts the prompt at the
runs' edges and gives the pad pieces the VIDEO cell -- the video projection
on the video-schedule block; the prompt's own timestep row never changes,
only the projection.
Cells stay few however many photos interleave, but groups no longer equal
cells: two prompt pieces separated by a pad share one cell non-adjacently.
So the merged-group output gains a per-group column map, and the modulated-
norm kernels -- libr4d and libref alike -- accept an optional trailing
colmap (slot 9 quant, 7 bf16, past every other arch's last operand) that
redirects sequence -> table column, relaxing the row-count checks it binds.
rad_arch_video_mod_segs exports boundaries then map, the plugin stages both
only for a reference request -- the plain path still stages boundaries alone,
byte-identical -- and the half-split keeps its single video row by taking
the target's column instead of the last one. max_ref_segs now bounds the
DISTINCT CELLS, its old meaning was the group count. ABI 28; no struct's
shape moved, the layout table is re-stamped.
Co-Authored-By: Claude <noreply@anthropic.com>