New models and formats:
- libr3d: a kernel library for RDNA3 (gfx11) cards
- nomic-embed-text-v2-moe (the nomicbert plugin)
- Gemma 4 E2B with its per-layer MLP width, and Google's unmodified E2B/E4B directories in bf16
- DeepSeek-V4.1-Flash converted straight from its release: the Engram tables, the fused imatrix and
rad-convert --chat-template for a release that ships no template
- GGUF Q8_0, Q4_K and Q6_K tensors import as their planes; rad-convert writes them without a recipe
- Qwen3.8-Flash-Next-FP8 converts and serves through qwen4exp_fp8
Speed:
- hc_read's decode kernels as one grid (34.7 -> 25.2 us at 4 rows) and its tiled up-mix pipelined
- gemm_fp8a8: the narrow form's scales staged through LDS (Flash-Next int8 at 32 rows 83.6 -> 68.3
us), the gated three-tile form at 8 waves (gate_up at 48 rows 272.9 -> 180.6 us)
- Qwen3.8-27B: the delta net's out-projection read beside its decode recurrent update (x1 19.40 ->
19.10 ms a step), and the verify's split-KV attention sized by context depth (x3 at 180K 42.4 ->
40.3 ms a step)
- Hy-Memory (HYV3) decode: fused QK norm, RoPE and KV store, residual adds folded into the norms,
coalesced one-token expert GEMMs
- spechub: the coupled verify walks the live candidates only (151 -> 31 us a launch)
Speculation:
- DFlash2: lossless coupled acceptance at T > 0 (--draft-coupling on)
- A block drafter's proposals verified as a tree, on by default for the Gemma 4 31B's DFlash2, with
a block-16 tree that runs its short block under load
Features:
- Decode-hot residency: --draft-expert-placement host, --expert-profile, --expert-pin-top, and
--expert-stats FILE for the routed experts each layer selects
- --ngram-placement ram=DIR: one n-gram table shared by engines on separate cards
- Prefix cache: --prefix-resume exact (default) resumes a hit on the cold run's own chunk grid, so it
answers bit-identically; snapshots at a head other prompts share, from 528-token prompts, and for
tip-only one drafter window below the tip; hits on models whose KV groups have different block
sizes; the snapshot store keeps a floor of 8 ahead of --host-headroom-mib
- Typed tool-call argument tags; rad-chatparse --request renders and reads back one request as the
server does
- MiniMax-H3: keyframes ride a latent upscale
- Gemma 3's fused all-reduce junction on the lossy wire
Fixes:
- A speculative step shorter than its band (an MTP step of 4 rows at gqa 8) no longer stops the
engine with a scratch refusal at issue (#293)
- --p2p off: prefill back to 1.12.0's rate; 1.13.0's push check read a host-memory slot over the link
twice (#323)
- A chat template that cannot render a conversation is refused at load, not mid-request
- imatrix entries found under llama.cpp's spelling; the W4A8 prefill's tail scale read; the GDN conv
kernels on an f32 weight; dense integer rows at the group they compute (a Q8_0 weight at group 32)
- --expert-profile refuses a profile recorded on another model
- hc_read's one-grid wait traps past its deadline instead of reading a stale value
Changes: Plugin ABI 31, unchanged. RADIANCE_DRAFT_TREE, DFLASH2_TREE_NODES, DFLASH2_TREE_TEMP and
DFLASH_Q_TEMP are gone (trees run where the probe says they pay; temperatures 1.25 / 0.6).
--host-headroom-mib is a courtesy to the system: the process's unpooled allocations, the
load's staging windows, the page cache. A linear-state snapshot store is not a courtesy.
A store too small for one snapshot does not serve a smaller store -- it serves none, and
every prefix hit re-prefills the whole conversation, while /metrics still counts the
attention blocks as a hit and the request log's "(cache 0)" is the only honest number.
--checkpoint-slots auto already promises a floor of kCheckpointSlotsFloor slots, but the
floor was only checked against what the host had left once the host pool, the streaming
mirror and the reserve had taken theirs. On a host where those fit exactly, the store
resolved to 0.
Charge the floor before the reserve: when the reserve is what stands between the host's
spare memory and the store's floor, it gives back exactly the shortfall -- whole MiB,
rounded up so the store is never a byte short, never below kHostReserveFloor (1 GiB) and
never above the margin the user asked for. A host that can pin the floor gets it; a host
that cannot still reports the shortfall, now naming --host-headroom-mib among the levers.
The boot guard a few lines below the sizing takes the same margin, or a count auto had
just fitted by giving the reserve back would be refused a moment later.
The rule is bytes over the host's own measurements: checkpoint_slots_want for the count,
MemAvailable, the memory cgroups and the driver's pin cap for the room. It needs no case
per model or per KV encoding -- a wider slot (more linear or windowed layers), a wider
streaming mirror (bf16 rather than fp8) and a larger --tp arrive as different numbers,
not as different rules.
Measured on 2x RX 9070 (16 GB), Qwen3.8-Flash-Next at --tp 2, bf16 KV, 2x262144,
--host-pool-mib 23652: 8 snapshots of 112.73 MiB, the reserve giving back 685 MiB and
holding 3.33 GiB (before: 0 snapshots, every turn re-prefilling 125-134k tokens at
ttft ~31 s with "(cache 0)"). The same 6398-token prompt twice: ttft 1.66 s -> 0.65 s,
cached 0 -> 5120, linear_checkpoints_written_total 0 -> 1.
Tests: the rule itself (fits -> untouched, short -> exactly the shortfall, beyond it ->
the 1 GiB floor, a smaller flag -> never exceeded) and checkpoint_slots_want against the
counts auto already reports.
At decode heights the recurrent update runs one workgroup per (sequence, head) and leaves the
card's memory mostly idle. Each delta-net layer now reads its out-projection (the whole weight,
7.9 MB a rank in MXFP4) into the on-die cache there, on the second lane behind a join from lane 0,
as prefetch_beside does beside the all-reduces. Up to four decode sequences and 32 rows; no read on
a step that carries a prompt's rows, at one rank, or where the deployment turns weight prefetch
off (RadBuildCtx::weight_prefetch_off: nothing is declared).
Qwen3.8-27B MXFP4 + DFlash2 at tp 2 on 2x R9700, production flags, 1k context, hwgrid ms/step,
median of five interleaved rounds, none -> whole projection:
x1 19.40 -> 19.10 (-1.5 %), x2 20.93 -> 20.78 (-0.7 %), x4 24.26 -> 24.17 (-0.4 %),
every round faster at each of the three;
x8 25.22 -> 25.48 (+1.0 %, four rounds of five slower) -- hence the four-sequence ceiling;
x16 (64 rows, no read) and 90k x4 unchanged. 4 MB reads as the whole.
Against this main (one round): x1 19.40 -> 19.15, other cells within noise.
Greedy output identical to the build without the read (300/300 tokens on two prompts, |dlogprob| 0).
arch_test: qwen35_fp8_reads_the_delta_net_out_projection_beside_its_decode_update; the qwen35_fp8
step pins move (prg_pins.py).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The full-attention decode law gives a three-wave workgroup (q_len * gqa > 32,
an 8-row DFlash2 verify at gqa 6) 128 / units segments whatever the depth.
Three to seven sequences of Qwen3.8-27B (two KV heads a rank) then get 21..9
segments, each walking 4-18k tokens at depth, and one or two sequences stay
at 64 / 32 where 256 / 128 are faster.
The law now reads the step's depth from the block table's width (max_blocks *
block_size, capped at max_ctx; the scheduler rounds the width to the batch's
longest sequence): up to 16k tokens 128 / units as before, past 16k at least
64, past 64k 512 / units capped at 256. Declare passes no table, so the
scratch is still sized at the declared bound, the deepest the law can be
asked for; the law grows with depth, so an issue never needs more.
Qwen3.8-27B MXFP4 + DFlash2 at TP2 on 2x R9700, k6_v4, speculation 7, ms a
decode step against this main:
x1 90k 22.07 -> 22.03 180k 25.35 -> 24.88
x2 90k 26.83 -> 26.36 180k 33.18 -> 31.99
x3 180k 42.41 -> 40.33
x4 90k 36.20 -> 34.96
Steps whose count does not change (1k x1..x8, the short block at 16k x16) are
within noise. Greedy output is identical (300 tokens, two prompts). The forced
segment sweeps behind the thresholds are in the comment.
r4d_selftest: decode_split_law_case reads the law through the decode scratch
hook's declare path, 21 batches across the depth thresholds.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
hc_role_wait, where hc_read_fused_kernel's B blocks wait for every A block, gave up after half a
second and went on, so a counter fault would have read a stale `d` and its scales and written
wrong values with no error. The all-reduce handshakes trap on the same condition (r4d_ar_seq.h,
r4d_ar_oneshot_2rank_exact.hip: a handshake that cannot complete is a lockstep violation); this
does the same. It cannot fire with the counters in order (each launch's last B block clears
them), so nothing that runs today changes.
libr4d/isa/res.sh: no hc kernel spills, hc_read_fused_kernel 126-147 VGPRs.
r4d_selftest --case hc_read_e4m3 and hc_read_bf16 on 890715f: 67 ok, 0 FAIL, the 24 byte-for-byte
comparisons against the previous decode kernels among them. --perfhc 4: 25.4 us a call (the
previous decode kernels 34.6), as before the change.
RDNA3's ISA lists exactly six wave-matrix instructions (f16, bf16, int8 and
int4 in; f32, f16, bf16 and i32 accumulating) and the toolchain emits them on
every gfx11 target; they run over multiple cycles driving the DOT pipeline
internally, and the MAC-core measurement on the 16-CU gfx1102 part confirms
it: f32-acc f16 19.11, f32-acc bf16 19.24, f16-acc f16 19.44, i32-acc i8
19.29 against the paired dot2 path's 18.86 TFLOP/s -- the same pipe within
three percent, matching the full-kernel 1.99-vs-1.97 already in r3d_common.h.
The i32-acc i4 tile is the exception at 25.68 TFLOP/s, 35% above, but it takes
i4 in both operands and the grids served here pair i8 activations against i4
and i2 weights: there is no mixed-precision integer WMMA on RDNA3, so that
pipe is unreachable from the w4a8 and w2a8 rows.
Commentary only -- the rationale passages in the README, CMakeLists.txt,
r3d_rows.cpp, r3d_plugin.h and r3d_selftest.cpp now state the measured
record; no kernel, lane map or numeric path changes, and the rebuilt library
is byte-identical (selftest 78 rows, 0 failed, 0 skipped).
A complete row set for the gfx11 family (1100/1101/1102/1103/1150/1151 plus gfx11-generic),
mirroring libr4d's structure: the quantised GEMM rows (m16, tiled, gated, the bf16 logits
gemm), the paged and ragged attention for decode and prefill, the KV store, the sampler
spine and the spec rows, with the recorded-fixture, board, selftest and comparison-driver
gates for each.
The gates are the record. Every row is measured against libref on the shape matrix: the
recorded fixture at 1153 cases with worst rel_l2 1.362e-03, the board's five modes with
bit-identical decision lines, the selftest at 74 rows, and the 233-case served-shape pairing
at 0 divergent against the tree libref. End-to-end on a 2B fp8 checkpoint served on the
card, coherent through prefix-cache adoption.
Two platform laws each shape the design. A kernel that calls device printf takes the
implicit hidden_hostcall_buffer argument and is undispatchable by the AQL backend, so the
trace records are plain stores behind a budget. And a plugin-owned __device__ global is not
a channel into the engine's dispatch path: in a dlopened plugin the runtime's symbol stub
is not the address the kernel's module writes, so the served trace channel is a hipMalloc'd
record slot passed as a kernel argument, with the device-global ring kept for the board.
kv_store bounds its slots at the pool's own plane (n_blocks x block_size), the span the
cache operand declares, not at the step's own span: a request that adopts a cached prefix
writes its new tokens at the allocator's global block indices, which sit past any bound
built from the step's token count, and a slot lost there is KV that attention then reads
stale. A corrupt slot map is dropped at the same bound.
DeepSeek's release carries no chat_template.jinja and its tokenizer_config.json
names none, so an HF-direct container answers /v1/chat/completions with 501
unless the serve passes --override-chat-template. The converter now takes the
template itself and bakes it into the vocab section, overriding whatever the
checkpoint carried or lacked. Trailing newlines are stripped as for a sibling
chat_template.jinja, and an unreadable or empty file is refused rather than
skipped. Both paths are covered: text_test reads the file, convert_test
converts the tiny checkpoint and reads the template back out of the container.
(cherry picked from commit 6381f61794cd61d1f86925fd23ea61e1b1544dfe)
engram_tables.py builds the Engram hash tables from the release's own tokenizer.json
and config.json, so rad-convert needs no llama.cpp converter run; imatrix_merge.py
fuses the gate/up imatrix entries llama.cpp's converter writes split, matching the
plugin's fused ffn_gate_up weights. The recipe is the UD-IQ1_S mix for the official
release (251.07 GiB plan).
The one-grid form and the pipelined tiled up-mix replaced hc_read_a_kernel, hc_up_mix_kernel and
hc_up_mix_tiled_kernel in place. Their previous forms are kept verbatim as *_prev, with
hc_up_mix_prev_launch launching the up-mix as before, and r4d_hc_read_pin_decode(1) selects them:
kernel A, then the up-mix in a second launch, and the tiled up-mix's K passes in sequence. 0, the
default, is the launcher's rule.
r4d_selftest's hc_decode_forms runs both on the same inputs on a real stream at 1 to 7 rows (each
one-grid instantiation), 8, 16, 32, 33 and 64 (the tiled up-mix at both row tiles), with E4M3 and
int8 codes, and compares x, the injected gains, the codes, their scales and the rotated twin byte
for byte. The two forms must dispatch different kernels (r4d_record_dispatches), so an ignored pin
fails: with the hook made a no-op, all 24 checks fail. For that the tiled up-mix now launches
through r4d_emit, so the dispatch log sees it. --perfhc times both under the launcher's prefill rule.
--perfhc M, cold (256 MiB through the caches), one R9700 at 240 W, three runs, medians, previous
-> rule: 1 row 32.3 -> 22.5 us (-30.3 %), 4 rows 34.8 -> 25.4 (-27.0 %), 8 rows 46.2 -> 43.3
(-6.3 %), 32 rows 51.1 -> 48.4 (-5.3 %). r4d_selftest --case hc_read_e4m3: 62 ok, 0 FAIL (24 of
them the new comparisons); hc_read_bf16: 5 ok.
libr4d/isa/res.sh: no hc kernel spills or uses scratch (195 kernels). hc_read_fused_kernel takes
126 to 147 VGPRs (9 or 10 waves). The pipelined tiled up-mix at its 32-row E4M3 tile takes 111
VGPRs where the previous one took 75 (12 waves a SIMD against 16), and is the faster of the two at
8 to 32 rows as measured above.
At 8 to 32 rows (two to eight streams at MTP 3) the up product with the mix ran its five K passes
as loads, barrier, WMMA, one after another. Its K loop now issues a pass's loads before staging
the previous pass from registers, with the mix's operands loaded alongside the first pass. The
barriers there order LDS only (hc_lds_barrier): __syncthreads() fences at workgroup scope, which
on gfx12 in WGP mode waits for every outstanding global load, so no prefetch survived it. The
quantise tail reads each thread's channels once, where it walked them a dependent load at a time.
Same fragments through the same WMMAs in the same K order, and the same tail arithmetic: the
output is bit-identical (compared byte for byte against the previous kernels in this series' last
commit).
r4d_selftest --perfhc M, cold, one R9700 at 240 W, three alternating rounds against 6c33ee4,
medians: 8 / 16 / 32 rows 46.6 / 47.8 / 51.4 -> 43.9 / 44.3 / 48.4 us (-5.8 / -7.3 / -5.8 %).
r4d_selftest --case hc_read_e4m3 and hc_read_bf16: 43 ok, 0 FAIL.
At one to seven rows hc_read is a chain of dependent latencies, not a stream of bytes: kernel A
is mostly its norm prologue and the L2 round trips around its dots, with memory idle meanwhile,
and kernel B cannot ask for W_up until A has ended. At Qwen3.8-Flash-Next's shape (hc 4, n 2560):
- A and B run as one grid (hc_read_fused_kernel), roles by ticket: a block's first act is an
atomic increment, tickets below `na` run A's body, the rest B's. A B block loads its W_up rows,
then waits until every A block is done. Every block holding a smaller ticket has started, so
the blocks it waits on are resident: no co-residency is assumed and none can deadlock. The last
B block past the wait clears the counters for the next launch on the stream (kHcSyncCtr more
words in the per-stream counter block), and a wait past half a second gives up rather than hang
the card. Without the counters the two kernels run as before.
- A's norm prologue loads all of a thread's h and norm gain at once, one round trip for ten.
- B's dot reads d from LDS as bf16, sixteen values in two 16-byte reads, two rows of W_up a thread.
- At four rows a wave computes its two W_down columns in one pass over N (hc8_dot_down2).
- Dynamic LDS starts 16-byte aligned: the fused kernel's static LDS is not a multiple of 16, and
misaligned N reads ran A three times slower.
- The quantise tail reads its group once instead of three times.
Every sum is the same fmaf sequence in the same order, so the output is bit-identical; this
series' last commit keeps the previous decode kernels behind a pin and r4d_selftest compares the
two byte for byte. Eight or more rows keep the tiled path.
r4d_selftest --perfhc M, cold (256 MiB through the caches), one R9700 at 240 W, three alternating
rounds against 6c33ee4, medians: 1 / 2 / 4 rows 32.7 / 33.2 / 34.7 -> 22.8 / 23.6 / 25.2 us
(-30 / -29 / -27 %); 8 and 32 rows unchanged. r4d_selftest --case hc_read_e4m3 and hc_read_bf16:
43 ok, 0 FAIL.
Pinned at 8 rows up to the wide row tile, the wide kernels refuse the shape (RAD_E_SHAPE: they
serve only the wide tile), and --perfhc stopped at that FAIL before timing anything, so hc_read
could not be timed at a verify step's 8 to 32 rows (two to eight streams at MTP 3). A pinned form
that refuses with RAD_E_SHAPE is now a skip; the forms that serve run, compare byte for byte and
time as before. The decode tiles' kernels, the first form, must still serve, and any other error
fails as before.
--perfhc 8 / 32 / 64, cold, one R9700: the decode tiles' kernels 46.5 / 51.2 / 81.0 us a call,
where each stopped at the FAIL before.
Two costs in gemm_fp8a8_body, which every fp8 and int8 linear at 64 rows or fewer runs
(gemm_fp8a8_nt_m16, gemm_i8a8_nt_m16, the bias and gated rows, and r4dchain_gemm_fp8a8):
- The fold loaded its weight and activation scales itself, after the next K tile's prefetch had
been issued. Loads return in order, so each fold waited for that whole prefetch, twice a tile at
FK 256, and the "one tile ahead" overlapped nothing. The scales are now staged through LDS a
tile ahead, beside the B tile: each thread loads one weight-scale dword and one activation scale
with its B prefetch and stores them with the B tile, so a fold reads LDS. Two registers a
thread; holding a tile's scales a lane (8 + 2*NT registers) spilled at the decode pins.
- The split-K finisher walked the partial planes token index fastest, `rows` floats apart, one
element a thread: a cache line a load and a round trip each, most of a 45 us call at N 512,
M 64. Consecutive threads now take consecutive weight rows, four rows a 16-byte load and four
loads in flight a plane; a shape off that alignment walks the rows fastest an element at a time.
The int8 single-tile wave pin goes from 12 to 10: the staged form needs a few more registers than
12 waves' 120 leave, gfx12 allocates them 24 at a time so 11 waves leave 120 too, and no decode
shape puts more than 8 of these waves on a SIMD. The gated three-tile form, at 8 waves since the
previous commit, spills 10 at 33-47 rows and 9 at 48 with the staging (0 and 7 without; at 9 waves
it would spill 70).
The same values are summed in the same order (each finished element from 0.0f in ascending split
index, rounded by the same rule) through the same WMMAs in the same K order: bit-identical. A dead
wave's fp8 block scale reads 0 instead of the plane row past the end; its rows are never stored.
A full r4d_selftest in 6c33ee4 and here, every launch of a gemm_fp8a8* or gemm_i8a8* row hashed
after it: 975 of 975 identical (829 gemm_fp8a8_nt_m16, 42 gated, 18 gemm_i8a8_nt_m16, 5 bias).
Greedy replies on Qwen3.8-Flash-Next (int8) and Qwen3.8-27B FP8 byte-identical to 6c33ee4's.
r4d_selftest --perfw8 / --perf at every narrow-GEMM shape of the two models at tp 2, cold
(256 MiB), one R9700 at 240 W, alternating rounds against 6c33ee4, medians, summed over each
model's ops at 1 / 8 / 32 / 48 / 64 rows: Flash-Next int8 61.7 / 64.2 / 83.6 / 111.9 / 130.9 ->
56.8 / 57.0 / 68.3 / 87.5 / 95.7 us, 27B FP8 411.0 / 411.9 / 427.2 / 446.3 / 485.4 -> 404.6 /
405.4 / 415.0 / 428.5 / 438.7 us. Most at narrow N, where the finisher dominated: fp8 512 x 5120
at 64 rows 53.2 -> 15.4 us, int8 256 x 2560 at 48 rows 21.0 -> 8.5 us. The gated row at 27B's
gate_up against the previous commit: 1.3-3.4 % faster at 8-32 and 48-64 rows, 1.8-2.3 % slower
at 33-47 (176.8 -> 180.2 us at 40), where the staging's spills cost more than its overlap gains;
against 6c33ee4, 3.5 % faster there. Decode step at tp 2, old / new / old: Flash-Next 15.76 /
15.69 / 15.76 ms, 27B FP8 28.02 / 27.69 / 28.04 ms.
The gated row at 33 to 48 rows (NT 3, MW 16) was pinned at 9 waves, 168 registers, where its
epilogue spilled: 57 registers at the full tile (48 rows) and 10 below it (12 and 59 in its
chained twin). At Qwen3.8-27B FP8's gate_up at tp 2 (N 17408, K 5120) 48 rows took 272.9 us
against 180.6 at 56. The gated form is always MW 16, so a block puts four waves on each SIMD, and
8 and 9 waves both hold two blocks a WGP: at 8 the form gets 192 registers for no occupancy, and
spills 7 at 48 rows and none below. f8_waves takes the gated flag (false by default), so no other
form's pin moves.
A pin changes register allocation only. r4d_selftest --case dequant_w4_bf16 (fp8_numeric, which
checks the gated row byte for byte against the GEMM + gated_quant_fp8 pair at every M it runs),
every launch of an fp8 narrow GEMM row hashed after it in 6c33ee4 and here: 879 of 879 identical,
42 of them gated; 1,526 ok, 0 FAIL.
r4d_selftest --perf 17408 5120 M, cold, one R9700 at 240 W, five alternating rounds against
6c33ee4, medians: 48 rows 272.9 -> 180.6 us (-33.8 %), 33 to 47 rows 186.2-187.6 -> 175.9-177.1
(-5.5 %), 8 to 32 and 56 to 64 rows within 0.3 %.
--perf N K M timed gemm_fp8a8_nt_m16 and the tiled row but not gemm_fp8a8_gated_nt_m16, the
engine's gate_up at every fp8 SwiGLU model, so that row had no timing. At N % 256 == 0,
K % 256 == 0 and M <= 64 it is now timed with the others, N being the gate and up rows together
as the engine fuses them; a shape the split rule would split is reported as not served. At
Qwen3.8-27B FP8's gate_up at tp 2 (N 17408, K 5120) on 6c33ee4, one R9700 at 240 W, cold:
157.1 us at 8 rows, 164.3 at 32, 186.7 at 40, 271.8 at 48, 180.3 at 56.
A hit recomputes the tokens past where it resumes. Kernels may round a row differently at another
chunk length (spec §17: the fp8 GEMM's split-K count is chosen from M), so a hit that recomputes
its tail in other chunks than a cold prefill of the same prompt can flip a near-tie in greedy text.
On the DeepSeek-V4.1 daily (TP4) a 24k-token prompt that hit a 16k one's tail snapshot resumed at
15856, ran a 528-token chunk to the next boundary and answered differently from its cold run.
--prefix-resume exact, the default:
- ChunkGeometry carries the grid an idle server's cold prefill chunks on: --max-num-batched-tokens
rounded down to the quantum, or the checkpoint interval where chunks split at it and it is the
smaller, times the span from the second interval on.
- plan_chunk writes checkpoints only on that grid. A prompt's tail snapshot is taken where its last
chunk starts (sliding-window snapshots keep their one-block margin) instead of at its last
quantum boundary. The chunk already ends there, so a long cold prompt no longer runs a short
extra step at its end.
- A checkpoint interval past the chunk must be a multiple of it; otherwise it is rounded up, and
startup says so.
- admit_one steps a hit with no snapshot to resume from (full attention) back to the grid. A
request's own checkpoint (Request::checkpoint_at, /v1/systemone's shared head) is honored where
it falls.
--prefix-resume nearest keeps the previous rule.
The cost is re-prefill: an exact repeat runs the cold run's last chunk again, and an agent's next
turn resumes where the previous prompt's last chunk started, about half a chunk more than nearest
(2048 tokens at a 4096-token budget). The property holds on an idle server; a prefill that shares
its steps with decode rows or other requests (--busy-prefill-chunk, --prefill-interleave) is cut
differently, as batching already changes greedy text.
Tests: sched_test covers the grid for six geometries (GDN hybrid, interval past the budget, span,
periodic and tip-only window snapshots, full attention), the interval rounding, the tail snapshot
at the last chunk start, admission stepping back to the grid, and a property over prompt lengths:
every checkpoint is a chunk start of the cold run of its prompt and of any longer prompt it
prefixes, and a hit from it cuts the cold run's chunks. config_test covers the flag.
DeepSeek-V4.1 declares its compressed attention at one KV row per r tokens: kv_index_r2 and
kv_compressed_r2 at 2-token blocks, kv_index_r1 and kv_compressed_r1 at 1-token blocks, beside a
16-token sliding window (kv_window), a linear compressor state (kv_comp_tail_r2) and a conv window
(kv_engram_tokens). On that model no request ever reused a token, for two reasons:
- PrefixCache::configure took the first full group's block size as its granularity and left every
paged group with another block size out ("block 1 != cache granularity 2: not cached").
- KVManager put a trunk's window in the checkpoint slot only on a model without linear state, and
the scheduler refuses a hit that leaves a trunk group uncovered. With linear state beside the
window, every hit was zeroed (HitCut::Window).
Either alone leaves the hit at zero. On an agent's growing conversation that is the whole context
prefilled again every turn.
The cache now holds every paged group but a windowed one. An entry covers the lcm of their block
sizes and holds lcm / B blocks of a group with B-token blocks (PrefixCache::entry_groups,
blocks_per_entry). A lookup hands each group its own blocks for adopt(); insert, eviction, trim,
rebind, restore_room, release_session and unshared_tokens count per block; trim() and trim_for()
count entries. The chunk quantum is already a multiple of every paged group's block, so
checkpoints and hits stay on the entry grid. With equal block sizes an entry is one block a group,
as before.
A trunk's window rides in the checkpoint slot whether or not linear state is beside it; the slot is
the state, then the window pages, the layout KVManager::checkpoint_copy already walked. The
scheduler lets a hit stand on a windowed trunk group when it resumes at a window snapshot
(win_hit no longer needs a model without linear state); any other trunk group the cache does not
hold refuses the hit, as before. The reserve's trim asks for entries, from the group furthest
short. The idle tiers move an entry as its blocks: TierExec and the slot layout take
entry_groups(), where a group appears once for each block it holds in an entry, and the VRAM
estimate counts the same.
No plugin on main has a window beside linear state or paged groups of different block sizes, so
every model here keeps its cache and slot as they were. DeepSeek-V4.1 (#266) has both; its slot
grows by the window's pages (10 blocks of kv_window, 6.25 MiB a rank at TP4).
Tests: mem_test -- an entry at the lcm over block sizes 2/1, 2/4 and 16/2 (lookup blocks, adopt,
refcounts, eviction and trim in entries, restore_room, unshared_tokens), a publish short of one
group's blocks refused and unwound, checkpoints on the entry grid (and the binding's key), an
interval off the grid refused, a hybrid with a window and mixed blocks, an entry over mixed block
sizes through the host tier byte for byte (one to three ranks, replicated beside zero), and a
checkpoint carrying linear state and the window together; the window-snapshot rule's test now
expects the window beside linear state. sched_test -- a hit on a hybrid whose slot carries the
window resumes at the snapshot, a trunk group neither cached nor in the slot refuses the hit, a
hit over mixed block sizes adopts each group's own blocks, and the reserve trim asks for entries.
llama.cpp keeps a Gated DeltaNet's ssm_conv1d unquantised, in f32, and a container converted from
a GGUF holds it so. The three kernels that read the convolution weight, gdn_conv_prep,
gdn_conv_update and the convolution gdn_conv_recurrent_update folds in, read bf16, so their shims
refuse an f32 weight. The weight's element type is now a template parameter of all three.
r4d_gdn_conv_tap.h, which already holds the arithmetic the fold shares with the standalone path,
gives the vector a channel's taps are loaded as (ushort4 or float4) and the widening of one tap,
exact for either type. The shims take a bf16 or an f32 weight and pick the instance by its dtype;
any other dtype is still refused.
The raw entry points keep their signatures. r4d.h gets an f32 twin of each standalone one,
r4d_gdn_conv_prep_w4_h128_bf16_f32wgt and r4d_gdn_conv_update_w4_h128_bf16_f32wgt, rather than a
flag, so no caller of the bf16 ones changes. The fold has no raw entry point; its CV parameter now
also says the weight's type (1 bf16, 2 f32), which leaves every existing instance's template
arguments and name as they were. That is twelve new conv instances and sixteen new fold ones.
The bf16 instances compile to the same code. Built before and after with the build's flags, all
116 kernels of the two units have the same instructions, resource counts and metadata; only the
conv kernels' names change with the added template argument. The bf16 reads keep their shape:
widening gdn_conv_update's ushort4 to a float4 before use reorders its loads. The f32 conv
instances use no scratch, conv_prep 56 to 57 VGPRs (53 at bf16) and conv_update 108 (96 at bf16,
12 waves per SIMD instead of 16); each f32 fold instance has exactly its bf16 twin's counts.
r4d_selftest gets three cases for the card. gdn_conv_prep and gdn_conv_update over an f32 weight
holding bf16's values must write the bytes they write over the bf16 weight: q, k and v, g and beta
at prefill, and the conv state. The sequences are uneven; at prefill two are seeded from their
cache, one of them over two chunks, and a one-token one is not. Outputs are poisoned, the cache
must move and an f16 weight must be refused. The fold over the f32 weight must match the pair
over the bf16 one, byte for byte as the fold already does at bf16.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The dense integer kernels compile their group in and read no `group` argument, and neither the
rows nor the layout hooks checked it: w8_enc_layout accepted an `i8*f16[1x32]` weight (a Q8_0
block) at group 32 and the kernel computed it at 128. The twelve dense gemm_nt_q rows now carry
C_EQ("group", ...), and the four hooks (w4, w5, w8, w2a8) answer RAD_E_DTYPE at any other group,
the one code select() counts as a refusal. relayout_parity_test pins the hooks, plugin_test the
rows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A GGUF tensor of block type Q8_0, Q4_K or Q6_K could only be dequantised, so rad-convert reached it
through a recipe rule and re-quantised what was already quantised. ckpt_resolve now states the
planes libquant's ggml quantiser writes for the same blocks and marks the weight imported, and
ckpt_plane_rows splits each row's blocks into them bit for bit. The split is
core/format/ggml_planes.h, the reader's copy of lq_ggml's unpack functions, since the core cannot
call libquant; a type there is one table row, its planes and its split. Pieces of one block type
joined along rows import, an expert's slices of a stacked tensor included; mixed types and column
joins keep a GGUF reason.
The weight is not trivial, so the loader refuses it with the hint to serve the container
rad-convert writes, and ckpt_rows_f32 still dequantises it for a recipe. A rule that declines such
a weight is an error in rad-convert, since keeping its planes would hide that the rule did not
apply (spec.md §4.4).
Tests: quant_ggml_test holds every type of the reader's table to the quantiser's encoding,
checkpoint_test decodes the planes of Q8_0, Q4_K (one-block rows and a row join) and Q6_K against
the block definition and holds an expert's gate|up, two slices of stacked Q4_K tensors, to the same
blocks stored on their own, and convert_test runs a declining rule over a Q8_0 tensor, with the
GGUF writer moved to tests/gguf_writer.h for it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A keyframe is pinned on the grid the steps run on, which is why 7935897 refused it with
latent_upscale. The pin can follow the switch instead: the server prepares each keyframe at the
small size too, the same way as at the canvas (stretch or centre crop), and the driver encodes
that picture into the keyframe's slot before the prompt pass, runs the small steps on the pack it
already lays out at the small size, and after the VUPSCALE pass encodes the canvas picture into
the same slot before the first full-size evaluation. The plugin reads its slots as before, so
neither the plugin nor the ABI changes; rad_builder.h documents the order. References keep their
own grids and are encoded once, as before.
Host: video_gen_test checks the pass order (E C S S U E S A D), each encode's size and slot and the
step rows at both sizes, and that a keyframe without its small picture is refused; videos_test
checks that each keyframe is prepared at both sizes with its stretch/crop and that the tower still
sees the canvas frame only. GUIDE, the ComfyUI node's README and tooltip no longer say keyframes
refuse latent_upscale.
Under --tp-wire wht6 a TranslateGemma step of 2-3 sequences (16-24 rows) sent its junction as
three launches (the standalone lossy all_reduce, rmsnorm, rmsnorm_quant_fp8): the fused
ar_rmsnorm_post_quant_fp8 sent the exact wire only, and the compressed fused form needed a row of
whole 512-element chunks, which Gemma 3 27B's 5376 is not (10.5).
- r4d_fused_quant_fp8.hip: a row of whole 64-element groups that is not whole chunks ends in a
partial chunk whose missing groups go out as zeros and are not stored back. Every real group is
the same 64 elements as in the flat message, so its bytes and the sum are the standalone wire's.
The (row, chunk) mapping is a template parameter (PAD, wire 6 only), so a row of whole chunks
(Qwen3.8's 5120) runs exactly the code it ran before; as a runtime branch it cost a Qwen3.8 x4
step 1.3-1.6 %. POST (the sandwich post-norm) on either wire.
- r4d_ar_entry.hip: K % 64 instead of K % 512 for wire 6, a size check of the padded message
against the slot and the local pack, and the local pack's scale region a sixteenth of the slot
instead of a thirty-second (padding adds up to 7 groups a row: a 2048-row prefill chunk would
have overrun the old size).
- gemma3: the junction declares its lossy twin (op_ar6) and takes it up to kAr6MaxRows (24); a
taller step keeps the standalone all-reduce, which spread over more blocks wins there (the
fused kernel gives a block one row).
TranslateGemma-27B MXFP4 + DFlash2, 2x R9700, --tp-wire wht6 --draft-short-from 8, greedy,
aggregate tok/s, two rounds, junction limit never / 24 / any:
2 streams (16 rows) 350.7 346.2 / 370.4 367.0 / 357.7 356.0
3 streams (24 rows) 455.8 451.2 / 462.8 460.6 / 437.3 436.8
4 streams (32 rows) 553.7 553.6 / 553.9 560.2 / 521.0 523.0
8 streams (32 rows) 717.4 718.0 / 716.7 720.8 / 662.4 661.9
So 2 streams +6 %, 3 +2 %, 4 and 8 unchanged.
Bit identity: with --tp-wire-min-kb 1 (one stream's steps go out lossy) the fused path gives the
unfused one's greedy top-5 logprobs, 300 of 300 tokens, max |d| 0, on two pieces (x1 there 197.6
-> 212.6 tok/s). Qwen3.8-27B MXFP4: 300 of 300 identical on two prompts, speed unchanged.
Tests: arch_test (the lossy-wire junction test now also expects a 24-row step to fuse through the
twin, other op instances than the 8-row step's, and the 64-row prefill to stay unfused).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Reuse one optional-link chain per repeated operand, preserving exact bounds and existing compile limits. Includes a synthetic multi-bound schema regression.
AI-assisted contribution; original implementation by claude-nanbeige.
The header asserted "Every kernel of every loaded library ran" on a pass
whose own body counted 132 of 510 rows reached, so a coverage gap read as
full coverage. Print the sentence only when no declared row was left
unreached; otherwise name the count and point at Rows nothing ran. The
counts come from the same LibRow data the section below prints, so header
and body cannot disagree.
Reproduces on v1.13.0 (checked-in docs/KERNELS.md); the generator literal
is unchanged on current main.
The counting is one python3 pass; exit 77 (ctest's SKIP_RETURN_CODE)
where python3 is not present, the same posture ops_doc takes for plugins
that will not dump.
The checked-in libr4d section of Rows nothing ran said 239 not reached
over a table of 243: 486c9331 added the four kv_store_streamed rows to
the table without the count (the previous regeneration, 1e968f6e, was
consistent at 239/239). The generator prints header and table from one
vector, so a file like this cannot be one run's output: it is a hand-
merged regeneration, and its headline (132 of 510) and section totals
read four rows short of the tables.
Count the rows each section emits (tests/kernel_report_check.sh), fail
the fast tier when a header and its table disagree or the headline no
longer adds up, and correct the report to the numbers its own tables
show: libr4d 243 not reached, 291 declared (the four rows are in
r4d_rows.cpp and the library reports them), headline 132 of 514.
Regenerating the report from one run on a rig with cards supersedes the
corrected numbers; the test keeps the file honest.
On a box whose cards expose no peer path (IOMMU off; the engine carries
the fact as device.p2p and selects host-mailbox rows around it), the
2-rank collective cases failed with RAD_E_DEVICE: ar_ipc_enable_peer
throws enable_peer: invalid device ordinal, init maps it, and a box
configuration the engine serves shows up as five failures. A card count
is not the fact the kernel contract gates on; hipDeviceCanAccessPeer
answers it without launching a kernel. Gate every collective case on it,
with a skip naming device.p2p, like the card-count gates. On such a box
the five failing cases now skip (targeted --case runs); the rest of
r4d_selftest is unchanged.
An AUTO probe that misses leaves one STATUS line in the configure log,
and the engine boots green and 500s every media request; the startup
report -- the part of a log to paste into an issue -- said nothing about
the capability that decides it. mm::decoder_version() names it (the
libavformat version, or "absent (built without libav*)"), reported on
the startup report and /diagnostics (hardware.host.media), and GUIDE
1.1 lists the five -dev packages, the RAD_WITH_FFMPEG tri-state and the
symptom.
A userspace SDK (venv-style) finds hipcc via -DRAD_HIPCC, then device
compilation dies on clang's 'Could not find standard C++ header cmath':
ROCm's clang needs --gcc-install-dir for the distro libstdc++, and
--rocm-device-lib-path for the tree's amdgcn/bitcode. ROCM_PATH covers
discovery, not these. The working flag set, for the SDK and the core
system install, in 1.2 after the direct-CMake recipe.
pp, cN, M, I, T, ti8, FK, W4, iq4r, hc_write, pp64K, QSA and L0..L3 are
used as if defined; the kill levels are defined below the table that
references them. One glossary block after the intro; every other word of
the document is unchanged.
The sentence in the Checking section predates the libref rows (ref_qsa.cpp
landed in the same release), and it reads as a reason to skip QSA's reference
comparison in a review. The library rows and the report's completeness matrix
show five registered ref rows. The remaining limitation is the subsystem one:
no oracle compares a dense run against a sparse one above the bound, and that
sentence stays.
The builder accepted one conversion direction beyond the exact widening it already did: a single-plane RAD_F32 source declared RAD_BF16 is rounded to nearest even at load (WeightInfo::narrow, beside widen). It is staged like a widened weight, never read in place from the container, and the planner and oracle treat it as 'not the container's stored bytes'. build_test covers the declaration, the stored dtype and size, and that it is not file-direct.
Post-norm encoder with fused Wqkv and biases, NeoX rotary, non-causal attention, a dense MLP on even layers and a top-2 of 8 expert MLP on odd layers, mean pooling into the pooled f32 buffer for /v1/embeddings. The checkpoint is f32; data/recipes/nomic-embed-v2-moe-bf16.recipe casts the linears, the token embedding and the token-type table to bf16 (the device kernels read bf16), norms and biases stay f32. The checkpoint's shared experts.bias is not applied: against a llama.cpp run of the same checkpoint at Q8_0 the variant without it matches best (cosine 0.9994; the others 0.9990 to 0.9993), and llama.cpp's own nomic-bert-moe does not carry it. Verified on a gfx1201 card and on libavx/libref against a pure-float32 torch reference: mean cosine 0.99995, min 0.99983 over 20 texts. Unit tests declare and lint a cut-down model. Not verified: inputs above 512 tokens against a reference on the device, other quantisations.
meta_from_config_json reads the nomic spellings (n_layer, n_embd, n_head, n_inner, n_positions, moe_top_k, layer_norm_epsilon, rotary_emb_base) as fallbacks in the same chain as the usual keys; existing checkpoints parse as before. RAD_MAP_TRANSPOSE can first take one expert's sub-tensor of a stacked table: src_index[0] picks the dim-0 sub-tensor of a rank-3 stack, or, with src_rows[0] > 0, the row block of a rank-2 stack flattened over its rows. map_transpose_slice() declares it; map_slice() takes the same optional sub_rows. Tests in checkpoint_test cover the aliases, the [8,4,3] case, the flattened case and an out-of-range index.
meta_from_config_json reads the nomic spellings (n_layer, n_embd, n_head, n_inner, n_positions, moe_top_k, layer_norm_epsilon, rotary_emb_base) as fallbacks in the same chain as the usual keys; existing checkpoints parse as before. RAD_MAP_TRANSPOSE can first take one expert's sub-tensor of a stacked table: src_index[0] picks the dim-0 sub-tensor of a rank-3 stack, or, with src_rows[0] > 0, the row block of a rank-2 stack flattened over its rows. map_transpose_slice() declares it; map_slice() takes the same optional sub_rows. Tests in checkpoint_test cover the aliases, the [8,4,3] case, the flattened case and an out-of-range index.
The sampler's candidate plane is kSampleCandidates (1024) wide and at top_k 20 about 20 entries are live,
but the coupled verify ran its eligibility scan (global memory, one entry at a time) and its sums and
walks on one thread over all 1024: 92-151 us a launch at any row count, on the critical path of every
coupled step. The workgroup now checks validity and takes the maximum in parallel (order-free, exact),
compacts the live indices in ascending order into LDS, and the serial sums and walks run over that list
in the host reference's order, so the token is the same bit for bit.
vtime (n_cand 1024, 20 live, every row bound): 151.7 / 92.8 / 100.5 -> 31.3 / 32.2 / 35.9 us at 4 / 16 /
64 rows; device == host on every row.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Q's temperature (RADIANCE_DFLASH_Q_TEMP) only moves acceptance, never the
output law. Held-out tokens per verify step at request temperature 1, x4,
32 rows of the eval set, Qwen3.8-27B MXFP4 with a DFlash2 drafter fine-tuned on our traffic, our serving flags:
ordinary rule 3.52; coupled with Q at 1.0 3.71, 0.7 3.88, 0.5 3.85,
0.35 3.77. The walk's scores are flatter than the target's law, so a
sharper Q puts its mass where the target's is; 0.6 is the default now.
At 0.6, 3 interleaved rounds against the ordinary rule (64 held-out rows
at x4, and three requests at x1 and x4, 1500 tokens, T 1):
- tokens per step 3.53 -> 3.82 (+8.2 %), every round apart
(3.50/3.49/3.61 vs 3.82/3.79/3.86); time-weighted decode +5.4 %;
- decode per stream: 0.7k prompt x1 174.1 -> 181.7 (+4.4 %), x4 144.6 -> 153.8
(+6.4 %); 22k prompt x1 186.6 -> 191.0 (+2.3 %), x4 135.1 -> 146.2 (+8.2 %);
41k prompt x1 186.9 -> 196.8 (+5.3 %), x4 125.8 -> 135.0 (+7.3 %);
aggregate at x4 +5.3..+5.5 %.
Coupled at 0.6 against the ordinary rule, 5000-6000 samples of tokens 1-4
of two chat prompts: chi-square p 0.62..0.99.
The walk's kernel issues each candidate's successor slice and unary score
before the predecessor's codebook row (both are independent of it). This is
the build measured above; it moved the pass time within noise (91.3 -> 90.8
us at M 16, steps 7), and tokens, ids, x and status still match the host
oracle on all 40 random lattices (q by FP64 exp ulps, <= 4.3e-16).
ctest (the environment-only tests excluded) 105/105.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
DFlash2's drafts were the greedy walk over its candidate lattice, accepted
only when they equal the target's own sampled draw: P(y == x) instead of
rejection sampling's sum min(P, Q). --draft-coupling already did the latter
for a linear MTP head; this extends it to the block drafter.
- dflash_couple_propose (spechub plugin, device row + host oracle): after
dflash_select, the same lattice walked again, sampled. Position l scores
each candidate as dflash_select does (unary + low-rank edge from the
previous token), Q_l = FP64 softmax of score / q_temp over the best eight
in-vocabulary candidates, x_l ~ Q_l at (seed, base, KEY_DRAFT + l + 1),
x_l is the next predecessor. Position l writes round l+1's state row, so
the engine binds it and the sampler's mtp_couple_verify (maximal coupling,
residual (P - Q)+) verifies it exactly as an MTP round. Q depends on the
committed text and on x_0..x_{l-1}, never on the verify, and is stored
exactly. Greedy requests keep dflash_select's tokens (status 0); a draw
for another card or a Q that cannot be built takes the walk's argmax and
the ordinary verify (status -1). The shared arithmetic is in
abi/rad_spechub.h (rad_dflash_couple_step / _walk).
- The block driver stages one draw per drafting row before the query pass,
reads the states back with the slots and binds them after the commit
(Engine::bind_couple, shared with the serial driver).
- qwen35_fp8 declares the planes and the op under --draft-coupling;
RADIANCE_DFLASH_Q_TEMP sets Q's temperature (default 1, exact at any).
- Default (flag off): no op, no plane, no change.
Gates:
- spechub_dflash_couple_test (CPU): emitted token vs P by chi-square over 3
seeds each, Fisher-combined p 0.135..0.919, for Q = P, Q on fewer tokens
than P, Q mostly outside P, top_k 20 + top_p 0.95, top_p 0.6, top_k 3 at
T 0.7, peaked Q; acceptance = sum min(P, Q) within 5 sigma; the walk's
stored Q equals the softmax of its scores (1e-5) and x follows it (p
0.993); the whole draft/verify/bonus loop over 3 tokens matches the
target's autoregressive law (combined p 0.62 at q_temp 1, 0.67 at 0.5,
0.024 with every 2nd step on the ordinary verify).
- Device row vs host oracle, 40 random lattices at the production geometry
(V 248320, K 16, R 256, steps 7/3, M 1..16): tokens, x, ids, status
identical; q differs only by FP64 exp ulps (<= 4.3e-16 relative).
91 us a launch at M 16, steps 7.
- Engine, Qwen3.8-27B MXFP4 TP2, our serving flags, 4-6 tokens of two chat
prompts at T 1 / top_p 0.95 / top_k 20, 5000-11000 samples per arm:
coupled vs ordinary speculation chi-square p 0.23..0.81 (tokens 1-4 and
pair 1-2); both differ from no speculation on one prompt by the same
amount (the verify-vs-decode logits, not the rule).
- Flag off, old build (up12 5dbb5dc) vs this: greedy top-5 logprob traces
identical over 300 tokens (spec 7 and 0, two requests each), 6/6
fixed-seed sampled texts identical.
- ctest (the environment-only tests excluded) 105/105.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Which experts a served model actually uses, per layer, is what deciding how to spend an expert's
bits needs, and the core already has it: every routed layer's counts come back to a host bank once
a pass, and the heat engine drains the landed banks once a step, one step behind. --expert-stats
FILE credits the same rows to a host tally and writes it as JSON every 30 s and at shutdown,
through a temporary and a rename (place/xstats.h). No device work, no copy, no synchronisation;
where the heat engine is off (every expert in VRAM, a static plan) the drain runs for the tally
alone, and at shutdown the streams are drained and the banks still in the ring are credited.
Counts are filed by step kind: prefill (no decode rows), decode, mixed (one histogram cannot split
it) and draft, which is every routed layer past the trunk (an MTP or DSpark head; its bank holds
the step's last draft pass). Each rank files its passes' kinds when it issues them.
A histogram row is the rank's own experts from zero, so under expert parallelism (deepseek41) it
is the rank's slice. The map from a rank's index to the model's expert id comes from the container:
index e is the unit declared with group expert e, and the directory entry of that unit's weight
names the expert. An expert several ranks hold (a width slice each) is counted on the lowest; a
rank that counts nothing does not drain for the tally. Without directory ids the map falls back to
the indices (one rank, or every rank holding the model's count) or to rank order.
The file carries the model, the routed layers, each layer's expert count and top_k, tokens and
steps issued by kind, histograms, passes, observed tokens and selections per kind and layer, the
per-rank drain counters (lost, unmapped, unclassified), and counts[kind][layer][expert].
/server_info names the file. Router weights are not summed: they stay on the card.
Tests: xstats_test (the map, the tally's kinds and merge, the file); config_test lists the flag
and checks it is off until it names a file.
## Summary
Optimize HYV3 decode and the shared W4/W5 and signed-I4 expert paths:
- Compact the asymmetric W4/W5 one-row epilogue without changing its WMMA or split-K arithmetic.
- Pack per-128-scale I4 experts into `t16k64` fragments and load one routed row directly into registers; keep prefill compatible with the same packed weights. Subgroup-scaled codebooks retain their layout.
- Narrow BF16 activations to F16 inside the W4 decode GEMM, replacing the separate activation cast with the same rounding.
- Reuse fused Q/K normalization/RoPE/KV-store, residual norms, routing and the TP1 shared/routed gather in HYV3. TP2 retains separate arm reductions.
- Add cold-weight timing modes, canonical/byte/guard checks, independent nibble-address tests and an affected-path/measurement report.
## Validation
On merged `main` (`2d2f638`):
- `gfx1201` kernel library, selftest executable and all three HYV3 plugins: compiled.
- Release and ASan/UBSan/leak architecture suites: passed.
- Layout parity: 1,145 checks over 20 cases, including GPTQ, rotated experts and subgroup codebooks: passed.
- Reference arithmetic: 136,622 checks over 254 cases passed with two failing upstream inventory/sweep cases excluded; the same failures were reproduced using unchanged upstream test source.
A full engine/unit run is blocked by upstream's missing KV-stream headers. No GPU workload or serving-service changes were made during this validation pass.
## Measurements and readiness
Earlier TP1 HYV3 measurements reached 115.678 decode tokens/s versus 90.290 initially; the isolated expert-packing step measured 95.392 to 103.364. These used a highly repetitive 10,030-prompt/2,000-output `alpha` workload on an R9700. They are **historical, not measurements of this rebased PR**, and establish neither general throughput nor gains on other models.
Keep this PR in draft until current-base GPU numerical/guard checks and matched throughput/text/tool-quality measurements pass for HYV3 and the other affected W4/W5/I4 paths. The historical tool subset did not clear its earlier guard and needs an isolated rerun.
See [the optimization report](docs/benchmarks/hyv3-w4-decode.md) for affected models/encodings, historical results, validation details and remaining gates.
Prepare a unity-gate plane once per step and use the existing gather at TP1 while preserving routed BF16 rounding before the shared add. Retain independent arm reductions and combination at TP2, with multi-pass graph and routing-rounding checks.
Reuse the existing BF16-rounded add/norm fusion while retaining final output materialization and the original collective positions. Cover TP1, TP2 and multi-pass prefill without introducing calibration hooks.
Wire the existing fused prologue into the private HYV3 attention helper for small BF16-KV batches. Retain the separate operations for other shapes and KV layouts, with graph coverage of both paths.
Replace the equivalent FP32 cast/add/cast chain with the existing BF16 add and enable the existing fused router for HYV3. Preserve separate tensor-parallel arm reductions and BF16 rounding boundaries; add the reference arithmetic check.
Replace the separate BF16-to-F16 activation cast with the same nearest-even narrowing on load. Keep existing split-K and WMMA arithmetic. Test finite and raw-bit activations, canonical arithmetic, byte parity and output guards; provide BF16-input cold-weight timing sweeps.
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>
RadBatch::mm_embd holds the image rows at rank 0 and zeros at every other
rank. The rows went in after the all-reduce of the token lookup, so at more
than one rank every rank past 0 wrote zeros over its image rows, and the
ranks ran on different residual streams from layer 0 on.
A staged pass copies whole layers into the pool at block-id identity: block b
of layer l goes to base + b * block_bytes. The ring addresses its slots at
base + l * slots * block_bytes + s * block_bytes, so the stage row of a later
layer is the ring row of an earlier one. The copy never touches `res` or
`slot_block`, so every block the map still calls resident names bytes that some
later layer has since overwritten.
Block ids are recycled between requests, so this is not theoretical. The second
request's prefill writes its mirror and -- gated on `res`, which is still valid
from the first request -- its ring slots; the rest of the layers' stage rows
then overwrite those slots. The first decode trusts `res`, skips the resolve,
and reads another layer's, or another request's, KV. Fluent, no fault.
Measured with --kv-resident 32768 on 2x16 GB gfx1201, exact compose flags:
ring off: an arithmetic probe answers 15:55 on every round;
ring on (before): 15:55, then 16:40 for rounds 2-4, on spec 0 and spec 3;
ring on (after): 15:55 on every round.
The same sequence previously answered a 3k system passphrase as Q97/Q&A and an
unrelated weather question with the previous request's filler text.
Clear `res`, `slot_block` and `slot_state` when the binding leaves the stage
view for the ring, for streams whose ring is smaller than their id space. The
first ring pass then resolves every live block out of the mirror -- the cold-map
path the first request already takes -- and the ring is self-consistent for the
decode steps that follow. One memset per prefill, not per step. A stream whose
ring covers its id space is left alone: there the staged bytes and the ring's
bytes are the same bytes at the same offsets.
Tests: kv_window_test 8/8, p4b_kv_ring_test 3/4 (one skipped: no in-tree test
kernels in this build), sched_test 142 cases green. arch_test has 15
pre-existing graph-pin failures on this tree, identical with and without this
change. The 47-case streaming battery is clean on both ring arms (spec 0 and 3).
The reference feeds the vision tower the same resized tensor it hands the
video VAE: an anchor's identity and its pinned latent are the SAME pixels.
Our port showed the tower the source file at the `match` area instead, so
a keyframe whose native aspect differed from the canvas reached the two
channels differently (parallel PR #236, point 5).
A keyframe now decodes once, onto the exact output canvas, in a pre-loop
that owns every FIRST/LAST_FRAME part: the pixels fill enc_pixels for the
VAE pin as before, and the frame itself rides to the prompt block, where
the anchor loop hands it to the tower through the new IMultimodal
prepare_frame -- implemented by the bridge as Processor::image_from, which
smart-resizes and patchifies the caller's pixels exactly as a prepared
file's would be. A reference picture is unchanged (tower `match`, encoder
grid); the two never share a request. The encode loop's keyframe branch is
gone: its pixels were built above, one decode for both consumers.
Co-Authored-By: Claude <noreply@anthropic.com>
Two findings from #236's author, both confirmed against the reference:
The <Picture k> ordinal for endpoint keyframes was fixed by ROLE (first = 1,
last = 2), so an l2va request presented its sole frame as <Picture 2>. The
reference numbers its presentation by PRESENCE (a last-frame-only request is
its picture ONE) -- as this server's own ref2va photo numbering already does.
The parse keeps the role's provisional ordinal; the count check settles it
once every part has arrived (parts may come in either order). fl2va is
unchanged: with both ends, roles and positions agree.
kMinChunks carried a stale 'EXPERIMENT: short-chunk test' enum (4) from a
cheap-clip verification battery, letting every request go under the model's
trained 5.17 s floor (7 chunks). Restored; the file's own '5 to 15 seconds:
7 to 20 chunks' comment describes the real bound.
Co-Authored-By: Claude <noreply@anthropic.com>
The per-layer table is vocab-sharded like the token table. Its lookup is now
reduced the same way, before the pad rows of image positions go in. The rest
of the branch is replicated, so the junction that closes it folds in no
all-reduce. The prefill overlap stays off with the branch. Four ranks stay
refused.
Declare the HYV3 graph with a private attention helper and existing kernels/layouts. Support per-head Q/K normalization, sigmoid-correction routing, the dense-first schedule and TP1/TP2 independent arm reductions with FP32 combine. Add graph, format and plugin tests without calibration or decode optimizations.
Use the existing RadChatFormat fields for the outer tool-call section, name separator and tagged values. Cover grammar, template replay, streaming at every truncation, section boundaries and OpenAI response lifting; leave the supports_reasoning adapter unchanged.
Carry the native FP8 release scalar K/V descales into metadata, reject invalid scales, and support conversion-time decoding of HYV3 GGUF source tensors. Add source metadata and block-decoding regressions.
Avoid empty-payload fwrite, retain the JSON embedding value during iteration, and release fake pinned allocations between Flash-Next redeclarations. Test-only fixes used by the HYV3 sanitizer run.
DenseFP8 takes `mapped` as declare()'s argument since bdb37d5; the member the plugin set was no
longer read, so each modulation slice's COPY map was declared twice and the plugin refused to
declare, in rad-convert and in the engine alike. The plugin now passes it, and the member goes,
so a caller that still sets it fails to compile instead of failing at declare.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With --kv-resident N and --num-speculative-tokens > 0, any prompt under
qsa_exact_to (~2051 tokens) emits digit spam at 65-140 tok/s instead of text;
the same prompt with speculation off is correct, and the same prompt at 61k
tokens with speculation on is correct.
The attention chooses sparse-or-dense with
T == batch->n_seq || qsa_exact_to <= 0 || reach > qsa_exact_to
where 'T == n_seq' is the decode-step test. A verify window carries
n_seq x (1 + n_spec) rows, so that disjunct is false; on a short context
reach > qsa_exact_to is false too, so the pass takes the DENSE branch, which
reads a block id out of the block table as a pool address. On the stage view
that is the addressing (identity); on the ring the pool is a window of slots,
so the launch reads another layer's blocks. The branch's only guard,
kv_stage_layer(), is a no-op on the ring and its result was discarded, so
nothing failed and the text stayed fluent.
The dense path is now refused whenever the group is ring-addressed: a stream
whose ring is smaller than its id space, on a pass that is not staged. A
stream whose ring covers the context keeps the dense path, where ids and slots
coincide. The dense branch also fails the step by name if it is ever reached
with a ring bound and no selection to resolve, so this cannot stay silent.
Measured on 2x16 GB gfx1201, ring 32768, spec 3: a 63-token prompt is coherent
at 63-78 tok/s (was digit spam) and a 4.9k-token prompt is unchanged at 67
tok/s. Suites: arch_test 181 cases, mem_test 184, sched_test 142,
kv_window_test 8, p4b_kv_ring_test 4, all green.
TENTATIVE FIX for a silent wrong-output bug: with --kv-resident N and
--num-speculative-tokens > 0, any prompt under qsa_exact_to (~2051 tokens)
streams digit spam at 65-140 tok/s instead of text, while the same prompt with
speculation off is correct. Measured, and traced:
* the attention chooses "sparse (resolve) or dense (read the block table)"
with `T == batch->n_seq || qsa_exact_to <= 0 || reach > qsa_exact_to`
(arch/common/rad_block_attn_gated_fp8.h). `T == n_seq` is the decode-step
test, and a verify step is n_seq x (1 + n_spec) rows, so it is false.
* short context, so `reach <= qsa_exact_to` is also false: the pass takes the
DENSE branch, which reads a block id straight out of the block table as a
pool address. That is right for a staged pass (identity view) and
meaningless on the ring, where the pool is a window of slots.
* the dense branch's only guard, kv_stage_layer(), is a no-op on the ring: it
returns 0 when the binding has no stage, and the call discards it.
* so the verify pass reads ring stripes holding another layer's blocks. Fluent
garbage, never a fault -- and the drafter's own rounds take the sparse path,
so acceptance still looks plausible.
The dense path is now refused whenever the group is ring-addressed -- a stream
whose ring is smaller than its id space and whose pass is not staged. A stream
whose ring covers the context keeps the dense path, which is correct there
(ids and slots coincide); the arch test that pins "below qsa_exact_to is dense"
still passes for that shape, which is how the predicate was narrowed.
Verified on 2x16 GB gfx1201, qwen3.8-next-flash-fp8-iq4r-moe, --kv-resident
32768 --num-speculative-tokens 3 --max-num-seqs 2:
63-token prompt coherent, 63-78 tok/s (was digit spam)
4 923-token prompt coherent, 67 tok/s (unchanged)
arch_test 181 cases, mem_test 184, sched_test 142, kv_window_test 8,
p4b_kv_ring_test 4 -- all green.
Known gaps, deliberately left for the follow-up: no byte-exact spec-on vs
spec-off gate has been run (only read-back quality), GLM-5.3's MLA path is
untested, and the draft window crossing a page boundary is untested.
main moved the arch fingerprints (PLE, split-KV decode attention, the tune
rows); the values here are main's for every case both sides pin, and the
branch's own bf16-KV case is kept with its hash left for the run to state.
The node is a pure HTTP client, so ComfyUI's VRAM only contends with
radiance's when both run on the server's box. Headless-radiance setups
(the normal layout: client UI on its own GPU, node pointed at a LAN
server) have idle cards on the server and boot --max-loras 2 fine.
Scope the recommendation to shared machines in node tooltip, README,
and GUIDE; PR body updated out-of-tree.
Co-Authored-By: Claude <noreply@anthropic.com>
Measured on the flagship serve (MiniMax-H3 dasiwa-fp8, TP2, rank 16): an
adapter slot is 265 MiB a card and EXACTLY one slot of elastic slack
survives the video arena after KV takes the rest. --max-loras 2 boots only
when nothing else holds VRAM (an idle ComfyUI on the box itself holds
~1.7 GiB); otherwise startup stops at 'vram_kv resolved to 0 MiB'. Lowering
--max-num-batched-tokens is not an escape for a video generator -- the auto
value is a floor (the largest denoise step must fit the arena) and the
declare refuses below it (verified live).
Written where a stuck user or their agent will grep it: the node's lora 2
tooltip (names the failure string), a README 'LoRA slots and VRAM' section,
GUIDE's --max-loras bullet, and the PR's Known limits. Recommendation:
serve with --max-loras 1; go to 2 on idle cards.
The wait's overall budget is the node's own timeout input (default
1800 s); the 30 s was the give-up-per-single-GET limit. A saturated
server should have to miss two straight minutes of tiny status replies
before the client errors out.
`rebalance` takes a preset's name beside true/false: "balanced", "detail" and "subtle" are
comfyui-krea2-conditioning's presets with renormalize on at multiplier 1, "legacy" is true
(ConditioningKrea2Rebalance's defaults, about 9x the taps' RMS). The node renormalises by
s = sqrt(sum m_t / sum w_t^2 m_t) per prompt, m_t tap t's mean square; the plugin holds s as a
constant per preset, m_t averaged over twenty prompts through krea/Krea-2-Turbo's text encoder
(scripts/krea2_rebalance_calib.py: balanced 0.44109, detail 0.35702, subtle 0.84759; per prompt
s stayed within 1.7 % of it). The gains are fixed per tap, so the presets reuse #187's
chan_affine into te.h2 with their own `mul`, one declared op per preset and tap.
The preset rides in RAD_GEN_COND_REBALANCE_PRESET, bits 8 to 15 of cond_opts beside
RAD_GEN_COND_REBALANCE, which a plugin declares when it has presets; the driver accepts both
bits, and the server refuses a preset's name on a model whose rebalance declares none. A row the
plugin does not know scales nothing. Enum values only, so no ABI bump.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 3 s poll must stay -- a plain HTTP client learns nothing unsolicited
(the API pushes no step events) and the progress bar/completion detect
need it -- but the CONSOLE LINE now rides the step counter: printed when
(steps_done or status/progress) moves, or every 30 s as a keep-alive so
encoding and stalls never go silent. A 26-step job logs 27 lines instead
of ~135 near-duplicates, mirroring the server's per-step RAD_INFO rhythm.
The pace tracker keeps sampling every poll regardless of printing.
At 3 s polls a 12.7 s step shows up as ONE increment between two adjacent
polls, so the per-increment delta read as the POLL interval -- a constant
"3.0 s/step" on every slow job (reported live: server log said 12.72).
The anchor now waits until two or more steps are visible and divides the
elapsed window by the steps in it; the EMA still tracks the draft->refine
re-price within a couple of windows, and the encode warm-up never rides
into the first rate (anchor starts on the first step DONE, not job start).
Also _fmt_secs: minutes and seconds each rounded INDEPENDENTLY, so 175 s
printed "3m 55s" and 119.5 s printed "1m 60s" -- now round to whole
seconds once, split with integer ops.
The old eta extrapolated whole-job progress, which folds the encode
warm-up into the average and drifts badly once a latent-upscaled job
switches grid mid-run (draft steps are cheaper than refine steps). The
node now mirrors the server's per-step log client-side: a _PaceTracker
measures seconds-per-step between polls from the steps_done counter and
smooths it (EMA ~40% new) so the number follows the phase change; the
eta multiplies the remaining steps by that pace and marks the decode
tail as extra. Old servers (no steps_done) keep the progress-based eta.
Help + README updated.
The V4 tile's store (storeV4) wrote dim octets 8 rows = 96 dwords apart, so the octets a wave stores at once
shared banks (4-way on 32 banks), and on k6_v4 each tile's V fetch ran as three exec-masked rounds, each issued
after the previous one returned, the scale pair packed right after its loads. Now:
- the V tile is skewed: octet o's rows start 16 (o & 3) + 8 ((o >> 2) & 1) + 128 (o >> 2) halfwords later, so a
store's octets land on distinct banks; the PV read adds the same offset, a compile-time constant a fragment
(V4 at tile 16, contiguous layout, two or more waves; one wave keeps the plain tile, which its LDS budget
needs);
- k6_v4: __builtin_assume(tid < NTHR) and a wave-uniform test for the partial round, so a tile's V loads issue
as one batch, and the scale pair packed at the store, as the prefill kernel does since its own fix. fp8_v4
keeps the tested rounds (batched there, its 4-row steps ran 6 % slower) and its pack.
Bit for bit: the same values in the same LDS cells, read in the same order.
r4d_selftest --perfdecattn on 2x R9700 (265 W), Qwen3.8-27B TP2 rank, k6_v4, sequences x rows x context,
3 interleaved rounds, medians: 1x8x100k 277.0 -> 260.1 us (-6.1 %), 1x8x200k 404.8 -> 377.7 (-6.7 %),
4x8x100k 799.4 -> 753.0 (-5.8 %), 4x8x200k 1733.3 -> 1655.3 (-4.5 %), 8x4x100k 1257.8 -> 1179.8 (-6.2 %),
16x4x41k 996.3 -> 973.4 (-2.3 %). fp8_v4 with the skew alone: -3.6 % (16x4x41k) .. -0.1 %.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
rad-tune skips a (kernel, shape) pair it cannot size: a schema names operands, not extents, and
a tool has to allocate the bytes the kernel will read. For gemm_nt_q the reference describes the
fp8 and the symmetric integer grids and declines every grid with a zero point, because
ref_planes.h joins scale and zero into one operand a RadOpdDesc cannot state. w2a8 is such a
grid, and it is the one the DFlash2 draft head serves, so both of its bands were skipped at
every tune and the served card ran the axis defaults for them.
The extents are not a guess. r4d_rad_layout_w2a8 owns them: codes to fragment order, N*K/4 bytes
(r4d.w2a8.frag.g128), and one dword per row and 128 of K joining that group's f16 scale and
integer zero, tile-major, N*K/128 of them (r4d.w2a8.sz.g128). The activation triple is
quant_act_i8's own output -- int8 codes, one f32 scale a row, and the group-major code sums with
rows padded to 16 -- and the grid is asymmetric, so the kernel refuses the case without the
sums. b_ref stays absent; the reference exponent is mxfp4's.
relayout_parity_test is where both sides exist, so the claim goes there: the table's byte total
for b and b_scale against the same hooks' RadLayout.bytes, over libquant's planes, for w2a8 and
for mxfp4a8, whose sizes the table has carried untested since it was written. Writing the
table's K/4 as K/2 fails it with "the table sizes 32768 byte(s), the kernel stores 16384". The
kernel's own guards -- K a whole number of 128-column blocks, N a whole number of 16-row tiles,
the group the stored form has -- are pinned as refusals, and the shape a two-rank draft head
tunes at (M 8, N 124160, K 2560, group 128) is pinned as accepted.
At one or two waves a workgroup (q_len * gqa <= 32: a plain decode step, or the DFlash2 short block's
4-row verify) the 128-workgroup target leaves too few KV bytes in flight for the card's DRAM; twice as
many workgroups reach it. At three waves (an 8-row verify) more workgroups only add contention, so
those keep 128.
Qwen3.8-27B MXFP4 at TP2 on 2x R9700, k6_v4 KV:
- r4d_selftest --perfdecattn: 4 sequences x 1 row over 100k 582 -> 464 us, 1 x 1 over 100k
264 -> 175, 16 x 4 rows over 41k 985 -> 801; 4 x 8 rows over 100k +9 % (kept at 128).
- The server's decode step at speculation 7 (the median gap between steps carrying every sequence,
three rounds): 8 x 41k 34.01 -> 32.48 ms (-4.5 %), 16 x 25k 44.65 -> 43.19 ms (-3.3 %).
The split count already moves with the batch (8 sequences at 256 split as 4 do at 128), so the merge
sees no new partition; not bit-identical to the 128 target at the same batch.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1.12.0 dropped RADIANCE_PREFETCH; the reads are now issued, or not, by prefetch_beside's own switch.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The window keeps lane 1's concurrent buffers live only across it. A weight read into the cache
(prefetch_beside) names no buffer, so it touches nothing the window protects: it may run on lane 1
outside the window (a DFlash2 drafter's reads come after the trunk's window), and it leaves no window
work for lane 0 to join. runtime_test covers it.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
As qwen35_fp8 has them (prefetch_beside, rad_arch.h): behind the o GEMM, beside the attention
block's all-reduce, gate|up's leading 24 MB are read into the on-die cache; behind the down GEMM,
beside the feed-forward's, the next layer's q; the drafter's all-reduces take the same
(Dflash2::Config::prefetch). Decode steps of up to 32 rows, none on a step with a prompt's rows,
only at more than one rank; RADIANCE_PREFETCH=0 declares none.
TranslateGemma-27B MXFP4 + DFlash2, TP2 on two R9700s, no speculation, two rounds, x1 / x4 / x8
tok/s against none (56.8 / 182.0 / 325.0): 8 MB 63.3 / 203.1 / 354.9; 12 MB 63.0 / 202.6 / 354.9;
16 MB 63.5 / 203.9 / 356.6; 20 MB 64.1 / 204.0 / 359.4; 24 MB 64.4 / 206.4 / 359.3 (+13.4 / +13.4 /
+10.5 %); 32 MB 63.1 / 201.4 / 351.9. With speculation 7 (three rounds, greedy, medians) x1 / x4 /
x8 / x16 158.1 / 409.0 / 592.0 / 710.8 -> 177.3 / 428.4 / 592.3 / 717.6 (+12.1 / +4.7 / 0.0 /
+1.0 %). Bit for bit: a prefetch reads weights only.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
As gemma4_bf16 does (prefetch_beside): at two or more ranks, on decode steps of up to 32 rows, gate_up's
first 12 MB is read into the on-die cache beside the mixer's all-reduce and the next layer's first
projection's beside the feed-forward's; the DFlash2 drafter's reads take the same 12 MB.
Qwen3.8-27B MXFP4 + DFlash2, tp 2, 2x R9700: no speculation x1 61.2 -> 67.9 tok/s (+11 %), x4 225.0
-> 251.2 (+12 %), x8 403.7 -> 438.6 (+9 %), x16 650.8 -> 668.1 (+3 %), x32 +0.8 %; speculation 7
x1..x16 +0..+2 % for the trunk, the drafter's reads x1 +6 % (median of eight rounds); prefill
unchanged. The size and ceiling sweep is in the comment by kPrefetchBytes. RADIANCE_PREFETCH=0
declares none: arch_test's pipe-off case now sets it and still meets the serial graph pinned before
either existed. qwen35_w8a8 builds the same source; the routed (MoE) trunk takes no reads.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A test-only mode of the two-rank exact all-reduce (drain 4, set by
R4D_AR_TEST_LATE_PUSH=1 in the launcher, not in any tuning table): every block
publishes its flag before its push, pushes about 20 us later and stores its check
word as a release, since no flag release follows to write the bytes back. The new
case runs the 32-round sweep of ar_oneshot_2rank_exact and its host twin under it.
Without the push check the readers sum their slots' previous contents (16.5 million
of 18.5 million elements wrong on the device row, 12.9 million on the host twin);
with it every sum is exact.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A two-rank all-reduce or gather pushes its bytes into the peer's slot over PCIe P2P,
drains its stores and then publishes a release flag; the peer reads the slot once it
sees the flag. On 2x R9700 the bytes do not always land before the flag. With reads
streaming beside the all-reduce (prefetch), a greedy reply differed from one server
start to the next.
A probe in ar_rmsnorm_quant_fp8 compared, right after the handshake, a plain load of
the slot with a system-scope load and with the same word 100 us later: in about 1
launch in 1000 the reader saw the slot's previous contents, and the new bytes arrived
about 1 us later, sometimes more. Pushed bytes wait in the writer's L2 until a
system-scope release writes them back: with the flag sent before the push (a test
mode) and nothing after it, they stayed invisible for the whole kernel (49 ms). The
flag's release does write them back, but the writeback and the flag store reach the
peer by different paths, so the flag can arrive first. A stronger drain on the writer
(drain=1), PCIe relaxed ordering off on both cards and an HDP flush on the reader did
not change that; acq=1 hides it only by delaying the reads (and costs 12-33 % of
decode).
The writer now sums a per-dword hash (MurmurHash3's finalizer over value and index)
over what it pushes and stores the block's sum, salted with its handshake value, into
the peer's check word for (slot, block): two parity slots of fine-grained words after
the flags. The flag's release that follows writes the pushed bytes back. The reader
reads the check word, sums the same over the bytes it is about to read and, until the
two agree, takes an acquire fence, sleeps briefly and reads again; a push that never
lands traps after 2 s. A stale element and a stale check word both disagree, so the
order in which the two land does not matter. No value changes.
Kernels: ar_rmsnorm_quant_fp8 (exact and 6-bit wire), r4d_ar_oneshot_2rank_exact,
r4d_ar_hc_write, r4d_ar_gather_hc_write, r4d_ar_gather_2rank,
r4d_ar_oneshot_2rank_wht6, r4d_ar_hc_write_wht6, ar_rmsnorm_quant_i8,
r4d_ar_ln_had_quant_i8. Also: the link gate is released after the check, the exact
and gather launchers round their width to whole waves (the check's wave sum reads all
32 lanes), and ln_had's dynamic LDS ceiling leaves room for the check's static words.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Refs carry their own latent grids, so conditioning is grid-independent and
survives the draft->refine canvas switch; only the pack's video-target
segment resizes. shape_job now lays the pack out twice on a wide+refs job
(draft geometry -> seg_s/mod_seg_s/step_rows_s/lat_v_s + pos_small) and
stage_geom/build_step stage the draft tables while small_now holds. The
arch re-derives the pack from the staged geom, so the plugin needs no
change. Keyframes + upscale now refuse with a message that names the
keyframe and latent_upscale and points at sending the frame as a
reference image instead.
Host: 2 new video_gen tests (per-phase seg_cu/geom/lat/pos staging, the
by-name refusal). Device (dual R9700 TP2, dasiwa-fp8): 2x at 704x704
completes in 133s vs 212s un-upscaled, same-seed rerun bit-identical in
video and audio, refs held identity through both phases; t2va+upscale
control clean; fl2va+upscale refused by name.
The parts of the series' review rounds that concern the fold, carried over when the series was
split:
- gemm_mxfp4a8_gated_gemv: operand dtypes checked, the activation scale grid read as the gemm_nt_q
rows read it (mx_ascale_grid), row pitches checked against the widths; the arrival counters are
zeroed before any launch reads them (the memset is on the null stream, which the engine's
streams need not wait for).
- The layout hooks refuse an operand the gated row does not have; the GeGLU chain refuses
out_bf16 (its bf16 plane is a temporary there).
- r4d_selftest: the reference plane through the gemv row's own hook must be the same bytes; the
small gated cases at K 256.
- libr4d/README.md and docs/TOOLS.md: the row, and --perfmxd's fold timing.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
One block a 128-column group left the grid at n / 128 blocks (68 at Qwen per rank on 32 WGPs) and
the fold lost to the pair it replaces. Now the gemv row grid and K order, the bf16 product and
row amaxes through the op scratch, an arrival counter per group keyed on the output. Byte for
byte the old fold (selftest, twice into one output); r4d_selftest launch_row sizes scratch.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
TranslateGemma's MLP over MXFP4 runs gate_up, gelu_mul into a bf16 plane and quant_act_fp8 over it
before down. The gated fold now takes act gelu_tanh: gelu_mul's tanh GELU with its constants, the
product rounded to bf16 as gelu_mul stores it, then quant_act_fp8's quantiser (the same arithmetic as
gated_quant_fp8's). Byte-identical to the three-op chain (selftest at M = 1, 4, 8 on TranslateGemma's
per-rank gate_up, the smallest shape and the per-row scale); the replaces-hook gives the chain. The
GeGLU form writes no out_bf16: the chain's bf16 plane is gelu_mul's own output, which the hook cannot
hand to an optional operand, and the shim refuses one.
The gemma3 plugin declares the fold at up to 8 rows when both MLP linears are MXFP4 and no
calibration tap reads the bf16 plane.
TranslateGemma alone, speculation 7, two rounds each: one stream 144.5 / 144.9 -> 151.5 / 150.5 t/s,
four streams (32 rows a step, past the band) unchanged; greedy translations identical.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A decode step on Qwen3.8-27B at TP2 issues 631 kernels a card, and a dependent kernel costs the card
3.5-6.4 us in a replayed graph on gfx1201 however little it does, so launches are about 13 % of a
step.
- gemm_nt_q_gated_mx: gemm_nt_q_gated over an OCP-MXFP4 weight (b_ref after b_scale; a new op, not
an optional operand on the old one). Row gemm_mxfp4a8_gated_gemv: M <= 8, a block per 128-column
group of the gated output, a wave per gate or up tile running all of the gemv WMMA form's partials
in its order, then gated_quant_fp8's epilogue -- byte-identical to gemv + gated_quant_fp8
(selftest, M = 1..8, Qwen's and TranslateGemma's gate_up). The MLP block declares it for a plain
MXFP4 gate_up when a loaded library declares the op (libref does not), so a CPU-only engine takes
the pair. Layout hooks map its b_ref (operand 4) to gemm_nt_q's index, so the weight is stored once.
The fold: 82.5 us against 81 + 4.6 for the pair at Qwen's gate_up, 98.8 against 104 + 4.7 at
TranslateGemma's.
- --perfmxd times gated_quant_fp8 and the fold beside the gemv row at a gate_up shape.
Greedy texts of four prompts, speculation 0 and 3, identical to the production build.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The four compute queue slots the GUIDE names are what amdgpu leaves to user queues while it keeps four of the
card's eight for its own kernel queues. With num_kcq=0 MES maps all eight (compute_hqd_mask 0xf), two engines'
queues fit, and the weight reads beside the all-reduces can stay on. The order the engines create their
second-lane queues decides where MES places them, so the first engine should serve one request before the
second starts. Measured with Qwen3.8-27B and TranslateGemma 27B on two R9700s.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The paged prefill attention rows (head_dim 256, gqa 6) at Qwen3.8-27B's per-rank geometry under TP2: one
sequence whose last Q of CTX tokens are the queries, causal, at fp8, fp8 K + 4-bit V, 6-bit K + 4-bit V and
bf16. A long prompt's prefill step is this at Q = the chunk (or a pipelined piece) and CTX = the tokens so
far, and nothing else times it without a server. Two R9700s at 265 W, 1024 queries ending 41040 tokens:
4.37 / 4.26 / 4.46 / 4.76 ms (fp8 / fp8_v4 / k6_v4 / bf16), 107..120 TFLOP/s.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The tile loop waited out a global round trip every tile with every wave of the workgroup (the only
one on its WGP) stalled: the wide K fetch sat in a branch whose join made the compiler drain every
load in flight right after it, and the fp8_v4 / k6_v4 V scales were packed right after their
prefetch was issued, so it was waited on at once. Now the K fetch is branch-free (the launch's
thread count is stated to the compiler), the scales are packed at the store, and on the fp8 and
k6_v4 caches tile t+1's K is fetched once tile t's last m-tile has its scores (O_KLATE), so the
staging phase between the barriers only widens and stores. Load order only: the bytes are the same
(greedy texts of a server identical, r4d_selftest 8124 ok / 0 FAIL on both trees).
r4d_selftest --perfpaged on the R9700, three interleaved rounds, medians, k6_v4: 2048 queries over
100k keys 25.91 -> 21.47 ms (-17.2 %), over 160k 41.43 -> 33.97 (-18.0 %), over 25k 5.63 -> 5.45
(-3.3 %), 1024 queries over 50k 5.69 -> 5.48 (-3.7 %). fp8: -7.8 % at 100k and 160k, within noise
at 25k and 50k. bf16 (the stated thread count alone): 0 to -3.5 %. fp8_v4 keeps the old order on
all three counts: with them it gained 19 % at 100k but lost 3 % at 25k and 50k.
The gap is widest where the cache no longer holds the KV (k6_v4 at 100k is 70 MB against 64 MB of
Infinity Cache), so the round trip is a DRAM one. Qwen3.8-27B MXFP4 at tp 2, production flags,
cold prefill, three rounds: 100k 3830..3856 -> 3932..3935 tok/s, 25k 5255..5292 -> 5292.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
With only the union raise, "raised to N tokens" always meant "one decode
step's selection". Now that the shipped floor can bind instead, both startup
lines said the wrong thing: --kv-resident 1 reported "a decode step can name
1026 blocks" while carving 8192. KVStreamRing::by_union carries which bound
won, and KVStreamSetup::raised_by_union hands it to the report.
Verified on 2x16 GB: --kv-resident 1 now prints "a ring under 32768 tokens
(8192 blocks of 4) misses more than it saves, so the shipped floor is what the
carve takes", the report line says the same, kv_resident_blocks reads 8192 and
the engine serves.
3.9 said "run 32 768" and 5.1 told operators to size at it, while the code only
raised to the validation union (4104 tokens at 2 sequences, no speculation).
Both now state it as the floor the carve takes: kStreamFloorTokens, the union
applied on top when it is larger, both clamped to the group's context, and the
raised number carried into kv_resolve's declared slot table. Also writes down
what that means at the bottom end: a context under 32 768 tokens streams
nothing at all.
The ring is no longer carved below kStreamFloorTokens, so the tests that used
a 1 024-token context to exercise the streamed path (the fail-safe warnings,
the packed-layout gate, the resolve-for-another-group case, the union ceiling
and the prefix tier's on/off rule) were silently covering the context instead
of streaming.
They now use --max-model-len 65536 --max-num-seqs 2 (8 192 blocks of 16), pass
that context to kvstream_configure/cap_probe, and pin the raised depth where
they used to pin the flag's: the union ceiling test takes sel_pitch 2048 so
the union (4 096 blocks = 65 536 tokens) is the binding bound, and the
fail-safe's "both ops declared" case now expects the 32 768-token floor.
The raise enforced only the validation union -- the largest block union one
decode launch selects, max_seqs x (1 + n_spec) x sel_pitch -- which on the
reference model is 1026 blocks = 4104 tokens. That is the depth below which a
step cannot be served at all, not the depth below which streaming pays: the
measured curve puts the cost point at 24 576 and the shipped value at 32 768
(docs/KV-STREAMING.md 3.9). --kv-resident 1 therefore carved a 4 104-token
ring, and one 7 800-token request took 7 213 misses over 8 decoded tokens.
kStreamFloorTokens (32 768) is now a floor the carve enforces:
* kvstream_ring_shape raises any ring under it, then kvstream_ring raises
that to the union when the union is larger; both are clamped to the
group's context, so a context under 32 768 tokens streams nothing (the
ring covers it and the group keeps the base engine's path);
* RadBuildCtx::kv_resident_blocks carries the raised number into the
declare, because kv_resolve sizes its residency table from it -- a carve
deeper than the declared table is refused by the kernel;
* the startup warning says which bound applied, and KVStreamRing::floor_blocks
keeps the two distinct.
The flag is still the operator's: --kv-resident 65536 stays 65536, and a
context that fits is untouched apart from the 32 768 floor.
The feed-forward at four bits (GPTQ), attention and layers 19-23 at i8a8, on one card; the recipe is
gemma4-e4b-bf16-a4-df.recipe with GPTQ for the int4 linears. Needs main from 248ecf5 (a4, #214).
The fp8 watercolour and oversaturation claims predated the root cause: the velocity
head's norm_out shift/scale table was staged at the narrow pitch argument instead of
the declared row width, landing all zeros at t>0, so both heads ran un-modulated.
Since the staging fix no quant has been seen to band. minimax-h3-w8a8.recipe keeps
the int8 case (uniform grid, no E4M3 448-clamp, closest to the int8-convrot finetune
lineage) without the artifact story; the fried-hunt conclusion in NOTE-REF2VA and the
decoder-dump and keyframe-anchor comments carry the same correction as history.
Also accuracy against the shipped server: GUIDE 5.16 and ARCHITECTURES document
i2va/l2va/fl2va/ref2va (first_frame/last_frame parts, 9/3/3 reference ceilings,
keyframes xor refs) instead of t2va-only; NOTE-REF2VA's stale keyframe-pin pending
claims marked shipped, ticket numbers stripped from its shipped headings, its ABI-24
line qualified; the ComfyUI blurb widens to ~50-60 GiB for the w8a8 containers; and
PORT-REF2VA.md leaves the index -- info/exclude always meant it local-only.
The result column now states the outcome the operator cares about -- "streaming
off" for the three rows where it does not run, "streaming on" for the two where
it does -- and the closing line spells out that both "on" rows mean streaming
works, prefix-cache hits work, and only the RAM overflow tier is gone.
The column named a model; the decision is per group, per run. It now says
"the group that would stream", defines the context limit the row refers to,
and spells out the two sides: no streamed path (dense attention, a windowed
group, a packed fp8_v4/k6_v4 cache), versus a full group with an fp8 (E4M3)
or bf16 cache whose resolve and streamed store both linked.
3.8 gains "When it is on, and when it is off. --prefix-cache-mib vs
--kv-resident are EXCLUSIVE": the one-line summary, the five-row table, and
the note that "streaming" means the engine's answer rather than the flag's.
An entry covers every cached group, and a streamed group's rows are addressed
by the block id its sequence used, in that group's own pinned mirror: a slot
cannot stand in for them and their ids cannot be given up for one. So the
tier is turned off when a group really streams, and its MiB are not reserved.
* KV-STREAMING.md 3.8: the rule, the on/off table (flag absent or 0, ring at
or above the context, an architecture with no kv_resolve, and under the
context with the tier at 0 or above), the three startup lines, what it
costs, the defects it replaced and the tp2 measurement; the host-RAM gate
paragraph no longer counts a tier that will not exist.
* KV-STREAMING.md 4.1: the module boundary names the host tier beside
TierExec's gather, since streaming does not take the prefix cache over.
* GUIDE: the operator line under --prefix-cache-mib, and the streaming
section's budget bullet, which no longer says the tier must be lowered.
conv1d keeps both stride forms: upstream's causal codec downsample with cu_div (Fish Audio) and the port's explicit-pad non-causal one (the H3 audio encoder's), in libref, libavx and libr4d alike; the ABI takes upstream's 27 on top of the port's RadVideoGenBatch growth.
Two pins on the rule in core/mem/prefix.cpp:
* an_entry_with_a_streamed_group_is_never_demoted -- demotable() is false,
the tiers are never told about the entry (plan_writeback yields nothing),
drop_clean takes nothing, and trim_sparing evicts it whole: every group's
block comes back, the streamed one included;
* the_prefix_cache_host_tier_is_off_only_when_streaming_is_really_on --
kvstream_prefix_host_off() turns --prefix-cache-mib off only when
cfg.kv_streams is set, i.e. the ring is under the context and the
architecture streams; the flag absent, a ring that covers the context and
a model with no streamed path all keep the tier. Runs through
kvstream_cap_probe, so the three cases are the ones an operator hits.
The prefix cache's host tier and --kv-resident are exclusive, and the engine
used to find that out at the first restore. An entry covers every cached
group; a streamed group's rows are addressed by the block id its sequence
used, in that group's own pinned mirror, so a slot cannot stand in for them
and their ids cannot be given up in exchange for one.
Three defects came from ignoring that:
* the write-back gathered the resident sibling with the streamed group's
block id, so the host slot held another group's row (TierExec indexes
its block vector by gi_, the entry's ids are in groups_ order);
* demotion released the streamed group's ids too (PrefixCache::
release_blocks walks every group), handing the mirror rows the entry
lives in back to the allocator;
* a restore reserved one group's ids against an entry that has two, so
rebind returned RAD_E_SHAPE and the record was dropped -- and
engine.cpp's failure path then released those ids against the wrong
pools.
Measured on 2x16GB tp2, three 44220-token conversations and a replay of the
first after the third displaced it, streaming on: 20247 entries demoted,
8588 restored, replay 0 cached tokens / 16.5s against streaming off's
44160 cached / 0.4s. The copies were pure waste.
Two rules now:
* PrefixCache::demotable() is false when any cached group streams: the
tiers are never told about such an entry (insert), and trim_sparing no
longer skips it as though its copy were in flight, so it is evicted
whole with every group's ids.
* kvstream_prefix_host_off() turns --prefix-cache-mib off at bring-up,
before anything is sized from it, when cfg.kv_streams is set -- the
flag asked, the architecture streams and the ring is under the context.
A flag with no streaming behind it (0, a ring that covers the context,
a model with no kv_resolve) keeps the tier exactly as configured.
On the cards: --kv-resident 32768 reports "no host cache ... so it is off"
and 0 (off); --kv-resident 131072 keeps 2.00 GiB / 38836 entries. The tests
live in the mem test file's own commit; the docs in the docs commit.
Four containers on Hugging Face (keptn): FP8 and w4a8, each with MTP or DFlash2, on four cards.
A compose file and a row in the models table for each; docs/DOCKER.md lists them and the two
NVIDIA-Nemotron-3.5-Bolt-E4B files.
MiniMax-H3 declares no guidance in RadVideoGenDecl (guidance-distilled: CFG
is baked into the weights, one forward a step), so /v1/videos answers any
request that names negative_prompt with "this model takes no guidance".
The box was not inert -- typing into it failed the job. The widget is gone;
graphs saved against the old schema have the value swallowed, not forwarded.
One node drives a radiance server: DaSiWa-style structured prompts, all
five tasks (t2va/i2va/l2va/fl2va/ref2va) with their media sockets, two
LoRA dropdown slots fed from GET /v1/loras mirroring --max-loras 2,
tier+aspect size picking that mirrors the plugin's size law into the node
title, and a live per-step progress line. Placement is a first draft; the
folder is exactly what ComfyUI loads from custom_nodes/.
The reference stretches the first frame to the output canvas, which squashes a portrait
photo pinned into a landscape video (ComfyUI behaves identically). Optional per-request
first_frame_mode: "stretch" (default, the reference's own resize) or "center" -- the
already-implemented cover-crop, previously used only for the last anchor: aspect kept,
the canvas centre-cropped. The latent grid stays the exact target canvas either way, so
pinned rows are unaffected; anything else is refused naming the field.
A waiting client had only job.progress (the steps' share of 0..90) and no
pace, so a long render looked like a hang. The job's thread now emits one
RAD_INFO per STEP -- step N/M, mean s/step and an eta, measured from the
first step's arrival on the steady clock so queue and encode time do not
inflate it -- and the video object carries steps_done/steps_total while it
runs (absent until the first step lands, so a queued object is unchanged).
The rate is a mean across the job; a latent upscale's small steps are
quicker than its refine steps, so the eta is a mean's guess -- the
completion line's breakdown stays exact. videos_test asserts the tally
reaches the finished object (the fake generator lands two steps).
At decode and verify sizes (up to 64 rows) the delta net's a|b projection (gemm_nt, N = 48) is
nearly all launch cost and reads only the norm's output, as the in-projection does: it runs on the
second lane beside the in-projection and is joined back before the convolution reads `ab`. A
prefill chunk keeps one lane: there the projection is real work and the lanes would split the
bandwidth the in-projection uses. An opt-in (GdnFP8::ab_lane) set by qwen35_fp8 only, whose second
lane carries no collectives: +1.1 % one stream without speculation (three rounds each). The same
for k and v beside q|gate in the gated attention was measured and left out (-0.7 %: q|gate is a
full-bandwidth GEMM and they compete).
It costs memory: naming the two buffers concurrent gives the arena a second scratch region and the
bring-up a third queue (Qwen3.8-27B at TP2: arena 534 -> 604 MiB, queues 67 -> 100 MiB a card, KV
752k -> 746k tokens).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Twenty turns of a transcript that outgrows a 32 768-token ring, streaming off
against --kv-resident, a fact planted at turn 2 asked at turn 20; the off arm
must hit the cache and the on arm must stream, or the run is not a reuse test.
Beside another server on the same card the lane-1 read costs more than it gains: the card has
fewer hardware queue slots than the two servers have queues, and the join puts a queue switch
into every decode step.
From arch/gemma3's G3Linear: int8 codes with a bf16 scale per [1 x 128], gemm_nt_q at i8a8
over quant_act_i8g (an activation scale per row and 128 columns). Gemma 4 E4B's activations
carry channels 40-200 times the row median; one int8 scale a row costs most of w8a8's KL
(wikitext-2: w8a8 0.076, i8a8 0.010). q|k|v stay one GEMM; the fused junctions stay off.
New models:
- Fish Audio drama-3: speech with speaker tags and inline direction, voices cloned from reference
clips (the `references` field of /v1/audio/speech and the streaming session), two cards
- Gemma 4 E2B/E4B (KV-shared layers, per-layer embeddings, clipped vision linears), with
NVIDIA-Nemotron-3.5-Bolt-E4B in bf16 with DFlash and vision on one card, and E4B recipes
Speed:
- MXFP4 GEMMs for one to 64 rows and a tiled prefill GEMM at TN=4 from 1024 rows: the 27B MXFP4
with DFlash2 decodes about 1% faster at c1, 5% at c4 and 14% at c16
- The fp8 and int8 LM heads read their weight once for 65 to 128 rows
- A prefill step of one sequence runs in two pieces on a second lane at two ranks (qwen35_fp8,
gemma3): a 45K-token prompt on the 27B fp8 in 15.1 s instead of 16.2 s
- Gemma 3's fused all-reduce junctions also under a lossy wire
- --draft-short-from N: a block drafter runs its shorter block from N decoding sequences on
(off by default; with 8 on the 27B MXFP4: c8 +12%, c16 +18%, c64 +32%, c1 unchanged)
- --tp-attn-split rows: GLM-5.3-Flash's MLA attention split by rows over the ranks, 18 to 21%
faster prefill; lossy, `heads` stays the default
- --draft-coupling on: Qwen3.8-Flash-Next's MTP drafter samples its proposals from its reranked
top-8 and the target's draw is coupled to it; pays at high temperatures (c1 at T 1.0: 155 ->
178 tok/s), costs at low ones; off by default
Features:
- Edited prompts on windowed models (Gemma 4) reuse their prefix: periodic window snapshots, and
snapshot-backed prefix KV kept across recomputes (an edited tail on Gemma 4 31B: 96 s -> 2.6 s)
- DELETE /sessions/<label> and DELETE /sessions?id=<id> forget one stored conversation
- --state-cache-dtype f16: the delta-net state cache at half the memory (qwen35 plugins; lossy)
Fixes:
- A browser's CORS preflight allows DELETE
Changes: Plugin ABI 27: out-of-tree plugins must be rebuilt. The environment switches the PRs
added are flags now (--tp-attn-split, --draft-coupling, --state-cache-dtype).
A one-frame media -- a reference picture, or an endpoint keyframe -- never
shrinks through the temporal downsamplers (1->1->1->1 against a full clip's
17->17->9->5), so it rides every level alone, and a keyframe must ride the
TARGET canvas: it is resized to the output resolution before the VAE and its
latent rows share the target grid. The deep level buffers only held a full
clip's shrunken temporal volume, which capped a single frame at 5*256^2
(~572-sided) -- 480x736 was refused, 544x736 had died the server with
'venc.l3.in 6256>5120' before cont.36 added the accept-time 400.
declare_venc now sizes each level's rows as max(full clip, kEncOneFrames)
frames at the tile side, kEncOneFrames = ceil(1344*768 / 256^2) = 16, so a
single frame is bounded only by the model's whole canvas (16*256^2 >=
max_area); venc_geom applies the same max() per volume. Multi-frame media are
unchanged (the pixels volume still forces sides <= 256). Levels 2-5 grow
(R 36864->65536, 5120->16384, 1280->4096, 192->1024): about +150 MB arena,
plugin-only -- no kernel, ABI, or container change; the driver's accept-time
check delegates to the plugin export and follows automatically.
Wikitext-2 KL against the HF bf16 reference: bf16 0.0015, w8a8 0.076, w4a8 0.242 (attention and
layers 19-23 int8, feed-forward int4; all int4 is 0.612).
As the reference (Gemma4Model.forward) the token-identity lookup of a multimodal placeholder is the
pad token's row; the context projection reads the scattered image rows.
Gemma 4 E2B/E4B clamp every projection input and output of the tower to bounds the checkpoint
stores. Nine clamps a layer around the fused q|k|v and gate|up GEMMs (the fused parts share
their bounds in NVIDIA's E4B).
A global class with its own v projection (attention_k_eq_v false, Gemma 4 E2B/E4B) named its row
attn_qkvs like the sliding class, and the second declaration failed at w4a8.
The token-identity table embed_tokens_per_layer (scaled by sqrt(n_ple)), the context projection
of the scaled embedding with its per-(token, layer) norm, combined (ctx + tok) * 2^-0.5; in each
layer after the feed-forward add: gate, gelu_tanh times the layer slice, projection, norm, add,
then the layer scalar. With fused junctions j_ma closes the PLE branch instead of the
feed-forward. One rank only.
From layer n_layer - num_kv_shared_layers on, a layer has no k or v projection and attends over
the cache of the last earlier non-shared layer of its class (transformers store_full_length_kv).
Shared layers are not bound to a KV group, so pages count only the layers that write. A null
num_global_key_value_heads falls back to num_key_value_heads.
When a stateful model's cached prefix is host-resident and another request recomputes shared tokens without restoring that entry, PrefixCache::insert can replace KV still referenced by an older recurrent checkpoint. Preserve the first cached copy for snapshot-backed prefixes regardless of tier, while retaining rebinding behavior for non-stateful caches.
Add a regression covering a recomputed shared prefix, the original host copy, and its recurrent snapshot.
Tests: `ctest --test-dir build-gfx1201 -L '^fast$' --output-on-failure --parallel 24` (96/96 passed).
The pins came from the whole series (with the gated fold and the a|b lane); this PR alone pipelines
the 4096-row budget's step to another graph, and with the pipeline off the build is upstream's serial
one, whose pin the off case now checks (main's 0x36da8d762194e24e / 0xe4022daff02ec8bd).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The parts of the series' review rounds that concern the pipelined prefill and the second lane,
carried over when the series was split:
- qwen35_fp8: a trunk whose norms write rotated int8 codes (qwen35_w8a8 where libr4d serves the
`_had_quant_i8g` forms) prefills serially -- the boundary norms on the second lane issue the E4M3
pair only, and before the fix libr4d refused them for the int8 op, failing every one-sequence
prefill step of 1024 rows or more; a pipelined step whose bounds have no storage fails the step
rather than falling back on one rank only.
- The three- and eight-rank overlap all-reduce rows accept every tunable pin their wide rows accept
(r4d_selftest checks it).
- rad_builder.h: the window joins lane 1 into lane 0 at its end only, so an op declared before it
must not be issued again while lane 1 has work pending.
- tests: arch_test for the w8a8 trunk; plugin_test's lane-row comment.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The three- and eight-rank `overlap` rows (ar_twoshot_3rank_exact_lane, ar_twoshot_3rank_ti8_lane,
ar_twoshot_8rank_exact_lane) took the four-rank lane rows' narrow launch for every collective a plugin
issues beside compute: qwen4exp's --prefill-span, gemma4's prefill trunk overlap and the image and
video plugins' second-lane collectives included. That changed a default above two ranks without a
measurement, and a narrow grid can lose there too: where the all-reduce is the longer of the two (a
large message, slow or shared links, seven peers to feed at eight ranks) the step waits on a slower
collective. They now launch exactly as the wide rows by default (tArTs38Lane holds tAr's defaults: the
same grid, the same bits, the same time); R4D_AR_LANE_3_8=1, read once at load, gives them the
four-rank lane's four blocks of 1024. The bits are the same either way.
r4d_selftest checks the defaults both ways (failed before the change: nblocks 4 where the wide rows'
rule is 0). GUIDE §4.7 (with what to set and what it may gain or cost), §4.5, the environment table,
OPS, TP3 and libr4d/README say it.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
rad_buf_concurrent held a buffer for the whole program because the planner cannot tell when lane 1
runs. An architecture whose lane-1 work lies in one stretch of its declared ops now declares it, and
its concurrent buffers live across that window and their own uses, so the drafter's and the heads'
buffers share their bytes again. Ctx holds it: an op on lane 1 outside the window fails the step by
name, and the first lane-0 op past it joins lane 1 first when work is pending there. qwen35_fp8 and
gemma3 declare it from the embedding's all-reduce to the final norm. Qwen3.8 + DFlash2 at 64
sequences with speculation: activation arena 633.99 -> 526.32 MiB a card, upstream's exactly (with
the second lane's own scratch region, KV 86208 -> 93856 tokens against upstream's 95520).
arch_test's fake builder applies the window too, so the pinned steps check every plugin touches its
concurrent buffers only inside it.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A program naming a buffer to rad_buf_concurrent got two scratch regions of the program's largest kernel
scratch each, though by Ctx::lane1_ rule 3 an op on the second lane touches only rad_buf_concurrent
buffers. Program::scratch_bytes_lane1 is the largest device scratch of such an op (or one naming no
transient buffer); the Arena takes per-region sizes, arena_plan_bytes counts them for the VRAM budget,
and Ctx::issue refuses a larger lane-1 request by name instead of overrunning the region. Qwen3.8 with
its drafter: region 1 0 B instead of 50 MiB (17 MiB without speculation).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
dflash_src ([max_tok, n_taps * n_embd], 100 MiB at a 2048-row chunk) was written on lane 1, so it
had to be a rad_buf_concurrent buffer, held for the whole program. Each piece of a tap layer is now
copied on lane 0 right after lane 0 has waited for that piece's feed-forward boundary, before
anything writes those rows of x again. Same copy, same bytes (pinned steps unchanged); qwen35_fp8
and gemma3. On its own it does not move the activation arena's peak, which other concurrent buffers
set; it is one buffer fewer for the second lane's window (next commit) to bound.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Independent review of fa118d8 / 14fb72c: no defect. Notes taken:
- RADIANCE_PREFILL_PIPELINE takes 1 / true as on and 0 / false as off (the old per-arch switches
took 0 for off; such a value must not leave the pipeline on); the header says that past two
ranks only the two-shot band is narrow and that eight ranks pipeline on the exact wire only; the
note says the switch allows the pipeline (gemma3 may still turn it off); "rad_arch.h" as the other
common headers include it; comment lines rewrapped.
- plugin_test resolves the all-reduce at `overlap` 1 against the real libr4d: the two-shot band
takes the lane row at three, four and eight ranks, exact and ti8; the one-shot band keeps the wide
row. arch_test: every spelling of the switch, off at two ranks in all three; no three-rank arch
case (neither test model's heads split three ways, nor do the real models' KV heads).
- r4d_selftest: gemv_wide's two column tiles at four row tiles and on the per-row scale.
- r4d_selftest: every timed pass is preceded by an untimed one. A fresh process otherwise times its
first pass while the clocks ramp up from idle (up to 1.5x slow, +-30 % between runs); two builds
of the same machine code read 13 % apart until both warmed.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- One switch for qwen35_fp8's and gemma3's pipelined prefill, RADIANCE_PREFILL_PIPELINE=auto|on|off
(arch/common/rad_prefill_pipe.h), in place of RADIANCE_QWEN35_PIPE / RADIANCE_GEMMA3_PIPE. auto
(or unset) pipelines at two ranks, where it is measured; on also at three, four and eight, with a
declare note that it is not yet measured on such hardware; off never. Another value is noted and
taken as auto.
- libr4d: the narrow `overlap` all-reduce rows at three and eight ranks, as the four-rank ones are:
the wide two-shot rows' entry points (exact at three and eight, ti8 at three) at tArTs4Lane's
launch, so the collective beside the other piece's compute does not take the card (a wide one
slows the GEMM beside it 1.45-2.1x and ate the whole gain at two). Bit-identical to the wide rows
by construction; neither launch is tuned on three or eight cards, which this rig does not have.
arch_test: at four and eight ranks a 2048-row step of one sequence is serial unless asked; asked,
it runs in two pieces on every rank with every collective on the second lane at `overlap` 1 and
the embedding's whole (failed before the change: the step stayed serial).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The pipeline is decided before the blocks are declared, the fused fp8 junctions only after them.
Where those then did not resolve (no rmsnorm_quant_fp8, a mixed container), every q|k|v and
gate|up still read the shared pair as a shared linear with no quantiser, and the serial fallback
read whatever the last writer left there. The pair is now handed to each such linear as the
target of its own quantiser (G3Linear::q8_into / s8_into): the fused junctions write it when they
resolve, the unfused step's quantisers otherwise.
- a note says why the pipeline is off when declare turns it off;
- a missing bounds buffer fails the step on both ranks (rad_step_fail) instead of one rank
falling back to the serial step alone.
arch_test: with rmsnorm_quant_fp8 refused at two ranks and 2048 rows the step is serial, every
q and gate|up quantises into the pair it reads (failed before: no quantiser).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
qwen35_fp8's pipelined prefill on Gemma 3's MXFP4 trunk at two ranks: every block runs a piece
at a time on lane 0 (the attention over its own query bounds and positions, the GeGLU MLP), and the
work between two blocks a piece at a time on lane 1 -- the block's all-reduce at `overlap` 1, its
post-norm and the fp8 junction (the add and the next norm with its quantiser), after the last block
the add, the DFlash2 taps and the final norm. RADIANCE_GEMMA3_PIPE=0 turns it off.
- Every q|k|v and gate|up reads one shared E4M3 input pair under the pipeline (the junctions write
it), so the second lane's buffers cost one pair, not one a linear (rad_buf_concurrent keeps them
live for the whole program).
- A window KV group's seqused counts from its rebased first block, so the first piece's cannot be
its position: it is the group's seqused less the second piece's rows, computed on the card by a
new libr4d op, sub_i32 (y = x - s[0], int32; documented in OPS.md, a selftest case). The first
try used the position and faulted on a 12k prompt past the 1024-token window.
- G3Linear and G3JunctionFP8 row-sliced forms; each block's overlap all-reduce.
Bit for bit the serial step: TranslateGemma's KL recordings at chunk 2048 and one sequence a step
(so a document's steps from 1024 rows pipeline) compare equal with the pipeline on and off. Prefill
on two R9700s, chunk 2048: 6k tokens 1.27 -> 1.21 s, 12k 2.48 -> 2.42 s; at chunk 1024 (pieces of
512) no gain, so a deployment wants 2048 (against 1024: -9 % / -7 %). arch_test: a 2048-row TP2
step runs in pieces with its collectives on lane 1 and the shared pair; RADIANCE_GEMMA3_PIPE=0 runs
it serially.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- pipe_ready: past the batch's and the build's own conditions (the same on every rank), a
rank-local failure -- no pinned host memory for the bounds table, or its copy failing -- now
fails the step instead of running it serially. A serial step on one rank beside a pipelined
one on the other issues different collectives on the shared all-reduce instance: a hang or a
wrong sum.
- declare frees the previous build's pinned bounds table before resetting the model.
- NormQuantFP8: the slicing comment back above step(); step_plain() gets its own.
- r4d_rows: the TN axis's help text says the new crossover (M >= 1024).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
At two ranks a prefill step of at least 1024 rows is cut into two pieces of about half
(pipe_rows: rounded up to 64, both in the whole step's band). Every block runs a piece at a
time on lane 0; the work between two blocks runs a piece at a time on lane 1: the block's
all-reduce at `overlap` 1 (the narrow lane rows), then the next block's plain norm, and after
a feed-forward that keeps its add, the add, the DFlash2 taps and the final norm. The fused
all-reduce + norm is not used there: it holds its blocks while waiting on the link and slowed
the GEMM beside it by a third (measured: no gain at all with it).
- GdnFP8, AttnGatedFP8: takes_pieces(); the dense attention gets a two-piece path (each piece
its own rows, positions, slots and query bounds, seeing the cache up to its own end), and
the delta net's piece path takes the caller's normed input (ArPieces::in_ready) and passes
each piece its own context length (positions + r0), so a prompt's first chunk works.
- MlpFP8: slice() split into body() and tail(), and an overlap all-reduce (issue_ar).
- NormQuantFP8::step_plain().
- M-RoPE batches (the vision tower loaded) take it when no token's components differ: plane 0
of rope_pos is then every token's position.
- RADIANCE_QWEN35_PIPE=0 turns it off; a wide prefill step that runs serially says why, once.
Bit for bit the serial step: Qwen3.8-27B KL recordings (k6_v4, wht6) compare equal with the
pipeline on and off, and greedy answers to three long requests (680-41k tokens, speculation 3
with the DFlash2 taps) are identical. 41k-token prefill on two R9700s: 9.00 -> 8.41 s with the
TN crossover of the next commit (-6.6 %). arch_test: the two-rank pin moves; new tests pin the
serial build under RADIANCE_QWEN35_PIPE=0 and the pieces, lanes and overlap of a wide step.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A fresh process otherwise times its first pass while the card's clock ramps up from idle: up to
1.5x slow, and two builds of the same machine code read 13% apart until both were warm. Numeric
cases for gemv_wide's two column tiles a block at four row tiles and on the per-row scale.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The parts of the series' review rounds that concern these rows, carried over when the series was
split:
- gemm_mxfp4a8_decode: the 64-wide slab is chosen by the split the launch runs (a pin or a tuned
point included), as before the register kernel; the header states the split-row bound the rule
applies (ks*M = 1024).
- r4d_selftest: the priority order of the MXFP4 rows is checked (gemv / gemv_wide over decode,
decode_shortk over gemv_wide, decode over tiled); gemv_wide's numeric cases at K 256 and at 56
rows; the M-invariance check names the decode_shortk corner it does not cover.
- Comments: gemv_wide's two-tile condition (N >= 4096, K >= 3072, an even tile count), the
decode_shortk corner's bit change at M = 33, decode_shortk in the list of rows whose state is
keyed on the output.
- libr4d/README.md: the rows by row count, with the measurements behind each band;
docs/TOOLS.md: r4d_selftest and its --perfmxd mode.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Since 1.9.0 --perfmx times the MXFP4 expert GEMM (M, experts, top_k, skew). The dense rows timing
added in this series had taken the same switch and, parsed first, shadowed it.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
gemv_wide's blocks hold three or four row tiles over the whole K, so on a short K the cross-wave
reduction of a block outweighs its WMMAs, and on a wide N there are many such blocks. Swept over 24
per-rank shapes (Qwen3.8 and TranslateGemma at TP1/2/4/8, 1B/4B/8B-class dense) at 24..64 rows, each
row timed alone: gemv_wide is at least upstream's decode kernel everywhere except N >= 8192 with
K <= 2560 past 32 rows, where it lost by 7..30 % (19456 x 2560 at 64 rows 131.8 us against upstream's
104.5; 16384 x 2048 92.8 / 76.1; 9728 x 2560 74.1 / 67.4). This decode kernel takes that corner:
93.3, 68.6 and 52.5 us. A row of its own (same entry, scratch hook and tunables as the decode row,
priority 59, constraints M 33..64, N 8192..36864, K <= 2560) rather than a rule in the gemv entry,
so the planner's choice stays a table lookup. Narrower N stays with gemv_wide (5120 x 2176 at 40
rows 39.2 against 52.8), as does every shape of the models we serve. r4d_selftest: five numeric
cases over the corner, both activation grids and parts.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The rule was tuned with the weight staged through LDS. Past 64 rows (the multi-fragment register
kernel) it now takes the 128-wide slab always and splits K only while every split keeps 16 slabs,
towards a 48-block grid or, at K >= 8192, regardless, up to ks*M = 512 split rows. Swept every
split 1..8 at both slabs on Qwen3.8-27B's and TranslateGemma-27B's per-rank shapes at 96 and 128
rows (warmed); old against new rule, two repetitions, 80 / 96 / 128 rows:
17408 x 5120 161 / 187 / 215 -> 161 / 175 / 197 us
5120 x 8704 105 / 116 / 160 -> 110 / 116 / 149
6144 x 5120 83 / 97 / 105 -> 80 / 87 / 109
5120 x 3072 71 / 79 / 67 -> 55 / 60 / 69
21504 x 5376 192 / 207 / 228 -> 187 / 200 / 217
5376 x 10752 133 / 155 / 197 -> 132 / 154 / 184
Up to 64 rows the rule is unchanged. A different split changes a split row's summation order, so
these rows' bits move within the selftest's bound (gemm_mxfp4a8_decode: 86 ok).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Measured on smaller models' MXFP4 shapes (r4d_selftest --perfmx, clocks warmed, two repetitions),
two tiles a block lose on narrow or shallow weights -- fewer blocks than the part has units, a
short K a wave: at 32..64 rows 1024 x 2048 +7..30 %, 2048 x 2048 +6..28 %, 2048 x 4096 +4..37 %,
6144 x 1536 at 32 rows +14..30 %. From N 4096 and K 3072 every measured shape gained or held
(4096 x 2048 even; 14336 x 4096 at 64 rows 120 -> 90 us; 4096 x 7168 67 -> 55; the 27B shapes as
before), so the launcher takes two tiles there only. Bits unchanged either way.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Independent review of 675322e: no defect (the double buffers, the ratio timing against the old
kernel including a split starting mid-block and the 64-wide slab, the clamped tile, the empty
split; every variant without spills inside its waves budget). Notes taken:
- the slab rule's LDS formula was the LDS-staged kernel's; say so, and that the DTM 4 arm may no
longer pay (not re-tuned);
- mxd_ratio's comment describes when each kernel publishes the ratio;
- gemv_wide no longer instantiates two column tiles at one row tile (unreachable: two tiles need
more than 24 rows);
- a comment line over 100 columns.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Bit for bit as before, faster where several streams speculate (25 to 128 rows a step):
- gemm_mxfp4a8_gemv_wide carries two 16-column tiles a block from 25 rows. The activation is read
per block, so one tile a block read all of it N/16 times -- 356 MB from L2 at 64 rows on a 27B's
17408-row gate_up, against a 47 MB weight. Each activation fragment now serves both tiles; a
tile's WMMA chain is unchanged. Four tiles spill past 32 rows.
- gemm_mxfp4a8_decode's multi-fragment kernel (17..128 rows) loads each wave's weight words straight
to registers, as the gemv kernel does (a fragment-order word is the WMMA fragment's register), and
double-buffers only the shared activation in LDS: one barrier a slab, the next slab's loads in
flight across this one's WMMAs. Same fold, k-step and slab order, scale carry and epilogue; its
whole output compared byte for byte with the LDS-staged kernel's on Qwen3.8-27B's and
TranslateGemma-27B's per-rank shapes at 17..128 rows, both scale grids, the 64-wide slab, parts
and forced splits (312 cases, an experiment-only selftest case).
r4d_selftest --perfmx with the clocks warmed (a first timed pass from an idle card catches them
ramping up and read up to 1.5x slow), before -> after:
17408 x 5120 32 rows 125 -> 85 us, 64 157 -> 122, 96 205 -> 159, 128 245 -> 214
5120 x 8704 32 rows 75 -> 56, 64 95 -> 75, 128 169 -> 139
6144 x 5120 64 rows 70 -> 57, 128 121 -> 92
21504 x 5376 32 rows 154 -> 111, 64 183 -> 150
5376 x 10752 32 rows 105 -> 68, 64 123 -> 98
At 16 to 24 rows within a few percent either way (unchanged kernels there).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The WMMA form takes up to four 16-row tiles a wave: each weight word of a chunk is loaded and folded
once and multiplied with every tile's activation fragment, so the weight streams once from DRAM to
registers whatever the row count, with no LDS staging. A row's sum is its tile's WMMA chain alone, so
its bits are the same at every tile count: the first row is bit-identical from M = 1 to 64 (selftest),
across the gemv row (M <= 8) and the new gemv_wide row (9 <= M <= 64, K % 128 == 0, same entry and
priority). Several streams with speculation land there (4 x (1 + 7) = 32, 16 x (1 + 3) = 64).
--perfmx against the decode row that served 9..64 before (us, Qwen3.8-27B / TranslateGemma per-rank
decode shapes): down 51-80 vs 56-105, ssm_out 27-42 vs 30-55, attn_qg 40-63 vs 44-74, TranslateGemma
down 61-97 vs 66-123, o 22-35 vs 25-51, gate_up at 24-48 rows 110-141 vs 145-170; gate_up at 48-64
rows about even (Qwen) or behind (TranslateGemma at 64, 171 vs 153).
Selftest: gemv_wide at RT 2..4, both activation grids, a partly live tile, parts; the M-invariance check
runs the wide row under the gemv row's selection (mxfp4a8_numeric's any_row).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
One stream's decode (M = 1 + the draft depth) is a pure weight stream; the decode row stages the
weight through LDS and leaves narrow projections at a third to two thirds of DRAM bandwidth. The new
row (priority 58; M <= 8, K % 64, N % 16; the same packed weight bytes as every MXFP4 row) keeps the
weight in registers: WMMA from register fragments when K % 128 == 0, v_dot4 otherwise. The form and
the wave count per block depend on K alone, so a row's output bits do not depend on M (a verify
step's first row equals the plain decode of it). The scale and reference planes must be 4-byte
aligned.
Selftest: every reachable instantiation (both forms, both activation grids, M = 1..8, tile counts
divisible by 4, by 2 only and odd, parts), the output prefilled with NaN, an odd column stride, and
the first row's bits against M for gemv and decode. --perfmx times the MXFP4 rows at one shape.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Treat tip-only as a true opt-out from periodic window snapshot creation and interval chunk splits, while retaining the existing tail snapshot and explicit request checkpoints. Leave recurrent-state scheduling unchanged and report the effective chunk bound accurately.
Cover geometric-backoff and keep-all interval behavior, tip-only chunk planning and single-snapshot reservation, aligned and short prompts, explicit checkpoints, and recurrent-state scheduling.
Keep intermediate window snapshots as well as the prompt-tail snapshot so a tail edit can resume below its divergence instead of re-prefilling the entire matched prefix. Reuse the existing checkpoint retention policy and preserve the pre-template-divergence tail boundary.
Add scheduler and cache regression tests for interval snapshots, aligned prompt tails, constrained chunk budgets, and edited-prefix lookup. Update the geometry report and guide to describe periodic window snapshots.
The ref2va heads are the vae/ and audio_vae/ encoders, in every pipeline
directory since the ref2va release -- what a T2VA-era container lacked was the
plugin's declare, not the weights. A reuse with nothing marked changed converts
only the never-declared head weights and copies the rest where they are; the
w8a8 recipe adds that a reuse under it re-quantises the DiT linears on the way,
since a weight copies only at the same encoding.
minimax-h3-dasiwa-fp8.recipe is minimax-h3-fp8.recipe with the modulation rule
dropped -- the same one-line delta minimax-h3-dasiwa-w8a8.recipe carries for the
int8 line. A curve-form checkpoint reads its ada as K=8 table GEMMs, which no
128x128 block quantiser can serve, so the plugin declares those weights plain
bf16 and the recipe must leave them as the checkpoint holds them.
1.11.0 runs a block drafter on the card only (issue_block_drafter). Engine::block_shape chooses the block
and the proposal count a step runs: the drafter's own, or its short block from --draft-short-from
decoding sequences on, off again two below. The card's query pass runs that block, ADV_BTAKE takes that
many proposals from the front of each row at the drafter's pitch, and the step issued ahead verifies
that many (expect_draft and finish_block_drafter read block_steps_). sched_test runs the card driver's
sequence at DFlash2's short block (4 rows, 3 proposals) against the host's reference.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
RadDrafterDecl::proposal_pitch defaults to depth for a block drafter and is refused below it (the
short block fills a row's front). arch_test: the qwen35 family's pins now that DFlash2 declares its
short block.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- declare_drafter: a block drafter's proposal_pitch, now the row pitch the engine reads row s
at, defaults to depth (it defaulted to 1, which a pitch-reading engine would take as packed
rows: wrong drafts from the second sequence and a read past the readback) and is refused
under depth. The engine's fallback goes.
- run_block_drafter: hysteresis -- the short block goes on at --draft-short-from decoding
sequences and off only two below, so a load wavering at the threshold does not switch the
block (a new pass shape, the adaptive estimates) every step. Comment: the proposals are for
the next step.
- block_begin's comment: after a long block a short one's reservation stops short of the trunk
step's end; the rejected rows past it land on freed pages with slot -1, which every kv_store
drops. Named as the load-bearing rule it is.
- The --draft-short-from warning names a serial head as such; the arch_test stub returns the
real builder's codes.
- build_test: the pitch's default and refusal.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A block drafter proposes its block whole, so the block's length is paid for every drafting
sequence whatever each verifies. At one sequence a long block pays: Qwen3.8-27B + DFlash2
(block 8, --draft-window adaptive) decodes one stream 135 -> 155-165 t/s against block 4. At
sixteen it does not: block 8 750-790 t/s, block 4 900, its drafter rows and weaker first
positions costing more than the extra drafts bring. --draft-window adaptive alone cannot help,
since it only shortens what each sequence verifies.
- rad_drafter_short_block(b, block): additive export (RAD_ABI_VERSION unchanged); the plugin
declares that its query pass also runs at `block` rows a sequence. Builder validates it
(block drafter, shorter than its own, still proposes).
- --draft-short-from N (default 0 = never): the engine stages the short block once N sequences
decoded in the step just run (Scheduler::decoded_seqs).
- The engine reads the proposals at the drafter's declared row pitch, not at the step's count:
dflash_select writes row s at s * pitch, and a short block fills only a row's front (with the
pitch read as the count, every sequence but the first got the wrong tokens).
- Dflash2: a short block of 4 rows (depth 3) wherever its own is longer: its own convolution and
selector ops at that block (every other op is per row); the query pass picks by T / n_seq and
fails the step on a block it has no ops for. qwen35_fp8 and gemma3 declare it.
- Tests: build_test (the declaration's checks), arch_test (the qwen35 family's short query pass
runs the short ops, a block without ops fails the step; the DFlash2 pin moves), config_test.
Measured (Qwen, speculation 7 adaptive, short block from 4 sequences, against production's
speculation 3 fixed): one stream +15-20 % (kratky) / +9 % (syslog), 4 streams +3 %, 16
streams equal (915 / 906 t/s).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
libr4d's recurrent update and chunk scan already read the state's width off the cache; the plugin
declared it f32 unconditionally because f16 changes the generated text. A deployment may now trade
that: RADIANCE_GDN_STATE_F16=1 (exactly) declares the cache f16, anything else keeps f32, and the
declare log says so. The default does not change.
Lossy. Qwen3.8-27B (MXFP4, TP2), mean KL against the bf16 reference, f32 -> f16:
- k6_v4 KV: chunk 2048 0.040238 -> 0.040005; chunk 64 (the state stored and rounded every 64
tokens) 0.039607 -> 0.040468, top-1 94.07 -> 94.00 %;
- fp8 KV: chunk 2048 0.039171 -> 0.039600 (+1.1 %), chunk 64 0.039327 -> 0.039690 (+0.9 %).
It halves the state pool, its host checkpoints and the state's traffic, which grows with the
decoding sequences. Decode on two R9700s, greedy, three rounds (medians, tok/s, f32 -> f16):
- no speculation: 1 stream 67.1 -> 67.5 (+0.6 %), 4 246.8 -> 253.3 (+2.6 %), 16 708.0 -> 779.5
(+10.1 %); the rounds agree to a tenth;
- speculation 7: 1 stream 222.2 -> 215.1 (-3.2 %), 4 636.9 -> 621.0 (-2.5 %), 16 1223.8 -> 1276.7
(+4.3 %); f16 also changes which drafts the greedy text accepts, and the text and the step were
not separated.
So it is for many concurrent sequences where the KL is acceptable. GUIDE §4.4 has the tables.
arch_test: the state group is f32 unset, at "0" and at "yes", f16 at "1".
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
New models:
- GLM-5.3-Flash reads pictures: its vision tower and processor (--image-tokens sets the budget),
with decode kernels for a few rows and the DSA indexer split over the ranks
- Sage-A1.5 (fp8 and MXFP4) with its vision tower and a DFlash2 drafter
- Unlimited-OCR (bf16)
- Gemma 4 31B with z-lab's DFlash and RedHatAI's DFlash2 drafters; at four cards its all-reduces
are fused with the junctions, overlapped with the compute and sent compressed
- Ornith-1.5-35B-A3B w4a8 compose files
Speed:
- Block drafters (DFlash, DFlash2) accept their drafts on the card, and the next step is issued
ahead
- The four-rank all-reduce is faster for every --tp 4 model
- qwen35_w8a8: the norms and SiLU write the int8 linears' operands directly
- --attn-prefill-fp8 off|qk|pv|both: fp8 QK and PV legs for the h256 prefill attention (about +20%
prefill on a 221K-token prompt for the 27B MXFP4 at TP2); lossy, off by default
Features:
- Control vectors: --control-vector off|on|disabled (disabled by default), a per-request switch,
and the published Qwen3.8-Flash-Next refusal-direction vector (its license is in NOTICE)
- Krea 2: the `rebalance` request field, as ComfyUI's ConditioningKrea2Rebalance
- Cards with a small PCI BAR run, with kernel arguments kept in host memory
- Dashboard: live acceptance figures; statsdump rotates its file at a size cap
- KV caches every rank holds whole (GLM-5.3's latent and index caches) take one host-tier slot
Fixes:
- Long conversations taking turns no longer fall back to an early snapshot: a host-tier restore
makes room as memory pressure does and waits a step for the previous turn's release (two
conversations of 142K and 147K tokens sent back to back: 31.3 s per turn before, 2.8 s now)
- Kernels before Linux 6.16 (amdgpu below 3.64) no longer hang at startup: virtual memory
management is turned off there, with a warning
- Gemma 4 dense scales its token embeddings as Hugging Face does (bf16), which changes its output
- The four-rank all-reduce fences prefill-sized messages, for a rare divergence after a fresh start
- GLM-5.3: every refusal names the setting and the reason; its template keeps string content
- Several pictures in one request no longer refuse processors that take one image at a time
Changes: Plugin ABI 26: out-of-tree plugins must be rebuilt. The environment switches the PRs
added are fixed rules or flags now (R4D_ATTN_FP8 is --attn-prefill-fp8).
The venc_geom cap tested only the pixels volume -- clip * h * w against 17
squares -- but the encoder arena holds five volumes, and the temporal
downsamplers shrink a full clip 17 -> 9 -> 5 while a one-frame clip stays 1:
the deep buffers (5 frames at their side) bind a single frame at
h * w <= 5 * kEncMaxSide^2, a ~572-sided square, not the 17-frame budget.
A 544x736 endpoint keyframe (the workflow-native Flair size) passed the
volume check and then killed the server mid-step: `operand 5 reaches past
buffer 'venc.l3.in': [6256,256] at offset 0, declared [5120,256]`. Check
every volume; the spatial divisor cancels between clip and arena, so the
temporal factors alone decide. 512^2 keyframes, every reference video and
the 256-side pictures all ride exactly as before.
The driver's picture and keyframe branches never asked the encoder at all
(only videos queried rad_arch_encode_geom), so the refusal has to arrive at
accept: probe the geometry for one-frame media and name the size in the
error, instead of a step-time rad_step_fail -- which stops the engine and
takes the server with it.
Co-Authored-By: Claude <noreply@anthropic.com>
The LoRA-runtime refactor moved DenseFP8::declare's `mapped` from a struct
member to a trailing parameter -- the body now gates its map_linear on the
parameter, and rad_builder refuses a COPY name map declared twice. minimaxh3
kept setting the (now-ignored) member, so every full-form container died at
boot on `name map for 'dit.blk.0.ada0.weight': declared twice`. The ada rows
are mapped by map_rows above for both modulation branches; pass the flag so
declare() reads through that map. Curve-form (adaln_t_table) never reaches
DenseFP8 and kept booting, which is why only the ref2va containers failed.
Co-Authored-By: Claude <noreply@anthropic.com>
The reference workflow moved to MP4 as its default and it plays everywhere, so the
webm/webm-av1 containers, the `format` field and the container-aware writer are
maintenance without a user. This reverts them to the pre-webm shape: core/mm/mp4.{h,cpp}
and the Dockerfile/docs are byte-identical to upstream again (the writer's H.264
runtime-discovery and faststart were always upstream's), the ffmpeg build loses
libvpx/libaom/libopus and the webm muxer, and the runtime image loses libvpx9/libaom3/
libopus0. Input-side webm is untouched: media.cpp still demuxes webm/matroska
references, audio endpoints still accept webm uploads, and the decoder set keeps
VP8/VP9/AV1/Opus.
A `format` in a request is now refused as an unknown field.
videos_test drops the WebM case (and the format echo/caps checks), keeps the refusal;
engine_e2e, video_gen and videos suites pass, mm_test unchanged (pre-existing webp gap).
Co-Authored-By: Claude <noreply@anthropic.com>
Merges upstream 1.10.0 (152 commits: the LoRA acquire/runtime refactor, the
form-1 LTX-2 scheduler family, guidance terms + negative prompts, decoder
selection, input_reference, new architectures) into the ref2va port branch.
Resolution rule throughout: keep BOTH feature sets; ABI numbering follows
upstream (RAD_ABI_VERSION 26, RAD_FORMAT_VER 2), with the port's video fields
unioned into RadVideoGenBatch/RadVideoGenDecl and abi_layout_table.h
regenerated from the live table.
Notable reconciliations:
* videos.cpp: the task grammars are disjoint by capability -- keyframe tasks
(i2va/l2va/flash-attn l2va/fl2va) are recognized only when decl.encodes,
so upstream models keep refusing them as unknown tasks; input_reference,
the LoRA tag/field pipeline, and the guidance/negative_prompt rendering
coexist with refs/ref2va; the prompt put() helper hoisted to block scope
for the media branch.
* video_schedule(): upstream's (steps, video_tokens, refine) keeps its
positional slots; the port's shift_video/shift_audio overrides move to the
tail so upstream's schedule tests call unchanged.
* r4d_selftest conv3d cases: the port's sp/st/causal/down/refl geometry and
upstream's tpad/tpre fold into one reference (ft = causal ? 2 : tpad==2 ?
2+tpre : 1); rms_mod rows keep the port's i8/fp8 quant modes alongside
upstream's wadd/norm_once/norm parameters.
* tests/oot_plugins.sh: the per-plugin cmake --install gains a --prefix
staging dir -- plugin .so files still land in the absolute
RAD_PLUGIN_INSTALL_HOME, but libr4d now also installs r4d_selftest to a
relative bin/, which needs no root.
Host ctest: 112/113 (mm_test's webp gap pre-exists this merge); r4d_selftest,
engine_e2e, oot_plugins, abi_layout, all LoRA tests green.
Co-Authored-By: Claude <noreply@anthropic.com>
The parity harnesses already honored COMFYUI_HOME; their defaults, and the docs'
provenance references, now use the mock home. No behavior change: export
COMFYUI_HOME (or pass argv) to point them at a real checkout.
Co-Authored-By: Claude <noreply@anthropic.com>
Port GitHub PRs #12 and #13 onto Codeberg upstream main, retaining upstream kernel-chain handling. Include the source Clang target-attribute fixes required by the host build; omit the KFD header workaround and unrelated fork work.
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
b_nout is declared with row width kMaxSegs*2*D, but the cond pass staged it
through bcol_at with a narrower pitch ARGUMENT (ncell*2*D) and the step pass
indexed row (lane,step) with that same narrow multiplier. The runtime strides a
buffer operand by its DECLARED row width, so every staging row past the first
landed beyond the consumer's window: the shift/scale table the rms_mod head
reads was ALL ZEROS for every denoise step after the first. Step 0 aligned by
coincidence (staging row #0 == the cell starts), which is why step 0 always
reproduced and hid this. The heads -- video and audio alike -- then ran
un-modulated at t>0: rms(h)*w*(1+0)+0, silently dropping a scale field of std
0.295 per step, inflating the velocity (measured 2.90 vs reference-math 2.05 at
step 1) and baking the fried look into every render.
Fix: stage and consume b_nout at its declared width, the pattern b_ada/b_modg
already use (block modulation was never wrong -- only the head table was). No
kernel, arena, or ABI change; the shared host issue path is fixed with it.
Proof chain: the nout shadow re-cast AT THE KERNEL'S OWN POINTER (the old one
sampled the declared pitch and lied -- zero_frac 1.0 at step 1 pre-fix) shows
cells matching emb(t)@W+b to 2e-3, modality-correct; torch replay on the device
stream: step-1 velocity cos 0.970->0.9975, device std 2.901->2.065 vs 2.051
reference math; device renders (512^2 6s seed 1234, flair FL2VA + T2VA control,
workflow prompt) read frame-by-frame: fried look gone on every arm, pins force,
bitrate 6.75MB->1.88MB at identical settings.
Kept (R4D_DIT_SEL-gated): per-step dump tagging dit_s{K}_*, kernel-pointer nout
shadow, tvid/tarr schedule dumps.
Co-Authored-By: Claude <noreply@anthropic.com>
Both junction kernels (ar_rmsnorm_quant_i8, ar_rmsnorm_post_quant_fp8) send the exact wire only, so
they were declared only on the exact wire. Since TranslateGemma moved to --tp-wire wht6 (19. 10.,
prefill +50 %) its decode ran every junction unfused -- all-reduce, post-norm and junction, three
launches for one -- although a decode step of a few rows goes out exact anyway (under
--tp-wire-min-kb). Now they are declared at two ranks whatever the wire and taken per step where
ar_wire_is_exact(T); a wider step keeps the lossy all-reduce, unfused. A fused step is bit for bit
the unfused exact one (the kernels are byte-identical to all_reduce).
arch_test: under a lossy wire an MXFP4 trunks decode step folds its junctions all-reduces, a
prefill chunk above the floor does not.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
lm_wmma_kernel held at most four 16-row tiles a wave, so past 64 rows the launcher made passes of 64
and read the fp8 head again for each. With MH = 2 the workgroup's eight waves split into two M halves
of four tiles over 64 weight rows that share one staged tile: Qwen3.8's per-rank head (124160 x 5120)
at 128 rows 3059 -> 1984 us, TranslateGemma's 3242 -> 2036 us; 65..128 rows -33..-39 %, 160..256
-26..-37 %, 64 and fewer unchanged. Same scale blocks, WMMAs and K order per output: the same bytes.
r4d_selftest: the heads' numeric cases at 65..150 rows, --perf times the head up to 256 rows, and
R4D_PERF_ONLY=<row> times one row alone.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Carried from the series' review rounds when it was split: numeric cases for the plain kernel at a
whole row of blocks (TN=4 forced and by the rule from 1024 rows, TN=2 at the 64-wide slab), the
plain kernel's comment, and libr4d/README.md's account of the row with the measurements behind
TN=4 from 1024 rows, the slab-ahead weight load and the thin last row.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The block is 256 rows at every M, so a block the M edge cuts ran its padding rows' WMMAs on clamped
copies of the last fragment (half the only block's math at 129 rows). M whose last row holds 1..160
rows (under 1024 in all) now runs a two-body kernel whose blocks of that row skip the WMMAs of their
fragments past M: same-session A/B over 12 shapes, M 129..160 -8..-20 %, 320..384 -2..-16 % (Qwen
gate_up at 320 rows 402 -> 339 us, TranslateGemma's 513 -> 441). Every other M runs the plain kernel,
whose body declares its own LDS, so its ISA is the old kernel's instruction for instruction: guarding
inside the one kernel cost full blocks 1..15 %, handing the body the LDS by pointer 2..8 %. Per output
byte the fold, the WMMAs and their order are unchanged.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Each slab used to load its weight words and exponents, wait for them, unpack them to LDS and only
then compute, so a DRAM round trip stood in front of every slab's unpack. The words a thread stages
are now loaded into registers right after the staging barrier, a slab ahead, and fly across the
slab's WMMAs (+1 VGPR at TN=4, no spills). Same fold, same WMMA order: bit for bit.
r4d_selftest --perfmx, warmed, at 1024 rows (a pipelined prefill's piece): Qwen3.8 gate_up
804 -> 768 us, down 443 -> 417, ssm_in 396 -> 384, ssm_out 249 -> 231, attention q|gate
306 -> 318; TranslateGemma gate_up 1063 -> 1029, down 651 -> 617; at 2048 rows 0..-4 %. Loading the
A fragments a slab ahead too (+38 VGPRs) was slower everywhere. End to end (three alternating
rounds against the production image): Qwen 41k prefill 8.57 -> 8.28 s (-3.4 %); TranslateGemma 6k
and 12k unchanged at 0.1 s; KL 0.040237.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
TN=4 wins from 1024 rows on (r4d_selftest --perfmx, a rank's weights: Qwen3.8 gate_up
17408x5120 1105.6 -> 1080.8 us, down 5120x8704 618.5 -> 599.1, TranslateGemma gate_up
21504x5376 1395.0 -> 1273.8, its down 5376x10752 793.6 -> 799.6; 1536 rows better on all four;
512 and 768 mixed). It matters to the pipelined prefill's 1024-row pieces and to TranslateGemma's
1024-row chunks. Same bytes: Qwen's KL recording and TranslateGemma's KL (0.054628) unchanged.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A client that deleted a conversation, or compacted it past a prefix, knows the
rest is dead before --prefix-cache-ttl does. DELETE /sessions/<label> (or
?label=, ?id=<engine id>) walks the session's chain from the tip inwards like
expiry: VRAM blocks to the pool, the host copy with them, the session's
snapshots to the store. ?keep_tokens=N keeps the chain's start in whole blocks.
Blocks another stored session shares (the system prompt) and blocks a live
request reads stay and are counted apart; the row is cut at the deepest block
that stayed, so a later release reaches it. A request of the same conversation
in flight is 409. IScheduler::release_session beside reset_prefix_cache,
PrefixCache::release_session over the tiers' session table (find_sessions,
shared_prefix_blocks, cut_session). Counters released{entries,snapshots} on
/sessions and /stats, prefix_cache_released_total{what} on /metrics.
Three host checks of where GLM's MLA split by rows can part from the split by heads:
- the f32-scale E4M3 GEMM gives a run of rows and a slice of columns the whole product's bytes
there, so q_b and o at full width over a rank's rows match the head form's slices;
- a TP8 step of 300 rows: each rank's run, placed as the all_gather places it (rank r's 38 rows
at r * 38, the last 34), lands on its rows;
- row by row on a prefill chunk past the DSA budget, bit for bit against the paired union tile:
the 16-head tile gives the union's first rows exactly and differs from its second rows in
about 0.1 % of their outputs by one bf16 step; the rows kernel differs in about 0.1 % of every
row's outputs, by the same step.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From GlmTp::kSplitRows each rank runs its run of the step's rows (GlmTp::run_of: ceil(T / world)
rows, the last run shorter) through q_b, absorption, attention with all 64 heads
(mla_attn_rows_bf16), expansion and o, and an all_gather of whole runs takes the all-reduce's
place. The latent cache and the DSA selection are whole on every rank, so nothing is exchanged
before the attention; each rank sends its run to seven peers, half the bytes of the two-shot
all-reduce, through the same exchange instance. In a 4096-row chunk at 16k of context a rank's
attention drops from 14.0 to 3.9 ms a layer on the kernel bench. The price is q_b, kv_b and o at
full width on every rank: 120 MiB a layer, 1.29 GiB a card over the 11 trunk layers, and about
0.1 GiB of activations; the MTP layer keeps its heads. The full-width weights are whole views
(RadWeightDecl::source) of blk.N.attn_q_b, attn_kv_b and attn_output, the head form's container
entries, so they take the stored encoding (fp8a8f32, bf16) and need no name map; LinearFP8 gets
`stored` for that, served by its block-fp8 branch only, and LinearFP8::step writes a run of rows
from a given output row.
The head form stays the default, unset or RADIANCE_GLM_MLA_ROWS=0, and declares none of it: that
graph is the one before this change, byte for byte (the pinned hashes). The row form is not
bit-identical to the head form, and GLM-5.3 turns that into a measurable divergence: over a
43k-position KL corpus at TP8 (English prose, German prose, code) the row form scores a mean KL
of 0.033 against the head form (median 0.004, top-1 agreement 93.5 %), with greedy text
unchanged. The projections are not the cause: q_b and o over a rank's rows give the head form's
bytes (r4d_emu), and o summed as eight rank partials in the all-reduce's order
(RADIANCE_GLM_MLA_ROWS=2, a test form, GlmMla::Form::rows_sliced_o) scores 0.032. The
attention's rounding is: the rows kernel parts from the paired union tile in about 0.1 % of
every row's outputs by one bf16 step (the union pairing sums a pair's second row in another
order), and the 16-head tile, which parts in the same share of every second row only, halves the
KL to 0.015. A bit-identical row form would run the union tile eight times a row over its own
group of eight heads, without this kernel's gain, or need a rows kernel with the union's
arithmetic; neither is here, so the form is opt-in.
Measured on eight R9700 at Gen5 links, the same build: a 20k-token prefill 5074 tok/s in the row
form against 4270 in the head form, BetterBench prefill at 22k 4984 against 4151, single stream
181.8 against 180.2 tok/s, eight streams 468 against 454.
glm5next_test declares the block at one to eight ranks and checks the full-width views and their
sources, the fp8a8f32 GEMMs, the gather's bound against the all-reduce's, each rank's operands
at 300 rows (runs of 38, the last 34 at eight ranks) and the head form at 255; the o-slices
form's eight GEMMs and seven adds; the model's counts and the TP8 pin under
RADIANCE_GLM_MLA_ROWS=1 (0x1d378152c40f8834 / 0x82ed1094dbf4b637), with the default pins
unchanged; and the row rule against both formulas it replaced. plugin_test resolves every band
of every op the row form adds at eight ranks against libr4d, with no card.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
An optional `y0`: rows [r0, r0 + rows) of the input land at row y0 of the output instead of at
row r0, so a rank's run of a step's rows can go to a buffer sized for the run. Unset, every
branch issues what it did.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A third mla_attn row, at 64 heads. A workgroup takes one query row and all its heads, four waves
to each group of sixteen, and loads each 16-token key chunk once for all of them, where the
matrix row loads it once a tile of sixteen. The scores are K Q^T, tokens as the tile's rows and
heads as its columns, so a head's running maximum and denominator stay in its lane; the waves of
a group each take a quarter of the latent's dot products and add the four partials in one order,
and the probabilities reach the value product through a permlanex16 swap instead of LDS. The
next chunk's keys are fetched into registers while the current one is multiplied, two barriers a
chunk. A row's bytes do not depend on the other rows of the batch. Under 32 rows the launcher
runs the matrix row's kernel; r4d_mla_rows_pin_form, a test hook, pins the element-wise key load,
32 heads a workgroup, the rows kernel at any row count, or the matrix row's kernel at every row
count (the form a KL measurement needs to tell this kernel's share of a row split's difference).
Measured on gfx1201 (r4d_selftest --perfmla, one sequence past the DSA budget at 16k of
context, 513 blocks): 512 rows x 64 heads take 3.9 ms, 35 TFLOP/s, against 12.3 ms on the
matrix row, and the 4096 rows x 8 heads they stand for in a TP8 prefill chunk 14.0 ms on the
paired union tile. Against the wave row the output stays within the matrix row's tolerance
(max abs 2.4e-4 at 513 blocks).
r4d_selftest checks it against libref at 1 to 33 rows, 32 and 64 heads, every fill and both key
loads, and times it against the matrix row (--case mla_attn_rows_bf16, --perfmla at 64 heads).
r4d_emu_mla runs it on the host against an f64 softmax, its forms bit for bit against each
other, a run of rows against the same rows of the whole batch, and a mixed TP step (decodes, a
verify window, a prefill past the budget, a fresh chunk) split by heads over the matrix row and
by rows over this one, at runs that do and do not divide the step.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A request may ask for Krea 2's twelve text taps to be multiplied by fixed gains
before the text fusion, as ComfyUI's ConditioningKrea2Rebalance (nova452) does at
its defaults: multiplier 4 times the per-layer weights 1, 1, 1, 1, 1, 1, 1, 2.5,
5, 1.1, 4, 1. `rebalance: true` on /v1/images/generations (JSON or form) sets
RAD_GEN_COND_REBALANCE in RadGenBatch::cond_opts, appended in ABI 26; the plugin
then scales each tapped layer's rows into te.h2 with chan_affine (f32, rounded
once) and scatters those instead of te.x, so the residual stream is untouched.
Without the field every pass issues exactly what it did before; other models
ignore it.
The gains cannot be folded into weights: the taps enter the fusion's layer-wise
blocks raw, through a pre-norm residual.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The eight-rank two-shot claims the same bits whatever the shard weights and piece count: a word is
reduced by one thread of its owner, acc = 0.0f, then src[0..7] added in ascending rank order in
fp32 and rounded once (reduce2 in r4d_ar_twoshot_Nrank_exact.hip), the one-shot's ar_vsum fold;
weights move only which rank owns a word, pieces only which step reduces it, and every form
(lockstep, ring, split) keeps both. The selftest's check of that claim was blind, though:
ar_pattern_value is k / 64 with |k| <= 254, and eight such values sum exactly in fp32 in any
order, so a kernel folding in another order, or twice-rounding a partial sum, passed.
ar_rough_value gives bf16 values (8 significant bits) whose exponents span 2^-12 to 2^12, so
partial sums round and the order shows: of 20000 elements, 547 fp32 sums differ between
ascending order and rank 3 first. The exact wide rows' pattern runs (ar_wide_pattern, the
weighted eight-rank runs over weights, pieces and forms) and --perfar8 now fold their oracle
from it, ascending from 0.0f, and must match it bit for bit; the lossy and fused cases keep
ar_pattern_value, whose bounds assume its range.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The eight-rank two-shot reaches 56% of its link time at 16 MiB (1316 to 1340 us against 763), and
measured(K) = f x link time(K) + h x (K + 1) fits f of about 1.45 and h of about 20 us a step:
both the transfers and the step boundaries lose time. Two schedules of the same work go after
them, each a new form beside the existing one, chosen by RADIANCE_AR8_FORM (unset or lockstep:
as before) or per launch by the `form` parameter:
- ring: the first hop goes to the peers in ring order from rank + 1 instead of ascending. In the
lockstep order every card but rank 0 starts by writing rank 0's shard, then rank 1's, so the
seven senders can converge on one receiver while the other links idle; in ring order each card
receives from one peer at a time.
- split: ring, and the one handshake a step, which waits until every peer has finished the
whole step (next piece's first hop, this piece's reduce, the previous piece's assemble), becomes
a flag after each half, awaited only before its data is read: before reducing piece j the
peers' first hop of j, before assembling j their reduce of j. A card whose half is done goes on
with the next piece's first hop while a slower card still reduces, so each link runs at its own
pace instead of the slowest card's per step. The flags stay one monotone word per (block,
source): the first hop of piece 0 at v0, of piece j + 1 at v0 + 2j + 1, the reduce of piece j
at v0 + 2j + 2; the launch reserves pieces + 1 steps for its 2 pieces + 1 values, so it mixes
with every other kernel on the instance. A launch still ends only after every peer has
published its last reduce inside it, so the slot parity argument holds unchanged.
r4d_ar_publish and r4d_ar_await (r4d_ar_wide.h) are the two halves of r4d_ar_handshake.
Neither changes which rank folds a word or in what order, so all forms give the bits of the
lockstep form, which compiles to the code it was. Ring and split are eight-rank only; the
three- and four-rank launches stay lockstep and refuse another form. Every rank must read the
same form; init compares it with the other eight-rank settings.
--perfar8 numel iters dtype forms (comma-separated) times the forms side by side; the timeline
prints a pair a synchronisation (K + 1 handshakes, or 2K awaits split, up to 8 pieces).
r4d_selftest's weighted eight-rank runs repeat for ring and split at 1, 4 and 8 pieces over even,
uneven, single-owner and zero-weight tables and with the piece count changing launch to launch,
and the box's own weights run auto, duplex and off. On one card (R4D_SELFTEST_ONE_CARD) all three
forms give the fold on every rank at 65536 to 8388608 elements, even and weighted, bf16 and fp32.
Which form is fastest on the board is for the TP8 window to measure.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The eight-rank two-shot in pieces runs both hops on a link at once, so each direction of rank r's
link carries (1 + 6 x_r) N for a shard fraction x_r: N - x_r N out in the reduce-scatter and
7 x_r N out in the all-gather, the same in. The slowest rank sets the time. The quadratic rule
(round(4 (rate / max)^2)) gives four Gen5 x16 and four Gen5 x8 cards 4 and 1: x8 carries 1.3 N at
28.6 GB/s (763 us for 16 MiB) while x16 carries 2.2 N at 57.1 (647 us), so the x16 links idle
15% of the time.
r4d_ar_weights_duplex equalises the ranks instead: x_r = (T B_r - 1) / 6 where positive, the x
summing to 1, filled from the fastest rank down. On that board it gives x16 2/9 and x8 1/36,
weights 64 and 8, and both kinds of card carry the same time's bytes: 7/6 N / 28.6 GB/s, 685 us
for 16 MiB, 10% under the quadratic rule's 763. On the earlier board with two Gen4 x8 links it
gives 64,9,0,64,0,9,64,64: the Gen4 cards nothing, as the measured best 4,1,0,4,0,1,4,4 did, the
Gen5 x8 ones half of what it gave them.
It is a new value of the variable, not a new default: unset and "auto" keep the quadratic rule,
so nothing runs differently until a measurement on the board says so. Which rank owns a word
changes only the link it crosses, not its fold, so the bits are those of every other table.
--perfar8 reads the variable the same way. r4d_ar_links_test checks both boards, equal links and
that every rank with a shard finishes together.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
At 4 x Gen5 x16 + 4 x Gen5 x8 the weighted two-shot moves a 16 MiB message in 1316 to 1340 us
(K4 to K8, --perfar8), against 763 us that the x8 cards' links need for its bytes, and
measured(K) = f x link time(K) + h x (K + 1) fits f of about 1.45 and h of about 20 us a
handshake. Whether that is link efficiency, waiting for the slowest rank, the local reduce or the
step boundaries cannot be told from the period alone.
A launch now takes an optional `timeline` parameter, a device buffer of nblocks x
R4D_AR_TL_WORDS int64 (r4d_ar_shards.h). Every block of the eight-rank two-shot stamps the device
wall clock after its sequence step, at each handshake when all its stores have drained (arrive)
and when every peer's flag has been seen (release), and after its last local work. The stamps sit
in r4d_ar_handshake behind a null check, so a launch without the parameter pays a branch per
handshake; no value changes either way.
r4d_selftest --perfar8 --timeline launches each two-shot point once more with the stamps on and
prints, per rank, the first push, every step's work and wait, and the final assemble. In one piece
that is the reduce-scatter's send, its receipt, the reduce with the all-gather's send, its receipt
and the local assemble, so the two hops are measured apart; in K pieces it shows which rank works
while the others wait.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The eight-rank collectives could only run on eight cards, so a change to their protocol, shard
table or arithmetic went untested until a TP8 window. Their bits do not need eight cards: a peer
on the same card is just another region of its VRAM.
build() now skips hipDeviceEnablePeerAccess for a peer on the rank's own card (the runtime refuses
it, and nothing needs it). On distinct cards nothing changes.
R4D_SELFTEST_ONE_CARD=1 lets --perfar8 run its eight ranks on the first card: each rank takes a
non-blocking stream of its own (one stream would serialise ranks that spin on each other), main()
raises GPU_MAX_HW_QUEUES to 16 before the runtime starts so the streams get queues of their own,
the block counts stay at 4 and 8 so all eight ranks' blocks are resident at once, and the workers
meet at a barrier before fini and the frees, which synchronise the card. With a card a rank the
worker keeps the legacy stream, so the timed launches are as before. On one card the results are
checked against the fold exactly as on eight; the times are not a board's, since the card runs
the eight queues in time slices of several milliseconds, and the run says so.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Every rank computes the whole normed latent (kv_store over the replicated kv_a) and pools
into the whole index cache, in the head form and the row form alike, so both cached groups
carry rad_kv_group_replicated. At eight ranks a 4-token block costs 49.59 KiB a slot
(kv_latent 48.00 KiB over its 12 layers, kv_dsa_index 1.59 KiB) rather than 396.75 KiB,
12.4 KiB a token rather than 99.2 KiB: --prefix-cache-mib 32768 holds 2.7M tokens rather
than 338K.
glm5next_test pins the two flags at 1, 2 and 8 ranks; the flag is outside the recording
fake's graph hash, so the pinned graphs and steps stand.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Under tensor parallelism a host slot held every rank's shard of an entry end to end, so a
group every rank holds whole (an MLA latent cache computed from a replicated projection) was
stored once a rank: on GLM-5.3-Flash at eight ranks 396.75 KiB a 4-token block for 49.59 KiB
of distinct bytes. The plugin now says which paged groups are replicated (additive export,
RAD_ABI_VERSION does not move), and the slot holds those once, in one window at its front
that rank 0 writes and every rank reads back on a restore; the sharded groups follow, one
window a rank, as before. Without the declaration nothing changes.
TierExec::slot_layout is the one place the slot arithmetic lives: bringup takes the windows
from it, and it refuses a group replicated on one rank but zero, unflagged or another width
on another. A follower moves only its own window on a copy out (nothing, when every cached
group is replicated) and both windows on a restore. The startup log names what is held once
and the tokens the tier holds either way.
RADIANCE_DEBUG_TIER_VERIFY now covers the claim: each follower gathers the replicated groups
into a pinned scratch beside the copy and hashes them once landed, and the engine, once every
rank has landed, has the leader compare its window with every follower's sum.
mem_test moves a chain through the real TierExec with a replicated and a sharded group at 1,
2 and 8 ranks, the ranks' copies differing on purpose, and checks every rank gets the leader's
bytes back; beside a zero group; the verify path alike and differing; and the layout's refusal.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The trunk linears, the routed and shared experts, and the DFlash2 linears
round to OCP-MXFP4 (fp4_e2m1, one e8m0 scale per 32 of K); output.weight
stays block FP8 and the draft head its 2-bit copy. 19.52 GiB against the
block-FP8 sibling's 34.45, served at 25.8 GiB of VRAM a card on tp2.
Sage-A1.5 (InternScience) is Qwen3.5-MoE's routed trunk with the Qwen3.5 vision tower beside it -- a shape qwen35moe_fp8 already declares, but no fixture covered the two together: the MoE fixture had no tower, the VL fixture was dense. arch_test gains q35moe_vl_meta, and checks the tower declares once for the build (not a copy a rank), that it is withheld when no encoder budget is given, and that the routed blocks, the folded shared expert and the MTP layer's own router are still declared beside it.
sage-a1.5-fp8.recipe puts every trunk linear -- attention, the delta net's in- and out-projections, the routed and shared experts of all 40 blocks, and the MTP layer at index 40 -- into block fp8, the head likewise, and keeps the routers, the shared-expert gates, the delta net's parameters, the norms, the embedding and the whole vision tower as the checkpoint ships them. recipe_test reads the shipped file and asserts all of that.
sage-a1.5-fp8-df2.recipe is the same trunk with incoai/Qwen3.6-35B-A3B-DFlash2's tensors in place of the MTP head, which the shared source declares through declare_dflash2. On two R9700s it decodes 392.9 tok/s against 281.6 with the MTP head, at 49.3% acceptance and depth 7; on one card, 231.6 against 168.3.
Compose: sage-a1.5.yaml (two cards, four 32k sessions), sage-a1.5-tp1.yaml (one card, an 8 GiB pinned host pool, one 262,144-token session) and sage-a1.5-df2.yaml. README, DOCKER.md and ARCHITECTURES.md list the containers and the drafter.
ARCHITECTURES.md's glm5next section describes the tower, the processor's budget against the
encoder pass, and the readings that are wrong without an error (the downsample's column order, the
rotary's pairing, no rotary in the language model, the draft head's image rows), with what the
tower measured against transformers. GUIDE.md, spec.md §11, PLUGIN.md, the README and the compose
file say GLM-5.3 takes pictures and how a container gains the tower.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The golden renders gain GLM-5.3's picture between text: the engine's media marker becomes
<|begin_of_image|><|image|><|end_of_image|> with no separator, as the template's own emit_image()
writes it (tests/mkchatgolden.py).
tests/glm5_vision_reference.py runs transformers' tower alone on the CPU (only model.visual.*,
about 3 GB) over the pictures of one encoder pass and writes the processor's patches and the
merger's rows, with --taps the tensors on the way (the patch embedding, block 0's q and k after the
rotary, blocks 0, 11 and 23, the post-norm, the downsample), in bf16 or f32. With --compare it
checks what an engine wrote with RADIANCE_DEBUG_MM_DUMP: patches bit for bit, rows to a cosine of
0.99 and a median per-row relative error of 0.08 against the bf16 reference.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the container's tower and an encoder budget (--mm-max-patches), glm5next declares
rad_block_glm_vision.h's tower after every text and draft op, its weight groups from 46, past the
MTP layer's; an encoder pass issues only the tower. The encoder's rows overwrite the placeholders'
embeddings before the vocab-sharded lookup's reduction (MediaRows), in the trunk and in the draft
head's own lookup (GlmMtp::declare_inputs with `media`), which is what SGLang feeds its draft
model: without them the drafts read the placeholder's embedding and acceptance falls on a prompt
with a picture. The model has no rotary, so nothing else changes in a step. The probe states the
tower's merged block (enc_merge 4).
glm5next_test: the tower only with an encoder budget, at one and eight ranks, its maps, groups,
rotary, unfold and clips; the refusals; an encoder pass issues the tower and nothing else over
two pictures; a prefill with a picture scatters its rows before the all-reduce in the trunk and
in the draft head's history pass, a text step none; a sizing declare with the tower is the real
graph. The operand-count and container cases run on the container with the tower. The pinned
text graph and steps are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
rad_block_glm_vision.h, transformers' Glm5NextVisionModel: the Conv3d patch embedding as a biased
linear with no position table; 24 pre-norm blocks of RMSNorm, a biased qkv whose q and k are
RMS-normed per head and turned by a 2-D rotary (qk_norm_rope's axial mode, the row on the first
quarter of the frequencies and the column on the second, NeoX pairs across the whole head),
attention within a picture, and a SwiGLU clipped at swiglu_limit (gate above, up both ways, with
gate and up joined into one GEMM); post_layernorm; the 2 x 2 stride-2 downsample; the merger's
bias-free projection, LayerNorm, exact GELU and clipped SwiGLU.
The downsample needs no new op and no weight permutation: the processor stages patches in
merge-block order, so conv2d_unfold (two input rows of two patches a block) writes each merged
block as one row in the checkpoint weight's own (channel, kernel row, kernel column) order, and
the [4096, 1024, 2, 2] weight is read as a [4096, 4096] linear as stored. Every op has rows in
libref, libavx and libr4d.
Weights are replicated and RAD_ACCESS_PER_REQUEST, a group a block, as rad_block_vit.h's are; a
sizing declare sizes the activations at the probe's rows and declares nothing to the core. A
tower with another activation, rotary, no swiglu_limit, no attention bias or rows of another
width than the model's is refused by name.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A fourth processor family beside Qwen-VL, Gemma 4 and LFM2-VL, chosen by vision_config.model_type
glm5_next_vision, as transformers' Glm5NextImageProcessor (torchvision backend) computes it:
- The canvas: both sides rounded up to patch * merge (28), grown by the area ratio under
min_image_tokens, and fitted by the reference's binary search over the picture's height past
max_image_tokens, a token being two frames of 28 x 28 pixels.
- The picture keeps its aspect ratio, is never enlarged while it reaches the floor, is resized
with torchvision's fixed-point bicubic only when its size changes, and sits in the top left of a
canvas of zero bytes, which the normalisation turns into each channel's -mean / std as it does
the reference's padding. Patches as Qwen-VL's (merge-block order, (channel, frame, y, x), the
picture in both frames, CLIP's mean and deviation from processor_config.json).
- <|begin_of_image|>, one <|image|> a token, <|end_of_image|>; the tokens rotate at their
positions (the language model has no rotary). Pictures only.
The budget is in tokens and comes from processor.image_processor.{min,max}_image_tokens; one
encoder pass bounds it, so it is lowered to max_patches / merge^2, as a Qwen-VL pixel band is
(4096 tokens at --mm-max-patches auto, the checkpoint's 8000 at 32000). --image-tokens sets the
ceiling; the pixel-band and video flags, a request's image_tokens and a video are refused by name.
tests/mkglm5golden.py writes glm5_golden.h from Glm5NextProcessor; mm_test checks canvases over a
grid of sizes and both budgets, and whole pictures (padded only, grown under the floor, shrunk to
a budget) patch for patch and token for token, all bit-exact, and the processor read from a
container's keys.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
77ef8f0 flipped the three ff.net.0.proj map_rows sites (dit/refiner ffn_gate_up,
vae ffn_up + bias) to identity because the container bytes were "gate-second"
against a gate-first CPU reference. That reference was circular: it read
CONTAINER rows through comfy's gate-first `_swiglu_eager`, so it agrees with
whichever order the container carries. The checkpoint's own library settles it:
ff.net.0.proj is diffusers' SwiGLU (diffusers/models/activations.py,
`hidden, gate = proj(x).chunk(2,-1); hidden * silu(gate)`) — VALUE first, gate
second — transformer AND VAE (autoencoder_kl_minimax_h3 builds its FFNs from
the same FeedForward). `silu_mul`/`gated_quant_fp8` gate with the FIRST half,
so the convert must swap. The swap was load-bearing.
Device evidence (task #64): every render of the identity-map container
(minimax-h3-dasiwa-w8a8-gatefix.rad) — including the pinned FL2VA frame-0 — was
a full-frame grid of ~16px tile-scrambled colour squares, while the original
swapped container on the SAME binary renders coherent video with both pins
forced (cmp45/FINAL_t2va512.mp4, FINAL_fl2va512.mp4; frames read by eye).
Aggregate metrics (luma 81, clipHi 0.1%) were perfectly normal on the
scrambled output — only vision caught it, and the cont.25 "device-verified"
claim was metrics-only.
Reverted maps verified by byte round-trip: rad-convert with the restored
recipe and --reuse minimax-h3-dasiwa-w8a8.rad writes 3273/3273 tensors
byte-identical to it. Kept: the R4D_DIT_SEL-gated decoder shadows + driver
readback, the trailing-optional operand arity fix (43a6768), and the ABI-24
table regen (3f0f4ef) — all still valid. minimax-h3-dasiwa-w8a8-gatefix.rad
stays only as the documented bad artifact; the good container remains
minimax-h3-dasiwa-w8a8.rad. The fried look itself stays OPEN: the restored
renders are coherent but still over-bright vs the reference. Docs cont.26
supersedes cont.25.
Co-Authored-By: Claude <noreply@anthropic.com>
Root cause, byte proof, reconvert recipe, device A/B (clipHi 37.8->0.1%), the final
velocity parity (cos 0.9886 / std ratio 1.071 supersedes cont.24's block table), and
the two pre-existing red tests fixed on the way (timestep_embed arity since e28cf86;
the ABI layout snapshot since 9d67df3).
Co-Authored-By: Claude <noreply@anthropic.com>
abi_layout_test has been red since 9d67df3 bumped RAD_ABI_VERSION to 24 without
regenerating the snapshot, and the row file never listed Batch.sampler or any of the
trailing debug fields (dbg_ve_*, dbg_dit_*, dbg_vd_* — 61 rows missing from the
snapshot). Verified purely additive: no previously-listed field moved or changed size,
both growths are fields past the old struct ends. kTableAbi 24.
Co-Authored-By: Claude <noreply@anthropic.com>
e28cf86 made timestep_embed's curve `table` an optional WEIGHT operand but left the
arity check demanding exact equality with the schema, so every sinusoidal issuer —
qwenimage21, minimaxh3's full-form path — died at step 0: engine_e2e_test has been red
since that commit. The check now accepts a count at or above the last REQUIRED operand
and nulls the dropped schema slots, which is what rad_abi.h promises ("an absent
optional operand is a null RadTensor.data") and what every shim already branches on
(r4d_opt(), rad_args_have(), libref's finish(); the curve kernel still requires the
table when curve > 0). Only TRAILING optionals: an omitted optional before a required
operand would shift positions, which is the miscount the check exists to catch.
Co-Authored-By: Claude <noreply@anthropic.com>
Three map_rows sites reordered ff.net.0.proj rows so the gate landed SECOND, while
silu_mul / gated_quant_fp8 gate with the FIRST half (comfy's _swiglu_eager — the
reference that produced the ground-truth clips — chunks gate-first). Every DiT,
refiner and video-VAE-decoder FFN therefore computed silu(up)*gate instead of
silu(gate)*up: the block-0 device internals dump measured the FFN down-projection at
cos 0.49 against the reference while attn/to_out sat at the bf16 floor, and renders
came out over-bright with 37.8% of pixels clipping high. The maps are now identity
(checkpoint order) at all three sites; quant scales follow because they are computed
from the mapped rows. TE blocks were never affected (separate gate/up concat,
already gate-first).
Reconverted with --reuse (707 tensors / 803 weights): minimax-h3-dasiwa-w8a8-gatefix.rad.
Byte check flips in every class (vae relFro 1.7e-3 vs 1.24 swapped, bias exact, dit
sign-match 0.989 vs 0.484, ref fp8 2.6e-2 vs 1.37). Device A/B 512² 6s seed 1234:
clipHi 37.8% -> 0.1%, luma 136 -> 81 (reference 86), T2VA control clean; step-0
velocity vs the full CPU reference cos 0.9886, std ratio 1.071 (was a 7.6x gap) —
the W8A8 quant floor.
Kept: the R4D_DIT_SEL-gated decoder parity shadows (dbg_vd_* decl fields + driver
readback) that localised the fault.
Co-Authored-By: Claude <noreply@anthropic.com>
The per-block window verdict showed the block stack faithful to its quantization
floor (cos 0.98 -> 0.78 smooth decay over blocks 0-19, cascade at 20), leaving
the 7.6x step-0 velocity-std gap pointing at the FinalLayer. Dump its two own
operands so a CPU replay can judge them without the trunk: norm_out's modulated
stream over the first 256 video rows (bf16 -> f32 cast shadow) and lane/step's
shift|scale table row. The driver writes them as dit_hn.f32 / dit_nout.f32
after the existing slab files.
Replay verdict (compare_head.py, dasiwa-w8a8 dump): the table's video cell
equals t8 @ norm_out.linear + bias to the bf16 floor (relFro 1.5e-3, no silu --
the curve form bakes it, a_temb.x aliases b_temb), and the checkpoint head
reproduces the device velocity exactly (row cos 1.000000, affine 1.0000). The
head and its modulation are faithful; the vel-std gap is a harness-side
statistic, not a device op.
Co-Authored-By: Claude <noreply@anthropic.com>
The first replay verdict (dev vs ref step-0 velocity) came back decorrelated
(cos -0.45, affine relFro 0.89) -- the fork is somewhere in the 50-block trunk,
and the modulation interface is EXONERATED against the checkpoint (dev_mod
cross-check: every block's cell = ada_w_block @ the step temb + bias, cos
1.0000, std ratio 1.000; weight order [video,text,audio] for stream cells
[text,audio,video]). To say WHO diverges and WHERE, declare_dit (env-gated) now
also casts the stream's first 64 rows into [L, 64, D] f32 PERSIST after every
block -- the same rows and ordering point the next block's norm reads -- and
the driver reads it back as dit_blk.f32. 69 MB, one cast op, no fingerprint
lost: the CPU harness gained the matching window stats (win64std) + ref_blkwin.
Co-Authored-By: Claude <noreply@anthropic.com>
The DaSiWa overlay ships its modulation curve as a precomputed table (adaln_t_table
[1025,8]): timestep_embed gains a curve mode -- y[m] = the table linearly sampled at the
timestep, no sinusoid, no MLP -- in the HIP, AVX and ref tiers, and the arch drives the four
timestep rows (video, audio, and each re-embedded with its reference pin) through it with the
ada projections as plain bf16 K=8 lines. The dasiwa-w8a8 recipe carries the overlay.
Device-verified at 512: T2VA, I2VA and FL2VA complete clean and the T2VA re-run is
bit-identical; the fried look PERSISTS on the exact finetune the reference clips rendered
from, which kills the checkpoint-style theory and pins the fork to Radiance's forward.
For the value-parity localisation: R4D_DIT_SEL (env, driver and plugin) declares f32 PERSIST
shadows of the stream entering block 0, the timestep table and the step-0 modulation, and the
driver reads those plus the velocity head back on a plain request's step 0 into
R4D_ENC_DUMPDIR, for the CPU reference DiT replay to diff against.
Co-Authored-By: Claude <noreply@anthropic.com>
Adds `shift` (video) and `audio_shift` (soundtrack) as per-request /v1/videos
fields, (0,100], each defaulting to the model's trained shift; echoed in the
video object and advertised in the model card as video_shift/video_audio_shift.
ABI-invisible: VideoRequest carries the two doubles, video_schedule() re-shifts
that stream's sigma grid, and the shifted sigmas ride RadVideoGenBatch::sched --
the plugin reads only sigmas/timesteps, never a shift scalar, so RAD_ABI_VERSION
stays 24 and no plugin rebuilds.
Diagnosis (cont.20): the review batch's blown-highlight/crushed-black "fried"
look is present in the text-only T2VA control at native res (clip 54-79% vs the
reference's ~4.5%), so it is not the keyframe/tower path (#52) and not a
regression (old ex10 T2VA has clip 51%). It is not the sampler (euler vs
res_multistep: clip 53-61% vs 56-65%) and not the shift: the container already
runs 12/3 (the reference's settings) and shift=4 leaves clip at ~54%. With
sampler, shift and CFG (=1, no guidance) all matched, the gap is downstream of
the schedule -- the video VAE decode scale parity and/or the DiT int8 quant, i.e.
#37/#44/#45. The shift field ships regardless: correct, useful, and requested.
Co-Authored-By: Claude <noreply@anthropic.com>
The five changes for decode's few rows in the glm5next section, where they apply and their
kernel times.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A KDA layer projects its input seven times: qkv, beta, the two rank-128 down-projections into
the forget and gate paths, their two up-projections, and the output. The block issued forget's
down- and up-projection, then gate's: a recorded pass orders the input's four readers, then
forget_b, then gate_a reading the input again, three ordered points where two would do. Both
down-projections now issue before either up-projection, in declare as in step, because the
buffer plan takes lifetimes from the declaration order and forget_low and gate_low must not
share bytes while both are live. The same GEMMs over the same operands, so the bytes are the
same; the pinned step hashes move with the order (world 1 0x906897570034f5f5 /
0x68ffc03d2b640d51, world 8 0x9f39f6f7a04dc4d3 / 0x3818eedb4ac10d1b), and the block's test holds
the four readers first.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
logits_gemm_bf16 runs a 256-thread block per vocabulary column. At n_embd 4096 a thread makes two
16-byte weight loads before the block-wide sum, and each row widens both operands for its own
product: GLM-5.3's TP8 slice (19360 columns) took 303 us at six rows and 1133 at 24, where a verify
pass of eight streams lands, against 235 at one.
The new row runs a wave per four columns: lane l takes, in turn, threads 32q + l of the old
block for q = 0..7 -- the same 8-wide k chunks summed from 0 and added in k order, the same lane
butterfly per q, the eight wave sums added in q order from 0 -- so each column gets the old row's
bytes. bf16 widens to f32 exactly, so each weight is widened once for every row and each
activation once for every column. It outranks the block row at n_embd 4096 only; the block row
is unchanged and serves every other width.
Measured at the TP8 slice (r4d_selftest --perflogits), us:
rows 1 6 8 16 24 48
logits_gemm_bf16 239.1 303.2 378.2 741.4 1133.2 2354.5
..._cols 235.5 247.5 250.4 404.5 635.6 1220.1
Two columns a wave and 16 rows a pass measured slower. r4d_selftest compares both rows byte for
byte from one row to past one 8-row chunk, at a vocabulary off the column step and a pitched
activation with a NaN and a signed zero.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The router (288 x 4096 f32, every MoE layer, the MTP layer in every draft pass) and the index
head gates (32 x 4096) took 26 to 36 us a call at decode's few rows: a lane loaded one weight a
step and fed it straight to its FMA, so a wave had one request in flight. The tile kernel now
loads U steps of k before their FMAs; each lane keeps its ascending fmaf chain and the butterfly,
so every form gives the same bytes, and U = 1 is the tile form as it was.
Below 64 rows the rule takes 2 x 2 tiles with 16 steps, at the router's width from 17 rows 8 x 1
with 8; the wave-per-output kernel for one row goes. Measured (r4d_selftest --cold 256 --perff32,
K 4096), us:
rows 1 4 8 16 24 48
N 288, before 28.1 36.0 36.3 41.9 45.4 47.9
after 14.4 14.5 15.0 19.1 21.6 35.5
N 32, before 27.3 33.3 32.9 36.4 36.2 36.1
after 9.8 9.8 9.9 9.9 10.0 10.2
r4d_selftest's byte comparison with the host arithmetic passes at every form tried, r4d_emu gains
three shapes with K short of and past whole groups of steps.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every draft pass runs the MTP layer's experts on one token: eight experts, and the expert-major
form's four column tiles a block below 128 routed rows left sixteen blocks, each a chain of 64
stages of 256 K. fp8_f32scale_small takes one column tile of the y-th touched expert a block
(grid rows min(experts, rows) + 1, as the MXFP4 small-M form), stages of 512 K, unconditional
loads masked at the store, LDS-only barriers, and a 128 of K's eight fragment pairs loaded before
its WMMA chain; the per-element sequence is the expert-major form's, so are the bytes.
The rule takes it at the MTP gate_up slice (288 experts, top 8, 512 x 4096) to 384 routed rows.
Down's K of 256 gains nothing from it (within a few percent, a quarter slower at three tokens) and
keeps the expert-major form. Measured (r4d_selftest --cold 256 --perfmxf8), expert-major against
small-M, us:
tokens 1 2 4 8 16
73.6 83.6 118.4 214.0 375.6
36.7 65.8 114.9 203.9 343.9
Byte for byte against the expert-major form at 1 to 16 tokens during the work, and in r4d_emu,
whose grouped cases hold both forms at GLM's MTP slices to a host restatement of the sequence.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
At 1 to 48 tokens a chunk (8 to 384 routed rows) the expert-major forms spent their time around
the loads rather than on them. Taking the loads out left gate_up at 72 of its 115 us at six
tokens; what remained was the skeleton of each block: 289 grid rows for the few touched experts,
activation scales read row by row from LDS behind a divergent branch, weight rows loaded through
generic pointers (flat loads, which every LDS wait also waits for), loads behind branches so each
store waited for the whole prefetch, and __syncthreads' workgroup fence. With 160 blocks resident
at 21.8 KiB of LDS each, the last round of an expert-major launch ran nearly empty, at the latency
of one block's chain.
moe_mxfp4_small_kernel keeps the expert-major per-element sequence, and so its bytes:
- block row y takes the y-th touched expert, counted by ballot over the offsets, so the grid has
min(experts, rows) + 1 rows;
- weight codes stay packed in LDS and are decoded at the fragment read, halving the weight tile;
gate_up stages 512 of K, reading 256 bytes of each weight row at once, down its 128-byte rows
whole over four column tiles;
- loads are unconditional from clamped addresses and masked at the store, weight rows load
through global pointers, the barriers order LDS only, and a 128 of K reads its activation scales
and eight fragment pairs before its WMMA chains.
The rule takes it at GLM's TP8 slices for gate_up to 384 routed rows and down to 32; from five
tokens down reads 3 to 5 % slower than the staged form and keeps it. Other shapes are unchanged.
A deeper register prefetch, a barrier-free form with B straight from global memory and A tiles
sized to the chunk's tokens measured no faster.
Measured at the TP8 slices (r4d_selftest --cold 256 --perfmx), expert-major against small-M:
tokens 1 3 6 8 16 48
gate_up, us 36.8 79.5 120.5 145.0 230.3 416.7
31.4 69.5 101.4 122.4 206.8 390.0
tokens 1 2 3 4
down, us 21.2 26.0 34.3 39.5
16.4 22.5 33.2 37.9
Byte for byte against the expert-major forms over 1 to 48 tokens at every form tried (perfmx with
the old form kept beside it during the work), and in r4d_emu against the host restatement: three
GLM TP8 cases, with runs longer than one tile, dropped slots and E8M0 codes 0 and 255.
r4d_selftest checks the new band against libref at 1 to 48 tokens, and --perfmx names the form.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A restore reserved only from the free list. The reserve's trim leaves a quarter of the pool free
after every publish, so a returning conversation larger than that came back as far as the free
list reached, and the lookup stopped at the first block still on the host. On GLM-5.3-Flash at
eight ranks, two conversations of 314K tokens in a 446,832-token pool: the second turn of the
first brought back exactly the 27,930 free blocks, hit 111,772 tokens, and on its hybrid state
resumed at the snapshot at 1,024, since geometric backoff keeps nothing between 1,024 and 131,072.
Its prefill took 84 s instead of under one.
PCBinding::restore_plan now makes room before the engine plans the restore, the same way
PCBinding::evict does for an admission: PrefixCache::trim_for drops entries whose host copy has
landed, the engine lands pending copies (flush_fn), and it drops again. It never erases one,
spares the restoring chain itself and every chain a waiting request holds, and like trim never
touches one a running sequence reads. The free quarter may go; the reserve's trim after the next
publish frees it again. One block table serves every rank, so the room rank 0's cache makes is
room on every rank, as with evict.
When the pool still cannot hold the chain, PrefixCache::restorable_from cuts it at the deepest
valid snapshot the shorter prefix reaches, so no block comes back past the point the hit resumes
from; without recurrent state it cuts where the room ends. TierExec::issue_restore keeps its own
cut as the backstop.
Both cuts are counted: radiance:prefix_restore_cuts_total for restores the pool could not hold
whole (/sessions moved.restore_cuts), and radiance:prefix_hit_cuts_total{reason="resumed_below"}
for admissions that resumed more than one checkpoint interval below their attention hit, which
hit_cut_tokens alone did not tell apart from many small tails (/stats and /sessions hit_cuts).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A restore reserves only from the free list, so after the reserve's trim has left a quarter of
the pool free, a session larger than that comes back partly, and the lookup stops at the first
block still on the host. On a hybrid model the hit then resumes at the deepest snapshot below
that point, which the retention ladder can put far down the chain. These tests drive the
engine's restore against the real cache, tiers and manager: two conversations of 0.6 of the pool,
the second admitted by pressure and published, then the first restored. Red on this tree: the
first comes back as far as the free list reaches, the hybrid one resumes below its tip, and a
restore the pool cannot hold is cut where the reservation ended, not at a snapshot.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every rank scored every query row of a step against every complete block of its sequence and
selected its 512 blocks, the same work eight times: 58 ms of a 1029 ms step at a 4096-row chunk
and 20k of context, about 185 ms at 64k, the largest op that grows with the context. From
GlmTp::kSplitRows each rank now scores one run of the step's rows with dsa_score's row_part,
selects for the rows of its run under the bounds the scorer rebased (cu_part), and two
all_gathers lay the page tables and lengths end to end (8 MiB a layer at 4096 rows). The key
side stays replicated. The run's queries are all a rank needs, so the query projection, its
quantiser and the head gates run on the run's rows too, and the gates lose their column split
and gather; the bf16 projection stays on the step's rows where a run would be 64 rows or fewer,
the skinny band whose split count a tuned configuration may set. Each row's selection is the
same kernels' answer to the same operands, so the joined table is bit-identical to the
replicated one and MLA reads it unchanged.
The rule for a run is GlmTp's, stated once: ceil(T / world) rows rounded up to whole 16-byte
words of the gathered row, because an all_gather moves whole words; the indexer gathers one i32
length a row, so its runs are multiples of four (DsaCache::part_rows). A rank whose run lies
wholly past a small step takes the first run and computes dead rows, so every plane it gathers
is written (GlmTp::run_of). The selection planes hold world runs, which can reach past the step,
and the score plane shrinks to one run, 256 MiB to 32 MiB at 64k of context and a 4096-row
chunk. A decode step splits too once rows x live blocks reach 2^18 from 16 rows
(GlmTp::kSplitWork): eight sequences verifying five drafts from about 22k of context, where
scoring 48 rows over 8000 blocks (250 us on one R9700) outweighs the two eight-rank gathers
(about 50 us); a single sequence's six rows never pay. The replicated issue passes cu_part
absent as its tenth operand, because the engine counts operands against the schema and refused
the nine-operand issue at a served engine's first long prompt.
On eight R9700s (TP8, two ranks on Gen4 x8 that day) a 19887-token prompt prefills 3927 tok/s
against 3748 on 1.9.0, 7881 tokens 3990 against 3655, 2k 3849 against 3663; greedy text with the
adaptive draft window is identical. r4d_emu splits decode rows beside a prefill chunk at 2, 4
and 8 ranks and joins the runs as the gather does, byte for byte against the unsplit scorer;
glm5next_test declares the split at 2 and 8 ranks with the lint, holds the row rule to the
formula it replaced at every world, and pins the graph and steps (world 1
0xed3fc26c486ea1b5 / 0x33e5f136f0dbba15, world 8 0x712f01858dbe1047 / 0xf9e357b1333c638f).
dsa_score_fp8's selftest passes 62 of 62 on eight cards, and --perfdsa times the indexer whole
and as one rank's run.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
dsa_score scores every complete block of each row's sequence and qsa_select ranks them, so both
grow with the context in decode as in prefill. --perfdsa CTX [M] [iters] times them at M rows in
the packed-cache form glm5next issues, and as one rank's run of a step split over 2, 4 and 8 ranks
by rows (dsa_score's row_part), printing what the split saves before its two all_gathers.
On one R9700, 48 rows (eight sequences verifying five drafts) take 273 + 155 us at 60k of
context and a run of 8 rows 53 + 21 us; six rows save 9 us. qsa_select at 4000 blocks takes 89 us
for any row count up to 32: its split path needs two chunks of 4096, so a list of 3500 to 4096
blocks falls to the single-workgroup kernel past its key cache.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
With `row_part` p, `score` holds R rows and row i is query row p * R + i; `q`, `q_scale` and
`gate` stay the whole step's, so a run is the unsplit op's rows bit for bit. A row past the last
sequence scores -inf, so every rank's run can be the same length whatever the step's. The optional
output `cu_part` receives cu - p * R, under which qsa_select runs over the run's own rows (pos
offset by p * R) and finds each row's sequence unchanged; qsa_select itself is untouched.
This is what an indexer split over tensor-parallel ranks by query rows needs from the op: the
scoring is the only per-row work in GLM-5.3's indexer that grows with the context.
libr4d offsets the query operands and compares row0 + r against cu; libref and libavx index the
same way. Without `row_part` nothing changes. Tests: the selftest scores each case's rows in equal
runs and holds every run to the unsplit rows' bytes and cu_part to the rebased bounds; ref_test
checks a run, a run past the step and a short query plane; r4d_emu_dsa (r4d_dsa.hip now runs on
the emulator) splits decode rows beside a prefill chunk at 2, 4 and 8 ranks, selects with the
rebased bounds and joins the runs as the all_gather does, byte for byte against the unsplit
scorer and selection, ties and signed gates included.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The prefill overlap's lane all-reduces coded losslessly at ~12.2 bits a value; the verify step's
GEMM, norm and all-reduces tuned for 17-64 rows; at 4-16 rows each GPU norms its own rows between
a reduce-scatter and an int8 all-gather; deploy/compose/gemma4-31b-w4a8-df2-tp4.yaml.
Squashed from:
- libr4d: the four-rank exact two-shot coded at ~12.2 bits a bf16 value, for the lane row
- libr4d: the prefill overlap's lane all-reduces coded by default
- libr4d: decode-sized two-shots take fewer blocks
- libr4d: gemm_w4a8_nt_m64 at multi-user verify heights (33-64 rows) -- narrower row tiles, wider N
- libr4d: rmsnorm_quant_i8's register form at 512 threads too (33 to 72-120 rows)
- libr4d: ar_rmsnorm_quant_i8_4rank's `sp`, the all-reduce split around the junction
- arch/gemma4_bf16: the 31B's junctions take libr4d's `sp` at 4-16 rows at four ranks
- deploy/compose, README: Gemma 4 31B with RedHatAI's DFlash2 drafter on four cards
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Chained launches on the AQL backend (a dependent kernel waits on a queue counter in its own
prologue), on by default where the model's plugin measured a gain with its block drafter (the
Gemma 4 31B and 26B); the prefill overlap runs attention per slice with narrower lane-1
reductions; the next GEMM's weight is read into the on-die cache beside each all-reduce at decode
heights.
Squashed from:
- core, libr4d: chained launches -- dependent kernels wait in their prologue, not behind the barrier bit
- core, libr4d: chain a kernel by its name, not by the row that launched it
- libr4d, core: chained forms hold nothing across their body
- libr4d: a chained kernel's prologue polls its counter less often after the first few tries
- core/sched: the advance kernel's chained form
- docs: GUIDE lists RADIANCE_CHAIN; chained launches stay opt-in
- core/device: a chained packet behind a chained one keeps its barrier bit while a plain one may run
- libr4d: qkv_norm_rope and its kv_store fold as chained forms
- libr4d: the split-KV decode attention and its merge as chained forms
- libr4d: the four-rank fused junction's tail form as a chained form
- libr4d: the attention, prologue and junction chained forms hold nothing across their body
- libr4d: the 31B's windowed attention and quant_act_i8 as chained forms; r4d_chain.h stubs for the host emulator
- libr4d: DFlash2's kernels as chained forms
- libr4d: chained forms for the decode tail
- abi, core, arch: chained launches on by default where the plugin measured a gain with its drafter
- arch/gemma4_bf16: the prefill overlap's lane-1 all-reduces take the narrow launch (`overlap` 1)
- arch/gemma4_bf16, libr4d: the prefill overlap runs attention per slice; kv_len_trim
- abi, core, libr4d: RAD_LAYOUT_ANY, and a device-only weight read (prefetch)
- arch: read the next GEMM's weight into the cache beside each collective at decode heights
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#159's tree (a full fence on four-rank prefill-sized all-reduces), which the maintainer will merge
by hand in the next release, as the integration branch composed and tested it. Not for review
here: review the last commit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A block drafter (DFlash) ran its two passes after the commit, staged from the committed sequence:
the verify, a host wait and the commit, the context and query passes, a second host wait for the
proposals, then the next step's build and issue, with the cards idle through each host turn and
the ranks starting every pass at different times. Pipelining was off for block drafters.
It now takes the serial drafters' path (sched/advance.h). After the trunk's ranks join, the
acceptance runs on every rank (ADV_ACCEPT). block_begin runs before the commit (on_card): the
context pass mirrors the trunk step, whose positions the host knows (a row issued ahead continued
from the committed end, as commit() reads it); the query block's rows are device rows staged at
the furthest anchor acceptance could leave, with the KV reservation that far, and ADV_BLOCK puts
the anchor (the token the verify chose) and the masks at the card's committed end. After the
query pass, ADV_BTAKE takes the proposals into each StepSlot behind the anchor, which is the token
row the next verify reads (ADV_TRUNK), so issue_ahead verifies them with no host round trip. The
slots come back with the step's one readback; finish_block_drafter checks the card's acceptance
against the host's, as the serial driver does, publishes the proposals and moves the drafter's
filled range.
RADIANCE_DRAFT_BLOCK_HOST=1 keeps the host's driver, for the A/B, and has a row in GUIDE.md's
environment table. On libref with the tiny 31B-shaped checkpoint (and one doctored so its drafter
is right part of the time) the two drivers give the same replies, the same draft acceptance and
the same sampled text, and greedy matches plain decoding. sched_test runs 24 pipelined steps
against the host's driver: the same trunk steps and the same context and query passes, positions,
lengths and slots (the context pass's token ids aside, which that pass does not read);
advance_test covers the two modes and the chain.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Attention reads q and the gqa-8 drafter's KV in place (attn_paged_qrow); the 31B's attention
prologue stores k and v itself (qkv_norm_rope_kv_store); DFlash2's norm/rope/cache-store chains
and add-then-norm pairs run as one launch each. Carries the launch-cliff padding until that PR
merges.
Squashed from:
- libr4d: attn_paged_qrow on the split-KV decode kernel -- h256/gqa2, and h128/gqa8 by two groups a kv head
- arch: the 31B's sliding layers and its drafter read through attn_paged_qrow where a card serves it
- libr4d: step past the full-card launch cliff in qkv_norm_rope and the row norms
- libr4d: qkv_norm_rope describes its operands, so rad-kbench and rad-tune can time it
- libr4d, arch/gemma4_bf16: qkv_norm_rope_kv_store -- the 31B's prologue stores k and v itself
- libr4d, arch/common: qkv_norm_rope takes v_norm; DFlash2's query pass folds its q/k chain
- libr4d, arch/common: qkv_norm_rope takes n_head 0; DFlash2's context pass folds its key chain
- libr4d, arch/common: add_rmsnorm; DFlash2 issues each residual add with the norm after it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 31B's prefill steps of 1024 rows or more run as two slices with each slice's all-reduces
beside the other's compute; q, k and v as one linear where the container holds them so; the 31B
serves RedHatAI's DFlash2 speculator; DFlash2's fc projection is split over the ranks, bit for bit.
Squashed from:
- arch/gemma4_bf16: a prefill step in two slices, each slice's reductions on the second lane
- arch/gemma4_bf16: q, k and v as one linear where the container holds them so
- data/recipes: the 31B -df recipes make q, k and v one linear (blk.*.attn_qkv)
- arch/gemma4: the 31B serves RedHatAI's DFlash2 speculator (gemma-4-31B-it-speculator.dflash2)
- libr4d: gemm_nt_q takes split_n, and all_gather lands rows at a wider output pitch
- arch/common: DFlash2's fc split over the ranks as windows of block-aligned rows, bit for bit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gemma 4's DFlash drafter moves into arch/common so both Gemma 4 plugins declare it, on the int8
grid too; the 31B declares it beside its w4a8 / w8a8 trunk when the container carries one; the
w4a8 and Q8 -df recipes and compose files; the tests.
Squashed from:
- arch: Gemma 4's DFlash drafter into arch/common, for both Gemma 4 plugins, and on the int8 grid
- arch: z-lab's DFlash drafter beside the 31B's w4a8 / w8a8 trunk, its gqa-8 attention at gqa 4
- data/recipes: gemma4-31b with DFlash, the w4a8 trunk with a block-fp8 drafter, and Q8
- tests: the 31B with its DFlash drafter declares the chains where libr4d's fused ops are not declared
- tests: the 31B's steps with its DFlash drafter lint clean, on both grids, at one, two and four ranks
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The four-rank exact all-reduce picks its transport and block count by message size, for every
tp-4 model; the four-rank fused junction gains its tail form (the two-shot with the junction after
it), which the 31B takes up to 16 rows. Carries rmsnorm_quant_i8's register form until that PR
merges.
Squashed from:
- libr4d: the four-rank all-reduce's fold a word at a time, 16-row standalone all-reduces on the two-shot, counters in L2
- libr4d: the standalone four-rank all-reduce takes the exact two-shot from 32768 elements
- libr4d: the four-rank exact all-reduce's two-shot takes 2 blocks at a DFlash2 verify, not 4
- libr4d: the all-reduce rows' nblocks axis offers 2 and 4
- libr4d: rmsnorm_quant_i8 at decode heights loads the row's operands before its reductions
- libr4d: the four-rank fused junction's tail form -- the two-shot with the junction after it
- arch/gemma4_bf16: the four-rank fold up to 16 rows, on libr4d's tail form
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fp8_v4's K is E4M3 already and goes to LDS as raw bytes, as on the fp8 cache.
k6_v4's K and the int4 V of both layouts are widened to the value times its
group scale (as for the f16 legs) and rounded once to e4m3 at staging. The
launcher reads R4D_ATTN_FP8 for all three fp8-family caches. The eight new
prefill instantiations spill no registers.
Measured with radiance 1.10.0, fp8_v4 KV, otherwise as above (KL against
the fp8-KV reference with R4D_ATTN_FP8=0):
- R4D_ATTN_FP8=0 with fp8_v4 matches the shipped libr4d (mean KL 0.006713
in both)
- 3: mean KL 0.0073, p99.9 0.89, max 5.2, top-1 98.3 %
- prompt 200K: 2,609-2,611 -> 3,073-3,091 t/s; 5 x 200K joint prefill
2,403 -> 2,834 t/s; decode unchanged
Ports the 8-bit prefill legs of radiance-vllm-mxfp4's r4d_radiance_extras.patch (commit afa21b5
there) to the h256/gqa6 prefill kernel as two separable bits, off by default:
- O_QK8 (32): Q is quantised to e4m3 once at load (after the folded scale), K stays raw bytes in
LDS, and Q.K^T runs as fp8 WMMA.
- O_PV8 (64): P is packed to e4m3, V stays raw bytes in LDS, and P.V runs as fp8 WMMA. PGROW
tightens to 8 octaves (e4m3 max 448) and DOT2 is off.
Both need CONTIG and are compiled out for bf16 KV. Byte tiles halve the K/V LDS footprint.
prefill_launch reads R4D_ATTN_FP8 once: 0 = f16 (unchanged), 1 = QK8, 2 = PV8, 3 = both.
Measured with radiance 1.9.0 on 2x R9700 (230 W), Qwen3.8-27B MXFP4, TP 2, fp8 KV,
--tp-wire wht6:
- kernel, ctx 200K, chunk 6592: 161.8 ms -> 113.9 ms with 3 (x1.42); per-row relative error
against fp32 1.7e-3 -> 3.1e-2
- prompt throughput at 200K: 2,621 -> 3,082-3,127 t/s; at 25K: 4,746 -> 4,861-5,011 t/s
- --kld-ref against the unpatched build: R4D_ATTN_FP8=0 is bit-identical (KL 0 on 10,198
positions); 3 gives mean KL 0.0076, p99.9 0.94, max 14.3, top-1 98.4 %, PPL x1.0024
- decode and DFlash2 acceptance unchanged (the decode kernel keeps its f16 legs)
The plugin carried the draft head's buffers, weights and ops in its declare and its draft pass
in its step, with the three ops that join the head to its layer declared inside the layer
function; each GLM block carried its core in a header of its own (rad_block_mla_latent.h,
rad_block_kda_state.h, rad_block_dsa_cache.h), the split threshold sat in rad_tp_split.h beside
the router's column split, and 64 / world, 8192 / world, 2048 / world were spelled across the
plugin and the blocks. tests/arch_test.cpp held the recording builder, the run-phase fakes, the
step lint, the batch kits and the fingerprints beside every architecture's cases, 9.5k lines in
one translation unit, GLM-5.3's among them.
Now one block a file in arch/common: rad_block_glm_{mhc,kda,mla,indexer,router,mtp}.h, the
cores joined to their blocks, and GlmMtp the draft head in three parts (inputs, join, head),
declared and stepped around the plugin's layer 45. rad_glm_tp.h (GlmTp) holds the widths a
rank's shard divides, the one threshold kSplitRows and the replicated all_reduce declared once;
SplitF32Proj moves over unchanged. The plugin reads as the stream's buffers, then each block's,
the KV groups, the layers, the head and the draft head.
tests/arch_fakes.h holds the fakes and the helpers every architecture test needs, included by
one translation unit a binary (neither binary links rad_core, as before); GLM-5.3's cases are
tests/glm5next_test.cpp, which includes only its plugin, with two cases new: every op the plugin
issues carries the operand count its schema declares (the kernel libraries' schemas under
$RADIANCE_HOME/kernels, counted as core/runtime/issue.cpp counts), and every declared weight
reads an entry the served container holds, at the dtype its stored encoding calls for (the
container's names and encodings as rad-info -v lists them).
Every declared name, declaration order and issue order is as it was: the pinned graph and step
hashes at one and eight ranks are the values arch_test pinned before the move (world 1
0xed3fc26c486ea1b5 / 0x98ba2952bb37b075, world 8 0x8204e073efdeee0c / 0x1279aecfe4e32d9a), and
arch_test's pins of the other architectures are unchanged.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
json{nullptr} is the one-element array [null], not an empty one. The string-content probe
passed it as `tools`; GLM-5.3's template iterates `tools` under `{% if tools %}`, so the probe's
render threw on the null element, the throw was taken for "cannot render string content", and
with typed content unsupported as well every request logged `render_message_to_json: Neither
string content nor typed content is supported`. llama.cpp master passes json::array() (PR
#27130); so does this probe now. The GLM-shaped template in chat_test asserts string content.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
On a freshly started 31B server at four ranks (4x R9700), the first greedy reply now and then
flipped a near-tie: 1 of 8 fresh starts after scribbling the cards' memory. Per-op output hashes
located the divergence at a prefill all-reduce that read a peer's scratch before that peer's words
had landed: the first reuse of a double-buffered slot, inputs identical on every rank. A full
system fence on every thread before the flag (drain 1), or after it (acq 1), cured it on the cards
(26 of 26 fresh starts). The per-wave store wait, the publisher's single writeback and Relaxed
Ordering off on every link did not. The mechanism below the fence is not known.
r4d_cfg_ar now takes drain 1 for a four-rank message of RADIANCE_AR_FENCE_FROM elements or more
(default 131072: 24 rows of the 31B's 5376, above any verify height and below every prefill chunk).
Decode and verify all-reduces keep the per-wave store wait and pay nothing; 0 turns the fence off.
Two-rank all-reduces never take it: Qwen3.8-27B's prefill at tp 2 paid 4.5% for it, and no
two-rank fresh start ever flipped. GUIDE.md lists the switch. Bytes are unchanged either way; only
when the flag goes out moves.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Judge ringer 4 on the final tree (3 slices, Tasmania, independent questions).
Slice A PASS-WITH-CAVEATS, slice B PASS-WITH-CAVEATS, slice C FAIL. Both
findings were real and both are fixed here.
statsdump (slice B, R1 + R2): the rotation fix deferred the death instead of
removing it. If the best-effort reopen inside rotate() itself fails, out stays
CLOSED, the re-raised OSError is swallowed by the cap check's handler, and the
next poll's write raises ValueError -- which no handler in the file catches
(they all catch OSError). Slice B found the unpatched twin in the write-failure
handler: close succeeds, reopen fails (EMFILE/ENOENT/EACCES/EIO -- not ENOSPC,
which append-open survives), and the cap check's out.tell() dies on the closed
handle two statements later. Both paths now raise a dedicated RecorderDead,
caught at the loop: the recorder exits loudly with its exit summary, because a
handle that cannot be reopened means recording cannot continue. Deferring a
traceback by one iteration was the wrong ambition; exiting with the count is
the honest terminal state.
Canaries reproduce both geometries (reopen fails after rotation shift fails;
reopen fails after write fails): pre-fix dies 'ValueError: I/O operation on
closed file' with no summary in both; post-fix exits rc=0/rc=1 with the summary
printed in both.
dashboard.cpp (slice C, FAIL): my previous commit replaced one wrong sparkline
comment with another. The truth, verified against the call sites: setMetric
samples EVERY poll for every tile (idle polls push 0), so the accept sparkline
spans the same 60 s as the others; the only difference is the dash case -- no
draft head, no value, a gap that stretches the line over more wall-clock. The
original comment claimed 10 s drafting windows; my rewrite claimed drafting-only
sampling, conflating the sparkline (setMetric/hist) with the triple's recent
window (noteSample, win=false). Two lies in one comment block, both caught by
review rather than by me.
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (level not visible) via Open WebUI
Auditor flagged this twice; it is a lie in shipped source (the comment is
served inside the page), so it goes before merge rather than after.
The comment claimed the sparkline's samples are 10 s drafting windows. No
10 s clock exists anywhere in the page: HIST is 120 at the 500 ms poll
(dashboard.cpp:1249), and the accept series pushes via noteSample only when
the poll drafted (aw.dr > 0). The true distinction from the other tiles is
the drafting-only sampling, not a different window length: 120 drafting
samples are 60 s of continuous drafting, stretched over more wall-clock when
drafting is intermittent.
Comment-only change; no behavior touched.
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (level not visible) via Open WebUI
Operator ruling 2026-10-20, applied one line down: the idle-0 law exists
because a stale value wearing a current name is a false measurement. Judge
slice 26 found the same defect surviving in the detail lines under the three
figures already fixed -- the headline obeyed the law and its own detail line
did not, so a busy lane that drafted nothing showed 0 and 'now 87% of
highest' directly beneath it.
- Accept tile: 'now' is shown only when THIS poll drafted. The guard inside
acceptTriple (last.dr > 0) can never be false -- the ring only stores
deltas with dr > 0 -- so the freshness test moved to the caller, where the
poll's own delta is known. highest/recent are session statistics by design
and stay.
- Step tile: 'now X% of best' is gated on this window HAVING decode steps,
not on the lane being busy. During a prefill-only stretch the lane is busy
and lastStepMs holds the last decode poll; the headline reads 0, so the
clause must not print.
- Speculation 'per step': reads 0 when the window took no decode steps
instead of holding the last value. EXTENSION of the ruling by one figure,
named here because it was not one of the three the operator listed -- same
defect class, flagged by slice 26, and it is derived from the step tile
that already reads 0, so leaving it frozen made the panel disagree with
itself.
Fully-idle was already correct on all three; every one of these was the
busy-but-no-measurement window.
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (level not visible) via Open WebUI
Operator call. The bullet is the engine's lifetime marginal ratio,
accepted/drafted (core/sched/draft.h:172, 'cumulative and exact' -- a pooled
ratio of sums, not an average of anything). 'Average' was wrong twice: it is
not an average, and it hid which denominator it used.
The panel shows two ratios that count the SAME accepted tokens and differ
only in the denominator -- reached for the live figure, drafted for this one.
'Average' distinguished them by time, which is not the axis they differ on,
and invited reading the lifetime figure as a longer window on the live one.
Naming the denominator makes the panel self-documenting, which is the same
reason the live figure became 'conditionally accepted'.
The label is ours, not upstream's: 685ec5b's panel had no such key, so this
asks nothing of upstream vocabulary. No test keys on the string (checked).
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (level not visible) via Open WebUI
The disk-full fix in c9aa677 guarded the WRITE path but not the ROTATION path:
rotate() closes the handle first, so if the generation shift or the reopen
itself raises (ENOSPC bites when the directory must grow), out stays closed --
and the next poll's write raises ValueError, which the OSError handler does
not catch. The poller dies with a traceback and no exit summary: the exact
terminal state the size cap exists to prevent.
Fix: rotate() reopens best-effort before re-raising (append-open needs no
disk space, so it succeeds even on a full disk), and the exit close is
guarded so a failing flush cannot eat the summary line.
Can-fail verified by injecting ENOSPC into os.replace at the second shift --
the auditor's geometry, rotation failing with the handle already closed:
pre-fix dies 'ValueError: I/O operation on closed file' with 0 summary lines;
post-fix completes the run, rc=0, summary printed.
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (level not visible) via Open WebUI
Judge slice 31 FAILed a91bf44 and the operator's thumb confirmed it: the
request table still locks under a phone drag. The media-query override
listed bare .hold, but the base '.hold { overscroll-behavior:contain }' is
defined LATER in this file -- equal specificity, later rule wins the
cascade, so the override matched and lost. The .pbody half won (its base
rule is earlier), which is why the page scrolled some of the way but the
request block did not.
Fixed by specificity, not by moving the block: '.body .hold' outranks the
base '.hold' regardless of order, and the media query stays co-located
with the other breakpoint rules per this file's convention. The graph
modal (.ginfo .pbody) deliberately stays contained: it is an overlay the
user scrolls on purpose, and chaining out of it into the page behind is
the wrong feel.
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (level not visible) via Open WebUI
Two operator findings from live phone use:
- Scroll trap: nested scrollers (the request/batch card bodies and .hold)
carry overscroll-behavior:contain, set deliberately for the desktop wheel
so a scroll over the request table does not move the page behind it. On a
phone that containment traps the thumb-drag: the card scrolls, bottoms
out, and the page refuses to chain -- the operator's 'scroll halfway, then
use the sides for traction' symptom is exactly that, the margins being the
only place with no scroller under the finger. Narrow screens now restore
overscroll-behavior:auto so the scroll chains to the document; desktop
containment is unchanged.
- Caption: the Speculation panel's live figure reads 'conditionally
accepted' (displayed uppercase by .cap), naming the ratio's basis on the
face of the panel. README's reference to the same figure follows. No test
asserts on either string (checked before editing).
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (level not visible) via Open WebUI
Slice 23 refuted my 'survive a failed write' claim in the primary geometry:
a write fails at the cap, the cap check's out.tell() FLUSHES the dirty
buffer and raises OUTSIDE the handler -- the poller dies with a traceback
and no exit summary, exactly the terminal state the cap was supposed to
prevent. Fix: on a failed write, drop the dirty buffer and reopen; the cap
check is wrapped so a size check can never be the thing that kills the
poller.
Can-fail verified with a real EFBIG geometry (RLIMIT_FSIZE 5 KB, cap 104 B,
live engine): the pre-fix code dies 'OSError: File too large'; the fixed
code completes the run, 16 rotations, exit summary printed, rows counted.
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (level not visible) via Open WebUI
Operator ruling 2026-10-20, on the three real-time figures: the decode-step
headline, the acceptance tile, and the Speculation live figure.
The defect was the FREEZE. Each of these held its last value while the lane
did nothing, so a stale number kept wearing a current name -- a reader
checking the dashboard at rest read a measurement of work that was not
happening. Judge slice 10 named the failure mode in review.
The fix follows the page's own convention rather than inventing one: every
other live figure on this page shows 0 when the lane is idle (tps() renders
0 as "0", and the engine publishes 0 rates when nothing runs), so 0 IS the
idle signal here. The dash stays reserved for a quantity that has no value
at all -- no draft head, no engine attached.
- Decode step: the tile reads this window's step time; a window with no
decode steps reads 0. The engine's own best/recent floor figures below it
are the engine's windows and stay put.
- Acceptance tile: drafted nothing this poll -> 0. Dash only when there is
no draft head at all.
- Speculation live figure: same condition, same 0.
Sparklines are unaffected: setMetric() pushes nothing for a null sample, so
history stays honest across idle gaps. The restart path needs no special
case -- a restart poll has no delta, so it reads the idle 0 -- and the
pooled-ring clear inside accWindow stays, so a pre-restart pair never pools
with a post-restart one.
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (level not visible) via Open WebUI
Non-gating findings from the Tasmania judge fan-out (reviews/judge/):
- HELP text on radiance:decode_step_seconds_best/_recent said 'seconds per
token'. It is a window mean of STEP times, and with speculation a step
emits several tokens, so the two differ by the accepted-per-step factor --
the wording invited a comparison that is wrong by exactly that factor.
Now says PER STEP and names the conversion. No test asserts on HELP text
(server_test parses it into d.help and never reads it), so this is a
documentation-only change to the exposition, not to the value.
- noteSample gains a argument; acceptance passes win=false. Its
winAt["accept"] ring was written every poll and read by nobody --
acceptTriple takes highest from extAt and recent/now from accPool -- so it
was a second copy of the same samples that a reviewer reasonably mistook
for a second figure.
- RECENT's '15 s at the 500 ms poll' is true only while the quantity keeps
updating; acceptance samples only when it drafts, so its 30-sample span is
30 UPDATES, minutes under sparse drafting (slice 01). Comment corrected.
Diff is 16 insertions / 7 deletions across two files, read line by line
(scripted sweep -- no test would have caught a wrong anchor).
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (level not visible) via Open WebUI
Auditor gating fix 2 (Qwen 27B, AUDIT-qwen-20261020.md §6), confirmed by
judge slice 05. An append-only recorder with no cap is a disk-full timer:
at 1 poll/s the /stats payload runs to hundreds of MB a day, and the
terminal state was an uncaught OSError traceback with no exit summary.
--max-mib (default 256) rotates keeping 5 generations; rows carry their
own timestamps so the chain stays readable in order. A failed write is
now counted and the poller survives to report it. dt_s moves to the
monotonic clock -- a wall-clock step could make it negative and every
consumer dividing counters by it would inherit the step; t stays
wall-clock because it is a timestamp, not a delta.
Can-fail check run against the live engine: --max-mib 0.00002 produced
17 rotations with generations capped at .1-.5 and no rows lost. Does not
touch the engine or the page, so the running image is unaffected; this
lands for the PR and for whenever statsdump is wired in.
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (level not visible) via Open WebUI
Two judge slices (Tasmania 27B, :8101) independently found what the auditor's
pass at 1505ef2 missed: accWindow pushes {ratio, dr, da} but acceptTriple read
d.r/d.a/last.r/last.a -- accPrev's names, a different object. Every pooled sum
was undefined, so the acceptance detail line was frozen at 'highest X% - recent
-' in the PRODUCTION page since 1505ef2. The headline was unaffected, which is
why it looked alive. Fixed to d.dr/d.da/last.dr/last.da.
Also from the judges: the Speculation 'Average' bullet printed 0% for an
undefined lifetime marginal (no drafts yet), breaking the panel's own rule that
0 reads as failure -- now a dash. The comment above it cited a 'GUIDE' that does
not exist; it now cites the README section, which is re-landed here (dropped in
the rebase onto v1.9.0) with the worked example corrected: 56/75/77 implies
43.4% marginal, not the 44% previously claimed.
New test the_pooled_acceptance_ring_reads_the_names_accWindow_writes holds both
sides of the ring contract to the same names -- it fails on the exact bug above,
which no C++ test could see because the page JS is never executed here.
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (level not visible) via Open WebUI
Auditor Qwen (27B, :8788) returned SHIP-WITH-FIXES; this is gating fix 1.
accPool was push-only, so after an engine restart up to RECENT=30 delta
pairs from the dead process pooled with the new one's and biased 'recent'
-- largest exactly when a restart is likeliest to change acceptance.
Restart detection now also watches uptime_s going backwards, which catches
the case backward counters cannot: a backgrounded tab whose accPrev froze
while the new process drafted past the old one's lifetime total, giving a
positive bogus delta. On either signal every pooled ring is cleared and
the accept headline + Speculation figure dash for that poll instead of
freezing a dead process's ratio. Also drops the dead accDelta/ACC_WIN
left by the pre-pool design and corrects the stale '10 s' comment.
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (level not visible) via Open WebUI
Full-suite build of the production branch FAILED 1 of 96: dashboard_test
every_field_the_page_reads_is_one_the_routes_emit reported the page reads
draft_positions[].length/.push/.shift. Cause: that test extracts every
'p.<field>' inside update() and asserts each is a field /stats emits --
p is the page's conventional name for a draft_positions element. My pooled
ring buffer reused p for an array, so its own methods were read as engine
fields. No logic error; a naming collision with the test's contract.
Renamed to 'ring' in update() and acceptTriple(). The gate worked exactly
as designed: rc=8, flip aborted, lane stayed on stock.
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (level not visible) via Open WebUI
Math audit before the production roll (op request): triple()'s recent
averaged per-poll ratios, but polls carry unequal draft counts, so quiet
polls weighed as much as 500-draft polls. Live c8 replica measured the
skew: avg-of-ratios 65.7% vs pooled 54.7% -- 11 points, growing with
burstiness. The tile now keeps a per-concurrency ring of delta pairs and
reports sum(accepted)/sum(reached) for recent and now; highest stays the
full-session extreme. Speculation panel headline unchanged (it is the
newest window ratio, which is a per-poll quantity by definition).
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (level not visible) via Open WebUI
metrics: export radiance:decode_step_seconds_best/_recent (omitted until measured)
scripts: statsdump.py -- /stats to JSONL verbatim recorder
Base: pr/decode-floor tip 14c5c8a (PR #142 content). Rebase onto v1.9.0 owed at
review time: upstream dashboard.cpp moved +87 lines in 1.9.0, expect conflicts.
NOT pushed, NOT merged. Turnstone review pending (Qwen busy).
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (level not visible) via Open WebUI
(cherry picked from commit 4a8b8fabdd834f8eb59320e1945471a8caff47c9)
Merging main brought 1.10.0's own 24 -> 25 bump, byte for byte the same two lines this
branch carried (abi/rad_abi.h's RAD_ABI_VERSION and the layout test's snapshot constants),
so the merge made those files identical to main and the PR's diff fell from 49 files to 47.
What is left is a version number that names two different layouts. main's 25 grew
RadGeneratorDecl (aux_max_tokens, sigma_grid, min_tokens, aux_tokens), RadStep's
conditioning tensors and the tokenizer's RAD_PRE_* constants; this branch's grew
RadBuildCtx by the trailing cvec pointer, which is that struct's offset 112 of 120. Both
trees said 25, and core/plugin/loader.cpp compares nothing but that number, so the one
direction that matters -- an engine from this branch loading a plugin home built from
1.10.0 -- was accepted: qwen4exp reads ctx->cvec at declare (qwen4exp_fp8.cpp:951) out of
an eight-byte-shorter struct, past its end, and treats whatever follows as a direction
table. The PR's own note, that an engine from here refuses an older home and names the
stale .so, was no longer true for the release it now merges.
26 it is, with the layout table and the snapshot constants saying so. ABI 25 keeps
meaning what shipped.
Discovery's third path, <home>/vectors/<arch>-control-vector.gguf, was the one an operator could
never rely on: it existed, but nothing filled it, so a deployment had to fetch Cudecnik's package
and rename two files before the switch was worth anything. The published file is small (483 KB),
specific to this architecture and width rather than to any one quant, and unchanged from upstream,
so it belongs with the other things the home ships next to architectures/ and kernels/.
CMake copies the GGUF and its JSON into the built home (and installs them under the data dir), which
means a missing file is a configure error rather than a silently missing feature. Discovery order is
unchanged, so the per-container and per-directory sidecar paths still win when an operator places one.
The directions are a derivative of Qwen3.8-Flash-Next and are not ours to relicense: they stay under
the Qwen Community License 1.0, whose text now sits beside them (data/vectors/LICENSE.qwen-community-1.0.txt),
is recorded in NOTICE, and is installed to share/doc/radiance/third_party/qwen-community.LICENSE. The
Apache-2.0 grant covers the loader and the kernels, not the directions.
The feature is still opt-in -- without --control-vector the file is never read -- and the request
default is still off, because what this particular vector removes is a safety behaviour.
The summary line led with the layer range, which is the least load-bearing term on it: a file
carrying another model's directions is refused at startup, so the range alone never tells the
operator whether this vector belongs to the model on the card. The panel now reads
`qwen4exp · layers 4-44 · project · scale 1`, with the family taken from the same
`meta_.arch_id` the loader compared against the file's `controlvector.model_hint` -- served as
`arch` in the payload, not invented by the page.
The switch's label says what it does rather than what it is called, and the note under it says why
the change is not retroactive: a running request keeps the choice it was admitted with, and a
session with a refusal already in its context may repeat it.
The graph is declared once, so whether the projection op exists cannot follow a per-request
switch. It follows a startup flag instead:
--control-vector off load the vector found for this model, requests default off
--control-vector on the same, requests default on
--control-vector disabled load nothing (also the default with no flag)
`disabled` declares no op, so an unprojected request costs the stock model's launches rather
than 41 empty ones; a request that asks for the vector is refused by name and the admin route
answers 404. `off`/`on` keep the per-request switch and the dashboard default.
Measured four ways on one box (stock, disabled, off, on -- one boot each, six 4,096-token answers,
speculation off): decode 85.1 / 86.1 / 83.7 / 82.8 tok/s. `disabled` is the stock graph, so there
is nothing to pay; `off` pays the 41 launches, `on` pays the projection. KLD mode serves no
request to carry the switch, so `--control-vector on` is how the projection itself is scored;
config_test covers the three states and the absent default.
GUIDE 4.10 carries numbers instead of assertions: the first-token table over 18 policy prompts
(stock / off / on inside one boot, KL over the union of both top-20 lists), the engine's own KLD
metric over eight boots a side (off 0.021-0.075 mean KL, median 0.044, against unmodified stock's
own floor of 0.019-0.095, median 0.046; permutation p=0.96), and the finding that the boot-to-boot
spread is bimodal (~0.02 or ~0.08 mean KL, top-1 ~96.5% or ~92.5%) and wider than any neutral-text
effect the switch has. The measurement runs are what took the space; the result is one table and a
paragraph about what can and cannot be claimed from this box.
libavx's README transcript is refreshed to 1.9.0's counts (924 checked per ISA level).
The loader stored a norm for every direction in the file, and the plugin declares
an op wherever a layer's scale is nonzero, so `layer_range` (4..44, the package's
own selection) reached only the range checks and the log line: the engine steered
all 47 directions -- 94 hc_project instances in the declared graph where the
sources and the docs say 41. The scale is zeroed outside the range now, which is
what RadControlVector documents ("a zero scale means this layer is not steered")
and what llama.cpp's patch does (its tensor is absent outside the range).
cvec_test asserts it for the default and for a JSON-stated range; --debug-graph
shows 41 a rank.
The direction table is also taken back out of the VRAM budget
(VramFacts::held_out). It is allocated in declare(), before vram_budget_resolve
reads free VRAM, so without the term the pools are planned around bytes the
program never sees. On this box the split came out identical either way
(claimable 12.92 GiB in both), so the term is a guarantee by construction rather
than a fix for an observed miss -- and it keeps a deployment that merely offers a
vector on the same plan as one that does not.
Reading the field's own name last made a null canonical value win over a
non-null alias (JSON null leaves the parsed bool untouched, so it became an
explicit off) and made a malformed alias fail a body whose canonical field was
valid. The loop now walks the field first, skips absent and null keys as the
rest of the parser does, and stops at the first one it finds: the field wins,
null means "the deployment's default", and the alias is only read when the field
is not.
server_test covers both -- a body with both spellings, and a null field with the
default on -- and cvec_test pins n_dirs, which the startup line now prints.
Stale text that outlived the fixes around it: the deleted unit's filename in
libr4d's gated-residual comments, hc_project missing from that unit's header,
"THE SPEED PROJECTION" heading the page's control-vector code, ABI 22 comments
beside a table that says 23, a projection_test header crediting rad-kbench with a
case it does not have, a comment stating the wrong scale arithmetic, a duplicated
<cstring>, and GUIDE's "off in all cases" (the admin switch flips it). libavx's
README transcript is refreshed from a real run (807 checked, at every level).
And the test the alias order needed: a body carrying both `control_vector` and
`experimental_speed_projection`, with the field's own name winning.
The direction table is indexed by layer (row 0 unused) and sized n_layers, so a
file carrying direction.<n_layers> passed the range check and then wrote one
row past `dir`, and a package JSON whose range ended at n_layers read one past
`scales`. Both bounds are exclusive now, and cvec_test covers each: direction.48
of a 48-layer model, and a JSON range 4..48 on the same model.
The startup line printed `n_layers - 1` as the direction count -- the published
file's count, but wrong for a file carrying fewer directions; the loader records
what it read and the line prints that. Also drops an unused <cstring>.
Review found four places where the branch's prose had outrun its code:
- docs/GUIDE.md 4.10 promised that an incompatible sidecar "stops startup" two
sentences after promising it is "reported and skipped" (the code warns and
serves without it), and claimed deployment-level bit-identity for a request
without the vector, which the PR explicitly withdraws. Both now say what the
engine does; the wording is core/cvec.h's, which already had it right.
- cvec_test claimed discovery order and a range past the model in the PR, but
neither case existed. Both are there now, reusing the file writer and load()
the file already had, so discovery -- the branch's policy choice -- has
coverage at all.
- the libr4d row descriptions still said "experimental speed projection" after
the naming commit, and pointed at the unit that no longer exists;
ref_hc.cpp's comment had a duplicated clause.
- /stats' `n_layers` reported the direction count (47 of 48 layers); it is the
model's layer count now, with first/last carrying the range.
The alias is read before the field's own name, so a request that sends both is
read as `control_vector`, and engine.cpp's /server_info comment is back above
engine_info.
The route's own comment, server.h and the dashboard's page all say a deployment
without a vector answers 404, and the page uses exactly that to tell "no vector
here" (hide the panel) from "not signed in" (show it, disabled). The handler
answered 501 instead, so such a deployment showed a panel claiming the vector was
present. The route now assembles the same 404 the server uses for a model it does
not serve, and the case that had no coverage -- a deployment without a vector --
checks it. The unreachable 405 arm goes: only GET and POST are registered.
The device kernel did not implement the operation core/cvec.h states, in two ways
found with a card probe (one row, n 2560, hc 4, through the plugin's own entry
point):
- it offset the direction by the stream (`v + blockIdx.y * v_ld`, with v_ld
falling back to n), so each hyper-connection stream was projected along a
NEIGHBOUR layer's direction -- rows of the table the caller never named, and
past its end when the range ends at the last row. libref and libavx both use
one v for all streams, as the package's JSON does;
- its block reduction used `__shfl_down(acc, off, 64)` under a 64-lane "wave"
bookkeeping, but gfx12 runs wave32 and nothing sets -mwavefrontsize64, so half
of each 64-group's partials never reached LDS: one application left h.v at
0.45 where the operation leaves 0.
Now one workgroup per (row, stream), the direction read once per stream, and the
reduction is the house one (r4d_wave_sum, a partial a wave in LDS, kWaves 32).
The entry refuses a [hc, n] direction table by name instead of reading it as one
direction a stream.
The kernel moves into the gated residual's unit (r4d_hc_bf16.hip), which already
has kWave/kThreads/bf2f/f2bf and the hc_common operand checks: one file fewer and
89 lines fewer than the standalone unit, and no duplicated reduction or conversion
code.
Measured through r4d_rad_hc_project after the change: each stream's h.v ends at
1e-3..6e-3 (bf16 rounding; rel_l2 1.6e-3 against the operation computed in
double), a row with `on` 0 changes 0 of its 10240 bf16 values, and a [hc, n]
table is refused. ctest -L fast: 80 of 82, the two failures environmental
(videos_test needs FFmpeg, ops_doc needs gawk, absent from rad-toolchain).
cvec_test writes control-vector GGUFs and checks what loads and what must not: the published shape,
the package JSON setting range and scale, a wrong architecture or width, a gap in the range, a
non-controlvector file. projection_test pins the per-row mask (a mixed step projects one
conversation and not the other) and launches libref's hc_project against an independent computation,
including the untouched disabled row. ref_test gains the operation's behavioural case, its
vocabulary entry and a sweep geometry.
The field is per request, with the deployment's runtime default when absent, and a deployment with
no vector refuses 'true' by name rather than serving the stock model. Strata's
`experimental_speed_projection` is accepted as an alias.
The dashboard's Model view carries a "Control vectors" panel with the switch for that default;
GET/POST /admin/control-vector is its endpoint, behind the API key like every other route. The state
is in /stats and /server_info. Nothing here reloads the model: the directions are uploaded once and
each step carries a per-request mask.
The panel stays visible when the page has no API key, with the reason, instead of disappearing --
a control that vanishes because the page has not signed in reads exactly like a build without the
feature.
`projection_on_rows` expands each request's choice across its tokens once per step, into the int32
mask hc_project reads; rows outside every sequence are zeroed first, so the reused arena region can
never carry a previous step's flag.
The prefix cache keys a projected request's blocks on the vector itself, through the same extension
point the runtime LoRA adapter uses: one content key spanning the whole sequence, pushed into
`media_keys` beside the adapter's, so every block overlaps it. Blocks and linear-state checkpoints
(whose keys are the same chained hash) therefore never cross modes; an unprojected request, or a
deployment with no vector, adds no span and hashes exactly as before, and an adapter and a vector
compose.
HcProject in arch/common/rad_block_hc.h owns the block: its per-token switch buffer
(`projection_on_rows`, a derived buffer), the per-layer op and the issue point. The plugin declares
it with one call per layer and issues it with one call after the feed-forward write -- the place
llama.cpp's build_cvec(res_hc, il) sits in the qwen4exp graph, in both the serial and the pipelined
step. An unsteered layer, or a deployment with no vector, declares nothing and issues nothing.
h[s] -= scale * (h[s] . v) * v for each of the hyper-connection streams s
llama.cpp's --cvec-mode project semantics: the dot is per stream, because the patch applies it to
the [n_embd, hc, tokens] view where mul_mat(v, cur) reduces over dim 0. v is one layer's unit
direction (f32), scale is the norm its file stored, and 'on' is a per-row int32 switch: a zero row
is skipped without a read or a write, so an unprojected request is byte-identical to a deployment
with no vector loaded.
libref is the oracle and the host fallback, libavx carries it at every ISA level, libr4d (one
workgroup per (row, stream), LDS reduction) serves the card. docs/OPS.md gains the row and the
operation's three facts.
A control vector is one unit direction per layer, applied to the residual stream while the model
runs (llama.cpp's --cvec-mode project). This is the loader and its ABI, with no configuration
surface: a vector is a property of the model family, so the engine looks for one beside the
container, in its directory or in $RADIANCE_HOME/vectors, and uses it when it fits the container.
The operation's parameters (layer range, scale, mode) come from the package's own JSON.
Validation is against the container, never the file's provenance: architecture hint, direction
width against n_embd, every layer in the range present, F32 rows. A discovered file that does not
fit is reported and skipped; the switch stays off until a request asks for it.
The ABI grows by one trailing, zero-defaulted field (RadBuildCtx::cvec), so an architecture plugin
that ignores it is unchanged, and the cache gains a salt (0 without a vector) that keeps blocks and
linear-state snapshots of one mode from being reused by the other.
A card whose PCI BAR spans less than its VRAM was refused at startup, because the kernel argument ring is written by the host and the runtime maps such VRAM PROT_NONE. Instead, place the ring, and a recorded pass's argument blocks, in a pinned host memory pool and grant them to the card, as HIP's own launches do; every dispatch then reads its arguments across the link. A card whose BAR spans its VRAM keeps its arguments in VRAM, unchanged.
RADIANCE_DEBUG_AQL_HOST_KARGS forces the host-memory path on a card that needs no fallback, to measure the cost.
Probe the expert encoding as qwen4exp does, declare the rotated input pair, set the GPTQ
calibration tap, and read expert sources stacked or per expert.
- ActFP8::q8_rot marks fed codes as rotated. NormQuantFP8 declares (ar_)rmsnorm_had_quant_i8g and
GateQuantFP8 declares gated_had_quant_i8g when an activation is fed and rotated. LinearFP8 takes
fed codes on an i8a8h weight only if their rotation is the weight's.
- The MLP no longer writes the bf16 silu product when the down projection is fed.
- qwen35_w8a8 feeds the normed input and the FFN activation only where libr4d declares the ops
(at TP2 the all-reduce form too), so the CPU graphs are unchanged.
A decode step's had_quant_act_i8g launches fall from 288 to 64; the 64 left quantise the attention
and delta-net outputs. The codes are the same bytes. On 2x R9700, against 1.9.0 with the RTN
container:
- KL rows are identical, and greedy answers are byte-identical at TP2 and TP1, with acceptance
unchanged.
- TP2: 33.98 -> 32.87 ms a decode step, 111.2 -> 114.9 tok/s.
- TP1: 55.81 -> 54.59 ms, 62.7 -> 64.1 tok/s.
- Prefill: +2%.
arch_test pins the unfused chain where the ops are undeclared, and the fed path where they are
(had_quant_act_i8g 8, rmsnorm_had_quant_i8g 16, gated_had_quant_i8g 8). The every-op-declared graph
hashes are re-pinned.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An i8a8h linear quantises its own input from the bf16 plane with had_quant_act_i8g, so a decode
step of the int8 Qwen3.8-27B issues 288 of them after the norms and the silu product. These three
device ops write those codes from the producer instead:
- rmsnorm_had_quant_i8g and ar_rmsnorm_had_quant_i8g (exact and wire=6): norm_quant_row gains an
HI8 form, r4d_fwht_wave<128> and then quant_group<I8>, on the lane mapping, rotation and rounding
had_quant_act_i8g uses.
- gated_had_quant_i8g: the gated kernel's existing ROT && I8 instance, which the shim refused.
Each writes the bytes its producer followed by had_quant_act_i8g writes. They are ops of their own,
not a flag on the fp8 forms, as gated_had_quant_fp8 is: a rotated and a plain quantiser must not be
substitutable. n % 128 == 0; device only, so a graph falls back to the pair where they are not
declared.
r4d_selftest checks each against its pair byte for byte (plain, with the residual add and the
residual it leaves, and the gated product) and that each refuses E4M3 codes. The all-reduce form
is skipped like ar_rmsnorm_quant_fp8, since it needs a peer rank.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The decode timeline shows sample_temp at ~10 us a step on the 31B at tp 4: a launch over every
row's whole vocabulary shard (up to 256 workgroups a row) whose rows all return at once, since a
greedy request under a split vocabulary has temperature 0 and a plain sampled one 1, and the
kernel leaves both as they are. Sampler::run now issues it only when a chain row has another
temperature; every other row's logits are untouched either way, so the tokens are the same. The
request check's note on greedy chain rows now says when run() issues the stage.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Counter blocks: the per-(stream, output) counter blocks of the fp8a8 split-K finisher (split_ctr),
the gated delta-net conv (ru_conv_ctr), the mxfp4a8 decode GEMM and the hc mix are zeroed with
hipMemset, which queues on HIP's null stream and returns before it lands. The engine launches on
queues of its own that need not wait for that stream, so the first launch on a new block could run
beside its own zeroing: a split-K finisher counting arrivals while the memset reset the count gives
that one launch a wrong output. r4d_moe.hip's router counters and the all-reduce's IPC allocations
already wait; these four now do too (hipDeviceSynchronize, once per block).
Seen as a greedy reply that differed on the first request of a freshly started 31B DFlash2 server
(2 of 13 fresh starts on 4x R9700, 2026-10-17; every later request matched): the drafter's fp8a8
GEMMs take split_ctr blocks on their first launch, and a draft that differs moves the verify blocks,
whose rounding the target's greedy choice can feel at a near-tie. No value changes otherwise.
Weight transfers: resolve_weight puts the mover's `ready` wait on the issuing lane's stream, but
remembered the generation it waited on per weight for the whole context. A weight resolved first on
lane 1 then had its wait on lane 1 only, and the lane-0 GEMM resolving it next skipped its own and
could read the slot before the copy landed. The Gemma 4 26B-A4B's dense arm is such a weight: a
decode step issues it on lane 1, beside the routed arm, and an overlapped prefill on lane 0.
waited_gen_ is now per lane, one record for each of the context's two lanes (set_lane admits 0 and
1 only), indexed by lane_ like the other per-lane state: at worst one more stream wait. Inert where
no transfer is in flight (static weights, the 31B on four cards); it matters wherever weights
stream.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The merge: the 31B's global layers merge their split-KV partials in merge_body
(r4d_attn_paged_window.hip), one wave a row, four splits at a time into one accumulator chain:
~9.4 us a layer on 4x R9700 in the decode timeline. Each group's loads went out only after the
previous group's FMAs, so a row paid one L2 round trip a group. Group g + 1's loads now go out
before group g's FMAs (two register groups in turn; 175 VGPRs at head_dim 512, no spill). The FMAs
and their order are unchanged, so the bytes are too.
The prefill kernel: attn_wmma_kernel (the 31B's global layers at prefill, ~1.1-1.5 ms a 1024-row
slice on 4x R9700) does three things a tile that change no byte:
- fp8 V widens to its f16 pairs with v_cvt_pkrtz: every e4m3 value is exact in f16, so the pack's
rounding and f16_bits' clamp (unreachable under 448) leave the same bits, for 2 instructions a
pair instead of ~10.
- A tile wholly inside [lo, hi) and, causal, at or before the block's first position is visible to
every valid row, so it takes its scores without the per-key masks.
- With an fp8 cache, a wave whose rows all kept their running max (corr exactly 1) skips the
rescale of O^T: x * 1 = x.
One-card microbenchmark of the three with the skip on both caches (the kernel against the shipped
one, random operands, a 1024-row slice at the end of the context): head_dim 512 gqa 8 fp8 cache
1481 -> 1295 us at context 4096, 657 -> 531 at 2048, 2220 -> 1785 at 6144; head_dim 256 gqa 2 fp8
675 -> 544, bf16 589 -> 511. Every output byte-identical to the shipped kernel's at all four
instantiations (512/8 and 256/2, fp8 and bf16). The skip measured ~4% at head_dim 512 with an fp8
cache, but with bf16 its split loop ran ~10% slower than the fused one (1634 against 1427 us at
context 4096; v_cvt and the interior path alone: 1318), so bf16 keeps the fused loop.
fp8x16_f16, left with no caller, is removed.
The pack is f16x2_exact: v_cvt_pkrtz on gfx12, f16_bits elsewhere (the host SIMT emulator,
tests/r4d_emu, compiles this unit as C++), the same bits since neither rounds a value exact in f16;
r4d_emu_attn passes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On gfx1201 a launch whose wavefronts fall in the last 32 before a multiple of 2048 (every wave slot
of the R9700's 64 CUs x 2 SIMDs x 16) runs about five times slower than the same work one workgroup
wider, whatever the kernel does. A launch-count sweep on one card (2026-10-17): 256-thread
workgroups take 27.6 us at 253 to 256 of them and 5.2 us at 252 or 257, for a norm, an LDS-only
kernel and a plain copy alike; 128- and 512-thread workgroups hit it at the same wavefront counts.
An empty kernel does not, and moving the data does not move it.
The 31B lands on it: qkv_norm_rope at a tp-4 verify is 16 rows x 16 heads of 8 wavefronts, exactly
a full card (21 us a call against ~6 expected; kbench's one-card 4-row point, 256 workgroups, 17.4
us against 5.3 at 8 rows), and a drafter's 256-row head norm through rmsnorm likewise (21.9 us).
r4d_cliff_rows(rows, per_row, waves) is the row count to launch: `rows` when clear of the window,
else the first count past it. qkv_norm_rope, rmsnorm and rmsnorm_p launch that many and return at
once in a row at or past the real count, so every result is the same bytes. r4d_selftest's
qkv_norm_rope case gains 8 rows of the head-256 class (32 heads a row: 256 workgroups, padded).
The window's two numbers are the R9700's, named as such in r4d_common.h, and apply on every target
libr4d builds for (RDNA4 only). They are not derived from the device: no other card has been
measured, and HIP's multiProcessorCount counts WGPs, not CUs, on RDNA. On an RDNA4 part with fewer
CUs a launch padded here costs one idle row and gives the same bytes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The kernel re-read its row from memory in each of three passes, each behind a barrier, so a
row cost three dependent round trips: 11 us a launch at any height on gfx1201 against a 4.2 us
launch floor. Every pass partitions the row the same way, so at 1024 threads (M <= 32, n <= 8192)
each thread now loads its own columns of the branch row, the residual and both gains in one go
and keeps them in registers; only the fragment-order store crosses threads, through LDS as
before. Same sums in the same order and the same per-element arithmetic, so the same bytes.
8.2 us a launch in a four-card microbenchmark at 1, 4, 8 and 16 rows of 5376.
The row gains a reg axis (1 the new form and the default, 0 the old), and the selftest checks
both forms against the unfused chain at M=8.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gemma4TextScaledWordEmbedding multiplies the looked-up rows by `embed_scale.to(weight.dtype)`,
which is sqrt(5376) rounded to bf16: 73.5. gemma4_bf16 multiplied the trunk's embedding by the
unrounded 73.32, and the assistant head's entry, which reads the trunk's embedding module, did the
same. The first layer's norm hides a 0.25% scale, but the residual stream every later layer adds to
does not. arch/gemma4 has taken the bf16 value since it was written (53.0 at 2816).
Both now take embed_scale(n_embd), the bf16-rounded value. arch_test's two checks of the scale
expect 73.5, and its three pinned gemma4_bf16 graphs move with the `mult` they record; no other
model's pin moves.
On 4x R9700 at tp 4 the replies move against main's, as a 0.25% scale on the residual stream
would (7 of 7 long prompts, drafter off). A drafter trained on the reference's hidden states
tracks the corrected stream better: z-lab's DFlash drafter (the next change) accepts 2.88 tokens a
step over seven 2-6K-token prompts against 2.71 with the scale unrounded, and 5.21 against 4.91 on
a code prompt (270 against 259 tok/s).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a_mover_gives_back_every_event_and_device_byte compares the process's KFD VRAM after two
identical runs. Each stream is a hardware queue, and KFD gives every queue a context save area
(the topology's cwsr_size + ctl_stack_size, 29.3 MiB on a 64-CU RDNA4 card) that can be released
a few milliseconds after the queue is destroyed. A reading straight after the test's streams are
torn down sometimes still held it: on 2x R9700 the check failed about 1 run in 5, by exactly
30765056 bytes, and polling showed the figure back within 10 ms.
settled_vram reads process_vram every 10 ms until 100 ms pass without a change, for at most 2 s,
and both readings use it. The warm-up run and the 2 MiB + 4 KiB allowance stay. Back to back on
the card, place_test -perf_ passed 17 of 20 runs before and 20 of 20 after; the host backend
passes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ar_rmsnorm_quant_i8_4rank is the wide family's exact four-rank one-shot with the junction (the
residual add, the sandwich norm and the int8 quantiser) as its epilogue, as ar_hc_write_4rank is
that one-shot with hc_write. The reduce is the standalone exact all-reduce's arithmetic element by
element (fp32 from zero, ranks ascending, one rounding to bf16), so the reduced row matches it to
the bit, and the junction is rmsnorm_quant_i8's over that row. It shares the standalone
all-reduce's transport and instance and ends the engine's link hold itself, as docs/TP4.md asks of
a new collective row.
Every block takes one handshake, a system-scope release by its first thread and a system-scope
acquire by every wave. Both fences are needed: on 4x R9700 behind an EPYC root complex, dropping
either left the readers with stale scratch on nearly every element. `nblocks` 2 and 4 (fewer
handshakes, each block owning several rows) are tune points, off by default.
r4d_selftest's case of the same name holds every rank's reduced row, residual, output, codes and
scales byte for byte to all_reduce followed by rmsnorm_quant_i8 on four cards, at 1, 8, 40 and 97
rows of 5376 and 64 rows of 2816. r4d_selftest is now installed in the image, so a card box can run
the rows' checks without a build tree.
At four ranks a 31B decode step issued 121 standalone all-reduces, 119 of them followed by a
separate norm launch. The plugin now declares ar_rmsnorm_quant_i8_4rank for steps of up to 4 rows
(kAr4FoldRows), where it serves every junction but the last layer's feed-forward one: a decode step
issues 2 standalone reductions. Taller steps, every speculative verify among them, issue the pair
(the all-reduce, then rmsnorm_quant_i8): a one-shot sends three times the message a rank, and at 16
rows the standalone all-reduce's exact two-shot beats the fold's per-row handshakes.
On 4x R9700 (the w4a8 container, tp 4, two rounds): plain decode 90 / 90 / 89-90 tok/s against
86 / 87 / 86 for code / prose / story, and 85 against 82 after a 6442-token prompt, +4.7%; a
DFlash verify at 16 rows measured 300 tok/s on the pair against 276 on the fold, hence the band.
Both paths give the same bytes. Where no library declares the fold, every step issues the pair.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Image-conditioned MiniMax-H3 (I2VA/L2VA/FL2VA = first_frame/last_frame) rendered
over-saturated / posterized while T2VA was clean on the same container. Root cause:
the reference conditions a keyframe TWICE -- a vision-tower anchor (clip.tokenize
images=[kf] -> <Picture N> soft-tokens in the text conditioning) AND a VAE-latent pin --
but Radiance did only the VAE pin for endpoint keyframes. The absent semantic anchor
left the DiT reconstructing the frame from low-level VAE pixels alone -> posterize /
black-outline / oversaturation.
Route endpoint keyframes through the existing vision-tower media path, so they produce
<Picture N> anchor soft-tokens in addition to their VAE pin (the reference's dual
channel). No new kernels, no ABI / arena change: build_cond stages r->media generically
and the arch scatter is the generic op_mm.
- videos.cpp: keyframe index = <Picture> ordinal (first=1,last=2); stable-sort keys
by kind before merge; run the prepare+placement loops for FIRST/LAST_FRAME as well
as IMAGE (area-matched tower form, aspect-kept; the exact-canvas VAE pin is a
separate, unchanged second encode); budget wording covers keyframes.
- video_driver.cpp: a towerless container no longer refuses a keyframe request (skip
FIRST/LAST_FRAME in the "needs a vision tower" scan) -> pin-only path runs; the
encodes guard still requires the VAE encoder and now labels a keyframe correctly.
Device A/B (uncensored w8a8, TP2, seed 1234, 512^2): prompt tokens i2va 27->291,
fl2va 1560->2088 (the +256 / +2*256 keyframe vision tokens + labels), t2va 27->27.
T2VA output is bit-identical across binaries (text path untouched). Image-conditioned
output diverges (cos 0.77/0.80): the realistic I2VA mid-frame recovers foliage
structure (blobs -> trees), softens outlines and shadow detail toward the clean control;
FL2VA gains semantic adherence (prompted "wings spread" now renders). Endpoint-pin
cosine unchanged (0.971 / 0.988 / 0.980, at/above the 0.985 bar). No budget reject.
Tests: fl2va keyframes now feed the tower and still pin the ends (index 1/2, token
stream with both vision blocks); towerless fl2va pins-only; driver-level keyframe
conditions through the tower and needs no tower. NOTE-REF2VA.md #8 closed.
Co-Authored-By: Claude <noreply@anthropic.com>
Radiance's video denoising had only first-order Euler. The DaSiWa reference
workflow samples MiniMax-H3 with res_multistep + simple, so add it as a second
order option, exposed as a `sampler` field on /v1/videos (default euler).
New op `flow_res_multistep` across all three kernel tiers (device==avx==libref),
closed form reusing the driver's per-step scalars:
x' = r*x + hb1*den + hb2*x0, den = x + sigma*v, r = sigma_next/sigma
order 2: h=ln(sg/sgn), h_last=ln(sg_prev/sg), r_s=h_last/h,
hb1=(1-r)(1+1/(2 r_s)), hb2=-(1-r)/(2 r_s)
hb1+hb2 == 1-r, so it collapses to Euler when x0==den. Order 1 (Euler) is forced
at the first step, the first full-size step after a latent upscale (stale
history), and the last step (sigma_next==0); order 2 otherwise. The previous
denoised estimate persists in new PERSIST buffers b_vx0/b_ax0. Verified equal to
k-diffusion sample_dpmpp_2m to 5.6e-17 on three sigma grids.
- ABI 23->24: trailing int32_t sampler on RadVideoGenBatch; RAD_SAMPLER_EULER=0
/ RAD_SAMPLER_RES_MULTISTEP=1 in rad_runtime.h.
- driver: R_SCHED region widened 6->16 f32 ([0..5] Euler, [6..10] video coeffs,
[11..15] audio); step_dit branches on V->sampler.
- server: `sampler` string field ("euler"/empty, "res_multistep", else
invalid_request_error with the supported list); echoed on the job object;
capabilities advertise video_samplers.
Tests: rad-avx-check 816 + 451 hand-built, 0 fail (left-assoc grouping matches
ref/device at tol 0); r4d_selftest --case flow_res_multistep_f32 f32|bf16 x
order {1,2} exact, both INOUT pitch gaps untouched.
Device-verified (TP2, fp8 container, 256^2/2s/10-step, seed 1234 identical):
both samplers complete clean 73-frame h264; outputs differ (branch genuinely
consumed, not ignored); bad value rejected; field omitted -> euler. res_multistep
renders warmer/higher-contrast than euler -- a tone lever, not an over-exposure
fix. The euler default path is unchanged.
Co-Authored-By: Claude <noreply@anthropic.com>
/v1/videos now emits webm (VP9+Opus) and webm-av1 (AV1+Opus) as well as mp4.
docs/DOCKER.md gains a "Video output: MP4 and WebM" section covering what the
ffmpeg stage must enable, the runtime shared libs (libvpx9/libaom3/libopus0) the
rootfs ldd-chroot gate pulls transitively (they are link-time deps of libavcodec,
not dlopen), the BSD/no-GPL license posture, the graceful mp4-still-works path,
the 32k->48k Opus resample, and no-card verification. Fixes the stale
"three encoders" comment in the Dockerfile header.
Co-Authored-By: Claude <noreply@anthropic.com>
LoRA for image and video generators:
- civitai and Hugging Face adapter files as published: kohya, ComfyUI and diffusers/PEFT key names;
LoRA, LoCon, LoHa, LoKr and full-weight diffs; DoRA, OFT and Tucker are refused by name
- stacked per request with a strength each, through the `loras` field or <lora:name:strength> tags
in the prompt; --lora-dir serves every file in a directory, GET /v1/loras lists them, and
--max-loras / --max-lora-rank size the slots on the card (generators default to rank 64)
- Krea 2, Qwen-Image 2.1, FLUX.3 [klein], MiniMax H3, LTX-2.5, Anima and SDXL
New models:
- Anima (base, aesthetic and turbo): Cosmos-Predict2 DiT with the Qwen3-0.6B text encoder and the
Qwen-Image VAE, on one card
- Stable Diffusion XL and its single-file finetunes (Illustrious, NoobAI including V-Pred, Pony),
read as civitai ships them, with the Euler, Euler a and DPM++ 2M samplers
Recipes:
- q38-27b-mxfp4-df2: any bf16 Qwen3.8-27B or finetune at MXFP4 with the DFlash2 drafter
- Krea 2 finetunes from civitai: scripts/krea2_native.py reads Krea's own key names, and
krea-2-fp8-unscaled keeps a plain-fp8 file's codes exactly
Changes: --max-num-batched-tokens defaults to 2048 (was 8192). Plugin ABI 25: out-of-tree plugins
must be rebuilt.
A `format` field chooses the container a generated video is written in:
mp4 (the default, H.264 + AAC, unchanged) or webm (VP9 + Opus) or webm-av1
(AV1 + Opus). Old-hardware users -- this box's CPU is Zen 3, AVX2 only --
get the browser-friendly WebM the DaSiWa workflow ships without a fragile
client-side re-encode, and both webm codecs so either a VP9-friendly or an
AV1-parity file is available.
core/mm/mp4.{h,cpp} become core/mm/video_out.{h,cpp}: Mp4Writer generalises
to VideoWriter with a VideoFormat enum, branching the muxer, the video
encoder (libx264/libopenh264 for H.264, libvpx-vp9, libaom-av1/libsvtav1),
the rate-control options and the audio codec. Opus encodes only at 48 kHz,
so a WebM soundtrack is resampled to 48 kHz with libswresample (the model's
is 32 kHz); the encoder is fed packed FLT at its fixed frame size, AAC keeps
the planar FLTP path at its own rate. faststart and the shift_data reader are
MP4-only; WebM writes forward. Each codec/muxer is runtime-discovered and a
missing one fails open() with a message naming it, so the mp4 default always
works.
videos.cpp parses `format` (mp4|webm|webm-av1, mp4 default, refusing any
other name), threads it to the job and the writer, serves the file under the
matching content-type and a .webm/.mp4 Content-Disposition, echoes `format`
in the object, and advertises video_formats in the capability block.
The Docker FFmpeg build gains libvpx/libaom/libopus and the webm/matroska
muxers (all BSD, so the LGPL posture holds) and their runtime libraries.
Verified host-side: the videos_test webm case writes a real VP9+Opus file
(completed on libvpx-vp9, EBML magic + content-type + disposition checked);
a standalone writer harness produced mp4/webm/webm-av1 at 512x512 with stereo
32 kHz audio -- ffprobe reports h264+aac@32k, vp9+opus@48k and av1+opus@48k
respectively, and all three decode in software on this AVX2-only box.
Co-Authored-By: Claude <noreply@anthropic.com>
b025018's W8A8 DiT path unfused the norm: rms_mod wrote a bf16 plane and
each int8 linear re-quantised it. That bf16 plane grew the activation arena
14.41->15.54 GiB, which left vram_kv=0 and the server aborted at startup.
Mirror the E4M3 path instead. rms_mod_kernel gains a third quant mode (i8),
sharing r4d_q8.h's q8_top/q8_pack4 with the int8 quantiser, exposed as the
new rms_mod_quant_i8 op; the block's modulated norm now writes a_hm's int8
code pair directly (a_hm is q8_fed, so qkv/gate_up read the codes with no
per-linear quantiser) and a_hm carries no bf16 plane. ActFP8::cq()/cs()
resolve the pair by trunk format, so the norm producer and both step issues
collapse to one path. LinearFP8's int8 guard now demands the bf16 plane only
when it quantises itself, matching the fp8 branch, which never required it.
Arena is back to fp8 parity (243 buffers, vram_kv 938 MiB); the container
serves at TP2 and renders all five task types device-clean.
Co-Authored-By: Claude <noreply@anthropic.com>
--mm-max-patches now says that a pass is not one tower invocation (8 tiles
per weight read at most, 4 at the 64 grid with the default pass), and the
Unlimited-OCR section explains the pass-per-geometry queue, the measured
TTFT ladder, the activation cost of batching, the tuning order and the
decode batching limit. Link the converted container
(Aijuus/unlimited-ocr-bf16) from the model table and the guide.
- sam_attn: tile queries and hoist the relative-position dots; the tower
drops from 0.44-2.09 s to 0.10-0.36 s per tile.
- processor: split OCR patch/LUT staging across rows, then make both bicubic
passes and the LUT append AVX2 (bit-exact, 1.15-1.38x host preprocessing).
- tower: batch the DeepEncoder across every tile segment of an encode pass.
Patch embed, the 12 SAM blocks, neck, the 24 CLIP blocks and the projector
run once per batch of up to 8 tiles (4 at the 64 grid); sam_attn and
attn_dense stay segment-independent through B+1 cu tables, and position
tables are host-staged PERSIST planes. B == 1 emits the old graph.
Fix the newline layout: the reference expands image_newline over every map
row, while the copy read past the one-row vector; with a multi-tile batch
that made the trailing cells live data and the decoder dropped the text at
the right margin of every line.
- attn: instantiate attn_paged_qrow at head_dim 128 (bf16 and fp8 caches) and
read OCR's q slice of the fused q|k|v plane in place, keeping the dense cast
as the fallback when the library does not serve the qrow row.
- tests: h128 attention emulator cases, a batched-tower arch test, an AVX2
bit-identity test, and a 15 s arch_test CPU budget for the image.
Measured through the router at 256 tokens: 8-page TTFT 4157 -> 1327 ms, 640
page 608 -> 284 ms, 8 concurrent pages 17.6 -> 4.26 s wall; decode unchanged
at ~344 tok/s. Parse gate 0.9901 text / 1 px on the deployed image.
The denoiser's linears were E4M3 with fp8a8 activations. Three mantissa bits
band the smooth per-token activations that carry image detail (a watercolour
look) and the 448 clamp clips highlights (oversaturated colour). int8 is 126
uniform levels per group with no clamp, at the same one byte a weight, so the
container footprint and served memory are unchanged; iu8 WMMA runs at the fp8
rate. A quarter of E4M3's error on the activations that were the fidelity limit.
Serve the fp8 and the new int8 containers from one plugin, told apart by
probing one trunk linear (linear_is_w8) before the activation code planes are
declared. There are no int8 forms of the fused producers (rms_mod_quant_fp8,
gated_quant_fp8), so for the int8 trunk the producers come apart: plain rms_mod
writes a bf16 modulated-norm plane and each int8 linear quantises that plane
into its own codes (LinearFP8::i8's quant_act_i8g), and the gate is a bare
silu_mul. The attention's own quantiser already emits int8 (QuantFP8 q8_fed),
so o_proj reads those codes directly. A trunk read entirely by int8 linears
declares no E4M3 code pair (ActFP8::declare_qs fp8_pair=false), freeing arena
the KV cache needs.
data/recipes/minimax-h3-w8a8.recipe converts the DiT linears to symmetric int8
on a per-row 128-column grid; reuse the fp8 container and list only the
transformer.* tensors as changed.
Co-Authored-By: Claude <noreply@anthropic.com>
Follow-up to the link-bound finding: tried --embedding-placement vram to
take the 1.45GiB/rank embedding read off the gen4 x8 link. It resolves to
VRAM but starves the KV cache: static weights fill the whole per-card
weight budget -> every MoE expert streams + vram_kv=0 MiB -> startup
aborts (invalid argument). So the shipped embedding-in-ram default is the
trade that keeps VRAM for KV+experts; forcing it to vram trades a small
streaming cost for a catastrophic one. No rows produced (aborted before
VRAM claim). Cards stayed 61MB.
Co-Authored-By: Claude <noreply@anthropic.com>
Removed the 215W cap + −75mV undervolt, re-ran bench2.sh. Uncapped vs
capped: ~2% at 6s, 5.3% at 12s (207→196), noise elsewhere; busy=100% on
519/528 samples. Conclusion: TP2 diffusion is NOT SM-clock-bound — the
gain is small because the step waits on the gen4 x8 fabric (all-reduce +
embedding/encoder reads over the link), which doesn't shrink with core
clock. Corrects the earlier note that implied the cap was a major
long-row handicap; the sol 12s gap is not the power cap — the link cap
is. Leaving the box at 215W costs ~5% worst-case on diffusion.
Co-Authored-By: Claude <noreply@anthropic.com>
The fused q|k|v GEMM writes one plane, so the q operand is a column slice
whose row pitch is q_dim + 2*kv_dim. libr4d's attn_prefill_h128_gqa1_fp8kv
reads q only contiguous and refuses the slice with RAD_E_STRIDE, which aborts
the step and stops the engine on the first prefill. attn_paged_qrow would read
the pitch in place but has no h128 row (only head_dim 256/512), so lift the
slice into a dense [T, q_dim] buffer with a cast after rope, as gemma4 does.
The 2a1ca01..f308216 range's 45 review findings (12 performance, 33 quality)
are applied: ABI 23 for the RadBatch append, the fused q|k|v projection, the
batched patch-embed GEMM and pitched layout copies, the sam_attn w-dot hoist
with an alignment-gated vector row path and NaN poisoning for malformed
segments, the fused quick_gelu act, and the R-SWA/scheduler/drafting gates.
Quality items: stale comments corrected, env reads hoisted, the ngram_window
negative refusal, the parts-form chat template instruction, the whitelist
fallback warning, and the segmented R-SWA refusal of the fixed/runtime window
mix.
The 3.2 MB generated resample header becomes a 9.6 MB little-endian blob
(tests/data/golden/uocr_resample_golden.bin) read by a small loader;
resample_golden.py emits and round-trip-verifies it.
One perf-med item (AVX2 bicubic passes/LUT patch staging in the processor) is
left as the follow-up the review itself recommends; the code says why.
Verified: ninja -C build-review -k 0; host ctest 89/89; GPU r4d_selftest
0 failures, kbench/kbench_moe and the card tests pass.
LibreChat sends the picture followed by U+FFFC (an object replacement
character) as the text part, so the turn looked non-empty and the parser
instruction was not supplied; the model then emitted a one-word preamble
before the layout. Treat U+FFFC like whitespace and drop it from the
rendered prompt, and default the instruction for any picture count.
Render only the last user turn and supply the reference parser instruction
when that turn carries no text, so clients that send a bare image (or
system/history text) no longer get a prose preamble before the layout.
Mount the template directory read-only at /chat-templates.
One card via RADIANCE_GPU, --tp 1 --max-num-seqs 8 --max-model-len 32768,
--kv-cache-dtype fp8, the vision tower on the card (the default placement)
and --gpu-headroom-mib 96. About 7 GiB of VRAM, so the other service in
this directory is stopped first.
The lossless-webp round-trip test failed on this host because FFmpeg's
native VP8L decoder rejects valid palette-coded libwebp streams (the
system ffmpeg 8.0.1 CLI refuses the same bytes; libwebp/PIL decode them).
The test now validates the RIFF/WEBP/VP8L container and tolerates exactly
that 'Invalid data' refusal with a visible note, while other decode errors
and wrong pixels still fail. media.h records the consumer-side caveat.
A 16000x1024 picture's 16-tile line takes two passes, 10+6: the earlier
chunk ends at its last tile, only the last carries the newline column,
only the real 4x4 separator is flagged, and the placeholders still equal
(10*cols+1)*10 + 273.
The pass packer now keeps a view and its one-cell separator in one pass, and
RadBatch carries each segment's grid host-side (enc_seg_h/enc_seg_w) so the
DeepEncoder no longer reads device coordinates to pick a geometry. The tower
lays out a line of n tiles as kMap rows of n*kMap features plus one newline
cell, accepts an earlier chunk of a longer line, and emits the learned
view_seperator for an explicit 4x4 separator rather than any square segment.
The device sam_attn resamples a rel_pos table that is not 2*tile-1 rows on
read (the 127-row global tables serve a 40-grid block as 79), matching
libref/libavx. The n-gram ban gains the reference's optional whitelist
(5th operand, OAI keys, generation_config alias) with range/dtype checks.
Gates: tiled e2e stage cosines 0.9994-1.0, det/text 0.9901 with every
coordinate within 1 px; two-page 0.9917 within 2 px; device selftest
sam_attn (incl. 127->79) and ngram whitelist (1344 columns) 0 mismatches.
DeepEncoder (arch/common/rad_block_sam.h): the checkpoint's SAM ViT-B/16,
neck and CLIP ViT-L/14 producing its 16x17+1 row layout, with a new
`sam_attn` op for the windowed, zero-padded SAM attention and its
decomposed relative-position bias (libref oracle, libavx kernel, libr4d
kernel and selftest). The plugin declares the tower when the container
records `radiance.encoder`, and splices its rows over the placeholders
after embed_lookup.
BOS: the chat path adds BOS when the rendered template does not already
start with it. This checkpoint's template is a bare concatenation and its
tokenizer states add_bos_token, so without it every position was off by
one and the det boxes came out wrong. A media run's placeholders shift
with it.
R-SWA: RAD_KV_RING, paged like a window group but with a per-sequence
floor armed at admission. adv_groups now computes the same clamped
seqused and modulo ring slots the builder stages; the mismatch read the
block table's -1 padding and faulted the card. Prefill stays causal;
prefix cache, checkpoints and speculation are off for the group.
Sampling: sample_ngram_ban in libref/libavx/libr4d and the host chain,
the request knobs, and the container's generation config (35 over 128).
Processor: the checkpoint's grid/mode selection, its tall-last tie order,
Pillow's bicubic pass order, and goldens generated from its own code.
Tools: --mm-max-patches auto-detection accepts a tower stated as per-width
tables under vision_config.image_size, and rad-convert records
radiance.encoder.
Verified: tower stages match the checkpoint's code (rows cos 0.9998), the
device sam_attn selftest is within tolerance, the R-SWA device repro
returns text, a GPU e2e reproduces the reference's first det block, and
the host suite is 88/89 (known webp decode baseline).
The text side of Unlimited-OCR: a 12-layer, 1280-wide decoder, 10 query heads over 10 KV
heads at head_dim 128, a dense layer 0 and 64 routed experts (top-6, softmax, no
renormalisation) plus one ungated shared arm in layers 1-11. arch/unlimitedocr_bf16/
carries its own plain-Llama bf16 attention, the shared MoE block in its bf16
external-input mode, and the tied LM head; data/recipes/unlimited-ocr-bf16.recipe is the
bf16 passthrough convert. core/format/checkpoint.cpp learns n_routed_experts, so n_expert
is read from the checkpoint's own key.
The router is issued as one op rather than a selection and a sort: libref gains
router_topk_scatter and router_gemm_topk_scatter (the second with the shared expert's
one-column gate at N = 1), libavx composes both from its router/gemm/scatter kernels, and
both get sweep geometries and the gate-absent/gate-present tests.
libr4d had no head_dim 128 leg at ratio 1, so every attn_paged band of this geometry
resolved to no kernel and the server refused to start on device.
r4d_attn_paged_h128_gqa1.hip instantiates the generic body at GQ 1 for both legs; the
rows and the selftest cases come with it.
Device numbers, one R9700 (gfx1201, HIP 7.16), bf16 weights and KV, no reference-kernel
fallback: a 523-token prompt prefills at 35.0-35.8k tok/s (15 ms) and a 4043-token prompt
at 54.2k tok/s (75 ms); decode is 351-354 tok/s (2.82-2.85 ms/token) at short context and
315 tok/s at 4k. r4d_selftest is 0 failures; the host suite is 86/87, the miss being
mm_test's lossless-webp decode, which fails on this box in code this change does not touch.
Endpoint keyframes are resized to the target canvas and their latent rows share the TARGET grid
(ref2va_build), so they must VAE-encode at output resolution -- but venc_geom had a flat
h,w > kEncMaxSide(256) reject, so I2VA/L2VA/FL2VA failed at any output above 256 with "the video
encoder refuses a reference at 512x512 over 1 frames". The flat cap is a crude proxy for the real
limit: the encoder holds one clip's pixels sized for a kVaeClipLength(17)-frame clip at 256
(Rmax=17*256^2). Replace it with clip*h*w <= 17*256^2 -- a multi-frame video ref is unchanged
(clip=17 forces each side back to 256), while a one-frame media fits at up to sqrt(Rmax) per side.
No buffer, kernel, or arena change: a 512^2 keyframe (262k rows) is a third of the existing budget.
A first relax then faulted ("cast n=128 at M=262144 outside band") because the encoder's debug
shadow casts (op_ve_cindbg / op_ve_ldbg / trunk / nout -- write b_vcin/b_vl/b_vtrunk/b_vnout, read
only under R4D_ENC_SEL) were issued on EVERY encode at a PF[] plane range a 512 frame overflows.
Gate them on R4D_ENC_DEBUG (the env the readback already uses): a no-op for the production latent,
and it stops paying for debug work on every encode.
Device-verified: FL2VA 512x512 and I2VA 512x512 12s complete clean, server survives, no band fault;
host vae_geom/video_gen/videos/ref2va_pack/encoding tests green.
Co-Authored-By: Claude <noreply@anthropic.com>
One keyframe path serves three DaSiWa modes: first_frame pins output frame 0,
last_frame pins the last frame, and the gap is diffused. A keyframe is pure
attention conditioning -- its VAE latent rides as a pinned (update=0) cond row
at its frame's time position, faithful to comfy/ldm/minimax/model.py where
keyframe latents are img_update==False rows. The sampler is untouched; the step
merely widens to carry the extra cond rows.
- server (videos.cpp/iface.h/adapters.h): first_frame/last_frame form parts ->
VideoRefMedia::FIRST_FRAME/LAST_FRAME; kf_task validation (i2va/fl2va need
first, l2va/fl2va need last); keyframes are mutually exclusive with refs;
encoder_image_canvas(cover=LAST) sizes the anchor.
- driver (video_driver.cpp): keyframe pass issues a RAD_ENC_IMAGE Vencode per
anchor (slot = ++ref_tab[1], ordered), appends ref_tab key triples
{frame(0|frames-1), video_t=1, audio_t=0}.
- arch (minimaxh3.cpp): ref_parts emits keyframe cond parts FIRST; the step
scatter admits kR2VCond/kR2VCondAudio rows.
- tests: video_gen_test keyframe-completes-widens-the-step-and-pins-the-ends
(2x Vencode at slot 1,2; widened step; seg_cu/lat_cu/ref_tab pinned); fake_pack_ref
lays keyframe rows (nk=0 byte-identical to before); videos_test keyframe API.
Device-verified (TP2, seed 9999): FL2VA completes a valid 73-frame MP4+AAC; pins
are consumed (fl2va != same-seed t2va) and force the endpoints (frame0 vs anchor
0.687 pinned vs 0.460 un-pinned; last 0.719 vs 0.521). Fidelity follow-up (not
function): anchors ride as pins only; the reference also feeds them through the
TE as vision tokens, so a prompt that contradicts the anchor lets text win --
full endpoint parity vs a golden needs TE-anchor tokens (#10/P6 bucket).
Co-Authored-By: Claude <noreply@anthropic.com>
Chaining already works via ref_video; the FL2VA exact-pin is an alternative
mechanism whose fidelity claim has no golden on this box, and its wiring lands
in the shared step_dit — so it is left pending rather than blind-changed.
Co-Authored-By: Claude <noreply@anthropic.com>
Record the fixed-shape TP2 wall-clock (plain 256/3s/25st=12s, 512/3s/25st=38s,
full-shape ref2va 256=93s / 512=121s). Encoder value-parity half of P6 is done;
the dual-vs-two-singles claim is documented as blocked on the external Hermes
sol-attn ComfyUI baseline (the 590/315 rows are stock-attention floors that
include queue wait), not on anything in this branch.
Co-Authored-By: Claude <noreply@anthropic.com>
In step_venc the ResnetBlock shortcut conv (op_sc) was issued after norm1
(op_n1), but on a shortcut level norm1 normalizes the input `in` IN PLACE
(nb = E.in), so the 1x1 nin_shortcut residual was fed silu(norm1(x))
instead of the raw x the reference uses:
ResnetBlock3D.forward: x = self.nin_shortcut(x) # raw, before any norm
return self.conv2(h, pre_norm=norm2, residual=x)
This shrank the residual term on every shortcut level (cout != cin, i.e.
levels 1 and 3), producing the ~0.49x structural deficit that accumulated
down the video/image VAE trunk. Reorder op_sc to read `in` before op_n1
overwrites it -- an op reorder, not a kernel change; it corrects the SHARED
trunk so the image encoder's fidelity is fixed too.
Localised by a frame-0 per-level bisection: R4D_ENC_SEL=all now dumps
frame-0 f32 shadows of every level's post-resnet output v_lv[0..4].a
(dbg_ve_l0..l4, a 9-buffer host slab) alongside the existing tail, and
ref_venc_parity.py --evcl0..--evcl4 compares each against the reference
level output on the device's own staged pixels. The std ratio walks to the
exact entry point -- conv_in 0.999, L0 0.999, L1 0.455 (first shortcut
level) -> every level 1.000 after the fix, tail nout/q48/q2 to the bf16
floor (relFro ~4e-3, affine 1.000). Device-live: a single-image ref2va
encode generates clean with the fix loaded.
Co-Authored-By: Claude <noreply@anthropic.com>
Adds a fourth R4D_ENC_SEL=all shadow — the norm_out INPUT (v_lv[5].a, level-5 trunk) as an
f32 PERSIST cast twin (b_vtrunk), via a new trailing RadVideoGenDecl field dbg_ve_trunk (no ABI
bump) + layout rows + a 4-readback "all" slab (trunk|nout|q48|q2). ref_venc_parity.py gains
--evctrunk (whole-volume vs per-frame GroupNorm discriminator) and --expand/--zeropad (single-frame
temporal tests).
Device-anchored golden comparison on a 256x256 image exonerates, one by one: input normalization
(byte-identical affine + IMAGENET consts), norm_out (faithful, relFro 1.6e-3), GroupNorm extent
(device already per-frame; #20 closed), temporal handling (reference frame0 std flat 8.986 at N=1..17
under both replication and zero-padding vs device 4.40), a single multiplicative gain (nout differs
0.57 non-affinely after per-group norm => structural), and weight precision. The gap is a structural
~0.49x spatial-trunk deviation (conv_in/resnet/spatial-downsample), NOT confined/golden-fixable, so it
is documented precisely and left open — no shared-kernel edit. Host tier green.
Co-Authored-By: Claude <noreply@anthropic.com>
Rewrite the superseded "shared final-norm / encoder-norm-kernel scale fault"
narrative: the audio ~0.37x under-gain was a pre_block norm1/norm3 swap (a
wiring bug), now fixed and device-verified. Records that the shared LayerNorm
kernel is demonstrably fine (audio matches using it), which kills the
"one norm damps both families" hypothesis; the video/image (conv3d) encoder has
no pre_block and remains a separate, open divergence (with the GN-extent gap
#20 stacked on it). Keeps the pre-fix measurements as labelled history.
Co-Authored-By: Claude <noreply@anthropic.com>
The reference AttnProjection (comfy/ldm/minimax/audio_vae.py:267) computes
proj(norm3(x)) + attn(norm1(x)), then + mlp(norm2(·)). The two 2048-wide
LayerNorms are not interchangeable: norm3's affine |w|mean is 0.60, norm1's
0.27, so the projection branch carries most of the block's magnitude (std 6.6
via norm3 vs 0.4 for the attention via norm1).
The device had them wired the other way -- it staged norm1 into the projection
and norm3 into the attention (qkv). Feeding the small-affine norm1 to the
projection shrank it 6.6 -> 1.8, collapsing the pre_block output and every
audio latent downstream to ~0.25-0.27x the reference.
Fix: stage norm1 for the attention (feeding p_op_qkv) and norm3 for the
projection (feeding p_op_proj). Both LN ops are the same ln(...,2048,b_apb->
b_aln3) kernel, so only the consumer wiring changed -- no kernel touched, no
re-convert (norm1.*/norm3.* weights are already loaded correctly).
Also adds a gated read-only R4D_ENC_SEL=amb readback (dbg_ae_amb = b_amb, the
f32 mean_proj input): the bf16 b_ax2 readback lags the arena and dumps garbage,
so b_amb is the reliable pre_block output used to localise the gap. Inert when
R4D_ENC_SEL is unset.
Device-verified (seed=7 tone, minimax-h3-ref2va-fp8, warm TP2): pre_block out
b_amb std 1.65 -> 6.43 (ratio 0.25 -> 0.97); final latent b_enca std 0.23 ->
0.546 vs reference 0.588 (ratio 0.39 -> 0.93), affine slope 0.385 -> 0.923,
R^2 0.975 -> 0.989. Host tier green (abi_layout/arch/ref/videos).
Co-Authored-By: Claude <noreply@anthropic.com>
Architecture refutes the "per-level attenuation compounding" reading: both encoders
TERMINATE in a normalisation that re-writes activation scale (video norm_out=venc_gn
before conv_out/quant_conv; audio pre-block norm1/2/3 LayerNorms before proj/mean_proj).
A GroupNorm/LayerNorm output has std ~= its per-channel gamma regardless of input, so
any gain accumulated in the encoder BODY is erased before the latent is emitted. The
~0.37 can therefore only originate in the FINAL norm's affine application or the final
conv/linear: video norm_out(gamma)->conv_out->quant_conv; audio norm3(gamma)->proj->
mean_proj. The two families' scale differing slightly (0.385 vs 0.369) is simply those
final chains differing per arch.
Re-explains encoder-confinement cleanly: the DiT uses RMSNorm (rmsnorm_op), the encoders
use GroupNorm/LayerNorm kernels (shared with the latent upscaler) -- a defect in those
kernels is invisible to the DiT's RMSNorm path, consistent with the DiT generating
correctly. Narrowed confirming step recorded: dump per-channel std of norm_out output and
conv_out/quant_conv output (and audio norm3/mean_proj) -- post-final-norm std ~0.37 pins
the norm affine/kernel; ~1.0 with collapse only after conv_out/quant_conv pins those
conv weights. Not blind-fixed (shared with live image/plain + upscaler paths).
Also records a SEPARATE real fidelity gap found while localising (task #20): the device
GroupNorm reduces statistics over a level's whole clip volume, but the reference
TemporalIsolatedGroupNorm normalises per frame. Exactly neutral for the single-image
parity measurement (T=1) but it biases real multi-frame video reference encodes -- what
DaSiWa actually feeds -- as a shape change stacked on the 0.37. Recorded, deliberately
not touched (shared kernel; whole-volume pooling may be an intentional temporal choice).
Co-Authored-By: Claude <noreply@anthropic.com>
Fit a single global affine dev_sorted ~ a*ref_sorted + b to both encoders' value
distributions (both harnesses now print it):
audio (conv1d): a=0.385 b=+0.009 R^2=0.975 relFro 0.79 -> 0.062 after affine
video (conv3d): a=0.369 b=+0.159 R^2=0.912 relFro 0.65 -> 0.114 after affine
Two entirely different encoder networks both reduce to ~0.37x the reference with
R^2 0.91-0.98 -- near-perfect linearity. This overrules the earlier "not a single
scale" and "suspect the strided conv1d temporal reduction" readings: a conv-reduction
or structural transform bug would not collapse to a clean global scale. The device
encoders compute the right SHAPE of latent, damped to ~0.37x amplitude. The scale is
~0.37 for both but not bit-identical (0.385 vs 0.369) => not one shared post-multiply,
but a fixed per-level attenuation compounding over each arch's own depth.
The DiT generates correctly on the same fp8 path and the same normal kernels, so this
is not a global kernel/quant fault -- the under-gain is confined to the encoder pass.
Prime suspect: the encoders' per-level / per-frame GroupNorm (the per-frame CS in
{8,4} template) applying a near-constant sub-unit gain that compounds level-over-level,
or an encoder-path dequant scale mismatch the convert round-trip does not see. If it is
a fixed encoder-norm gain, a fix is confined to the encoder path and never touches the
DiT's norms -- which is why this is worth localising rather than shipping. Not
blind-fixed (encoder kernels are shared with the live image/plain encode paths).
Confirming step is cheap and read-only: dump one encoder block's GroupNorm input AND
output on-device, check whether output std is a fixed fraction of the reference GN.
docs/NOTE-REF2VA.md point 4 corrected (the superseded "not a single scale" clause) and
the affine table + encoder-specific-under-gain hypothesis recorded.
Co-Authored-By: Claude <noreply@anthropic.com>
The audio half of the #14 strict numeric value-parity was already measured and
found to diverge. This measures the OTHER half — the conv3d_ndhwc video/image
encoder, a separate kernel family — the same device-INPUT-anchored way, and it
diverges too, with the SAME signature.
New harness tests/data/ref2va/ref_venc_parity.py:
- Does NOT import comfy.ldm.minimax.vae (that drags comfy attention -> an aiter
JIT build that fails on this box), so like vae_geom/gen_golden.py it
AST-extracts just the encoder classes + the _normalize_pixels /
_encode_moments methods, execs them on torch alone, and loads the REAL fp16
minimax_h3_video_vae_fp16.safetensors into encoder+quant_conv (decoder
excluded; the encode path has no attention). --selftest validates the
reshape / normalisation / sorted metric with no device involvement.
- Device stores b_evc PATCH-FOLDED (op_ve_fold: 24ch x 2x2 = 96-wide rows) and
per-channel-normalised. The fold is a pure bijection and the norm is
per-channel, so the value MULTISET of the device slot region matches the
reference's normalised latent regardless of fold order; the harness compares
the two SORTED value vectors. This is immune to re-deriving the fold's
(t,h,w)+channel packing — the mistake that once cost a bogus audio reading.
- A single reference IMAGE is the cleanest case (encode()'s T==1 branch, one
clip, exactly one latent frame), so keep-first/last is moot; the harness
refuses T_pad!=1.
Two inert, R4D_ENC_DEBUG-gated dumps added to core/gen/video_driver.cpp (the
staged pixel buffer + enc_geom, next to the existing audio ones) so the
reference can be fed the device's OWN staged input and only encoder math can
differ. Zero-touch when R4D_ENC_DEBUG is unset.
Result on a 256x256 gradient picture: sorted relative Frobenius 0.65, device
latent std 0.44 vs reference 1.15 (~2.6x under-spread), max-abs 4.26. DIVERGED
like the audio path.
The finding is the SHARED signature: audio collapsed std 0.59->0.23 (~2.6x) and
video 1.15->0.44 (~2.6x) across two entirely different kernel families, AND for
BOTH families the latent-normalisation constants are byte-identical to the
reference (kVaeLatentsMean/Std vs LATENTS_MEAN/STD max rel-diff 0.0). So the
collapse is NOT the norm constants and NOT audio-specific — this refines the
earlier "suspect the strided conv1d temporal reduction" note. Localising it
needs stage-by-stage activation dumps on kernels the live image/plain paths also
run through, so the kernels are deliberately NOT blind-fixed. The device
encoders remain content-live and deterministic (cont.3/5/19): self-consistent,
so conditioning is genuinely live; only reference-matching OUTPUT fidelity is
open (= #10 / P6).
docs/NOTE-REF2VA.md point 4 records the video-half result and the sharpened
ruling-out of the normalisation constants.
Co-Authored-By: Claude <noreply@anthropic.com>
The device stores a slot's stereo latent channel-major with per-channel row
stride MAXA=625 (ch1 at base+625), not contiguous after ch0; the harness sliced
contiguous rows and thus compared reference-ch1 against device zeros. Fix the
slice to vstack the two channel blocks. With the correct slice the audio encoder
measures relative Frobenius 0.79 / corr 0.67 / device std 0.23 vs ref 0.59 — a
real encoder-network divergence, not fp8 precision (unbiased, floor ~1.6e-3),
not preprocessing (device-input-anchored), not the reference export (97 shared
encoder tensors bit-identical to the HF source), not the norm constants
(identical). Recorded honestly in NOTE-REF2VA: measured on audio; video/image
VAE is a separate kernel family, not yet measured; functional conditioning is
unaffected; kernels deliberately not blind-fixed.
Unblocked by the on-box torch env. ref_aenc_parity.py loads the reference HF audio
VAE (fp32) under ComfyUI's --cpu branch (no GPU context — the TP2 server holds both
cards), and compares the device's b_enca normalised latent to the reference encode()
run on the device's OWN staged enc_samples buffer. Device-input-anchored => removes
every decode/normalise/pad confound; a kernel bug shows gross, a correct fp8 port
shows at/below the ~1.6e-3 convert quant floor. --selftest validates the reshape /
slot / metric logic without a device (perfect->0, temporal-misalign->0.24).
Driver side: extend the R4D_ENC_DEBUG scaffolding to raw-dump the staged enc_samples
(host buffer at stage time) and the b_enca / b_evc readback to R4D_ENC_DUMPDIR.
Inert unless R4D_ENC_DEBUG + R4D_ENC_DUMPDIR are both set; host tier green.
Reference model.py re-baked golden.json byte-identical (no reference drift).
Re-baking golden.json under the on-box torch env (comfyui-rocm10-venv, torch
2.13.0+rocm) came out byte-identical, proving: (1) the reference model.py has not
drifted, and (2) the pack keyframe/cond golden is NOT stale or torch-blocked —
pack_golden_fl2va / _chain already assert kR2VCond layout bit-exact and pass. So
#8's PACK layer is reference-verified; only the engine consumption (driver keyframe
staging, step_dit cond scatter, tail input) is unwired. Corrects point 3's 'pack
keyframe rows remain unimplemented' and point 4/6's 'this host has no torch' (the
encoder value golden is now actionable, not blocked — not yet produced).
Wall-clock per job on TP2/dual-gfx1201 (empty queue, completed_at-created_at):
plain 256/512, step/duration/resolution scaling, and the full DaSiWa reference
shape (4 img + video + soundtrack + standalone audio). Conditioning cost is the
widened sequence, not the encoders. Self-contained scaling figures, NOT a
ComfyUI parity claim (parity = open, needs reference stack).
Acceptance test #5 on dual gfx1201/TP2: one request with 4 images + a video +
its soundtrack + a standalone audio is accepted and completes clean; changing
only the standalone audio at a fixed seed changes BOTH output streams, proving
the full-shape denoise consumes the audio reference (not just its count).
PLACEHOLDER AUTHOR — re-author before any push. Do NOT push.
Co-Authored-By: Claude <noreply@anthropic.com>
The gap note still asserted a defect the device probes disproved. All three
reference kinds (image, video, audio) are device-verified live + content-sensitive
+ deterministic on a warm-server fixed-seed content-control; the earlier
'video/audio give byte-identical output, encoder collapses' claim was a
measurement artifact (raw-MP4-byte comparison + a cold-start pair). Continuity
chaining is drivable today through the ref_video path (a control shows the tail
conditions scene B); the kR2VCond keyframe-pin mechanism stays open (FL2VA
exact-pin, reachable via image refs). Strict numeric encoder value-parity is
environment-blocked on a torch-less host and was never the claim.
PLACEHOLDER AUTHOR — re-author before any push. Do NOT push.
Co-Authored-By: Claude <noreply@anthropic.com>
Follows the merged-cell pin (c725a2d). That commit proved reference IMAGE
conditioning consumed on device; reference VIDEO and AUDIO were plumbed
through the pack and step but still refused at submit — only their decode
and encoder-enqueue were missing. This lands them.
Server (videos.cpp): `task ref2va` now decodes `ref_video_N` and
`ref_audio_N` (and a video's paired `ref_video_audio_N`) into encoder form
via the mm encoders and enqueues them as Vencode/Aencode passes, instead of
the old image-only decode loop that rejected them. A soundtrack is folded
into its video's row (the `audio` word), matching how the pack lays that
pair. Caps stay <=9 images / <=3 videos / <=3 audios.
Driver (video_driver.{h,cpp}): the encode queue `enc_q` now carries VIDEO,
VAUDIO and AUDIO items in presentation order; `ref_tab` stamps each
reference's latent counts straight from the encoder geometry (rad_arch_encode_geom:
a video's frame count eg[24]=its total latent frames, its soundtrack's eg[12]),
so the pack's ref segments are sized by the encoder, not hand arithmetic.
processor.{h,cpp}/iface.h/adapters.h gained the media decode entry points.
Arch (minimaxh3.cpp): step_dit scatters reference rows into the packed step —
picture/video via op_vin from b_evc, audio via op_ain from b_enca, at each
segment start, targets last. A bounds audit confirms the scatter reads exactly
the slot region the encode pass wrote this job (eg[24]=lat = the pass's
written row count = the pack's segment size; no stale-neighbor read).
DEVICE-VERIFIED on dual gfx1201 / TP2, warm server, fixed seed, comparing
DECODED stream md5 (never raw mp4 bytes — the muxer stamps a field): all three
reference kinds are DETERMINISTIC (a rerun of one reference is bit-identical,
including raw bytes) AND CONTENT-LIVE (a different reference at the same seed
gives different output video AND audio). Image (content tokens), audio
(tone/noise/880 distinct) and video (refv_a vs refv_b: both streams differ)
each steered the generation. An earlier "the video step is nondeterministic"
note was a measurement artifact — it compared raw mp4 bytes and straddled the
one-off cold-start outlier; the warm decoded-stream probe is bit-reproducible.
Debug scaffolding (R4D_ENC_DEBUG, 4 trailing RadVideoGenDecl fields + a pinned
driver slab + an FNV digest in done()) is entangled in these files. It is
env-gated and zero-touch when unset; STRIP IT BEFORE ANY PR.
tests: video_gen_test/videos_test/server_fakes cover the video/audio enqueue
paths; abi_layout_rows adds the new trailing rows; ref_audio_sensitivity.py is
a standalone host golden harness (audio reference separates 4/4), not a ctest
case. Host tier green (only mm_test's pre-existing webp demuxer gap fails, and
the GPU card/kbench tests fail solely on VRAM contention with a live server).
NOTE-REF2VA.md updated: continuity tail (#8) remains unimplemented; strict
numeric parity vs the ComfyUI CPU reference remains open.
PLACEHOLDER AUTHOR — repo has no git identity; re-author before any push.
DO NOT PUSH this branch.
Co-Authored-By: Claude <noreply@anthropic.com>
New models:
- LTX-2.5 (base and distilled): video with a stereo soundtrack from text or from text and a first
frame, on one card, with its duration head, tiled VAE decoding, the diffusion decoder and the x2
latent upsampler
- Krea 2 Raw and Turbo, and FLUX.3 [klein] and its base: text to image, and for FLUX.3 edits from up
to ten reference pictures, on one card
- GLM-5.3-Flash from AMD's Quark MXFP4 export, on eight cards (John McDonough, Nunze)
- Gemma 3 / TranslateGemma 27B with an optional DFlash2 drafter (mici81)
Engine:
- --kv-cache-dtype fp8_v4 and k6_v4 for Gemma 3 and Qwen3.8-Flash-Next (mici81)
- the rotated int8 trunk (i8a8h) for Qwen3.8-27B (eddie168168)
- eight-rank all-reduce bands, weighted shards and pieces (Nunze); --host-headroom-mib (sfjes)
- the dashboard shows the single-stream decode floor and its most recent window (Memoria)
Fixes: prefix-cache reservations kept until their save lands (baKon), tool calls in Responses
namespaces (#119), system messages merged when a template refuses several (#137), a prefill
continued with no open step (#127), calibration of a Gram accumulation (#122), JSON Schema patterns
read unanchored (davetha), GLM-style tool calls, the KV floor counting every sequence's state.
Plugin ABI 24.
The glm5next section of ARCHITECTURES.md (geometry, traps, KV groups, linears, tensor parallelism,
the MoE decode fusions, measurements), the conversion and the four RADIANCE_GLM_* variables in
GUIDE.md, the README's models table. deploy/compose/glm53-flash.yaml serves the container on eight
R9700s with the expert plane resident and the native MTP layer drafting, with the flags of the
measured run.
Co-Authored-By: John McDonough <18016200+JohnCMcDonough@users.noreply.github.com>
An architecture plugin for GLM-5.3-Flash (45 layers, 4096 wide) from its Quark MXFP4 export: four
mHC residual streams; KDA layers and full layers with absorbed MLA behind the DSA indexer; a MoE
block of 288 MXFP4 experts (top 8, sigmoid routing with a correction bias and route_scale 2.5) and
an ungated shared expert; clamped SwiGLU; the block-fp8 attention and MTP weights at their f32
scales; and its native MTP layer as the drafter. Under tensor parallelism experts shard by width,
MLA by whole heads, and the f32 router and index-head projections split their columns from 256 rows.
The MoE block's decode fusions are on by default (RADIANCE_GLM_ROUTER_FUSE,
RADIANCE_GLM_SWIGLU_QUANT, RADIANCE_GLM_GATHER_INVERSE; 0 restores the separate launches, byte for
byte). Its tool-call format is derived from the chat template, as for the other models.
data/recipes/glm53-mxfp4.recipe decodes only the combined MLA projection to bf16; every other
weight keeps its stored encoding.
arch_test declares the model at one, two, four and eight ranks and lints its steps: the mHC
connections, the routing's f32 path, the head-complete MLA shards, the indexer's cache pages and
tail ring, KDA's local heads, the expert geometry at TP4 and TP8, that the sizing declares give
the real graph at every arena level, where the decode fusions replace their launches, and, with
the fusions off, a pinned graph and step hash.
Co-Authored-By: Nunze <lorenz.lamping1@web.de>
New blocks: mHC (rad_block_mhc.h), KDA and its state (rad_block_glm_kda.h,
rad_block_kda_state.h), absorbed MLA over a latent cache (rad_block_glm_mla.h,
rad_block_mla_latent.h), the DSA indexer and its paged key cache (rad_block_glm_indexer.h,
rad_block_dsa_cache.h), the correction-bias router (rad_block_glm_router.h), and rad_tp_split.h:
a replicated f32 projection computed column-split over the ranks and all-gathered, so every value
is the replicated one's bits (from RADIANCE_GLM_TP_SPLIT_ROWS rows, 256 by default).
The shared blocks gain what GLM's checkpoint stores, each off unless a model asks for it:
- LinearFP8 reads a block-fp8 weight whose scale plane is f32 (dtype fp8a8f32), and the import
check accepts that form beside bf16 scales.
- GateQuantFP8 serves a clamped SwiGLU (swiglu_clamped), optionally fused with its quantiser.
- MoeFP8 takes MXFP4 experts (format 8) and block-fp8 experts with f32 scales (format 9), the
sigmoid router with f32 weights, an ungated shared arm, the router/scatter fusion and the
sort's inverse handed to the gather (moe_scatter_inv, moe_gather_inv) where they resolve.
- The MLP's gated fold excludes the forms it cannot serve (f32 scales, a clamped product).
share_test checks that KDA's convolution weight shards per head across its three parts at TP4.
The device rows for GLM-5.3-Flash's ops, at its geometry and at TP4 and TP8 slices:
- mhc_pre / mhc_post / mhc_contract, and mhc_pre_partial / mhc_pre_finish, which run mhc_pre's
own projection and finishing kernels with its chunk-sum order, so the pair is byte-identical
to mhc_pre at n 4096, hc 4, chunk 2048.
- kda_update_k128_v128_bf16, one, two or four value rows a wave, both state forms.
- dsa_pool_fp8, dsa_query_fp8 and dsa_score_fp8 (fp8 WMMA, 32 heads of 128).
- mla_attn: a matrix row whose WMMA tile holds a query's heads, or pairs eight heads of two
neighbouring queries over the union of their page tables, above the wave row; mla_project
with up to eight rows a thread or wave.
- gemm_nt_f32 and router_sigmoid_topk in tiled and one-wave-a-row forms; gemm_fp8a8_f32scale
and moe_gemm_fp8a8_f32scale read f32 block scales in place; moe_gemm_mxfp4a8 decodes e2m1 into
exact E4M3 bytes for fp8 WMMA, with an expert-major decode form and a wide prefill form.
- swiglu_clamped, and the device-only fusions of GLM's MoE block: swiglu_clamped_quant_fp8,
router_sigmoid_topk_scatter, and moe_scatter_inv / moe_gather_inv, which pass the gather's slot
table from the sort instead of rebuilding it.
moe_gather takes f32 routing weights in its column-per-thread kernel. The sort and the gather
kernels move from r4d_moe.hip into r4d_moe_sort.h and r4d_moe_gather.h, so the fused router and
gather instantiate the same code.
Every form that replaces another gives its bytes: tests/r4d_emu runs the kernels on the host
(test_f32, test_fp8f32, test_kda, test_mhc, test_mla, test_moefuse, test_moemx), r4d_selftest
compares them on a card against libref and against each other, and plugin_test pins the
mla_attn band. docs/OPS.md states what libr4d serves.
Co-Authored-By: John McDonough <18016200+JohnCMcDonough@users.noreply.github.com>
The reference and CPU forms of the ops GLM-5.3-Flash's graph needs, with their schemas and shape
hooks: mhc_pre / mhc_post / mhc_contract and the column-split pair mhc_pre_partial /
mhc_pre_finish; swiglu_clamped; gemm_nt_f32 (bf16 activation, f32 weight and result) for the
router logits and the indexer's head gates; router_sigmoid_topk (correction-bias top-k);
kda_update with per-channel decay and both state forms; dsa_pool, dsa_query and dsa_score; and
mla_attn and mla_project for absorbed latent attention. moe_gather takes f32 expert weights beside
bf16, and fp8a8f32 joins the dtype list. docs/OPS.md states each op.
ref_test checks every op against hand-computed cases, avx_check_hand the CPU forms against
libref, build_test the indexer cache's page size.
Co-Authored-By: Nunze <lorenz.lamping1@web.de>
qsa_select ranks max(score, 0) and treats a score at or below -1e30 as dead: QSA's block scores
are sums of relus, so the clamp changes nothing there. GLM-5.3's DSA indexer weights its heads by
signed gates, and its block scores can be negative; ranked through the clamp, every negative block
ties at zero and the selection is wrong. `signed` 1 ranks finite scores as they are (-0 tying +0)
and treats nonfinite ones as dead; absent or 0 is the ranking as it was. libref, libavx and libr4d
take it together, since the three declare one schema. docs/OPS.md; tests/r4d_emu/test_qsa.cpp
runs both rankings against the reference.
With a lending cache the staging region (two buffers of one layer's off-card experts) always came
out of the cache, which left a large-context MoE model short of its configured coverage. Expert
residency above the host pool's floor now pays first; the cache pays only when the experts are at
their floor, and an expert with no other home is never evicted for it. The startup report names
whichever paid. mem_test (prefill_staging_*).
The floor a KV pool must keep for one --max-model-len request came from a separate plan at
max_seqs 1. A hybrid model's recurrent and conv slots are fixed per configured sequence and stay
allocated while one request is active, so that plan undercounted and the pool it allowed could
not hold max_ctx. The floor is now pool_mib_for_tokens over the real plan's groups. mem_test
(hybrid_context_floor_accounts_for_all_configured_state_slots).
GLM-5.3-Flash's Quark export is MXFP4 throughout except the layers it excludes, attention and the
MTP layer, which it keeps as 128x128 E4M3 block-FP8 with F32 scales and names in
layer_quant_config. Every nonempty override map was refused. Each override is now checked: MXFP4
(fp4, per_group 32, e8m0) or block-FP8 (fp8_e4m3, per_block 128 128) passes, anything else --
including a null or empty weight, which flattening used to drop -- is refused by name.
The expert counts read n_routed_experts and n_shared_experts as DeepSeek-style configs spell them
(GLM-5's included). checkpoint_test covers both spellings, the mixed export, and the refusals.
The note_ready comment claimed "the page divides by this figure", but the
submitted dashboard does not divide by startup_s (the payback formula that did
was removed). Reworded to describe the actual risk: a zero cost would price
every restart as free in any payback formula that divides by it.
Dropped CHECK(gap_pct >= 0) in the decode-floor drift test: recent >= floor
holds by construction (floor is the min of the window means, recent is one of
them), so the check can never fail. The load-bearing assertion is the adjacent
CHECK(gap_pct < 3).
Authored at: Tasmania Qwen 3.8 27B Dense XHigh (level not visible) via Open WebUI
(cherry picked from commit 98429a9b15d7da1aa0e644cbd7e519d1bf33d797)
100% would claim a sustained floor the ~500 ms poll window cannot
confirm, and would read as a bug the moment a fast stretch briefly beat
the 32-step floor. Cap at 99 and show it with a tilde: "now ~99% of
best" says "at your best" without overclaiming. Anything slower still
reads a plain percentage of the floor.
Operator-directed 2026-10-18.
Authored at: Tasmania Qwen 3.8 27B Dense XHigh (level not visible) via Open WebUI
(cherry picked from commit 7c35068e60d8a7baf61483e4d2a6452d71e0bc6f)
The tile's detail line gained a third figure in 4fe6ff1 (now X% of best)
and a 100% cap in e083a2d; the GUIDE still described only the two engine
figures. Document the percentage: 100% is the fastest, anything slower a
percentage of it, capped at 100 because `now` is a ~500 ms poll mean while
`best` is a 32-step window mean, and keyed by concurrency above c1.
Authored at: Tasmania Qwen 3.8 27B Dense XHigh (level not visible) via Open WebUI
(cherry picked from commit 7263163748b98c1e5b5c9d4fa3e7fe8fed924678)
`now` is a ~500 ms poll mean; `best` is a 32-step window mean. A fast
stretch shorter than a window can therefore read faster than the recorded
floor, which the ratio printed as >100% -- "105% of best", which is a
contradiction: if it beat the best, the best should have moved.
The engine only ratchets the floor on a completed 32-step window, so a
sub-window blip is not a new record. Cap the figure at 100: a live window
at or above the floor reads "100% of best" (at your best), and anything
slower reads a percentage of it. The "best X ms" figure is unchanged.
Operator-directed 2026-10-18.
Authored at: Tasmania Qwen 3.8 27B Dense XHigh (level not visible) via Open WebUI
(cherry picked from commit e083a2d606c2194539bd0640916fb0ae0852962e)
The suffix was a ratio of time (100 * lastStepMs / ref): the fastest step
read 100% and anything slower read ABOVE 100% -- 18.75 ms against a 15 ms
floor printed "125% of best". Slower meant bigger, which is backwards.
Flipped to a ratio of speed (100 * ref / lastStepMs): the fastest reads
100%, anything slower reads a percentage of it (the same pair now reads
80%), and the figure can never exceed 100% because ref is always the
minimum. The "% of best" label now says what it shows.
Operator-directed 2026-10-18; live-verified on the Tasmania lane
(best 33.73ms / recent 35.76ms -> "94% of best").
Authored at: Tasmania Qwen 3.8 27B Dense XHigh (level not visible) via Open WebUI
(cherry picked from commit 6540ff811addc15288e6fcaa09b37b6c82ee7ebb)
The drift line carried a percent-of-best suffix that left with the drift
verdict on 10-18. Restored as a raw ratio, keyed by concurrency: a c8 step
against the fastest c8 step this process has done, never against the
single-stream floor (that cross-read is what made the old line lie about a
batch arriving). No threshold, no colour.
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (level not visible) via Open WebUI
(cherry picked from commit 4fe6ff1c838d67b642cc12782ce6a441368c3d76)
The five-rung chain that produced step_ns_decode_best/recent: the raw min that
latched 1.16 ms, the two guards refuted by measurement before being built, the
phase gate that passed 38,820 checks and failed live, window averaging that kept
a 10%-low floor, and the advisory whose premise — step time ratchets with engine
age — survived a day of watching zero observations. The advisory was deleted,
not tuned: the gap it priced is operating load (3-11% on a healthy lane), and
the payback formula assumed a permanent gain the lane never offered.
Written for the next contributor tempted to add a gate, a smoother, or a verdict
here: each rung's temptation was to add mechanism, and each rung's cheap move
was to measure the premise first.
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (xhigh) via Open WebUI
(cherry picked from commit 9260f8e646c95aa8537d5e632a948bc54653c2ba)
The tile now shows two engine figures and no verdict, so the guide says what
they are: window means of 32 single-sequence steps, best the lane's most
favorable moment and recent its current one. The load-bearing sentence is the
one nobody can derive from the numbers: a gap of a few percent up to ~11% is
operating load on a shared card, not degradation, and not a reason to restart.
That claim is measured, not stylistic — the live lane held a flat floor while
its recent window moved 3-11% with what else the machine was doing.
Cross-references rad::DecodeFloor and the devlog for how the interpretation was
tested and withdrawn.
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (xhigh) via Open WebUI
(cherry picked from commit 604617bd72b7360d3855acac5e96d82e51ef91b7)
The decode step's detail line now shows two figures the engine measures itself: the
fastest single-sequence decode window this process has run, and its most recent
one. Nothing is asked of the reader -- no ruler to type, no panel to open -- and
no conclusion is drawn.
Both come from the engine rather than the browser because the browser cannot
produce either well. A tab only sees the steps taken while it is open, and a floor
learned from a lane that was already degraded says "at your best" forever. The
engine sees every step and knows the concurrency of the step it timed.
Single-stream on both sides of the engine's own measurement. The floor is a
single-sequence window, so the engine keys it to one row: a decode step at eight
sequences is a different measurement, and reading it against a single-sequence
floor would report a batch arriving as a slowdown. On an engine too old to emit
the field, the page falls back to the fastest single-stream step this tab has
seen.
This commit previously also priced a restart, and that clause is removed here
after being built, deployed, measured, and refuted on live traffic the same day.
It compared the floor against the recent window, called the gap drift, and
computed a payback from startup_s. The gap is not drift. On a healthy shared lane
the floor held flat at 14.79 ms while the recent window moved between 15.2 and
16.5 ms -- 3% to 11% -- tracking what else the lane was doing: it froze when the
lane went idle and rose on a fresh short request, so it was neither context
length nor engine age. The payback formula assumes a restart's improvement is
permanent, so following it pays the measured 49 s bringup and re-drifts within
minutes; the line was advising a restart every 12 to 19 minutes forever, for a
gain that was never there. What floor-vs-recent actually measures is the distance
between the lane's most favorable moment and its typical one.
An earlier version of this clause also compared the engine's floor against a
median of the browser's per-poll means -- two instruments over different sample
counts, disagreeing by pure order statistics on a flat engine, a measured 7.7%
phantom drift. That is why the two figures shown now are both engine window means
of one stream at one size. They are honest numbers; only the interpretation was
withdrawn.
A verdict can return once someone observes what none of this data shows: step
time rising with engine age and staying up. Every excursion measured was load.
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (xhigh) via Open WebUI
(cherry picked from commit 2eaf32201cb1a8c45857dfbb509a12acaa9ee216)
A restart's cost is the one number a reader needs in order to decide whether one
is worth suffering, and any guess at it would decide the answer by itself. The
server knows it exactly: the interval from process start to the socket listening,
on this machine, with this model and this cache state.
Emitted on /stats as startup_s, 0 until the server has listened. Raw figure only
-- the page no longer consumes it. It is here because it is the missing half of
any restart decision a human or a tool makes downstream, and because the
decode-step advisory that did consume it was withdrawn the same day it shipped
(see the following commit for what the live data showed).
Trailing zero-defaulted field on both SchedMetrics structs plus the adapter copy;
neither struct is ABI-pinned, so this is the sanctioned append.
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (xhigh) via Open WebUI
(cherry picked from commit 76a9e2f7a28b8e034cfd56caa091792c68fe19b6)
The dashboard's restart advice needs a reference the degraded engine is read
against. Asking a human to type a ruler is fragile (a stale or mistyped number
silently mis-advises) and cannot see steps taken while the dashboard tab is
closed. The engine sees every step and knows the concurrency of the exact step it
just timed (plan_.n_seq_decode), so it can keep the reference itself.
Records two figures over single-sequence decode steps: the floor (the fastest
window mean this process has measured) and the current (the most recent window
mean). Both are window means of one stream at one size, so the advisory compares
like with like. A min, not a max: drift only raises the CURRENT step, so the
reference a degraded engine is read against is its own demonstrated floor.
Single-sequence on purpose -- a decode step at eight sequences is a different
measurement, so keying the floor to one row keeps a batch arriving from being
misread as drift. A mixed step is excluded by the phase gate even when it carries
one decode row: that row shared the step with a prefill chunk an order of
magnitude dearer.
Why not a raw min over step brackets: step timing is host-side, and with
pipelining on the next forward pass is issued behind the current step's commit.
Behind a step with long host work -- a prefill chunk, or a decode step that saves
a KV checkpoint -- the decode pass is finished before its own bracket opens, so
the bracket holds readback and commit and no GPU work. It is a real step
advancing a real token, so no token-count or predecessor-phase guard catches it.
A raw min latches that degenerate on the first occurrence and never recovers:
measured live 2026-10-18 on a TP2 R9700 lane, 1.16 ms against a 15.55 ms mean on
the first request after bringup.
Why averaging alone is not enough: these degenerate brackets are not rare. At the
observed ~1.4% rate a min over hundreds of windows reliably lands on a
degenerate-heavy window, and the floor sits ~10% below the true floor -- still
phantom drift, because the engine can never reach a floor that was an artifact.
So a candidate is rejected BEFORE it enters a window when it is under half the
running mean of accepted steps: degenerate brackets sit at ~9% of a real step and
real single-sequence steps at ~96%, so the populations are ~10x apart and any
threshold between them separates them -- 0.5 is the midpoint of that gap, not a
value tuned to one distribution. Filtering at the step level is essential; at
this rate a degenerate dilutes inside a 32-step window to ~0.91x, which no
window-level threshold would catch.
The first window is recorded by neither figure. The rejection gate needs a
window's worth of accepted samples before it can judge one, so the first window
is un-gated by construction; recording it lets the floor latch an unreachable
value forever (measured: a 5% degenerate rate put the floor ~2% low through
bootstrap alone). The cost is one window -- about a second of single-stream
decode -- against a 46 s bringup and a 10 s repaint, so it is never observed.
The estimator is a small struct (rad::DecodeFloor) so it is testable on a
synthetic stream: the scheduler fixture runs steps in microseconds and cannot
manufacture a degenerate bracket, which is why the first round of tests missed
this. The tests feed streams laced with degenerate-short samples, assert a raw min
latches them, assert the estimator rejects them and tracks the true floor, and
assert the rejection does not eat real steps.
Emitted on /stats as step_ns_decode_best and step_ns_decode_recent (0 until the
first gated window completes). Trailing zero-defaulted fields on both SchedMetrics
structs plus the adapter copy -- neither struct is ABI-pinned (scheduler<->server
internal), so this is the sanctioned append. Matches the kv_tokens_max
running-extremum precedent.
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (xhigh) via Open WebUI
(cherry picked from commit bf5a803deaa08ae0c2d94e2c3dda0d518c08d9aa)
Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (level not visible) via Open WebUI
(cherry picked from commit d1dd050d5165536885840fb485f7041706938f8c)
A modulation cell is a pure function of a segment's kind -- (modality ada,
timestep block) -- so all reference photos share one cell. Runs of consecutive
same-cell segments collapse to a group; group boundaries are a subset of the
fine segment boundaries and the merge is sequence-length independent (the key
is kind alone). The modulated norm now reads COARSER group boundaries via a new
trailing RadVideoGenBatch::mod_cu while attention keeps the fine seg_cu, and the
fixed-width table is pitched by GROUP count. Nine photos therefore occupy four
groups (prompt / all-photos / soundtrack / video); buffer sizes and the arena
are unchanged (kMaxSegs stays 8, no kernel change, no re-convert).
No regression for <=5 photos: each photo cell already filled its own column from
the same input rows and weights, so it was bit-identical to the others; merging
issues it once instead of N times and yields the same per-row value. Only the
previously-rejected sixth through ninth photos change, by being allowed.
Driver: rad_arch_video_mod_segs (trailing plugin export) computes the merged
groups host-side; the driver stages them into R_MOD, guards the GROUP count
against max_ref_segs at submit (a clean refusal beats a step-loop fault), and
the plain path stages the fine table into both operands.
Device-verified on dual gfx1201 / TP2 with a CONTROLLED same-seed battery
(task=ref2va, seed fixed on every job, so neither the seed nor the token count
is a confounder): same prompt, same seed, same ref-count, DIFFERENT image
content give DIFFERENT outputs -- the reference is genuinely consumed. Nine
photos complete (the case the pinned build refused at submit), whole-run fault
scan clean.
Adds docs/NOTE-REF2VA.md: what this port reproduces of the DaSiWa workflow and
what it does not -- the residual 8-group ceiling under heavy interleaved mixed
refs, the reference-token / row budget, continuity tail (unimplemented), the
video/audio reference paths (plumbed, not yet device-verified), references x
latent-upscale exclusion, and open conditioned-step parity.
Co-Authored-By: Claude <noreply@anthropic.com>
Ref2VA ref-image conditioning verified on-device: ref step runs all steps no
fault; output differs ref-present vs ref-absent (by log). 6-9 images rejected
cleanly at submit (no engine crash). Merged-cell modulation (<=9) tracked next.
NOTE: placeholder author -- re-author before any push. Do NOT push this branch.
Co-Authored-By: Claude <noreply@anthropic.com>
GLM-5 writes <tool_call>NAME<arg_key>K</arg_key><arg_value>V</arg_value>...</tool_call>: no
prefix of the name's own and no suffix, the name ends at the first argument or at the call's
close. The tagged family now takes an empty name_suffix when name_prefix opens the call (no
call_open): the derivation from the template makes the per-call opener the prefix and its closer
call_end, the grammar takes eps() for the suffix, and the streaming parser finds the name's end
byte by byte (name_stop, name_plausible) and reads the closing tag as the first item of the
body. arg_name_suffix and arg_value_prefix may both be set and are read back to back, so
chat_format_markers keeps both tags. value_newlines comes from a probe render of the template
rather than a constant (GLM and MiniCPM false, Qwen true). The ABI struct is unchanged; its
comments say what an empty name_suffix means now.
chatparse_test: GLM's template serves tools; the derived format equals the one a plugin would
declare; every rendered reply in the corpus reads back as the message it rendered, split at
every byte; and replies that stray from the grammar. Each fails without this change. The Gemma
refusal names call_end.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The template as GLM-5.3-Flash ships it, in cases.json beside the other four, with its goldens from
mkchatgolden.py (jinja2 3.1.6); bos is empty, eos <|endoftext|>, and no media, since no
architecture here reads its pictures. It needs the dotted index (vendor/patches/0021).
Two cases leave it out: an assistant turn with tool calls and content null. The template prints
that content bare ({{- content }} in visible_text), so jinja2 writes "None" into the turn, and the
engine, as llama.cpp's runtime does, writes nothing. The golden would hold the engine to a
template bug; the reply-side tests for this format read those turns instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kv_store_fp8v4 / k6v4 and the folds now read v_scale as the fp8 store does (attention already
applied v_descale). Scales are clamped to 8188 (V) and 2112 (K) so 7 or 31 times them stays an
f16: a group gone inf or NaN decodes finite, as E4M3's clamp to 448 does. r4d_selftest adds
decode at ctx 1000 (a partial last block) and q_len 7 (three waves) for both layouts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The flag sets the trunk's cache to E4M3 plus a RAD_KVQ_* layout; a plugin offers the layouts it
serves in its probe and the server refuses any other, naming the plugin. qwen35_fp8 offers both
at head_dim 256, gqa 6, and declares the group at head_dim 200 / 176 (the row's bytes / 2), so
the core sizes pages as for fp8; a drafter's cache stays fp8. Qwen3.8-27B on two R9700s, KL
against bf16 on 17 long documents: fp8 0.039963 (518,800 tokens of KV), fp8_v4 0.040076
(664,400), k6_v4 0.039965 (755,184); prefill and decode at fp8's speed. ABI 23: two trailing
fields, the layout table regenerated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two narrower layouts of an attention cache, a head's dims in groups of 32 with an f16 scale:
fp8_v4 (E4M3 K, int4 V; 25 * head_dim / 16 bytes a token and head) and k6_v4 (int6 K, int4 V;
22 / 16). kv_store and qk_norm_rope_gate_kv_store write them (the folds byte-identical to the
pairs); attn_prefill / attn_decode at h256 gqa6 widen the codes to f16 in a tile's staging, V a
key pair's 8 dims a thread fetched a tile ahead and widened with packed f16 (one rounding, a
dword store holding both keys), K6's high bits laid out so one mask and shift join them to the
low nibbles. r4d_selftest: the stores against an exactly representable set, the folds, and the
attention rows against the inline oracle extended to the layouts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jinja2 reads `obj.0` as `obj[0]`; the engine threw "Static member property must be an
identifier". GLM-5's template tests a tool result with `m.content.0.type`, and the capability
probe swallows the throw, so the template came back as tools=0 tool_calls=0 and every request
with `tools` was refused.
The fix is llama.cpp's ae9afff8, which landed after the lifted commit, taken as it is so the next
refresh drops it. vendor/patches/0021, vendor/UPSTREAM; chat_test
(a_dotted_integer_is_an_index_as_in_jinja2) fails without it on both counts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without perf_event_open in the build sandbox, tokenizer_perf_test bounds the encoder's linearity by
CPU time. Its 500 KB single word reads a ratio of 10 to 12 against the threshold of 9 on a Zen 2
VM with 512 KiB of L2, every run, with the tokenizer unchanged. A ctest -E regex lets such a host
build the image without the threshold moving for everyone. Empty by default. docs/DOCKER.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The per-binary CPU budgets are set on a fast machine. A VM on an EPYC 7302 spends 4.6x the quoted
CPU time on tokenizer_test's reference pass, so the image's test stage failed there on a correct
tree, and -j sized for the compile also sized the tests: twelve at once on a 24-thread host put
tests on busy SMT siblings, which costs CPU seconds too.
RAD_TEST_CPU_BUDGET_SCALE multiplies the budget where rad_test.h reads it, at run time, so a
direct ctest takes it as well and the build layer is untouched by it. The stage takes it as
TEST_CPU_BUDGET_SCALE (build.sh -B) and its parallelism as TEST_JOBS (build.sh -J), each empty by
default, which is the stage as before. harness_test checks the factor and keeps it out of its
fixture's environment; docs/DOCKER.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On an MXFP4 container the fused junctions skip the bf16 activations the tap reads, and q/k/v and
gate_up Grams came out zero without a word (down likewise behind gelu_mul_quant_i8). Under
RADIANCE_CALIB_DIR no junction or fused down-quantiser is declared, so any container
calibrates, unfused; checked on the production MXFP4 container. RADIANCE_G3_CALIB_LAYERS
refuses trailing characters. Docs: which trunk fuses what, the four-stream numbers' two
workloads, which sizes are tested. arch_test's world-2 check counts the post-norm op.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The gemma3 section of ARCHITECTURES.md (geometry, traps, KV groups, linears, calibration,
measurements, the DFlash2 drafter), the calibration variable and the conversion of record in
GUIDE.md, the README's models table. Recipes: the int8 calibration container (KL 0.003),
MXFP4 + GPTQ (KL 0.042, 56 tok/s a stream on two R9700s), and with a drafter. The compose file
serves a plain Gemma 3 template: TranslateGemma's own refuses the startup render's plain turn.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gemma4_bf16's block structure with Gemma 3's differences (modeling_gemma3, transformers 4.57):
GemmaRMSNorm everywhere, one head geometry, scores at query_pre_attn_scalar^-0.5, linear rotary
scaling on the global layers only, the bf16-held embedding scale, no value norm, soft-capping
and YaRN refused. Linears i8a8, mxfp4a8 and w4a8i8_asym over an activation scaled per
(row, 128), beside bf16 and w4a8 / w8a8: one int8 scale a row costs KL 0.097 at w8a8 on
Gemma 3's outlier channels. Fused junctions on a quantised trunk. A calibration tap
(RADIANCE_CALIB_DIR, RADIANCE_G3_CALIB_LAYERS), the column-split linears as rank parts.
A DFlash2 drafter as qwen35_fp8 declares one; rad_block_dflash2.h applies the drafter's
input_embedding_scale through embed_lookup's mult when it is not 1, so other drafters'
graphs are unchanged. Against transformers' float32 forward on a tiny Gemma 3: KL 0.00016 on
the host backend and the cards. arch_test: 7 cases.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- r4d_attn_paged_h128_gqa2w.hip: decode and query-tiled prefill at head_dim 128, gqa 2,
window >= 1, instantiations of the h256/gqa6 templates with WIN = 1 (as h256_gqa2 for
Gemma 4); the h128/gqa2 rows keep window 0.
- qkv_norm_rope: head_dim 128, and an optional v_norm (0 leaves v alone).
- ar_rmsnorm_post_quant_fp8: ar_rmsnorm_quant_fp8 with a post-norm of the reduced sum against
w_post before the residual add (the sandwich junction), exact wire only. Its own op: an
optional seventh operand on ar_rmsnorm_quant_fp8 broke every plugin issuing its six.
r4d_selftest: the windowed rows against the inline oracle over a history past the window, and
qkv_norm_rope at h128 / v_norm 0 byte-identical to its chain.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the bf16 release: the trunk's linears RTN int8 under fwht128 (weight error 6.3e-3), the
lm_head int8 (6.8e-3), the drafter as q38-27b-fp8-df2.recipe makes it; 29.0 GiB. Against the
bf16 model over 45K mostly-Go positions: mean KL 0.00051 and 99.25% top-1, against 0.00404 and
97.75% for Qwen's FP8 release.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A third build of the qwen35 source, as qwen35moe_fp8 is, claiming (qwen35, w8a8_fwht128).
Behind QWEN35_W8A8: check_format's method and fmt, a probe of the first delta-net input
projection that learns the trunk is rotated int8 before the activations are declared (and refuses
one that is not, plain int8 included: the descriptor names the rotation), and the plugin
identity; the four trunk activations then carry int8 code pairs.
It declines imported checkpoints (RAD_ARCH_SERVES_IMPORTS(0)): as the family's second quantised
plugin it would make every imported Qwen3.8 release (Quark, ParoQuant, GPTQ, NVFP4) refuse, so
those stay with qwen35_fp8.
arch_test: every trunk linear an i8a8h GEMM behind its own quantiser at one and two ranks, the
refusals (no int8 trunk, a plain one, another format, no fmt), lint clean with the MTP head and
with DFlash2, and two ArchCases (pinned graphs; libref's vocabulary serves it at one rank).
shipped_plugins_test lists the new key and holds each shipped family to at most one plugin that
takes imports. ARCHITECTURES.md and GUIDE.md list the plugin.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
decl_gated_fold was declared for any gate_up that was not bf16, MXFP4 or rotated 5-bit, so an
int8 one got an fp8a8 fold over int8 codes. Only a host kernel took the op, and placement then
pinned every layer group's weights to the host.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
linear_is_w8h recognises i8*bf16[1x128]/fwht128; probe() reports it as int8 so the producer
writes the bf16 plane, and declare() quantises it with had_quant_act_i8g. A rotated weight fed
codes its producer wrote (ActFP8::q8_fed) is refused: those codes are unrotated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An imported quantisation names its tool, which no plugin claims, so the family's one quantised
plugin serves it and two are refused. rad_arch_serves_imports(), optional and absent = yes, lets a
second quantised plugin that reads only its own containers return 0: the import pick then leaves
it out of the family, neither counted nor picked as the only plugin. Its own descriptor still
selects it. Additive export; RAD_ABI_VERSION does not move.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Its consumer's scale carries the whole 1/group, as had_quant_act_fp8's does; the per-row had_*
int8 forms fold 1/sqrt(group) and are not interchangeable with it. TOOLS.md: libr4d reads the
int8 block rows rotated too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
had_quant_act_fp8 at int8 codes (top 127), one body shared by both in each library, so a
rotated int8 trunk runs on the host kernels too. gemm_nt_q needs no change: both libraries pick
the int8 product from the operands' dtypes, and i8a8h's rotation is in the values. libref's
operand description takes i8a8h, and rad-avx-check gains cases for the op and the dtype.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libquant's rtn at codes=i8 group=128 scale=bf16 transform=fwht128, decoded through the core:
the weight gemm_nt_q reads at i8a8h comes back as its source, with less error than the plain
grid on a source with outliers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gemm_i8a8_nt_m16 and gemm_i8a8_tiled take dtype i8a8h: the same launch over i8 codes rotated by
the unnormalised 128-wide Hadamard along K, the 1/128 in the bf16 scale (libquant's
transform=fwht128). The layout hook accepts only the transform its dtype names and tags the
rotated codes r4d.i8h.w.frag64, since the bytes cannot tell the two forms apart.
r4d_selftest's i8a8h_rot measures the pair against the exact f32 product: rel_l2 0.009-0.012
rotated, 0.012-0.014 plain, ~1.0 for the rotated weight against the plain quantiser. The
had_quant_act_i8g row now says the factor of 128 is the weight's, not sqrt(128).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The single-threaded loops stay beside LAPACK; RAD_LQ_LAPACK=0 takes them and
gptq_through_lapack_matches_the_loops compares the two (output error equal to rounding). A
factor whose diagonal is not finite and positive is refused, as the loops refused a NaN pivot
that dpotrf lets through. The cache keeps the 4 most recent layer factors: a MoE layer's
experts alternate between two stems. The size in the comment is the f32 factor's, 1.85 GB.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Under tensor parallelism an attention output or down projection sees only its rank's K / world
columns, so no rank can write the K x K Gram. A tap may write each rank's block as
<stem>.part; with no whole file calib_sum places the parts on the diagonal in rank order (the
cross-rank products, never formed, zero) and converts the result like a whole file. Parts that
do not cover K, or not in domain 0, are reported and the weight rounds to nearest. Tested
byte for byte against the whole block-diagonal file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
At K = 21504 (a dense 27B's down projection) the single-threaded Cholesky and inverse took hours
a layer; dpotrf / dpotri take 13.5 s for all three on 24 cores, identical to 1e-14. Without
OpenBLAS nothing changes. The factor cache kept every layer's factor, 3.7 GB each at that
width, which OOM-killed a 62-layer conversion at layer 25; it now keeps one at a time (a layer's
experts arrive together and still share it). RAD_LQ_FACTOR_CACHE_ALL keeps the old behaviour.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ar_ln_had_quant_i8 clamped a tuned block count to M only; it stays under R4D_AR_MAX_BLOCKS
now, as every other entry's. The MoE hyper-connection gathers keep the minimum their LDS table
needs, which may exceed the ceiling: the comment and GUIDE say so instead of "every
collective". r4d.h states that a refused IPC export leaves the handle zeroed, out_len 0.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every block of a collective spins until its twin on the peer card has pushed. One engine is safe
(both cards dispatch its blocks in the same order); two tensor-parallel engines on the same
cards can deadlock, one engine's spinners filling a card while their twins wait behind the
other engine's kernel. Two TP2 engines on two R9700s hung within a minute of concurrent
prefill and the failed queue eviction froze the host. Capped in both engines so their spinners
together leave part of a card free, the cycle cannot close: 15 minutes of concurrent load
clean at 64 / 16. Only launch counts shrink; each element's sum is the same. Unset, nothing
changes. GUIDE section 8 documents it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
r4d_ar_ipc_alloc exports every collective buffer with hipIpcGetMemHandle. Beside another
process holding the same cards it answers invalid argument while the allocation is fine, and
HIPOK stopped the engine. libr4d's ranks are threads of one process and share the pointer
itself, so the handle is never read: a refused export leaves it empty.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Over a split vocabulary every rank's candidates are gathered and merged in one workgroup
(sample_merge_topk), and libr4d's row holds world_size * n_cand <= 4096 pairs in LDS. The engine
declared the default 1024 a rank, 8192 pairs at eight ranks, and the first step stopped on a shape
the merge does not serve. Declare now narrows the width to 4096 / world_size, 512 at eight ranks,
and says so in one line; a request whose top_k is wider is refused at admission, as a top_k over
the width already was. Two and four ranks keep 1024.
sample_test: at two, four and eight ranks declare succeeds, top_k at the width is admitted and one
more is refused, naming the width.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Weights from a variable describe one board on one day. Unset or "auto", RADIANCE_AR8_SHARD_WEIGHTS
now reads them from the links: each rank takes its card's bus id from the runtime
(hipDeviceGetPCIBusId), walks /sys/bus/pci/devices from the root port down to the card as
core/diag/sysinfo.cpp's read_card does, and keeps the slowest hop's current speed x width x line
code (8b/10b under 8 GT/s, 128b/130b from there) / 8. The R9700 sits behind an on-card switch
whose endpoint reports Gen5 x16 in any slot, so a degraded slot shows only at the root port. The
weight is round(4 x (rate / fastest)^2): x16 4, half the rate 1, a quarter 0. On the board of the
previous commits that is the measured best, 4,1,0,4,0,1,4,4, and after both Gen4 links retrained
at Gen5 x8 it is 4,1,1,4,1,1,4,4, where the 16 MiB two-shot takes 1360 us. "off" keeps the shards
even and eight integers set them, as before.
The ranks publish their links in the rendezvous (ar8_settle) and, after one barrier, derive the
same table from the same eight entries before anything is sized; settings that differ between
ranks fail init on every rank. Equal weights run the unweighted kernel, and a rank whose path says
nothing (no /sys/bus/pci in a container) leaves the shards even, with a warning naming it. Startup
logs one line, "[r4d] eight-rank two-shot shard weights from the slowest PCIe hop of each card: r0
32.0 GT/s x16 63.0 GB/s w4, r1 32.0 GT/s x8 31.5 GB/s w1, ...". The links are read once, at init:
a link that falls back while the server runs changes the weights at the next start.
r4d_ar_links_test builds that board's sysfs under a temporary root (root port, on-card switch,
endpoint) and checks the bottleneck hop, the weights before and after the repair, equal links, the
line code and a path that says nothing; it needs only libr4d's include path. r4d_selftest runs
auto and off at the default floors, for bits only since what auto derives depends on the box, and
--perfar8 derives the weights the same way and names each rank's link. 206 of 206 on the cards.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each block splits its words (in shard space) into K runs. Step j pushes run j+1's first hop and
reduces and pushes run j's second, then handshakes, so a rank with a short shard sends and
receives at once instead of one direction a hop. A launch takes K+1 handshakes instead of two.
The flag a (block, source) publishes is a monotone counter, so one handshake vouches for every
earlier one, and r4d_ar_seq_take reserves the K steps at once (`steps`, 1 for every other kernel):
one-shots and gathers on the same instance stay in the family's flag space. The regions stay at 0
and the longest shard, so the scratch is as before; every word is touched by the same thread in
the same three steps, so the fold, the bits and the in-place form are unchanged. The launcher
clamps K to the words a block holds, and K 1 is its own instantiation without the loop.
16 MiB, bf16, warm K 1 K 2 K 4 K 8
even 2841 us 2806 2667 2470
4,1,0,4,0,1,4,4 2730 2126 1798 1636
4,2,1,4,1,2,4,4 2495 2121 1940 1922
4,1,0,4,0,1,4,4 in 8 pieces is 42% under the even split. Fitting measured = f x computed + h x
(K+1) at K 4 and 8 gives f = 1.21 and h about 5 us a handshake: what separates 1636 us from the
1.17 ms the Gen4 links need is their efficiency, not the handshakes.
A decode-sized message loses with either:
numel even K 1 4,1,0,4,0,1,4,4: K 1 / K 2 / K 4 / K 8
196608 73 us 85 / 76 / 81 / 113
524288 214 207 / 166 / 169 / 198
2097152 699 711 / 581 / 531 / 527
8388608 2841 2730 / 2126 / 1798 / 1636
so below RADIANCE_AR8_SHARD_WEIGHTS_MIN_ELEMS and RADIANCE_AR8_PIECES_MIN_ELEMS (262144 elements
each) the message runs even and in one piece, on the kernel as it was. Above them, without
RADIANCE_AR8_PIECES, K follows the size (r4d_ar8_auto_pieces): 2 under 1048576 elements, 4 under
4194304, 8 above, where the crossings above lie. RADIANCE_AR8_PIECES (1 to 16) fixes K over the
floor, and a launch's `pieces` parameter (the selftest's) overrides that. Weights and K are a
function of the message size and the instance (ar8_weights_for, ar8_pieces_for), so a replay of
the same size decides the same; the slot is sized for weights only when the largest message is
over the weight floor. Every rank compares both variables and both floors at init.
r4d_selftest, with both floors at 0: the weighted and even sets at K 1, 2 and 4 (1- and 9-word
messages cross the launcher's clamp), and one instance whose K changes from launch to launch (1,
4, 2, 8, 16, 3, 1), which a wrong flag reservation hangs or races. At the default floors: the size
rule over 131072 to 4194304 elements, K 4 on both sides of the piece floor, a 131073-word message
over the weight floor (served only weighted) and a 9-word one under it (refused, and served at a
floor of 64). 192 of 192 on the cards. --perfar8 names the floors and times the two-shot as the
server runs it and at K 1, 2, 4 and 8.
GLM-5.3-Flash at TP8 (an out-of-tree plugin) on these eight cards with 4,1,0,4,0,1,4,4, against
the same build without in the same hour: a 20K-token prefill 3450 tok/s against 2945, 8K 3372
against 2920; eight agent streams 457 tok/s against 458, one 141 against 139. K 8 at every size
instead gave the same prefill (3461) and 436 at eight streams, 113 at one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In the two-shot rank r reduces shard r: in the first hop it sends N - len_r and receives
(ws-1)*len_r, in the second the reverse. With even shards every rank moves 1.75 N each way at
eight ranks, so on a board whose links differ the slowest link sets the time. On eight R9700 (four
links at Gen5 x16, two at Gen5 x8 and two that trained at Gen4 x8, 14.3 GB/s one way by
TransferBench) the 16 MiB two-shot, a 2048-token chunk at 4096 wide, takes 2.45 to 3.05 ms over a
day, where the Gen4 links alone need 2.05 ms for their 28 MiB.
RADIANCE_AR8_SHARD_WEIGHTS=w0,...,w7 sizes rank r's shard in proportion to w_r (the floor, then
the few remaining words one each to the weighted ranks in ascending order); a rank of weight 0
owns no shard and only pushes, gathers and handshakes. The shard bounds become a table the kernel
takes by value (r4d_ar_shards.h, host-only, shared by the launcher, the shim and the selftest), so
a recorded launch keeps its table. Equal weights give the even split word for word, and unset the
split is the even one as before; three and four ranks stay unweighted. Which rank reduces a word
changes the link it crosses, not its fold, so every table gives the same bits.
Every rank must cut the message at the same words: init reads the variable on each rank and fails
on all of them if the ranks disagree. A weight over half the sum makes the longest shard's two
regions outgrow a message, and only then does init grow the slot. Weighted shards need not divide
the words evenly, so the even rule (words % 8, else RAD_E_SHAPE) applies without weights only.
Measured with --perfar8 (16 MiB, bf16, warm): even 2.78 to 3.05 ms that day, 4,1,0,4,0,1,4,4 (no
shard on the Gen4 ranks) 2.71, 4,2,1,4,1,2,4,4 2.50, 2,1,1,2,1,1,2,2 2.58. Only 10 to 17%: with
the hops separated by a handshake a rank sends in one and receives in the other, and the larger of
N - len and 7 len a hop is least at len = N/8. The weights pay once the hops overlap.
r4d_selftest: ar_wide_weighted runs 0,3,1,0,5,1,2,4, 1,0,0,0,0,0,0,0 and 4,1,0,4,0,1,4,4 over
uneven and empty shards, a single owner (the slot grows) and messages of 1 and 9 words, which the
even split refuses; the refusal check runs without weights whatever the environment. 55 of 55 on
the cards, every one bit for bit with the fold. --perfar8 prints the weights, every size's shard
lengths and each rank's time.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The exact all-reduce at eight ranks shared the three- and four-rank band: one-shot up to 524288
elements. The one-shot sends (ws-1)*N bytes a rank, seven times the message at eight ranks, where
the two-shot sends 2*(ws-1)/ws*N, and on eight R9700 (PCIe P2P, bf16, warm) the two-shot is the
faster from 16384 elements on. A decode step of eight streams with a draft window of six on
GLM-5.3-Flash (4096 wide, an out-of-tree plugin) reduces 48 x 4096 = 196608 elements: 232 us
one-shot, 68 us two-shot, where all_reduce was 20.7% of the step's device time.
R4D_AR_8RANK_ONESHOT_MAX_ELEMS is 8192, a multiple of 64, the eight-rank two-shot's DIV;
cArTsExact8 starts one element above it. The two-shot's block rule stops at 8 blocks at eight
ranks: every block handshakes with seven peers, and past eight blocks the extra flag rounds cost
more than the reduce bandwidth they add (4 blocks up to 393216 elements, 5 at 524288, 8 instead of
16 from 2097152). Both rows fold in fp32 in ascending rank order, so neither change moves a bit.
numel before after
4096 one-shot 22.5 us one-shot nb 4 12.8 us
16384 one-shot 39.7 two-shot nb 4 21.5
131072 one-shot 176.3 two-shot nb 4 52.3
196608 one-shot nb 16 233.2 two-shot nb 4 68.7
524288 one-shot 573.7 two-shot nb 5 177.4
2097152 two-shot nb 16 615.8 two-shot nb 8 610.5
8388608 two-shot nb 16 2460 two-shot nb 8 2489
16777216 two-shot nb 16 4999 two-shot nb 8 4824
At 4096 the rule already chose 4 blocks; the 22.5 us was the microbenchmark's, ten launches after
the host-side check, which now warms up with as many launches as it times.
Band edges are the union over every candidate row (core/plugin/bands.cpp), so the edge at 8192
splits the two-, three- and four-rank bands too. Both halves resolve the same row, kernel and
bits, at the cost of one more instance per (width, dtype) whose slot holds 8192 elements. Keeping
the edge to eight ranks would need the band builder to skip rows whose fixed constraints the
geometry rules out (world_size 8 here), a change to every op's bands for one row; plugin_test
states the new edges instead.
r4d_selftest runs the eight-rank rows (ar_oneshot_8rank_exact, ar_twoshot_8rank_exact,
ar_gather_8rank) through the width-parametrised cases of the three- and four-rank ones instead of
skipping them: the pattern's band edge is at 8192 and 8256 there, and a 9-word message must be
refused. --perfar8 numel [iters] [dtype] times both rows, one thread a card, at the block rule
and at 4 to 64 blocks, each checked bit for bit against the fold on every rank. On the cards:
ar_oneshot_8rank_exact 20 ok, ar_twoshot_8rank_exact 16 ok, ar_gather_8rank 5 ok.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Inside a class, escapes GBNF does not know ([\b], [\f], [\v], [\0], an escaped space, \p{..}, \c,
a backreference) were copied raw and the grammar then failed to load, an internal error on a
schema the converter had accepted.
A JSON string holds a control character only as an escape, so \t \n \r \f \v \0 (and \b in a
class) now match that escape, in a positive class as alternatives beside it and in a negated
class by leaving the escape out. Outside a class the escape is a group, so a quantifier takes all
of it. An escaped space or non-ASCII character is itself; \x and \u in a class need their hex
digits. Any other class escape is refused at conversion with a message naming it.
vendor/patches/0020, vendor/UPSTREAM; gbnf_test cases.
Patterns written in JavaScript escape punctuation that needs no escape: "\/" in a path, "\-" in
a class. zod's email pattern carries "[A-Za-z0-9_'+\-]", so any tool validating an email with zod
sent a schema that was refused outside a class ("Unsupported regex escape") or, inside one,
produced a grammar that failed to load.
Outside a class such an escape is now the bare character; regex syntax characters and '"' keep
their backslash. Inside a class it is written \xHH, so an escaped '-' or '^' cannot read as a
range or a negation. Found by running 203 patterns harvested from installed agent packages
through rad-gbnf-check. vendor/patches/0019, vendor/UPSTREAM; gbnf_test cases.
\d \w \s \D \W \S were refused in a literal ("Unsupported regex escape") and copied raw into a
class, where GBNF cannot load them. Tool schemas use them freely: oh-my-pi's workpool tool sends
"\S" thirteen times, so with 0017 its requests got past the anchors and were refused here.
Each shorthand is written out as its ECMA-262 class before the scanner reads the pattern. The
negated forms leave out '"', '\' and the control characters and admit any JSON escape instead, so
a match cannot run past the closing quote; \s also admits \t \n \f \r. In a class a positive
shorthand becomes its ranges and [\s\S] and its kin become any text; a negated shorthand mixed into
a class is refused. vendor/patches/0018, vendor/UPSTREAM; gbnf_test cases, and sample_test's
"cannot spell" case moves from \d to \b.
_visit_pattern() read only ^...$ and refused every other `pattern` with "Pattern must start
with '^' and end with '$'". JSON Schema patterns are unanchored (ECMA-262 search, validation
6.3.3). Since 1.8 constrains tool-call arguments with a grammar, a bare pattern on array items
failed the whole request: an opencode agent's tool list did, on every request.
A missing anchor is now written out as any string text on that side, (?:[^"\\]|\\.)*, not ".*"
('.' matches '"' here, so on array items ["1","x"] read as one string holding a digit). A
one-sided anchor beside a top-level '|' is still refused. vendor/patches/0017, vendor/UPSTREAM;
tests in gbnf_test (json_schema_grammars_admit_exactly_their_instances) and sample_test (an
empty pattern now matches every string).
oot_plugins.sh gave libr4d's out-of-tree configure the tree's HIP compiler and targets but not
RAD_HIP_VOPD_REPEATABLE. In a tree configured as the build image configures it (ON, for the
patched LLVM 24), the out-of-tree libr4d was compiled with VOPD pairing off and step 5 found
different device code. The option is now the script's sixth argument (default OFF), forwarded to
the device libraries' configure. In radiance-build, ctest -L oot failed at step 5 and now passes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gemma's tokenizer.json spells runs of 2-31 spaces as added, non-special tokens in U+2581
(ids 138-167). piece_at returned every user-defined token literally, so indentation and
double spaces in a Gemma reply came out as U+2581. HuggingFace runs every token it keeps
through the decoder; now a user-defined token does too, and only control and unknown
tokens stay literal. decode, the Detokenizer and TokenView change together. tokenizer_test
covers it with a Gemma-shaped tokenizer.json.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A checkpoint reservation (Scheduler::reserve_ckpt, at planning) is written only after the
step (Engine::checkpoint_save), and nothing between the two checked that the slot was still
the reservation's. A later reservation in the same step that found the store full ran
retention over every session, and the policy, placing its ladder from each session's tip,
could release the very slot just handed out: a second request's reservation lands on a
snapshot a first session already holds (the same prefix, so the same key) below that
session's tip, or a lookup's take_over indexes a fresh reservation under a session whose
ladder does not keep it. The save then faulted in checkpoint_copy ("the store does not hold
that slot ... given back after its id was handed out"), the step loop read the negative as a
device fault, and the engine exited with every in-flight request (#129: every 25-50 min
under multi-session agentic load, the store not full at the fault, 12-15 of 16 in use --
the eviction itself had freed the rest).
A reservation now keeps its slot the way a handed-out snapshot does: retention, the LRU
eviction and expiry skip it from reserve_checkpoint until commit_checkpoint, or until the
next step begins when the save was skipped (its request gone), so a skipped save cannot hold
a slot for good. The engine issues every save before it plans the next step, so the window
covers the copy. A reservation that finds every slot handed out or awaiting a save is
refused as before (ckpt_refused) and the chunk goes without a snapshot.
mem_test: the two cases, the shared-prefix one at the position geometric backoff releases,
and a step boundary (begin_step) in the three cases that reserve several snapshots in a
row without committing, as the engine does one per step.
- MiniMax-H3 and FastH3 no longer stop the server on a prompt longer than 16 tokens (FastH3) or
128 tokens (MiniMax-H3)
- latent upscaling for the MiniMax-H3 containers: with LBH-123-AI's latent upscaler in the
container, `latent_upscale` runs the first steps at a smaller size and refines the latent at the
full size; `upscale_refine_steps` sets how many steps refine, and the video object reports both
- rad-convert --in-place extends a container whose weights the plugin has regrouped since
- plugin ABI 22: out-of-tree plugins must be rebuilt
- video: MiniMax-H3 and FastVideo's FastH3 8-Step V2, a video with its stereo soundtrack from text
on OpenAI's /v1/videos, block fp8 on two cards
- music: MiniMax-Music3, songs from lyrics and a description on /v1/audio/speech
- speech: Breeze-TTS-2 on /v1/audio/speech and vLLM-Omni's realtime WebSocket
- runtime LoRA adapters beside the base model, picked per request by `model` (baKon, #105)
- several agent streams keep their cached history: --checkpoint-slots auto, the new default, sizes
the snapshot store by --max-num-seqs (#108)
- the Swift 1.5 27B W4 releases convert and serve: compressed-tensors AWQ and GPTQ int4, AutoRound,
ModelOpt NVFP4 (#110)
- the image's host tests pass where perf_event_open is refused, as in BuildKit's sandbox (#106)
- plugin ABI 21: out-of-tree plugins must be rebuilt
POST /v1/unload_lora_adapter for an adapter requests still hold marks it draining and answers
202 {"action": "draining", "lora_name", "in_flight": N}: from then on a request naming it gets the
404 an unknown model gets and /v1/models leaves it out, the N requests finish normally, and the
last hold to go frees the slot, which then cools for three step-loop rounds like any freed slot.
An idle adapter still unloads at once with 200; a second unload while it drains answers 202 with
the count as it is then, and 404 once it is gone; a load of the same name while it drains answers
409 (is being unloaded).
The slots' bookkeeping moves out of Engine into lora::SlotTable (core/lora/slots.h): reserve,
publish, acquire with its hold, unload, names. It has its own lock, so a request's hold and an
unload no longer wait behind a load's device copy; Engine::lora_mu_ now only serialises loads,
which is what keeps a reserved slot from being handed out twice. lora_test drives the table
through both paths, and server_test drives the routes over a real table with a streamed request
held open: 200 idle, 202 draining twice, 404 for a new request and on /v1/models/:id, 409 for a
load while draining, the slot freed when the stream ends, 503 while it cools, 200 after.
The per-row adapter slot moves from the core's `lora_slot` derivation into the step batch, beside
the other per-row arrays: [n_tok] i32 device, the row's slot in the adapter pools, < 0 or >= S a
base row, null when the engine serves no adapters. The batch builder fills it from
Request::lora_slot where it fills token_ids and positions, in the slab every rank's batch already
points into -- one address per rank for the engine's life, uploaded in stream order ahead of the
step's kernels -- so a recorded pass replays it the way it replays token_ids. Ctx::pass_key reads
the pointer; the adapter ops are issued whatever the slots hold, so nothing a pass launches depends
on their values.
Off: the slab carves nothing for it (a zero-length carve), no buffer is declared, and every other
slab offset and the arena are what they were. The derivation, its program buffer and
Program::lora_slot_buf are gone. abi_layout_table regenerated at 18 (RadBatch grows to 320 bytes,
the fields after seq_ids move by 8); sched_test holds the per-row fill, and that the slot array is
the only thing adapters add to the slab.
lora_case now runs each row pair as the engine issues it at real shapes --
M 1 / 8 / 2048, K 2048 / 5120 / 6144 / 17408, N 2560 / 12288 / 17408, R 16 /
48 / 64 / 192 -- with slots in runs of requests and base rows, the f64 sums
on the host's cores. The tiled rows add the batch-invariance check only the
card can make (a row alone vs inside M = 8 / 37 / 2048 must give the same t
and y bits: the WMMA unit's answer for a row must not depend on its tile
position) and a base-only launch. A static check holds the tiled rows above
the scalar ones.
--perflora M K N R S PATTERN [iters] times every lora_shrink and every
lora_expand row at one shape and slot layout (base, one, half, mix, runs),
comparing each row's t and y with the first row's; R4D_PERFLORA_A and
R4D_PERFLORA_Y pick the activation and output dtypes, --cold applies.
The shared lora_cases matrix now runs the tiled rows beside the scalar ones,
handing a row the scratch its hook asks for. test_lora adds: the real shapes
(K 2048 / 5120 / 6144 / 17408, R 16 / 48 / 64 / 192, N 256 .. 12288, odd M,
S 1..4, bf16 / E4M3 / E5M2 / i8, aligned and unaligned rows), each a shrink
-> expand pair held to the f64 bound and to libref's bytes; a row alone vs
the same row inside M = 7 / 16 / 17 / 37 / 300 of random slots and base
rows, bit for bit, through aligned and unaligned buffers; a base-only M 2048
launch touching nothing; and every fp8 / i8 code widened exactly through a
one-hot pool. The emulator shim gains the fence, atomic and allocation calls
the split's arrival counters use.
The v1 rows grid by row: shrink is one block a row walking K serially, and
expand one block a (row, 256 columns) that re-reads all of B[s] for every
row, so a prefill chunk reads it M times and a chunk of base rows still
launches M * ceil(N/256) blocks that read a slot and leave.
lora_shrink_wmma (bf16 a) and lora_shrink_wmma_q (fp8 / i8 codes whose scale
group is whole 32-wide steps) run WMMA bf16 over 16-row x 16-j tiles: K in
32-wide steps over 4 waves, the waves summed in fixed order in LDS, and a K
split fixed by K and R alone (sh_plan) whose partials live in the op's
scratch and are summed in split order by the last block to arrive; the
arrival counters are a small block keyed on (device, t). Codes are exact in
bf16 and each step's partial is scaled by its group's f32 scale; f16 / f32
activations and other groups stay on the scalar kernel.
lora_expand_tiled stages B[s]'s [128 columns, 32 j] slab in LDS as f32 for a
32-row tile and keeps v1's per-output sequence (j ascending, no FMA), so its
bytes are libref's.
Both grid by row tiles; a tile of base rows leaves on one ballot before any
barrier or operand load, a mixed tile runs one pass per distinct slot, and a
small grid spreads a tile's passes over blockIdx.z. No choice depends on M
but which block runs a pass. The scalar rows stay, by name and as the
f16 / f32 shrink, below R4D_PRIO_LORA_TILED.
A hot swap (unload, then load at once) under traffic found the freed slot still inside its three
step-loop rounds and got a 503 almost every time. The rounds pass in milliseconds whether the engine
is busy or idle, so the load now waits for them (up to 2 s, the lock let go meanwhile).
Found on Qwen3.8-27B fp8: the 64 declined gemm_nt_q_gated folds tripped the reference-kernel gate,
and as unresolved readers of gate_up they would have told the planner the weight cannot live on the
card.
--lora NAME=PATH, --max-loras, --max-lora-rank, --lora-target-modules. Off unless
named: no site, no pool, no op, and every prefix hash is what it was.
build_sites() walks one rank's Program after declare and makes a Site of every LoRA-capable
trunk GEMM (gemm_nt, gemm_nt_bias without act, gemm_nt_q without pb1/pb2 and with K equal to the
weight's, gemm_nt_q_bias) whose `b` weight a target leaf names. The geometry is read off what the
plugin recorded on the weight -- shard mode, row parts, shard and per-part spans, name-map
sources -- and is checked against weight_share() on a plain view of the weight, so the LoRA slice
and the loader's slice cannot disagree. Sites of one declared weight share one pool.
weight_targeted() is the one predicate (scope rule in lora.h), usable mid-declare.
find_unsupported_uses() lists every live op that reads a targeted weight and is not a site: a
fused gated fold, a routed expert, a weight stored in a transform basis, a rotated or widened
gemm_nt_q. Unresolved ops the builder recorded are never issued and are skipped.
load_adapter() reads adapter_config.json and adapter_model.safetensors, refuses what is not
plain linear LoRA (DoRA, other peft types, modules_to_save, trained or lora biases, embedding
LoRA, fan_in_fan_out, parameter LoRA, rank above the cap, rank/shape mismatches, an ambiguous
VLM spelling), computes alpha/r or alpha/sqrt(r) with rank_pattern/alpha_pattern searched as
rad-export does, converts BF16/F16/F32 to bf16 RNE and packs one slot per pool. A fused weight
whose sources are fewer than its row parts (the delta net's ssm_inz) is laid out from the
adapter's B rows. A module no site on this rank takes is listed, not refused -- an
attention-zero rank declares no q/k/v/o -- and check_placed() refuses one no rank took.
tests/lora_test.cpp declares with the real Builder and arch/common's LinearFP8 (fused qkv and
gate_up; gated attention with an attention-zero rank and KV replication; the delta net's uneven
2/2/1 head split) at worlds 1-4 and holds every rank's slot product to the dense delta. It
loads no kernel plugin, so it never reaches the device layer.
lora_cases.h holds the matrix (M 1/3/17/64/130, R 16/32/48, S 4, K and N 64/256/1000, a bf16 or
E4M3 with a 128-column scale, y bf16/f32, f16/f32/E5M2/i8 once; a, a_scale and y as column
slices; slots -1, -5, 0..3 and S) and the checks: base rows untouched by bytes (a sentinel NaN in
t, -0 in y), adapter rows against an f64 sum within (K + 2) 2^-24 sum|terms| (shrink) and half an
ulp of y plus 4 (R + 2) 2^-24 (|y| + |scale| sum|terms|) (expand).
lora_test runs libref and libavx at every ISA level through rad_plugin_open (libavx builds its fp8
decode table there). r4d_emu_lora runs libr4d's source on the SIMT emulator beside ref_host.cpp
and libref, expand bit for bit.
r4d_lora_bf16.hip: shrink is one block a row (a base row's block leaves at once), one wave a
column of R, each lane's k in order and a fixed xor butterfly, so a row's bytes depend on nothing
but the row. Expand is one thread an output over M strips of 256 columns, j ascending, sum then
scale then one rounding to y's dtype: libref's order, so the emulator holds it to libref bit for
bit. A base row of y is neither read nor written. Strides of a, a_scale, t, y and the pools come
from the tensors; the grid is M (and N) only.
Rows lora_shrink_scalar / lora_expand_scalar with libref's schemas field for field, constrained
with C_IN on the tensor dtype names, so an activation the decode does not read never resolves.
Not concurrent: the core orders them behind their GEMM. r4d_selftest gets a device case (not run
here: this host's GPU is off limits for this work).
The stream states the group through its extent (make_scales' grid_block), and a K no wider than
one group has one group whatever `group` says: a 64-wide row under group 128 read as group 64 and
was refused. Compare the grid -- groups along K -- instead of the number. An a_scale with no
dtype is absent, like one with no data.
The two halves of y += scale * (B . (A . x)) at a trunk GEMM, with each row's adapter named by an
i32 `slot`:
lora_shrink t[m, j] = sum_k x(m, k) * lora_a[s, j, k]
lora_expand y[m, n] = y[m, n] + scale[s, n] * sum_j t[m, j] * lora_b[s, n, j]
A row whose slot is outside [0, S) is a base row and neither op touches it: shrink writes no `t`,
expand neither reads nor writes `y`, so a base row stays bit for bit what the GEMM wrote (y + 0
would already turn a -0 into +0). x(m, k) is gemm_nt_q's activation value, read through the same
make_scales; an fp8/i8 activation without its scale stream is refused. The dtype parameters carry
the tensor dtype names (rad_dtype_name). Sums are per row in a fixed order, so a row's bytes do
not depend on M or on its neighbours.
libref is the oracle (straight f32 loops, OpenMP over whole output elements); libavx covers both
at every ISA level with vectorised dots. ref_test gains hand-computed cases (column slices, -1 and
S as base slots, a -0 that must survive, the fp8 scale fold, the missing-scale and wrong-group
refusals); avx_check gains a case table; docs/OPS.md the two rows; rad-kbench and avx_check a
tolerance row for the shrink's f32 reduction.
- every model serves without a GPU: libavx covers every op, so `--kernels libavx` alone serves
every shipped container
- Qwen3-ASR (zivius): speech to text on /v1/audio/transcriptions and live over /v1/realtime
- /v1/messages works with Claude Code as it ships (gearwave00001)
- a long agent conversation keeps its cached history when the client rewrites its last turn
(manueloverride)
- a stream's first event goes out with the first token, so llama-benchy measures prefill right
- opt-in --prefill-interleave (Smellyyyy, baKon) and --prefill-span (keptn42)
- four-rank TP releases the link early; four-rank selftests and docs/TP4.md (goodman-b)
- NVFP4 and FP8 compressed-tensors imports (devmilan); tools/rad-export for finetunes and LoRA
adapters (baKon)
- many fixes, among them lost tokens on stop strings under concurrency, keep-alive, MiniCPM5 tool
arguments and the CPU's vision and audio encoders
- plugin ABI 17 and changed op schemas: out-of-tree plugins must be rebuilt
- Qwen-Image 2.1 and 2.1 Turbo: text to image and image edits over OpenAI's images API,
/v1/images/generations and /v1/images/edits. An edit takes up to ten pictures and an optional
mask, outside which the picture comes back exactly as it was; `background: transparent`, png,
jpeg and webp output, `n` pictures from one prompt, streamed previews (`partial_images`), and
vLLM-Omni's seed, negative_prompt with true_cfg_scale, num_inference_steps, width and height.
arch/qwenimage21 serves the diffusers pipeline directory, converted with
data/recipes/qwen-image-2.1-fp8.recipe (block fp8) or qwen-image-2.1-bf16.recipe.
deploy/compose/qwen-image-2.1.yaml and qwen-image-2.1-turbo.yaml serve the fp8 containers on
two cards. Two R9700s make a 2048x2048 picture in 61 s at the base model's 40 steps and in
13 s with Turbo (56 and 12 s with --tp-wire wht6), a 1024x1024 one in 6.0 and 2.6 s. The
models are under Qwen's research license, which is non-commercial
- an image generator is a program kind of its own (core/gen): an architecture declares its
conditioning, denoising and decoding passes, and the driver runs the schedule, the pictures of
a batch and the conditioning cache. An image model's /v1/models entry is its generator's name
(qwen-image-2.1, qwen-image-2.1-turbo), and its capabilities and startup banner list only the
images endpoints
- the tiled prefill GEMMs run their tiles in groups of activation bands, 16 for fp8 and 8 for
bf16, so an operand larger than the 64 MB cache is read once a group instead of once a band. A
bf16 GEMM with more than 64 MB of weight runs up to twice as fast
- fixed: a second lane opened in the middle of a step started beside work lane 0 had not
finished. Gemma 4 26B-A4B opens its lane that way, so its first step after startup could read
rows not yet written
- startup no longer warns about --checkpoint-slots when it was not passed, nor about an expert
floor on a model with no experts
- the image's FFmpeg writes png, jpeg and webp (libwebp)
- for out-of-tree plugins: RAD_ABI_VERSION is 16. The op vocabulary gains the image generator's
ops (conv2d_nhwc, ln_mod, ln_mod_quant_fp8, flow_euler, attn_prefix_self and others; docs/OPS.md,
"Image generation"), and all_reduce takes an optional `overlap`. Plugins built against 1.5.0
must be rebuilt
- Gemma 4 31B (PRs #74, #75, #81, #86; sfjes, keptn42): sliding and global attention with their
own kernels, the assistant head as a drafter that reads the trunk's cache, the vision tower, a
fused w4a8 decode step, bf16 and compressed-tensors int4 checkpoints, and window snapshots so a
prefix hit on a sliding-window model resumes instead of prefilling again.
deploy/compose/gemma4-31b-w4a8.yaml serves keptn42's container on two cards
- ParoQuant (PRs #65, #66, #67; malic): Qwen3.8-27B checkpoints with learned Givens rotations,
as int4, int5 and MXFP4, imported without re-quantising, the prefill's rotations on the matrix
cores. deploy/compose/qwen3.8-27b-paro.yaml serves them on one card. A ParoQuant container made
with the PR builds is refused: convert it again with --reuse <old container>
- Gemma 4 26B-A4B with z-lab's DFlash drafter (PR #88; Perire): arch/gemma4 serves Google's bf16
checkpoint with the routed experts in block fp8 or bf16 (data/recipes/gemma4-26b-a4b-df*.recipe),
and libr4d gains its windowed paged attention, the fused sandwich-norm joins, expert_scale and
the sharded draft head's pair_argmax. A prefill chunk runs as two slices with its all-reduces
beside the compute, bit-exact with the whole step. The 31B's global layers take the windowed
attention too: an 11.5K-token prefill on two R9700s in 3.1 s instead of 4.9
- a startup that logs nothing for two minutes says where it waits (#89): the system call (a KFD
request by name), the library that made it, and its stack, which addr2line resolves against the
binary
- the prefix cache is kept in VRAM and host memory only (#70): the disk tier wrote every block and
snapshot a prompt produced, and its copies never outlived the process. --prefix-cache-host-mib
is renamed --prefix-cache-mib; --prefix-cache-dir and --prefix-cache-disk-mib are removed, and
startup refuses all three with what replaced them. The compose files no longer mount /data, and
.env no longer needs RADIANCE_STATE
- --prefix-cache-ttl S (default 3600, 0 never): a conversation no request has used for that long
leaves the cache, whichever tier holds it; radiance:prefix_cache_expired_total counts them. A
full host tier now drops its least recently used conversations
- --vision-tower-placement vram|ram (#84): ram keeps an encoder tower in pinned host memory and
gives its VRAM to the KV cache, read over the link once an image
- timings carry ttft_ms and total_ms (#85): the server's own time from the request body's arrival
to the first and the last token, queueing and tokenisation included
- a KV-cache recall that found a moved expert with nowhere to go stopped halfway and leaked the
slots it had already freed: after it every recall failed, the cache stayed short until a
restart, and requests failed with HTTP 500. A recall now waits for the slots it is owed and
always finishes
- a tool result or tool-call arguments that are not JSON are no longer refused as nesting past
1024 levels for their unmatched brackets (#90): only text that parses as JSON is held to the
bound, since nothing else is parsed into a tree
- the host-pool refusal names the limit that applies to pinned memory (RAM less 1/64 and
1.5 GiB), not ttm.pages_limit
- --embedding-placement auto, removed in 1.3.0, is refused with what replaced it
- for out-of-tree kernel libraries: gemm_nt_q gains two operands (pb1, pb2, the part bounds), and
the loader requires identical op schemas, so a library built against 1.4.0 must be rebuilt. For
architecture plugins, rad_op_declared(b, op) asks whether an op is in the loaded vocabulary
without declaring it
The two feed-forward arms of a Gemma 4 MoE layer read the same normed residual and meet only at
the feed-forward join; issued one after the other, the dense arm's three launches -- gate_up,
act_mul, down, ~36 us under --profile-ops at a 26B-A4B decode step on 4x R9700 -- wait behind the
routed arm's ~120 every layer. At a few rows its GEMMs are latency-bound, nowhere near the
bandwidth the experts' GEMMs take.
In a step that runs whole -- every decode and verify step, and a prefill chunk too short to cut --
the dense arm now rides the second lane: issued behind a join from lane 0 (the attention join is
its producer), beside the routed arm on lane 0, and joined back before the feed-forward reduction
reads both. Its rows of the join buffer and the routed arm's are disjoint. No collective rides it,
so the reductions keep lane 0 here and lane 1 in a cut prefill chunk, and a step's collectives are
on one lane as before. h, gate_up, ffn and ff2 are named to rad_buf_concurrent. Off with the
overlap's switch, RADIANCE_GEMMA4_OVERLAP=0, which now keeps every step on one stream; a startup
note says which.
arch_test: a decode step issues the dense arm's three launches a layer on lane 1 and every
all-reduce on lane 0, two joins a layer, and nothing on the two lanes that touches a common
element unordered; a 4095-token chunk the same; the cut chunks keep lane 1 for their reductions
alone. GUIDE.md's switch and ARCHITECTURES.md say so.
Not yet run on the cards.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 26B-A4B's router reads rmsnorm(x) * w_r * hidden^-0.5 and its experts rmsnorm(x) * w_e,
quantised to E4M3 for the fp8 gate_up: an `rmsnorm` and an `rmsnorm_quant_fp8` a layer, each
reading back the x norm_add_norm has just written and taking the sum of squares it has just taken.
At decode that is 60 launches a step (8.3 and 7.8 us under --profile-ops on 4x R9700); at a
prefill, eleven passes of each a layer per 20K-token request.
norm_add_norm_route is norm_add_norm, then from the norm factor it already holds the router's row
by rmsnorm's expression, ((x * s) * w_r) * mult, and the experts' codes as rmsnorm_quant_fp8 writes
them: the bf16-rounded norm, a scale of amax * (1 / 448) a 128 columns (1 for an all-zero group),
the value times its reciprocal clamped to +-448, one v_cvt_pk_fp8_f32. Element i is thread i % 256
at slot i / 256, so a group is four waves at one slot -- a wave's max, then the four through LDS.
Its own name rather than optional operands on norm_add_norm: the codes need whole 128-column
groups, which the plain join does not, and the arch falls back cleanly where it does not resolve.
A device row and a host arm (one helper with norm_add_norm's), the schema, OPS.md.
arch/gemma4 asks for it on every layer whose gate_up is block fp8 -- the user's fp8gu container,
every layer -- and then issues neither op_rnorm nor op_enorm; it declares both still, and
norm_add_norm and the chain behind it, for where it does not resolve. The routed arm's two norm
gains are declared ahead of the attention join now, which names them. The overlap takes either
join. A startup note counts the layers that take it.
The same rounding as the chain, but for the order a sum of squares is added in, as every join here:
g4k_emu holds the kernel to a chain summed in its block order bit for bit -- x, y, the router's
row, every code and scale -- at the 26B-A4B's 2816 at four heights, at 128, 3072, 3200 and 6144,
and with an all-zero group; against the host arm, no code more than a step off. The emulator gains
v_cvt_pk_fp8_f32, through the project's saturating encoder. arch_test: with fp8 gate_up experts the
route op resolves on all six layers, a decode step issues it and no rmsnorm_quant_fp8 and one
rmsnorm fewer a layer; refused, norm_add_norm and both launches; a tp-4 prefill through the
overlap issues it a slice and keeps every reduction ordered.
Not yet run on the cards.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every input of a drafter layer was three launches after its all-reduce: `add` (x += h), `rmsnorm`
(x -> h) and `quant_act_fp8` (h -> hq | hs), ~8 us each under --profile-ops on 4x R9700 and a few
unprofiled, twice a layer -- thirty a draft pass, every decode step.
libr4d's `rmsnorm_quant_fp8` is that chain in one pass where it takes the residual operand (the
fused_add_rms_norm form): the norm of the bf16-rounded sum, the codes of the bf16-rounded norm,
which its row states is the chain's function. The drafter now issues it for both inputs of every
layer, the attention input of layer 0 with no residual -- x as the embedding left it -- and the
last layer's trailing add stays, ahead of the final norm, which no quantiser follows. Nineteen
launches fewer a draft pass. Where nothing serves the op the chain is declared and issued as
before. A draft is verified whatever it is, so this cannot change what is accepted.
arch_test: a draft pass issues ten rmsnorm_quant_fp8 and one add, the residual operand x and the
delta h past layer 0 and x alone at it; refused, the chain's ten adds and fifteen quantisers.
Not yet run on the cards.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On gemma-4-26B-A4B at tp 4 on 4x R9700 the all-reduces were 47% of a 20K-token prefill under
--profile-ops (957 of 2020 ms): a layer reduces T x E after attention and both arms' 2T x E after
the feed-forward, at ~16.5 GB/s a rank on the link, against ~8 ms of compute a layer at the average
chunk. Run whole, the two take turns.
A chunk of two routed passes or more (4096 tokens) now runs as two slices, and every trunk
all-reduce rides the runtime's second lane (rad_lane) beside the other slice's compute: slice A's
attention reduction under slice B's output projection, slice B's under slice A's two arms, slice
A's feed-forward reduction under slice B's arms, and slice B's under the next layer's join and
projections of slice A. Attention runs whole -- it reads every row's keys. A model of the measured
times puts it at up to a quarter off an unprofiled prefill; --profile-ops syncs every op and cannot
show it.
The same bits as the whole step: the cut is a whole number of routed passes, so the routed arm
makes the passes the whole step makes, and both slices are at least one pass, above every row band
the sliced kernels have (the GEMM's 16 and 64, the reduction's one-shot edge) -- core's rule four
for the second lane. The slice's partials sit dense-then-routed in its own run of the join buffer,
so each slice's feed-forward reduction is one message.
The order: a reduction is issued on lane 1 behind a join from lane 0, its producer; lane 0 joins
lane 1 back before the consumer and before the next reduction is issued, since a join orders behind
everything its lane has issued. The embedding's reduction stays on lane 0, ahead of everything lane
1 is first joined behind, so the collectives keep one order on every rank. The two buffers reduced
in place are named to rad_buf_concurrent. Taken where the joins are fused, the wire is exact and
there is more than one rank; RADIANCE_GEMMA4_OVERLAP=0 runs every chunk whole, and the startup note
says which. A decode step never takes the lane.
routed() takes a run of rows and the join row its partial lands at; attention between the
projections and the output projection moves into attend(), which both paths issue.
arch_test records the lane of each issue and where each join sits, and a new test holds a 6-layer
26B-A4B with the DFlash taps, at tp 4: no two issues on different lanes that touch a common element
go unordered (taking every operand as read and written; dropping one wait makes it count six), lane
1 carries the trunk's 4 x 6 reductions at the slices' sizes and nothing else, the slices issue the
whole step's rows by op and its routed passes, a 4095-token chunk and a decode step stay on one
lane. GUIDE.md has the switch, ARCHITECTURES.md the paragraph.
Not yet run on the cards.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The drafter's head was `gemm_nt` over the target's bf16 table -- 352 MiB a rank at tp 4, every draft
pass, 566 us of a 26B-A4B decode step under --profile-ops on 4x R9700: the widest read on the draft
path, and the "first thing to change once the model runs" its own comment named.
A container may now hold the table a second time as `dflash.draft_head.weight`, block fp8 -- one
checkpoint tensor, two logical weights, as rad_block_dflash2.h does it -- made by the recipe line
dflash.draft_head.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16
which the three gemma4-26b-a4b -df recipes now carry. Where the copy is there, the head is
quant_act_fp8 over the gathered rows and gemm_nt_q over the copy at fp8a8: half the bytes, for 176
MiB a rank more. The copy is row-sharded exactly as the table, so a rank's rows are the same
vocabulary slice and row_topk's vocab_off, the all_gather and pair_argmax are unchanged. Drafts are
verified, so the coarser logits change what is proposed and never what is accepted --
draft_n_accepted says whether they propose worse; there is no rerank against the bf16 table yet.
Where the copy is not there -- every container converted before this, or one whose recipe made it
something other than block fp8 -- the head reads the bf16 table exactly as before. The decision is
the stored encoding's (weight_enc on the copy's name), and the copy's name map entry alone writes
nothing: rad-convert walks the declared weights. The startup note names the head in use. The
block-fp8 test moves to one helper, which the routed experts' encoding check now uses too.
arch_test: with the copy's encoding block fp8, the copy is declared and the head is gemm_nt_q over
it from the quantised rows; without, nothing is declared and the head is gemm_nt over the table;
a draft pass issues the head once either way. ARCHITECTURES.md says so.
Not yet run on the cards; it needs a container converted with the new recipe line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8772d5b handed the sliding layers' attn_paged q as a column slice of the fused [q|k|v] row. gemma4k
reads that; libr4d's paged attention reads q only dense and refuses the slice with RAD_E_STRIDE,
which stops the engine at the first step. Under attn_paged the first library in --kernels wins, so
the slice was only safe with gemma4k ahead of libr4d -- and the deploy script's default order
(libr4d,gemma4k,libavx) took the server down at layer 0's attention on both profile runs.
gemma4k now declares the same kernels a second time under attn_paged_qrow: attn_paged's schema
field for field, with q read at its own row pitch. Only gemma4k declares it, so it resolves there or
nowhere. The sliding layers ask for it once; where it resolves they read q in place (no lift), and
where it does not -- a hierarchy without gemma4k, or RADIANCE_GEMMA4_FUSE=0 -- q is lifted into a
dense block by a `cast` again and attn_paged reads that, which every attention library takes. The
lift's buffer is declared only then, since an unnamed buffer is live for the whole program. A miss
is the swa group's first op carrying a block_size, and answers rad_kv_block_size with the
RAD_KV_BLOCK it declares, as attn_paged would. No libref row, as the joins.
The kernel order still matters for speed -- gemma4k first is the order this model was measured with
(ARCHITECTURES.md) -- but no longer for whether the server runs. A startup note says which form
was taken.
arch_test: the slice reaches attn_paged_qrow and never attn_paged; refused, every sliding layer
lifts q for attn_paged; a decode step issues either form; and the three older gemma4 tests
count the sliding layers' attention under its new name. docs: OPS.md's row and paragraph (and a
line of the joins' text reflowed to the width, as one of gemma4.cpp's), ARCHITECTURES.md's kernel
paragraph, which now names expert_scale too, and GUIDE's FUSE row.
Not yet run on the cards.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A barrier is a fence, so a load written after a reduction waits for it. norm_add_norm fetched the
residual and both gains phase by phase, join_add_scale the residual, three or four gains and the
layer scalar, so each paid a global round trip per phase on top of its reductions: --profile-ops on
4x R9700 has them at 13.2 and 17.8 us a call at decode, 30 of each a step, where a launch that does
nothing costs ~7.
Now every operand of the row is in flight at once before the first reduction, the two arm norms
share one barrier pair (block_sum2: each value takes block_sum's butterfly and wave order), and a
thread holds 12 elements where the row fits -- n <= 3072, Gemma 4 26B's 2816 among them -- and
kMaxPer's 24 past that, instead of 24 always. The arithmetic is the same expressions in the same
order; a sum's terms past n were +0 and are gone.
g4k_emu: both joins at the edge between the two widths (3072, 3073), with and without the next
norm, bit for bit against the chain as every other case.
Not yet run on the cards.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One 256-thread block a row: at Gemma 4's tp 4 a row is a 65536-wide vocabulary shard and a step has
a decode's few rows, so a handful of blocks walked 256 elements a thread of tanhf each. --profile-ops
on 4x R9700: 82.7 us a decode step and 85.6 us for the prefill's single row, for 256 KiB of f32 a row
-- four times the drafter's row_topk over a row as wide (18.6 us).
Both legs now put a row on up to 64 blocks, eight elements a thread (32 blocks at 65536). Elementwise,
so no bit moves; libr4d's selftest and rad-kbench's libref comparison hold it as before.
Not yet run on the cards.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
R4D_AR_TWOSHOT_WIDE_MAX_ELEMS was 20971520 -- a 4096-token chunk of a 5120-wide residual -- and the
band above it went back to the one-shot, which sends (ws-1)*N bytes a rank where the two-shot sends
2*(ws-1)/ws*N. At the default --max-num-batched-tokens 8192, Gemma 4 26B-A4B's attention reduce is
8192 x 2816 = 23M elements and its feed-forward reduce, which carries both branches for their own
post-norms, 46M: both over the bound, so every full prefill chunk went one-shot at twice the bytes.
--profile-ops on 4x R9700, tp 4, a 20489-token prefill (chunks of 8192, 8192, 4105) fits one link
rate across all of it: the attention reduces 16.8 ms the three calls (two one-shot, one two-shot)
and the feed-forward reduces ~37 ms (all one-shot), 1.6 s of the 2.7 s prefill. The same rate with
every call two-shot is ~9 and ~19 ms: about 0.8 s less a 20k prefill.
The bound guards the kernel's int word offsets and nothing else -- the scratch already holds a
full message per slot (r4d_ar_entry.hip build()), twice what the two-shot uses -- so it is now
2^28 elements, 2^26 words at fp32. The fold is the one-shot's, fp32 in ascending rank order, so
the band edge moves no bits. Fewer bands also means one scratch set less: the old 20971520 band
was its own instance, ~335 MiB a rank at tp 4.
plugin_test: a 16384-token chunk is two-shot to its end, and the one-shot still takes a message
past the bound. r4d_selftest's three-rank pattern walks a 46137344-element message, past the old
ceiling.
Not yet run on the cards.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gemma 4 multiplies each renormalised routing weight by per_expert_scale of the expert it chose.
In the conventional vocabulary that is an `embed_lookup` of the [n_expert, 1] table by the ids
and a `mul` into the weights -- two launches a MoE layer, a few dozen elements each at decode
(--profile-ops: ~0.26 and ~0.22 ms a step across the 30 layers). gemma4k's `expert_scale` is the
pair as one kernel, ew = bf16(ew * w_e[id]), with an id outside the table reading 0 as
embed_lookup's missed row does: one product rounded once, so the pair's value bit for bit.
Like the joins it has no libref row on purpose, so arch/gemma4 falls back to the pair wherever
gemma4k is not loaded, and RADIANCE_GEMMA4_FUSE=0 turns it off with them. 30 launches a step the
fewer.
g4k_emu: device and host rows against the pair over 32 shapes -- top-k 1 and 8, pitched rows,
pads and one-past-the-end ids, rows past M untouched -- every element equal. arch_test: a decode
step scales in one launch, and in two with it refused. docs/OPS.md: the row and its paragraph;
GUIDE: what the switch now covers.
Not yet run on the cards.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
At decode heights the router GEMM (128 x 2816), its top-k and the expert sort are each one small
workgroup's work behind a full dispatch: --profile-ops put the three at ~0.27, 0.29 and 0.24 ms a
step across the 30 MoE layers. libr4d already fuses them for the Qwen MoE blocks --
`router_topk_scatter` for the pair, `router_gemm_topk_scatter` with the GEMM in front -- and
documents both as byte-identical to the launches they replace, so the routing does not move.
arch/gemma4 now asks for them as rad_block_moe_fp8.h does: the pair up to the sort's
single-workgroup bound (1024 routing slots, 128 rows at top-8), the GEMM form up to the skinny
GEMM's decode band (64 rows), and the separate ops for a pass past either, declared regardless.
The per-expert scale and the experts' input norm sit between them in the issue order and read only
the ids and weights the fused op writes. Two launches a MoE layer the fewer at decode, 60 a step.
arch_test: a decode step routes with the fused op; refused, with the pair; both refused, with the
three separate ops -- and the per-expert scale and the gather run in every case.
Not yet run on the cards.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
join_add_scale takes an optional gain `w_n` and output `y` (both or neither) and, given them,
writes y = rmsnorm(x) * w_n over the residual it has just stored -- the next layer's
input_layernorm, or the final norm after the last layer. Those norms read the x the join writes
and nothing else, so each was a launch of its own and a second read of the row; now it is a fourth
reduction in a block that already holds x in registers. On the 26B-A4B that is 30 launches a
forward pass the fewer (29 input norms and the final norm), at decode a step's worth of ~8 us
launches.
Rounding where the chain rounds: y is taken over the bf16 x the join stores, with libr4d's
expression, so g4k_emu holds it to the chain bit for bit (+next cases, decode to prefill heights,
odd widths and pitches) and to the host arm within a flipped rounding.
arch/gemma4 declares every layer's input-norm gain ahead of the layers so a join can name the
next one's; where a join resolves, the norm it replaces is neither declared nor issued, and where
it does not, the chain is as before. docs/OPS.md: the row and its paragraph. arch_test: fused,
the only x -> h rmsnorm is layer 0's and every join writes h; refused, all thirteen come back.
Not yet run on the cards.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The q lift -- a `cast` copying q out of the fused [q|k|v] projection into a dense block -- was
there because libr4d's paged attention reads q only dense. gemma4k's takes q at any row pitch
(its head_view, and g4k_emu's q-pitch-slice cases), and gemma4k serves all of Gemma 4's attention,
so the slice goes straight in: one launch and a [T, q] copy less on each of the 25 sliding layers,
every step. With libr4d ahead of gemma4k its attention refuses the slice by name (RAD_E_STRIDE)
rather than reading it wrong.
arch_test: no copy between projection and attention, and the attention reads `qkv_s`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ARCHITECTURES.md: a `gemma4` section in the file's form -- the 26B-A4B's geometry, the readings
that stay plausible when wrong (proportional rope is not a partial rotary, K is V, the router reads
the residual, per-arm post-norms, the bf16 embedding scale, the FULL sliding group, the drafter's
causality), tensor parallel, fp8 experts, which kernel library serves what, and what is not
declared. Its table gains the arch/gemma4 row, and the gemma4_bf16 row is corrected: that plugin
claims ("gemma4", "compressed-tensors"), not ("gemma4_bf16", "i4").
GUIDE.md: converting gemma-4-26B-A4B-it with its drafter, and RADIANCE_G4K_WMMA /
RADIANCE_GEMMA4_FUSE in the tooling table. IMPLEMENTATION.md: gemma4k/ in the layout.
KERNELS.md is rad-kbench's and is not edited here; it wants regenerating on a card with gemma4k
loaded.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The three containers arch/gemma4 has been served from, each with the usage header the in-tree
recipes carry:
- gemma4-26b-a4b-df: the routed experts' gate_up block fp8, their down bf16 (K = 704 is not
whole 128-blocks), the drafter's linears block fp8. The measured container.
- gemma4-26b-a4b-df-pad768: both expert projections fp8, from a checkpoint whose experts were
padded 704 -> 768 before conversion (zero rows of gate and up, zero columns of down: exact).
The padding is described rather than shipped: the tool that did it is Python and stays out of
the tree.
- gemma4-26b-a4b-df-bf16x: only the drafter quantised -- the bf16 reference for the KL mode.
The rules are the ones the containers were converted with; only the headers are new.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claims ("gemma4", ""): a container converted from Google's bf16 checkpoint, the recipe choosing
what is fp8. gemma4_bf16 keeps ("gemma4", "compressed-tensors"), the CT-INT4 dense release; the
two do not overlap. Serves gemma-4-26B-A4B-it (128 experts of 704, top 8) and the dense sizes
without per-layer embeddings, with a DFlash block-diffusion drafter merged at convert time.
The readings that stay plausible when wrong, each explained at its site:
- Proportional rope is not a partial rotary: the full layers rotate the first 64 frequency pairs
of the 512-wide head at theta^(-2j/512), pair j = channels (j, j + 256), declared as full-width
NeoX with the frequencies past pair 63 divided by 1e30 through the YaRN ramp `rope` carries.
- K is V on the full layers: V is the un-normed, un-rotated k projection, so its norm is issued
before the key norm overwrites `k`.
- The router reads the residual through a gainless rmsnorm times its `scale` times hidden^-0.5,
and per_expert_scale multiplies after the renormalised top-k.
- Two post-norms a layer's feed-forward, one an arm, each arm's partial reduced before its norm;
both partials share one [2T, n_embd] buffer so one all-reduce carries them.
- The embedding scale is sqrt(hidden) rounded to bf16 (53.0, not 53.066).
- The sliding layers' KV group is RAD_KV_FULL with the window on the attention op: a WINDOW
group is not prefix-cached, and on this tree a hit on one re-prefills; FULL keeps the hit.
- fp8 experts are two tables by parity, so a rank holds an even count; down at K = 704 cannot be
fp8 (whole 128-blocks), hence the 768-padded recipe.
- The sharded draft head's merge is pair_argmax at R = 2 on the wire.
- The drafter's tap copy is declared at the end of the layer it taps, where it is issued. The
buffer planner takes liveness from declaration order; declared once after the trunk, it let the
plan share `dflash_src` with `moe_edn`, which every MoE layer writes, whenever the sizes
allowed. At --max-num-seqs 16 they did, and on the cards DFlash accepted 2% of its drafts
(97 tok/s against 135 with speculation off and 186 with the taps intact), the text fluent
throughout.
The sandwich joins are asked for as norm_add_norm / join_add_scale (gemma4k) and declared as the
rmsnorm / add chain where nothing serves them; RADIANCE_GEMMA4_FUSE=0 asks for the chain. The
reply format is the shared one (arch/rad_gemma4_chat.h), so tool calls are parsed in the engine;
the plugin as measured declared reasoning only and left calls to an out-of-tree sidecar, so the
call path is untested on this plugin's containers.
arch_test: the MoE trunk declares both arms and six of each join; both KV groups FULL with the
window on the op; the full layers' rope over the whole head with the ramp at 63.5..64; with the
joins refused, the chain is declared and issued instead; both Gemma 4 plugins export one format;
with a DFlash drafter, `dflash_src` is live from the first tap layer (its range overlaps
`moe_edn`'s, so no plan can share them) and a step writes each tap once.
Measured on 4x R9700 at TP4 (gemma-4-26B-A4B-it + DFlash, gate_up experts block fp8), with
gemma4k and --draft-window adaptive: a story at T 1 177 tok/s, greedy thinking 572 tok/s, code at
T 0 319-334 tok/s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two plugins are about to serve Gemma 4 -- gemma4_bf16 the CT-INT4 dense release and arch/gemma4
the bf16 / fp8-expert containers -- and the reply format is the model's, not the weights': the
thought channel, and calls written as a name and one object in Gemma's dialect of JSON. One
declaration in the shared header library (installed as <arch/rad_gemma4_chat.h>), so the two
cannot drift apart and the reply-format tests read what both export.
The declaration moves unchanged, from gemma4_bf16::chat_format_decl() to
rad::arch::gemma4_chat_format(); chatparse_gemma4_test follows it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gemma4k builds for gfx12 only and its two joins have no libref oracle, so nothing on a machine
without the card, and nothing in rad-kbench, would ever run its kernels. g4k_emu compiles the
.hip sources as host C++ against a HIP shim: every GPU thread a fiber, __syncthreads and every
cross-lane op a barrier (one not reached uniformly is reported as a deadlock), the WMMA operand
layouts gfx12's. Checked against a port of libref's ref_attn_paged (attention, fixed cases and a
random sweep over every compiled geometry), against the host rows (pair_argmax), and against the
unfused chain bit for bit (the joins).
Registered in CTest under the label g4k_emu, on x86-64 with a clang: the kernels use
ext_vector_type and the fiber switch is SysV inline assembly. Under a clang C++ compiler they are
ordinary targets. The docker image compiles host C++ with g++, so there g4k_emu/run.sh builds the
same tests with the HIP compiler, ROCm's own clang++, and runs them as one test -- so wherever
gemma4k is built, this runs, the image's host-test stage included. About 40 s at the default
40-case sweep (50 s through run.sh, which compiles too); `g4k_emu_attn sweep 200` is the long run.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A kernel library beside libr4d, gfx12 only, and AHEAD of it for Gemma 4:
`--kernels gemma4k,libr4d,...`. Its own library rather than rows in libr4d: a smaller change,
its own gfx12 gating, and no churn in libr4d's row table; folding it in can follow.
- attn_paged at head_dim 256 and 512, gqa 1/2/4/8, bf16 or fp8 cache, any window, causal or not.
One scalar kernel serves decode, verify and prefill, with a split-KV path whose merge is one
wave a row (live pieces found by ballot, four at a time; a piece that saw no key writes only
its max and sum); a WMMA prefill kernel takes a query of at least 64 rows and 32 a sequence on
average -- Q and K bf16, P and V f16 (bf16 P measured 0.25% of the V range in error), the
denominator summed from the rounded P. RADIANCE_G4K_WMMA=0 keeps every launch on the scalar
kernel.
- pair_argmax, device and host, described as libref describes it so rad-kbench checks both.
- norm_add_norm and join_add_scale, ops of its own (docs/OPS.md, a new subsection): each one
kernel for a post-norm / residual add / pre-norm chain, rounding where the chain rounds. libref
has no row for them on purpose -- a reference row would resolve them where gemma4k is not
loaded and the architecture would never fall back to the chain -- and no row declares
`replaces`, since rad-kbench assembles a replaced chain from the fusing library's own rows.
WHY FIRST. libr4d on this tree also has rows at h256/gqa2 and h512/gqa8, Gemma 4's own
geometries, written for the dense 31B (which has no drafter) and not measured on the 26B-A4B or
under a DFlash verify; the hierarchy is absolute, so the first library takes them. These rows are
the ones every Gemma 4 number below was measured with. No other row overlaps libr4d's (the h256
gqa4/gqa8 rows take a window only), so putting this library first takes nothing else from it. The
softcap is libr4d's and libavx's `logit_softcap`.
Measured on 4x R9700, gemma-4-26B-A4B-it + z-lab DFlash, TP4: decode attention 3.234 -> 0.104 ms
a step on the full layers and 1.906 -> 0.722 on the sliding ones (the split-KV merge); a
20,489-token prefill 4.01 -> 2.83 s (the WMMA kernel); rad-kbench against libref 176/176. Not yet
run on the cards: the joins.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A vocab-sharded draft head proposes each position's argmax: every rank takes its slice's top-R
as (id, value) pairs, an all_gather puts them side by side, and something picks the winner.
row_topk_merge does that with an R-wide answer; a block drafter wants ONE id a row, written
contiguously into the token buffer it verifies, and a rank cannot send R = 1 -- a
row-interleaved all_gather moves whole 16-byte words and a pair is 8 bytes. pair_argmax is the
merge at R = 1 over world_size * R pairs: largest value, ties to the lower id, a negative id a
pad, -1 and -inf for a row with nothing valid, `val` optional.
The Gemma 4 DFlash head is its caller (arch/gemma4, later in this series) and gemma4k its device
kernel. libref is the oracle and the schema's first declarer; libavx carries the host row,
because an op the placement puts on the host cannot run on a reference (avx_check holds libavx
to libref's vocabulary). Both scalar: n is sixteen pairs at TP8.
docs/OPS.md: the row and a paragraph beside row_topk_merge's. ref_test: ties to the lower id in
any slot, a pad carrying the row's largest value dropped, an all-pad row, all-negative values,
`idx` at a pitch of two with the slots between untouched, and `val` absent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The adaptive window priced only a serial head's rounds and was refused for a
block drafter, on the grounds that the block is proposed in one pass. But
every verified draft is still a verify row, and on a MoE whose verify reads
the experts each row routes to, rows are not free (16 rows read ~10x the
experts one does). A block drafter now takes the same policy with its rounds
fixed: each sequence verifies the first min(D, its stop) of the block, its
stop from its own measured acceptance and D from the measured step times.
Prompt lookup alone keeps the fixed window and says so.
Speculation stays lossless: what is verified is a prefix of the proposal.
Measured on gemma-4-26B-A4B-it + z-lab DFlash (block 15), 4x R9700, TP4,
together with gemma4k's split-KV merge rewrite (landed in the same build, so
the two are not separated): story at T=1 95 -> 177 tok/s, greedy thinking
~360 -> 572 tok/s; code at T=0 319-334 tok/s (it verifies deep either way).
tests/sched_test.cpp: the block-drafter case now expects the policy on
(4 drafts verified while the estimate is the prior, 1 after 64 rejected
steps, draft_verify_depth[4] and [1] both counted); the prompt-lookup-only
and no-speculation cases are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
/v1/completions accepts llama-server's preserved_tokens: control tokens the
completion's text keeps rather than drops. A client that renders its own
template and parses its own reply (a tool-call sidecar) has no other way to
see a reply format built of control tokens. Bounded like the stop strings.
A thinking budget needs the reasoning block found by token. Gemma 4's opener
<|channel>thought is one control token followed by text; it is now found by
that first token (what a reply opening its own block writes first, and no
text can spell), with the text after it counted as reasoning. An opener with
a second control token in it is still refused, since its first token may open
something other than the reasoning. The refusal message says why.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gemma 4 declares <eos> as its eos but ends a turn on <turn|>, and a
tool-calling turn on <|tool_response> (the opener of the result the caller
supplies, written after the model's last <tool_call|>). Neither was in
kEogNames, so every Gemma 4 reply ran to max_tokens. llama.cpp's loader
lists both for this vocabulary.
A vocabulary that has <|tool_response> as a control token also has </s> as
ordinary text (llama.cpp concludes the same); ending on it would cut a reply
that writes the HTML tag, so </s> is not an end-of-generation token there.
This branch already ends a generation on every id generation_config.json
names (c65fabe), which covers both tokens for a container that carries
`generation.eos_token_id`. The spellings here cover one that does not, and
the </s> rule is new either way: the eos list never names </s> for Gemma 4,
but kEogNames did.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
std::tanhf is in <cmath> only from libstdc++ 14; against 13 (Ubuntu 24.04's) the host build stops
at libref and all four libavx levels. std::tanh's float overload is tanhf, so the arithmetic is
the same to the bit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rotated Qwen3.8-27B checkpoints: ParoQuant MXFP4, int5 bit-plane and z-lab's int4 import (the givens
transform with parts, per-row scales, zero points), the w5a16/w4a16_asym decode GEMMs, the
w4a8i8/w5a8i8 prefill band, the givens_rotate kernel, and the dense per-group rotation
(givens_dense_quant: one 128x128 f16 matrix a part and group on the matrix cores) for the quantising
rotation in prefill. gemm_nt_q gains part bounds (pb1/pb2), an op-schema change an out-of-tree
kernel library has to follow.
Fixes on top: the dense matrices are a container table ("t.dense") that rad-convert composes in f64
from the pairs and angles, and the loader only moves its bits. A container converted before this is
refused at load, naming the re-convert (--reuse copies every unchanged weight). A gemm_nt_q row that
does not read part bounds refuses them instead of ignoring them. libavx implements givens_rotate and
givens_dense_quant.
The 8192-token default makes a long prompt's step take about 5 s on Gemma 4 31B, holding every
running decode for that long. At TP2 on two R9700s, a 26K-token prefill: 1475-1477 tok/s at 2048
against 1456-1463 at 8192; decode step time equal at c1 and c4.
The gemma4_bf16 architecture (sliding and global attention, the proportional RoPE ladder, the
assistant head as a drafter that reads the trunk's cache, the vision tower), its w4a8 decode
junctions, the h512/gqa8 and h256/gqa2 attention kernels, compressed-tensors int4 import, multi-EOS
from generation_config, the call/reasoning reply format, a window group that keeps the keys a
prefill chunk still reads, and window snapshots in checkpoint slots so a prefix hit on a
sliding-window trunk resumes.
Fixes on top: the investigation switches and diagnostic blocks out of the served paths; int4 import
through the checkpoint import framework; attention_k_eq_v from the config; the fused junctions only
where every reader takes their pair; a shared-KV head binds no group of its own; the compose file
without HSA_ENABLE_IPC_MODE_LEGACY (TP2 fails with it on ROCm 10.1); a checkpoint carries a window
only where a hit resumes from it; the README says the linked container is keptn42's calibrated GPTQ
build and what the in-tree recipe gives.
- Qwen3.8-Flash-Next on one card: the heat engine moves 64 experts a step (was 8), its copies and
the prefill's expert staging run on the card's DMA engines instead of as copy kernels, and at
decode the next layer's likeliest experts are copied onto the card ahead of its GEMMs. Against
1.3.0 at --tp 1: prefill +17-20% from 8K tokens up, throughput under load +16-20%
- deploy/compose/flashnext-tp1.yaml: Qwen3.8-Flash-Next on one card and 64 GB of host RAM
(4096-token prefill steps, 4 sequences, a 301K-token cache)
- #61: --busy-prefill-chunk (default auto): a long prefill leaves the rest of the step to the
requests decoding beside it and to new arrivals, instead of taking all of it (baKon)
- LiquidAI's LFM2 and LFM2-VL, and d1's /v1/systemone (after zivius's PR #50)
- a startup report: every option with its value and where it came from, the hardware, and what
on it costs speed with the fix; /diagnostics serves it (behind the API key; without one, only
to the same machine)
- #69: a GPU memory fault names the buffer and kernel argument behind it and ends the server at
once (exit status 70), instead of hanging or writing a core of tens of gigabytes
- #64: a card without Resizable BAR is refused at startup, naming what to turn on, instead of
crashing at the first launch
- the image is built with ROCm 10.1 (the host's amdgpu driver must support it), with ROCm's
libLLVM rebuilt so the same source compiles to the same kernels every time; a source build
takes ROCm 10.1 or 7.2
- #71: the image ships curl, jq and a CA bundle, so --model <HF repo id> works in the container,
and hfget.sh runs under its busybox (baKon)
- --profile-ops shows how long each op's lane sat idle before it; cardclock.py skips an
integrated GPU instead of stopping
The prefix cache cannot index a windowed group, so every hit on a windowed
trunk re-prefilled the whole prompt (73620ef). Gemma 4 31B (50 of 60 layers
windowed at 1024) paid that on every chat and agent turn: 17-48 s to the
first token at 25-49k tokens.
A model with a window and no linear state now takes one checkpoint per
prompt, a block short of its end -- the next turn re-renders the last few
tokens -- if the prompt is --checkpoint-interval tokens or longer, and does
not split chunks at the interval. The prefix cache treats the window like
linear state: a hit is reusable at a checkpoint only. admit_one adopts the
full-attention blocks as before, seeds the windowed groups at the window's
floor, and the entry's restore fills them from the slot; anything else
re-prefills as before. A model with both linear state and a window keeps
refusing the hit.
Measured on Gemma 4 31B, TP 2, agent transcripts: a follow-up turn's first
token in 0.8-3.4 s instead of 17-48 s; greedy output byte-identical to a
cold prefill with the same chunk boundaries (32 turns, chains five hits
deep, thinking on and off).
A WINDOW group keeps only the blocks its window can still read, so no block
list from the prefix cache describes it. A checkpoint slot now carries, after
the linear state, window_blocks pages a WINDOW group (every layer, layer-major
rows): the window a query at the checkpoint reads, blocks
[max(0, P/B - (window_blocks - 1)), P/B) -- the floor recycle_window keeps.
window_rows() names those pages from the leader's table, padded per group, so
every rank copies its own shard with one vector (followers keep no sequence
tables); it answers false when the table no longer holds them. seed_window()
gives a sequence with an empty window table fresh blocks at that floor for a
restore to fill. checkpoint_save/restore take the rows; a model with no window
passes none.
Gemma 4 sometimes skips the <|"|> that closes a string and writes the
object's `}` and <tool_call|> straight after the text (measured on the
31B: the close delimiter at p=0.86, `}` at p=0.08). The object reader
only ended a dialect string at its own close, so the call's close, a
repeated close, an empty thought channel and the next call's opening
were read into the value -- up to the next call's <|"|>, which then
"closed" it.
Inside a string, the call's close now ends the string and the call when
the closers just before it close every open bracket of the object, as
vLLM's and HF's Gemma 4 parsers end a call at the first `}<tool_call|>`.
Those closers are the object's and leave the value, a repeated close
goes with them, and a quote or backtick just before them that leaves the
string with an odd count of its kind was the string's close in the wrong
spelling (seen with thinking on). The call's close inside a string that
does not close the object is text, as before.
A value opened with a plain `"` or `'` in a dialect with strings of its
own is read the way the model writes it there (measured: `'...'` for
nested arguments, `"..."` verbatim, or with only `\"` escaped): verbatim
but for an escaped quote, never with JSON's other escapes -- `\n` stays
the two characters, as in the JS source it came from. It ends at a quote
the object's syntax goes on after (a member, an element, the closers and
the call's close), or at <|"|>. Single-quoted values were read as bare
words before.
The object grammar admits such a value too. Refused, the model took the
next token the grammar allowed, a `-`, and every single-quoted string
came out as a number (-1, -2, ... at temperature 0).
Held bytes stay bounded (a 16-byte run, 32 bytes of lookahead).
gemma4-31b-w4a8.rad on Hugging Face (keptn/gemma4-31b-w4a8): the bf16 checkpoint's trunk as GPTQ
int4 with int8 activations, the assistant head as MTP drafter, the vision tower. The compose file
carries the flags the model card's numbers were measured with.
The 31B's tower (27 layers of 1152, 72-wide heads, a 2-D rotary over two 18-pair
neox blocks, 3x3 pooling, per-channel standardisation) declared beside the text
model when the container carries it and the deployment serves media; its rows
replace the placeholder embeddings after the lookup. qk_norm_rope's blocks mode
now runs at any head_dim and section size (a lane a pair outside the register
layout).
Between two w4a8 blocks the stream ran five single-row dispatches
(post-norm, add, layer scalar, norm, quantiser), q, k and v quantised the
same norm output three times, the attention prologue was five more ops
and down's input two. Now every junction is one rmsnorm_quant_i8 (at two
ranks on the exact wire ar_rmsnorm_quant_i8, with the all-reduce in it),
q, k and v read one int8 pair, the prologue is qkv_norm_rope and down's
input gelu_mul_quant_i8. The trunk pass at k=3 goes from 1786 to 840
dispatches.
Byte-identical to the unfused step: greedy output equal at k=0 and k=3.
A kernel set without an op keeps that op's chain; RADIANCE_G4_FUSE=0
keeps every chain, for an A/B against the same build. arch_test checks
the issued op sequence fused, at two ranks, and with the ops refused.
The plugin mapped only the CT-INT4 release's X.weight_packed. A bf16
checkpoint (Google's gemma-4-31B-it, every finetune of it) stores
X.weight; the name is now chosen from the checkpoint's own
quantization_config. A linear a recipe keeps at int8 on the same
128-column grid is served by gemm_nt_q at w8a8 with the activation
quantiser the w4a8 path already declares.
Recipe gemma4-31b-dense-bf16-w4a8 added: the CT recipe's grid and size
(int4, f16 scale a 128 columns) with the least-squares scale search. The
assistant head was trained against the bf16 trunk: served from this
container it accepts 0.71/0.62/0.63 of its k=3 drafts on prose, against
0.49/0.50/0.44 from the QAT container, at the same step time.
At two ranks the residual junction follows the row-parallel GEMM's
all-reduce. ar_rmsnorm_quant_i8 is that all-reduce (exact wire, the
ar_rmsnorm_quant_fp8 handshake) and rmsnorm_quant_i8 in one kernel, x
INOUT because it is the message. A deployment on the lossy wire keeps the
standalone all-reduce. Needs a peer rank, so the selftest skips it like
ar_rmsnorm_quant_fp8; byte identity is checked through a model run.
The down projection of a GELU-gated feed-forward on a w4a8 grid is fed by
gelu_mul then quant_act_i8, two single-row dispatches at a decode batch.
gelu_mul_quant_i8 is the pair in one pass, byte-identical to it: the
product formed as gelu_mul_kernel forms it (tanh form, bf16 store), then
quant_act_i8's partition. The selftest compares it against the pair at
M 1/4/40.
An attention block with separate q, k and v projections and per-head
norms (Gemma 4) runs five single-pass ops between the projections and the
cache store: rmsnorm_p on v (or on the raw k where v is k), rmsnorm over
the q heads, rmsnorm over the k heads, rope on q, rope on k.
qkv_norm_rope does them in one dispatch, one workgroup a (token, head).
Byte-identical to the five: the same norm widths r4d_act_threads picks
and rope's ladders, head included. The row is constrained to head_dim
256..512 in steps of 256; other shapes keep the five. The selftest
compares both of Gemma 4 31B's attention classes at M 1/4/40.
A w4a8 linear is fed by rmsnorm then quant_act_i8, two single-row
dispatches at a decode batch; in a sandwich-norm model (Gemma 2/3/4) the
residual junction in front adds a post-norm, the add and a layer scalar,
five dispatches at every junction. rmsnorm_quant_i8 is that chain in one
pass over the row, with the junction optional (w_post, scalar and the
residual operand).
Byte-identical to the chain it replaces: the same row partition
(r4d_act_threads) and a bf16 rounding wherever the chain stores. The
selftest compares it against the chain at three forms x M 1/8/40.
Google's Gemma 4 assistant (Gemma4AssistantForCausalLM), merged under
`draft.` by `rad-convert --draft-model`, declared when the container carries
it and the deployment speculates (max_spec > 0):
x = pre_projection(concat(E_trunk[tok] * sqrt(n_trunk), h_trunk))
x = 4 layers (3 sliding, 1 full): q-only attention over the TRUNK's cache,
o_proj, plain-gain sandwich norms, GELU ffn, per-layer scalar
hd = norm(x); logits = the head's own tied table (no soft-cap)
h' = post_projection(hd), the next round's hidden state
h_trunk is the trunk's final-normed hidden state. Each head layer reads the
last trunk layer of its class (58 sliding, 59 full on the 31B), as vLLM wires
it. The head keeps no cache, so it is declared with rad_drafter_shared_kv:
one row a drafting sequence, every round at the committed position.
TP: q heads row-sharded with the trunk's kv heads; o_proj and down are
column-sharded and all-reduced before their post-norm; projections and norms
replicated; the lm_head vocab-sharded through the ordinary sampler chain.
Declare refuses a head whose kv geometry, window, rotary or vocabulary differs
from the trunk's, and use_ordered_embeddings (centroid masking). The probe
answers draft depth 3 for `--num-speculative-tokens auto`.
arch_test: no head without one or at max_spec 0; shapes, name maps, the
drafter declaration; the issue order of a history pass and a round; the
attention reading trunk layers 10/11 of the 12-layer fixture; TP2 reduces
before each post-norm; a history pass of the wrong shape is refused.
rad_drafter_shared_kv(b, pos_offset), an additive builder export: the
declared SERIAL head reads the trunk's K and V and writes none (Gemma 4's
assistant head has a query projection and nothing else per layer). A
plugin that does not call it drafts exactly as before; RAD_ABI_VERSION is
untouched (same pattern as rad_kv_group_zero).
For such a head the serial driver changes in two places:
- No history is owed. The history pass carries round 1 only: one row a
drafting sequence, at the committed position, with the token the trunk
chose after it and the trunk's hidden state there. A sequence that does
not draft gets no row; a step with nothing to draft runs no pass.
- Every round runs at that same position, over the same context. seqused
ends at the committed position: past it, the trunk's cache holds the K
and V of drafts the verify rejected, or nothing.
`pos_offset` (0 or 1) is where the rows sit for the rotary, relative to the
committed position; it moves nothing else.
Card side: ADV_HIST and ADV_ROUND take the shape from AdvanceArgs::shared_kv
and rot_shift, which the scheduler fills from the Program. Host side:
serial_begin/serial_batch stage one row and a constant ceiling.
Tests: build_test checks the export's refusals; sched_test stages one verify
step both ways (the old path pinned: five history rows, rounds stepping),
checks that a cacheless head runs no pass when nothing drafts, and runs the
card's advance rows directly for both shapes.
Gemma 4's template is one llama.cpp reads with a hand-written handler, so the template analysis
found no format in it: the server warned "this model's reply format cannot be described",
returned the thought channel as content and refused every request with tools (HTTP 400).
The plugin now states the format its tokenizer_config.json declares (`response_template`), in
gemma4_chat_format.h, exported through RAD_ARCH_CHAT_FORMAT:
thinking <|channel>thought\n ... <channel|>, reasoning_anywhere
calls <|tool_call>call:NAME{...}<tool_call|>, repeated, triggers on <|tool_call>
the object bare keys, strings between <|"|> and <|"|>, other values as JSON writes them
The template closes an empty channel in the generation prompt when thinking is off and opens one
after a tool response when it is on; RAD_CHAT_THINK_FROM_PROMPT reads both. llama.cpp's handler
records an extra thought channel after the answer and a lone <channel|>; reasoning_anywhere reads
the first as reasoning and drops the second, so neither reaches the content.
chatparse_gemma4_test, against the model's own template (tests/data/chat/gemma4) and llama.cpp's
Gemma 4 parser as the oracle (tests/legacy, which now takes a declared format): every reply the
template renders reads back as the message it rendered, byte for byte as llama.cpp reads it; the
shapes the model writes and the ways it leaves the format; thinking on, off, and after a tool
response; reasoning_format none; a conversation with role:tool results rendered into the open
turn and continued; every truncation, fuzzed replies and a 200 KB string under the streaming
contract; the call grammar against llama.cpp's on rendered calls, tool_choice required and a
response format; and the chat bridge serving it, with the decoder rendering <|"|>.
arch_test holds the export to the header.
End to end on the 31B QAT checkpoint, two R9700 at TP 2: 60 requests over greedy and
temperature 1.0 / top_k 64 / top_p 0.95, streaming and not, thinking on and off. Every request
with tools came back with finish_reason "tool_calls" and JSON arguments -- one call, two parallel
calls, integer and boolean arguments -- every follow-up with role:tool results as an answer with
finish_reason "stop", and no <|channel>, <channel|>, <|tool_call> or <|"|> reached any content or
reasoning_content. With thinking off the model writes <|channel>thought\n<channel|> itself
before its answer to a tool result; it is read as an empty thought.
A checkpoint states the tokens a generation ends on in generation_config.json (eos_token_id, one
id or a list), and rad-convert already carries it into the container as
`generation.eos_token_id`. The vocabulary did not read it: it ended on eos, eot and a list of
known spellings. Gemma 4 names three, [1, 106, 50] -- <eos>, <turn|> and <|tool_response> -- and
the container's eos is only the first.
- <turn|> closes every turn. Without it a reply runs past its own end: a three-sentence answer
stopped at max_tokens 400 after ~390 tokens of "---" lines instead of finish_reason "stop" at
65 tokens.
- <|tool_response> is what the model writes after its calls, where it waits for the result.
Greedy on the 31B QAT checkpoint (TP 2): after a finished call the next token is 50 with and
without this change; without it generation goes on and writes the same call again until the
token limit, with it the reply ends there (stop_type "eos", one token).
The engine reads `generation.eos_token_id` from the metadata before loading the vocabulary
(VocabBuild::eos_ids, not baked) and Vocab::load ends a generation on every id in range, logged
beside the spellings it adds.
text_test: ids in the list end a generation, an id naming no token is no id.
The reply format described one call syntax, the tagged one: each argument in its own tags,
typed by the tool's schema. A call written as its name followed by ONE object holding the
arguments could not be described -- Gemma 4's `<|tool_call>call:NAME{key:<|"|>text<|"|>}<tool_call|>`
is one, and its tool requests were refused; JSON behind a name tag (`[TOOL_CALLS]NAME[ARGS]{...}`)
or inside a function tag is the same shape.
RadChatFormat grows at its end (no ABI bump; an older plugin reads the new fields as zero):
- args_form RAD_CHAT_ARGS_OBJECT: the arguments are one object after the name. name_suffix may
be empty, and the name then ends at the object's `{`; call_end may be empty, and the object's
own `}` ends the call. The arg_* fields are unused and must be empty.
- object_string_open / object_string_close: a string delimiter of the object's dialect besides
JSON's `"`, between which the text is verbatim (Gemma 4: <|"|> twice).
- object_bare_keys: the dialect writes keys bare, `key:value`.
- reasoning_anywhere: a reasoning block may open again later in the reply (after the answer,
between calls) and is read as reasoning there too; a close with no block open is dropped.
The streaming parser reads the object as it arrives and writes it as JSON as it reads: brackets
and separators as they come, a key once its `:` shows it is one, a string's bytes as they arrive
(the dialect's verbatim, JSON's with its escapes checked: an unknown escape is text, a lone
surrogate is U+FFFD), and a bare value as the tagged family writes a typed one -- held while it
could be a number or literal, else a string. Trailing and missing separators, a bracket of the
wrong kind, a key without value and an object cut off by the call's close are repaired locally
and reported as leaving the grammar; a closed call's arguments are JSON whatever was written.
The streaming contract holds: deltas are never revised, holds stay bounded.
The lazy grammar writes the object in its dialect (strings between the delimiters, bare keys,
JSON numbers and literals) and leaves the values to the model, as llama.cpp's own Gemma 4
grammar does: the schema converter speaks JSON, and the dialect is not JSON.
chat_format_check refuses what the parser could not read unambiguously, by name: tagged fields in
an object format, a dialect string opener that begins like a bare word, a call close that holds
object punctuation or cannot be told apart from the string opener, a reasoning marker that
overlaps a call opener in content.
chatparse_test: JSON behind a name tag and behind a function tag (strict, lenient, streamed every
way, grammar admits and refuses), reasoning_anywhere on and off, and the refusals.
o_proj and down_proj are column-sharded, so under TP each rank holds a partial sum of the
projection. The post-attention and post-feedforward norms ran on those partials and the
all-reduce summed the normed halves: sum_r rmsnorm(p_r) instead of rmsnorm(sum_r p_r). HF and
vLLM (RowParallelLinear) reduce first. At TP 1 there is no all-reduce and nothing changes.
The windowed prefill took the walk's first tile from the chunk's row 0, so every CTA of a long
chunk walked from the chunk's window start to its own causal limit. Tiles below the window of a
CTA's first row are masked for every row it holds, so starting there changes no value.
ladder=head kept the rotary_dim-wide pairing: pair i = (i, i + rotary_dim/2). HF's proportional
RoPE (and vLLM's Gemma4RotaryEmbedding) rotates the whole head: inv_freq has head_dim/2 entries,
the first rotary_dim/2 of them 1 / theta^(2i/head_dim) and the rest zero, so pair i is
(i, i + head_dim/2). On Gemma 4's global layers (128 of 512) the old pairing turned channels
64..127 and left 256..319 alone.
rope in libr4d, libref and libavx now rotates the whole head under ladder=head, with the
frequencies past rotary_dim/2 at zero. The rotary ladder is unchanged. op_rope_ladder and the
r4d_selftest mirror check the HF pairing.
ensure() recycled a RAD_KV_WINDOW group against the end of the step, so a
prefill chunk lost the keys its first rows read (a 2185-token prompt kept
no window KV for positions 0..1151). Recycle below the step's first query
(keep_from = n_computed), size the caps for one extra chunk, and trim the
window when a prefill chunk is committed. The old test pinned the bug.
Found while debugging #75 (Gemma 4).
Gemma 4 dense as two attention classes (sliding-window + proportional-RoPE
global, k_eq_v) over one GemmaRMSNorm stream with GELU ffn, two KV groups,
softcapped logits, tied scaled embedding. arch_test builds the full graph.
Env-gated residual-trace instrument in the arch (RADIANCE_TRACE_RESID, default
off). 21.7 GiB w4a16 QAT checkpoint serves coherent sampled output on the box.
bind_ops falls back to the host domain when an op is host-only and carries no
weight tensors: a plugin declaring host-only math gets the same binding path as
device ops, with no model-specific quirk. Adds the R4D_DIAG kernel-selection
trace in plugin selection (default off).
head 512 (gqa 8) — a head width the library had not compiled before — for the
global layers, head 256 (gqa 2) for sliding-window decode, plus the >=32-token
windowed prefill fix. Numeric selftests vs an inline port of ref_attn_paged
with negative control; env-gated attn-verify probes (R4D_VERIFY_ATTN, default
off) at the decode entries.
ladder param on rope/rope_table across ref/avx/r4d legs; embed_lookup gains its
runtime scale under the canonical registry name (mult). Default-preserving:
existing checkpoints replay unchanged (kbench rope fixture 44/44).
Elementwise ops with numeric selftest cases against the f64 oracle (both legs
of logit_softcap: bf16 and the f32 band the sampling chain carries). libr4d
gains env-gated verification probes alongside them (R4D_VERIFY_OFF
recompute-on-host checks; default off — instruments, not features).
prefix.cpp indexes the RAD_KV_FULL groups and skips RAD_KV_WINDOW (its own
words: "a hit's blocks do not describe a cache whose floor moves" — the
blocks below the window are recycled). admit_one clamped a hit for the
linear/checkpoint cases; a model whose own attention includes a group the
cache skips — every windowed+full pair — passed every clamp, reused, and
adopted blocks covering the CACHED groups only. The windowed trunk layers
take used = ctx_len + n_tokens (batch.cpp) and read positions below
ctx_len this sequence never wrote; grab_block's min-heap (kv.cpp) hands
out the most recently freed blocks, i.e. the previous tenant's. The
sequence attends to the PREVIOUS REQUEST'S KV as its own prefix: fluent
text carrying the last request's content. Reproduced on a live server
with sequential prompts (A-B-C-A-B: the re-run of A reads C's prompt),
and it is why a windowed model with the prefix cache on cannot currently
serve more than one conversation at a time.
The fix is a second predicate next to the drafter floor, computed once
in init(): a paged group bound to a TRUNK layer (below meta.n_layers —
a drafter borrows from base_layer and above, per rad_bind_layer_kv) that
cached_groups() does not name. In admit_one, a hit with such a hole
reuses nothing: the prefix re-prefills (windowed prompts are small;
milliseconds). The drafter's own hole stays the refill design's —
HitCap ends the hit one drafter window before the prompt's end so the
tail-recompute covers the drafter's window while the trunk reuses the
rest (the e95d397 tests keep passing, all of them); no tail-recompute
can repair a trunk hole, which is why zero is the honest answer there.
sched_test gains an opt-in WINDOW group in the fixture (bound to a
trunk layer) and a_hit_on_a_model_with_a_windowed_group_reuses_nothing:
a deep, checkpoint-covered hit — legal under every other clamp — on a
cache indexing only the FULL group. Reuse lands at 0, nothing is
adopted, and attn_cached_tokens still reports the 304-token match: the
cache hit and the scheduler refused it. Disable the clamp and the hit
adopts 16 blocks of the seeded (previous tenant's) KV — n_computed 256,
the leak as shipped; that is the regression net.
Box: ctest lane + A-B-C-A-B battery green (evidence in the PR body).
prefix.cpp indexes the RAD_KV_FULL groups and skips RAD_KV_WINDOW (its own
words: "a hit's blocks do not describe a cache whose floor moves" — the
blocks below the window are recycled). admit_one clamped a hit for the
linear/checkpoint cases; a model whose own attention includes a group the
cache skips — every windowed+full pair — passed every clamp, reused, and
adopted blocks covering the CACHED groups only. The windowed trunk layers
take used = ctx_len + n_tokens (batch.cpp) and read positions below
ctx_len this sequence never wrote; grab_block's min-heap (kv.cpp) hands
out the most recently freed blocks, i.e. the previous tenant's. The
sequence attends to the PREVIOUS REQUEST'S KV as its own prefix: fluent
text carrying the last request's content. Reproduced on a live server
with sequential prompts (A-B-C-A-B: the re-run of A reads C's prompt),
and it is why a windowed model with the prefix cache on cannot currently
serve more than one conversation at a time.
The fix is a second predicate next to the drafter floor, computed once
in init(): a paged group bound to a TRUNK layer (below meta.n_layers —
a drafter borrows from base_layer and above, per rad_bind_layer_kv) that
cached_groups() does not name. In admit_one, a hit with such a hole
reuses nothing: the prefix re-prefills (windowed prompts are small;
milliseconds). The drafter's own hole stays the refill design's —
HitCap ends the hit one drafter window before the prompt's end so the
tail-recompute covers the drafter's window while the trunk reuses the
rest (the e95d397 tests keep passing, all of them); no tail-recompute
can repair a trunk hole, which is why zero is the honest answer there.
sched_test gains an opt-in WINDOW group in the fixture (bound to a
trunk layer) and a_hit_on_a_model_with_a_windowed_group_reuses_nothing:
a deep, checkpoint-covered hit — legal under every other clamp — on a
cache indexing only the FULL group. Reuse lands at 0, nothing is
adopted, and attn_cached_tokens still reports the 304-token match: the
cache hit and the scheduler refused it. Disable the clamp and the hit
adopts 16 blocks of the seeded (previous tenant's) KV — n_computed 256,
the leak as shipped; that is the regression net.
Box: ctest lane + A-B-C-A-B battery green (evidence in the PR body).
With curl and jq in the image, hfget.sh got further and stopped twice more,
both times on busybox, which is the only shell and coreutils the runtime
image has:
- `df -BG --output=avail` is GNU-only. Busybox printed its usage, $free came
out empty, and every download "did not fit". Free space now comes from
POSIX `df -Pk` (KiB), and the fit check compares bytes against KiB * 1024.
- Busybox `xargs -I` strips a line's leading blanks, and GNU's doesn't. A
non-LFS file (config.json, tokenizer.json...) has an empty oid, so its line
started with a tab and reached the child one field short. The size landed in
oid and the path in size, so every small file failed its size check:
"config.json is 721 bytes, listing says config.json". The list line is now
<size><tab><oid><tab><path>. Size is never empty, so no line starts with a
blank. The manifest format is unchanged, so an existing cache stays warm.
Tested in the image (busybox) and in ubuntu:24.04 with curl and jq (GNU):
fresh fetch, warm re-run, a truncated shard resumed and a deleted file
re-fetched (sha256 matches the hub's LFS oid), and the does-not-fit guard on a
1 MiB tmpfs.
`--model <repo id>` runs hfget.sh, which needs curl and jq, and curl needs a
CA bundle to reach huggingface.co over TLS. The runtime image is built FROM
scratch and had none of the three, so inside the container the fetch stopped
at "hfget: jq is required" (and with jq alone it would have stopped at curl,
then at the TLS handshake).
The rootfs stage now installs curl, jq and ca-certificates and copies the two
binaries and /etc/ssl/certs/ca-certificates.crt in. Their libraries go through
the same ldd closure, ELF-from-the-chroot check and licenses.sh as everything
else. They're installed in rootfs rather than build, so this doesn't
recompile the engine. The rootfs grows from 297 to 315 MB.
cfg_for() pins MB = 1 across the decode band (M <= 64): right for the bf16
and MXFP4 skinny kernels, where the grid, not the weight, is the cost. The
w5a16 / w4a16_asym kernel is dequantise-bound, and one block per 16-row tile
unpacks every weight fragment once per tile, so two or three concurrent
streams (M = 16..48) paid the unpack two or three times: 104 us/call at one
stream, 190 us at three (profile-ops, PARO int5, 1.3.0).
Cover every row tile in one block (MB = ceil(M / 16), at most 4) unless a
tuned MB is pinned. The split-K bound is unchanged, so every output element
is still one wave's accumulation over the same K slices: output bits are
identical.
PARO int5, prod shape (175k / 3 seqs), BetterBench c3 aggregate t/s at
1 / 2 / 3 streams: 96 / 156 / 155 -> 92 / 169 / 170 (+9% / +10%);
same-source A/B on the dev build: c3 127 -> 166. Single-stream decode is
unchanged (that GEMM streams the weights at the memory roofline, ~620 GB/s).
Quality unchanged: ppl wiki 6.797 / code 1.533, GSM8K 100%, genchat 17/17
cold-verified, dia-mini v2 23/27, v3 15/15.
r4d_selftest gemm_w5a16_nt_m64: pass (incl. M = 40 with 3 parts, M = 64).
A prefill chunk took every token the step had left (plan_chunk(..., budget)). On a step budget of
a few thousand tokens and a prompt of a few hundred thousand, that is every step for a minute or
more, and for all of it a decode row behind the prefill in running_ got nothing (`want > budget`
-> break) and admission never ran (`while (... budget > 0)`). A mostly-cached turn that needed a
few hundred tokens waited for somebody else's whole prompt: on three ranks at
--max-num-batched-tokens 2048, a 94,529-token turn with 94,208 cached took 40.6 s to its first
token, which landed on the instant a 264,725-token cold prefill ahead of it ended (#61).
--busy-prefill-chunk auto (the default) holds a prefill chunk back only when work that would
otherwise get nothing is pending in the step: one row plus the draft window for each decode row
behind it, a share (an eighth of the budget, at least one quantum) for each prefill behind it and
for the next request waiting to start. The chunk never drops under the smallest step the prefill
stager overlaps -- under it every routed layer reads its pooled experts synchronously, the
-65 % prefill measured at a budget one token under the threshold. Where holding it back for a
waiting request or another prefill would leave a remainder under that floor before the checkpoint
boundary, the interval is split into two staged halves instead. Decode rows alone only take their
few tokens: the chunk ends a quantum short of the boundary and the next step finishes the
interval, the same pair of steps a prefill already runs when decode rows are planned ahead of it.
(Halving for decode rows too held a long prompt to half-interval chunks for as long as anything
decoded behind it, the larger cost.) Whatever the reserve was not used for (a refused admission, a
decode row that drafted less than its window) goes back to the chunk before the step is issued.
Admission shares the same way, so a cold prompt admitted with others queued behind it does not
take the whole step either; an embedding input still runs whole or not at all.
A prompt with nothing beside it, and rows already planned ahead of the prefill, are planned
exactly as before, so a lone request's steps -- and every greedy output -- are unchanged. `off`
restores the old loop including its break. `N` holds a chunk that shares the step to N tokens,
rows ahead included (the operator trading prefill speed for every other row's latency); startup
warns when N is under the stager's step.
The engine hands the scheduler the stager's smallest pass after init (PrefillStager::min_rows,
the largest over the ranks). radiance:engine_prefill_chunks_capped_total counts the chunks held
back. sched_test covers admission during a long prefill, a decode row behind one, off reproducing
the old plan, a lone prefill unchanged, an explicit N with rows ahead and behind, the share
handed back when nobody takes it, and the cap's arithmetic at a 2048-token step with the stager
at 1025, with and without a share in the reserve.
* r4d_rad_relayout_gdense composes in f64 (angles widened, cos/sin and products in double) and rounds to
f16: the stored matrix is a derivation of the planes, the same bytes whichever libm computed it, as
abi/rad_abi.h asks of a relayout.
* givens_dense_quant (libr4d and libref) refuses an `out` that does not name q's dtype instead of reading
the quantiser off q alone.
* relayout_parity_test pins the dense stored form by hash, checks each matrix is orthogonal to f16
accuracy and that a broken pairing is refused.
* r4d_givens_dense: static_assert that a thread stages one channel scale of the group; the selftest's
givens_numeric takes one mode (rotate / dense fp8 / dense i8) instead of three flags; cGivensDense
sits after the Hadamard constraint with its own comment.
* docs/OPS.md: the dtypes w5a16, w4a16_asym, w5a8i8, w4a8i8_asym, givens_quant_act_i8g, and which rows read pb1/pb2.
* r4d_gemm_w5a16_nt_m64: drop the unused two's-complement dequant copied from w4; the errors name this kernel.
* r4d_layout: r4d_rad_unrelayout_w5 (the inverse, wired to both w5 rows; the int4 rows take w4's); a zero point
that is not a 4-/5-bit code is refused at load (the int8 prefill kernel reads five bits of it, the f16 one all).
* rad_fp8.h: one linear_is_givens predicate (table dtypes checked for both formats, the zero plane's u8 too);
declare_rotation declares the tables and rot_stages only, decl_rot_op the op in front of each GEMM.
* tests: relayout_parity pins the w5 stored form and its refusal; checkpoint_test imports z-lab's int4 as a fused
gate|up (two rotated parts); the selftest's asymmetric planes and part bounds come from one helper each.
* checkpoint: the ParoQuant refusal names both readable forms.
* givens_rotate and givens_quant_act_i8g take the same checked `pairs` relayout as givens_quant_act_fp8.
* gemm_w4a8i8/w5a8i8_tiled: one re-tile slab for every part, as gemm_mxfp4a8_tiled (they share its
scratch hook, which is one slab now).
* LinearFP8::decl_gemm_q: the one gemm_nt_q declaration, pb1/pb2 only with parts, for the MXFP4, the
skinny 5-/4-bit and the int8 prefill GEMMs.
* libr4d: givens_quant_act_fp8 gets layout/relayout/unrelayout hooks for `pairs` -- stored as is,
refused (RAD_E_FORMAT) when a stage is not a pairing of its own group of 128, which the kernel would
index out of bounds. relayout_parity_test covers it.
* gemm_mxfp4a8_tiled: the parts run in order on one stream, so they share one re-tiled activation;
the scratch is one slab again.
* mx_part_bounds: the pb1/pb2 clamping in one place (mx_parts, the decode scratch hook).
* LinearFP8: one gemm_nt_q declaration and one issue path for the plain and the rotated MXFP4 weight;
pb1/pb2 still only on a weight with parts, so a one-part op keeps its tune-cache geometry.
A rotated weight reads the producer's bf16 plane, rotates and quantises it into its own planes
(parts side by side) and runs the ordinary mxfp4a8 GEMM. Adds data/recipes/q38-27b-paro-mxfp4-df2.recipe
and the GUIDE entry.
The rotate+scale+quantise kernel does a (part, group) per wave with the stages' tables prefetched.
The three MXFP4 GEMM rows learn row pitches (lda, ldws, ldc) and launch once per weight part; the
layout hook accepts the codes/exponent planes of a givens-encoded weight. r4d_selftest checks the
kernel against an f64 rotation and every GEMM row's parts against the planes' meaning.
quant_method paroquant_mxfp4 is Quark's MXFP4 planes in a rotated basis plus z-lab's learned
Givens rotations. rad-convert reads the codes and exponents byte for byte and builds the
encoding's givens tables (t.pairs/t.angle/t.scale) from pairs/theta/channel_scales; a fused
gate|up or qkv|z gets one set of tables a checkpoint tensor (new t.part table). The core decoder
undoes the per-part rotation. fp8 tensors with one f32 scale a row are read exactly.
- #47: llama-server's request fields, routes and sampler order, and /props (with baKon's model
entry: max_model_len, root and capabilities on /v1/models, and /v1/models/:id)
- new APIs: Anthropic's Messages API (/v1/messages), OpenAI's Responses API (/v1/responses),
llama-server's /completion and /infill, logprobs (OpenAI's logprobs and top_logprobs, up to
20; llama-server's n_probs), OpenAI's legacy `functions`, and X-Api-Key beside the bearer key
- #4: --model takes a Hugging Face repo id (owner/name), fetched before startup into
~/.cache/radiance/hf or --download-dir and checked for changes at every start (redxherring)
- #46: --tp 3 --tp-wire wht6 serves -- a three-rank two-shot all-reduce with uneven shards and
the tiered-int8 wire over it (baKon); scripts/cardclock.py names what holds each card's clock
under load (baKon)
- CPU-only serving works again; --kernels names the kernel libraries to load; a model the
loaded libraries cannot fully serve refuses at startup instead of failing its first request;
--vram-kv-mib and --vram-weights-mib are gone (the split is automatic)
- --embedding-placement ram is the default, and `auto` is gone
- #40: Swift 1.5 recipes; rad-convert reads which shard holds a tensor from the index
- #53: the pinned host pool gets huge pages where shmem THP is off; #57: a crash on video with
an odd frame width is fixed
A non-path owner/name is downloaded before bring-up and the model path
rewritten to the cached dir, so a new user points --model at a repo link
instead of a pre-fetched checkpoint. hfget.sh now keys its re-run skip on
lfs.oid (sha256) for LFS files and size for the rest, recorded in a
.hfget-manifest, so a same-size weight update is caught and re-fetched
while a warm cache stays a no-rehash no-op.
--tp 3 --tp-wire wht6 had no kernel: the lossy rows were world_size 2 (rotated 6-bit) and 4
(tiered int8 over the two-shot). The tiered-int8 two-shot is already written over the world size,
and what kept it at four was the even split it shards by -- numel % (32 x ws) -- which a 2048-wide
row (64 groups) meets at three ranks one step in three.
The kernel now splits ng = numel/32 groups as evenly as they divide, the first ng % ws shards one
group longer, and lays every slot out for the longest shard, so writer and reader agree on one
number. At four ranks the entry still requires numel % 128 and the split is the even one it was.
ar_twoshot_3rank_ti8 is the only lossy row at three, so as at four it resolves at every size; a
message under min_bytes, or not whole groups, goes to the exact one-shot.
r4d_selftest holds it to what a lossy wire can be held to: every rank the same bytes, the declined
messages the exact fold bit for bit, and the rest within the int8 wire's error of the fp32 sum
(relative RMS < 1%), over groups % 3 of 0, 1 and 2 with outliers, to the 20971520 ceiling. The
--tp-wire help, the startup LOSSY warning, README, GUIDE and TP3.md say three ranks.
At three ranks the exact all-reduce was the one-shot at every size: the two-shot required the
message to shard evenly, and a 2048-wide bf16 row is 256 16-byte words, a multiple of 3 only one
step in three. Every prefill chunk therefore sent twice its message per rank where the two-shot
sends 4/3.
The two-shot kernel now splits n16 words into shards of n16/ws, the first n16 % ws one word longer,
with region B at the longest shard. At 4 and 8 ranks every message the entries accept divides, so
nothing there changes. ar_twoshot_3rank_exact takes the band above R4D_AR_WIDE_ONESHOT_MAX_ELEMS the
way the 4- and 8-rank rows do. Its fold is the one-shot's -- fp32, ascending rank order -- so the
band edge between the two rows changes no bits.
r4d_selftest runs both three-rank rows through a per-element oracle (bf16 and fp32, words % 3 of 0,
1 and 2, 16 words to the 20971520-element ceiling, in and out of place, back to back on one
instance).
A tensor-parallel step ends when its slowest rank does, and under a sustained load the firmware picks
each card's clock: the power limit, a temperature or current limit, or the top of the card's
voltage/frequency curve. The same image then reads several percent apart from one boot to the next,
depending on which card heats first and how hard its limit bites.
cardclock.py reads every AMD card's gpu_metrics table ten times a second (read-only, no root) and
counts a throttler bit only when the clock is lower while it is set -- some firmware keeps a bit on at
idle -- then names the card the step waits for, what holds it, and the setting that addresses it. The
engine's own step counters sit beside it per window, so a slow window is attributed (slower steps,
fewer tokens per step, host time between steps) before anyone tunes a card. It drives its own greedy
load, or with --watch only samples a server that real traffic is driving; --compare puts two saved
runs side by side.
OpenAI's model object has no field for what a model can be asked for, so a client learned it
by sending a request and reading the refusal. The entry it already fetches now carries the same
capabilities object /server_info does (tools, reasoning, grammar, media, logprobs, the reasoning
efforts the template takes), built by one Server::capabilities() so the two cannot disagree.
A served name is chosen for clients and says nothing about which container is behind it.
Report what --model named as `root`, the field vLLM fills with the path it loaded; left out
when the server has none.
OpenAI's retrieve returns the entry itself, and its SDK reads `id` off the top level, where
the list of one this route answered before has none. /v1/models still answers the list.
The model list carried only the id, so a client had no way to read the context the server
was started with and guessed it from the model's name. Carry the field vLLM's model card does:
the server's max_ctx (--max-model-len, else the container's trained length), on both
/v1/models and /v1/models/:id, and leave it out when the length is unknown.
Front-ends built against llama-server size their context from /props'
default_generation_settings.n_ctx, decide whether to offer images from modalities, and read the
defaults a request inherits; on Radiance that route was a 404. Answer it with what this server
can fill honestly, under llama-server's names: n_ctx (the context one request may use, left out
when unknown), total_slots, modalities, the sampler defaults and build_info. No chat template
text or GGUF metadata -- the server has neither.
- EmbeddingGemma 2 (google/embeddinggemma-2): text, image, video and audio embeddings on the
card (libr4d) and on the CPU (libavx); prompt_name, Matryoshka dimensions, image budgets,
mixed content parts and the messages form on /v1/embeddings
- #43: on serves that lend the activation arena to the experts (Qwen3.8-Flash-Next with
expert_tiered), every image after the first read its rows from the wrong place -- garbage
replies, or an earlier request's image. Fixed
- the Qwen vision towers' attention resolves on the card again (broken on main after 1.2.3,
never released)
- #42: a warning at startup when amdgpu cwsr_enable is 0, and a stalled queue is reported as
slow or stuck; the guide covers the GPU-hang-and-reset chain
- DFlash2: the drafter's linears can be MXFP4 (slydlake), and its draft candidates are
rescored against the target's own lm_head, so a 2-bit draft head ranks them exactly
- the Qwen3.8-27B recipes (Quark MXFP4 and FP8) use both: MXFP4 drafter linears and a
clip-searched 2-bit head. One stream at TP2: 182 -> 204 tok/s (MXFP4), 124 -> 139 tok/s
(uncensored FP8); 0.75 GiB less weight. Containers made with the older recipes still load.
- Static YaRN for the Qwen rotary paths (#37): a container whose config names YaRN gets it in
attention, the QSA index keys and a DFlash2 drafter; one reader for every rotary type, and a
LLaMA container whose type is not served (llama3, longrope, dynamic) is refused by name.
- --rope-scaling yarn:FACTOR[:ORIG] (#38) writes YaRN over a container's own rotary keys at load,
no reconvert; the persisted prefix cache's fingerprint carries the resolved rotary.
- An uneven world's cheaper rank (#36) pages the common token count and gives the rest of its
VRAM to its experts; a plan and pool that disagree refuse to start.
- MoE prefill (#35): wide gather, parallel scan and run-map prefix, 256-column down tile, early
weight loads -- by rule, bit-identical.
- MoE decode (#34): the sorted operand's own down kernel, its column tiles by routed rows.
- --draft-window fixed|adaptive (#24): a per-sequence draft window priced by measured step time,
one head depth per step over the batch; fixed stays the default. New metric
radiance:draft_position_accepted_total and Grafana panels.
- Out-of-tree plugin builds compile to the tree's device code from any build directory.
yarn:FACTOR[:ORIG] (or none) is written at load into the rotary object yarn_from takes first --
for a Qwen3.8 container text_config.rope_parameters, which already says default, so YaRN written
beside it would never be read -- and resolved and checked exactly as a converted container's is.
An existing container serves past its trained context with no reconvert; a DFlash2 drafter gets
the same factor over its own trained length; a checkpoint's own YaRN has its factor replaced and
its stale attention_factor/mscale dropped; linear or other explicit types are refused. Startup
names the rotary's reach and warns when --max-model-len is past it, and a persisted prefix cache
written under another --rope-scaling is not reused. core/format/rope_override.h is held to
yarn_from in tests/yarn_test.cpp.
At 16 sequences the (tile, run) grid gives down 25 600 blocks. Many find no
run, the others stage 4-8 KB of weight behind a search and a barrier pair,
and a run that crosses a 16-row tile is read twice. R4D_MOE_DOWN2=1 sends
down's decode-form launch to moe_down_dec_kernel: one block per 16-row tile
of a run, found among all runs in one round trip, and G 64-column tiles a
block whose passes form one pipeline. G follows the routed rows (1 below
200, 2 below 480, 4 above) or R4D_MOE_DOWN2_G. Bit-identical, off by
default. 16 concurrent: 36.4 -> 33.9 ms a step.
Two panels for RADIANCE_DRAFT_ADAPT: the mean window of the running
sequences (a gap while none runs) and the share of verifies by the drafts
they carried.
Conditional acceptance by position is now accepted(j) / reached(j). The
old reached(j+1) / reached(j) needs every verify to carry the same depth;
on an adaptive instance it showed 0.24 at position 2 where the engine's
own ratio was 0.72, and the last-position series is no longer defined.
radiance:draft_position_accepted_total{position}, next to the reach. At a
fixed depth the next position's reach is this position's acceptances, so
reached(j+1) / reached(j) gives the conditional acceptance over a window.
Under the adaptive window a verify can end at j with j taken, and that
ratio drops wherever windows end; accepted(j) / reached(j) does not.
RADIANCE_DRAFT_ADAPT prices a draft as one more round of the head. A block
drafter proposes its whole block in one pass, so it is not that trade; with
a block drafter the engine now turns the policy off before the first step
and says so. New sched_test case.
The cost table prices a step at one sequence. Under load every row a step
adds is expert bandwidth its neighbours wait on, and the adaptive window
lost 4 % at 8 concurrent requests. With RADIANCE_DRAFT_ADAPT_BUSY=N and
more than N sequences running, every window is capped at
RADIANCE_DRAFT_ADAPT_BUSY_DEPTH (default 3); the estimates keep learning.
The count is taken once a cycle and held to its end, so the plan, the
rounds, expect_draft and set_draft see one cap. Unset, nothing changes.
One depth for every request is too shallow for code and JSON and too deep
for prose. With RADIANCE_DRAFT_ADAPT=1, --num-speculative-tokens becomes
the ceiling and each sequence drafts into the window d that maximises
E(d)/T(d): the tokens a step is expected to emit from the sequence's own
smoothed acceptance at each position, over the step's cost
(RADIANCE_DRAFT_COST, depth:ms pairs). The serial head runs as many rounds
as the deepest window in the step. A window moves only past a hysteresis
and a hold, since a new window is a new pass shape. Acceptance is
unchanged. /metrics gains radiance:draft_depth_adaptive and
radiance:draft_verify_depth_total{depth} while it is on. Unset, nothing
changes. Greedy at up to 6 against fixed 3: code +7.7 %, JSON +16.3 %.
moe_q4_gemm holds the run-aligned form under parts 16 and 64 to the form
without them as well, so the block-fp8 instance of the early weight issue
and the narrow classes' pad tiles are compared byte for byte too. Past 512
experts the launcher builds no run map and there is no aligned launch, so
the pass is skipped there rather than failed.
In the run-aligned form the map entry names the block's expert, yet the
weight loads wait behind the token load, a barrier, the live count and the
table entry. Part 64 issues the rows and the live count first, then the
table entries and the first pass's weight through the uniform global base,
all unconditional, so the weight stays in flight while the tokens arrive.
The same bytes go to the same registers and LDS slots: bit-identical.
In a prefill chunk moe_gather loads two bytes a lane and waits on every
slot, moe_scatter scans on one thread, and so does the run map's prefix.
R4D_MOE_PF2=1, or a mask of the parts: 2 a wave a token and 16 bytes a
lane with every slot's row in flight, 4 its column groups last first, 8 a
parallel scan with the tail folded into the placement, 16 the map prefix
in parallel, 32 a 256-column run-aligned down tile (w4). Each part keeps
its sums in the same order or is integers: bit-identical. Unset, every
launch is as before.
The resolver derives one split, the dearest rank's, for every card, and one
block table serves every rank. An attention-zero rank keeps no attention cache:
at TP3 on Flash-Next it pages the common 1.45M tokens in ~1.8 GiB of its
10.6 GiB KV pool, the rest is an address reservation nothing ever commits or
lends, and 1091 of its experts can never reach the card even with the cache
idle.
Such a rank now gets a KV pool that pages exactly the common token count (the
new KVManager::pool_mib_for_tokens, the inverse of paged_tokens, plus a 64 MiB
margin) and the difference in its weights pool, no further than every weight
resident. The per-rank split reaches BOTH readers of the resolved sizes --
Pools::configure and the planner -- so the grown pool is planned into. The
token count, the carve, the loan and the dearest ranks' pools are unchanged;
configure_kv names it if a re-sized pool ever binds.
Only a derived split under expert_tiered is re-split: a stated pool is the
operator's, and under auto a fully resident rank would choose all_vram while
its peers spill. Where every rank's cache costs the same -- every world the
heads divide -- no rank qualifies and every rank takes cfg_ as before.
- A checkpoint restore that found its snapshot slot given back stopped the engine (#33): a
snapshot handed to an admission is now kept until its step has run, a lost one re-prefills
that request instead, and a failed restore names the check and the rank.
- The headroom warning had no fixed point (#32): it now checks the room left for a kernel's first
launch and names the --gpu-headroom-mib value that clears it.
- reasoning_effort (#31): the levels the chat template takes are probed at startup and published
in /server_info; a level outside them is a 400 on `reasoning_effort` with `supported`;
--reasoning-effort-map rewrites a client's level.
- rad-convert reads published quantised releases (#29): AMD Quark MXFP4 byte for byte, and
AutoRound (auto_round:auto_gptq) / GPTQ int4 and int8, with Flash-Next checkpoints that ship
their experts one by one.
- tool_choice "required" and a named function are served by a call grammar for the whole reply.
- MXFP4 weights: block-fp8 Qwen3.5/3.6/3.8 dense models serve OCP-MXFP4 linears (e2m1, an E8M0
exponent per 32) at 4-bit weights against E4M3 activations. New libr4d rows: the decode GEMM
(M <= 128, split-K with a fused last-arriver reduction) and the prefill GEMM on a fragment-tiled
activation. Qwen3.8-27B MXFP4 (AMD Quark AWQ) is in the model table.
- Cards without peer-to-peer access serve: every collective has a host-memory twin; --p2p
auto|on|off.
- Stop strings apply to the answer, not to the reasoning block a reply starts in.
- A prefix hit ends one drafter window before the prompt's end, so a windowed block drafter
(DFlash2) drafts from the first token of a follow-up turn.
- Pinned host memory works again on kernel drivers without the SVM API (e.g. a KVM guest with the cards passed through): the host pool is one allocation there instead of 1 GiB pieces that landed apart on the cards (#28). Regression since 1.0.9.
- A host-pool refusal no longer advises shrinking the pool when it fits under the pin cap and the available RAM.
- The VRAM split has no ratio: --expert-vs-cache-ratio is gone (now an unknown option). The
experts keep what the pinned host pool cannot hold, the KV cache takes the rest and lends idle
blocks to the experts. Flash-Next at tp2: 7.9 GiB of KV a card, up from 4.7. Startup, /stats,
/metrics and the dashboard report the most the cache can hold.
- Linear-state snapshots live in pinned host memory, not VRAM (--checkpoint-slots sizes the
store). Prefix-cache misses on agent sessions fixed; a published conversation is no longer
trimmed away.
- Any world size from the shipped container (baKon): --tp 3 on Flash-Next with no padded
checkpoint -- the attention world, uneven delta-net heads, the fill op.
- Kernels (keptn42): moe_gemm_q decode loads and one-trip run search, hc_read's prefill form
(+3.7% prefill at 18K), hc_up row groups up to eight, the fused router launch. Each is the rule
where it was measured faster; no environment switches.
- Tool calls: a typed argument is always JSON (Python True/None no longer leak into arguments --
Codeberg #21); nine further reply-parser fixes; the reply path inside a call is ~12x cheaper on
the host.
- The kernel changes: prefill +2-3% and decode -2% a step on 2x R9700 at tp2, identical text.
This reverts commit fa01bd2. Its premise -- the attention-zero rank holds
a larger share of the experts, so the bytes its cache does not need are
best spent in its weights pool -- went with the experts' remainder-first
placement (665d181): the experts cut as every world always has and no
rank has a larger share. What the re-split did keep was a KV pool on that
rank a third the size of its peers', and BetterBench after three 250k
prefills (a cache three quarters full) decoded 13-23% slower at every
concurrency than the same tree without it, while a cold server measured
faster. The pool goes back to the common split; what the rank does not
carve for attention it lends, as every rank's idle cache does.
An expert block is a whole GEMM of every routed token; a rank taking the
extra block of every class became the step's slowest rank. Measured on
Flash-Next at three ranks, interleaved image A/B, two reps each: experts
50/25/25 cost 25% a step single-stream; one class's extra block
(37/25/37) swung 16.5-19.1 ms between boots; the delta-net head alone on
the attention-zero rank gave 15.6 ms both reps against 16.7-17.2, c1
+10-16%, c4 +4%, c8 +2-3%, acceptance unchanged at 2.54 tokens a step.
The experts cut as every world always has; TP2 and TP4 are untouched.
A freshly assigned recurrent slot was zeroed on every rank with rank 0's
layer_bytes_per_state. The ranks' shares of a group need not be equal --
a world the heads do not divide gives them different counts -- and a rank
holding more heads than rank 0 had the tail of its state left as the last
sequence left it, read by the recurrence from the first token. Every rank
now clears by its own plan. The host/disk tier made the same assumption
twice: a slot was rank 0's entry times the world and a rank's window sat
at rank times that; a slot is now the sum of the ranks' entries, each
rank's window where the ranks before it end, and the staging ring is
sized for the largest. Equal shares give the bytes they always gave.
Found by moving the extra delta-net head of Flash-Next at three ranks
onto the attention-zero rank: rank 0 held five heads, rank 2 six, and
every answer was noise.
Whatever does not divide over the world -- the extra block of an expert's
width, the extra delta-net head -- went to whichever rank the rotation picked,
and the attention-zero rank, which pays nothing for attention and keeps no
attention cache, came away the lightest. rad_arch.h remainder_place puts the
attention-zero ranks first in the order the remainders are handed out, then
the attention ranks in today's rotation; with no such rank the place is the
rotation itself and every cut is byte for byte what it was. Flash-Next at
three ranks: experts 30/30/40 and delta-net heads 5/5/6 instead of 35/35/30
and 6/5/5.
The resolver derives one split for every rank (the dearest rank's). A rank
whose KV groups cost less per token -- an attention-zero rank keeps no attention
cache -- would spend the common pool on tokens configure_kv then caps away, one
block table serving every rank. Its KV pool is now sized for the same token
count as the dearest rank's, a hair over, and the difference goes to its
weights pool, where its larger share of the experts lives. Only a derived split
is re-split; a world whose ranks cost the same is untouched.
rad_kv_group_zero(b, group): the group is declared as on every other rank --
the scheduler indexes groups by position and one block table serves every
rank -- and this rank carves nothing for it: its block count is the shared
table's, its costs are zero, its pool base is null, and issue refuses any op
on this rank that names it. For a rank the geometry gives no attention heads,
whose attention is a fill of zeros and never stores or reads a key. qwen4exp
declares its attention group so on such a rank. The arch test's contract
becomes the real one: same KV groups by position; ops are each rank's own.
Its share of every projection is zero, so q, k, v, the attention and the output
projection are zero and the reduce gains exactly nothing from it. Declaring the
projections and running them on zero weights spent a real rank's dispatches and
bytes every layer, and a slot for every zero. The block on such a rank is now
one fill of its output wire, then the all-reduce and the residual it always had;
the norm stays because a pre-norm block's fold and ar_in live in it. The branch
is dead on every rank with heads, so a world the heads divide declares as before.
y = value over an [M, n] extent at a row pitch, bf16, default 0. The op a rank
issues where it has nothing to compute and a reader downstream -- an all-reduce,
a residual -- still expects a defined buffer: a wire shared across layers cannot
be zeroed once a step, and a memset knows neither the pitch nor the dtype.
Smoke-tested for the exact zero, the pitch, and the RNE of a value.
From a container the relayout workers are fed by the sweep over the file, and a
zero share (rad_weight_shard_zero: an attention-zero rank's q|gate, k, v and o)
has no bytes in the file, so nothing ever arrived for it, its worker never ran,
and its slot held whatever the card had there. On a card whose freed VRAM the
driver wipes that is zeros and the rank serves correctly by luck; on a card
fresh from a reset ("VRAM is lost") it is garbage and every token is garbage.
The checkpoint branch hands every staged weight to the workers itself, which is
why the hole was never seen there.
Zero shares are now handed to the workers before the sweep, and the pool's
finish() refuses when any staged weight was never delivered, so a slot nothing
wrote cannot serve again.
Reproducer on any card: RADIANCE_POISON_ALLOC=255 with an odd world over a
container (--tp 3 on a two-KV-head model).
A buffer read before anything wrote it is zeros on a card whose freed VRAM the
driver wipes, and garbage on one that has just been through a reset ("VRAM is
lost"). RADIANCE_POISON_ALLOC=B fills every fresh device allocation with byte B
so such a read shows on any card; RADIANCE_POISON_RANGE=lo:hi narrows the fill
to allocation ordinals for a bisect. Debug knobs beside RADIANCE_TRACE_ALLOC;
off, nothing changes.
One block table serves every rank, and Engine::serve refuses ranks whose
paged groups hold different block counts. Under the even split that was
a check that never fired: the ranks' pools had the same geometry and the
same bytes. Under the attention world they do not. A rank with 6 of 16
delta-net heads holds more recurrent state than one with 5 and has less
pool left for pages; the attention-zero rank has no attention weights
and has more. Three ranks over Flash-Next carved 136256, 142352 and
more, and the serve was refused.
KVManager::paged_split is the carve's paged arithmetic with nothing
carved -- the token count the paged groups exhaust at together for a
pool of so many bytes, a windowed group capped at its window -- and
carve_into spends what it says. paged_tokens asks it; cap_paged_tokens
sets a ceiling it keeps under. Engine::configure_kv plans every rank
first, asks each what it could page, and caps every rank at the least
before any carves; a rank that could have paged more says so at info.
At an even split the cap is what every rank would have carved.
mem_test: kv_ranks_with_unequal_pools_carve_the_least_ranks_blocks_under_a_cap.
arch_test: flashnext_tp3_zeroes_the_third_ranks_attention_and_splits_gdn_heads_unevenly
holds the three-rank declaration of the Flash-Next fixture: the three
programs declare the same ops and KV groups in the same order; every
rank the two-rank attention geometry with the span of its heads, rank 2
zero; the delta net 6/5/5 K and 18/15/15 V heads as per-part spans of
[q|k|v|z] and the conv channels, a span of A_log, the output columns,
and the state group at each rank's own V count. The fake builder
records the two new exports as it records the span. The TP4 case's
"world 3 is refused" check becomes "world 3 declares".
docs/TP3.md is rewritten: what replaced the padded checkpoint, the two
rules, what they are built from, the serve line and the log lines. The
pad tools stay in the tree for an engine without an attention world.
A world the KV head count neither divides nor is a multiple of -- three
ranks over Flash-Next's two -- was refused by geom_from, and 1.0.12
served it by padding the checkpoint offline (docs/TP3.md): zero heads
appended so that 36 / 3 / 18 / 54 divide, a second 115 GiB container
per model, 1/3 of the attention and 2 of 18 delta-net heads computing
zeros. This serves the shipped container at any world size instead.
The attention world. geom_from serves attention on the largest multiple
of the KV head count under the world (split, or replicated as 1.0.7
does when that is still above the count) and the ranks past it are
attention-zero: they declare the same heads and the same program as
their peers -- the scheduler sees one program -- and read nothing for
attn_qg, attn_k, attn_v and attn_output (rad_weight_shard_zero). Their
attention computes zeros from zeros and their output projection adds
exactly nothing to the reduce. Three ranks over two heads: attention on
ranks 0 and 1 exactly as the two-rank serve declares it, 12 heads, one
KV head, gqa 12, the same kernels; rank 2 zero. Five over two:
attention on four, rank 4 zero. Under a smaller attention world the even
shard over `world` is the wrong cut for every projection, so
rad_block_attn_gated_fp8.h declares spans -- q|gate rows and output
columns [attn_rank * n_head, +n_head) heads, k/v at kv_off -- the same
call the KV replication already used. When the attention world is the
world, every TP2 and TP4 deployment, nothing here is declared and the
block declares as it always did.
Uneven delta-net heads. The delta net has no KV-head constraint: its
kernels are bound on head widths and take any head count. 16 K heads
over three ranks are 6, 5 and 5, each rank's V heads the same multiple
(48 / 16 = 3: 18, 15, 15), every rank real heads. qwen4exp computes the
split and rad_block_gdn_fp8.h declares it as spans of the container's
rows: per-part for [q|k|v|z] and the conv channels (the parts are not
equal), one span for [a|b], A_log, dt_bias and the output columns.
LinearFP8 owns the scale plane's units (1/128 of the weight's rows for
block-fp8, the weight's own for int8 and bf16), so a block declares in
the weight's rows and the scale plane follows. The even split, when the
counts divide, is untouched.
The log says what the geometry did:
world_size = 3 over n_head_kv = 2: attention on 2 rank(s), rank(s)
2..2 carry zero attention weights and the delta net and experts of a
full rank
qwen4exp: rank 1 takes delta-net K heads [6, 11) of 16 and V heads
[18, 33) of 48
Two additive builder exports, RAD_ABI_VERSION untouched.
rad_weight_shard_span_parts: a row-sharded weight whose stacked parts
are not the same width -- the delta net's [q|k|v|z], 2048, 2048, 6144,
6144 rows on Flash-Next -- cannot take rad_weight_shard_span's one
[lo, hi), which is applied to every part and assumes them equal. This
takes a span per part together with each part's whole extent in the
container; share.cpp cuts every part by its own rows and refuses totals
that do not sum to the entry. It is how a rank declares an UNEVEN share
of the heads -- 6 of 16 K heads where three ranks take 6, 5 and 5 --
with nothing padded.
rad_weight_shard_zero: this rank's share of a row- or column-sharded
weight is zeros. weight_share returns the declaration's extents with no
rectangles; the loader stages the weight with a worker that writes
zeros (the route a checkpoint weight already takes from a container)
and reads nothing. It is for a rank the geometry gives no real heads
(next commit), which then declares the same program as its peers.
share_test holds the per-part cut and the zero share.
hc_up_rg rounds the row group down to 8, 4, 2 or 1. The group exists so a
verify reads W_up once, but at MTP 4 or 5 (five or six rows) it splits into
4 + 1 or 4 + 2 and W_up is read twice. R4D_HC_RG_EXACT=1 makes a row count
up to eight one group of exactly that many rows; 3, 5, 6 and 7 are
instantiated as well. Only the loop nest changes, so the output is
bit-identical. Unset, the power-of-two rule as before. Flash-Next at tp 4,
MTP 4: 14.18 -> 13.32 ms a decode step.
A decode-form block finds its run by a chunked search: four to six
dependent L2 round trips and two barriers a chunk, paid also by blocks that
find nothing. R4D_MOE_RUNSCAN=1 loads the block's sorted rows and all
offsets in one batch, numbers the runs in expert order with a DPP scan, and
hands the run's bounds over LDS. Up to 512 experts; above that the chunked
search runs. Bit-identical, off by default. Flash-Next at tp 4 with UW and
RS: 36.9 -> 36.1 ms a step at 16 concurrent.
In the decode form every weight load is a flat_load through a table pointer
in VGPRs, and the waitcnt pass puts s_wait_loadcnt 0 in front of each, so a
pass's scale, activation and weight loads go out one after the other.
R4D_MOE_UWLOAD=1 makes the table entries uniform and reads them through
address_space(1), issues the scale loads unconditionally, and uses LDS
barriers in the K loop with one release fence for the prefetch: one wait a
pass. R4D_MOE_GU_FK256=1 (or =N, up to N routed rows) stages two 128-wide
K blocks a gate_up pass. Both bit-identical and off by default; the default
kernels are instruction-identical to before. r4d_selftest compares every
variant byte for byte.
Each wave keeps its 16 rows of d as twenty WMMA fragments (K = 320) and the
workgroup walks a run of channel blocks, with mix_up in fragment order so a
block's B is a 40 KB copy into LDS. R4D_HC_READ_PF2 5, 6 and 7 pair it with
the 64-row, the 128-row or the wide down product. Bit-identical. On gfx1201
it is slower than the 256-row tile of value 1.
The wide prefill form reads h and builds N once per 128-column tile, three
times a call, decodes both E4M3 mixing matrices again in every row tile,
and launches the norm scales on their own. PF2 decodes the matrices once in
a prologue that also computes the norm scales in the same order, runs the
down product one workgroup per 64 rows over all columns with B straight
from WMMA fragment order, and the up product and mix at 256 rows.
R4D_HC_READ_PF2 picks 1 both halves, 2 or 3 one of them, 4 a 128-row down
product. Bit-identical to the wide and the decode tiles' forms; unset, as
before. At M = 2048: 711 -> 611 us a call.
At decode every MoE layer launches the router GEMM, router_topk_scatter
after it, and the shared expert's gate. With R4D_ROUTER_FUSED=1 the last
workgroup of the router's skinny bf16 GEMM, named by a self-resetting
arrival counter, runs router_topk_scatter's body, and one more workgroup
computes the shared gate; =2 keeps the gate separate. Each logit is the
same split-K chain at the split the unfused GEMM's law picks, so the
outputs are byte-identical. Decode band only (M <= 64); unset, nothing new
is declared. Single stream: -0.8 % a step.
- Faster prefill on models with an MTP head (Qwen3.8-Flash-Next, Qwen3.6-35B-A3B). Every prefill
chunk but a prompt's last runs the head only to leave its K and V behind, and the head no
longer runs its expert layer and lm_head for nothing on those chunks. Flash-Next on two R9700:
+1.4% at 8K tokens, +3.2% at 26K, +5.9% at 78K; text and decode unchanged. From Code000's
opt33.
- A request log at the info level: one line when a request is admitted (endpoint, peer, message
and tool counts, prompt tokens, max_tokens), one when it ends (finish reason, cached prompt,
generated and reasoning tokens, time to first token, decode rate), and every refusal with its
status and peer -- a wrong API key included. No prompt text at info. (baKon)
- deploy/grafana: a dashboard for /metrics on Prometheus or VictoriaMetrics. (keptn42)
- Three-rank tensor parallelism for Qwen3.8-Flash-Next: the all-reduce and all-gather at three
ranks, the vocabulary split by 128-row blocks where the world does not divide it, and
tools/pad_tp.py to pad the checkpoint's head counts to a world of three -- docs/TP3.md.
(baKon)
geom_from divides n_ff by the world before the plugin's own split runs,
and 640 does not divide by 3. The plugin cuts the routed experts' width by
whole fp8 blocks and parity at any world up to the block count (1.0.8),
so the refusal is answered before it is asked. geom_from gains
arch_splits_ff (default off): with it, a width the world does not divide
is left whole in g.n_ff for the plugin to slice; a width that divides is
unaffected, and every other plugin keeps the refusal because for them
g.n_ff is the per-rank width. qwen4exp opts in.
Radiance refuses a head count the world does not divide, by name, and
three is such a world for Qwen3.8-Flash-Next (24 q / 2 kv / GDN 16, 48).
Replication answers four ranks, not three. The answer at three is the
one tcclaviger's vLLM applies at load time: pad to 36 / 3 / 18 / 54 with
zero weights placed where a zero contributes nothing, so the padded model
computes what the original does. Radiance has no load-time pad, so this is
an offline tool and a document.
- tools/pad_tp.py: numpy-only, streams one tensor at a time, handles the
Flash-Next fused q+gate head blocks and the GDN in_proj row orders,
rewrites config.json. --sparse reflinks the original shards and writes
only the padded tensors into shards that sort first, which the
checkpoint reader's first-wins emplace then shadows: 6.6 GB of new
bytes for a 336 GiB checkpoint.
- tools/pad_verify.py: every tensor read back -- untouched ones
byte-identical, padded ones the source in place and zeros elsewhere.
- docs/TP3.md: what is padded and why each pad is exact, the tool, what
the engine gained at three ranks, the serve line, measurements on three
R9700s against the shipped two-rank container.
- README: the three-rank row and the document.
token_embd / output are RAD_SHARD_ROW; at three ranks 248320 rows do not
divide, and share.cpp refuses a row shard without a declared span.
qwen4exp now declares [vocab_off, vocab_off + n_vocab) for both. The split
rule (rad_arch.h shard_extent/shard_begin, restated in core/engine.cpp)
keeps the even share whenever the world divides the vocabulary -- two and
four ranks are untouched -- and only otherwise rounds the per-rank count
up to a 128-row block, because a block-scaled fp8 head refuses a cut
inside a tile: at three the ranks take 82816, 82816, 82688.
Instantiate the wide one-shot all-reduce at WS=3 and add an all-gather on the
wide transport (ar_gather_3rank), with dispatch rows for world_size 3, so a
three-card box resolves 'all_reduce' and the vocab-parallel sampler's
'all_gather'. The two-shot is not instantiated at 3: it shards the message
world ways and the residual width does not divide. Selftest: 3-rank sum,
block-count sweep and both gather placements (skipped on fewer than 3 cards).
Local lab build on top of 1.0.3 (f487864); not submitted upstream.
(cherry picked from commit a76f2ab66500b9a7711b8f52abbf48eb88758359)
Throughput, prompt tokens by source, speculative decoding by draft
position, scheduler steps, latency, prefix cache and HTTP, from both
metric families. Plain PromQL, so the same JSON runs on Prometheus and on
VictoriaMetrics. Window ratios are counter ratios with the definitions of
the since-start gauges; conditional acceptance at position j in a window
is reached(j+1) / reached(j).
GUIDE: draft_position_acceptance_ratio is cumulative since start
(draft.h), and the dashboard is named under §6.3.
docker logs answered nothing about traffic: the only lines the server
wrote on a request were the kernel recordings, and a refusal left no
trace at all, so a client reporting "rejected" could not be matched to
anything. Two lines per request now, at info: one when it is admitted
(id, endpoint, peer, model, message and tool counts, prompt tokens, n,
max_tokens) and one from record() when it ends (finish reason, prompt
tokens and what the prefix cache spared, generated and reasoning
tokens, time to first token, decode rate, wall). Every refusal logs its
status, type and message with the peer -- 4xx at info, 5xx as a
warning. The debug level adds the last user message's opening, one
bounded line, so a log line can be matched to what was typed; the
daily's info level never prints prompt text.
HttpRequest carries the peer (httplib's remote_addr:port; empty
in-process), OaiRequest carries what the parse already walked past
(message and tool counts, the last user message) and the peer.
(cherry picked from commit 067facd47e2b0c0afeefe79166e77f01c33d588f)
- Wrong answers under concurrency on models with gated delta net layers (Qwen3.8-Flash-Next,
Qwen3.8-27B, Qwen3.6-35B-A3B). A conv state slot was one entry wider in the allocation than in
the state the kernels index, so clearing the slot a newly admitted request was given -- and a
prefix-cache checkpoint's save and restore -- reached into the next request's conv and n-gram
windows. A request decoding beside an admission then lost part of its recent context: a right
first token followed by a context-free continuation ("1. **Identify the numbers..." for "What
is 65 times 3?"), repeated or skipped digits. A single request was never affected. One
definition of the slot now, and the server refuses to start if the allocation and the kernels
ever disagree on it. Present since 1.0.0; reported with a strict concurrent sanity check.
- --num-speculative-tokens 0 no longer stops the engine at the first multi-sequence decode step:
an all-reduce argument struct's padding was uninitialised, and a recorded pass's audit read it
as a changed argument.
- The n-gram embedding table (Qwen3.8-Flash-Next's per-layer embedding) can be gathered on the
card. libr4d gains a row for embed_lookup_q whose output is the host gather's to the bit, and
--ngram-placement uses it: ram keeps a pinned copy in RAM that the cards read in place over the
link, so a step has no host work in it; vram puts the whole table on every card that holds it;
disk reads it from the container on the host, as before. auto takes the first of the three that
holds the table and prints why it passed over the others. Without a device kernel for the gather,
ram is the locked copy the host gather reads and vram is refused, as in 1.0.10.
- The pinned copy is not charged to RLIMIT_MEMLOCK; the host gather's locked copy still is, so
--ulimit memlock=-1 matters only on a run without the cards.
- The idea and a first kernel for the device gather came from Code000.
- Four-rank Qwen3.8-Flash-Next (PRs 14 and 16 by keptn42): the all-reduce runs fused with the
hyper-connection's write, and with the MoE gather in front of it, on decode and verify steps on
the exact wire. The routed experts are split in four classes, so every rank computes the same
share; moe_gemm_q_mod4 is the new grouped GEMM. The oracle now checks moe_gemm_q on w4nl and
w5nl containers.
- --embedding-placement and --ngram-placement, each auto | vram | ram | disk. The token embedding
can live in the pinned host pool, read in place over the link (from PR 17 by mechkbfan). An n-gram
table can be copied into locked RAM at load instead of read from the container (from PR 15 by
keptn42). auto takes the fastest tier with room once every other weight is placed, and startup
prints what it chose and why. A tier that cannot be honoured stops the start with the reason; the
embedding on disk and the n-gram table in VRAM are refused, since nothing can serve them.
- The expert_tiered placement no longer spends the pinned host pool twice when it falls back to
layer offload, and a lossy-wire request for a four-rank fused write is a selection miss rather
than a startup abort.
At --tp 4 each MoE connection ran moe_gather and the fused write as two
launches, three or four with the inverse table. ar_gather_hc_write_4rank
runs r4d_ar_gather_word as the prologue of ar_hc_write_4rank, with the
two-rank slot table and grid rule. The arithmetic is moe_gather's plus
ar_hc_write_4rank's, so the bytes are unchanged. One and two ranks unchanged.
At --tp 4 each gated-residual connection ran all_reduce and hc_write_bf16
as two launches. ar_hc_write_4rank fuses them: the wide exact one-shot,
reduced in place, with r4d_ar_hc_write_word as its epilogue. It takes the
steps the exact one-shot would (under 1 MiB, and under min_bytes on wht6);
larger and lossy messages keep the two launches. Two ranks unchanged.
embed_lookup_q reads the n-gram table through a row cache and direct reads,
and about half of a step's rows are first-seen, so steps wait on the drive.
--ngram-table ram (default disk, unchanged) copies the table into locked
huge pages in the background, checks the copy against the mapping and then
serves the gather from memory. MemAvailable, RLIMIT_MEMLOCK and the cgroup
limit are checked first; if any is short the table stays on disk. The flag
reaches the plugin as an optional `resident` parameter of embed_lookup_q.
The scale view of a w4nl64a8h, w4nl32a8h or w5nl64a8h expert is the E4M3 scale
plus its fixed second level, which enc_selection_logical could not read, and
libref described the weight scale on block fp8's grid for every dtype. So
RADIANCE_OP_ORACLE left every moe_gemm_q and moe_gemm_q_mod4 issue at those
formats NOT CHECKED. Both fixed; libref's arithmetic and serving unchanged.
The parity split gave ranks 0..3 30/30/20/20 % of the routed work. The extra
block of each five-block expert now goes round all four ranks by expert id
mod 4: rank r takes two blocks of class r and one of each other class, a
quarter each. The plain experts' extra tiles move to ranks 0 and 1 so they
do not stack on the shared expert's. One and two ranks declare as before.
moe_gemm_q over four tables instead of two: expert e is entry e / 4 of class
e % 4. A separate op, because the declaration divides a table op's weights
over its table operands by count. The arguments are repacked to fit four
classes in 256 bytes; moe_gemm_q's arithmetic is unchanged. Where weights
do not divide evenly over the tables, the first tables take one more each
(510 experts: 128/128/127/127). libref and libavx serve the op.
At four ranks the routed parity split leaves ranks 0 and 1 widest, and the
shared expert's extra block and the plain bf16 experts' extra tiles were cut
from rank 0 as well. Both remainders now go to the ranks the routed split
leaves narrowest. One and two ranks declare byte for byte as before.
The embedding table is the largest model-level weight a dense model has --
248320 x 5120 in bf16 is 1.18 GiB a card at --tp 2 -- and a step reads only
its rows: M of them, a few KiB at decode. On a 16 GiB card that is VRAM the
KV cache wants, and no strategy could move it: layer_offload spills whole
layers only, and the derived split charges every model-level weight to VRAM.
--host-weights NAMES places the named weights in the pinned host pool before
any strategy runs. The site is DeviceZeroCopy: the pool is mapped, so the
lookup kernel is handed its device-side address and reads the rows over the
link in place. The unit is never movable, and every assignment pass and VRAM
total skips it through one MoveUnit::preplaced(), as they skip the mapped
tier.
- weight_footprint() counts hosted units in their own bucket, so a derived
split leaves them out of the weight budget and the KV pool gets the room
without stating --vram-*-mib
- only a weight embedding lookups alone read is accepted: a GEMM operand
(the head) would stream its shard every step, and is refused
- names are parsed at config time (comma-separated, trimmed, a trailing '*'
a prefix); each one that matches nothing is warned about by name
- a weight the host pool cannot hold is refused with the plan filled in, and
the placement report gives host weights their own line beside the pool
- GUIDE.md §4.3 and the flags table; engine info carries host_weights
Measured on Qwen3.8-27B-FP8 with its MTP head, 2x RX 9070 XT (16 GiB),
--tp 2, two sequences, a 2560-token step, the split derived:
table in VRAM --host-weights token_embd.weight
KV pool (tokens) 70,976 144,576
decode, 500 tokens 115.8 tok/s 115.7 tok/s
prefill, 22K prompt 2773 tok/s 2798 tok/s
Tests: place_test covers the footprint bucket, the pinned zero-copy
placement, the refusal of a GEMM's weight and of a pool too small; ctest
-LE 'gpu|oot' passes.
- Pinned host memory is locked in pieces of at most 1 GiB (issue 13): an Intel VT-d host in
scalable mode that refuses any single pin above about 2.5 GiB now takes the host pool with IOMMU
translation, and peer-to-peer access, left on.
- Four-rank all-reduce (PR 11 by keptn42): the tiered-int8 wire serves in-place calls, so
--tp 4 --tp-wire wht6 runs. At four and eight ranks the exact all-reduce is one-shot up to
524288 elements and two-shot above, chosen by the selector, so the band report names the kernel
that runs. The docs and the startup warning describe the four-rank lossy wire; eight ranks have
none.
- A VRAM allocation the card cannot take is refused, saying what the card has left and which
processes hold memory on it. ROCm 7.2's runtime crashes on such an allocation once a queue has
been destroyed, which every startup does.
- rad-convert --changed FILE: with --reuse, converts only the weights that read a changed
checkpoint tensor and copies the rest.
The exact two-shot row needs hops=2, which the four-rank blocks never
state, so a 10 MiB prefill chunk went one-shot: 3N bytes a rank instead
of 1.5N. Above 1 MiB the one-shot entry now runs the two-shot kernel, in
place. Same fp32 fold order, bit-identical (KL vs tp 2 equal to the last
digit). Flash-Next tp 4 on 4x R9700: prefill +17% at 16k and 64k, decode
unchanged.
At four ranks every all_reduce is declared in place and without `hops`,
so `--tp 4 --tp-wire wht6` resolves all of them to ar_twoshot_4rank_ti8,
whose entry refused x == y: the first step failed and the engine stopped.
The entry now gates by `min_bytes` like the two-rank wht6 entry (exact
one-shot below) and accepts in place. Flash-Next tp 4 on 4x R9700: KL
vs tp 2 exact 0.062 / 0.070 (tp 4 exact: 0.061 / 0.068), prefill +27%
at 16k and 64k, decode unchanged.
- Qwen3.8-Flash-Next serves at --tp 4, contributed by goodman-b (PR 9). Rank pairs share each of
the model's two KV heads, every rank computes a slice of every expert's width, and four ranks
run the unfused all-reduce plus a new four-rank all-gather for the vocab-parallel sampler. Two
ranks declare and compute exactly as before. The README has a four-rank flag row; it pins
--host-pool-mib on every card, 48 GiB in all. At four ranks the expert shares are not equal:
ranks 0 and 1 compute three blocks of every even/odd pair of experts and ranks 2 and 3 two
(docs/ARCHITECTURES.md).
- The four- and eight-rank all-gathers require peer access between the cards, as every other
collective does since 1.0.7, and the kernel library's selftest now refuses any multi-rank kernel
that does not.
--debug-graph on the real container at --tp 4 was red on exactly one op: thirteen
device bands, all of them attn_paged_gate_quant, refused with 'gqa == 12, have 6'.
The row table registered the fused sparse-decode leg only at the two-rank ratio, so
at four ranks the block declared a fused op nothing served.
That was my reading of v1, and it was wrong in a way that is not neutral: the block
declares the fused op beside the unfused pair EITHER way, so an unregistered geometry
is not a quiet fallback, it is a device hole -- a band a request can land in whose
step then fails at issue rather than at declare.
The kernel already exists. r4d_attn_paged_gqa8.hip pastes the _gq entry points onto
R4D_ATTN_GQA, so the gqa6-bs4 unit has exported them since it was written; the
build's libr4d.so has r4d_rad_attn_decode_gq_h256_gqa6_fp8 and _bf16 in its symbol
table. Unlike all_gather, this leg needed a row registered, not a kernel written.
q_len <= 10 rather than <= 5 is the same q_len*gqa <= 64 at six queries a position;
the verify bound moves with the ratio and nothing else. TP2 cannot regress: the rows
carry C_EQ(gqa, 6) against a world-2 query that carries 12.
radiance: 'layer 34's plain experts are 384 wide, which 4 ranks cannot share in
64-wide tiles' -- on ranks 1 and 2 only. The protected experts are declared by a
second grouped GEMM over their own slice of the expert's width, and that width
was read off THIS RANK's parity slices (max ff_hi). At two ranks that is the
model's width; at four it is 384, 512, 640 depending on who asks. Ranks 0 and 3
passed the check, ranks 1 and 2 refused, so the all-reduce's rendezvous got two
of four ranks and the launch died -- the AR error was the cascade, not a bug.
The width is g.n_ff_all. And an even share of it is not available here: 640
columns are ten 64-wide output tiles, which four ranks take as 3, 3, 2, 2. An
uneven share is still whole tiles and every tile still has exactly one owner, so
the rank takes a span -- uniform across a layer's protected experts, because
their GEMM takes ONE table and every entry of a table has one geometry (unlike
the quantised experts, which alternate by parity precisely because they have two).
A rank count that divides the width keeps the old declaration verbatim, span
included: no span at all, the loader dividing the entry itself.
The old assertions pinned expert parallelism -- n_expert = 128, expert_base =
r*128 -- which is the design this replaces. What the four ranks divide is each
expert's width, so what the test pins is a span on every expert's down
projection, per parity, plus the property that actually matters: the four
ranks' slices of one parity TILE the width, each block claimed exactly once.
Neither unserved (a rank quietly dropping a fifth of every expert) nor twice
(the all-reduce then double-counts that block).
Read off the declared spans, not off the plugin's formula -- recomputing them
would only prove the test agrees with the code.
The real-container declare gate refused this container at layers 46-47: 'keeps
1 experts plain bf16 on this rank, which leaves 127 quantised'. Root cause:
protected-expert counts are per-rank, and the recipe protects IN PAIRS precisely
so that each rank's quantised count stays even. Expert parallelism broke that
property the parity tables rest on; fixing it properly would need unequal-length
weight tables, which the builder's equal-split rule refuses by design.
The width split was always the right answer above two ranks and serves more
ranks than the old code realised. Each parity's blocks are cut contiguously
across the ranks and the rank taking the odd block alternates with the parity:
at four ranks and five blocks, [0,2) [2,3) [3,4) [4,5), with the fat class
rotating between the two parities so no rank takes both. Every block of every
expert has exactly one owner, protected counts go back to the recipe's global
even numbers, and -- because every rank still computes a slice of every routed
expert -- the routing-balance cost the EP design carried disappears with it.
World 2 is byte-identical: base, extra and the parity rotation reduce to the
same expressions at g.world == 2. Worlds up to the block count now declare;
beyond it the refusal names the reason.
World 4 refused at declare on two counts and at boot on a third the audit
found; the fourth is unchanged by design.
- rad_arch.h: a world above the KV head count replicates the heads in rank
pairs instead of dividing them. Geom gains kv_off; each rank declares
n_head_kv 1 and gqa 6. A world that is not a multiple of the head count
is still refused, by name.
- rad_block_attn_gated_fp8.h: k/v pass the row span LinearFP8 already
takes, gated on world > n_head_kv_all so an even shard is untouched and
TP2 declares byte-identically.
- qwen4exp_fp8.cpp: above two ranks the ranks own whole experts (5 blocks
of 128 do not cut four ways); the parity tables stay two-rank and the
router stays replicated.
- libr4d: attn_{prefill,decode}_h256_gqa6_bs4 rows and their TU -- the
gqa8 body at ratio 6, page 4. No fused form is instantiated at this
geometry; the unfused pair is what resolves.
- libr4d: r4d_ar_gather_Nrank.hip. The vocab-parallel sampler declares an
all_gather at any world > 1 and libr4d shipped only the 2-rank row, so a
TP4 boot was refused by the reference-kernel gate rather than served
wrong. The wide one-shot all-reduce with the reduction removed.
- rad_block_attn_gated.h / rad_block_attn_fp8.h: refuse a world above the
KV head count. They read n_head_kv and declare no span, so they would
have booted and read half a KV head -- fluent wrong text.
- tests/arch_test.cpp: the four-rank declare test, and the fake records
the shard span the real builder stores.
- README, ARCHITECTURES: TP4 in the present tense, with the costs named
and the rate against TP2 left unmeasured.
- Chat responses report usage.completion_tokens_details.reasoning_tokens: how much of
completion_tokens was the reasoning block. A reply that ran out of max_tokens inside <think>
now reads as that, instead of as a model that answered nothing.
- thinking_token_budget (vLLM's name; thinking_budget is read as the same field) caps the
reasoning. At that many tokens the block is closed and the model answers from what it has
reasoned so far. It holds under speculative decoding and at any temperature.
--thinking-token-budget sets the default for clients that send none.
- Every completion response carries a `timings` object in llama.cpp's shape: prompt and generated
token counts, times and rates, and the speculative tokens drafted and accepted for that request.
It is on the buffered response, on each streamed choice's final chunk and on the usage chunk,
so a proxy such as llama-swap can read per-request speed. /metrics stays the aggregate.
- Peer-to-peer access between the cards is checked at launch. The all-reduce kernels need it; on
a machine where the cards cannot reach each other's memory, startup stops and names device.p2p
instead of the first all-reduce faulting or hanging. A kernel library can require it with a
constraint on the new "device." keys, which match the machine and not the op's parameters.
- A pool allocation the driver refuses says why, with the card's free VRAM at that moment and,
for the host pool, the pinned memory taken against the amdgpu limit (ttm.pages_limit). Every
rank pins its own --host-pool-mib, so --tp 2 pins it twice.
- A text prompt to /v1/completions reads the model's control tokens as tokens, as vLLM and
llama.cpp do. A client that renders its own chat template can send "<|im_start|>user ..." and
the model sees the turn markers; they used to reach it as plain text. /tokenize and
/v1/embeddings read a text prompt the same way, and a prompt that already opens with BOS gets
no second one.
- The VRAM budget counts the engine's own hardware queues, which the driver backs with about
33 MiB of VRAM each, and the KV tiers' copy staging. Both used to come out of
--gpu-headroom-mib: Qwen3.8-Flash-Next ran with 9 MiB free under load against the 96 MiB it
asked to keep, the room a kernel's first launch allocates from. The startup receipt has a
"hardware queues" line.
- Running the whole model on the CPU (RADIANCE_HOST_DOMAIN=1 with no GPU visible) no longer
repeats words or answers differently at temperature 0. A decode step could read its input
token before the copy that delivers it had landed.
- The README says to clone the repository before installing.
- Answers no longer stop partway through. A request without max_tokens got 512 tokens, and a
reasoning model can think for thousands before it answers, so the reply ended inside the
reasoning with finish_reason "length", which chat clients do not show. It now gets whatever
the context leaves after the prompt, as in vLLM. --default-max-tokens N sets a number, and
--max-tokens-cap bounds every request.
- Qwen3.8-Flash-Next in Docker without --security-opt seccomp=unconfined is refused at startup,
in about a second, with a message naming that option. It used to load the whole model and then
fail every request as "unsupported", and a restart policy reloaded it over and over. The
n-gram table is read through io_uring, which Docker's default seccomp profile refuses.
- A request the engine fails says what failed, in the 500 or the stream's error event. It read
"the engine failed this request: ok".
- Flash-Next no longer crashes at startup about one start in seven (a race between the
parallel declares that size the activation arena).
- rad-convert no longer needs io_uring, so it converts in a sandbox that forbids it.
- oh-my-pi works unmodified on every Qwen model. Its requests carry a top-level
preserve_thinking, which was refused as an unknown field; it now reaches the chat template the
way enable_thinking does. Its task tool's `model` parameter is the `not` of every JSON type,
which the 1.0.1 fix did not cover: any `not` that excludes every value is now an argument no
call writes, under every chat template and Flash-Next's declared format.
- Command-line defaults and bounds for what a request leaves out. A flag left unset changes
nothing; /server_info reports the values under request_defaults.
- Sampling: --typical-p, --presence-penalty, --frequency-penalty, --repetition-penalty,
--repeat-last-n, --dry-multiplier, --dry-base, --dry-allowed-length, --dry-penalty-last-n,
--dry-sequence-breakers, --xtc-probability, --xtc-threshold.
- Requests: --default-max-tokens N|auto, --max-tokens-cap, --max-n, --max-queued-requests,
--max-stop-strings, --max-stop-bytes.
- Chat template: --chat-template-kwargs JSON|@FILE sets template variables a request's own
chat_template_kwargs override; --reasoning-format auto|none.
- HTTP: --http-threads, --read-timeout, --write-timeout, --keep-alive-timeout, --max-body-mib,
--retry-after, --no-cors.
- Media: --image-min-pixels, --image-max-pixels, --video-min-pixels, --video-max-pixels,
--video-fps, --video-min-frames, --video-max-frames, --video-max-frame-tokens,
--max-source-pixels.
- Under --reasoning-effort none or minimal, a request that sets enable_thinking true now thinks
instead of having the deployment default override it.
- --temp, --top-p, --min-p and --top-k refuse a value that is not a number instead of reading
it as 0.
- A tool whose schema bounds a string or an array past 2000 (maxLength, minLength, maxItems,
minItems) no longer fails every request carrying it (issue #5). The bound is held exactly, up to
about 200,000; past that the request is refused with a 400 naming the tool's property and the
count. A bound past 2^31, such as Number.MAX_SAFE_INTEGER, is no bound.
- Compiling a grammar with a long bounded repetition is linear in the bound instead of quadratic:
maxLength 32000 compiles in 0.7 s instead of 2.1 s.
- Qwen3.8-Flash-Next serves with its container on btrfs (issue #3). The host gather of the n-gram
table needed the filesystem to report its direct-I/O alignment, which btrfs never does, and
refused every request. Where none is reported it now reads in units of the file's block size,
and one read of the table proves that before a row is served.
- docs/DOCKER.md says which filesystems the models directory can be on, and what btrfs compression
costs the n-gram reads.
- Up to 32 sequences a step on every model. The DSpark drafter (MiniCPM5) no longer rejects every
draft from the tenth sequence on, and the step batch's block tables and media staging are
charged to the VRAM budget instead of the headroom kernels load into.
- A tool parameter whose schema accepts no value ({"not": {}}, as TypeBox and Arktype export
`never`) is an argument no call writes, instead of failing the request. oh-my-pi's task tool
works.
- --served-model-name NAME and --override-chat-template PATH.
- The startup session count counts only the part of the KV pool that holds context.
- Compose files and README run --max-num-seqs 32 where it keeps a 200K-token request.
| Gemma 4 31B Q8: int8 trunk and lm_head (Q8_0's grid at group 128), int8 DFlash drafter, vision | `gemma4-31b-dense-q8-df.rad` (33 GiB) | [convert](#convert-a-checkpoint) | `gemma4-31b-q8-df.yaml` |
| Gemma 4 31B on four cards: int4 trunk, int8 activations and lm_head, RedHatAI's DFlash2 drafter, vision | `gemma4-31b-dense-w4a8-df2-qkv.rad` (23 GiB) | [download](https://huggingface.co/Ashlyn4202025/gemma4-31b-w4a8-dflash2) | `gemma4-31b-w4a8-df2-tp4.yaml` |
| Gemma 4 31B on four or two cards: int4 trunk, int8 activations and lm_head, a block-16 DFlash2 drafter (15 drafts a step, verified as a tree), vision | `gemma4-31b-dense-w4a8-df2b16-qkv.rad` (23 GiB) | [download](https://huggingface.co/Ashlyn4202025/gemma4-31b-w4a8-dflash2-b16) | `gemma4-31b-w4a8-df2b16-tp4.yaml`, `gemma4-31b-w4a8-df2b16-tp2.yaml` |
| Qwen-Image 2.1 FP8: text to image and image edits | `qwen-image-2.1-fp8.rad` (16 GiB) | [download](https://huggingface.co/StillDeadcode/radiance-qwen-image-2.1-fp8) | `qwen-image-2.1.yaml` |
| Qwen-Image 2.1 Turbo FP8: the same in 8 steps | `qwen-image-2.1-turbo-fp8.rad` (16 GiB) | [download](https://huggingface.co/StillDeadcode/radiance-qwen-image-2.1-turbo-fp8) | `qwen-image-2.1-turbo.yaml` |
| Krea 2 Turbo FP8: text to image, one card | `krea-2-turbo-fp8.rad` (16 GiB) | [download](https://huggingface.co/StillDeadcode/krea-2-turbo-radiance-fp8) | `krea-2-turbo.yaml` |
| Krea 2 Raw FP8: the same, undistilled | `krea-2-raw-fp8.rad` (16 GiB) | [download](https://huggingface.co/StillDeadcode/krea-2-raw-radiance-fp8) | `krea-2-raw.yaml` |
| FLUX.3 [klein] FP8: text to image and edits from up to ten pictures, one card | `flux-3-klein-fp8.rad` (9.3 GiB) | [download](https://huggingface.co/StillDeadcode/radiance-flux-3-klein-fp8) | `flux-3-klein.yaml` |
| LTX-2.5 distilled FP8: video with its stereo soundtrack from text or a first frame, one card | `ltx-2.5-distilled-fp8.rad` (37 GiB) | [download](https://huggingface.co/StillDeadcode/radiance-ltx-2.5-distilled-fp8) | `ltx-2.5.yaml` |
| MiniMax-H3 FP8: video with its stereo soundtrack from text | `minimax-h3-fp8.rad` (60 GiB) | [download](https://huggingface.co/StillDeadcode/minimax-h3-fp8) | `minimax-h3.yaml` |
| FastH3 8-Step V2 FP8: the same in eight steps | `fasth3-8-step-v2-fp8.rad` (62 GiB) | [download](https://huggingface.co/StillDeadcode/fasth3-8-step-v2-fp8) | `fasth3.yaml` |
| MiniMax-Music3 bf16: songs from lyrics and a description | `minimax-music3-bf16.rad` (20 GiB) | [download](https://huggingface.co/StillDeadcode/minimax-music3-bf16) | `minimax-music3.yaml` |
| Unlimited-OCR bf16: document parsing with the DeepEncoder tower | `unlimited-ocr-bf16.rad` (6.2 GiB) | [download](https://huggingface.co/Aijuus/unlimited-ocr-bf16) | `unlimited-ocr-bf16.yaml` |
| Breeze-TTS-2 bf16: speech, whole, streamed or live, one card | `breeze-tts2-bf16.rad` (5.5 GiB) | [download](https://huggingface.co/StillDeadcode/radiance-breeze-tts2-bf16) | `breeze-tts2.yaml` |
| Fish Audio drama-3: speech with speaker tags and inline direction, voices cloned from reference clips, whole, streamed or live; block-FP8 experts, two cards | `drama3-fp8.rad` (36 GiB) | [convert](#convert-a-checkpoint) | `drama3.yaml` |
| Stable Diffusion XL bf16 and its finetunes (Illustrious, NoobAI, Pony): text to image, one card | `illustrious-xl-v2.0-bf16.rad` (6.4 GiB), from any single-file SDXL checkpoint | [convert](#convert-a-checkpoint) | `sdxl.yaml` |
| EmbeddingGemma 2 bf16: text, image, video and audio embeddings, one card | `embeddinggemma2-bf16.rad` (1.4 GiB) | [convert](#convert-a-checkpoint) | `embeddinggemma2.yaml` |
| nomic-embed-text-v2-moe bf16: text embeddings, one card | `nomic-embed-v2-moe-bf16.rad` (959 MB) | [convert](#convert-a-checkpoint) | - |
| Anima Aesthetic FP8: anime and illustration, text to image, one card (Base and Turbo convert the same way) | `anima-aesthetic-fp8.rad` (3.0 GiB) | [convert](#convert-a-checkpoint) | `anima.yaml` |
| Qwen3-ASR 1.7B bf16: speech to text, `/v1/audio/transcriptions` and live over `/v1/realtime`, 30 languages, one card | the checkpoint as it ships (4.1 GiB) | [Qwen/Qwen3-ASR-1.7B-hf](https://huggingface.co/Qwen/Qwen3-ASR-1.7B-hf) | — |
A container holds everything the server needs: the weights, the tokeniser, the chat template and
any drafter. Each download link's repository has the recipe and the exact command that made the
file. Download one into your models directory (the transfer resumes if interrupted):
/* A group opens where the cell changes; cells are numbered in their first group's order. */
autocolumn_of=[&](intmd,int64_tr0){
for(size_tc=0;c<out->md.size();++c)
if(out->md[c]==md&&out->r0[c]==r0)return(int)c;
out->md.push_back(md);
out->r0.push_back(r0);
return(int)out->md.size()-1;
};
intcur=-1;
boolopen=false;
int64_tprev_end=0;
for(constPiece&pc:pieces){
constintcol=column_of(pc.md,pc.r0);
if(!open||col!=cur||pc.start!=prev_end){
out->bound.push_back(open?pc.start:0);
cur=col;
open=true;
out->col.push_back(col);
}
prev_end=pc.end;
}
if(open)out->bound.push_back(p.rows);
}
}/* namespace minimaxh3 */
Loaded 100 of 1294 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.