Archived
radiance 1.7.0
- every model serves without a GPU: libavx covers every op, so `--kernels libavx` alone serves every shipped container - Qwen3-ASR (zivius): speech to text on /v1/audio/transcriptions and live over /v1/realtime - /v1/messages works with Claude Code as it ships (gearwave00001) - a long agent conversation keeps its cached history when the client rewrites its last turn (manueloverride) - a stream's first event goes out with the first token, so llama-benchy measures prefill right - opt-in --prefill-interleave (Smellyyyy, baKon) and --prefill-span (keptn42) - four-rank TP releases the link early; four-rank selftests and docs/TP4.md (goodman-b) - NVFP4 and FP8 compressed-tensors imports (devmilan); tools/rad-export for finetunes and LoRA adapters (baKon) - many fixes, among them lost tokens on stop strings under concurrency, keep-alive, MiniCPM5 tool arguments and the CPU's vision and audio encoders - plugin ABI 17 and changed op schemas: out-of-tree plugins must be rebuilt
This commit is contained in:
1 parent
b068190326
commit
1e968f6e1d
739 files changed
+128447
-84632
No files matched your search
+341
-333
@@ -1,68 +1,64 @@
|
||||
# Architectures — the geometry, and the traps that stay plausible when wrong
|
||||
# Architectures: geometry and traps
|
||||
|
||||
One architecture plugin claims one **(architecture id, quantisation descriptor)** pair — that is the
|
||||
selection key of `spec.md` §2.4, and it is why a family with two checkpoint formats is two `.so`
|
||||
files rather than one that branches. `rad-convert` normalises whatever it read (safetensors or GGUF)
|
||||
into the id an architecture plugin claims.
|
||||
An architecture plugin claims one **(architecture id, quantisation descriptor)** pair, the
|
||||
selection key of `spec.md` §2.4, so a family with two checkpoint formats is two `.so` files rather
|
||||
than one that branches. `rad-convert` normalises what it reads (safetensors or GGUF) into the id a
|
||||
plugin claims.
|
||||
|
||||
| plugin | id | quantisation | what it serves |
|
||||
|---|---|---|---|
|
||||
| `arch/llama_fp8` | `llama` | `fp8_e4m3` | the plain LLaMA decoder, from a checkpoint that already holds E4M3 codes and a `weight_scale_inv` plane |
|
||||
| `arch/llama_dense_fp8` | `llama` | *(empty)* | the same graph from a bf16 checkpoint; `rad-convert` quantises. MiniCPM5-2B |
|
||||
| `arch/llama_fp8` | `llama` | `fp8_e4m3` | the plain LLaMA decoder, from a checkpoint that holds E4M3 codes and a `weight_scale_inv` plane |
|
||||
| `arch/llama_dense_fp8` | `llama` | *(empty)* | the same graph from a bf16 checkpoint, linears made block fp8 by a recipe or kept bf16. MiniCPM5-2B |
|
||||
| `arch/qwen35_bf16` | `qwen35` | *(empty)* | the Qwen3.5/3.6/3.8 dense hybrid, served bf16 |
|
||||
| `arch/qwen35_fp8` | `qwen35` | `fp8_e4m3` | the same, block-scaled FP8 weights and activations |
|
||||
| `arch/qwen35moe_fp8` | `qwen35moe` | `fp8_e4m3` | `qwen35_fp8` with the feed-forward routed |
|
||||
| `arch/qwen4exp_fp8` | `qwen4exp` | *(empty)* | Qwen4-Exp (Qwen3.8-Flash-Next), a bf16 checkpoint quantised at convert |
|
||||
| `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 (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 |
|
||||
| `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, served w4a8. Optional draft head: Google's assistant (`rad-convert --draft-model`), 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 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 |
|
||||
| `arch/qwen3asr_bf16` | `qwen3asr` | *(empty)* | Qwen3-ASR: a Whisper-style audio encoder over a dense Qwen3 decoder, speech to text |
|
||||
|
||||
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.
|
||||
The traps below are readings that are wrong without any error: the model produces fluent output.
|
||||
|
||||
## The rule that applies to all of them
|
||||
## Common rule
|
||||
|
||||
**`head_dim` is READ, never derived.** On the Qwen hybrids `head_dim` is 256 while
|
||||
`hidden_size / num_attention_heads` is 213, so a derived value makes every downstream shape silently
|
||||
wrong — the projection widths, the KV page size, the attention kernel's band. `core/engine_bringup.cpp`
|
||||
takes it from the container's meta and says so at the line that does it.
|
||||
**`head_dim` is read, never derived.** On the Qwen hybrids `head_dim` is 256 while
|
||||
`hidden_size / num_attention_heads` is 213, and a derived value silently breaks the projection
|
||||
widths, the KV page size and the attention kernel's band. `core/engine_bringup.cpp` takes it from
|
||||
the container's meta.
|
||||
|
||||
---
|
||||
|
||||
# `llama` — the plain decoder
|
||||
# `llama`: the plain decoder
|
||||
|
||||
`model_type: llama` with `LlamaForCausalLM`, the most widely shared decoder shape there is. Every
|
||||
layer is full attention; there is no gated delta net, no layer schedule, no output gate and no
|
||||
per-head q/k norm, which is precisely what separates this plugin from `qwen35_fp8`.
|
||||
`model_type: llama` with `LlamaForCausalLM`. Every layer is full attention; unlike `qwen35_fp8`
|
||||
there is no gated delta net, layer schedule, output gate or per-head q/k norm.
|
||||
|
||||
MiniCPM5-2B is what it exists for: 42 layers, hidden 2048, 16 query heads over 2 KV heads at
|
||||
`head_dim` 128, SwiGLU at 6144, RMS norms, full rotary at theta 5e6, an untied 130560-row head, and
|
||||
no biases anywhere.
|
||||
MiniCPM5-2B: 42 layers, hidden 2048, 16 query heads over 2 KV heads at `head_dim` 128, SwiGLU at
|
||||
6144, RMS norms, full rotary at theta 5e6, an untied 130560-row head, no biases.
|
||||
|
||||
**Two checkpoint formats, one graph.** OpenBMB publishes MiniCPM5-2B in bf16 and nothing else, so
|
||||
"MiniCPM5-2B FP8A8" is a statement about what this engine *runs*, not about what the checkpoint
|
||||
holds. `llama_dense_fp8` declares the empty quantisation descriptor and the recipe
|
||||
`data/recipes/minicpm5-2b-dspark.recipe` does the work at conversion — libquant's `rtn`, one amax
|
||||
per 128x128 block, `scale = amax/448` rounded to bf16 — so the container holds the encoding a
|
||||
checkpoint that shipped fp8 would. Both plugins declare the same ops over the same encoding, and the
|
||||
kernels lay it out the same way at load, so nothing downstream can tell which one ran. For the same
|
||||
reason the bf16 checkpoint itself is not served directly: its linears are not the fp8 this plugin
|
||||
reads.
|
||||
**Two checkpoint formats, one graph.** OpenBMB publishes MiniCPM5-2B only in bf16, so
|
||||
`llama_dense_fp8` declares the empty quantisation descriptor and the recipe
|
||||
`data/recipes/minicpm5-2b-dspark.recipe` quantises at convert (libquant's `rtn`, one amax per
|
||||
128x128 block, `scale = amax/448` rounded to bf16). The container then holds what an fp8 release
|
||||
would, both plugins declare the same ops over it, and nothing downstream can tell which one ran. A
|
||||
container whose linears are left bf16 (`minicpm5-2b-bf16-dspark.recipe`) is read by `gemm_nt`.
|
||||
|
||||
What is fp8: `self_attn.{q,k,v,o}_proj` and `mlp.{gate,up,down}_proj`, each with a bf16
|
||||
`[N/128][K/128]` scale plane. What is not: every norm and the embedding. The lm_head is declared at
|
||||
whatever the source holds — bf16 from a checkpoint, fp8 where the recipe made it so — and the
|
||||
selection picks the GEMM that reads it. Both vocabulary edges are row-sharded.
|
||||
fp8: `self_attn.{q,k,v,o}_proj` and `mlp.{gate,up,down}_proj`, each with a bf16 `[N/128][K/128]`
|
||||
scale plane. Not fp8: every norm and the embedding. The lm_head is declared at whatever the source
|
||||
holds (bf16 from a checkpoint, fp8 where the recipe made it so), and the GEMM that reads that
|
||||
encoding is selected. Both vocabulary edges are row-sharded.
|
||||
|
||||
---
|
||||
|
||||
# `qwen35` — the hybrid Gated DeltaNet / gated-attention family
|
||||
# `qwen35`: the hybrid Gated DeltaNet / gated-attention family
|
||||
|
||||
Qwen3.5, Qwen3.6 and Qwen3.8 dense models share this architecture; HuggingFace calls it
|
||||
`model_type: qwen3_5` (`Qwen3_5ForConditionalGeneration`) and GGUF calls it `qwen35`.
|
||||
Qwen3.5, Qwen3.6 and Qwen3.8 dense models. HuggingFace calls it `model_type: qwen3_5`
|
||||
(`Qwen3_5ForConditionalGeneration`); GGUF calls it `qwen35`.
|
||||
|
||||
## Qwen3.8-27B-FP8, exactly
|
||||
## Qwen3.8-27B-FP8
|
||||
|
||||
```
|
||||
64 layers, full_attention_interval 4 -> layers 3,7,...,63 are FULL ATTENTION (16 of them)
|
||||
@@ -82,10 +78,7 @@ quantization: fp8 e4m3, activation_scheme "dynamic", per-weight `weight_scale_in
|
||||
vision: 27 blocks, hidden 1152, 16 heads -> head_dim 72, patch 16, out_hidden_size 5120
|
||||
```
|
||||
|
||||
### Why this lines up with libr4d
|
||||
|
||||
Every geometry above lines up with a libr4d entry point, which is the strongest available evidence
|
||||
that the kernel-plugin constraint model is the right shape.
|
||||
### libr4d entry points
|
||||
|
||||
| model geometry | libr4d entry point |
|
||||
|---|---|
|
||||
@@ -97,11 +90,12 @@ that the kernel-plugin constraint model is the right shape.
|
||||
| GDN gated norm over an interleaved z | `gdn_gated_norm_had_quant_i8` (`zgrp`/`zblk`) |
|
||||
| vision head_dim 72 | `attn_vit_h72_bf16` |
|
||||
|
||||
## Tensor names — the FP8 safetensors checkpoint
|
||||
## Tensor names: the FP8 safetensors checkpoint
|
||||
|
||||
Sharded one file per layer (`layers-N.safetensors`), plus `outside.safetensors` and
|
||||
`mtp.safetensors`. Every FP8 weight carries a companion `weight_scale_inv`; the norms, biases,
|
||||
`A_log`, `dt_bias` and `conv1d` stay bf16.
|
||||
`mtp.safetensors`. Every FP8 weight has a companion `weight_scale_inv`; the norms, biases, `A_log`,
|
||||
`dt_bias` and `conv1d` stay bf16. Linear shapes below are `[in, out]`, as the plugins write them;
|
||||
the safetensors tensors are stored `[out, in]`.
|
||||
|
||||
**Full-attention layer** (`model.language_model.layers.N.`):
|
||||
```
|
||||
@@ -129,14 +123,14 @@ mlp.{gate,up,down}_proj as above
|
||||
```
|
||||
|
||||
**Model level**: `model.language_model.embed_tokens.weight`, `model.language_model.norm.weight`,
|
||||
`lm_head.weight` (**not tied** on this model), and the MTP head: `mtp.fc.weight`,
|
||||
`mtp.norm.weight`, `mtp.pre_fc_norm_embedding.weight`, `mtp.pre_fc_norm_hidden.weight`.
|
||||
`lm_head.weight` (not tied on this model), and the MTP head: `mtp.fc.weight`, `mtp.norm.weight`,
|
||||
`mtp.pre_fc_norm_embedding.weight`, `mtp.pre_fc_norm_hidden.weight`.
|
||||
|
||||
## The full-attention layer — gated attention
|
||||
## Full-attention layer: gated attention
|
||||
|
||||
`q_proj` produces the query **and a gate, interleaved per head**: for each of the 24 heads the
|
||||
first 256 elements are the query and the next 256 are the gate, so both are strided views with
|
||||
pitch 512 rather than a contiguous split.
|
||||
first 256 elements are the query and the next 256 the gate, so both are strided views with pitch
|
||||
512.
|
||||
|
||||
```
|
||||
qg = gemm(x, q_proj) [n_tok, 12288]
|
||||
@@ -151,11 +145,11 @@ o = o * sigmoid(gate) <-- the gate. output_gate_type "swish
|
||||
out = gemm(o, o_proj)
|
||||
```
|
||||
|
||||
`qk_norm_rope_gate` does the two norms, the rope and the gate extraction in one kernel and takes the
|
||||
interleaving off the `q_gate` operand's own row pitch, so the projection is declared as it is laid
|
||||
out rather than converted at load. Declare it first and fall back to the unfused sequence.
|
||||
`qk_norm_rope_gate` does the two norms, the rope and the gate extraction in one kernel, taking the
|
||||
interleave from the `q_gate` operand's row pitch, so the projection is declared as laid out rather
|
||||
than converted at load. Declare it first and fall back to the unfused sequence.
|
||||
|
||||
## The linear layer — gated delta net
|
||||
## Linear layer: gated delta net
|
||||
|
||||
```
|
||||
qkv = gemm(x, in_proj_qkv) [n_tok, 10240]
|
||||
@@ -171,29 +165,27 @@ o = rmsnorm(o, linear_attn.norm) * silu(z) the gated norm
|
||||
out = gemm(o, out_proj)
|
||||
```
|
||||
|
||||
`linear_num_value_heads` (48) is three times `linear_num_key_heads` (16), so q and k are shared
|
||||
across three value heads. libr4d's GDN kernels take `H` and `Hg` separately for exactly this.
|
||||
`linear_num_value_heads` (48) is three times `linear_num_key_heads` (16), so each q/k head serves
|
||||
three value heads; libr4d's GDN kernels take `H` and `Hg` separately for this.
|
||||
|
||||
## Things that stay plausible when wrong, so get them right
|
||||
## Traps
|
||||
|
||||
- **`q`/`k` use L2 normalisation, not RMS.** Different op, different arithmetic.
|
||||
- **`A_log` is a log.** In the GGUF conversion `ssm_a` is already `-exp(A_log)`; in *this*
|
||||
safetensors checkpoint the tensor is named `A_log` and the exponent has **not** been taken. The
|
||||
converter is the component that decides which convention reaches the kernel, and it must say so.
|
||||
- **`q`/`k` use L2 normalisation, not RMS.**
|
||||
- **`A_log` is a log.** In the GGUF conversion `ssm_a` is already `-exp(A_log)`; in this safetensors
|
||||
checkpoint the tensor is `A_log` with the exponent not taken. The converter decides which
|
||||
convention reaches the kernel, and must say so.
|
||||
- **The GDN output gate is `silu` here and `sigmoid` on Qwen4-Exp.** `RMSNormGated` defaults to silu
|
||||
and every Qwen3.5/3.6 release leaves it there; Qwen4-Exp states `output_gate_type: "sigmoid"` and
|
||||
means it. A gate of `sigmoid(z)` where the model wants `silu(z)` rescales every value head's
|
||||
output — a config read, not a kernel to write. `arch/common/rad_block_gdn_fp8.h` refuses anything
|
||||
but those two names.
|
||||
- **Two readings the checkpoint cannot settle by inspection.** The rope convention (`neox`, halves,
|
||||
against `gptj`, adjacent pairs) and which half of each head's `q|gate` pair is the query are both
|
||||
self-consistent either way, and the sigmoid accepts either half — so no per-op check can reach
|
||||
them. The MTP head's concat order (hidden-first or embedding-first) is the third of the same kind.
|
||||
Each is a declared knob at the site that reads it, for the same reason.
|
||||
and every Qwen3.5/3.6 release keeps it; Qwen4-Exp sets `output_gate_type: "sigmoid"`. The wrong
|
||||
gate rescales every value head's output. `arch/common/rad_block_gdn_fp8.h` refuses any other
|
||||
name.
|
||||
- **Readings no per-op check can settle.** The rope convention (`neox`, halves, against `gptj`,
|
||||
adjacent pairs), which half of each head's `q|gate` pair is the query (the sigmoid accepts
|
||||
either), and the MTP head's concat order (hidden-first or embedding-first) are all
|
||||
self-consistent either way. Each is a declared knob at the site that reads it.
|
||||
|
||||
## KV groups
|
||||
|
||||
Three of them, which is why hybrid KV groups are first-class rather than an extension:
|
||||
Three groups, which is why hybrid KV groups are first-class:
|
||||
|
||||
| group | kind | geometry |
|
||||
|---|---|---|
|
||||
@@ -201,59 +193,52 @@ Three of them, which is why hybrid KV groups are first-class rather than an exte
|
||||
| GDN recurrent state | `RAD_KV_LINEAR` | 48 layers, 48 states of 128 x 128 |
|
||||
| GDN conv state | `RAD_KV_CONV` | 48 layers, 2*16 + 48 = 80 heads x 128 = 10240 channels, a rolling `conv_width - 1 + n_spec` window |
|
||||
|
||||
**The recurrent state is f32 by default**, which is 48 x 128 x 128 x 4 = 3 MiB a layer and
|
||||
**144 MiB across the 48 linear layers, per sequence** — and it is what the prefix-cache checkpoint
|
||||
of `spec.md` §7.3 snapshots. Its read and write are most of what the two GDN kernels do, so halving
|
||||
its width halves one of the largest kernels after the fp8 GEMMs. libr4d compiles an f16 form and
|
||||
argues the numerics where the kernel lives — the elements are O(0.1) with no range problem and
|
||||
f16's eleven mantissa bits put the round-trip error at 5e-4 relative. It is **off by default
|
||||
anyway**, because it changes generated text without being asked to; nothing about the container
|
||||
changes between the two, so there is no re-convert. How a speculative step keeps the state it can
|
||||
roll back is `docs/OPS.md`'s `state_form`.
|
||||
**The recurrent state is f32**: 48 x 128 x 128 x 4 = 3 MiB per layer, **144 MiB per sequence**
|
||||
across the 48 linear layers, and it is what the prefix-cache checkpoint of `spec.md` §7.3
|
||||
snapshots. Its reads and writes dominate the two GDN kernels. libr4d also compiles an f16 form
|
||||
(elements are O(0.1); the f16 round trip is about 5e-4 relative) that would halve that traffic,
|
||||
but the plugins declare f32 because f16 changes the generated text. How a speculative step keeps a
|
||||
state it can roll back is `docs/OPS.md`'s `state_form`.
|
||||
|
||||
## FP8
|
||||
|
||||
`quant_method: fp8`, `fmt: e4m3`, `activation_scheme: dynamic`, and a `weight_scale_inv` beside
|
||||
every quantised weight — DeepSeek-style block scaling, 128x128. Activations are quantised at
|
||||
runtime, which is what "dynamic" means and what makes the activation quantiser an op rather than a
|
||||
constant. The vision tower's first several blocks are in `modules_to_not_convert` and stay bf16.
|
||||
every quantised weight: DeepSeek-style 128x128 block scaling. Activations are quantised at runtime
|
||||
("dynamic"), so the activation quantiser is an op. The vision tower's first several blocks are in
|
||||
`modules_to_not_convert` and stay bf16.
|
||||
|
||||
**libr4d reads those bytes directly, so `rad-convert` COPIES**: no permutation, no repacking, no
|
||||
dequantisation, and a `.rad` costs what the checkpoint does. That is the whole reason this plugin
|
||||
family exists — widening a 27B FP8 checkpoint to bf16 doubles the weight bytes; `qwen35_bf16` is the
|
||||
plugin for a checkpoint that is bf16 to begin with.
|
||||
The rows are `gemm_fp8a16_nt_m1`, `gemm_fp8a8_nt_m16`, `gemm_fp8a8_gated_nt_m16` and
|
||||
**libr4d reads those bytes directly, so `rad-convert` copies them**: no permutation, repacking or
|
||||
dequantisation, and a `.rad` costs what the checkpoint does. Widening a 27B FP8 checkpoint to bf16
|
||||
would double the weight bytes; `qwen35_bf16` is for checkpoints that are bf16 to begin with. The
|
||||
rows are `gemm_fp8a16_nt_m1`, `gemm_fp8a8_nt_m16`, `gemm_fp8a8_gated_nt_m16` and
|
||||
`gemm_fp8a8_tiled`.
|
||||
|
||||
**The shipped path is `fp8a8`**, and the reason is a band and not a preference. `dtype` is ONE string
|
||||
per declared op, so a linear is `fp8a16` or `fp8a8` and cannot be both. `fp8a16` reads a bf16
|
||||
activation directly and needs no quantise launch, which is strictly better — and its kernel serves
|
||||
`M <= 1`, which is a single-sequence decode and nothing else. `fp8a8`'s two kernels cover every M
|
||||
between them, and the price is one `quant_act_fp8` launch per activation that feeds a GEMM — *per
|
||||
activation*, not per linear, which is why the quantiser is its own struct rather than a step inside
|
||||
the linear.
|
||||
**The shipped path is `fp8a8`.** `dtype` is one string per declared op, so a linear is `fp8a16` or
|
||||
`fp8a8`, not both. `fp8a16` reads the bf16 activation directly with no quantise launch, but its
|
||||
kernel serves only `M <= 1` (single-sequence decode). `fp8a8`'s two kernels cover every M, at the
|
||||
price of one `quant_act_fp8` launch per activation that feeds a GEMM. That cost is per activation,
|
||||
not per linear, which is why the quantiser is its own struct rather than a step inside the linear.
|
||||
|
||||
**The scale plane is a WEIGHT operand**: `gemm_nt_q` takes `a, a_scale, b, b_scale`, and `b` and
|
||||
**The scale plane is a weight operand**: `gemm_nt_q` takes `a, a_scale, b, b_scale`, and `b` and
|
||||
`b_scale` are two declarations over the planes of one logical weight (`RadWeightDecl::planes`).
|
||||
Each is placed, moved and sharded on its own — the engine cuts a row-sharded scale plane on its
|
||||
block boundary exactly as it cuts the codes beside it.
|
||||
Each is placed, moved and sharded on its own; the engine cuts a row-sharded scale plane on its
|
||||
block boundary as it cuts the codes.
|
||||
|
||||
## `qwen35moe`
|
||||
|
||||
This architecture with the MLP replaced by a router plus experts, and *only* that: the gated
|
||||
attention, the gated delta net, the layer schedule, the rope, the vocabulary edges and the MTP head
|
||||
are identical, and the places where a routed feed-forward differs are behind one conditional in the
|
||||
shared source. It is a second translation unit rather than a branch on `n_expert` because the id is
|
||||
half the selection key — one `.so` cannot claim both, and an operator looking at what is installed
|
||||
should see two plugins for two architectures.
|
||||
The same architecture with the MLP replaced by a router plus experts; the gated attention, the
|
||||
gated delta net, the layer schedule, the rope, the vocabulary edges and the MTP head are identical,
|
||||
and every difference is behind `#if QWEN35_MOE` in the shared source. It is a second translation
|
||||
unit rather than a branch on `n_expert` because the id is half the selection key, and one `.so`
|
||||
cannot claim both ids.
|
||||
|
||||
---
|
||||
|
||||
# `qwen4exp` — Qwen4-Exp / Qwen3.8-Flash-Next
|
||||
# `qwen4exp`: Qwen4-Exp / Qwen3.8-Flash-Next
|
||||
|
||||
`model_type: qwen4_exp`, a subclass of `Qwen3_5MoeTextModel` — so most of it is composition over the
|
||||
blocks above. What is genuinely new is small and named: the gated residual, the n-gram/PLE layer,
|
||||
QSA's indexer, stacked dense expert tensors, GQA 12, and the delta net's sigmoid output gate.
|
||||
`model_type: qwen4_exp`, a subclass of `Qwen3_5MoeTextModel`, so most of it composes the blocks
|
||||
above. New: the gated residual, the n-gram/PLE layer, QSA's indexer, stacked dense expert tensors,
|
||||
GQA 12, and the delta net's sigmoid output gate.
|
||||
|
||||
```
|
||||
48 layers of 12 x (3 x GatedDeltaNet -> MoE, then 1 x QSA -> MoE)
|
||||
@@ -265,146 +250,116 @@ indexer_n_heads 4 indexer_head_dim 128 indexer_budget 2048 indexer_compress_r
|
||||
mtp_num_hidden_layers 1 output_gate_type sigmoid
|
||||
```
|
||||
|
||||
**The residual stream is four times as wide, and the blocks do not own their norms.** There is no
|
||||
`input_layernorm`, no `post_attention_layernorm` and no final `norm` in this checkpoint. In their
|
||||
place every block has a gated residual connection — a grouped norm over the 10240 stream, a low-rank
|
||||
data-dependent read gate that mixes the four sub-streams down to 2560, and four data-dependent
|
||||
scalars that gain the block's output back into all four. 96 of them, plus a 97th with no write half
|
||||
that collapses the stream for the lm_head. The consequence for the blocks is that they run in their
|
||||
"input is already normed and quantised" mode and therefore give up two fusions — the residual add
|
||||
folded into the next norm, and the all-reduce folded into it.
|
||||
**The residual stream is four times as wide, and the blocks do not own their norms.** The
|
||||
checkpoint has no `input_layernorm`, `post_attention_layernorm` or final `norm`. Each block has a
|
||||
gated residual connection instead: a grouped norm over the 10240 stream, a low-rank data-dependent
|
||||
read gate that mixes the four sub-streams down to 2560, and four data-dependent scalars that add
|
||||
the block's output back into all four. There are 96, plus a 97th with no write half that collapses
|
||||
the stream for the lm_head. The blocks run in their "input already normed and quantised" mode and
|
||||
so give up two fusions: the residual add and the all-reduce folded into the next norm.
|
||||
|
||||
**Each weight's storage is the recipe's choice.** The checkpoint is bf16 with no
|
||||
`quantization_config`, so the descriptor is empty; `rad-convert` quantises by a recipe, and the
|
||||
plugin reads each weight's encoding from the container and declares the op that reads it:
|
||||
|
||||
- block linears (`self_attn.{q,k,v,o}_proj`, `linear_attn.{in_proj_qkv, in_proj_z, out_proj}`,
|
||||
the shared expert's three): fp8 or int8 (served W8A8);
|
||||
- routed experts' gate_up and down: fp8, bf16, or one of the four- and five-bit forms of
|
||||
`docs/MOE-W4.md`;
|
||||
- each connection's two mixing matrices and the MTP head's `fc_hidden` / `fc_embedding`: E4M3 rows
|
||||
or bf16. The low-rank width is 320, 2.5 scale blocks, so they are scaled a row group at a time;
|
||||
- the lm_head: whatever a `logits_gemm` kernel reads;
|
||||
- bf16: every norm gain, `A_log`, `dt_bias`, `conv1d`, `in_proj_a` and `in_proj_b` (48 rows is not
|
||||
a whole scale block), the router, `shared_expert_gate` and `embed_tokens`.
|
||||
|
||||
**What each weight is stored as is the recipe's decision.** The checkpoint is bf16 throughout and
|
||||
carries no `quantization_config` at all, so the plugin's descriptor is the empty one: `rad-convert`
|
||||
quantises by a recipe, and the plugin reads each weight's encoding from the container and declares
|
||||
the op that reads it. The block linears — `self_attn.{q,k,v,o}_proj`,
|
||||
`linear_attn.{in_proj_qkv, in_proj_z, out_proj}`, the shared expert's three — are block fp8 or
|
||||
int8 (served W8A8). Every routed expert's gate_up and down is fp8, bf16, or one of the four- and
|
||||
five-bit forms of `docs/MOE-W4.md`.
|
||||
Each connection's two mixing matrices and the MTP head's `fc_hidden` / `fc_embedding` are E4M3 rows
|
||||
or bf16: the low-rank width is 320, which is 2.5 scale blocks, so they are scaled a row group at a
|
||||
time rather than block-scaled. The lm_head is whatever a `logits_gemm` kernel reads. Every norm
|
||||
gain, `A_log`, `dt_bias`, `conv1d`, `in_proj_a` and `in_proj_b` (48 rows is not a whole scale
|
||||
block), the router, `shared_expert_gate` and `embed_tokens` stay bf16.
|
||||
`data/recipes/qwen4exp-w4nl64-i8-hc8m.recipe` is the served choice: four-bit codebook experts with
|
||||
ten protected experts left bf16, int8 block linears and lm_head, E4M3 mixing and MTP fc matrices,
|
||||
and the n-gram table at one fixed E4M3 scale.
|
||||
|
||||
**Tensor parallel at two ranks splits every expert's width, unevenly.** `moe_intermediate_size` is
|
||||
640 = 5 x 128, so an even share at tp2 is 320, which is not a whole number of 128-column blocks —
|
||||
and the fp8 scale block, the four-bit scale group and the rotation all sit on them. So each rank
|
||||
takes three blocks of the experts of one parity and two of the other's (`moe_gemm_q`'s two tables in
|
||||
`docs/OPS.md`), the router stays replicated so both ranks agree on the routing, each rank computes
|
||||
its slice of every routed expert, and the block's existing end-of-block all-reduce sums the
|
||||
partials. No all-to-all, no extra collective. The shared expert's 640 columns split the same way,
|
||||
three blocks on rank 0 and two on rank 1.
|
||||
**Tensor parallelism splits every expert's width.** `moe_intermediate_size` is 640 = 5 x 128, and
|
||||
the fp8 scale block, the four-bit scale group and the rotation all sit on 128-column blocks, so an
|
||||
even tp2 share (320) does not work. Each parity's five blocks are cut contiguously across the
|
||||
ranks, and the rank taking the extra block alternates with the parity: at tp2 a rank takes three
|
||||
blocks of the experts of one parity and two of the other's (`moe_gemm_q`'s two tables in
|
||||
`docs/OPS.md`). The router is replicated, each rank computes its slice of every routed expert, and
|
||||
the block's existing all-reduce sums the partials: no all-to-all, no extra collective. A world
|
||||
above the block count is refused at declare, since an empty slice would still join the
|
||||
all-reduce. The shared expert splits as evenly as whole blocks allow: three blocks on rank 0 and
|
||||
two on rank 1 at tp2; at tp4, rank 2 `[0, 256)` and one block each on ranks 3, 0 and 1.
|
||||
|
||||
**Five blocks do not divide evenly, and an even share is not required.** 5 is odd, so at tp4 an
|
||||
even share is 160 columns, 1.25 blocks — but the split is TWO SLICES per expert, not one slice a
|
||||
rank: each parity's blocks are cut contiguously across the ranks and the rank taking the odd block
|
||||
alternates with the parity, so every rank's share is whole blocks, every block of every expert has
|
||||
exactly one owner, and each rank still computes a slice of every routed expert. At four ranks and
|
||||
five blocks an even-parity expert is `[0, 2)` blocks on rank 0, `[2, 3)` on rank 1, `[3, 4)` on
|
||||
rank 2, `[4, 5)` on rank 3, and each rank's place on the odd parity shifts by one — rank 1 takes the
|
||||
fat block there instead of rank 0 — so no rank takes the extra block of both parities. A world
|
||||
above the block count is refused at declare, by name: a rank with an empty slice computes nothing
|
||||
and still joins the all-reduce. The shared expert's 640 columns split as evenly as whole blocks
|
||||
allow: five blocks over four ranks is rank 2 `[0, 256)` and one block each on ranks 3, 0 and 1.
|
||||
|
||||
**At four ranks the classes are four.** Parity gives the extra block only two places to go, so
|
||||
ranks 0 and 1 would compute three blocks of every even/odd pair of routed experts and ranks 2 and 3
|
||||
two, and every block's all-reduce would have 2 and 3 wait. So at four ranks the cut above is made
|
||||
per class of the expert's number mod 4, the rank's place shifted by the class: rank `r` takes
|
||||
`[0, 2)` blocks of class `r` and one block of each other class, five blocks of every four experts
|
||||
on every rank. That is `moe_gemm_q_mod4`, four slice tables where `moe_gemm_q` takes two
|
||||
(`docs/OPS.md`), and every slice is one a rank already took of some parity. A layer that keeps two
|
||||
experts plain bf16 has 510 quantised ones, and its first two classes are one expert longer. What
|
||||
does not divide elsewhere stays apart: the shared expert's extra block is rank 2's and the
|
||||
**At four ranks the classes are four.** Parity alone would give ranks 0 and 1 three blocks of every
|
||||
expert pair and ranks 2 and 3 two. So at tp4 the cut is made per class of the expert's number
|
||||
mod 4: rank `r` takes blocks `[0, 2)` of class `r` and one block of each other class, five blocks
|
||||
of every four experts on every rank (`moe_gemm_q_mod4`, four slice tables). A layer that keeps two
|
||||
experts plain bf16 has 510 quantised ones, and its first two classes are one expert longer. The
|
||||
protected bf16 experts' ten 64-wide tiles go 3, 3, 2, 2.
|
||||
Expert parallelism — whole experts a rank — is what this replaced, and why it stays replaced: the
|
||||
recipe protects its bf16 experts in pairs precisely so each rank's quantised count stays even, and
|
||||
sharding experts by rank breaks that parity property the weight tables rest on.
|
||||
|
||||
**Attention splits by KV head, and replicates once the ranks outrun the heads.** There are 2 KV
|
||||
heads of 256 rows, so each rank declares `n_head_kv 1` and reads one head's row-span of `k_proj` and
|
||||
`v_proj`. At tp2 that is the ordinary row shard. At tp4 the heads cannot divide four ways, so they
|
||||
are replicated in rank pairs: ranks {0,1} carry KV head 0, ranks {2,3} carry KV head 1, and both
|
||||
ranks of a pair hold byte-identical KV weights — more read traffic, no extra VRAM. `n_head` is 12 a
|
||||
rank at tp2 and 6 at tp4, so gqa is 12 at tp2 and 6 at tp4 and the attention kernel is a different
|
||||
instantiation (`attn_{prefill,decode}_h256_gqa6_bs4`, the QSA page of 4) than the gqa12 pair tp2
|
||||
resolves to, not the same kernel over fewer heads. Any world size above the KV head count must be a
|
||||
multiple of it: 4 is a multiple of 2, 3 and 5 are not, and those widths are refused at declare
|
||||
time.
|
||||
Expert parallelism (whole experts per rank) is not used: random routing leaves ranks whole experts
|
||||
apart and waiting at the all-reduce, and it would break the parity tables, for which the recipe
|
||||
protects bf16 experts in pairs.
|
||||
|
||||
**The fused all-reduce forms are two-rank, except the exact write.** At four ranks `ar_hc_write`
|
||||
exists on the exact wire only (`ar_hc_write_4rank`, the 4-rank one-shot with the write as its
|
||||
epilogue), and so does `ar_gather_hc_write` (`ar_gather_hc_write_4rank`, the same with
|
||||
`moe_gather` as its prologue), which the MoE connections take wherever the step is one MoE pass.
|
||||
Both are declared over the rows of a decode or verify step — `--max-num-seqs` × (1 +
|
||||
`--num-speculative-tokens`) — because a one-shot is for those messages, and a step within that
|
||||
bound takes them wherever its message goes out exact: always with `--tp-wire exact`, and with
|
||||
`--tp-wire wht6` under `--tp-wire-min-kb`. They run on an all-reduce instance keyed by that bound,
|
||||
not on the standalone all-reduce's unless the two bounds agree; the wide family's flag, sequence
|
||||
and slot discipline is what makes either safe on one stream. A prefill chunk, and every message
|
||||
that goes out lossy, keeps the standalone sequence — `moe_gather` on the MoE connections,
|
||||
`all_reduce` (whose size bands pick the 4-rank one-shot or two-shot, or ti8 on the lossy wire),
|
||||
then `hc_write_bf16`. The unfused sequence is declared beside the fused one, so nothing is
|
||||
unresolved at boot. The attention's own fusion is not a collective and does carry over: the sparse
|
||||
decode with the output gate and the quantiser in its merge (`attn_paged_gate_quant`) has gqa-6,
|
||||
page-4 rows. The per-step cost against tp2 on the same cards is unmeasured.
|
||||
**Attention splits by KV head.** There are 2 KV heads of 256 rows; each rank declares
|
||||
`n_head_kv 1` and reads one head's row span of `k_proj` and `v_proj`. At tp2 that is the ordinary
|
||||
row shard. At tp4 the heads are replicated in rank pairs (ranks {0,1} carry KV head 0, {2,3} KV
|
||||
head 1; both ranks of a pair hold identical KV weights, at no extra VRAM per rank). `n_head` is 12
|
||||
per rank at tp2 and 6 at tp4, so tp4 resolves a different instantiation
|
||||
(`attn_{prefill,decode}_h256_gqa6_bs4`, the QSA page of 4) than tp2's gqa12 pair. A world that
|
||||
neither divides nor is a multiple of the KV head count (3, 5) runs attention on the largest
|
||||
multiple below it and leaves the other ranks attention-zero; `docs/TP3.md` describes this and the
|
||||
uneven delta-net head split.
|
||||
|
||||
**One collective does generalise, because it has to.** The lm_head is vocab-sharded, so the sampler
|
||||
gathers the ranks' candidate sets rather than their logits (`core/sample/sampler.cpp`) and an
|
||||
`all_gather` is on every step's sample path at any world size above one. libr4d shipped a two-rank
|
||||
form only — one peer flag, a `1 - rank` peer index, a destination stride of `2 * row16` — so the
|
||||
N-rank gather is a new kernel, not a fallback: at four ranks nothing but the reference
|
||||
implementation resolves and the engine refuses to serve rather than run a naive gather. It is the
|
||||
same one-shot push as the N-rank all-reduce with the reduction removed, and it moves the
|
||||
(u32 id, f32 logit) pairs without ever adding them.
|
||||
**Fused all-reduce forms at four ranks.** The fused forms are two-rank except on the exact wire:
|
||||
`ar_hc_write_4rank` (the 4-rank one-shot with the gated-residual write as its epilogue) and
|
||||
`ar_gather_hc_write_4rank` (the same with `moe_gather` as its prologue, taken by the MoE
|
||||
connections when the step is one MoE pass). Both are declared over the rows of a decode or verify
|
||||
step, `--max-num-seqs` x (1 + `--num-speculative-tokens`), and used whenever a step within that
|
||||
bound sends its message exact: always with `--tp-wire exact`, and with `--tp-wire wht6` under
|
||||
`--tp-wire-min-kb`. They run on an all-reduce instance keyed by that bound. A prefill chunk, and
|
||||
every lossy message, uses the standalone sequence: `moe_gather`, `all_reduce` (4-rank one-shot or
|
||||
two-shot by size, or ti8 on the lossy wire), then `hc_write_bf16`. The unfused sequence is
|
||||
declared beside the fused one, so nothing is unresolved at boot. The sparse decode's fused output
|
||||
gate and quantiser (`attn_paged_gate_quant`) has gqa-6, page-4 rows.
|
||||
|
||||
**Four-bit experts are what make it fit.** 512 experts of 640 over 48 layers is 112.8 GiB of expert
|
||||
**Candidate gather.** The lm_head is vocab-sharded, so the sampler gathers the ranks' candidate
|
||||
sets rather than their logits (`core/sample/sampler.cpp`), and every step at a world above one runs
|
||||
an `all_gather`. libr4d serves it at 2 ranks (`r4d_ar_gather_2rank.hip`) and at 3, 4 and 8
|
||||
(`r4d_ar_gather_Nrank.hip`, moving (u32 id, f32 logit) pairs without adding them). Where no device
|
||||
row resolves, only libref's host gather does, and the serve is refused.
|
||||
|
||||
**Four-bit experts are what make it fit.** 512 experts of 640 over 48 layers is 112.5 GiB of expert
|
||||
weight at E4M3 and twice that at bf16. `--weights-disk-tier` serves what fits neither VRAM nor the
|
||||
host pool from the container file, but a routed expert is then read a layer at a time and a step is
|
||||
paced by the drive. At four bits an expert unit is 2.42 MiB instead of 4.69 and the per-rank share
|
||||
host pool from the container file, but then a routed expert is read a layer at a time and a step is
|
||||
paced by the drive. At four bits an expert unit is 2.42 MiB instead of 4.69, and the per-rank share
|
||||
fits VRAM plus a few GiB of pinned host. `docs/MOE-W4.md` is the format.
|
||||
|
||||
**PLE / the n-gram embedding is 51B of the model's 180B parameters** — a 320,001,536-row table of
|
||||
160-dim embeddings, gathered 16 rows a token by a hash of the last three token ids, read once at
|
||||
layer 1 and injected into the wide stream. Without it this is a 125B model missing a third of its
|
||||
parameters.
|
||||
**PLE, the n-gram embedding, is 51B of the model's 180B parameters**: a 320,001,536-row table of
|
||||
160-dim embeddings, gathered 16 rows per token by a hash of the last three token ids, read once at
|
||||
layer 1 and injected into the wide stream.
|
||||
|
||||
**QSA** picks the best `indexer_budget / indexer_compress_ratio` = 512 blocks of 4 tokens for each
|
||||
query and attends to those alone. Below `indexer_budget + indexer_compress_ratio - 1` = 2051 tokens
|
||||
of context every complete block is selected, so QSA is dense causal attention bit for bit — which is
|
||||
why a prefill below the bound runs the cheaper dense attention, and is the property any change to it
|
||||
is argued against. `docs/QSA.md` is the decomposition.
|
||||
of context every complete block is selected and QSA equals dense causal attention bit for bit, so
|
||||
a prefill below the bound runs the cheaper dense attention, and every change is tested against
|
||||
that equality. `docs/QSA.md` is the decomposition.
|
||||
|
||||
The vision tower is declared when the container carries one and `--mm-max-patches` is not 0
|
||||
(`arch/common/rad_block_vit.h`, `spec.md` §11).
|
||||
|
||||
---
|
||||
|
||||
# Two rules about measuring these
|
||||
# Sample size
|
||||
|
||||
**A bisect knob is not a deployment knob.** Several switches here ablate a block or a layer range;
|
||||
they produce a DIFFERENT MODEL and exist so that a wrong distribution can be attributed to a block
|
||||
when nothing compares a whole layer against an oracle. A serve that sets one is a serve that is not
|
||||
running the model, and the plugin says so at declare time. **Knobs are documented where they are
|
||||
read** — a table of them in a document goes stale silently and ends up naming variables nothing
|
||||
reads.
|
||||
|
||||
**THE SAMPLE SIZE IS PART OF THE RESULT.** Top-1 agreement between two numeric formats is one
|
||||
Bernoulli trial per prompt, so at p ≈ 0.93 its standard error is 2.8 points at N = 80 and 2.0 at
|
||||
N = 160 — wide enough that formats which differ by less than that rank in any order. Rank with a
|
||||
graded statistic that has thousands of samples rather than hundreds (the mean |delta| over the
|
||||
logits row, or the per-position KL of `radiance --kld-ref`), and confirm any ordering at N ≥ 160
|
||||
before acting on it.
|
||||
Top-1 agreement between two numeric formats is one Bernoulli trial per prompt, so at p ≈ 0.93 its
|
||||
standard error is 2.8 points at N = 80 and 2.0 at N = 160: formats that differ by less than that
|
||||
rank in any order. Rank with a graded statistic that has thousands of samples (the mean |delta|
|
||||
over the logits row, or the per-position KL of `radiance --kld-ref`), and confirm any ordering at
|
||||
N ≥ 160 before acting on it.
|
||||
|
||||
---
|
||||
|
||||
# `embeddinggemma2` — an embedding model
|
||||
# `embeddinggemma2`: an embedding model
|
||||
|
||||
`arch/embgemma2` declares a POOLED output (`rad_declare_pooled`) and no logits, which makes the
|
||||
`arch/embgemma2` declares a pooled output (`rad_declare_pooled`) and no logits, which makes the
|
||||
program an embedding program: the engine runs it with no sampler and no KV cache, carries every
|
||||
input whole in one step, and returns each sequence's pooled row on `/v1/embeddings`
|
||||
([GUIDE §5.6](GUIDE.md)). One card (`--tp 1`).
|
||||
@@ -425,39 +380,41 @@ audio Gemma 4's USM conformer: two stride-2 3 x 3 convolutions over (time, m
|
||||
embedder -> 512; 4 frames (40 ms) a token, clips cut at 30 s
|
||||
```
|
||||
|
||||
The traps:
|
||||
Traps:
|
||||
|
||||
- **The embedding scale is the bf16 of sqrt(512)**, 22.625, because the reference stores it as a
|
||||
bf16 buffer. sqrt(512) itself is off by one part in 800 on every embedding.
|
||||
bf16 buffer. sqrt(512) itself is off by about 1e-4 relative on every embedding.
|
||||
- **A media row replaces its placeholder's embedding before the per-layer inputs are projected.**
|
||||
The per-layer input of an image token is computed from its image row, not from the placeholder
|
||||
id's embedding.
|
||||
- **The vision rotary is two independent neox rotaries**, one over each half of a head (`qk_norm_rope`
|
||||
mode `blocks`). `rope` mode `axial` pairs across the halves and is a different function.
|
||||
- **The vision pooler stores the mean in bf16 before scaling it by sqrt(768)** (`pool_rows`), and
|
||||
the processor lays each 3 x 3 window's patches out consecutively so the pooler is a mean of nine
|
||||
An image token's per-layer input is computed from its image row, not from the placeholder id's
|
||||
embedding.
|
||||
- **The vision rotary is two independent neox rotaries**, one over each half of a head
|
||||
(`qk_norm_rope` mode `blocks`). `rope` mode `axial` pairs across the halves and is a different
|
||||
function.
|
||||
- **The vision pooler stores the mean in bf16 before scaling it by sqrt(768)** (`pool_rows`). The
|
||||
processor lays each 3 x 3 window's patches out consecutively, so the pooler is a mean of nine
|
||||
consecutive rows; attention and both position terms read each patch's own coordinates.
|
||||
- **The audio subsampler masks its input to the clip's real frames before each convolution**: the
|
||||
second convolution reads the first one's output at frame 2t's validity (`conv2d`'s `valid`
|
||||
operand, stride 2), which zeroes the one row past the real ones that the zero padding alone
|
||||
would not.
|
||||
operand, stride 2), which zeroes the one row past the real ones that zero padding alone would
|
||||
not.
|
||||
- **The audio attention reaches 11 rows back, not 12.** The config says `attention_context_left`
|
||||
13 and the chunked layout fetches 12 keys behind each block, but the mask transformers applies
|
||||
keeps a key only when `0 <= q - k < context_left - 1`. Twelve back drifts a few percent a block
|
||||
and leaves rows at cosine 0.6 by the last one.
|
||||
13 and the chunked layout fetches 12 keys behind each block, but transformers' mask keeps a key
|
||||
only when `0 <= q - k < context_left - 1`. Twelve back drifts a few percent per block and leaves
|
||||
rows at cosine 0.6 by the last one.
|
||||
- **An audio clip's tokens are ceil(real frames / 4)**, real frames being those whose last sample
|
||||
is a real one; the processor stages exactly those plus zero frames to whole rows, which
|
||||
reproduces every row the reference keeps.
|
||||
is real; the processor stages exactly those plus zero frames to whole rows, which reproduces
|
||||
every row the reference keeps.
|
||||
|
||||
---
|
||||
|
||||
# `gemma4` — Gemma 4 text, and its DFlash drafter
|
||||
# `gemma4`: Gemma 4 text and its DFlash drafter
|
||||
|
||||
`arch/gemma4` serves a container converted from Google's bf16 checkpoint (`Gemma4ForConditionalGeneration`
|
||||
or `Gemma4ForCausalLM`), the recipe choosing what is fp8: gemma-4-26B-A4B-it, and the dense sizes
|
||||
without per-layer embeddings. The CT-INT4 31B release is `arch/gemma4_bf16`'s. A z-lab DFlash
|
||||
drafter is merged at convert time (`--draft-model`); the recipes are
|
||||
`data/recipes/gemma4-26b-a4b-df*.recipe`. The reference is transformers' `modeling_gemma4`.
|
||||
`arch/gemma4` serves a container converted from Google's bf16 checkpoint
|
||||
(`Gemma4ForConditionalGeneration` or `Gemma4ForCausalLM`), the recipe choosing what is fp8:
|
||||
gemma-4-26B-A4B-it, and the dense sizes without per-layer embeddings. The CT-INT4 31B release is
|
||||
`arch/gemma4_bf16`'s. A z-lab DFlash drafter is merged at convert time (`--draft-model`); the
|
||||
recipes are `data/recipes/gemma4-26b-a4b-df*.recipe`. The reference is transformers'
|
||||
`modeling_gemma4`.
|
||||
|
||||
```
|
||||
gemma-4-26B-A4B-it
|
||||
@@ -478,115 +435,111 @@ DFlash a small Qwen3-shaped block drafter: an anchor and block - 1 mask token
|
||||
pass over the trunk's hidden states at target_layer_ids; drafts read off the TARGET's head
|
||||
```
|
||||
|
||||
The readings that stay plausible when wrong:
|
||||
Traps:
|
||||
|
||||
- **Proportional rope is not a partial rotary.** The full layers rotate the first 64 frequency
|
||||
pairs of the 512-wide head at theta^(-2j/512) — the exponent divides by the HEAD — with pair j
|
||||
channels (j, j + 256), and leave the other 192 pairs at frequency zero. `rope` with
|
||||
`rotary_dim` 128 pairs (j, j + 64) at theta^(-2j/128): a different function that still produces
|
||||
pairs of the 512-wide head at theta^(-2j/512) (the exponent divides by the head width), with pair
|
||||
j at channels (j, j + 256), and leave the other 192 pairs at frequency zero. `rope` with
|
||||
`rotary_dim` 128 pairs (j, j + 64) at theta^(-2j/128), a different function that still produces
|
||||
fluent text. The plugin declares a full-width NeoX `rope` whose frequencies past pair 63 are
|
||||
divided by 1e30 through the YaRN ramp `rope` already carries, a step at 63.5..64.
|
||||
- **V on a full layer is the un-normed, un-rotated k projection**, RMS-normed with a unit gain, so
|
||||
the value norm reads `k` before the key norm writes it.
|
||||
- **The router does not read the feed-forward's input.** It reads the residual stream through a
|
||||
gainless norm times its own `scale` vector times hidden^-0.5, while the experts read
|
||||
pre_feedforward_layernorm_2's output. `per_expert_scale` multiplies the weight AFTER the
|
||||
pre_feedforward_layernorm_2's output. `per_expert_scale` multiplies the weight after the
|
||||
renormalised top-k.
|
||||
- **The arms' two post-norms are per arm**, so under tensor parallel each arm's partial sum is
|
||||
reduced before its norm. The partials share one [2T, hidden] buffer, dense rows first -- each
|
||||
slice's own run of it when a prefill chunk is cut in two -- so one all-reduce carries both.
|
||||
reduced before its norm. The partials share one [2T, hidden] buffer, dense rows first (each
|
||||
slice's own run of it when a prefill chunk is cut in two), so one all-reduce carries both.
|
||||
- **The embedding scale is sqrt(hidden) rounded to bf16**: 53.0, not 53.066. The drafter reads the
|
||||
same scaled embedding.
|
||||
- **The sliding layers' KV group is `RAD_KV_FULL`**, with the window on the attention op. A
|
||||
`RAD_KV_WINDOW` group is not prefix-cached, so a hit on it reuses nothing and re-prefills; as
|
||||
FULL the hit is kept. The planner gives every paged group the same block count, so the recycling
|
||||
a window group would buy is worth nothing here.
|
||||
`RAD_KV_WINDOW` group is not prefix-cached, so a hit on it reuses nothing and re-prefills. The
|
||||
planner gives every paged group the same block count, so the recycling a window group would buy
|
||||
is worth nothing here.
|
||||
- **The drafter's sliding layers are causal and its full layer is not**, and its logits' softcap
|
||||
is ignored on purpose: a draft is an argmax and the cap is strictly increasing.
|
||||
|
||||
**Tensor parallel.** Heads split by rank, o and down by column with an all-reduce, the vocabulary
|
||||
by row. The full layers' two KV heads are replicated past two ranks. Routed experts are
|
||||
expert-parallel, 128 / world whole experts a rank, because a 704-wide expert has no block-aligned
|
||||
expert-parallel, 128 / world whole experts per rank, because a 704-wide expert has no block-aligned
|
||||
width split; the router is replicated, so every rank agrees on the routing without a collective.
|
||||
The drafter's head is vocab-sharded with the trunk's: each rank's top-2 are all-gathered and
|
||||
`pair_argmax` picks the winner (two a rank, because a row-interleaved `all_gather` moves 16-byte
|
||||
`pair_argmax` picks the winner (two per rank, because a row-interleaved `all_gather` moves 16-byte
|
||||
words and one pair is 8 bytes).
|
||||
|
||||
**The prefill overlap.** At more than one rank, a prefill chunk of two routed passes or more (4096
|
||||
tokens, at the 2048-token pass) runs as two slices, and the trunk's all-reduces ride the runtime's
|
||||
second lane beside the other slice's compute: slice A's attention reduction runs under slice B's
|
||||
output projection, slice B's under slice A's two arms, and so on through the layer. Attention runs
|
||||
whole, since it reads every row's keys. The cut is a whole number of routed passes and both slices
|
||||
are above every row band the sliced kernels have, so the step issues the same kernels over the
|
||||
same rows and its output is the whole step's, bit for bit. On 4x R9700 the reductions were 47% of
|
||||
a 20K-token prefill under `--profile-ops`; a model of the measured times puts the overlap at up to
|
||||
a quarter off an unprofiled prefill. The per-op profile syncs every op, so it cannot show it --
|
||||
time a prefill without `--profile-ops`. A step that runs whole -- every decode and verify step --
|
||||
takes the second lane for the dense arm instead, beside the routed arm, which needs nothing of it
|
||||
until the feed-forward join: at decode the dense arm's GEMMs are a few rows, latency-bound and far
|
||||
from the bandwidth the experts take, and its reductions stay on lane 0. On two R9700s the sliced
|
||||
prefill gives the whole chunk's text and logprobs exactly, at 2048- and 8192-token chunks; the
|
||||
startup notes say which form each step takes.
|
||||
**Prefill overlap.** At more than one rank on the exact wire, with every join fused, a prefill chunk
|
||||
of two routed passes or more (4096 tokens at the 2048-token pass) runs as two slices, and the
|
||||
trunk's all-reduces ride the runtime's second lane beside the other slice's compute (slice A's
|
||||
attention reduction under slice B's output projection, and so on). Attention runs whole, since it
|
||||
reads every row's keys. The slices issue the same kernels over the same rows, so the output equals
|
||||
the whole step's bit for bit. On 4x R9700 the reductions are 47% of a 20K-token prefill under
|
||||
`--profile-ops`, and the overlap is modelled at up to a quarter off; `--profile-ops` syncs every op
|
||||
and cannot show it, so time a prefill without it. A step that runs whole (every decode and verify
|
||||
step) puts the dense arm on the second lane instead, beside the routed arm, with its reductions on
|
||||
lane 0. The startup notes say which form each step takes.
|
||||
|
||||
**The draft head in fp8.** The drafter's head is the widest read on the draft path: the target's
|
||||
bf16 table, 352 MiB a rank at tp 4, every draft pass. A container converted with the line
|
||||
bf16 table, 352 MiB per rank at tp 4, every draft pass. A container converted with the line
|
||||
`dflash.draft_head.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16` (the three `-df` recipes
|
||||
carry it) stores a block-fp8 copy of the table under that name, and the head reads the copy at
|
||||
fp8a8 instead -- half the bytes, for 176 MiB a rank more. Drafts are verified, so the coarser
|
||||
logits can change what is proposed and never what is accepted; `draft_n_accepted` says whether
|
||||
they propose worse. A container without the copy reads the bf16 table as before, and the startup
|
||||
note names which head is in use.
|
||||
carry it) stores a block-fp8 copy under that name, and the head reads it at fp8a8 instead: half
|
||||
the bytes, for 176 MiB per rank more. Drafts are verified, so the coarser logits can change what is
|
||||
proposed, never what is accepted; `draft_n_accepted` shows whether they propose worse. Without the
|
||||
copy the head reads the bf16 table, and the startup note names which head is in use.
|
||||
|
||||
**FP8 experts.** The experts are ~90% of the weight bytes, so each projection is served as the
|
||||
container holds it, per layer: bf16 by `moe_gemm`, block fp8 by `moe_gemm_q`. gate_up `[1408, 2816]`
|
||||
is whole 64-row tiles and 128-blocks. down `[2816, 704]` is not — the fp8 grouped GEMM reads K in
|
||||
whole 128-column blocks — so it stays bf16 unless the checkpoint's experts were padded to 768 before
|
||||
conversion (zero rows of gate and up, zero columns of down: exact). The fp8 tables are split by
|
||||
expert parity, so a rank holds an even number of experts.
|
||||
container holds it, per layer: bf16 by `moe_gemm`, block fp8 by `moe_gemm_q`. gate_up
|
||||
`[1408, 2816]` is whole 64-row tiles and 128-blocks. down `[2816, 704]` is not (the fp8 grouped
|
||||
GEMM reads K in whole 128-column blocks), so it stays bf16 unless the checkpoint's experts were
|
||||
padded to 768 before conversion (zero rows of gate and up, zero columns of down: exact;
|
||||
`gemma4-26b-a4b-df-pad768.recipe`). The fp8 tables are split by expert parity, so a rank holds an
|
||||
even number of experts.
|
||||
|
||||
**Kernels.** libr4d serves all of the trunk's attention on its windowed kernels -- the sliding
|
||||
layers (h256, gqa 2) and the full layers at gqa 8, 4 and 2 (one or two, four, eight ranks) --
|
||||
plus `pair_argmax` and the fusions: the two sandwich-norm joins (`norm_add_norm`,
|
||||
`join_add_scale`), `norm_add_norm_route` -- on a layer whose gate_up is block fp8, the attention
|
||||
join writing the router's input and the experts' fp8 codes from the norm it already takes, in place
|
||||
of an `rmsnorm` and an `rmsnorm_quant_fp8` -- `expert_scale`, and `attn_paged_qrow`, the sliding
|
||||
layers' attention reading q where the fused qkv projection left it. The plugin declares each one's
|
||||
unfused form where nothing serves it -- the rmsnorm / add chain, `embed_lookup` + `mul`, a `cast`
|
||||
lifting q for `attn_paged` -- and the startup notes say which were taken. libref and libavx do not
|
||||
declare these ops, so the plugin asks whether one is declared before it asks for it
|
||||
(`rad_op_declared`), and a deployment without libr4d's device rows -- a CPU-only build, the host
|
||||
backend -- runs the chains. On a card the fused joins and libr4d's chain differ by the order of
|
||||
the chain's reductions, not bit for bit: the joins round as the host chain does (tests/r4d_emu).
|
||||
The drafter's residual add, norm and fp8 quantiser of x are one libr4d `rmsnorm_quant_fp8` launch
|
||||
an input (ten a draft pass), and the `add` / `rmsnorm` / `quant_act_fp8` chain where nothing serves
|
||||
it. The sliding layers' attention stays on the windowed kernel because only it reads q in place:
|
||||
plain `attn_paged` at h256/gqa2 -- the dense 31B's sliding layers -- takes libr4d's h256/gqa2
|
||||
leg, which rad-kbench times at 0.26-0.71 of the windowed kernel at decode and 0.43-0.67 at
|
||||
prefill. A drafter head sharded over more than one rank needs `pair_argmax` on the card.
|
||||
**Kernels.** libr4d serves all of the trunk's attention on its windowed kernels (the sliding layers
|
||||
at h256, gqa 2, and the full layers at gqa 8, 4 and 2 for one or two, four and eight ranks), plus
|
||||
`pair_argmax` and the fusions:
|
||||
|
||||
**A drafter that is not working still writes fluent text.** Every draft is verified, so a broken
|
||||
drafter costs speed and nothing else: judge it by `draft_n_accepted` (about a third of `draft_n` on
|
||||
prose, at about two tokens a step), not by the reply. The trap that showed it: the buffer planner
|
||||
takes liveness from DECLARATION order, so the tap copy into `dflash_src` is declared at the end of
|
||||
the layer it taps, where it is issued. Declared once after the trunk, it let the planner share
|
||||
`dflash_src` with `moe_edn`, which every MoE layer writes, whenever the sizes allowed it
|
||||
(`--max-num-seqs 16` did): 2% acceptance, slower than no speculation, and nothing in the text to
|
||||
say so. arch_test holds the two live ranges to overlap.
|
||||
- the two sandwich-norm joins (`norm_add_norm`, `join_add_scale`);
|
||||
- `norm_add_norm_route`: on a layer whose gate_up is block fp8, the attention join also writes the
|
||||
router's input and the experts' fp8 codes from the norm it already takes, in place of an
|
||||
`rmsnorm` and an `rmsnorm_quant_fp8`;
|
||||
- `expert_scale`;
|
||||
- `attn_paged_qrow`, the sliding layers' attention reading q where the fused qkv projection left it.
|
||||
|
||||
**Not declared.** The vision tower (`arch/embgemma2` declares Gemma 4's, for an encoder): a container
|
||||
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.
|
||||
Where nothing serves a fusion the plugin declares its unfused form (the rmsnorm / add chain,
|
||||
`embed_lookup` + `mul`, a `cast` lifting q for `attn_paged`), and the startup notes say which were
|
||||
taken. libref and libavx do not declare these ops, so the plugin checks `rad_op_declared` first,
|
||||
and a deployment without libr4d's device rows (a CPU-only build, the host backend) runs the chains.
|
||||
On a card the fused joins and libr4d's chain differ in reduction order, not bit for bit; the joins
|
||||
round as the host chain does (`tests/r4d_emu`). The drafter's residual add, norm and fp8 quantiser
|
||||
of x are one `rmsnorm_quant_fp8` launch per input (ten per draft pass), or the `add` / `rmsnorm` /
|
||||
`quant_act_fp8` chain. The sliding layers' attention stays on the windowed kernel because only it
|
||||
reads q in place; plain `attn_paged` at h256/gqa2 (the dense 31B's sliding layers) takes libr4d's
|
||||
h256/gqa2 leg, which rad-kbench times at 0.26-0.71 of the windowed kernel at decode and 0.43-0.67
|
||||
at prefill. A drafter head sharded over more than one rank needs `pair_argmax` on the card.
|
||||
|
||||
**A broken drafter still writes fluent text**, since every draft is verified; judge it by
|
||||
`draft_n_accepted` (about a third of `draft_n` on prose, at about two tokens per step), not by the
|
||||
reply. The buffer planner takes liveness from declaration order, so the tap copy into `dflash_src`
|
||||
is declared at the end of the layer it taps, where it is issued. Declared after the trunk, it would
|
||||
let the planner share `dflash_src` with `moe_edn`, which every MoE layer writes, and acceptance
|
||||
would collapse silently. arch_test holds the two live ranges to overlap.
|
||||
|
||||
**Not declared.** The vision tower (`arch/gemma4_bf16` and `arch/embgemma2` declare Gemma 4's): a
|
||||
container 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
|
||||
# `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.
|
||||
`arch/qwenimage21` declares a generator (`rad_declare_generator`), which makes the program a
|
||||
three-pass one the engine drives through `core/gen`: COND once per request (the text encoder over
|
||||
the prompt and its pictures, then the DiT over that prefix into the KV cache), DENOISE once per step
|
||||
(the image's latent rows against the cached prefix), DECODE once per 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
|
||||
@@ -607,28 +560,83 @@ schedule flow-matching Euler, exponential dynamic shift (0.5 at 256 tokens to 0
|
||||
shift_terminal 0.02, 40 steps; Turbo: the 8 sigmas model_index.json lists, no guidance
|
||||
```
|
||||
|
||||
The traps:
|
||||
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.
|
||||
means handing diffusers the same latents; a NumPy port of the stream does that.
|
||||
- **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.
|
||||
and re-modulating it would differ from the reference at every step after the first.
|
||||
- **The text encoder's output skips the final norm.** The normed output scales every row by the
|
||||
norm's gain and gives a plausible, wrong picture.
|
||||
- **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.
|
||||
and guidance bf16(neg + bf16(cfg * bf16(pos - neg))). Unrounded is a different trajectory, not a
|
||||
more accurate one.
|
||||
- **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.
|
||||
- **Alpha off the decoder is never exactly 255** (243..255 on an opaque picture). Read as
|
||||
transparency, it makes every picture the model made transparent when 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.
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
# `qwen3asr`: speech to text
|
||||
|
||||
`model_type: qwen3_asr` (`Qwen3ASRForConditionalGeneration`), served from the checkpoint as it
|
||||
ships: Qwen3-ASR 1.7B is a Whisper-style audio encoder, a two-layer projector and a dense Qwen3-1.7B
|
||||
decoder, all bf16. The reference is transformers' `modeling_qwen3_asr` with its
|
||||
`Qwen3ASRFeatureExtractor`, which core/mm reproduces (`AudioFamily::Qwen3ASR`).
|
||||
|
||||
```
|
||||
features Whisper log-mel, 128 bins: n_fft 400, hop 160, torch.stft centred with reflected padding,
|
||||
power spectra, the last frame dropped (n samples -> n / 160 frames), Slaney mel bank and
|
||||
area norm, log10 floored at the clip's maximum less 8, then (x + 4) / 4; a clip under
|
||||
8000 samples zero-padded to 8000 first
|
||||
encoder each second (100 frames) convolved on its own: 3 x Conv2d 3x3 / stride 2 / pad 1, 480
|
||||
channels, exact gelu, over [mel, time] -> 16 mel x 13 rows a second; 7680 -> 1024 linear
|
||||
(no bias); sinusoidal positions 0..12 added to every second's rows; 24 pre-LayerNorm
|
||||
layers, d_model 1024, 16 heads of 64, biased q/k/v/o and FFN 4096 with exact gelu,
|
||||
bidirectional in blocks of 104 rows (8 s) from the clip's start; LayerNorm
|
||||
projector 1024 -> 1024, gelu, 1024 -> 2048
|
||||
decoder 28 layers, hidden 2048, 16 heads over 8 KV heads of 128 (GQA 2), per-head q/k RMS norms,
|
||||
NeoX rope over the whole head at theta 1e6, SwiGLU 6144, RMS eps 1e-6, vocab 151936,
|
||||
lm_head tied to the embedding
|
||||
prompt <|im_start|>system\n{context}<|im_end|>\n<|im_start|>user\n<|audio_start|> pads
|
||||
<|audio_end|><|im_end|>\n<|im_start|>assistant\n[language English<asr_text>]
|
||||
```
|
||||
|
||||
Traps (each loads and transcribes plausibly when wrong):
|
||||
|
||||
- **A second's convolution must not see the next second.** The reference pads every second to 100
|
||||
frames and convolves the batch; one convolution over the clip with no seam reads one second's
|
||||
frames into the next's. core/mm stages a whole second as 104 frames whose last four the encoder
|
||||
reads as zero (`conv2d`'s `valid`, at strides 1, 2 and 4), and the last, shorter second as 8 x
|
||||
the rows the reference keeps of it, so the rows the tower writes are the rows the reference
|
||||
keeps and nothing is compacted. The zero frames inside the last second's window are real input
|
||||
(the reference's padding) and are read: its last kept row depends on them.
|
||||
- **The kernels are [mel, time]**, so PyTorch's weight is `[cout, cin, mel, time]` with time last,
|
||||
where `conv2d` convolves (time, width). `t_last` reads it as stored; reading it the other way is a
|
||||
transposed kernel, which still produces text.
|
||||
- **The 7680 -> 1024 linear takes channel-major features** (`c * 16 + f`) where the convolution
|
||||
writes frequency-major ones. Declared as a 1 x 16 convolution over frequency, its weight is
|
||||
PyTorch's `[1024, 480, 1, 16]`; declared as a GEMM, it would need a permutation the name map has
|
||||
no form for.
|
||||
- **Positions restart every second** (`seg_sinusoid`, period 13) and **attention runs in blocks of
|
||||
104 rows**, the last one short (`attn_dense`'s `block`). Positions counted over the whole clip,
|
||||
or attention over all of it, is a different model that still writes text.
|
||||
- **The decoder's positions are the tokens' indices**: plain Qwen3, no M-RoPE; the audio
|
||||
placeholders count up like text.
|
||||
|
||||
A pass carries 30 s (3120 staged frames); `/v1/audio/transcriptions` cuts longer recordings into
|
||||
clips at their pauses (docs/GUIDE.md §5.14). Against transformers on LibriSpeech test-clean and
|
||||
test-other clips, the encoder's rows are within 1.1-1.3% relative L2 of the bf16 reference's; on
|
||||
the one clip where they differed by 5%, the reference itself was 5.3% from a float32 run of the
|
||||
same model and this engine 0.8%. The transcripts match word for word.
|
||||
Reference in new issue
Block a user