arch, data/recipes, libr4d: the 31B's prefill overlap, q|k|v as one linear, RedHatAI's DFlash2, its fc split

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>
This commit is contained in:
AshlynandClaude Opus 5.5 authored and StillDeadcode committed 2026-10-21 09:48:20 +02:00
1 parent bdb37d5d16
commit 04e5480387
21 files changed
+1805 -199

No files matched your search

+44 -1
View File
@@ -17,7 +17,7 @@ plugin claims.
| `arch/glm5next` | `glm5next` | *(empty)* | GLM-5.3-Flash from AMD's Quark MXFP4 export: four mHC residual streams over 34 KDA and 11 sparse latent-attention (MLA) layers with a DSA indexer, 288 MXFP4 experts at top-8 under sigmoid routing, block-FP8 attention and dense layers at f32 scales, each weight served as stored; its MTP layer is a serial drafter. Text only, bf16 KV |
| `arch/lfm2_bf16` | `lfm2` | *(empty)* | LiquidAI's LFM2 and LFM2-VL, bf16, one rank |
| `arch/embgemma2` | `embeddinggemma2` | *(empty)* | EmbeddingGemma 2: a bidirectional encoder with Gemma 4's vision tower and audio conformer, pooled to one vector |
| `arch/gemma4_bf16` | `gemma4` | `compressed-tensors` | Gemma 4 31B dense with its vision tower: sliding-window and proportional-RoPE global (`attention_k_eq_v`) attention, GELU ffn, softcapped logits; int4 codes with an f16 scale per 128 from Google's CT-INT4 (QAT) release or from bf16, served w4a8, or int8 codes on the same grid from bf16 (w8a8, the Q8 container). Optional draft model (`rad-convert --draft-model`): Google's assistant, with no cache of its own (`rad_drafter_shared_kv`), or z-lab's DFlash drafter, the block `arch/gemma4` serves (`arch/common/rad_gemma4_dflash.h`) |
| `arch/gemma4_bf16` | `gemma4` | `compressed-tensors` | Gemma 4 31B dense with its vision tower: sliding-window and proportional-RoPE global (`attention_k_eq_v`) attention, GELU ffn, softcapped logits; int4 codes with an f16 scale per 128 from Google's CT-INT4 (QAT) release or from bf16, served w4a8, or int8 codes on the same grid from bf16 (w8a8, the Q8 container). Optional draft model (`rad-convert --draft-model`): Google's assistant, with no cache of its own (`rad_drafter_shared_kv`), or z-lab's DFlash drafter, the block `arch/gemma4` serves (`arch/common/rad_gemma4_dflash.h`), or RedHatAI's DFlash2 speculator (`arch/common/rad_block_dflash2.h`) |
| `arch/gemma3` | `gemma3` | *(empty)* | Gemma 3 dense text (TranslateGemma 27B) from the bf16 checkpoint: sliding-window and global attention at one head geometry, GemmaRMSNorm, GELU ffn; linears bf16, or int8, MXFP4 or asymmetric int4 over an activation scaled per (row, 128), as the recipe stores them. Optional DFlash2 drafter (`rad-convert --draft-model`) |
| `arch/gemma4` | `gemma4` | *(empty)* | Gemma 4 text from Google's bf16 checkpoint (the 26B-A4B MoE and the dense sizes without per-layer embeddings) with z-lab's DFlash drafter; routed experts bf16 or block fp8 |
| `arch/qwenimage21` | `qwenimage21` | *(empty)* | Qwen-Image 2.1 and 2.1-Turbo, an image generator, from the diffusers pipeline directory; DiT and text encoder bf16 or block fp8 |
@@ -745,6 +745,49 @@ hidden states and was trained beside the bf16 trunk. Both plugins scale the embe
sqrt(hidden) rounded to bf16, as the reference's embedding module does (73.5 at 5376, not 73.32),
and the drafter reads it through the same scale.
**The 31B's prefill overlap.** `arch/gemma4_bf16` cuts a prefill step of 1024 rows or more in two
(slice A whole 128-row tiles, both at least 512) and runs each slice's two all-reduces per layer on
the second lane beside the other slice's compute, as the prefill overlap above does, with one
difference: o_proj and down_proj both write `h`, so the issue order never lets lane 0 write rows of
`h` that lane 1 is reducing, and `h` is the one buffer taken out of the arena's sharing. Attention
runs whole. Both slices are above every row band the sliced kernels have (the int8 GEMMs' skinny
band at 64, since the prefill kernel takes each row's K in order whatever M is, and
r4d_act_threads' last width change at 120 rows for these widths), so on the exact wire the output
equals the whole step's bit for bit. Every junction must be fused, as the w4a8 and w8a8
containers' are; a bf16 trunk runs whole, and so does every step under `RADIANCE_GEMMA4_OVERLAP=0`.
**The 31B's q, k and v as one linear.** Converted with a recipe that names `blk.*.attn_qkv.weight`
(both -df recipes do), each layer's q, k and v (q and k on a global layer, where v is k) are one
weight, each rank holding its slice of every part, and one `gemm_nt_q` reads them where three did:
at decode on the R9700 q, k and v take 17 + 13.5 + 13.5 us and a 4096-row GEMM of the same K 25.
The grid's groups never cross a row, so the codes are those of three separate rules, and on libref
the replies are too. On libr4d the skinny GEMM picks its in-block K split from N (k and v alone
split K in two, the fused GEMM does not), so k and v can round differently in the last bit and a
long greedy reply can part from the old container's late. `qkv_norm_rope` and `kv_store` work on
the row's column slices in place. A global layer's
attention reads q in the row (`attn_paged_qrow`, the windowed kernel that serves head_dim 512 under
`attn_paged` too); a sliding layer's reads it there in a one-row step, and a taller step copies q
out with a `cast` for libr4d's h256/gqa2 kernels, which take 0.26-0.71 of the windowed kernel's
time. Without `qkv_norm_rope` (a CPU-only engine) q, k and v are copied out for the unfused
prologue. A container that holds the three apart serves as before: the plugin asks the weight's
encoding, which rad-convert answers from the recipe and a container from its entries.
**The 31B with a DFlash2 drafter.** RedHatAI's `gemma-4-31B-it-speculator.dflash2` is z-lab's
DFlash2 architecture trained with vLLM's speculators library: five Qwen3-shaped layers at 5376 (32
heads / 16 kv x 256, ffn 21504), every one on a 2048-token window and non-causal, the grouped
dynamic convolution and the candidate selector (rank 256, top-k 16), block 8 (seven drafts). The
31B serves it with the block qwen35_fp8 uses for Qwen3.8's (`arch/common/rad_block_dflash2.h`) in
place of z-lab's DFlash, when the container's drafter is a `DFlash2DraftModel`. Its config is in
the speculators layout: the speculator's keys at the top of `draft.` and the layers' under
`draft.transformer_layer_config.` (`drafter_layer_prefix`). Its `aux_hidden_state_layer_ids`
count as vLLM captures them, the residual entering a layer, so 1 17 29 47 59 tap the outputs of
layers 0 16 28 46 58 (`gemma4::dflash2_taps`). It was trained against the target's table as a
plain embedding and the target's head as a plain linear, so its lookup takes no Gemma scale and its
head no soft-cap. The -df2 recipe stores its head copy int8 (`head_i8`, read at w8a8) rather than
the 2-bit grid Qwen3.8's recipes use, so the selector ranks what an 8-bit head proposes. Its
attention is the sliding layers' h256 gqa-2 split-KV decode, non-causal. `run-gemma4-31b.sh`
takes it with `DRAFTER=df2`.
**The 31B's junctions at four ranks.** At two ranks every junction carries the all-reduce in front
of it (`ar_rmsnorm_quant_i8`). At four it does too, at decode heights. libr4d's
`ar_rmsnorm_quant_i8_4rank` is the exact four-rank one-shot with the junction as its epilogue,
+1
View File
@@ -3086,6 +3086,7 @@ reductions running on fewer blocks: Qwen3.8-27B's 41k-token prefill 9.5 s uncapp
| `RADIANCE_G3_CALIB_LAYERS` | `lo:hi`: `arch/gemma3`'s calibration tap over layers lo to hi - 1 only, to take a large model's Grams in passes (docs/ARCHITECTURES.md) |
| `RADIANCE_PROFILE_EVERY` | with `--profile-ops`, dump the per-op table every N steps (default 32) |
| `RADIANCE_LOG_STEPS` | log one line per step: its phase, sequences, and each one's token count and context (§4.5) |
| `RADIANCE_GEMMA4_OVERLAP` | the Gemma 4 31B's prefill overlap (`arch/gemma4_bf16`, two or more ranks, fused junctions, the exact all-reduce wire): a prefill step of 1024 rows or more runs as two slices, each slice's all-reduces on a second stream beside the other's compute. On by default; `0` turns it off and runs every step whole (the startup notes say which) |
| `RADIANCE_AR8_SHARD_WEIGHTS`, `RADIANCE_AR8_PIECES` | the eight-rank two-shot's shard weights (`auto`, the default, reads the PCIe links; `off`; or eight integers) and piece count, with `RADIANCE_AR8_SHARD_WEIGHTS_MIN_ELEMS` and `RADIANCE_AR8_PIECES_MIN_ELEMS` for the message size each starts at (§4.7) |
Engine development has its own instruments: `RADIANCE_DEBUG_*` (residual probes, routing and issue
+15 -2
View File
@@ -691,7 +691,7 @@ may not have arrived.
| `gemm_nt` | `M`(range) `N` `K` `dtype` | `a`, `b`w → `y` |
| `gemm_nt_f32` | `M`(range) `N` `K` `dtype` | `a`, `b`w → `y` |
| `gemm_nt_bias` | `M`(range) `N` `K` `dtype` `act`/opt | `a`, `b`w, `bias`w, `res`? → `y` |
| `gemm_nt_q` | `M`(range) `N` `K` `group` `dtype` `pb1`/opt `pb2`/opt | `a`, `a_scale`?, `b`w, `b_scale`w → `y`; `a_sum`?, `b_ref`w? |
| `gemm_nt_q` | `M`(range) `N` `K` `group` `dtype` `pb1`/opt `pb2`/opt `split_n`/opt | `a`, `a_scale`?, `b`w, `b_scale`w → `y`; `a_sum`?, `b_ref`w? |
| `gemm_nt_q_bias` | `M`(range) `N` `K` `group` `dtype` | `a`, `a_scale`, `b`w, `b_scale`w, `bias`w → `y` |
`nt` is A row-major `[M,K]` times B transposed `[N,K]`, giving `[M,N]`: the layout every weight in
@@ -726,7 +726,14 @@ weight element (n, k) is `(code - zero) * scale`, one f16 scale and one integer
`a_sum` is `quant_act_i8`'s `asum`, group-major `[K/group][Mpad]` with `Mpad = ceil(M/16)*16`. The
ParoQuant grids (the four 4- and 5-bit ones) take parts (`pb1`, `pb2`); `w2a8` and `w4a8_asym` do
not, and none has a bias form. libr4d's kernels compute the same products in another order (split-K
not, and none has a bias form.
`split_n` is the output width whose K split the call takes, when it is a row slice of a wider
linear (a rank's share of a weight whose rows do not divide among the ranks, issued as two slices).
libr4d's narrow fp8a8 and i8a8 kernels pick their K split from N alone, and the split sets the order
K partials are summed in, so a slice given the whole width sums each output as the whole linear
does and its outputs are the linear's to the bit. Absent, N. The host libraries never split K and
ignore it. libr4d's kernels compute the same products in another order (split-K
partials, the activation scale applied at the store); libavx folds the scales into its decoded rows,
each product rounding once where libref rounds each group's sub-sum. A `b_scale` that is not joined
at these grids has no zero to read and is refused (`RAD_E_DTYPE`). libref describes none of them
@@ -2094,6 +2101,12 @@ libr4d serves these at 2, 3, 4 and 8 ranks:
- `all_gather` at those widths rides the same instance as the wide `all_reduce` (`ar_gather_3rank`,
`_4rank`, `_8rank`).
With `row`, `all_gather`'s `y` may be the leading `world_size * row` columns of a wider buffer, and
`x` a `row`-wide window of a wider one (column views whose row pitch is whole 16-byte words): rows
are read and land at those pitches, and the rest of each row is left as it was. A linear split by
rows whose rank shares cut its scale blocks has each rank compute the whole blocks covering its
share and hand over the share's window, gathered into a tight output (arch/common's DFlash2 fc).
`min_bytes` is the byte floor under which a lossy row serves the message exactly. It is a parameter,
not a library constant, because it is a property of the link: compression pays only once the
transfer is bandwidth-bound, and for a decode step's few residual rows the rotate, pack and unpack