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.
`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 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>
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 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).
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.
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.
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).
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>
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>
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.
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).
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>
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.
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>
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 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>
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>
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 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>
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>
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>
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>
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>
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.