Commit Graph
911 Commits
Author SHA1 Message Date
AnimusNull 17f0eae420 r4d mla_attn: E4M3 latent cache twins of the three rows
mla_attn takes an optional `kv_dtype`; at fp8_e4m3 the cache is E4M3 as kv_store_fp8 writes it at its
default descale of 1. mla_attn_fp8kv, mla_attn_matrix_fp8kv and mla_attn_rows_fp8kv are the bf16
rows' kernels with the cache element as a template parameter: the key load decodes E4M3 to bf16
(v_cvt_pk_f32_fp8, then the high half), which is exact since every E4M3 value is a bf16, so the
tiles and all arithmetic past the load are the bf16 instance's. The twins carry the bf16 rows'
constraints plus kv_dtype fp8_e4m3 and rank above all three bf16 rows, in their order. At uint16_t
the loads are the plain loads the bf16 kernels made; their launchers still refuse any cache that
is not bf16.

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

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

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

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

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

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

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

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

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

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

Mirror libr4d: the kernel's flag test gains a null guard (no params:
every row runs), the launcher no longer refuses null, and the row's spec
marks the operand optional.
2026-11-05 21:18:00 +11:00
mici81 7f5218ee5f qwen4exp: decode, verify and draft passes are recorded, keyed by their split cap (issue #402)
pass_key() answered 0 for every draft and verify pass, and with a callback present the core neither
records such a pass nor gives its launches the keyed context bound, so with the MTP drafter nearly
every decode pass was issued op by op (1.17.0: 206 passes played and 508,236 issued unkeyed, where
1.15.1 played 492,894). Dropping the export would record them with the cores bucketed bound, which
2026-11-05 09:50:02 +01:00
Asim Siddiqui 036bd8fec0 libr3d: register the fused gdn_conv_recurrent_update row
The kernel and launcher (libhalo's, r3dh_gdn_recurrent_update.hip) have
been in the tree since 1.16.0, but no row referenced them, so the op
always landed on libavx's CPU row. Register them:

- the op's schema (12 params, 18 operands: the convolution's inputs,
  then the recurrence's minus q, k and v, which the fused kernel never
  materialises), identical to libavx's and libref's;
- the constraint set: q_len >= 1, head_k 128, head_v 128, conv width 4;
- the row at R3D_PRIO_ONLY, NOTUNE (one kernel configuration), no
  layout hooks;
- the selftest case (hand-built, as the sibling GDN rows): T=4, Hg=2,
  H=4, K=V=128, window 4, state f32; o_q and o_scale absent;
- the README row, the table count (111 rows over 72 schemas) and the
  decode-path prose.

rad-schemas over the four libs: 244 shared ops, 0 disagree (the new
schema matches the canonical registries). gfx1102 (RX 7600):
r3d_selftest 118 rows / 0 failed, the new row runs with 8 output
planes finite; ref_test 153,146 checks / 294 cases / 0 failures.
2026-11-05 09:49:06 +01:00
Asim Siddiqui 87c604370d libr3d: add 8 kernels — MoE GEMM (w4a8, w4a4, mod4), dequant_w4, row_topk_merge, ngram_ids, gemm_nt_q_bias, gemm_nt_q_short
moe_gemm_q w4a8: the 2-class MoE GEMM with bf16 weight scale and bf16
output. E4M3 activation codes, bf16 weight scale (not f32), single
16x128-block i32 wave-matrix config. The w4a8 dtype row is folded into
the existing moe_gemm_q op as a dtype variant, not a separate op.

moe_gemm_w4a4: the 2-class MoE GEMM with int4 activation codes and
int4 weight codes. i32 wave-matrix core (no E4M3 decode table),
symmetric int4 x int4 multiply-accumulate. Single fixed 16x128-block
config.

moe_gemm_q_mod4: the 4-class MoE GEMM. Experts route to class e%4
(entry e/4 within the class). Same E4M3 wave-matrix core as
moe_gemm_q_e4m3, with 8 individual R3dTab parameters (4 weight + 4
scale tables) to stay within the gfx1102 kernel parameter limit.

dequant_w4: packed int4 weight to row-major bf16. Each 32-bit word
holds 8 int4 codes; the scale is f16 in the low 16 bits, the zero
point is -(1024+zero) as f16 in the high 16 bits. One warp per 32
output elements.

row_topk_merge: top-R of gathered per-rank candidate sets. Each rank
contributes a sorted candidate list; the merge selects the top-R
global candidates by score. int32 ids are bit patterns in an f32
plane (memcpy, not cast).

ngram_ids: hashed n-gram row ids for PLE (Per-Layer Embedding).
Computes the row index for each n-gram in the sequence using a
FNV-1a hash folded into the embedding table size.

gemm_nt_q_bias: narrow fp8 GEMM (M <= 16) with per-column bf16 bias
fused into the epilogue. The bias is added to the f32 accumulator
before the single bf16 narrowing at the store. Extends
r3d_gemm_nt_q_fp8_ex with a bias parameter.

gemm_nt_q_short: narrow fp8 GEMM (M <= 16) for short-prompt decode,
unsplit K. Forces sk=1 (no K-split) in r3d_gemm_nt_q_fp8_ex. The
short-prompt path avoids the K-split overhead when K is small.

The two narrow fp8 rows carry the tGemmM16 tune matrix (sk 0/1/2/4/8/16,
wv 1/2/4/8, nt, the two E4M3 decode impls, 16-row tiles) like the other
gemm_nt_q rows, measured per card by rad-tune.

The six new ops adopt the canonical op schemas. The engine enforces
schema identity across kernel libraries: the first library to declare
an op fixes its schema, and a disagreeing plugin is refused whole at
load. libavx loads first, so the specs match the canonical registries:
- moe_gemm_q_mod4: 15 params / 13 operands (the eight weight tables at
  the RAD_OPD_WTAB role); the launcher reads a_order (token/sorted),
  requires group = 128, checks the activation's row count against the
  output, and refuses unequal class shapes (N_1..K_3 differ from N/K)
  as moe_gemm_q does with N_odd/K_odd.
- ngram_ids: 4 params / 11 operands under the canonical names; state
  required; per, W and the ids pitch derive from the operand shapes.
- row_topk_merge: 4 params (+dtype) / 3 operands.
- gemm_nt_q_short: the family's four optional params (pb1, pb2,
  split_n, w_rb) and two optional operands (a_sum, b_ref).
- gemm_nt_q_bias: a_scale required, not optional.
- dequant_w4: the dtype param, twos required, the scale operand named
  ws; the launcher refuses zero rows with RAD_E_SHAPE like every
  other op.

A kernel audit found five launcher param reads the engine can never
populate (the spec's params plus the row's tune axes are the only
sources): pb1/pb2 in the gemm_nt_q_bias launcher, splits in the decode
attention path, and nt/kb/sk in the tiled rows that tune only impl.
Each always took its default; the reads are deleted, behavior-
identical.

All 8 verified bit-exact on gfx1102 (RX 7600, box card 2).
Selftest: 117 rows clean, 0 failed. rad-schemas over libavx, libr3d,
libr4d and libref: 244 shared ops, 0 disagree.
2026-11-05 09:49:06 +01:00
mici81andClaude Opus 5.5 8ab6f2a8b3 libr4d: qsa_select launches its chained form from a site of its own
The emulator test reads the plain launch's kernel name (tests/r4d_emu/test_qsa.cpp), and one launch
choosing between the two kernels spelled the choice instead; r4d_emu_qsa and r4d_emu_qsa_sweep
failed on it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 09:48:37 +01:00
mici81andClaude Opus 5.5 e2e9416843 qwen4exp: chained launches pay with the MTP drafter
The probe sets chain_pays, as the Gemma 4 DFlash drafter does, so the engine chains the
speculative step's launches on the AQL backend (the chained forms of the previous commit).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 09:48:37 +01:00
mici81andClaude Opus 5.5 b0a58b5dbf libr4d: chained forms for Flash-Next's decode step, hc_read forms G, S and B3
Every kernel of Flash-Next's speculative decode step gets a chained form (r4d_chain.h), so the
step's small launches wait on their predecessor on the card instead of behind a queue barrier:
the router and the fp8 and four-bit expert GEMMs, the gated quantisers, the delta-net recurrence
and conv, the hyper-connection write and its all-reduce gather, the attention layer's indexer,
norm/rope/gate, quantiser and gqa6 decode rows, and the tiled and fused hc_read kernels. A
chained form is taken only at steps of up to 32 token rows (kR4dChainMaxRows); above that the
waiting blocks hold room a wide predecessor needs.

hc_read at one to sixteen decode rows (hc 4, n 2560, E4M3 mixing matrices, inject gains), the
shape Flash-Next calls 97 times a pass:
- form G (1..8 rows): kernel A' as (16-column tile, stream) blocks, so a block reads its W_down
  slice once for every row of the step; the slice and the norm gain load before the chain wait,
  the dots are bf16 WMMA, and the last of a tile's blocks sums the streams in ascending order.
- form S (9..16 rows): as G, but the norm's scale is applied after the dot, so N never sits in
  LDS and one block holds every row.
- kernel B3 (both forms, lr 320): the up product as WMMA over d with W_up's exact quarter
  scales, and the mix in each lane; W_up loads before the chain wait.
From 17 rows the tiled path (now chained) stays faster.

The new forms are not byte-identical to the kernels they replace: the bf16 WMMA dots sum in
another order and S scales after the dot. Against an fp64 host reference, d is as close as the
per-row kernels' at 1..7 rows and closer than the tiled path's at 8..16 (mean error 0.13-0.14 %
of the row's RMS against 0.17 %, max 1.2-1.4 % against 1.3-2.0 %). The selftest's decode-forms
case now holds d to that reference (no further from it than the two-grid form) and x to the
two-grid form within rounding up to 16 rows, and stays byte for byte above.

Flash-Next on 2x R9700, sampled at temperature 1, 25k prompt, 500 tokens, two rounds of
1/2/4/8/16 streams: MTP depth 3 174/291/458/657/851 -> 207/339/493/647/843 tok/s; with depth 5
and the adaptive window 191/331/493/661/897 -> 218/355/494/662/893.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 09:48:37 +01:00
keptn42 aeaf6a4580 r4d_selftest: sweep the verify-against-decode check to 2048 keys
attn_verify_bits_case ran three contexts. The sweep runs every context from 40 to 300, then the
page edges up to 2048, at 2, 3, 4, 5 and 8 verify rows, for the gqa16 (bf16 and fp8 KV) and gqa8
rows. One line a verify width; a failing context counts. It found the merge difference fixed by
the previous commit. Past 2048 keys a verify of more than 32 rows is cut differently from a decode
by design (r4d_decode_splits), so the sweep stops there.
2026-11-04 22:08:53 +01:00
keptn42 d6109d7e3e libr4d: the split-KV merge reads a causal row's own segments
The decode kernel cuts the tiles of the launch's context into segments, and the merge read all of
them for every row of a verify. A row that ends in an earlier tile than the last row therefore
merged a different number of segments than its single-row decode, and the merge's chains take the
tail differently (the last u mod 4 segments go to chain 0), so the sums associate differently. At
contexts of 16k+1 keys the two-row verify differed from its two decodes in the last bit; with
eight rows 75 of 867 contexts between 40 and 2100 did (gqa 16, bf16 KV), and the same at gqa 8 and
for the fp8 KV. Greedy text with the drafter left the text without it from such a step on.

The merge counts a row's segments from the row's own causal context. Windowed rows, non-causal
rows and tree verifies keep the launch's count, and a plain decode is its own row, so nothing but
the verify rows of causal rows changes.
2026-11-04 22:08:53 +01:00
keptn42 030a3a37b7 advance_test: StepSlot::hrow is the row of the last accepted position
The chain acceptance checks hrow = rtok + accepted; the tree acceptance checks the row of the last
node on the accepted path (rows are nodes, in order; the root when nothing is accepted), over the
same random trees and end-of-generation cuts.
2026-11-04 22:08:53 +01:00
keptn42 1a900398a3 kbench: a fixture for Nemotron-H's rows, and docs/KERNELS.md from it
data/kernels_nemotronh.rkb holds 1009 cases recorded from the 74B skeleton (host only). With
kernels.rkb the report reaches 188 of 1031 rows (134 before), among them the gqa16 attention
rows, and 5226 cases pass.
2026-11-04 22:08:53 +01:00
keptn42 6436410e63 kbench: the report check reads every plugin's table, not only lib*
The per-library header "N row(s) not reached" was matched as lib\w+. A plugin library such as
spechub has a table of its own; its rows were counted into the library above it, and the headline
sum came out six short. The pattern is \w+ now. docs/KERNELS.md lists spechub from this run.
2026-11-04 22:08:53 +01:00
keptn42 7cad854f2b libr4d: the gqa16 decode takes a verify of eight rows, so a draft step matches its single-row decodes
The h128/gqa16 decode row stopped at q_len 4 (64 query-head rows a workgroup), so LiLiCorr's
verify of 7 drafts and the anchor (q_len 8) ran the query-tiled prefill kernel while a plain decode
runs the split-KV one: no verify row was the single-row decode at its position, and greedy text
with the drafter left the text without it within a few hundred characters at one and two ranks.
The gqa16 unit raises G8_MAX_DECODE_ROWS to 128, which compiles an eight-wave arm into the gqa8
body's decode launch; gqa8 and every other unit compile as before. The rows take q_len <= 8.

Selftest: the numeric cases at q_len 8, and attn_verify_bits_case, eight verify rows against eight
single decodes bit for bit at 120, 700 and 2048 keys (gqa 16, and gqa 8 for four ranks).
docs/ARCHITECTURES.md: past 2048 keys the split law partitions a verify and a decode differently,
so a near-tie can still flip greedy text.
2026-11-04 22:08:53 +01:00
keptn42 72160a9cff nemotron-3.5-bolt-74b compose: two cards at w4a8, four at FP8
nemotron-3.5-bolt-74b-w4a8.yaml (--tp 2) and nemotron-3.5-bolt-74b-fp8.yaml (--tp 4): 8 sequences
of 65536 tokens, LiLiCorr at 7 drafts, a bf16 KV cache, as the containers were measured. The
README's model table and docs/DOCKER.md list them.
2026-11-04 22:08:53 +01:00
keptn42 882050e45a data/recipes: nemotron74-fp8.recipe and nemotron74-w4nl64-gptq.recipe
Every block linear and routed expert as block FP8; or the routed experts at w4nl64a8h (GPTQ
against $CALIB, rounded to nearest without it) and the rest block FP8. Both carry the LiLiCorr
drafter's linears when it is merged.
2026-11-04 22:08:53 +01:00
keptn42 0c4292e45b arch/nemotronh: Nemotron-3.5-Bolt-74B-A9B
NVIDIA's Nemotron-H hybrid from its bf16 checkpoint: 40 Mamba-2, 40 latent-MoE and 8 NoPE attention
blocks, the LiLiCorr drafter (7 drafts a step) and the C-RADIO tower with its projector, at one, two
or four ranks. docs/ARCHITECTURES.md describes the model. nemotronh_test: the drafter's KV heads at
two and four ranks, a speculative step at four, and the arena's sizing declares.
2026-11-04 22:08:53 +01:00
keptn42 cc46e3b714 core/mm: the Radio image family and video tubelets
Nemotron-H Omni's processor: NVIDIA's size rule for one tile, torch's antialiased bicubic on float
pixels, patches in merge-block order, and video in tubelets labelled as the reference labels them.
A picture and a video frame share one patch row, so one embedding GEMM serves both. mm_test against
golden rows.
2026-11-04 22:08:53 +01:00
keptn42 eda0e92e8e arch/common: LiLiCorr, DFlash2's backbone with a candidate correlator
Config::lili runs DFlash2's backbone with attention sinks and leaves the head to the plugin;
rad_block_lilicorr.h is the correlator over the draft rows (lili_cand, lili_attn, lili_factor,
lili_walk), conditioned on the context state at the anchor (RadBatch::anchor_rows). At four ranks
drafter_geom replicates the drafter's two KV heads as geom_from does the target's (kv_repl_ok), and
Dflash2 reads k and v at kv_off (DenseFP8::span).
2026-11-04 22:08:53 +01:00
keptn42 6f9c084ac6 arch/common: calibrate in layer ranges (RADIANCE_CALIB_LAYERS)
Nemotron-3.5-Bolt's per-expert Hessians take 169 GiB at once. RADIANCE_CALIB_LAYERS names the
layers a run taps, so several runs over disjoint ranges share one directory, and a layer's host
sums are released once written.
2026-11-04 22:08:53 +01:00
keptn42 c9c3a98894 arch/common: MoeFP8's ungated relu2 experts, a router on the hidden width, and no reduce
For a latent MoE: ungated experts, down(relu(up(x))^2), through GateQuantFP8's relu2; a router that
reads another width than the experts (Config::router_k, Wire::route); and Config::no_reduce, which
leaves the routed sum unreduced for a caller that reduces it with its shared expert.
2026-11-04 22:08:53 +01:00
keptn42 3b7ef1ed48 arch/common: AttnFP8 without positions, and with KV heads replicated above their count
rotary_dim 0 is attention without positions (NoPE): no rope is declared. Above the KV head count
the fused q | k | v takes a span per part, q this rank's heads and k and v the head at kv_off, as
gemma4's q | k | v does.
2026-11-04 22:08:53 +01:00
keptn42 b466c91b26 ops: attn_dense at head_dim 80 and grid_embed_cpe, for the C-RADIO tower
attn_dense at head_dim 80 without GQA (C-RADIO's ViT heads), and grid_embed_cpe, RADIO's cropped
position embedding: the table resampled half-pixel bilinear onto a square and cropped to the
grid, with the class and register rows ahead of each segment. libref, libavx and libr4d; ref_test,
avx_check_hand and selftest cases; docs/OPS.md.
2026-11-04 22:08:53 +01:00
keptn42 2420b2b383 ops: act_mul's relu, relu(x)^2 over one tensor
act_mul's `act` takes "relu": with one tensor in both operands it is relu(x)^2, Nemotron-H's
ungated expert activation and its vision projector's. libref, libavx and libr4d.
2026-11-04 22:08:53 +01:00
keptn42 63416510a0 ops: ssd_update and ple_conv_bias, Mamba-2's scan and convolution
ssd_update is Mamba-2's selective state update, a token at a time, with kda_update's rollback
contract: per_candidate, or the anchor form (one committed state and a scratch of per-token
records). libref, libavx and a libr4d kernel at a 128-wide state (r4d_ssd.hip, r4d_kda.hip's
register layout). ple_conv_bias is ple_conv with a per-channel bias inside the silu, Mamba-2's
conv1d, an op of its own so ple_conv's callers keep their operand list.

ref_test, avx_check_hand and selftest cases; docs/OPS.md.
2026-11-04 22:08:52 +01:00
keptn42 3b278dcec3 ops: attention sinks and LiLiCorr's correlator
For NVIDIA's LiLiCorr drafter:
- attn_paged_sink: attn_paged with a learned logit a query head beside the keys, in libref,
  libavx and libr4d (the windowed kernels at h128, gqa 8 and 16)
- sample_logprobs without params writes every row (a drafter's candidate logprobs)
- lili_cand, lili_attn, lili_factor, lili_walk: the correlator's candidates and features, its
  attention over the candidate lattice, the factor input and the greedy walk

ref_test, avx_check_hand and r4d_emu cases; docs/OPS.md.
2026-11-04 22:08:52 +01:00
keptn42 44490c859a libr4d: paged attention at head_dim 128 and gqa 16
Nemotron-H's attention layers have 32 query heads over 2 KV heads, gqa 16 at one and two ranks.
r4d_attn_paged_h128_gqa16.hip is the gqa8 body at that ratio: prefill blocks of 24 query
positions, decode q_len <= 4. Selftest cases at one rank.
2026-11-04 22:08:06 +01:00
keptn42 dccc6329a9 abi, sched: RadBatch::anchor_rows, ABI 36
A block drafter's query pass gets, for each drafting sequence, the row of its last committed
position in the context pass just run (StepSlot::hrow, written by the advance on the card).
LiLiCorr's correlator reads the context state there. Appended after bidi_used; main ships
ABI 35 and an appended field is read past the end of an older engine's copy, so the version is
36 and the layout table follows. The pass key reads the pointer.
2026-11-04 22:08:06 +01:00
keptn42 a1b7643310 core/format: read nemotron_h checkpoints
Nemotron-3.5-Bolt's config nests its language model under llm_config, which is now read as
text_config is; arrays of objects (Puzzle's block_configs) become flat keys,
block_configs.<i>.<field>; a checkpoint without num_hidden_layers counts layers_block_type; and a
drafter merged from its own checkpoint keeps its own quantisation (Checkpoint::imports_at).
2026-11-04 22:08:06 +01:00
keptn42 e6787b7bdd core/format: a stacked vector may have parts of different widths at TP > 1
Mamba-2's conv1d bias is x | B | C, 8192 | 1024 | 1024 wide. The share of a vector stacked from
parts was cut only when the parts were equally wide; the reader already lays the parts end to end,
so a vector's parts now add their widths. share_test: a stacked vector with parts of different
widths.
2026-11-04 22:08:06 +01:00
keptn42 394b8cd290 kbench: a kernel that lays out a weight table's experts is handed them laid out
A weight table reached every kernel as the tensor its planes decode to. libr4d's 4-bit grouped GEMMs
read each expert through their layout hooks (the w4 codes as R4D_DT_MOEW4, the E4M3 scales of
w4nl64a8h), so moe_gemm_w4a8 refused every case with "dtype this kernel does not serve", which
counts as a failure. Each expert is now laid out from its planes (the container's or
kf_draw_table's) and the entries are stacked one laid expert apart, while the oracle still reads
the decoded table. The container pass and the replay both do it, and a table counts as laid out
where the replay decides whether to compare exactly.

kfixture: kf_table_entry, kf_draw_entry_planes (kf_draw_table's per-expert draw, the same bytes)
and kf_lay_table. fixture_test: a table's experts are each laid out by the kernel.
2026-11-04 22:08:06 +01:00
keptn42 e0c3f971dc arch/common: DFlash2's split fc gathers its message as a range
The context pass's all_gather declared numel as a fixed crows * n_embd. crows is max_tok, so every
sizing declare (RadBuildCtx::shape_probe) changed a fixed parameter and was refused: with a
block-fp8 fc at TP > 1 no arena level was planned and nothing was lent to the expert slab. numel
is now a range with the trunk all-reduce's bound, issued at T * n_embd, as the reference reads it
(band_rows).

arch_test: the fc split's gather is the trunk's bound, as a range.
2026-11-04 22:08:06 +01:00
Deadcode 19d4e8fe0e radiance 1.17.0
IQR-V4 for Qwen3.8-27B:
- 15 recipes, data/recipes/q38-27b-iq2r-v4 .. q38-27b-iq8r-v4 (2.5 to 8 bits a weight), docs/IQR.md
  "IQR-V4". On the quantisation board's private split every entry has 2-19% less KL than its V3 twin
  of the same size (10-19% from 2.5 to 5.4 bits); IQ4R-L-V4 is 24% below the official FP8 checkpoint
  at 55% of its size, and IQ2R-L-V4 (2.8 bpw) is below the MXFP4 checkpoint. Containers with the
  DFlash2 drafter and the vision tower: huggingface.co/StillDeadcode/qwen3.8-27b-iqr-v4, served by
  deploy/compose/qwen3.8-27b-iqr-v4.yaml (IQR_V4 names the size)
- GPTQ runs in act order inside the column trellis (tcq_order=1); the head-fed projections
  (attn_output, ssm_out) take a bf16 scale a (row, 128) block from five bits up; widths from
  measured prices
- A vocabulary-weighted lm_head: four width classes of the computed trellis (output.k<B>), the
  tokens carrying the probability on the widest, decoded in one launch by logits_gemm_vocab with
  16-bit head activations; 0.62 ms at one token on a TP2 rank against the int8 head's 1.02 ms.
  tools/vhead.py and data/vhead/ build the class split from the bf16 checkpoint; libquant reads the
  head's input Hessian for every class
- At IQ6R-L and up, the int8 lm_head is GPTQ'd against its input Hessian (same bytes, median KL
  -8..-12%)
- embed_lookup_iqr takes u7/u8 tables under a zero point and the 4096-state trellis at 6 and 7 bits
- The whitepaper: radiance.stilldeadco.de/whitepapers/iqr-v4.pdf

Faster IQR kernels:
- The one-token GEMV gives each 16-row weight tile a block whose waves split K (5120 x 6144 at one
  token 42.3 -> 30.0 us), with a biased-int fold, a v_perm activation broadcast and one code stream
  a column
- A 16-token WMMA tile without block barriers serves 2 to 16 tokens (6- and 7-bit codes from one
  token): a 4-bit weight takes 0.52-0.66 of FP8's time from one token to sixteen, 1.15-1.74x V3's
  kernels from four tokens up
- The activation quantisers after the IQR gate_up (gemm_iqr_gated), the delta net's decode conv
  fold (gdn_conv_recurrent_update_had) and the attention gate (gate_had_quant_i8g) are folded into
  their producers, byte for byte the same codes: 128 fewer launches a decode step
- End to end on one R9700 (TP1, no speculation): IQ4R-S-V4 decodes one stream in 24.7 ms against
  the MXFP4 checkpoint's 25.8 at five times lower KL; IQ3R-S-V4 is faster than MXFP4 at 1 to 8
  streams. Prefill stays 8-9% behind MXFP4's 4-bit tile

Quantisation tooling:
- rescale=1 refits each row's scale to its codes after GPTQ; gptqsim measures a tensor's W16A16
  form (tcq_code=mad16); an int8 trunk's calibration Grams can be recorded from the codes its GEMMs
  read (--calib-dir, TP1)
- Fixed: the GPU trellis packs tcq_code=mad16's values two int16 a register

New models (merged):
- Spark 2.5 (spark25: bf16 and rotated-int8 IQ8R checkpoints, tensor parallelism with exact
  collectives, reasoning and tagged tool calls) with its DSpark drafter (exact attention and Markov
  walk ops), docs/SPARK25-IQ8R.md (@gostar)
- Ling-3.0-flash (bailing_hybrid: KDA, dense latent attention with mla_attn_paged, group-limited
  sigmoid routing, the clipped SwiGLU and its MTP layer as a serial drafter), its w4a8 recipes and
  compose files for four and two cards (@keptn42)
- Gemma 4 12B (gemma4_unified, served by the gemma4 plugins): its picture and audio embedders, a
  picture's placeholders read both ways on the sliding layers as the model was trained (the
  scheduler ends no prefill chunk inside such a run; RadBatch::n_bidi), windowed attention at
  head_dim 512, the assistant head as MTP drafter at one, two and four ranks, suppress_tokens from
  generation_config, bf16 and i8g compose files (@keptn42)

Merged:
- The prefill KV split sized by the live KV length rather than the model's max_ctx, recorded passes
  keyed by their split geometry, and --gpu-memory-mib, the inverse of --gpu-headroom-mib (@gostar)
- Possessive quantifiers in tokenizer patterns where the greedy reading provably matches the same
  (Ling-3.0's), and the Grafana dashboard's first screen of totals (@keptn42)
- The dashboard's history line (decode, prefill and TTFT over finished requests, kept in the
  browser, JSON export), session extremes that age and reset on a restart, card-count changes, an
  Advanced tab for the poll intervals, each request's prefill time from admission in /stats
  (prefill_s), and the page's JavaScript run by tests/js (@Memoria)
- From PR #390: the file tier reads a routed layer with its own router's counts and waits for its
  deposits; the stop-string hold-back keeps back only a tail that can still become a stop string
  (before, every delta waited up to the longest stop's length); the sampler's planes are sized by
  the step's token bound, the n-gram ban runs beside a drafter, and a top-1 row issues no candidate
  cut (@Code000)
- The n-gram reader refills its reads as they land, and a decode gather waits on the other rank's
  read of a row instead of reading it again (#369, @pokesjw)
- libr3d's GEMM structs value-initialised so the tape audit sees no padding (@RikshaDriver)

Added:
- --ngram-placement disk=DIR: the n-gram table read from its own file, DIR/ngram-<id>.bin, filled
  from the container at the first start, on a faster or separate drive (#130)

Fixed:
- input_reference's H.264 round trip runs on libopenh264, which the image carries, at a quantiser
  held at the crf (a side under 16 padded and cut back); a build with no H.264 encoder answers 501
  (#163)
- kvtier: at most 1024 session rows under one shared first block; with one shared prompt the list
  grew a row a request and prefill fell from 9k to 2.5k tok/s after 500K requests (#375)
- Speculative steps on an architecture with no pass-key callback keep their recorded passes under
  the live-KV prefill split

Plugin ABI 35:
- RadArgs::kv_used_max_h and wgp_count, RadBatch::kv_used_max_h and positions_h, the optional
  rad_arch_pass_key export and RAD_KERNEL_CAP_DYNAMIC_PREFILL_SPLIT; RadEncoderDecl::bidirectional
  and RadBatch's n_bidi runs. The layout fingerprint table is regenerated; out-of-tree plugins
  rebuild against 35

Thanks to @gostar, @keptn42, @Memoria, @Code000, @pokesjw and @RikshaDriver.
2026-11-04 18:56:58 +01:00
keptn42 3af8065cc6 deploy: Gemma 4 12B composes and README rows
gemma4-12b-bf16.yaml (two cards) and gemma4-12b-i8g.yaml (one card), both
with bf16 KV, MTP depth 3 and 1120 patches for pictures.
2026-11-04 07:21:07 +01:00
keptn42 a72686b7e7 sampler: read suppress_tokens
generation_config.json's suppress_tokens (Gemma 4: the end-of-image and
end-of-audio markers, ids 258883 and 258882) are never sampled. The ids
reach the sampler as SamplingParams::suppress_tokens and leave the row
the way a grammar's mask does. A container carries them already, as the
space-separated generation.suppress_tokens.
2026-11-04 07:21:07 +01:00
keptn42 c1c05e9029 gemma4_bf16: a picture longer than the window reads it with the window behind only
A run of more rows than `sliding_window` (1120 soft tokens against 1024)
is attended again with attn_paged_ahead, where the window bounds the keys
behind a row, as transformers' mask does. A shorter run keeps the
two-sided window, which is the same mask for it. Where no kernel serves
the ahead form, the two-sided one stays.
2026-11-04 07:21:07 +01:00
keptn42 a0ea6ad1ba libr4d: a non-causal window that bounds the keys behind a row only
attn_paged_ahead and attn_paged_qrow_ahead are attn_paged at causal 0
where `window` limits the keys behind a row and every later key of the
sequence is visible. The windowed kernels take it as a launch flag (h256,
1 to 8 queries per kv head). Gemma 4's sliding layers read a picture's
rows with transformers' mask, the window AND (causal OR the same
picture), which this is for a picture longer than the window. Emulator
cases for the scalar, split and WMMA kernels.
2026-11-04 07:21:07 +01:00
keptn42 eb3aa7eae7 r4d_emu: Gemma 4 picture runs read again non-causally up to the run end 2026-11-04 07:20:43 +01:00
keptn42 c6391e6ef9 gemma4_bf16: a picture's rows read both ways on the sliding layers
use_bidirectional_attention "vision" (the 12B and the 31B): each
sliding layer attends a run's rows again over the cache up to the
run's end without the causal bound, over their causal result. The
global layers stay causal, as transformers' Gemma 4 masks, KerasHub
and vLLM have it. RADIANCE_MEDIA_BIDI=0 keeps every layer causal.
2026-11-04 07:20:43 +01:00
keptn42 da7b911c64 abi, sched: placeholder runs read both ways
An encoder states that the language model reads a picture's or video
frame's placeholders both ways (RadEncoderDecl::bidirectional). The
scheduler then ends no prefill chunk inside such a run, and a trunk
pass names its runs and the keys their rows see (RadBatch::n_bidi).
Fields appended; such a pass is not recorded.
2026-11-04 07:20:43 +01:00
keptn42 81be3cb63d gemma4_bf16: the 12B's image and audio embedders
rad_block_gemma4_unified.h: LayerNorm, the dense with its bias,
LayerNorm, the column's and the row's position rows, LayerNorm (eps
1e-5), the weightless RMS norm and the projection; for audio the norm
and the projection. The position table is read as its two taps of
dimension 1, which a recipe stores (gemma4-12b-bf16, -i8g).
2026-11-04 07:20:29 +01:00
keptn42 a00e5e7094 mm: Gemma 4 12B's pictures and audio
The 12B (gemma4_unified) has no tower: its embedder takes a whole
48 x 48 pooling window as one patch, so a patch is a row (merge 1),
its values u / 255. Its audio is frames of 640 samples as they are,
one frame a token, the last zero-padded. Goldens from transformers.
2026-11-04 07:20:29 +01:00
keptn42 9782a9afb5 rad-convert: name the checkpoint tensors no declared weight reads
They are not written. A tower or head the plugin does not recognise was
left out without a word. A tensor beside one that is read (its scale)
counts as read.
2026-11-04 07:20:29 +01:00