radiance 1.6.0

- Qwen-Image 2.1 and 2.1 Turbo: text to image and image edits over OpenAI's images API,
  /v1/images/generations and /v1/images/edits. An edit takes up to ten pictures and an optional
  mask, outside which the picture comes back exactly as it was; `background: transparent`, png,
  jpeg and webp output, `n` pictures from one prompt, streamed previews (`partial_images`), and
  vLLM-Omni's seed, negative_prompt with true_cfg_scale, num_inference_steps, width and height.
  arch/qwenimage21 serves the diffusers pipeline directory, converted with
  data/recipes/qwen-image-2.1-fp8.recipe (block fp8) or qwen-image-2.1-bf16.recipe.
  deploy/compose/qwen-image-2.1.yaml and qwen-image-2.1-turbo.yaml serve the fp8 containers on
  two cards. Two R9700s make a 2048x2048 picture in 61 s at the base model's 40 steps and in
  13 s with Turbo (56 and 12 s with --tp-wire wht6), a 1024x1024 one in 6.0 and 2.6 s. The
  models are under Qwen's research license, which is non-commercial
- an image generator is a program kind of its own (core/gen): an architecture declares its
  conditioning, denoising and decoding passes, and the driver runs the schedule, the pictures of
  a batch and the conditioning cache. An image model's /v1/models entry is its generator's name
  (qwen-image-2.1, qwen-image-2.1-turbo), and its capabilities and startup banner list only the
  images endpoints
- the tiled prefill GEMMs run their tiles in groups of activation bands, 16 for fp8 and 8 for
  bf16, so an operand larger than the 64 MB cache is read once a group instead of once a band. A
  bf16 GEMM with more than 64 MB of weight runs up to twice as fast
- fixed: a second lane opened in the middle of a step started beside work lane 0 had not
  finished. Gemma 4 26B-A4B opens its lane that way, so its first step after startup could read
  rows not yet written
- startup no longer warns about --checkpoint-slots when it was not passed, nor about an expert
  floor on a model with no experts
- the image's FFmpeg writes png, jpeg and webp (libwebp)
- for out-of-tree plugins: RAD_ABI_VERSION is 16. The op vocabulary gains the image generator's
  ops (conv2d_nhwc, ln_mod, ln_mod_quant_fp8, flow_euler, attn_prefix_self and others; docs/OPS.md,
  "Image generation"), and all_reduce takes an optional `overlap`. Plugins built against 1.5.0
  must be rebuilt
This commit is contained in:
Deadcode committed 2026-10-14 14:03:59 +02:00
1 parent b93b531f63
commit b068190326
66 files changed
+9035 -87

No files matched your search

+56
View File
@@ -16,6 +16,7 @@ into the id an architecture plugin claims.
| `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 (text): two attention classes — sliding-window and proportional-RoPE global (`attention_k_eq_v`) — over one GemmaRMSNorm stream, GELU ffn, two KV groups, softcapped logits, tied scaled embedding; served from a CT-INT4 (QAT w4a16) checkpoint as group-128 int4 codes with an f16 scale. Optional draft head: Google's assistant (`rad-convert --draft-model`), a serial head with no cache of its own (`rad_drafter_shared_kv`) |
| `arch/gemma4` | `gemma4` | *(empty)* | Gemma 4 text from Google's bf16 checkpoint — the 26B-A4B MoE (a dense and a routed arm side by side) and the dense sizes without per-layer embeddings — with z-lab's DFlash drafter; routed experts bf16 or block fp8, as the recipe chose |
| `arch/qwenimage21` | `qwenimage21` | *(empty)* | Qwen-Image 2.1 and 2.1-Turbo, an image GENERATOR: a Qwen3-VL-8B text encoder, a 32-block single-stream DiT and an RGBA VAE, from the diffusers pipeline directory; the DiT and text encoder bf16 or block fp8, as the recipe chose |
This document is the geometry of each, and the handful of readings that are **arithmetically
silent** — wrong in a way that produces fluent output and no error anywhere.
@@ -576,3 +577,58 @@ say so. arch_test holds the two live ranges to overlap.
that carries one is served with `--mm-max-patches 0`. An fp8 attention or dense arm — under a tenth
of the weight bytes, and the dense arm's 2112 is not whole 128-blocks either.
---
# `qwenimage21` — Qwen-Image 2.1 and 2.1-Turbo, an image generator
`arch/qwenimage21` declares a GENERATOR (`rad_declare_generator`), which makes the program a
three-pass one the engine drives through `core/gen`: COND once a request (the text encoder over the
prompt and its pictures, then the DiT over that prefix into the KV cache), DENOISE once a step (the
image's latent rows against the cached prefix), DECODE once an image (the VAE). It is served on
`/v1/images/generations` and `/v1/images/edits` ([GUIDE §5.6](GUIDE.md)); fp8 on one or two cards,
bf16 on two. The checkpoint is the diffusers pipeline directory, read as one.
```
text Qwen3-VL-8B-Instruct as released: 36 layers of 4096 (32 x 128, 8 kv heads), interleaved
M-RoPE over (t, h, w) at 24, 20, 20 pairs, theta 5e6; the vision tower's 27 layers with
deepstack taps 8, 16, 24 added to text layers 0..2 at the picture rows
OUTPUT: the last layer BEFORE the final norm, without the 14 tokens of the system turn
DiT 32 single-stream blocks of 4096 (32 x 128, gqa 1), SwiGLU 12288, q and k RMS-normed, no
biases; ONE modulation linear for every block (scale1, gate1, scale2, gate2 -- no shift,
tanh gates) over a LayerNorm without affine; rope over (t, h, w) at 8, 28, 28 adjacent
pairs, theta 1e4, the picture grid centred on zero; txt_in = RMSNorm (gain 1 + w),
linear, gelu-tanh, linear; timestep embedding at t * 1000, rounded
THE CONDITION IS A CAUSAL PREFIX: text and reference latents, modulated at t = 0,
block-causal (text causal, a picture bidirectional within itself); written to the KV
cache once, and a step runs only the image's rows, non-causal over prefix and self
VAE Wan 2.2's on one frame: RGBA in and out, 64 latent channels, 16x down, decoder widths
1152..144, one single-head 1152-wide attention in each middle block
schedule flow-matching Euler, exponential dynamic shift (0.5 at 256 tokens to 0.9 at 8192),
shift_terminal 0.02, 40 steps; Turbo: the 8 sigmas model_index.json lists, no guidance
```
The traps:
- **The noise is radiance's, not torch's.** A seed is a Philox stream (`abi/rad_philox.h`), element
(k, c) of image row k drawn at k * 64 + c, identical on every card count. Parity against diffusers
means handing diffusers the same latents; a NumPy port of the stream does.
- **The conditioning is modulated at t = 0**, not at the step's timestep: the prefix is written once,
and a step that re-modulated it would differ from the reference at every step after the first.
- **The text encoder's output skips the final norm.** Taking the normed output scales every row by
the norm's gain and leaves a picture that is plausible and wrong.
- **A reference picture is read twice**: by the VAE as RGBA in [-1, 1], and by the vision tower
composited on white, both after PIL's premultiplied Lanczos resize to the 1024x1024 area at its
own aspect, sides rounded to 32. A different resampler changes every token the picture becomes.
- **The Euler step rounds where diffusers does**: x' = bf16(x + bf16(bf16(sigma_next - sigma) * v)),
and guidance bf16(neg + bf16(cfg * bf16(pos - neg))). Unrounded is not more accurate here; it is a
different trajectory.
- **The VAE config's `temperal_downsample` is a boolean array**; a reader that drops booleans makes
every level look unscaled.
- **Alpha off the decoder is never exactly 255** (243..255 on an opaque picture). Reading it as
transparency makes every picture the model made a transparent one when it is edited again; the
server's cutoff is alpha 128, the mask's.
Measured against diffusers' own pipeline in bf16, from the same latents (1024x1024, 20 steps, PSNR):
bf16 TP2 33.9 dB for a prompt and 42.2 for an edit, where diffusers differs from itself by 32.6 to
34.4 dB across its own attention kernels; fp8 28.7 to 29.3 and 37.6 to 38.4; Turbo fp8 33.4 and
38.9 at its 8 steps.
+2
View File
@@ -134,6 +134,8 @@ the cards the engine runs on.
| `minicpm5-2b.yaml` | `minicpm5-2b-fp8.rad` | MiniCPM5-2B FP8 with its DSpark drafter |
| `minicpm5-2b-bf16.yaml` | `minicpm5-2b-bf16.rad` | MiniCPM5-2B in bf16 with its DSpark drafter |
| `embeddinggemma2.yaml` | `embeddinggemma2-bf16.rad` | EmbeddingGemma 2 in bf16: text, image, video and audio embeddings on one card |
| `qwen-image-2.1.yaml` | `qwen-image-2.1-fp8.rad` | Qwen-Image 2.1 as block fp8 on two cards: OpenAI's images API, generation and edits |
| `qwen-image-2.1-turbo.yaml` | `qwen-image-2.1-turbo-fp8.rad` | Qwen-Image 2.1 Turbo, the same in 8 steps |
The container names are the files the README's model table downloads or converts.
+74 -2
View File
@@ -340,6 +340,14 @@ rad-convert ~/models/ukisai/Swift-1.5-Qwen3.8-27b -o swift-27b-fp8.rad \
# arch/gemma4; docs/ARCHITECTURES.md says why down stays bf16 unless the experts were padded to 768)
rad-convert ~/models/google/gemma-4-26B-A4B-it -o gemma4-26b-a4b-df.rad \
--draft-model ~/models/z-lab/gemma-4-26B-A4B-it-DFlash --recipe data/recipes/gemma4-26b-a4b-df.recipe
# Qwen-Image 2.1 or 2.1-Turbo, an image model (§5.6): the diffusers pipeline directory is the
# checkpoint -- text encoder, DiT, VAE and the tokenizer together. fp8 blocks for the text encoder
# and the DiT (17 GB, one card or two), or the checkpoint's bf16 (31 GB, two cards)
rad-convert ~/models/Qwen/Qwen-Image-2.1 -o qwen-image-2.1-fp8.rad \
--recipe data/recipes/qwen-image-2.1-fp8.recipe
rad-convert ~/models/Qwen/Qwen-Image-2.1-Turbo -o qwen-image-2.1-turbo-fp8.rad \
--recipe data/recipes/qwen-image-2.1-fp8.recipe
```
A checkpoint directory's `model.safetensors.index.json` decides which shard each tensor is read
@@ -1237,6 +1245,7 @@ for a model that takes no images or video.
| `POST /v1/chat/completions` | chat, with tools, reasoning and streaming |
| `POST /v1/completions` | raw text completion |
| `POST /v1/embeddings` | needs a model with an embedding head, else 501 |
| `POST /v1/images/generations`, `POST /v1/images/edits` | OpenAI's images API, needs an image model (Qwen-Image 2.1), else 501 — §5.6 |
| `POST /v1/systemone` | LiquidAI d1's decisions over a state: named yes/no, choice and score questions answered as probabilities, nothing generated; needs a container converted as d1, else 501 — §5.12 |
| `POST /v1/messages`, `POST /v1/messages/count_tokens` | Anthropic's Messages API, for Claude Code and the Anthropic SDKs — §5.9 |
| `POST /v1/responses`, `POST /v1/responses/input_tokens` | OpenAI's Responses API, for Codex and the OpenAI SDKs' `responses` client — §5.9 |
@@ -1400,7 +1409,7 @@ refused, never dropped: an unconstrained 200 would leave you
parsing free prose against a schema you were told was enforced. `/v1/completions` has no template
in the way, so the same grammar works there — which is why the example above uses it.
### 5.6 Completions, embeddings, tokenising
### 5.6 Completions, embeddings, images, tokenising
```sh
curl -s http://localhost:8000/v1/completions -H 'Content-Type: application/json' \
@@ -1466,6 +1475,69 @@ cut at 30 seconds. `prompt_name` takes the names the model's sentence-transforme
states (`query`, `document`, `Retrieval-query`, `STS`, ...) and applies to text and content-part
inputs; a model that states a default prompt applies it when the request names none.
**An image model** (Qwen-Image 2.1 or 2.1-Turbo) serves OpenAI's images API and nothing else;
completions, chat and embeddings answer 501. Clients written against OpenAI's images endpoints
(Open WebUI, the OpenAI SDKs) work as they are; the picture always comes back in the response.
```sh
# a picture from a prompt: b64_json, 2048x2048 unless `size` says otherwise
curl -s http://localhost:8000/v1/images/generations -H 'Content-Type: application/json' \
-d '{"prompt":"a lighthouse at dusk, oil painting","size":"1536x1024","seed":7}'
# an edit: one picture or up to ten (`image[]`), multipart as OpenAI's SDKs send it
curl -s http://localhost:8000/v1/images/edits -F 'prompt=put a red scarf on the fox' \
-F 'image[]=@fox.png'
# repaint only where the mask is transparent; the rest comes back exactly as it was
curl -s http://localhost:8000/v1/images/edits -F 'prompt=a green wool hat' \
-F 'image=@fox.png' -F 'mask=@mask.png'
# progress as server-sent events: `partial_images` previews, then the picture
curl -sN http://localhost:8000/v1/images/generations -H 'Content-Type: application/json' \
-d '{"prompt":"a red apple, product shot","background":"transparent","stream":true,
"partial_images":2}'
```
| field | |
|---|---|
| `prompt` | required |
| `size` | `WxH` or `auto`; each side is rounded down to a multiple of 32. `auto` is the model's native 2048x2048, and for an edit the last picture's aspect at that area. Larger than the model makes (16800 latent tokens, about 2400x1792) is refused |
| `n` | pictures from one prompt, 1..16; picture i uses seed + i |
| `seed` | the noise; the same seed, prompt and size give the same picture |
| `quality` | `auto`/`high` the model's step count (40 for 2.1), `medium` three quarters, `low` half |
| `num_inference_steps` | the step count itself; refused by a model with a fixed schedule (Turbo: 8) |
| `negative_prompt`, `true_cfg_scale` | guidance against the negative prompt, at twice the cost of a step; `true_cfg_scale` above 1 needs a `negative_prompt` |
| `background` | `transparent` asks the model for one (png or webp), `opaque` flattens on white, `auto` keeps the transparency of an edit's input and is opaque otherwise |
| `output_format`, `output_compression` | `png` (default), `jpeg` or `webp`; compression 0..100 for jpeg and webp |
| `stream`, `partial_images` | OpenAI's `image_generation.partial_image` / `image_edit.partial_image` events, 0..3 previews of the clean picture the step predicts, then `.completed` |
| `image`, `image[]`, `mask` | an edit's pictures (png, jpeg, webp; up to ten) and the first picture's mask: alpha below 128 is where the picture may change |
`response_format: url` is refused: nothing here stores a picture to serve later. The response
carries `usage` (input tokens: the prompt and the pictures' tokens; output: latent tokens) and
each picture's `seed` and `revised_prompt` (the prompt as given).
On two cards the step's two all-reduces of the image's rows (128 MB each at 2048x2048, over the
cards' link) run on a second stream: the rows go through each block in two halves, and one half's
all-reduce travels while the card computes the other's. `--tp-wire wht6` sends them as 6-bit and
makes a picture about 9% faster still (2048x2048, 40 steps: 61 -> 56 s; Turbo 12.9 -> 11.9 s, at
1024x1024 2.6 -> 2.2 s), within a dB of the exact wire against diffusers. Exact is the default.
The VAE decoder is split by rows across the cards after its mid-block, with the same pixels.
On an fp8 container the denoising attention computes its scores in int8 (about 16% faster
attention); a picture moves by less than switching between two exact attention implementations
moves it. A bf16 container keeps bf16 scores.
Two cards (`--tp 2`) are the fastest picture; two servers of one card each make the most
pictures an hour (each takes 1.7x as long and there are two). A card runs these models at its
300 W limit, in the DiT's GEMMs and attention alike.
A reference picture costs 4096 rows of the conditioning's KV cache at the model's 1024x1024
reference area -- its latent rows, which take its vision tokens' places. One card holds the fp8
container and a cache of 20256 rows: four pictures with their prompt. Two cards (`--tp 2`) hold
all ten the model takes, and the bf16 container. A request the cache can never hold is a 400
that says how many rows it needed. The models are under Qwen's research license,
non-commercial.
### 5.7 Request fields
| field | notes |
@@ -1957,7 +2029,7 @@ of a log to paste into an issue.
fix. Every warning is also printed as a `W` line of its own.
```
I STARTUP REPORT -- radiance 1.5.0
I STARTUP REPORT -- radiance 1.6.0
I CONFIGURATION -- every option, the value in force, and where it came from
I --model /models/flashnext.rad [command line]
I --tp 2 [command line]
+93 -1
View File
@@ -694,6 +694,95 @@ nearly cancel the ULP comes out as a few percent and the transcript moves after
The kernel reproduces the reference's fold exactly: the widths above the head dim contribute zeros
and adding 0.0f is exact, so a block sum over 8 wave partials and over 32 are the same number.
## Image generation
The ops a diffusion image generator declares (`rad_declare_generator`, abi/rad_builder.h): a
single-stream diffusion transformer's adaptive norm and gated residual, the timestep embedding, the
per-image latent LANES and the flow-matching sampler over them, attention over a cached
conditioning prefix, and an image decoder's convolution, channel norm, resampling shortcuts and
pixel output. Each rounds where the reference model materialises a bf16 tensor; the libref
function says which (libref/ref_gen.cpp).
| op | params | operands |
|---|---|---|
| `ln_mod` | `M`(range) `n` `eps`:f64 `dtype` | `x`, `s`, `cu_seqlens` → `y` |
| `gate_add` | `M`(range) `n` `dtype` | `y`, `g`, `cu_seqlens`, `x`:inout |
| `ln_mod_quant_fp8` | `M`(range) `n` `eps`:f64 `group` `gated` `dtype` | `y`?, `g`?, `s`, `cu_seqlens`, `x`:inout → `q`, `scale`, `z`? |
| `timestep_embed` | `M`(range) `n` `scale`:f64 `max_period`:f64 `round`/opt `dtype` | `t` → `y` |
| `gather_rows2` | `M`(range) `n` `dtype` | `a`, `b`, `idx` → `y` |
| `lane_gather` | `M`(range) `n` `stride` `dtype` | `src`, `lane`, `cu_seqlens` → `y` |
| `lane_store` | `M`(range) `n` `stride` `dtype` | `src`, `lane`, `dst`:inout |
| `randn_lanes` | `M`(range) `n` `stride` `dtype` | `flags`, `seed`, `lane`, `cu_seqlens`, `dst`:inout |
| `flow_euler` | `M`(range) `n` `stride` `dtype` | `v`, `sigma`, `sigma_next`, `cfg`, `pair`, `lane`, `flags`, `seed`, `cu_seqlens`, `inp_lat`?, `inp_mask`?, `state`:inout, `preview`:inout? |
| `chan_affine` | `M`(range) `n` `mul` `add` `mode` `dtype` | `x` → `y` |
| `conv2d_nhwc` | `M`(range) `cin` `cout` `k` `stride` `pad` `up` `dtype` | `x`, `w`w, `b`w → `y` |
| `l2norm_chan` | `M`(range) `n` `act` `dtype` | `x`, `gamma`w → `y` |
| `d2s_add` | `M`(range) `cin` `cout` `ft` `dtype` | `x`, `y`:inout |
| `s2d_avg_add` | `M`(range) `cin` `cout` `ft` `dtype` | `x`, `y`:inout |
| `to_rgba8` | `M`(range) `n` `dtype` | `x` → `y` |
| `gelu_tanh` | `M`(range) `n` `dtype` | `x` → `y` |
| `scatter_add_rows` | `M`(range) `n` `dtype` | `v`, `idx`, `x`:inout |
| `attn_prefix_self` | `q_len` `head_dim` `gqa` `block_size`/der `causal` `q_dtype` `kv_dtype` `scale`:f64/opt `max_ctx`/opt `n_head`/opt `max_seqs`/opt `qk`/opt | `q`, `k`, `v`, `kv_cache`, `block_table`, `seqused`, `cu_seqlens`, `k_descale`?, `v_descale`?, `k_i8`?, `k_scale`? → `out` |
**Sequences and lanes.** `cu_seqlens` partitions the rows into entries (`[n_seq+1]` i32, entry `e`
owning `[cu[e], cu[e+1])`; it need not start at 0). `ln_mod` and `gate_add` take each row's
modulation row from `s`/`g`, `[n_seq, >= n]` at its own row pitch -- a column slice of one shared
modulation projection. A LANE is one image's latent in a per-image state buffer, `stride` rows
apart: `lane_gather` copies entry `e`'s rows out of lane `lane[e]`, `lane_store` copies one
source into every listed lane (a repainted picture's latent into each of its images).
- `ln_mod`: `y = bf16(bf16(LN(x)) * bf16(1 + s[seq]))`, a layer norm with no gain and no bias.
- `gate_add`: `x = bf16(x + bf16(bf16(tanh(g[seq])) * y))`.
- `ln_mod_quant_fp8`: with `gated` 1, `gate_add` first; then `z = ln_mod(x)` and
`(q, scale) = quant_act_fp8(z, group)`, `z` written when bound -- the three in one pass, each
rounded as its own store would round it, so the bytes are the three ops'.
- `timestep_embed`: `[cos | sin]` of `t' * f_i`, `f_i = exp(-ln(max_period) * i / (n/2))` in f32,
`t' = scale * t`; with `round` 1, `t' = scale * bf16(bf16(t * scale) / scale)` -- the value
diffusers' pipeline hands its transformer. `t` is f32 `[M]`.
- `gather_rows2`: `y[i] = idx[i] >= 0 ? a[idx[i]] : b[-1 - idx[i]]`, zeros past either source.
- `randn_lanes`: for entries whose `flags` carry 1, the lane's rows become the entry's seed's
standard-normal stream (abi/rad_philox.h), element `(k, c)` the stream's `k * n + c`. `seed` is
`[n_seq, 2]` u32, low word first.
- `flow_euler`: for every entry with `pair != -2` (an entry that IS a negative conditioning moves
no lane), `v' = pair >= 0 ? bf16(neg + bf16(cfg * bf16(v - neg))) : v`, `neg` the paired entry's
rows; flag 4 writes `bf16(x - sigma * v')` to the lane's `preview`; then
`x' = bf16(x + bf16(bf16(sigma_next - sigma) * v'))`; flag 2 restores the kept region,
`x' = bf16(m x' + (1 - m)((1 - sigma_next) src + sigma_next noise))` with `m` the lane's f32
`inp_mask` row, `src` its `inp_lat` row and `noise` the seed's stream.
**Images** are `[height, width * channels]`, dense, and the ops read both sizes off the operand
shapes: an image's size is a request's, and a parameter is fixed at declare.
- `conv2d_nhwc`: `w` is PyTorch's `[cout, cin, k, k]` (a kernel may store it permuted through its
layout hook), `b` `[cout]`; `up` 2 reads the input upsampled 2x nearest-neighbour; `pad` `same`
is `k/2` zeros a side, `down` is none above and left and one below and right (`ZeroPad2d((0,1,0,1))`
before a stride-2 conv). f32 accumulation, the bias added, one rounding.
- `l2norm_chan`: each pixel's channels to unit L2 (eps 1e-12), times `sqrt(n)`, times `gamma` --
three roundings -- then `act` `none` or `silu`.
- `chan_affine`: `mul` and `add` are space-separated lists of `n` values, each rounded to bf16;
`fma` is `bf16(bf16(x * mul) + add)`, `inv` is `bf16(bf16(x - add) / mul)`.
- `d2s_add` (Wan's DupUp3D on one frame): `y[2r+i, 2c+j, o] += x[r, c, (o F + off + 2i + j) /
rep]`, `F = 4 ft`, `off = 4` when `ft` is 2, `rep = cout F / cin`.
- `s2d_avg_add` (AvgDown3D on one frame): `y` gains the mean of each output channel's group of
`cin F / cout` dealt values, a dealt channel being `(c, t, i, j)` at `c F + 4t + 2i + j`; with
`ft` 2 the frame `t = 0` is the zero frame the reference pads in, which the mean still counts.
- `to_rgba8`: `round(clamp(bf16(bf16(clamp(x, -1, 1) / 2) + 0.5), 0, 1) * 255)`, u8 out.
**`attn_prefix_self`** attends over two key sources: entry `s`'s first `seqused[s]` keys in the
paged cache, all visible, and the pass's own rows `k`/`v` beside `q` (dense, at their own pitch,
rows indexed as `q`'s), of which row `i` sees `j <= i` with `causal` and all of them without. It
is an image's latent rows against its conditioning, and one segment of a conditioning against the
segments before it. `qk` `"i8"` is the int8 score form and takes `k_i8` [tokens, kv_heads *
head_dim] and `k_scale` [tokens, kv_heads] f32, the own keys as `quant_act_i8g` writes them at
group `head_dim`; the query and every prefix key are quantised inside the op by the same rule
(scale `amax/127`, 1 for an all-zero row; code `rint(clamp(x * (1/scale), +-127))`) and a score is
the exact integer dot product times both scales. `k` is then not read for the own rows.
`qk_norm_rope` takes two more `mode`s for these models: `gptj_blocks` is `blocks` with each
section's pairs ADJACENT, `(start + 2j, start + 2j + 1)` -- a 3-axis image rotary's complex form
-- and `imrope` is the interleaved M-RoPE of Qwen3-VL's text attention over NeoX pairs (`rope`'s
`imrope`), reading three position planes.
## Mixture of experts
| op | params | operands |
@@ -977,7 +1066,7 @@ and the third is what needs the token stride carried separately.
| op | params | operands |
|---|---|---|
| `all_reduce` | `world_size` `numel`(range) `dtype` `exact` `min_bytes`/opt `hops`/opt | `x`:inout, `y`:out? |
| `all_reduce` | `world_size` `numel`(range) `dtype` `exact` `min_bytes`/opt `hops`/opt `overlap`/opt | `x`:inout, `y`:out? |
| `all_gather` | `world_size` `numel` `dtype` `row`/opt | `x` → `y` |
`exact` separates the exact sum from the quantised wire, and a caller has to say which it wants: a
@@ -988,6 +1077,9 @@ libr4d separates one-shot from two-shot, at a width that has both, by message si
rows start above 524288 elements, which makes that a band edge of the ranged `numel`, so a caller
states nothing for it. `hops` is a caller's request for one or the other (1 or 2); libref accepts
and ignores it, and no libr4d row reads it. Every all-reduce kernel serves `y` absent, in place.
`overlap` 1 says the caller issues the collective on its second lane, beside compute: libr4d then
serves it with rows whose launch is narrow (8 blocks of 256 threads at two ranks), which compute
the same bits and leave the CUs to the kernels running beside them; libref ignores it.
libr4d serves these at **2, 3, 4 and 8 ranks**. Two ranks have their own kernels (one flag word a
block, the rotated 6-bit wire, the fused norm-and-reduce forms). The wide family is one template on