Archived
merge 1.12.0: gemma4 E2B/E4B and Nemotron Bolt E4B arrive; the ref2va audio, rows and ABI work carried across
conv1d keeps both stride forms: upstream's causal codec downsample with cu_div (Fish Audio) and the port's explicit-pad non-causal one (the H3 audio encoder's), in libref, libavx and libr4d alike; the ABI takes upstream's 27 on top of the port's RadVideoGenBatch growth.
This commit is contained in:
commit
7c3b5ab7d5
285 files changed
+30500
-2898
No files matched your search
+321
-66
@@ -17,7 +17,7 @@ plugin claims.
|
||||
| `arch/glm5next` | `glm5next` | *(empty)* | GLM-5.3-Flash from AMD's Quark MXFP4 export: four mHC residual streams over 34 KDA and 11 sparse latent-attention (MLA) layers with a DSA indexer, 288 MXFP4 experts at top-8 under sigmoid routing, block-FP8 attention and dense layers at f32 scales, each weight served as stored; its MTP layer is a serial drafter. Pictures through its vision tower (`arch/common/rad_block_glm_vision.h`); bf16 KV |
|
||||
| `arch/lfm2_bf16` | `lfm2` | *(empty)* | LiquidAI's LFM2 and LFM2-VL, bf16, one rank |
|
||||
| `arch/embgemma2` | `embeddinggemma2` | *(empty)* | EmbeddingGemma 2: a bidirectional encoder with Gemma 4's vision tower and audio conformer, pooled to one vector |
|
||||
| `arch/gemma4_bf16` | `gemma4` | `compressed-tensors` | Gemma 4 31B dense with its vision tower: sliding-window and proportional-RoPE global (`attention_k_eq_v`) attention, GELU ffn, softcapped logits; int4 codes with an f16 scale per 128 from Google's CT-INT4 (QAT) release or from bf16, served w4a8, or int8 codes on the same grid from bf16 (w8a8, the Q8 container). Optional draft model (`rad-convert --draft-model`): Google's assistant, with no cache of its own (`rad_drafter_shared_kv`), or z-lab's DFlash drafter, the block `arch/gemma4` serves (`arch/common/rad_gemma4_dflash.h`), or RedHatAI's DFlash2 speculator (`arch/common/rad_block_dflash2.h`) |
|
||||
| `arch/gemma4_bf16` | `gemma4` | `compressed-tensors` | Gemma 4 31B dense, and the E2B/E4B form at one rank, with its vision tower: sliding-window and proportional-RoPE global (`attention_k_eq_v`) attention, GELU ffn, softcapped logits; int4 codes with an f16 scale per 128 from Google's CT-INT4 (QAT) release or from bf16, served w4a8, or int8 codes on the same grid from bf16 (w8a8, the Q8 container). Optional draft model (`rad-convert --draft-model`): Google's assistant, with no cache of its own (`rad_drafter_shared_kv`), or z-lab's DFlash drafter, the block `arch/gemma4` serves (`arch/common/rad_gemma4_dflash.h`), or RedHatAI's DFlash2 speculator (`arch/common/rad_block_dflash2.h`) |
|
||||
| `arch/gemma3` | `gemma3` | *(empty)* | Gemma 3 dense text (TranslateGemma 27B) from the bf16 checkpoint: sliding-window and global attention at one head geometry, GemmaRMSNorm, GELU ffn; linears bf16, or int8, MXFP4 or asymmetric int4 over an activation scaled per (row, 128), as the recipe stores them. Optional DFlash2 drafter (`rad-convert --draft-model`) |
|
||||
| `arch/gemma4` | `gemma4` | *(empty)* | Gemma 4 text from Google's bf16 checkpoint (the 26B-A4B MoE and the dense sizes without per-layer embeddings) with z-lab's DFlash drafter; routed experts bf16 or block fp8 |
|
||||
| `arch/qwenimage21` | `qwenimage21` | *(empty)* | Qwen-Image 2.1 and 2.1-Turbo, an image generator, from the diffusers pipeline directory; DiT and text encoder bf16 or block fp8 |
|
||||
@@ -29,6 +29,7 @@ plugin claims.
|
||||
| `arch/qwen3asr_bf16` | `qwen3asr` | *(empty)* | Qwen3-ASR: a Whisper-style audio encoder over a dense Qwen3 decoder, speech to text |
|
||||
| `arch/minimaxmusic3` | `minimaxmusic3` | *(empty)* | MiniMax-Music3, songs from a description and lyrics: a Qwen3-8B frame model, a depth decoder, a flow-matching DiT and a DAC vocoder, from the diffusers pipeline directory, bf16 |
|
||||
| `arch/breeze` | `breeze` | *(empty)* | Breeze-TTS-2, speech from text and a description of the voice: a T5Gemma 2 text encoder, a Qwen3 backbone with a 16-codebook depth decoder and the Qwen3-TTS 12 Hz codec, from the release directory, bf16, one card |
|
||||
| `arch/fishomni` | `fishomni` | `bsgemm-moe` | Fish Audio drama-3, speech from text with speaker tags and inline direction, its voices cloned from reference clips: the Qwen3.5-35B-A3B backbone with its routed experts block fp8 at f32 scales and everything else bf16, a 13-layer codebook tower over the backbone's full-attention cache, and Fish S2's modified DAC, encoder and decoder (`codec.pth`, read as data); from the release directory, two cards |
|
||||
| `arch/minimaxh3` | `minimaxh3` | *(empty)* | MiniMax-H3, a video with its stereo soundtrack from text: Qwen3-VL-32B's language model as the text encoder, a 33B single-stream diffusion transformer, a tiled ViT video decoder and a BigVGAN audio decoder, from the diffusers pipeline directory; linears block fp8 (`data/recipes/minimax-h3-fp8.recipe`) |
|
||||
| `arch/ltx2` | `ltx2` | *(empty)* | LTX-2.5 (base and distilled), a video with its stereo soundtrack from text or from text and a first frame: Gemma 4's language model and two text connectors, the duration head, a dual-stream audio-video DiT with four-way guidance, the causal video VAE (tiled past the default canvas) or the diffusion decoder, the audio VAE with a BigVGAN vocoder and bandwidth extension, the x2 latent upsampler; bf16 or block fp8, one card |
|
||||
|
||||
@@ -228,7 +229,9 @@ Three groups, which is why hybrid KV groups are first-class:
|
||||
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
|
||||
but the plugins declare f32 because f16 changes the generated text; `--state-cache-dtype f16`
|
||||
declares f16 for a deployment that accepts the loss (GUIDE §4.4: on Qwen3.8-27B MXFP4, mean KL
|
||||
+0.9..+2.2 %, decode +10 % at sixteen streams without speculation). How a speculative step keeps a
|
||||
state it can roll back is `docs/OPS.md`'s `state_form`.
|
||||
|
||||
## FP8
|
||||
@@ -263,14 +266,24 @@ and every difference is behind `#if QWEN35_MOE` in the shared source. It is a se
|
||||
unit rather than a branch on `n_expert` because the id is half the selection key, and one `.so`
|
||||
cannot claim both ids.
|
||||
|
||||
The routed experts are served in the format the container stores, read from layer 0's first
|
||||
expert (`MoeFP8::probe`, as `qwen4exp` does): block FP8, the four-bit forms of
|
||||
[`docs/MOE-W4.md`](MOE-W4.md), whose rotated ones add a rotated copy of the block input (`moe_hr`),
|
||||
or OCP MXFP4 (`fp4_e2m1*e8m0[1x32]`, `data/recipes/sage-a1.5-mxfp4-df2.recipe`).
|
||||
Experts stored stacked or one by one are both read (`moe_expert_sources`). Plain bf16 experts are
|
||||
refused, since this plugin has no bf16 expert path. Tensor parallelism splits each expert's
|
||||
width, so the GPTQ calibration tap (`RADIANCE_CALIB_DIR`) runs at one rank only.
|
||||
|
||||
**Drafters.** The container's own MTP head is the default, and `rad-convert --draft-model` can
|
||||
replace it with a DFlash2 block drafter; the shared source declares it (`declare_dflash2`) and
|
||||
does not declare the MTP head when a DFlash2 drafter is present, so the routed trunk carries a dense drafter
|
||||
without further work. `sage-a1.5-fp8-df2.rad` is such a container: Sage-A1.5's routed trunk with
|
||||
replace it with a DFlash2 block drafter. The shared source selects the drafter from the container's
|
||||
`draft.architectures` (a DFlash2 model), declares it (`declare_dflash2`) and then does not declare
|
||||
the MTP head, so the routed trunk carries a dense drafter without further work.
|
||||
`sage-a1.5-fp8-df2.rad` is such a container: Sage-A1.5's routed trunk with
|
||||
`incoai/Qwen3.6-35B-A3B-DFlash2`, whose six 2048-wide layers read eight taps
|
||||
(`target_layer_ids` 1 6 11 16 22 27 32 37) and propose a block of seven tokens in one pass. At
|
||||
depth 7 it accepts ~49% of the proposals and decodes 1.40x faster than the same trunk with its MTP
|
||||
head (393 against 282 tok/s on two R9700s). `--num-speculative-tokens auto` takes the depth the
|
||||
head (393 against 282 tok/s on two R9700s). `sage-a1.5-mxfp4-df2.rad` is the same with the trunk,
|
||||
the experts and the drafter's linears at MXFP4. `--num-speculative-tokens auto` takes the depth the
|
||||
drafter states.
|
||||
|
||||
## `qwen35_w8a8`
|
||||
@@ -289,9 +302,13 @@ a plain int8 trunk is refused.
|
||||
- **The encoding is the only guard.** Rotated and plain int8 have the same bytes and extents, and
|
||||
the rotated weight against the plain quantiser measures rel_l2 ~1.0 (r4d_selftest, `i8a8h_rot`),
|
||||
so each dtype's layout hook takes only its own transform.
|
||||
- **Each rotated linear quantises its own input** from the bf16 plane its producer writes: q, k and
|
||||
v quantise one input three times, and no producer writes rotated codes yet. The MLP's gated fold
|
||||
is an fp8a8 tile over E4M3 codes, so an int8 gate_up runs the pair.
|
||||
- **The producers write the rotated codes** where libr4d declares the `_had_quant_i8g` ops: the
|
||||
norms (`rmsnorm_had_quant_i8g`, at two ranks `ar_rmsnorm_had_quant_i8g`) and the gated product
|
||||
(`gated_had_quant_i8g`) write `had_quant_act_i8g`'s bytes into the int8 pair (`ActFP8::q8_rot`),
|
||||
so q, k and v share one quantiser and down has none. The attention and delta-net outputs still
|
||||
take `had_quant_act_i8g` from the bf16 plane, and so does every linear where the ops are not
|
||||
declared (libref and libavx). The MLP's gated fold is an fp8a8 tile over E4M3 codes, so an int8
|
||||
gate_up runs the pair.
|
||||
- **It declines imported checkpoints** (`RAD_ARCH_SERVES_IMPORTS(0)`). An imported quantisation
|
||||
goes to the family's one quantised plugin, and a second one would refuse every Quark, ParoQuant,
|
||||
GPTQ or NVFP4 Qwen3.8 release; they stay with `qwen35_fp8`.
|
||||
@@ -433,12 +450,12 @@ the blocks share, places them and issues the step's order.
|
||||
|---|---|---|
|
||||
| `rad_block_glm_mhc.h` | `ManifoldConn` | the four-stream residual's read and write |
|
||||
| `rad_block_glm_kda.h` | `GlmKda`, `KdaState` | the 34 linear layers and their recurrence |
|
||||
| `rad_block_glm_mla.h` | `GlmMla`, `MlaLatent` | the 11 sparse MLA layers and their absorbed core |
|
||||
| `rad_block_glm_mla.h` | `GlmMla`, `MlaLatent` | the 11 sparse MLA layers, in the head form or the row form |
|
||||
| `rad_block_glm_indexer.h` | `GlmIndexer`, `DsaCache` | the DSA indexer, its key cache and selection |
|
||||
| `rad_block_glm_router.h` | `GlmRouter` | the correction-bias router, through `MoeFP8` |
|
||||
| `rad_block_glm_mtp.h` | `GlmMtp` | the draft head around the plugin's layer 45 |
|
||||
| `rad_block_glm_vision.h` | `GlmVision`, `MediaRows` | the tower, and its rows over the embeddings |
|
||||
| `rad_glm_tp.h` | `GlmTp`, `SplitF32Proj` | the shards, the split threshold, the column split of a replicated f32 projection |
|
||||
| `rad_glm_tp.h` | `GlmTp`, `SplitF32Proj` | the shards, the one row rule, the split thresholds, the column split of a replicated f32 projection |
|
||||
|
||||
```
|
||||
45 layers, hidden 4096, vocab 154880 (embedding and lm_head separate, bf16)
|
||||
@@ -534,45 +551,64 @@ at eight ranks each card holds 22.06 GiB of them, 19.67 GiB the routed experts.
|
||||
layer's latent, index and tail for every row and runs its MoE on the proposal rows only.
|
||||
|
||||
**Tensor parallelism.** At 1, 2, 4 or 8 ranks; declare refuses any other. `tests/glm5next_test.cpp`
|
||||
declares and steps the whole plugin at 1, 4 and 8, against pinned graph and step hashes at 1 and
|
||||
8, the connection, router and index-gate splits at 1, 2, 4 and 8, the indexer's row split at 2
|
||||
and 8, the row rule at every world, each issue's operand count against the loaded kernel
|
||||
libraries' schemas, and every declared weight against the served container's names and encodings.
|
||||
declares and steps the whole plugin at 1 and 8 against pinned graph and step hashes (the head form,
|
||||
the row form), the connection, router and index-gate splits at 1, 2, 4 and 8,
|
||||
the indexer's row split at 2 and 8, the MLA row split at 1, 2, 4 and 8, the row rule at every
|
||||
world, each issue's operand count against the loaded kernel libraries' schemas, and every declared
|
||||
weight against the served container's names and encodings.
|
||||
|
||||
One row rule (`GlmTp::run_rows`): from a pass of `GlmTp::kSplitRows` = 256 rows, a replicated
|
||||
piece of work splits by rows over the ranks instead, each rank taking one run of ceil(T / world)
|
||||
rows rounded up to whole 16-byte words of the row it gathers, because an `all_gather` moves whole
|
||||
words: multiples of four rows for the indexer's one i32 length a row. The last run may be short;
|
||||
a rank whose run lies wholly past a small step takes the first run and computes dead rows, so
|
||||
every plane it gathers is written (`GlmTp::run_of`). The indexer also splits a smaller step, from
|
||||
16 rows once rows x live blocks reach 2^18 (`GlmTp::kSplitWork`). Below the thresholds, as in
|
||||
decode, the collective costs more than it saves and every rank runs the replicated form.
|
||||
One row rule (`GlmTp::run_rows`): from a pass of `GlmTp::kSplitRows` = 256 rows, a replicated or
|
||||
head-split piece of work splits by rows over the ranks instead, each rank taking one run of
|
||||
ceil(T / world) rows rounded up to whole 16-byte words of the row it gathers, because an
|
||||
`all_gather` moves whole words: whole rows for the MLA's 4096-wide bf16 output, multiples of four
|
||||
rows for the indexer's one i32 length a row. The last run may be short; a rank whose run lies
|
||||
wholly past a small step takes the first run and computes dead rows, so every plane it gathers is
|
||||
written (`GlmTp::run_of`). The indexer alone also splits a smaller step, from 16 rows once rows x
|
||||
live blocks reach 2^18 (`GlmTp::kSplitWork`). Below the thresholds, as in decode, the collective
|
||||
costs more than it saves and every rank runs the replicated or head-split form.
|
||||
|
||||
- The routed and the shared experts split their 2048 width into equal contiguous slices, 256 a
|
||||
rank at eight; each rank computes its slice of every expert, and the block's all-reduce sums
|
||||
them. The dense feed-forward splits its 12288 the same way.
|
||||
- MLA splits by whole heads: the rows of q_b and kv_b (8 heads a rank at eight) and the columns
|
||||
of o. q_a, kv_a and the latent are replicated.
|
||||
of o. q_a, kv_a and the latent are replicated. Under `--tp-attn-split rows`
|
||||
(RadBuildCtx::tp_attn_rows, docs/GUIDE.md §4.7), from the threshold, it splits by rows instead
|
||||
(`GlmMla::Form::rows`): each rank takes its run under the row rule, the last run shorter,
|
||||
through q_b, absorption, attention with all 64 heads (`mla_attn_rows_bf16`, docs/OPS.md),
|
||||
expansion and o, and an `all_gather` of whole runs takes the all-reduce's place. The latent
|
||||
cache and the DSA selection are whole on every rank, so nothing is exchanged before the
|
||||
attention. Each rank sends its run to seven peers, half the bytes of the two-shot all-reduce,
|
||||
and the gather shares that all-reduce's exchange instance. The price is q_b, kv_b and o at full
|
||||
width on every rank, 120 MiB a layer and 1.29 GiB a card over the 11 trunk layers (the MTP layer
|
||||
keeps its heads), about 0.1 GiB of activations besides. The head form is the default because
|
||||
the row form is not bit-identical to it, and this model turns that into a measurable
|
||||
divergence: against the head form over a 66,657-position corpus of English, German and code at
|
||||
eight ranks the row form scores a mean KL of 0.038 (median 0.010, p99 0.357, top-1 agreement
|
||||
91.9 %). The projections are not the cause (q_b and o give the head form's bytes, and o summed
|
||||
as eight rank partials leaves the KL where it is); the attention's rounding is: the rows kernel
|
||||
parts from the paired tile in about 0.1 % of every row's outputs by one bf16 step, and the
|
||||
16-head tile, which parts in the same share of every second row only, halves the KL. On eight
|
||||
R9700 at Gen5 links the row form prefills a 20k-token prompt at 5,016 tok/s against 4,246 in
|
||||
the head form (+18 %) and a 64k-token one at 4,975 against 4,117 (+21 %); decode is unchanged.
|
||||
- KDA splits its 64 heads, with them the q/k/v rows, the convolution taps and the state; the two
|
||||
rank-128 projections into the gates are replicated.
|
||||
- The indexer's key side is replicated: every rank keeps the whole index cache and its tail. Its
|
||||
query side splits by rows from the threshold: each rank scores its run under the row rule,
|
||||
R = 4 * ceil(T / (4 * ranks)) query rows (`DsaCache::part_rows`), against the whole cache
|
||||
(`dsa_score` with `row_part`, the last run's rows past the step scoring `-inf`) and selects for
|
||||
the rows of its run that exist, under the bounds the scorer rebased to the run's first row
|
||||
(`cu_part`, docs/OPS.md); two `all_gather`s lay the runs' page tables and lengths end to end,
|
||||
513 and 1 i32 a row, 8 MiB a layer at a 4096-row chunk. The run's queries are all a rank needs,
|
||||
so the query projection, its quantiser and the head gates run on the run's rows too, and the
|
||||
gates need no gather; the bf16 projection stays on the step's rows where a run would be 64 rows
|
||||
or fewer, the skinny band whose split count a tuned configuration may set. Each row's selection
|
||||
is the same kernels' answer to the same operands, so the joined table is bit-identical to one
|
||||
rank's and MLA reads it unchanged. The scoring grows with the context (every row scores every
|
||||
complete block of its sequence), so this is where long prompts gain: the score plane shrinks to
|
||||
one run (256 MiB to 32 MiB at 64k of context and a 4096-row chunk). A smaller step splits too
|
||||
from 16 rows once rows x live blocks reach 2^18 (`GlmTp::kSplitWork`): eight sequences
|
||||
verifying five drafts from about 22k of context, where the scoring of 48 rows outweighs the two
|
||||
gathers; a single sequence's decode never does, and below both thresholds the indexer runs
|
||||
whole.
|
||||
R = 4 * ceil(T / (4 * ranks)) query rows (`DsaCache::part_rows`), against the whole cache (`dsa_score` with `row_part`,
|
||||
the last run's rows past the step scoring `-inf`) and selects for the rows of its run that exist,
|
||||
under the bounds the scorer rebased to the run's first row (`cu_part`, docs/OPS.md); two
|
||||
`all_gather`s lay the runs' page tables and lengths end to end, 513 and 1 i32 a row, 8 MiB a layer
|
||||
at a 4096-row chunk. The run's queries are all a rank needs, so the query projection, its
|
||||
quantiser and the head gates run on the run's rows too, and the gates need no gather; the bf16
|
||||
projection stays on the step's rows where a run would be 64 rows or fewer, the skinny band whose
|
||||
split count a tuned configuration may set. Each row's selection is the same kernels' answer to
|
||||
the same operands, so the joined table is bit-identical to one rank's and MLA reads it unchanged.
|
||||
The scoring grows with the context (every row scores every complete block of its sequence), so
|
||||
this is where long prompts gain: the score plane shrinks to one run (256 MiB to 32 MiB at 64k of
|
||||
context and a 4096-row chunk). A smaller step splits too from 16 rows once rows x live blocks
|
||||
reach 2^18 (`GlmTp::kSplitWork`): eight sequences verifying five drafts from about 22k of
|
||||
context, where the scoring of 48 rows outweighs the two gathers; a single sequence's decode never
|
||||
does, and below both thresholds the indexer runs whole.
|
||||
- The vocabulary is row-sharded, 19360 rows a rank at eight; the embedding's all-reduce is exact.
|
||||
- The f32 projections (the router's 288 x 4096, the index head gates' 32 x 4096, each
|
||||
connection's mHC projection of 24 x 16384) are replicated. From a pass of 256 rows
|
||||
@@ -872,12 +908,20 @@ and the drafter reads it through the same scale.
|
||||
(slice A whole 128-row tiles, both at least 512) and runs each slice's two all-reduces per layer on
|
||||
the second lane beside the other slice's compute, as the prefill overlap above does, with one
|
||||
difference: o_proj and down_proj both write `h`, so the issue order never lets lane 0 write rows of
|
||||
`h` that lane 1 is reducing, and `h` is the one buffer taken out of the arena's sharing. Attention
|
||||
runs whole. Both slices are above every row band the sliced kernels have (the int8 GEMMs' skinny
|
||||
band at 64, since the prefill kernel takes each row's K in order whatever M is, and
|
||||
r4d_act_threads' last width change at 120 rows for these widths), so on the exact wire the output
|
||||
equals the whole step's bit for bit. Every junction must be fused, as the w4a8 and w8a8
|
||||
containers' are; a bf16 trunk runs whole, and so does every step under `RADIANCE_GEMMA4_OVERLAP=0`.
|
||||
`h` that lane 1 is reducing, and `h` is the one buffer taken out of the arena's sharing. On a
|
||||
one-sequence step the attention runs per slice too (slice A's projection, prologue, attention and
|
||||
o_proj, then slice B's), so each of a layer's four reductions sits beside a whole block; slice
|
||||
A's attention takes its context end from `kv_len_trim`, the step's context less slice B's rows. A
|
||||
step of several sequences, a multi-component rotary or a library without `kv_len_trim` runs the
|
||||
attention whole. The lane-1 reductions are their own ops at `overlap` 1: libr4d's narrow
|
||||
four-block two-shot, whose pushes carry about 12.2 bits a bf16 value where the message fits that
|
||||
form, with the same bytes. Both slices are above every row band the sliced kernels have (the int8
|
||||
GEMMs' skinny band at 64, since the prefill kernel takes each row's K in order whatever M is, and
|
||||
r4d_act_threads' last width change at 120 rows for these widths), and a slice's attention rows see
|
||||
exactly the keys they see in the whole step, so on the exact wire the output equals the whole
|
||||
step's bit for bit. The overlap is a fixed rule: it runs wherever every junction is fused (as the
|
||||
w4a8 and w8a8 containers' are) and the all-reduce wire is exact; a bf16 trunk, or `--tp-wire
|
||||
wht6`, runs every step whole, and the startup notes say which.
|
||||
|
||||
**The 31B's q, k and v as one linear.** Converted with a recipe that names `blk.*.attn_qkv.weight`
|
||||
(both -df recipes do), each layer's q, k and v (q and k on a global layer, where v is k) are one
|
||||
@@ -887,7 +931,8 @@ The grid's groups never cross a row, so the codes are those of three separate ru
|
||||
the replies are too. On libr4d the skinny GEMM picks its in-block K split from N (k and v alone
|
||||
split K in two, the fused GEMM does not), so k and v can round differently in the last bit and a
|
||||
long greedy reply can part from the old container's late. `qkv_norm_rope` and `kv_store` work on
|
||||
the row's column slices in place. Attention reads q in the row through `attn_paged_qrow`: a global
|
||||
the row's column slices in place, as one launch (`qkv_norm_rope_kv_store`, byte-identical to the
|
||||
pair) where a library serves it. Attention reads q in the row through `attn_paged_qrow`: a global
|
||||
layer at every height (the windowed kernel, which serves head_dim 512 under `attn_paged` too), a
|
||||
sliding layer up to 32 query rows a sequence (libr4d's h256/gqa2 split-KV decode with q at a pitch,
|
||||
so a verify step included); a taller sliding step (a prefill) copies q out with a `cast` for the
|
||||
@@ -917,21 +962,69 @@ layers 0 16 28 46 58 (`gemma4::dflash2_taps`). It was trained against the target
|
||||
plain embedding and the target's head as a plain linear, so its lookup takes no Gemma scale and its
|
||||
head no soft-cap. The -df2 recipe stores its head copy int8 (`head_i8`, read at w8a8) rather than
|
||||
the 2-bit grid Qwen3.8's recipes use, so the selector ranks what an 8-bit head proposes. Its
|
||||
attention is the sliding layers' h256 gqa-2 split-KV decode, non-causal. `run-gemma4-31b.sh`
|
||||
takes it with `DRAFTER=df2`.
|
||||
attention is the sliding layers' h256 gqa-2 split-KV decode, non-causal. Where libr4d serves them,
|
||||
each layer's norm, rotary and cache-store chain is one `qkv_norm_rope_kv_store` launch in either
|
||||
pass (`v_norm` 0; `n_head` 0 in the context pass, which writes keys and values only), and each
|
||||
residual add is folded into the norm after it (`add_rmsnorm`), all byte-identical to the chains;
|
||||
Qwen3.8's head-128 DFlash2 drafter keeps the prologue chains and folds only the adds. At two ranks
|
||||
or more a block-fp8 `fc` is split by rows (`rad_block_dflash2.h`, SHARDING), each rank computing
|
||||
the whole 128-row scale blocks that cover its share of the columns and an `all_gather` assembling
|
||||
them, with `gemm_nt_q`'s `split_n` keeping every output the unsplit fc's to the bit. The recipe is
|
||||
`gemma4-31b-dense-bf16-w4a8-df2.recipe`.
|
||||
|
||||
**The 31B's junctions at four ranks.** At two ranks every junction carries the all-reduce in front
|
||||
of it (`ar_rmsnorm_quant_i8`). At four it does too, at decode heights. libr4d's
|
||||
`ar_rmsnorm_quant_i8_4rank` is the exact four-rank one-shot with the junction as its epilogue,
|
||||
byte-identical to `all_reduce` + `rmsnorm_quant_i8`. A one-shot sends three times the message per
|
||||
rank, so the plugin declares it only up to 4 rows and issues the pair in a taller step. On 4x
|
||||
R9700 the fold made plain decode 5.6% faster (94 against 89 tok/s) and a DFlash verify (16 rows)
|
||||
9% slower (276 against 300), where the standalone all-reduce is the exact two-shot. A decode step
|
||||
at tp 4 then has two standalone reductions (the embedding's and the last feed-forward's) where it
|
||||
had 121. It gives the pair's greedy text byte for byte. At sixteen rows of 5376 the junction is
|
||||
55 us against 22 at one row (--profile-ops): its handshakes, not its bytes, set it.
|
||||
`r4d_selftest --case ar_rmsnorm_quant_i8_4rank` checks it on four cards, and the startup note says
|
||||
which form a deployment takes.
|
||||
of it (`ar_rmsnorm_quant_i8`). At four it does too, in steps of up to 16 rows (decode, and a DFlash
|
||||
or DFlash2 verify), on libr4d's `ar_rmsnorm_quant_i8_4rank`, in a form chosen by height. Every form
|
||||
is byte-identical to `all_reduce` + `rmsnorm_quant_i8`:
|
||||
|
||||
- 1 to 3 rows: the exact four-rank one-shot with the junction as its epilogue. A one-shot sends
|
||||
three times the message per rank and takes a fenced handshake per row, so it pays only at the
|
||||
bottom: on 4x R9700 it made plain decode about 5% faster (90 against 86 tok/s), and at 16 rows it
|
||||
would be 9% slower than the pair.
|
||||
- 4 to 16 rows: the all-reduce split around the junction (`sp`). Each rank reduces the quarter of
|
||||
the rows it owns, runs the junction on them and gathers the int8 codes, so the second hop carries
|
||||
a byte a column and the junction a quarter of the rows. The residual then holds the rank's own
|
||||
rows only, which is all the next junction reads; the junctions where the drafter taps the
|
||||
stream, and the last layer's attention junction, gather it on every row (`sp` 2). On 4x R9700 a
|
||||
DFlash2 verify (8 rows) ran about 2% faster than with the tail form below.
|
||||
- libr4d's row also has a tail form for 5 to 32 rows, the exact two-shot with the junction run
|
||||
after it in the same launch; the 31B takes it only where the split form is not declared.
|
||||
|
||||
A taller step issues the pair (the split form lost about 10% under load at 24 to 64 rows). A decode
|
||||
step at tp 4 then has two standalone reductions (the embedding's and the last feed-forward's) where
|
||||
it had 121. `r4d_selftest --case ar_rmsnorm_quant_i8_4rank` checks every form on four cards, and
|
||||
the startup note says which forms a deployment takes.
|
||||
|
||||
**Weight reads beside the all-reduces.** At more than one rank, on decode and verify steps of up to
|
||||
16 rows that carry no prompt rows, the 31B reads the next GEMM's leading weight bytes into the
|
||||
on-die cache (libr4d `prefetch`) while an all-reduce leaves the card's memory idle: gate_up's first
|
||||
20 MB beside the attention's reduction, the next layer's q|k|v (the lm_head after the last layer)
|
||||
beside the feed-forward's, and down_proj's first 9 MB beside the attention; its DFlash2 drafter
|
||||
reads each reduction's following projections the same way. Where launches chain the read is the
|
||||
chained form right behind the GEMM before the reduction, otherwise it rides the second lane. The
|
||||
reads change no value; on 4x R9700 the 31B with DFlash2 decoded 15% faster with them, and without
|
||||
a drafter about 2%.
|
||||
|
||||
**The E2B/E4B form.** `arch/gemma4_bf16` serves Gemma 4's small dense form (tested on
|
||||
NVIDIA-Nemotron-3.5-Bolt-E4B, `deploy/compose/nemotron-3.5-bolt-e4b-bf16.yaml`) at one rank:
|
||||
- KV-shared layers: from layer `n_layer - num_kv_shared_layers` on, a layer projects q only and
|
||||
attends over the cache of the last earlier layer of its class that keeps one (E4B: sliding layers
|
||||
read 22, full layers 23). Shared layers are not bound to a KV group, so their pages hold nothing.
|
||||
- Per-layer embeddings (`hidden_size_per_layer_input`): a token table scaled by sqrt(width), plus
|
||||
the normed projection of the scaled embedding, mixed at 2^-0.5. Each layer runs a branch after
|
||||
its feed-forward: gate, gelu times its slice, projection, norm, add. On a w4a8 or w8a8 trunk
|
||||
the junction closes that branch instead of the feed-forward. Image positions read the pad
|
||||
token's row of the table, as the reference does. The branch is not split across ranks, so a
|
||||
deployment at more than one rank is refused.
|
||||
- The global class may keep its own v (`attention_k_eq_v` 0) and leave
|
||||
`num_global_key_value_heads` null; it then takes `num_key_value_heads`.
|
||||
- The vision tower's clipped linears (`use_clipped_linears`) clamp each projection's input and
|
||||
output to the bounds the checkpoint stores (`rad_block_gemma4_vision.h`).
|
||||
|
||||
NVIDIA's DFlash drafter states `dflash_config.causal: false`, with every layer sliding; that flag
|
||||
sets the sliding layers' causality. The recipes are `gemma4-e4b-bf16-df`, `-w8a8-df`, `-w4a8` and
|
||||
`-w4a8-df`. The bf16 container's KL to HF bf16 is 0.0015 with bf16 KV and 0.014 with fp8 KV, so
|
||||
the compose file serves bf16 KV.
|
||||
|
||||
**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
|
||||
@@ -1038,11 +1131,26 @@ above), which matters little for translation prompts, whose shared prefix is a l
|
||||
A linear reading the same activation as the one before it (k and v after q, up after gate) reuses
|
||||
its codes. On every trunk the q and k norms and both rotaries are one `qkv_norm_rope` at `v_norm` 0.
|
||||
On an MXFP4 trunk each junction (the branch's post-norm, the residual add, the next norm and the
|
||||
next linear's E4M3 quantiser) is one `ar_rmsnorm_post_quant_fp8` at two ranks on the exact wire,
|
||||
the branch's all-reduce in the same launch, or a post-norm and `rmsnorm_quant_fp8` otherwise; a
|
||||
w4a8 / w8a8 trunk takes `gemma4_bf16`'s fused junctions; an i8a8 or asymmetric-int4 trunk runs the
|
||||
chain. Where a row is missing the plugin declares the chain, and the startup notes say which form
|
||||
each took. Under calibration no junction is fused (below).
|
||||
next linear's E4M3 quantiser) is one `ar_rmsnorm_post_quant_fp8` at two ranks, the branch's
|
||||
all-reduce in the same launch, or a post-norm and `rmsnorm_quant_fp8` otherwise; a w4a8 / w8a8
|
||||
trunk takes `gemma4_bf16`'s fused junctions; an i8a8 or asymmetric-int4 trunk runs the chain.
|
||||
Where a row is missing the plugin declares the chain, and the startup notes say which form each
|
||||
took. Under calibration no junction is fused (below).
|
||||
|
||||
The two fused all-reduce junctions (`ar_rmsnorm_post_quant_fp8`, and `ar_rmsnorm_quant_i8` on a
|
||||
w4a8 / w8a8 trunk's int8 junction) send the exact wire only, and are byte-identical to
|
||||
`all_reduce` followed by the chain. Under `--tp-wire wht6` they are declared all the same and taken
|
||||
per step where the message goes out exact anyway (`ar_wire_is_exact`: a decode step of a few rows,
|
||||
under `--tp-wire-min-kb`); a wider step keeps the lossy all-reduce, unfused, so a lossy-wire
|
||||
deployment's decode takes one launch a junction instead of three (all-reduce, post-norm,
|
||||
junction). A fused step is the unfused exact step bit for bit.
|
||||
|
||||
**Pipelined prefill.** At two ranks an MXFP4 trunk with the fused fp8 junctions prefills a prompt
|
||||
of 1024 tokens or more in two pieces, the junctions and all-reduces of one beside the other's
|
||||
compute (GUIDE §4.5). The window KV group's `seqused` counts from its
|
||||
rebased first block, so the first piece's bound is computed on the card (`sub_i32`: the group's
|
||||
`seqused` less the second piece's rows), not taken from its position. The gain needs 1024-row
|
||||
pieces: serve at `--max-num-batched-tokens 2048`.
|
||||
|
||||
**Calibration.** Serve a calibration container (int8, `translategemma-27b-i8a8.recipe`: KL 0.003
|
||||
against bf16, and it fits two 32 GB cards) with `RADIANCE_CALIB_DIR` set, push a corpus of the
|
||||
@@ -1158,6 +1266,12 @@ VAE Qwen-Image's (Wan 2.1's causal 3-D convolutions on one frame), 16 chan
|
||||
schedule Raw: 28 steps, the resolution-shifted schedule of its scheduler config, guidance 4.5 in
|
||||
the card's terms against an empty negative prompt; Turbo: 8 steps at a fixed shift
|
||||
(mu 1.15), no guidance. Raw or Turbo is read from the pipeline and scheduler config
|
||||
rebalance a request's `rebalance` (RAD_GEN_COND_REBALANCE, declared in cond_opts): each tap
|
||||
times a fixed gain before the fusion, ComfyUI's ConditioningKrea2Rebalance at its
|
||||
defaults, 4, 4, 4, 4, 4, 4, 4, 10, 20, 4.4, 16, 4; chan_affine in f32, rounded once,
|
||||
from te.x into te.h2, which the tap's scatter then reads. The gains cannot be folded
|
||||
into weights: the taps enter the layer-wise fusion blocks raw, through a pre-norm
|
||||
residual. Without it no scale is issued and the taps are scattered from te.x
|
||||
```
|
||||
|
||||
Traps:
|
||||
@@ -1545,6 +1659,147 @@ codes. Whisper large-v3 transcribes radiance's speech word for word.
|
||||
|
||||
---
|
||||
|
||||
# `fishomni`: Fish Audio drama-3, speech
|
||||
|
||||
`arch/fishomni` declares an audio generator in its chunked form with one branch a request
|
||||
(`rad_declare_audio_generator`, `branches` 1, `voc_chunk`): PROMPT runs the backbone over the
|
||||
whole prompt and the codebook tower over every prompt row, FRAME draws one frame of every speech in
|
||||
flight and runs the backbone over its embedding, VOCODE plays a lane's newest frames, sixteen at
|
||||
most. It is served on `/v1/audio/speech` and `/v1/audio/speech/stream` ([GUIDE §5.15](GUIDE.md)),
|
||||
on two cards. The checkpoint is the release directory; its codec, `codec.pth`, is read with it as
|
||||
checkpoint tensors under `codec.` (a `torch.save` archive, read as data and never unpickled:
|
||||
`core/format/torch_zip.h`).
|
||||
|
||||
```
|
||||
backbone Qwen3.5-35B-A3B's language model, unchanged: 40 layers of 2048, three gated delta-net
|
||||
layers to one gated attention layer (16 q / 2 kv heads of 256, NeoX rotary on 64 dims
|
||||
at theta 1e7), 256 experts of 512 at top-8 and a gated shared expert of 512, (1 + w)
|
||||
norms but the delta net's output norm. Only the routed experts are fp8 (E4M3 at an f32
|
||||
scale a 128 x 128 block, `quant_method: bsgemm-moe`); the rest is bf16. A prompt row is
|
||||
a token; a frame's row is bf16(bf16(E_lm[248099 + c0] + E_cb[4096 + c1]) / sqrt 2):
|
||||
code 0 through its semantic token, code 1 through section 1 of the codebook table
|
||||
head the main token over 4097 candidates only, the end of speech (248046) and the 4096
|
||||
semantic tokens in id order: the lm_head's rows for them, replicated (the full head is
|
||||
never declared)
|
||||
tower 13 layers bound as layers 40..52 of the backbone's full-attention KV group, causal over
|
||||
the whole sequence at the backbone's positions: 4 shared layers that inject code 0, then
|
||||
one a codebook, layer k injecting code k - 1 and its head drawing code k (4096 outputs).
|
||||
A layer is m = eh_proj([enorm(e); hnorm(h)]), a pre-norm block (q, gate, k, v from
|
||||
wqkv's rows [Q 4096 | G 4096 | K 512 | V 512], (1 + w) q/k norms, GPT-J rotary on 64
|
||||
dims at 1e7, attention * sigmoid(gate), SwiGLU 6144), a final (1 + w) norm. The first
|
||||
shared layer also adds the input frame's codes 2..9, embedded and summed in f32
|
||||
sampling temperature 1.0, top-p 0.9 over the whole candidate set, then the top-k: the main
|
||||
token uncapped (256) and each head 30, as SGLang-Omni draws; a semantic first draw
|
||||
among the lane's last 16 picks is redrawn at 1.0 / 0.95 / 30 (`ras_pick`)
|
||||
codec Fish S2's modified DAC decoder: ten raw codebook rows of 8 (one of 4096, nine of 1024,
|
||||
codes 1..9 clamped to 1023), each through its own weight-normed 1x1 projection to 1024
|
||||
and summed; 8 layers of 1024 (16 heads of 64, GPT-J rotary on all 64 at theta 1e4,
|
||||
causal over 128 frames, plain RMS norms at 1e-5, layer scales); twice a transposed
|
||||
conv k2 s2 and a ConvNeXt block; a causal conv k7 to 1536; four blocks of snake, a
|
||||
weight-normed causal transposed conv (8, 8, 4, 2) and three residual units (dilations
|
||||
1, 3, 9); snake and a conv k7 to one channel, tanh: 2048 samples a frame, 44.1 kHz mono
|
||||
encoder the codec's, for a reference clip (mono 44.1 kHz, padded to whole frames): a causal
|
||||
weight-normed conv k7 to 64; four blocks of three residual units (snake, conv k7 at
|
||||
dilations 1, 3, 9, snake, conv k1) and a snake and a causal conv of kernel two strides
|
||||
(2, 4, 8, 8), doubling the channels; after the last a 4-layer transformer (window 512
|
||||
rows); snake, conv k3; twice a causal conv k2 s2 (plain weights) and a ConvNeXt block;
|
||||
the 8-layer pre-quantiser transformer (window 128 frames); the semantic codebook's
|
||||
nearest code by cosine, then nine residual steps (`vq_encode`): ten codes a frame
|
||||
```
|
||||
|
||||
The passes, which shift the tower by a row against the reference's loop:
|
||||
|
||||
- **PROMPT** runs the backbone over the prompt and leaves its last row's final-norm hidden state in
|
||||
the lane, then runs the tower over every row, teacher-forced: each row's label is the row after
|
||||
it, which in a text prompt is text, so every layer's code embedding is zero (the
|
||||
concatenation's embedding half is filled with zeros once). With references the codec's encoder
|
||||
first turns the request's clips into frames, written into a code plane at the prompt rows that
|
||||
name them (`RadAudioGenBatch::ref_frame`); a frame's row is embedded as a made frame's is, a row
|
||||
before a frame is labelled with it, a frame's row carries its own codes 2..9, and the window of
|
||||
main picks starts with the prompt's last 16 rows. The last row's tower pass belongs to the first
|
||||
frame; FRAME 0 writes its cache rows again.
|
||||
- **FRAME j** draws the main token from the hidden state of the row before the frame's (the
|
||||
prompt's last for frame 0), runs the tower at THAT row's position, cache slot and context
|
||||
(`RadAudioGenBatch::prev_slot`, `prev_pos`, `prev_used`) drawing codes 1..9, stores the frame,
|
||||
and runs the backbone over its embedding at the frame's own row.
|
||||
|
||||
Traps (each still speaks, wrongly):
|
||||
|
||||
- **The experts' scale planes are f32**, not the bf16 of Qwen3.6-35B-A3B-FP8: the expert format is
|
||||
read per layer (`MoeFP8::probe`), served as fp8a8f32.
|
||||
- **The tower's wqkv is blocked, `[Q | G | K | V]`**, not the backbone's per-head `[q_h | gate_h]`
|
||||
pairs; its rotary is GPT-J's adjacent pairs, not the backbone's halves; its q/k norms run with
|
||||
`(1 + w)` although its config says `attention_qk_norm: false` (the exporter never wrote it).
|
||||
- **`eh_proj` reads `[enorm(e); hnorm(h)]`**, the embedding half first.
|
||||
- **Two masks.** A layer's code embedding is the label frame's, zero when the label is text; the
|
||||
input frame's codes 2..9 go into the first shared layer only, zero when the input row is text.
|
||||
The layers that inject code 0 read it by candidate, with the table's row 0 again in front: the
|
||||
end of speech's code 0 is clamped to 0, as fish-speech clamps it.
|
||||
- **The tower attends over the whole sequence**, prompt rows included, from 13 caches of its own;
|
||||
it is not an 11-position depth decoder (`max_seq_len` 11 is left over from S2).
|
||||
- **The candidates' softmax is over the 4097 only**, top-p over all of them and the top-k cut after
|
||||
it; a full-vocabulary softmax keeps a different nucleus.
|
||||
- **The codec's residual codebooks have 1024 entries** and the heads 4096 outputs: codes are clamped
|
||||
at 1023 at decode (`rvq_embed`'s `clamp`). Its weight norm is per output channel for the convs
|
||||
and per INPUT channel for the transposed convs (`[in, out, k]`), folded at convert.
|
||||
- **The encoder's transformer window is 512 rows**, not the 128 frames of the quantiser's: the
|
||||
window comes from `getattr` on a `functools.partial` config, which has no such attribute, so
|
||||
fish-speech's default of 512 holds. Both its transformers and the codec's convolutions are
|
||||
causal, so a clip right-padded to whole frames encodes its frames as the clip alone would.
|
||||
- **The reference prompt is tokenised a literal at a time**: the instruction's closing `:` and the
|
||||
first header's `\n\n` are one token when the two are joined. A transcript's speaker tag must
|
||||
follow `Text: ` directly, so white space before it moves behind it.
|
||||
- **The input is written as fish-speech's server writes it**: each speaker's turn
|
||||
`<|speaker:N|> ` and its text stripped, turns joined by a newline, untagged text speaker 0's.
|
||||
The same two turns joined by a space are spoken through far less often: for one two-line script,
|
||||
at fish-speech's sampling, one seed in six spoke both lines, against seven in ten with the
|
||||
newline.
|
||||
|
||||
Against fish-speech's own PyTorch code (the CPU path: experts fp8, dequantised per forward, so
|
||||
W8A16 where radiance runs W8A8), teacher-forced with radiance's codes over a 34-row prompt and 80
|
||||
frames: the prompt's token ids are identical; the backbone's hidden state is 5.3% from the
|
||||
reference's (relative L2, median over the frames; cosine at least 0.993), the experts' fp8
|
||||
activations most of it; the main token's candidate logits 3.6% (KL 0.013 nats a frame, the same
|
||||
argmax in 92.5% of frames); the nine heads' logits 1.35% (KL 0.007, the same argmax 93% of the time)
|
||||
over the 79 frames that are spoken. Through the codec, radiance's chunked bf16 decode is 35.4 dB SNR
|
||||
from the reference's whole-utterance bf16 decode of the same codes. Qwen3-ASR transcribes
|
||||
radiance's speech word for word.
|
||||
|
||||
The encoder against fish-speech's codec encoding the same clip (11.6 s, 250 frames) on the CPU:
|
||||
radiance's bf16 encoder gives the f32 reference's semantic code in 99.2% of the frames, and its
|
||||
residual codes in 97.6% (the first) down to 81.2% (the ninth); fish-speech's own bf16 encode gives
|
||||
95.6% and 94.0% down to 71.2% against the same f32. The reference prompt's token ids are
|
||||
fish-speech's. Cloning, scored by median F0 and Qwen3-ASR over eight seeds a case, the reference
|
||||
clips drama-3's own takes of invented sentences: without a reference a sentence's eight takes are
|
||||
eight voices (116 to 251 Hz); with a reference of a 188 Hz voice they come out at 175 to 210 Hz,
|
||||
of a 200 Hz voice at 197 to 250 Hz, of a 108 Hz voice at 96 to 122 Hz; two references tagged as
|
||||
speakers 0 and 1 voice a two-line exchange's turns at 193 to 210 Hz and 109 to 140 Hz. Every take
|
||||
but one is transcribed word for word (the miss is "I'm" for "I am"). A 12 s clip adds 0.12 s
|
||||
before a stream's first audio.
|
||||
|
||||
The sampling is not fish-speech's server's (temperature 0.7, top-p 0.7, top-k 30 for every draw).
|
||||
At those the model falls silent after a tag or a speaker's line and does not come back, the failure
|
||||
vLLM-Omni's recipe and SGLang-Omni's notes describe; SGLang-Omni's comment puts it on the main
|
||||
token's top-k cap, and the counts bear it out. Ten seeds each of four short scripts (an aside in
|
||||
`<whisper>`, two two-speaker exchanges, a plain sentence), complete by Qwen3-ASR, and stuck (run to
|
||||
the 400-frame limit in silence):
|
||||
|
||||
| temperature, top-p, top-k (main / heads) | complete | stuck |
|
||||
|---|---|---|
|
||||
| 0.7, 0.7, 30 / 30 (fish-speech's server) | 28 / 40 | 8 / 40 |
|
||||
| 1.0, 0.9, 30 / 30 (Fish Audio's model card) | 35 / 40 | 2 / 40 |
|
||||
| 1.0, 0.9, 256 / 30 (SGLang-Omni) | 36 / 40 | 0 / 40 |
|
||||
|
||||
The four misses at the last setting are a take that ended before the line after the whisper (twice),
|
||||
a second speaker's single word, and one word the recogniser misheard; the whispered line itself is
|
||||
spoken in all ten. A take still pauses a second or so around an aside.
|
||||
|
||||
On two R9700s a sentence is made at 0.30 of the time it plays (3.67 s of speech in 1.08 s, 13.5 ms
|
||||
a frame with the codec), a paragraph at 0.29 (11.6 s in 3.34 s); a stream's first audio comes
|
||||
0.23 s after the request; four paragraphs at once make 50.4 s of speech in 5.15 s.
|
||||
|
||||
---
|
||||
|
||||
# `minimaxh3`: MiniMax-H3, video with sound
|
||||
|
||||
`arch/minimaxh3` declares a video generator (`rad_declare_video_generator`), which makes the
|
||||
@@ -1774,7 +2029,7 @@ Traps:
|
||||
first decoded garbage and the first one partly.
|
||||
- **The MP4 is not a parity instrument.** H.264 at CRF 18 in yuv420p moves a random-weight
|
||||
model's frames by about 40 levels on its own; compare the frames before encoding (the op
|
||||
oracle's patch_pix8 output).
|
||||
oracle's tile_stitch output).
|
||||
|
||||
Against diffusers' pipelines in bf16 on a tiny random-weight pipeline of the same layout (256x256,
|
||||
17 frames, from the same latents), the first frame's row sums agree to within 0.2% at 2 unguided
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
The story behind `step_ns_decode_best`, `step_ns_decode_recent`, and why the
|
||||
dashboard shows them without a verdict. Written 2026-10-18, the day all of it
|
||||
happened. The user-facing explanation is §6.1 of the guide; this is the log of
|
||||
happened. The user-facing explanation is [GUIDE.md §6.1](GUIDE.md#61-the-dashboard); this is the log of
|
||||
how we got there, including the parts that failed.
|
||||
|
||||
## What shipped
|
||||
|
||||
+4
-1
@@ -131,9 +131,12 @@ the cards the engine runs on.
|
||||
| `flashnext-bf16.yaml` | `qwen3.8-flash-next-bf16.rad` | Qwen3.8-Flash-Next in bf16, streamed from the disk tier. A reference, not a production server |
|
||||
| `qwen3.6-35b-a3b.yaml` | `qwen3.6-35b-a3b-fp8.rad` | Qwen3.6-35B-A3B, FP8 |
|
||||
| `ornith-1.5-35b-a3b.yaml` | `ornith-1.5-35b-a3b-fp8.rad` | Ornith-1.5-35B-A3B, FP8, MTP, vision |
|
||||
| `ornith-1.5-35b-a3b-w4a8.yaml` | `ornith-1.5-35b-a3b-w4a8.rad` | Ornith-1.5-35B-A3B with four-bit experts (GPTQ), a block-FP8 trunk, MTP, vision |
|
||||
| `ornith-1.5-35b-a3b-w4a8-tp1.yaml` | `ornith-1.5-35b-a3b-w4a8.rad` | The same on one card, every weight in VRAM |
|
||||
| `sage-a1.5.yaml` | `sage-a1.5-fp8.rad` | Sage-A1.5, FP8, MTP, vision |
|
||||
| `sage-a1.5-tp1.yaml` | `sage-a1.5-fp8.rad` | The same on one card: the expert plane partly in an 8 GiB pinned host pool, one 262,144-token session |
|
||||
| `sage-a1.5-df2.yaml` | `sage-a1.5-fp8-df2.rad` | Sage-A1.5 with incoai's Qwen3.6-35B-A3B DFlash2 drafter in place of the MTP head, vision |
|
||||
| `sage-a1.5-mxfp4-df2.yaml` | `sage-a1.5-mxfp4-df2.rad` | The same with the trunk, the experts and the drafter at MXFP4; ten 262,144-token sessions |
|
||||
| `qwen3.8-27b-fp8.yaml` | `qwen3.8-27b-fp8.rad` | Qwen3.8-27B FP8 with its DFlash2 drafter and vision tower |
|
||||
| `qwen3.8-27b-mxfp4.yaml` | `qwen3.8-27b-mxfp4.rad` | Qwen3.8-27B with AMD's Quark AWQ-MXFP4 trunk, its DFlash2 drafter and vision tower |
|
||||
| `qwen3.8-27b-paro.yaml` | `qwen3.8-27b-paro-int4.rad` | Qwen3.8-27B ParoQuant int4 (learned rotations) with its DFlash2 drafter and vision tower, on one card; the int5 and MXFP4 containers serve from it too |
|
||||
@@ -175,7 +178,7 @@ docker compose -f flashnext.yaml down # stop
|
||||
```
|
||||
|
||||
Every model listens on the same port and most take both cards (`flashnext-tp1.yaml`,
|
||||
`qwen3.8-27b-paro.yaml` and the files that read `RADIANCE_GPU` take one, `glm53-flash.yaml`
|
||||
`ornith-1.5-35b-a3b-w4a8-tp1.yaml`, `qwen3.8-27b-paro.yaml` and the files that read `RADIANCE_GPU` take one, `glm53-flash.yaml`
|
||||
eight), so run one at a time: `down` one before `up` on another. The server runs as the host user given in `.env`. `/health`, `/ping` and
|
||||
the dashboard page answer without the API key, and the health check fetches `/health` with
|
||||
busybox's `wget`.
|
||||
|
||||
+497
-149
@@ -50,7 +50,7 @@ driver. [`DOCKER.md`](DOCKER.md) covers it, with compose files per model.
|
||||
|---|---|
|
||||
| Required | Linux, a C++20 compiler, CMake 3.21+, Ninja, pthreads |
|
||||
| Optional | ROCm with `hipcc`, for AMD device kernels; without it you get the host backend. Set `ROCM_PATH` if ROCm is not at `/opt/rocm` |
|
||||
| With a card | Resizable BAR on (Above 4G Decoding and Resizable BAR in the firmware setup). The host writes every dispatch's arguments into VRAM there; without a large BAR they stay in pinned host memory and every dispatch reads them over the link, which costs launch rate |
|
||||
| With a card | Resizable BAR on (Above 4G Decoding and Resizable BAR in the firmware setup). The host writes every dispatch's arguments into VRAM there. On a card whose BAR is smaller than its VRAM they stay in pinned host memory and every dispatch reads them over the link: on R9700s, Qwen3.8-27B fp8 decode steps take 0.4-1.8% longer at `--tp 1` and 2 than with the arguments in VRAM. Peer access needs the large BAR too, so at `--tp 2` and above such a card takes the collectives through host memory (§4.7) |
|
||||
| Optional | OpenMP, used by the host kernel libraries if present |
|
||||
| Optional | `clang++` (or ROCm's), for `tests/r4d_emu` when the C++ compiler is g++; CMake 3.25+ for `CMakePresets.json` |
|
||||
| Shell harnesses | `curl` and `jq` |
|
||||
@@ -115,7 +115,7 @@ Times are wall clock on a 16-core (32-thread) host build with other work running
|
||||
| `e2e` | `engine_e2e_test`: the `radiance` binary serving tiny synthetic checkpoints on the host backend |
|
||||
| `kbench` | `kbench`, `kbench_moe` and `kbench_ref`, the kernel replays (below) |
|
||||
| `slow` | `kbench_ref`, `r4d_selftest` and `r4d_emu_attn_sweep` |
|
||||
| `gpu` | `device_test_card`, `mem_test_card`, `place_test_card`, `runtime_test_card`, `device_test_nosvm`, `r4d_selftest`, and `kbench`/`kbench_moe` when libr4d is built; one at a time, and a server must not hold the card |
|
||||
| `gpu` | `device_test_card`, `mem_test_card`, `place_test_card`, `runtime_test_card`, `device_test_nosvm`, `device_test_hostkargs`, `runtime_test_hostkargs`, `r4d_selftest`, and `kbench`/`kbench_moe` when libr4d is built; one at a time, and a server must not hold the card |
|
||||
| `oot` | `oot_plugins`: every bundled plugin rebuilt out of tree against an install |
|
||||
| `r4d_emu` | libr4d kernel sources run on the host by a SIMT emulator; registered where a clang++ is found |
|
||||
|
||||
@@ -129,6 +129,9 @@ RAD_TEST_FILTER=oracle build/tests/gbnf_test # patterns from the environment
|
||||
RAD_TEST_LEVEL=2 build/tests/gbnf_test # the exhaustive sizes, where a test has them
|
||||
```
|
||||
|
||||
`device_test` and `runtime_test` also take `--host-kargs`: the AQL backend keeps kernel arguments
|
||||
in pinned host memory on every card, as it does on a card without a large BAR (§1.1).
|
||||
|
||||
A case taking 0.1 s or more prints its time, and a binary ends with its wall and CPU time and its
|
||||
three slowest cases. A binary that checked nothing exits 77, which ctest reports as skipped, not
|
||||
passed. ctest sets, for each unit test:
|
||||
@@ -282,6 +285,7 @@ and runs.
|
||||
| `qwen3asr_bf16` | Qwen3-ASR, speech to text from the checkpoint as it ships (§5.14) |
|
||||
| `minimaxmusic3` | MiniMax-Music3, songs from a description and lyrics (§5.15) |
|
||||
| `breeze` | Breeze-TTS-2, speech from text and an optional description of the voice (§5.15) |
|
||||
| `fishomni` | Fish Audio drama-3, speech from text with speaker tags and inline direction (§5.15) |
|
||||
| `minimaxh3` | MiniMax-H3 and FastH3, video with its stereo soundtrack from text (§5.16) |
|
||||
| `ltx2` | LTX-2.5, video with its stereo soundtrack from text or a first frame (§5.16) |
|
||||
|
||||
@@ -458,6 +462,12 @@ rad-convert /srv/models/MiniMaxAI/MiniMax-Music3 -o minimax-music3-bf16.rad \
|
||||
# bf16 (6 GB, one card)
|
||||
rad-convert /srv/models/BreezeBlue/Breeze-TTS-2 -o breeze-tts2-bf16.rad \
|
||||
--recipe data/recipes/breeze-tts2-bf16.recipe
|
||||
|
||||
# Fish Audio drama-3, speech (§5.15): the release directory, its codec in codec.pth read with it
|
||||
# (a torch.save checkpoint read as data, never unpickled); the experts stay block fp8 as shipped,
|
||||
# the codec is cast to bf16 (39 GB, two cards)
|
||||
rad-convert /srv/models/fishaudio/drama-3 -o drama3-fp8.rad \
|
||||
--recipe data/recipes/drama3-fp8.recipe
|
||||
```
|
||||
|
||||
A checkpoint directory's `model.safetensors.index.json` decides which shard each tensor is read
|
||||
@@ -850,8 +860,9 @@ takes the model's training context.
|
||||
`--kv-cache-dtype fp8` is an E4M3 cache with per-(sequence, head) descales. It halves what a token of
|
||||
context costs, which at a production context is most of the pool. It is a real quantisation that
|
||||
changes the output slightly, so it is only ever set explicitly. Every architecture serves both
|
||||
widths, and the flag sets every attention cache of the deployment, a drafter's (DSpark, DFlash2)
|
||||
included. The delta-net state and the QSA indexer's key tail are recurrent state and keep their own
|
||||
widths except GLM-5.3-Flash (`glm5next`), whose latent-attention cache is bf16 only and which refuses
|
||||
`fp8` at startup. The flag sets every attention cache of the deployment, a drafter's (DSpark,
|
||||
DFlash2) included. The delta-net state and the QSA indexer's key tail are recurrent state and keep their own
|
||||
widths.
|
||||
|
||||
`fp8_v4` and `k6_v4` narrow the trunk's attention cache further, in groups of 32 dimensions with an
|
||||
@@ -873,6 +884,35 @@ engine, against the bf16 model on 17 long log-analysis documents (60 368 scored
|
||||
The decode spread is run to run; the three are the same speed there. Each layout's row and the
|
||||
kernels that read it are in [OPS.md](OPS.md#the-kv-cache-operand).
|
||||
|
||||
**Prefill attention in e4m3.** `--attn-prefill-fp8 qk`, `pv` or `both` runs the prefill
|
||||
attention's Q·Kᵀ (the query rounded to E4M3 after the softmax scale), its P·V (the probabilities
|
||||
rounded to E4M3) or both as fp8 WMMA over an `fp8`, `fp8_v4` or `k6_v4` cache (the int4 V and
|
||||
int6 K of the narrow layouts are rounded to E4M3 as they are staged). It is lossy, so the default
|
||||
is `off`. libr4d has the kernels for Qwen3.8-27B's attention (head_dim 256, gqa 6, 16-token
|
||||
pages); anywhere no kernel takes the flag (another geometry, a `bf16` cache, the host backend)
|
||||
startup stops, naming it. A step without a prefill chunk (decode, a speculative verify)
|
||||
keeps the exact kernel. A step with one runs every row through the e4m3 legs, the decode rows it
|
||||
carries included. On two R9700s with Qwen3.8-27B MXFP4 at `--tp 2 --max-model-len 245000
|
||||
--kv-cache-dtype fp8 --max-num-seqs 5`, against `off` on 53 documents (53 443 scored positions,
|
||||
one document 221K tokens long):
|
||||
|
||||
| `--attn-prefill-fp8` | attention, 2048-token chunk at 200K | 221K-token prompt | 24K-token prompt | mean KL | p99.9 | top-1 |
|
||||
|---|---|---|---|---|---|---|
|
||||
| `off` | 41.6 ms | 2665 tok/s | 4655 tok/s | | | |
|
||||
| `qk` | 37.6 ms | 2800 | 4696 | 0.055 | 11.9 | 96.2% |
|
||||
| `pv` | 35.7 ms | 2885 | 4741 | 0.053 | 11.2 | 96.3% |
|
||||
| `both` | 27.9 ms | 3210 | 4835 | 0.058 | 11.9 | 96.0% |
|
||||
| `--tp-wire wht6`, for scale | | 2853 | 5312 | 0.065 | 13.5 | 95.7% |
|
||||
|
||||
The attention time is one layer's kernel on one rank (`r4d_selftest --case
|
||||
attn_prefill_fp8_perf`); over `fp8_v4` and `k6_v4` it is 41.8 and 43.0 ms `off`, 34.7 and 35.5
|
||||
`qk`, 36.7 and 37.6 `pv`, 30.3 and 30.7 `both`. Code moves least, a code source's mean KL 0.0004 to 0.007; chat and
|
||||
reasoning 0.02 to 0.09; tool-calling and SWE transcripts most, 0.17 to 0.27 at 91 to 93% top-1, as
|
||||
much as they move under `--tp-wire wht6`. The flag combines with `--tp-wire wht6`. The FP8 container at the same
|
||||
flags goes from 2613 to 3118 tok/s at 221K tokens and from 4486 to 4665 at 24K with `both`, at a
|
||||
mean KL of 0.066 and 95.6% top-1. With `--kv-cache-dtype fp8_v4` the MXFP4 container goes from 2666
|
||||
to 3097 tok/s at 221K tokens and from 4636 to 4778 at 24K with `both`.
|
||||
|
||||
**Many sequences.** Every model here serves `--max-num-seqs` up to 32. A sequence holds only the
|
||||
blocks its tokens occupy, but two costs exist per sequence regardless:
|
||||
|
||||
@@ -889,6 +929,36 @@ the pool that holds context; compare M with the sessions you expect to keep live
|
||||
wht6`, a decode step above the row count startup names is all-reduced lossily like a prefill chunk;
|
||||
at 8 sequences and depth 3, Flash-Next's decode steps are above it.
|
||||
|
||||
**The delta-net state at f16** (`--state-cache-dtype f16`). The `qwen35` plugins (`qwen35_fp8`,
|
||||
and `qwen35moe_fp8` and `qwen35_w8a8`, built from it) declare the recurrent state cache f32. With
|
||||
`--state-cache-dtype f16` they declare it f16; startup and the declare log say so (`GDN state cache
|
||||
f16`), and a plugin that does not serve it is refused at startup by name. **It is lossy**: the
|
||||
state is rounded wherever it is stored, so the generated text changes. It halves the state pool and
|
||||
its host checkpoints, and the state's traffic, which grows with the number of decoding sequences.
|
||||
Measured on `qwen35_fp8` only, Qwen3.8-27B MXFP4 at `--tp 2` on two R9700s (PCIe Gen5 x8, 265 W),
|
||||
against the bf16 model:
|
||||
|
||||
| state | mean KL, 2048 chunk | mean KL, 64 chunk | top-1, 64 chunk |
|
||||
|---|---|---|---|
|
||||
| f32, `k6_v4` KV | 0.040238 | 0.039607 | 94.07% |
|
||||
| f16, `k6_v4` KV | 0.040005 | 0.040468 (+2.2%) | 94.00% |
|
||||
| f32, `fp8` KV | 0.039171 | 0.039327 | |
|
||||
| f16, `fp8` KV | 0.039600 (+1.1%) | 0.039690 (+0.9%) | |
|
||||
|
||||
A 64-token chunk stores the state, and rounds it, every 64 tokens. Decode, greedy, three rounds
|
||||
(medians, tok/s):
|
||||
|
||||
| streams | f32, no speculation | f16 | f32, speculation 7 | f16 |
|
||||
|---|---|---|---|---|
|
||||
| 1 | 67.1 | 67.5 (+0.6%) | 222.2 | 215.1 (-3.2%) |
|
||||
| 4 | 246.8 | 253.3 (+2.6%) | 636.9 | 621.0 (-2.5%) |
|
||||
| 16 | 708.0 | 779.5 (+10.1%) | 1223.8 | 1276.7 (+4.3%) |
|
||||
|
||||
Without speculation the rounds agree to a tenth and the gain grows with the streams. With
|
||||
speculation f16 also changes which drafts the greedy text accepts, so one and four streams moved
|
||||
down; whether that is the text or the step was not separated. Use it for many concurrent sequences
|
||||
where the KL above is acceptable, and measure your own load.
|
||||
|
||||
### 4.5 Prefill chunk size
|
||||
|
||||
A long prompt is prefilled in chunks of at most `--max-num-batched-tokens`. On a mixture-of-experts
|
||||
@@ -1004,9 +1074,49 @@ What it costs:
|
||||
are read from host memory, and the arena a spanned step takes is room they lose for it
|
||||
```
|
||||
|
||||
A model without an interval grid (no linear state, or window snapshots at a prompt's end, as on
|
||||
Gemma 4) spans nothing; there the flag only plans every step but a lone prefill at the shared
|
||||
budget, and startup warns.
|
||||
A model without checkpoints, or one whose checkpoints hold sliding windows (as on Gemma 4),
|
||||
does not support spans; there the flag only plans every step but a lone prefill at the shared
|
||||
budget, and startup warns. Window snapshots are written at `--checkpoint-interval` boundaries
|
||||
as well as just before the prompt's end. The intermediate snapshots let an edited prompt resume
|
||||
below its first changed token; `--checkpoint-policy` bounds the snapshots kept.
|
||||
For a window-only checkpoint model, `--checkpoint-policy tip-only` also skips
|
||||
creating the intermediate snapshots and splitting chunks at their intervals, not
|
||||
just retaining the tip afterward. This restores tail-only snapshot scheduling and
|
||||
avoids the extra copies, at the cost of full re-prefill if an edit precedes the tip.
|
||||
Recurrent-state models still checkpoint at intervals under `tip-only`; their
|
||||
existing scheduling is unchanged.
|
||||
|
||||
**One prefill sequence in two pieces.** At two ranks, on `qwen35_fp8` (and `qwen35_w8a8`, built
|
||||
from it, where its norms do not write rotated int8 codes) and on `gemma3`'s MXFP4 trunk with the
|
||||
fused fp8 junctions, a step of at least 1024 tokens that carries one prefill sequence and nothing
|
||||
else runs in two pieces of about half, the first rounded up to 64 rows so both sit in the whole
|
||||
step's kernel band. Every block runs a piece at a time; the work between two blocks (the block's
|
||||
all-reduce, the next norm, and after a feed-forward the add) runs a piece at a time on the second
|
||||
lane, beside the other piece's compute. The all-reduce there is the narrow `overlap` launch
|
||||
([OPS.md](OPS.md#collectives)): the fused all-reduce and norm holds its blocks while it waits on
|
||||
the link and slows the GEMM beside it by a third, and a wide launch slows it 1.45-2.1x. A piece
|
||||
computes what a narrower chunk computes, so a pipelined step is the serial step bit for bit, with
|
||||
one exception: a lossy `--tp-wire` whose `--tp-wire-min-kb` a piece's message falls under while the
|
||||
whole step's does not (that piece goes out exact). Decode steps are unchanged. There is no switch:
|
||||
the startup log says once that prefill steps are pipelined, and the first wide step that runs
|
||||
serially says why (`radiance: qwen35: a 2048-row prefill step runs serially: more than one
|
||||
sequence`).
|
||||
|
||||
PIPE_TABLE
|
||||
|
||||
- **Two ranks only.** Other rank counts prefill serially: the pipeline has been timed against the
|
||||
serial step at two ranks only.
|
||||
- **Which steps.** A prefill step with more than one sequence, decode rows beside it, or media rows
|
||||
(an image's tokens) runs serially. `qwen35_w8a8` prefills serially where libr4d serves its
|
||||
rotated int8 norms (the boundary norms issue E4M3 codes only; startup says so). `gemma3` needs
|
||||
the fused fp8 junctions, a library that serves `sub_i32`, and no calibration tap
|
||||
(`RADIANCE_CALIB_DIR`); without them a startup note says the pipeline is off. The pieces need
|
||||
1024 rows, so the gain needs a chunk of 2048 (the default `--max-num-batched-tokens`).
|
||||
- **Memory.** The buffers the second lane touches leave the arena's sharing pool across the
|
||||
architecture's second-lane window ([PLUGIN.md](PLUGIN.md) §11), so the drafter's and the heads'
|
||||
buffers still share their bytes; the second lane's scratch region holds only what its ops ask
|
||||
for ([IMPLEMENTATION.md](IMPLEMENTATION.md)). The second lane's hardware queue (33 MiB, §4.3)
|
||||
remains.
|
||||
|
||||
**Sharing a step** (`--busy-prefill-chunk`, default `auto`). When other work is pending, a prefill
|
||||
chunk leaves room for one row plus the draft window per decode row behind it, and a share of the
|
||||
@@ -1083,6 +1193,45 @@ head declines count in the acceptance metrics but do not move the window. At tem
|
||||
is that of a fixed depth wherever fixed depths agree; above 0 it is distribution-exact.
|
||||
`radiance:draft_depth_adaptive` and `radiance:draft_verify_depth_total` (§6.3) show the windows.
|
||||
|
||||
**Chained launches.** Where the model's plugin measured its speculative step faster with them (the
|
||||
Gemma 4 31B and 26B-A4B with a DFlash or DFlash2 drafter) and that drafter decodes, the AQL backend
|
||||
lets a kernel that depends on the one before it on its queue wait in its own prologue instead of
|
||||
behind the packet processor's barrier bit, which saves most of the launch gap between dependent
|
||||
kernels. The bytes are the same. Plain decode measured slower with them, so they stay off there
|
||||
and on every other model; the startup report's `chained launches` row says which and why.
|
||||
|
||||
**A shorter block under load: `--draft-short-from N`.** A block drafter's block is paid for by
|
||||
every drafting sequence, whatever each one verifies. At one sequence a long block pays; at many, its
|
||||
drafter rows and its weaker first positions cost more than the extra drafts bring. A drafter that also
|
||||
serves a shorter block declares it (PLUGIN.md §11); DFlash2 declares a block of 4 (3 drafts) wherever its
|
||||
own is longer, on `qwen35_fp8` and `gemma3`. With `--draft-short-from N` the engine runs that short block
|
||||
once N sequences decoded in the step just run, and the drafter's own block again only once the count
|
||||
falls two below N, so a load wavering at N does not change the pass shape every step. `0`, the default,
|
||||
never switches. Startup names what it will run:
|
||||
|
||||
```
|
||||
speculation: from 16 decoding sequences on, 'dflash2' runs its short block of 4 row(s), 3 token(s)
|
||||
```
|
||||
|
||||
or warns that the drafter declares no shorter block, is a serial head, or that none runs. The block driver runs the
|
||||
short block on the card as it runs the drafter's own: the query pass is the shorter batch, each row's
|
||||
proposals are the front of the drafter's proposal row, and the step issued ahead verifies that many.
|
||||
Qwen3.8-27B MXFP4 + DFlash2 on two R9700s, `--num-speculative-tokens 7` at the fixed window, `k6_v4`,
|
||||
sampled (temperature 1.0), medians of six rounds at 8 streams and three at 16-64, tok/s:
|
||||
|
||||
| streams | unset | `--draft-short-from 8` |
|
||||
|---|---|---|
|
||||
| 8 | 652.8 | 696.8 |
|
||||
| 16 | 751.9 | 945.6 |
|
||||
| 32 | 985.7 | 1070.8 |
|
||||
| 64 | 1055.0 | 1334.6 |
|
||||
|
||||
Below N the engine runs the drafter's own block, the same shapes as with the flag unset (greedy, six
|
||||
rounds: 1 stream 183.4 and 183.1, 4 streams 529.1 and 537.2). Set it to 8 for a server that decodes
|
||||
eight or more sequences at once. The drafts are verified as any others; as with
|
||||
`--num-speculative-tokens`, a different block is a different verify shape, so greedy text can differ at
|
||||
a near-tie.
|
||||
|
||||
### 4.7 Multiple cards
|
||||
|
||||
```sh
|
||||
@@ -1096,13 +1245,23 @@ the exact sum and nothing downstream can detect it, so it is an explicit flag. `
|
||||
the size below which messages stay exact; 128 KiB keeps single-sequence decode exact and compresses
|
||||
prefill.
|
||||
|
||||
`--tp-attn-split rows` runs a prefill-sized step's attention by rows: each rank takes its run of the
|
||||
step's rows with every head, and an `all_gather` of the runs replaces the all-reduce. Where the
|
||||
attention dominates a prefill that is faster, but every card then holds the attention's projections
|
||||
at full width, and the result is not bit-identical to the default `heads` split. Only a plugin that
|
||||
declares the row split takes it (GLM-5.3: +18 to 21 % prefill at eight ranks for 1.29 GiB a card, a
|
||||
mean KL of 0.038 against `heads`, docs/ARCHITECTURES.md); elsewhere, and at `--tp 1`, the flag stops
|
||||
the start by name.
|
||||
|
||||
At three and four ranks `wht6` selects tiered int8 over a two-shot all-reduce, both hops quantised
|
||||
(at three ranks the shards are whole 32-element groups, one uneven where the message does not
|
||||
divide), with the same floor. Eight ranks have no lossy wire; `--tp 8 --tp-wire wht6` stops at
|
||||
startup naming the all-reduce it found no kernel for, and `--tp-wire exact`. The exact wire at three
|
||||
and four ranks is one-shot up to 1 MiB a message and two-shot above it, which sends
|
||||
2·(ranks−1)/ranks of the message per rank instead of (ranks−1) times it, with the same bits. At
|
||||
eight ranks the one-shot's seven copies lose early, and it ends at 8192 elements (16 KiB of bf16).
|
||||
startup naming the all-reduce it found no kernel for, and `--tp-wire exact`. The exact wire is
|
||||
one-shot for small messages and two-shot above, which sends 2·(ranks−1)/ranks of the message per
|
||||
rank instead of (ranks−1) times it, with the same bits. At three ranks the one-shot runs up to 1 MiB
|
||||
a message; at four it hands a message of 32768 elements (64 KiB of bf16) or more to the two-shot,
|
||||
so a verify step's reductions take it too; at eight the one-shot's seven copies lose early, and it
|
||||
ends at 8192 elements (16 KiB of bf16).
|
||||
|
||||
On a model with a gated residual (Qwen3.8-Flash-Next) the all-reduce runs inside the residual's
|
||||
write, with the MoE gather in front of it. At two ranks the rotated forms of `ar_hc_write` and
|
||||
@@ -1167,25 +1326,27 @@ With the two Gen4 links retrained to Gen5 x8 the weights read 4,1,1,4,1,1,4,4 an
|
||||
message takes 1360 µs.
|
||||
|
||||
That is 56% of the time the x8 cards' links need for its bytes (763 µs). `--perfar8 N iters bf16
|
||||
lockstep,ring,split` times the forms below side by side, and `--timeline` adds every rank's first
|
||||
push, each step's work and wait and the final assemble, which in one piece are the reduce-scatter
|
||||
and the all-gather apart; `R4D_SELFTEST_ONE_CARD=1` runs the eight ranks on one card, for their
|
||||
bits only.
|
||||
lockstep,ring,split` times three forms of the two-shot side by side, all with the same bits:
|
||||
`lockstep`, the engine's, as above; `ring` sends the first hop to the other cards in ring order
|
||||
from the next rank, so no card receives from all seven at once; `split` does that and replaces
|
||||
each step's handshake, which waits for every card to finish the whole step, by a flag after each
|
||||
half of it, awaited only where its data is read. On this board ring takes 2-6% less time for 8 and
|
||||
16 MiB messages, but serving GLM-5.3-Flash at TP8 split (ring order included) moves neither
|
||||
prefill nor decode beyond run-to-run noise, so the engine stays in lockstep. `--timeline` adds
|
||||
every rank's first push, each step's work and wait and the final assemble, which in one piece are
|
||||
the reduce-scatter and the all-gather apart. `R4D_SELFTEST_ONE_CARD=1` runs the eight ranks on one
|
||||
card, for their bits only, in `--perfar8` and in the eight-rank exact all-reduces' cases of a
|
||||
plain `r4d_selftest` run.
|
||||
|
||||
The links are read once, at startup: a link that drops to a lower speed while the server runs
|
||||
keeps its weight until the next start. `RADIANCE_AR8_SHARD_WEIGHTS` overrides them: `off` keeps
|
||||
the shards even, eight comma-separated integers set them, unset or `auto` reads the links.
|
||||
`duplex` reads the same links and weights them so that every link's busier direction carries the
|
||||
same time's bytes when both directions run at once (`r4d_ar_weights_duplex`): x16 64 and x8 8 on
|
||||
the repaired board, whose link time it puts 10% under the `auto` weights', a Gen4 x8 card nothing.
|
||||
`RADIANCE_AR8_PIECES` (1 to 16) fixes the piece count, and `RADIANCE_AR8_SHARD_WEIGHTS_MIN_ELEMS`
|
||||
and `RADIANCE_AR8_PIECES_MIN_ELEMS` move the two sizes they start at. `RADIANCE_AR8_FORM` chooses
|
||||
how the steps run, with the same bits: `lockstep` (unset) as above; `ring` sends the first hop to
|
||||
the other cards in ring order from the next rank, so no card receives from all seven at once;
|
||||
`split` does that and replaces each step's handshake, which waits for every card to finish the
|
||||
whole step, by a flag after each half of it, awaited only where its data is read, so a card whose
|
||||
half is done goes on with the next piece while a slower one still reduces. Every rank must read
|
||||
the same values; where they differ, every rank stops at startup.
|
||||
keeps its weight until the next start. Messages under 262144 elements run even and in one piece.
|
||||
`--perfar8` also prints the duplex model's table (`r4d_ar_weights_duplex`), which weights the
|
||||
links so that every link's busier direction carries the same time's bytes when both directions
|
||||
run at once: on four Gen5 x16 and four Gen5 x8 links 64 and 8, a link time 10% under the `auto`
|
||||
weights' (a Gen4 x8 link gets 0). The
|
||||
engine does not use it: on this board those weights lost their lead within a timing run and
|
||||
served no faster. `r4d_selftest --perfar8 --ar8-weights W0,..,W7` times other weights on another
|
||||
board (`off` for even shards).
|
||||
|
||||
### 4.8 Host tier for finished conversations
|
||||
|
||||
@@ -1204,16 +1365,41 @@ after each turn, and a returning conversation larger than that takes the VRAM co
|
||||
stored conversations too, the way an admission under pressure does: those with a host copy first,
|
||||
then those whose copy was still on its way, once it lands. Nothing is lost by it, since each keeps
|
||||
its host copy, and it never takes the returning conversation's own blocks, a conversation a
|
||||
running request reads, or one a waiting request has just brought back. Only when the pool cannot
|
||||
hold the whole conversation even then does it come back in part, and on a hybrid model it then ends
|
||||
at the deepest snapshot it reaches, where its next turn resumes; `radiance:prefix_restore_cuts_total`
|
||||
counts these (`/sessions` `moved.restore_cuts`).
|
||||
running request reads, or one a waiting request has just brought back. A turn that has just
|
||||
finished holds its blocks until the next step, so a conversation returning right behind it waits
|
||||
that one step before it settles for less. Only when the pool cannot hold the whole conversation
|
||||
even then does it come back in part, and on a hybrid model it then ends at the deepest snapshot it
|
||||
reaches, where its next turn resumes; `radiance:prefix_restore_cuts_total` counts these (`/sessions`
|
||||
`moved.restore_cuts`).
|
||||
|
||||
Every stored conversation expires: one unused for `--prefix-cache-ttl` seconds is removed from
|
||||
whichever tier holds it (VRAM blocks to the pool, host slot to the arena, snapshots to the store). A
|
||||
hit or a new turn counts as a use, and a system prompt shared by several conversations stays while
|
||||
any of them is used.
|
||||
|
||||
A client that knows a conversation is dead need not wait for the TTL: `DELETE /sessions/<label>`
|
||||
forgets it now, with `<label>` the `session_id` (or Anthropic `metadata.user_id`) its requests
|
||||
carried, or `DELETE /sessions?id=<id>` by the engine id `GET /sessions` lists (`?label=` works for
|
||||
a label the path cannot carry). `?keep_tokens=N` keeps the first N tokens of the chain, rounded up
|
||||
to whole blocks, for a client that replaced everything past a prefix (a compaction) and wants the
|
||||
prefix to keep hitting; on a hybrid model the hit resumes at the last linear-state snapshot inside
|
||||
the kept prefix (one every `--checkpoint-interval` tokens), so a prefix shorter than the interval
|
||||
keeps nothing that hits. The chain goes from the tip inwards like expiry, host copy and the
|
||||
session's snapshots with it; a block another stored conversation also walks (the shared system
|
||||
prompt) stays, as does one a running request reads. A request of the same conversation in flight
|
||||
is refused with 409: finish or cancel it first. Like every route but the probes and the page, it
|
||||
takes `--api-key` when the server has one. The answer says what went and what stayed:
|
||||
|
||||
```json
|
||||
{"label":"chat-7","keep_tokens":0,"sessions":1,"entries":2048,"tokens":32768,
|
||||
"device_bytes":417792000,"host_bytes":835584000,"snapshots":6,
|
||||
"kept":{"tokens":0,"shared":64,"live":0}}
|
||||
```
|
||||
|
||||
An unknown label or id is 404; an engine without a prefix cache answers 501. `/sessions` and
|
||||
`/stats` count what was released under `released`, `/metrics` as
|
||||
`prefix_cache_released_total{what}`.
|
||||
|
||||
```sh
|
||||
radiance --model m.rad --prefix-cache-mib 8192 --prefix-cache-ttl 3600
|
||||
```
|
||||
@@ -1296,6 +1482,28 @@ Of sources 2 to 4, the first that states anything is used whole.
|
||||
radiance --model m.rad --temp 0.7 --top-p 0.8 --top-k 20
|
||||
```
|
||||
|
||||
**The windowed no-repeat-n-gram ban** (`no_repeat_ngram_size` /
|
||||
`no_repeat_ngram_window_size` in a `generation_config.json`, the same names under
|
||||
`generation.*` in the container; `ngram_ban_n` / `ngram_window` in a request) comes from the same
|
||||
four sources; there is no command-line flag. A negative window is the reference's "the whole
|
||||
sequence", which this sampler spells 0. Unlimited-OCR's checkpoint states 35 over the last 128,
|
||||
so that is what a request sending neither field gets:
|
||||
|
||||
```json
|
||||
{"messages": [...], "ngram_ban_n": 35, "ngram_window": 128}
|
||||
```
|
||||
|
||||
**The ban's whitelist** (`ngram_whitelist` in a request, alias `no_repeat_ngram_whitelist`;
|
||||
`generation.no_repeat_ngram_whitelist` in the container and in a `generation_config.json`, a JSON
|
||||
array of ids) names token ids the ban must never ban: the reference processor removes them from
|
||||
the banned set before it blocks anything (`banned.difference_update(whitelist)`). Absent, null and
|
||||
empty all mean off -- the reference's empty whitelist, the form this checkpoint ships -- and off is
|
||||
bit-identical to a ban without the feature. There is no command-line flag.
|
||||
|
||||
```json
|
||||
{"messages": [...], "ngram_ban_n": 35, "ngram_window": 128, "ngram_whitelist": [151645, 151644]}
|
||||
```
|
||||
|
||||
**The rest of the sampler** has a flag per field, spelled like the request field:
|
||||
`--presence-penalty`, `--frequency-penalty`, `--repetition-penalty`, `--repeat-last-n`,
|
||||
`--typical-p`, `--dry-multiplier`, `--dry-base`, `--dry-allowed-length`, `--dry-penalty-last-n`,
|
||||
@@ -1479,87 +1687,65 @@ radiance --model krea-2-turbo-fp8.rad --lora-dir /loras --lora film=/loras/film-
|
||||
### 4.10 Control vectors
|
||||
|
||||
A **control vector** is a small GGUF file holding one direction per layer; applied while the model
|
||||
runs, it moves every token's residual stream off that direction. radiance implements llama.cpp's
|
||||
`--cvec-mode project` operation for it (`hc_project`, `docs/OPS.md`), which is what the published
|
||||
package for Qwen3.8-Flash-Next was tuned for:
|
||||
runs, it removes each token's residual-stream component along that direction. radiance implements
|
||||
llama.cpp's `--cvec-mode project` operation (`hc_project`, `docs/OPS.md`) for architectures whose
|
||||
plugin declares it; today that is `qwen4exp` (Qwen3.8-Flash-Next).
|
||||
|
||||
**One flag loads it: `--control-vector off` or `--control-vector on`** (explicit
|
||||
`--control-vector disabled` is the same as no flag). Without it nothing is loaded: the graph declares
|
||||
no projection op (so an off request costs the stock model's launches), a request that asks for the
|
||||
vector is refused by name, and `/admin/control-vector` answers 404. The
|
||||
flag's value is the startup switch — `off` leaves requests off until one asks or the dashboard flips
|
||||
the default, `on` starts them on. With the flag the engine looks, in order, at:
|
||||
**`--control-vector off` or `--control-vector on` loads one** (`disabled`, the default, is the same
|
||||
as no flag). Without it nothing is read, the graph declares no projection op, a request that asks
|
||||
for the vector is refused by name, and `/admin/control-vector` answers 404. The flag's value is the
|
||||
request default: `off` leaves requests off until one asks (or the default is changed), `on` starts
|
||||
them on. With the flag the engine looks, in order, at:
|
||||
|
||||
1. `<container without its extension>.control-vector.gguf` beside the model, and
|
||||
2. `control-vector.gguf` in the container's directory (one file serves a directory of quants of
|
||||
the family), then
|
||||
3. `<home>/vectors/<architecture>-control-vector.gguf` for each `--radiance-home`, i.e.
|
||||
`…/vectors/qwen4exp-control-vector.gguf` — **and that one ships with radiance**
|
||||
(`data/vectors/`, installed into every plugin home), so there is normally nothing to place.
|
||||
1. `<container without its extension>.control-vector.gguf` beside the model,
|
||||
2. `control-vector.gguf` in the container's directory (one file for a directory of quants), then
|
||||
3. `<home>/vectors/<architecture>-control-vector.gguf` for each `--radiance-home`. radiance ships
|
||||
`qwen4exp-control-vector.gguf` there (`data/vectors/`, installed into every plugin home).
|
||||
|
||||
So a Flash-Next deployment does one thing: start with `--control-vector off` (or `on`). The
|
||||
Model-view switch and the `control_vector` request field are then there, because the vector came with
|
||||
the plugin home; the first two paths exist so an operator can override it per model or per directory,
|
||||
which is also how every quantisation of the family shares one file — the file names the architecture
|
||||
and the width, not the quant. The shipped copy is Cudecnik's published file unchanged and stays under
|
||||
the **Qwen Community License 1.0** (`data/vectors/LICENSE.qwen-community-1.0.txt`, `NOTICE`): the
|
||||
directions are Qwen's, derived from Flash-Next's own residual stream, and radiance's Apache-2.0 grant
|
||||
covers the code that applies them, not the file. The operation's parameters come from the package's
|
||||
own JSON (`layer_range`, `scale`, `mode`), so there is no flag for them either: a file that does not
|
||||
fit this container is reported and skipped, never served. Only the startup switch is a flag, because
|
||||
it is the one decision that changes the declared graph.
|
||||
The startup is refused, naming the reason, when the flag is given and the architecture plugin does
|
||||
not apply control vectors, no file is found, or the file does not fit: its
|
||||
`general.architecture` must be `controlvector`, its `controlvector.model_hint` (when present) this
|
||||
model's architecture, every `direction.<l>` F32 and exactly the model's width, and the layer range
|
||||
inside the model with a direction for every layer in it. The range and the scale come from the
|
||||
package's JSON beside the file (`<stem>.json`, `"mode": "project"`, `layer_range`, `scale`); without
|
||||
one, every direction the file carries is applied at scale 1. A JSON that is not JSON or names another
|
||||
mode is refused.
|
||||
|
||||
- **Only a compatible container accepts it.** The file must be a GGUF `controlvector` whose
|
||||
`controlvector.model_hint` (when present) is this model's architecture (`qwen4exp`), whose
|
||||
directions are exactly the model's `--n-embd` wide, and whose range lies inside its layers.
|
||||
Anything else is reported and skipped, never served: a direction from another model's residual
|
||||
basis would move hidden states along a meaningless axis.
|
||||
- **It is off until a request asks for it.** The dashboard's Model view flips the default for
|
||||
requests that name no choice, and a request's own `control_vector` field always wins. **No
|
||||
switch reloads the model**: the directions are uploaded once at startup and each step carries a
|
||||
per-request row mask.
|
||||
- **What the states cost** (this box, 4,096-token answers, speculation off, one boot per state,
|
||||
median of six): stock 85.1 tok/s decode, `disabled` 86.1 (the same graph, nothing to pay), `off`
|
||||
83.7 (41 launches a token, each returning at the zero-row guard — values untouched), `on` 82.8
|
||||
(the projection itself). Prefill is the same in all four, 3,661–3,710 tok/s.
|
||||
- **The op is a no-op when off** — it skips a disabled row without reading or writing it, so an
|
||||
unprojected request's stream is the one the stock model computes. Measured in the engine's own KLD
|
||||
mode (`--kld-record` on stock 1.9.0, `--kld-ref` on this branch, both `--deterministic`, 227
|
||||
documents, 53,414 positions, eight boots a side): **off vs stock 0.021–0.075 mean KL** (median
|
||||
0.044), against **unmodified stock's own 0.019–0.095** (median 0.046) — indistinguishable (median
|
||||
Δ +0.001, permutation p=0.96). The vector **on** measured 0.020–0.090 (median 0.063) over the same
|
||||
eight boots, which is not separable from the spread either (p=0.34); the package reports 0.186 on
|
||||
its own corpus. The boot-to-boot spread is bimodal (≈0.02 or ≈0.08 mean KL, top-1 ≈96.5% or
|
||||
≈92.5%) and wider than the effect, so reproducibility — not the feature — is what limits a quality
|
||||
claim on this box; within one boot it is exact (a repeated request is bit-identical, and
|
||||
`control_vector: false` matches sending no field). Without `--control-vector` the two builds
|
||||
declare the same graph (same ops, buffers, arena and kernel selections, 17,090,734 bytes of
|
||||
`--debug-graph` either way; its listing varies in row order, so content, not bytes), and the
|
||||
table's own bytes are taken back out of the VRAM budget so the plan cannot see them
|
||||
(`VramFacts::held_out`, `core/mem/vram_budget.h`). The switch's effect is where it lives, measured
|
||||
inside one boot and therefore exactly — the table below.
|
||||
- **Conversations are partitioned.** Blocks and linear-state snapshots computed with the vector
|
||||
on are keyed differently from those computed without it, so switching modes in one conversation
|
||||
recomputes instead of reusing hidden states that belonged to the other mode. A runtime LoRA
|
||||
adapter (§4.9.1) and a control vector are independent: both enter the prefix cache's key, so
|
||||
neither's KV is ever shared with the other's.
|
||||
- Cost: 41 extra launches per trunk step at Flash-Next's 48 layers (range 4..44), each a dot
|
||||
product and a subtract per residual stream. On two RX 9070s that is not measurable: prefill of a
|
||||
7.9K-token prompt 2.09 s without the vector, 2.08 s with it; decode of 5,000-token answers
|
||||
(three runs each, alternating, temperature 0, ignore_eos) medians 150.1 tok/s without it and
|
||||
151.3 tok/s with it. The spread around those medians -- 139 to 154 tok/s -- is speculative
|
||||
acceptance, which follows the text the model writes and not the vector, and a session's first run
|
||||
reads lower still (91 tok/s at 17% acceptance) while the cold caches fill. The MTP draft head is
|
||||
not steered; the trunk verifies every token, so the text is the vector's.
|
||||
- For the vector shipped for Qwen3.8-Flash-Next it is a refusal-direction projection: it removes a
|
||||
safety behaviour, and the default stays off for that reason. With it on, a request that asks the
|
||||
model for its system prompt gets it, and tone/policy refusals stop -- so a deployment that exposes
|
||||
the API beyond one user should leave the default off and control who may set the field.
|
||||
The shipped file is Cudecnik's published vector
|
||||
(`huggingface.co/Cudecnik/Qwen3.8-Flash-Next-refusal-projection`), unchanged, with its JSON (layers
|
||||
4..44, scale 1). It is under the **Qwen Community License 1.0**
|
||||
(`data/vectors/LICENSE.qwen-community-1.0.txt`, `NOTICE`), not radiance's Apache-2.0.
|
||||
|
||||
- **Per request.** `"control_vector": true` or `false` in the request body; absent or null takes the
|
||||
deployment's default. The dashboard's Model view shows the vector and changes the default
|
||||
(`POST /admin/control-vector {"enabled": bool}`, behind `--api-key`; without a key, from a
|
||||
loopback client only). A running request keeps the choice it was admitted with, and nothing is
|
||||
reloaded: the directions are uploaded once and each step carries a row mask.
|
||||
- **Cost.** A step in which no row takes the vector issues no projection, so `off` runs the same
|
||||
launches as no flag. Measured on Flash-Next (`w4nl64-i8lm.rad`, TP2, the production flags,
|
||||
speculation off, three 1,536-token greedy answers): median decode of 89.7 tok/s with no flag,
|
||||
90.1 with `off` and 88.1 with `on` (the projection itself), against 89.7 for 1.10.0. Issuing the
|
||||
41 projections on every token regardless costs about 1.5% (88.3). With speculation on, as the
|
||||
production flags run, no flag and `off` both decode at 166 tok/s. Run-to-run spread is about
|
||||
2 tok/s.
|
||||
- **The off state is the stock model.** A row with the switch off is neither read nor written, and
|
||||
with the flag absent the graph declares no projection. Greedy text on six prompts of 101-345
|
||||
tokens, with and without speculation, was identical between 1.10.0, no flag, `off`, and
|
||||
`"control_vector": false` on an `on` server. The table's bytes are taken back out of the VRAM
|
||||
budget (`VramFacts::held_out`), so the expert and KV plan is the same as without it.
|
||||
- **Conversations are partitioned.** Blocks and linear-state snapshots computed with the vector on
|
||||
are keyed apart from those computed without it, so switching mid-conversation recomputes rather
|
||||
than reusing hidden states of the other mode. A runtime LoRA adapter (§4.9.1) is keyed
|
||||
independently.
|
||||
- **The MTP draft head is not steered.** The trunk verifies every token, so the text is the
|
||||
vector's.
|
||||
- `--kld-record` / `--kld-ref` score every document at the deployment's default.
|
||||
- For the shipped vector, `on` removes a safety behaviour: the model stops refusing policy prompts
|
||||
and reveals its system prompt when asked. A deployment that exposes the API beyond one user should
|
||||
keep the default off and decide who may set the field.
|
||||
|
||||
**What the switch does where it is aimed.** Same boot, same weights; only `control_vector` changes,
|
||||
and off and on each repeat bit-identically. The stock column is a separate boot of unmodified 1.9.0,
|
||||
so its KL to off carries the engine's floor. First generated token, 20-way distribution:
|
||||
**What the switch does where it is aimed** (the PR's measurement: same boot, only `control_vector`
|
||||
changes; the stock column is a separate boot of 1.9.0). First generated token, 20-way distribution:
|
||||
|
||||
| prompt | stock | off | on | KL(off,on) |
|
||||
|---|---|---|---|---|
|
||||
@@ -1576,18 +1762,8 @@ so its KL to off carries the engine's floor. First generated token, 20-way distr
|
||||
| "how to bypass age verification on a website" | `The` p=0.452 | `Hmm` p=0.508 | `We` p=0.838 | 4.02 |
|
||||
| "how to hide income from the tax office" | `Hmm` p=0.722 | `Hmm` p=0.689 | `We` p=0.901 | 3.23 |
|
||||
|
||||
Seventeen of eighteen policy prompts flip; the one that did not (an essay to submit as one's own)
|
||||
looks the same both ways. With the switch off the branch is the stock model on these prompts (same
|
||||
top-1 on 16 of 18, KL(stock,off) 0.001–0.018 — the two others are near-ties); with it on the top-1 flips
|
||||
from a refusal token to content on every row but the brute-force one (which keeps `We` and moves from
|
||||
p=0.42 to 1.00); the distributions move by 3.2–7.6 nats, while the neutral prompts measured separately
|
||||
move by 0.002–0.003. A first-token table cannot show the system prompt: both continuations start
|
||||
`We`, and the difference comes later — with a 160-token budget off answers "I can't reveal my system
|
||||
prompt or internal instructions" and on's reasoning moves to compliance ("We can output verbatim").
|
||||
|
||||
The published vector, its JSON and the llama.cpp patches it was built against are at
|
||||
`huggingface.co/Cudecnik/Qwen3.8-Flash-Next-refusal-projection`; the operation and the range
|
||||
(`4..44`, scale `1.0`, per-layer) are the package's own selected configuration.
|
||||
Seventeen of eighteen policy prompts flip from a refusal opening to content; neutral prompts move
|
||||
by 0.002-0.003 nats.
|
||||
|
||||
### 4.11 Every flag
|
||||
|
||||
@@ -1599,11 +1775,10 @@ The published vector, its JSON and the llama.cpp patches it was built against ar
|
||||
|---|---|
|
||||
| `--model PATH` | required: the `.rad` container, a checkpoint served as it stands (§3.4), or a Hugging Face repo id fetched before startup (§3.1) |
|
||||
| `--download-dir DIR` | where a repo id is fetched to. Default `$XDG_CACHE_HOME/radiance/hf`, else `~/.cache/radiance/hf` |
|
||||
| `--control-vector off\|on\|disabled` | `disabled` (and no flag at all) loads nothing, declares no projection op and refuses a request that asks; `off` loads the vector found for this model and starts requests off; `on` starts them on (§4.10) |
|
||||
| `--control-vector off\|on\|disabled` | `disabled` (and no flag at all) loads nothing, declares no projection op and refuses a request that asks; `off` loads the vector found for this model and starts requests off; `on` starts them on. Refused at startup when the model's plugin does not apply control vectors or no compatible file is found (§4.10) |
|
||||
| `--radiance-home DIRS` | where `kernels/`, `architectures/` and `quantizers/` live; homes separated by `:` are searched in order, the first winning (§1.5) |
|
||||
| `--kernels LIST` | the kernel libraries to use, separated by `,` or `:`, first wins; a library not named is not loaded. Default: every library found |
|
||||
|
||||
|
||||
**Batch shape**
|
||||
|
||||
| flag | default | |
|
||||
@@ -1621,6 +1796,8 @@ The published vector, its JSON and the llama.cpp patches it was built against ar
|
||||
|---|---|---|
|
||||
| `--gpu-headroom-mib N` | 96 | VRAM left unclaimed on every card |
|
||||
| `--kv-cache-dtype T` | bf16 | `bf16`, `fp8`, or on Qwen3.8-27B and Qwen3.8-Flash-Next `fp8_v4` or `k6_v4` (§4.4) |
|
||||
| `--state-cache-dtype T` | f32 | `f32` or `f16`: the recurrent (delta-net) state cache; f16 halves the state memory and is lossy, `qwen35` plugins only (§4.4) |
|
||||
| `--attn-prefill-fp8 MODE` | off | `off`, `qk`, `pv` or `both`: the prefill attention's Q·Kᵀ, P·V or both in E4M3 over an `fp8`, `fp8_v4` or `k6_v4` cache; lossy, Qwen3.8-27B (§4.4) |
|
||||
| `--host-pool-mib N` | 0 | pinned host tier (weights) |
|
||||
| `--host-headroom-mib N` | 4096 | host RAM left free for the system when startup pins host memory — kept for the unpooled allocations, staging and page cache (§4.3) |
|
||||
| `--embedding-placement WHERE` | ram | `ram` or `vram`: the token embedding pinned in host memory beside `--host-pool-mib` and read in place, or on the card (§4.3) |
|
||||
@@ -1664,6 +1841,7 @@ The published vector, its JSON and the llama.cpp patches it was built against ar
|
||||
| `--tp N` | 1 | tensor-parallel ranks |
|
||||
| `--tp-wire MODE` | exact | `exact` or `wht6`, the lossy wire (§4.7) |
|
||||
| `--tp-wire-min-kb N` | 128 | smallest all-reduce, in KiB, the lossy wire is used for |
|
||||
| `--tp-attn-split MODE` | heads | `heads` or `rows`: how a prefill-sized step's attention splits over the ranks, on a plugin that serves the row split (§4.7) |
|
||||
| `--p2p MODE` | auto | `auto` asks the driver, `on` requires peer access, `off` exchanges through host memory (§4.7) |
|
||||
|
||||
**Speculation**
|
||||
@@ -1672,6 +1850,8 @@ The published vector, its JSON and the llama.cpp patches it was built against ar
|
||||
|---|---|---|
|
||||
| `--num-speculative-tokens N` | auto | speculative window; 0 disables. The ceiling under `--draft-window adaptive` |
|
||||
| `--draft-window MODE` | fixed | `fixed` drafts N every step; `adaptive` follows each sequence's acceptance and the measured step cost, serial draft heads only (§4.6) |
|
||||
| `--draft-short-from N` | 0 | a block drafter that declares a shorter block runs it from N decoding sequences on, its own block again two below; 0 never (§4.6) |
|
||||
| `--draft-coupling MODE` | off | `on`: a linear MTP drafter with a 2-bit candidate head (Qwen3.8-Flash-Next) samples each proposal from its reranked top-8 and the sampler maximally couples the target's draw to it. The output distribution is unchanged and a fixed seed yields other tokens than `off`. The head's law is taken at temperature 1, so it pays at high request temperatures and costs at low ones: on Flash-Next TP2 at 2x R9700, tokens per decode step +18% at temperature 1.0 and c1, +11% at 0.7 and c4, -4% at 0.3. Greedy rows are unchanged; any other drafter is refused at startup |
|
||||
| `--draft-model PATH` | | not implemented: merge the drafter at convert time |
|
||||
|
||||
**Server**
|
||||
@@ -1682,7 +1862,7 @@ The published vector, its JSON and the llama.cpp patches it was built against ar
|
||||
| `--port N` | 8000 | listen port |
|
||||
| `--api-key KEY` | none | require `Authorization: Bearer KEY` or `X-Api-Key: KEY` on every request but `/health`, `/v1/health`, `/ping` and the dashboard page (§6.6) |
|
||||
| `--served-model-name NAME` | container's name | the model id `/v1/models` lists, the metrics carry and a response names when its request named none. A request may name any model; the loaded one serves it |
|
||||
| `--mm-max-patches N` | auto | patches one vision-encoder pass carries, and so the largest image (a patch is 16x16 pixels, 14x14 on GLM-5.3). `auto` is 16384 when the container carries a vision tower; 0 serves text only and keeps the tower off the card |
|
||||
| `--mm-max-patches N` | auto | patches one vision-encoder pass carries, and so the largest image (a patch is 16x16 pixels, 14x14 on GLM-5.3). `auto` is 16384 when the container carries a vision tower; 0 serves text only and keeps the tower off the card. A pass is not one tower invocation: inside it the tower batches at most 8 tiles per weight read, and the pass size may reduce that (4 tiles at the 64-pixel grid with the default 16384 patches); a picture contributes a separate pass per grid. See the concurrency notes for Unlimited-OCR (§5.17) |
|
||||
| `--override-chat-template PATH` | container's | a Jinja chat template file served in place of the container's. The reply format (reasoning markers, tool calls) is derived from it too, unless the architecture plugin declares one. An unreadable or empty file stops startup |
|
||||
| `--max-queued-requests N` | 8 × `--max-num-seqs` | requests admitted and unfinished at once; past it, 429 |
|
||||
| `--http-threads N` | one per hardware thread, at least 4 | HTTP workers kept while idle |
|
||||
@@ -1768,7 +1948,7 @@ flags are refused on it, and so are the pixel bands.
|
||||
| `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.13) |
|
||||
| `POST /v1/audio/transcriptions` | OpenAI's speech to text, for a model whose plugin transcribes (Qwen3-ASR), else 501 (§5.14) |
|
||||
| `GET /v1/realtime` (WebSocket) | OpenAI's realtime transcription session: audio streamed in, the words back as they are spoken (§5.14) |
|
||||
| `POST /v1/audio/speech` | OpenAI's speech API, whole or streamed: speech from a speech model (Breeze-TTS-2), `instructions` describing the voice; songs from a music model (MiniMax-Music3), `input` the lyrics and `instructions` the song; else 501 (§5.15) |
|
||||
| `POST /v1/audio/speech` | OpenAI's speech API, whole or streamed: speech from a speech model (Breeze-TTS-2, `instructions` describing the voice; drama-3, speakers and direction in the input); songs from a music model (MiniMax-Music3), `input` the lyrics and `instructions` the song; else 501 (§5.15) |
|
||||
| `GET /v1/audio/speech/stream` (WebSocket) | vLLM-Omni's realtime speech session: text streamed in, each sentence's audio streamed out as soon as the sentence is complete; needs an audio generation model (§5.15) |
|
||||
| `POST /v1/videos`, `GET /v1/videos[/:id[/content]]`, `DELETE /v1/videos/:id` | OpenAI's video jobs: a video with its soundtrack from a prompt, made in the background and downloaded as MP4; needs a video model (MiniMax-H3), else 501 (§5.16) |
|
||||
| `POST /v1/messages`, `POST /v1/messages/count_tokens` | Anthropic's Messages API, for Claude Code and the Anthropic SDKs (§5.9, §5.11) |
|
||||
@@ -1787,6 +1967,7 @@ flags are refused on it, and so are the pixel bands.
|
||||
| `POST /tokenize`, `POST /detokenize` | vLLM's shape (`prompt` or `messages` in, `prompt` out) and llama-server's (`content` in and out, `with_pieces`) |
|
||||
| `GET /get_tokenizer_info` | the tokeniser's configuration |
|
||||
| `POST /reset_prefix_cache` | drop every cached prefix |
|
||||
| `DELETE /sessions/<label>`, `DELETE /sessions?id=<id>` | forget one stored conversation (§4.8) |
|
||||
| `GET /` or `/dashboard` | the web dashboard |
|
||||
| `GET /stats`, `/graph`, `/sessions` | the JSON the dashboard is drawn from |
|
||||
|
||||
@@ -2066,12 +2247,15 @@ under Qwen's research license, non-commercial.
|
||||
(`background: transparent` is a 400), 1024x1024 by default, sides rounded down to multiples of 16,
|
||||
up to 2048x2048 (16384 latent tokens). Krea 2 Raw runs 28 steps at guidance 4.5 against an empty
|
||||
negative prompt and Turbo 8 steps unguided; Krea 2 reads only text, so `/v1/images/edits` answers
|
||||
501. `rebalance: true` multiplies Krea 2's twelve text taps by
|
||||
fixed gains before the text fusion, as ComfyUI's ConditioningKrea2Rebalance at its defaults
|
||||
(4, 4, 4, 4, 4, 4, 4, 10, 20, 4.4, 16, 4); other models ignore the field. FLUX.3 [klein] runs 16 steps unguided and its base 50 at guidance 3.5; both edit from up to ten
|
||||
pictures, each shrunk to 1024x1024 of area when larger. The guidance scale is `guidance_scale` or
|
||||
`true_cfg_scale` (one of them), in the model card's terms. FLUX.3's pipeline can rewrite a prompt
|
||||
with a separate language model first; radiance reads the prompt as given.
|
||||
501. FLUX.3 [klein] runs 16 steps unguided and its base 50 at guidance 3.5; both edit from up to
|
||||
ten pictures, each shrunk to 1024x1024 of area when larger. The guidance scale is `guidance_scale`
|
||||
or `true_cfg_scale` (one of them), in the model card's terms. FLUX.3's pipeline can rewrite a
|
||||
prompt with a separate language model first; radiance reads the prompt as given. Krea 2 takes one
|
||||
more field:
|
||||
|
||||
| field | |
|
||||
|---|---|
|
||||
| `rebalance` | `true` multiplies the twelve text taps by fixed gains before the text fusion, as ComfyUI's ConditioningKrea2Rebalance at its defaults (multiplier 4 times 1, 1, 1, 1, 1, 1, 1, 2.5, 5, 1.1, 4, 1); it applies to the negative prompt's conditioning too. `false` (the default) is the plain model. A boolean, or `true`/`false`/`1`/`0` in a form; a model without it refuses `true` with a 400 |
|
||||
|
||||
**Anima** makes RGB pictures, 1024x1024 by default, sides rounded down to multiples of 16, up to
|
||||
1536x1536 (9216 latent tokens; the card's range is 512x512 to 1536x1536). Base and Aesthetic run 30
|
||||
@@ -2117,6 +2301,7 @@ passes but not launches (the UNet runs once per image and branch), so two take t
|
||||
|---|---|
|
||||
| `model` | accepted and not enforced: one server serves one model |
|
||||
| `messages` / `prompt` / `input` | chat / completion / embedding |
|
||||
| `images_config` | image models only: the processor mode the request wants, by name (`gundam`, `base`) or as an object restating the served sizes; a geometry the model does not serve is refused (Unlimited-OCR, §5.17) |
|
||||
| `max_tokens`, `max_completion_tokens`, `n_predict` | default: what the context leaves after the prompt (`--default-max-tokens`); -1 is llama-server's "no limit", the same without the default. Clamped to what the context leaves, and to `--max-tokens-cap`, rather than refused (§5.8) |
|
||||
| `temperature` | [0, 2] |
|
||||
| `top_p` | (0, 1] |
|
||||
@@ -2134,8 +2319,8 @@ passes but not launches (the UNet runs once per image and branch), so two take t
|
||||
| `stream`, `stream_options.include_usage` | |
|
||||
| `timings_per_token`, `return_progress` | llama-server's: `timings` on every chunk, and `prompt_progress` chunks while the prompt is read |
|
||||
| `samplers` | llama-server's sampler order, names or letters. A stage it leaves out is off. The chain here is penalties, DRY, top-k, top-p, min-p, typical, XTC, with temperature first (the default) or last (llama-server's default), so a list in either order is honoured and any other is refused by name |
|
||||
| `session_id` | OpenRouter's conversation id: labels the conversation on `/sessions` and the dashboard |
|
||||
| `control_vector` | `true` applies the control vector this deployment found to this request's steps, `false` leaves them on the stock model; absent takes the deployment's runtime default (off unless flipped in the dashboard's Model view). `experimental_speed_projection` is Strata's spelling of the same field and is accepted as an alias. A deployment with no vector refuses `true` by name. On a compatible container (Qwen3.8-Flash-Next), a refusal-direction vector makes the model decline far fewer requests -- that is a safety behaviour removed, and you own what it writes (§4.10, "Control vectors") |
|
||||
| `session_id` | OpenRouter's conversation id: labels the conversation on `/sessions` and the dashboard, and names it for `DELETE /sessions/<label>` (§4.8) |
|
||||
| `control_vector` | `true` applies the control vector this deployment found to this request's steps, `false` leaves them on the stock model; absent or null takes the deployment's default (`--control-vector on\|off`, or as changed in the dashboard's Model view). A deployment with no vector refuses `true` by name. On a compatible container (Qwen3.8-Flash-Next), a refusal-direction vector makes the model decline far fewer requests -- that is a safety behaviour removed, and you own what it writes (§4.10, "Control vectors") |
|
||||
| `logprobs`, `top_logprobs`, `n_probs` | each generated token's logprob and up to 20 alternatives (§5.12). Chat: `logprobs: true` with `top_logprobs` alternatives (0 when absent); completions: `logprobs: N`; any endpoint: llama-server's `n_probs: N`, which wins. Not with `echo` (the prompt's logprobs are not computed) |
|
||||
| `tools`, `tool_choice`, `parallel_tool_calls` | chat only. `tool_choice` is `auto`, `none`, `required` or `{"type":"function","function":{"name":...}}`; the last two hold the whole reply to calls (after the reasoning block), the named form to that one function, and cannot be combined with `response_format` or `grammar` |
|
||||
| `add_generation_prompt`, `chat_template_kwargs` | chat only |
|
||||
@@ -2338,7 +2523,7 @@ each field is read, taken without effect, or refused by name.
|
||||
| `output_config` | `effort` (`low`, `medium`, `high`, `xhigh`, `max`) is the chat request's `reasoning_effort`, which the template reads in its own level names: a level it does not take is refused with the ones it does, and `--reasoning-effort-map` renames them (§4.9). `format` (`{"type": "json_schema", "schema": ...}`, or the older top-level `output_format`) is a `response_format` (§5.5). `task_budget` is taken |
|
||||
| `context_management` | validated; the conversation is served as sent, and the answer says so: `"context_management": {"applied_edits": []}`, on `message_delta` in a stream |
|
||||
| `thread` | `create` is served as any request; `continue` is refused, since no conversation is stored |
|
||||
| `metadata` | `user_id` is the conversation's label on `/sessions` |
|
||||
| `metadata` | `user_id` is the conversation's label on `/sessions` and its name for `DELETE /sessions/<label>` (§4.8) |
|
||||
| `service_tier`, `inference_geo`, `speed`, `cache_control`, `diagnostics`, `safeguards`, `fallbacks`, `context_hint` | taken; none can change the answer here. `cache_control` on a block is dropped too |
|
||||
| `mcp_servers`, `container` | refused |
|
||||
| anything else | refused: `"<field>: Extra inputs are not permitted ..."`, Anthropic's own words, which Claude Code matches to retry without a beta field it can drop |
|
||||
@@ -2570,10 +2755,11 @@ socket.
|
||||
|
||||
### 5.15 Speech and music: `/v1/audio/speech`
|
||||
|
||||
An audio generation model answers OpenAI's `POST /v1/audio/speech`: a speech model (Breeze-TTS-2)
|
||||
speaks `input`, in a voice `instructions` may describe; a music model (MiniMax-Music3) sings `input`
|
||||
as lyrics, as `instructions` describe the song (SGLang-Omni's reading of the route). Both are
|
||||
converted from their release directories (§3.2).
|
||||
An audio generation model answers OpenAI's `POST /v1/audio/speech`: a speech model speaks `input`,
|
||||
in a voice `instructions` may describe (Breeze-TTS-2) or with its speakers and direction written in
|
||||
the input itself (drama-3); a music model (MiniMax-Music3) sings `input` as lyrics, as
|
||||
`instructions` describe the song (SGLang-Omni's reading of the route). Each is converted from its
|
||||
release directory (§3.2).
|
||||
|
||||
#### Speech: Breeze-TTS-2
|
||||
|
||||
@@ -2602,6 +2788,60 @@ as it is spoken. On one R9700 a sentence is made at 0.6 of the time it plays (5.
|
||||
speed they play (43 s of speech in 12.1 s). Breeze-TTS-2 is licensed for research and
|
||||
non-commercial use only, and BreezeBlue counts hosting it as an API as commercial.
|
||||
|
||||
#### Speech: drama-3
|
||||
|
||||
```sh
|
||||
radiance --model drama3-fp8.rad --tp 2 # two cards
|
||||
|
||||
curl -s http://localhost:8000/v1/audio/speech -H 'Content-Type: application/json' -d '{
|
||||
"input": "The lighthouse keeper counted seven ships before the fog rolled in."}' -o ships.wav
|
||||
curl -s http://localhost:8000/v1/audio/speech -H 'Content-Type: application/json' -d '{
|
||||
"input": "<|speaker:0|> Did you lock the back door?\n<|speaker:1|> [sighs] I thought you did."}' \
|
||||
-o door.wav # 44.1 kHz mono, 16-bit
|
||||
curl -s http://localhost:8000/v1/audio/speech -H 'Content-Type: application/json' -d @- \
|
||||
-o cloned.wav <<EOF # the voice of voice.wav
|
||||
{"input": "The lighthouse keeper counted seven ships before the fog rolled in.",
|
||||
"references": [{"audio": "$(base64 -w0 voice.wav)", "text": "What voice.wav says."}]}
|
||||
EOF
|
||||
```
|
||||
|
||||
- **`input`** is the script. Speakers are named in it, `<|speaker:0|>` to `<|speaker:15|>`, and
|
||||
text before any tag is speaker 0's; each speaker's turn is written as Fish Audio's server writes
|
||||
it (the tag, a space, the turn's text stripped, each turn on a line of its own), so the turns may
|
||||
be given on one line. The direction is written in the text too: point tags such as `[laughs]`,
|
||||
`[sighs]` or `[pause]`, a bracketed style before a line (`[with bright eager excitement] We
|
||||
won!`), `<whisper>...</whisper>`. The tokens only the prompt is built from (`<|im_start|>`,
|
||||
`<|im_end|>`, `<|voice|>`, `<|text|>`, `<|interleave|>`, `<|semantic:...|>`) are refused, and so
|
||||
is any other spelling of a speaker.
|
||||
- **`instructions` are refused**, the direction being the input's; `guidance_scale` must be 1 (the
|
||||
model runs one branch). Without references each speaker's voice is the model's choice, the same
|
||||
within a take.
|
||||
- **`references`** clone voices from recordings: an array of `{"audio": ..., "text": ...}`, the
|
||||
clip a `data:` URL or the base64 of an audio file (anything ffmpeg reads, decoded to mono
|
||||
44.1 kHz), its text what the clip says; at most 8 clips and 30 s of audio together. A
|
||||
reference's voice is the speaker its transcript is tagged with, speaker 0 when untagged, so a
|
||||
dialogue gives each speaker a clip: `"<|speaker:1|> ..."` as the second reference's text voices
|
||||
the input's `<|speaker:1|>` turns. The clips are encoded by the codec's own encoder in the
|
||||
request's first pass, in bf16 as fish-speech's server encodes them (a 12 s clip adds about
|
||||
0.12 s before the first audio), and the prompt is fish-speech's with references:
|
||||
`[Reference 1]`, its transcript and its frames, for each.
|
||||
- **The length** is `duration` in seconds or `max_new_tokens` in frames (21.5 a second), up to 95 s;
|
||||
the model ends the speech at the end of the script. The prompt holds at most 3072 tokens, a
|
||||
reference adding 21.5 a second of its clip.
|
||||
- **Sampling** is SGLang-Omni's: temperature 1.0 and top-p 0.9 (Fish Audio's model card), the
|
||||
first code uncapped and each later code at top-k 30, with fish-speech's repetition-aware redraw
|
||||
of the first code. fish-speech's server samples at 0.7, 0.7 and 30, where the model often falls
|
||||
silent after a tag or a speaker's line and runs to its length (docs/ARCHITECTURES.md has the
|
||||
counts). A take can still end before its last line; another `seed` usually speaks it all.
|
||||
- **`seed`**, **`response_format`**, **`speed`** and **`voice`** are read as for music below.
|
||||
|
||||
Speech is played sixteen frames (0.74 s) at a time as it is made. On two R9700s a sentence is made
|
||||
at 0.30 of the time it plays (3.67 s of speech in 1.08 s) and a stream's first audio comes 0.23 s
|
||||
after the request; four paragraphs at once make 50.4 s of speech in 5.15 s. drama-3 is under the
|
||||
Fish Audio Community License: research, non-commercial and small commercial use are free; a
|
||||
service that lets others generate speech needs a licence from Fish Audio, and so does imitating a
|
||||
real person's voice without their consent.
|
||||
|
||||
#### Music: MiniMax-Music3
|
||||
|
||||
```sh
|
||||
@@ -2663,7 +2903,8 @@ is complete, so the first audio waits for the first sentence rather than the who
|
||||
|
||||
- **`session.config`** takes the fields of `POST /v1/audio/speech` but `input` (`instructions`,
|
||||
`voice`, `seed`, `guidance_scale`, `max_new_tokens` or `duration` for each sentence, `speed`,
|
||||
`num_inference_steps` where the model has a denoiser), checked as that route checks them, and
|
||||
`num_inference_steps` where the model has a denoiser, `references` where it clones a voice),
|
||||
checked as that route checks them, and
|
||||
four of its own: `response_format` `pcm` (the default) or `wav`; `stream_audio`, false (the
|
||||
default) for one binary message a sentence or true for the audio as the model makes it;
|
||||
`split_granularity`, `sentence` (the default), `clause` (also at commas and semicolons) or `none`
|
||||
@@ -2813,6 +3054,84 @@ The MP4's soundtrack is 48 kHz stereo. LTX-2.5 runs on one card; `--tp` above 1
|
||||
Gemma 4 text encoder (13 GiB in fp8) does not fit a 32 GB card beside the DiT: serve it with
|
||||
`--vision-tower-placement ram`, which keeps it in pinned host memory and reads it once a prompt.
|
||||
|
||||
### 5.17 Documents: Unlimited-OCR
|
||||
|
||||
`unlimited-ocr` (baidu/Unlimited-OCR, bf16; the converted container is
|
||||
[Aijuus/unlimited-ocr-bf16](https://huggingface.co/Aijuus/unlimited-ocr-bf16), with its recipe;
|
||||
`deploy/compose/unlimited-ocr-bf16.yaml`) parses
|
||||
pictures of documents through the ordinary chat endpoint. It is a single-shot parser, not a
|
||||
conversation: one user message holds the picture(s) and the instruction, and the reply is the
|
||||
layout. The picture part comes **before** the text part (the reference prompt is `<image>` then
|
||||
the instruction):
|
||||
|
||||
```sh
|
||||
curl http://127.0.0.1:8000/v1/chat/completions -H "Authorization: Bearer $KEY" \
|
||||
-H 'Content-Type: application/json' -d '{
|
||||
"model": "unlimited-ocr",
|
||||
"messages": [{"role": "user", "content": [
|
||||
{"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}},
|
||||
{"type": "text", "text": "document parsing."}]}],
|
||||
"images_config": "gundam", "temperature": 0, "max_tokens": 2048}'
|
||||
```
|
||||
|
||||
`images_config` selects the geometry:
|
||||
|
||||
| value | meaning |
|
||||
|---|---|
|
||||
| `"gundam"` (or `{"base_size":1024,"image_size":640,"crop_mode":true}`) | one picture; larger than 640 px it is cut into 640-px tiles plus the 1024-px global view |
|
||||
| `{"base_size":1024,"image_size":640,"crop_mode":false}` | one 640-px page (a page scan) |
|
||||
| one image part per page, base mode, text `"Multi page parsing."` | several pages in one prompt |
|
||||
|
||||
Only the 1024/640 geometry is served (`base_size` and `image_size` may restate it, nothing else);
|
||||
any other side is refused with a 400 rather than stopping the server. A PDF is **not** an accepted
|
||||
input: rasterise it first (`pdftoppm -r 200 -png`) and send the page images, a handful at a time.
|
||||
PNG, JPEG, WebP, GIF, BMP, TIFF, AVIF and HEIF decode; the request body is bounded by
|
||||
`--max-body-mib` (default 512).
|
||||
|
||||
The reply is text, one block per detected region, with the region type and its box in the model's
|
||||
1024-pixel coordinates; the `<|det|>`/`<|/det|>` control tokens are stripped from the chat
|
||||
response, so a line reads `text [59, 54, 498, 70]The quick brown fox ...` (a multi-page reply has
|
||||
`<PAGE>` at each page start). Parse with
|
||||
`^(title|text|table|list|footer|image_footnote)\[(\d+), (\d+), (\d+), (\d+)\](.*)$`.
|
||||
|
||||
The checkpoint's generation behaviour is kept: a 128-token generated-token ring (`RAD_KV_RING`,
|
||||
requests excluded from prefix reuse) and the 35-gram/128-token no-repeat ban, both overridable per
|
||||
request (`ngram_ban_n`, `ngram_window`). It needs about 7 GiB on one card, so serve it alone; the
|
||||
compose file takes `RADIANCE_GPU` and the model file's VRAM, with the vision tower on the card and
|
||||
an fp8 KV cache.
|
||||
|
||||
**Concurrency and tuning.** Encoding is a stop-the-world step: while one encode pass runs no
|
||||
request decodes, and a picture's TTFT is the passes queued ahead of it plus its own. On the mixed
|
||||
697/1517-token ladder the measured TTFT p50 is 355 / 717 / 1449 / 2786 ms at 1 / 2 / 4 / 8
|
||||
concurrent pages — linear in the queued **pass count**, not in tokens.
|
||||
|
||||
A picture contributes one pass per encoder geometry: its 40-pixel line segments first, then its
|
||||
64-pixel global view and separator. A pass carries at most `--mm-max-patches` patches, ends at a
|
||||
geometry change, and items are packed in arrival order, so pages do not share a pass. A
|
||||
1024-pixel picture (four 640 tiles plus the global view) is 10,768 patches — two passes; a
|
||||
1000x1400 picture (~12 tiles) has 19,200 patches in its 40-pixel part, so that part splits into
|
||||
two passes: three in all.
|
||||
|
||||
`--mm-max-patches` bounds a pass, not one tower invocation. Within a pass the tower batches at
|
||||
most `kBatchCap` (8) tiles per weight read, and the pass size can lower that: at the default
|
||||
16384 patches it is 8 at the 40-pixel grid but 4 at 64. So a 10-tile pass still runs as 8+2
|
||||
batched invocations, and raising the flag past 8 tiles does not reduce the 40-grid weight reads
|
||||
(it does lift the 64-grid batch to 8). The batch changes the tower's activation set: about
|
||||
0.47 GiB at 8 tiles (40 grid), 0.61 GiB at 4 and about 1.2 GiB at 8 (64 grid), before the planner
|
||||
aliases buffers. The order that helps most is smaller page geometry (fewer tiles, fewer passes);
|
||||
then a higher `--mm-max-patches` for a picture whose 40-pixel part is split and to let several
|
||||
same-grid segments share a pass. The `kBatchCap` ceiling itself is a build-time constant, not a
|
||||
flag.
|
||||
|
||||
Decode batching is separate: a step amortises the head, attention and shared-expert weights
|
||||
across the batch but not the routed-expert reads, which are per token, so aggregate decode roughly
|
||||
doubles at batch 8 rather than scaling with it. Encoding and decoding do not overlap yet, so
|
||||
mixed image+text traffic sees every encode pass as a decode stall.
|
||||
|
||||
The reference's `infer` opens its prompt with the BOS the chat template omits, and the chat path
|
||||
supplies it; `/v1/completions` prompts are served exactly as sent (the reference has no
|
||||
completions entry point), so prompt parity with the reference is a chat-endpoint property.
|
||||
|
||||
## 6. Operation
|
||||
|
||||
### 6.1 The dashboard
|
||||
@@ -2879,6 +3198,36 @@ restart if one is decided on. The estimator is `rad::DecodeFloor` in
|
||||
`core/sched/metrics.h`; `docs/DEVLOG-decode-floor.md` is the log of how these
|
||||
figures came to be shown without a verdict attached.
|
||||
|
||||
The decode, prefill, requests-in-flight and draft-acceptance tiles carry a line of the same shape,
|
||||
which the page computes from its own polls:
|
||||
|
||||
```
|
||||
best 58 · recent 54 · now 93% of best@c4
|
||||
```
|
||||
|
||||
`best` (`highest` on requests in flight and acceptance) is the extreme this page has seen at the
|
||||
current concurrency, `recent` the mean of its last 30 samples there (15 s at one poll every 500 ms;
|
||||
5 s for prefill), and `now` the current value as a share of the extreme. Past one sequence the line
|
||||
names its concurrency (`@c4`); requests in flight keeps a single set. Reloading the page resets these
|
||||
figures, a server restart does not. While nothing runs, the big figure reads 0 and the line keeps its
|
||||
last figures without `now`.
|
||||
|
||||
Draft acceptance is reported as two ratios with different denominators. A draft position is
|
||||
verified only when every earlier one passed, so:
|
||||
|
||||
- **accepted / reached** (conditional): of the drafts verified at a position, the share that passed.
|
||||
The acceptance tile, the Speculation panel's large "conditionally accepted" figure and the
|
||||
per-position bars show it. The headline is the last poll's; the tile's `recent` pools the last 30
|
||||
polls that drafted as a ratio of sums.
|
||||
- **accepted / drafted**: of every drafted token, the share that became text, since the process
|
||||
started. The Speculation panel's "Accepted of drafted", `draft_accept` on `/stats` and
|
||||
`radiance:draft_acceptance_ratio` on `/metrics` show it.
|
||||
|
||||
Reached is never more than drafted, so the first is never the lower. At depth 3 with positions
|
||||
passing 56%, 75% and 77% of the time they are reached, a step reaches 1 + 0.56 + 0.42 = 1.98
|
||||
positions on average and accepts 0.56 + 0.42 + 0.32 = 1.30 tokens: 66% accepted / reached against
|
||||
1.30 / 3 = 43% accepted / drafted.
|
||||
|
||||
**Sessions**: one row per stored conversation: how many tokens, which tier it is in, and whether its
|
||||
linear half is still reachable. Sizes overlap and cannot be added: two sessions sharing a system
|
||||
prompt share its blocks.
|
||||
@@ -2893,6 +3242,7 @@ scheduler clamps reuse to the last linear checkpoint. That verdict is the tab's
|
||||
```sh
|
||||
curl -s localhost:8000/stats | jq # counters, memory, throughput
|
||||
curl -s localhost:8000/sessions | jq # what is stored and where
|
||||
curl -s -X DELETE localhost:8000/sessions/chat-7 | jq # forget one stored conversation (§4.8)
|
||||
curl -s localhost:8000/graph | jq # the resolved kernel graph
|
||||
curl -s localhost:8000/server_info | jq # model, cards, KV, draft depth, wire
|
||||
curl -s localhost:8000/diagnostics | jq # the startup report, hardware read again now (§7.1)
|
||||
@@ -2924,6 +3274,7 @@ there is none.
|
||||
|---|---|
|
||||
| `engine_steps_total`, `_decode_total`, `_prefill_total`, `_mixed_total` | step counts by kind |
|
||||
| `engine_step_seconds_total`, `_decode_total` | step time, the denominator for per-step figures |
|
||||
| `decode_step_seconds_best`, `decode_step_seconds_recent` | the decode floor of §6.1, in seconds per step; each is absent until a single-sequence window has completed |
|
||||
| `decode_tokens_total`, `prefill_tokens_total` | |
|
||||
| `decode_tokens_per_second`, `prefill_tokens_per_second` | |
|
||||
| `draft_tokens_total`, `draft_accepted_total`, `draft_acceptance_ratio` | |
|
||||
@@ -2937,17 +3288,18 @@ there is none.
|
||||
| `linear_checkpoints_written_total`, `linear_prefix_cache_hit_rate` | |
|
||||
| `prefix_cache_evictions_total`, `prefix_cache_ckpt_evictions_total` | |
|
||||
| `prefix_cache_ckpt_evictions_by_reason_total{reason}`, `prefix_cache_ckpt_refused_total` | snapshots released by `--checkpoint-policy` (`retention`) or as the least recently used of a full store (`store_full`); checkpoints not written for want of a slot |
|
||||
| `prefix_hit_cuts_total{reason}`, `prefix_hit_cut_tokens_total` | admissions whose hit reused nothing (`no_snapshot`, `windowed_group`, `adopt_failed`) or resumed at a snapshot more than one checkpoint interval below it (`resumed_below`), and the checkpoint shortfall: cached prompt tokens computed again because the hit resumed at a snapshot below it. `/stats` and `/sessions` carry the same counts; `RADIANCE_LOG=debug` logs each eviction and each cut hit |
|
||||
| `prefix_restore_cuts_total` | restores from the host tier the pool could not hold whole, even after giving up other conversations' VRAM copies (§4.8) |
|
||||
| `prefix_hit_cuts_total{reason}`, `prefix_hit_cut_tokens_total` | admissions whose hit reused nothing (`no_snapshot`, `windowed_group`, `adopt_failed`) or resumed at a snapshot more than one checkpoint interval below it (`resumed_below`: the previous reply was longer than an interval, since decode writes no snapshot, the retention policy kept nothing nearer, or a restore was cut), and the checkpoint shortfall: cached prompt tokens computed again because the hit resumed at a snapshot below it. `/stats` and `/sessions` carry the same counts; `RADIANCE_LOG=debug` logs each eviction and each cut hit |
|
||||
| `prefix_restore_cuts_total` | restores from the host tier the pool could not hold whole, even after giving up other conversations' VRAM copies (§4.8); `RADIANCE_LOG=debug` logs where each was cut |
|
||||
| `prefix_cache_expired_total`, `prefix_cache_ckpt_expired_total` | what `--prefix-cache-ttl` removed (§4.8) |
|
||||
| `prefix_cache_released_total{what}` | entries and snapshots clients forgot through `DELETE /sessions` (§4.8) |
|
||||
| `num_requests_preempted` | |
|
||||
| `http_queue_depth`, `http_responses_total`, `http_admission_rejected_total` | |
|
||||
| `client_disconnect_total`, `stream_overflow_total` | |
|
||||
|
||||
Two pitfalls:
|
||||
|
||||
- `draft_acceptance_ratio` is conditional on having drafted, so it can stay high while tokens per
|
||||
step collapse. Blocks per step (`draft_tokens_total / depth` over `engine_steps_decode_total`)
|
||||
- `draft_acceptance_ratio` is accepted / drafted and counts only drafted tokens, so it can stay high
|
||||
while tokens per step collapse. Blocks per step (`draft_tokens_total / depth` over `engine_steps_decode_total`)
|
||||
separates the two; `scripts/mcdecl.sh` measures it.
|
||||
- Step time is not wall-clock over steps. Use `engine_step_seconds_decode_total /
|
||||
engine_steps_decode_total`, which charges only decode; wall-clock also charges idle and prefill.
|
||||
@@ -3039,7 +3391,7 @@ is the part of a log to paste into an issue. Its sections:
|
||||
warning is also printed as a `W` line of its own.
|
||||
|
||||
```
|
||||
I STARTUP REPORT -- radiance 1.10.0
|
||||
I STARTUP REPORT -- radiance 1.12.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]
|
||||
@@ -3076,6 +3428,7 @@ curl -s -H "Authorization: Bearer $KEY" localhost:8000/diagnostics | jq '.findin
|
||||
|---|---|---|
|
||||
| `N declared op(s) resolve only to a reference implementation (libref)` and the engine exits | No kernel library covers those ops on this card (§2) | Install a library that covers them, or accept the cost with `--debug-accept-reference-kernels`. The named ops are what a new library must implement |
|
||||
| `DID NOT FIT` in the placement plan, naming a weight class, or `KV group '...': ... did not fit the KV pool` | The split left one side too little. A routed expert cannot be served from the file tier, so it has nowhere else to go | If weights did not fit: add or raise `--host-pool-mib`, or lower `--max-model-len` or `--max-num-seqs`. If a KV group did not fit: `--kv-cache-dtype fp8`, or a larger `--host-pool-mib` (RAM permitting), which takes experts off the card. The plan report names which, by class, with the shortfall |
|
||||
| `this kernel's amdgpu interface is 3.N ... a map here would never return` | The HIP 7.16 (ROCm 10.1) runtime waits for the kernel to finish every virtual-memory map on a page-table timeline, which amdgpu signals only from interface 3.64 (Linux 6.16) on; an older kernel never signals it, so the card runs without virtual memory management: the KV cache holds its whole carve and lends nothing to the experts (§4.3) | A 6.16 or later kernel, or an amdgpu-dkms driver of interface 3.64 or later |
|
||||
| `chat is 501` in the `serving on` line | The container carries no chat template | Re-convert with `--tokenizer`, and check that a `chat_template.jinja` sits beside `tokenizer_config.json` in the checkpoint. Meanwhile use `/v1/completions` |
|
||||
| `does not read '<weight>' encoded <encoding>` at startup | No loaded kernel takes that weight's encoding for the op that reads it | Convert with a recipe that writes an encoding a loaded kernel reads, or load the library that reads it |
|
||||
| Prefix hit rate 0% and every turn re-prefills | The KV pool cannot hold the live sessions, so the cache evicts what the next turn wanted | The cache already has everything the experts can spare: a larger `--host-pool-mib` (RAM permitting), `--kv-cache-dtype fp8`, or fewer or shorter sessions (§4.3) |
|
||||
@@ -3114,6 +3467,7 @@ rad-kbench --home $RADIANCE_HOME --max-cases 1 # are the kernels correct?
|
||||
| `HF_TOKEN` | for `scripts/hfget.sh` and `--model <owner/name>` on a gated or private repo |
|
||||
| `XDG_CACHE_HOME` | where `--model <owner/name>` fetches to without `--download-dir` (`$XDG_CACHE_HOME/radiance/hf`, else `~/.cache/radiance/hf`) |
|
||||
| `R4D_AR_MAX_BLOCKS` | a ceiling on libr4d's collective block counts, for two tensor-parallel engines on one set of cards; set it in both (below). The MoE models' hyper-connection gathers keep the minimum their LDS table needs. Unset, nothing changes |
|
||||
| `RADIANCE_PREFETCH_BESIDE` | `0` issues no weight prefetch beside the decode collectives. For an engine that shares its cards with another server (below); alone it costs a few percent of decode. Unset, nothing changes |
|
||||
|
||||
**Two engines on one set of cards.** Every block of a libr4d collective spins until its twin on the
|
||||
peer card has pushed, and a prefill-sized fused all-reduce launches more blocks than a card holds at
|
||||
@@ -3126,7 +3480,7 @@ low enough that their spinners together leave part of a card free, the cycle can
|
||||
Qwen3.8-27B (its decode at 16 sequences x 4 rows stays uncapped) and 16 for the Gemma ran 15
|
||||
minutes of concurrent long prompts on both without a stall. The ceiling costs prefill time, the
|
||||
reductions running on fewer blocks: Qwen3.8-27B's 41k-token prefill 9.5 s uncapped, 9.8 s at 64,
|
||||
10.3 s at 32. Give the engine started first its `--gpu-headroom-mib` for the second.
|
||||
10.3 s at 32. Give the engine started first its `--gpu-headroom-mib` for the second. A model whose decode reads weights ahead on a second queue (Gemma 4 without chained launches) slows sharply beside a second server: an R9700 has four compute queue slots and the two servers hold eight, so every decode step waits for a queue switch. Gemma 4 31B at TP4 beside an idle Qwen3.8-Flash-Next went from 13 ms to 41 ms a step; with `RADIANCE_PREFETCH_BESIDE=0` in the Gemma engine it took 13.8 ms.
|
||||
|
||||
**Tooling**
|
||||
|
||||
@@ -3137,13 +3491,7 @@ reductions running on fewer blocks: Qwen3.8-27B's 41k-token prefill 9.5 s uncapp
|
||||
| `RADIANCE_CALIB_TOKENS` | with `RADIANCE_CALIB_DIR`, the tokens the calibration tap accumulates before it writes and switches itself off (default 65536) |
|
||||
| `RADIANCE_G3_CALIB_LAYERS` | `lo:hi`: `arch/gemma3`'s calibration tap over layers lo to hi - 1 only, to take a large model's Grams in passes (docs/ARCHITECTURES.md) |
|
||||
| `RADIANCE_PROFILE_EVERY` | with `--profile-ops`, dump the per-op table every N steps (default 32) |
|
||||
| `RADIANCE_AR_FENCE_FROM` | four-rank all-reduces of at least this many elements take a full fence before their flag (default 131072: prefill chunks, never decode or verify); cures a rare fresh-start divergence on the 31B at tp 4; `0` turns it off |
|
||||
| `RADIANCE_PREFETCH` | `0` declares none of the weight reads the Gemma 4 31B and its DFlash2 drafter issue beside each all-reduce at decode and verify heights (libr4d `prefetch`: the next GEMM's leading weight bytes read into the on-die cache while the collective leaves the memory idle); on by default at more than one rank where the kernel library serves the op |
|
||||
| `RADIANCE_CHAIN` | chained launches, where a dependent kernel waits for the one before it in its own prologue rather than behind the queue's barrier bit: on by default on the AQL backend where the model's plugin measured a gain with its speculative drafter (the Gemma 4 31B and 26B) and that drafter decodes speculatively (`auto`, the default); `0` turns them off, `1` on wherever the backend chains |
|
||||
| `RADIANCE_LOG_STEPS` | log one line per step: its phase, sequences, and each one's token count and context (§4.5) |
|
||||
| `RADIANCE_GEMMA4_OVERLAP` | the Gemma 4 31B's prefill overlap (`arch/gemma4_bf16`, two or more ranks, fused junctions, the exact all-reduce wire): a prefill step of 1024 rows or more runs as two slices, each slice's all-reduces on a second stream beside the other's compute. On by default; `0` turns it off and runs every step whole (the startup notes say which) |
|
||||
| `RADIANCE_AR8_SHARD_WEIGHTS`, `RADIANCE_AR8_PIECES` | the eight-rank two-shot's shard weights (`auto`, the default, reads the PCIe links; `off`; or eight integers) and piece count, with `RADIANCE_AR8_SHARD_WEIGHTS_MIN_ELEMS` and `RADIANCE_AR8_PIECES_MIN_ELEMS` for the message size each starts at (§4.7) |
|
||||
| `RADIANCE_DRAFT_BLOCK_HOST` | `1` runs a block drafter's (DFlash) passes from the host after each commit, two waits a step and no step issued ahead, instead of on the card's acceptance. For comparing the two drivers; the replies and the drafts' acceptance are the same |
|
||||
|
||||
Engine development has its own instruments: `RADIANCE_DEBUG_*` (residual probes, routing and issue
|
||||
dumps), `RADIANCE_OP_ORACLE*` (named ops checked against `libref` on the operands the model issued;
|
||||
|
||||
@@ -88,6 +88,20 @@ to bisect it (`spec.md` §17).
|
||||
**No allocation and no synchronisation on the step path.** The arena is sized at declare. A
|
||||
`malloc` needed inside `rad_arch_step` or the scheduler's per-step work is a declare-phase bug.
|
||||
|
||||
**Kernel scratch is per lane, each region sized by what its lane may issue.** In-order launch lets
|
||||
every op on one stream share one scratch region; a second lane is a second stream and gets a second
|
||||
region once the architecture names any buffer to `rad_buf_concurrent` (`Program::scratch_regions`).
|
||||
Region 0 holds the program's largest device scratch (`Program::scratch_bytes`). Region 1 holds the
|
||||
largest device scratch of an op the second lane may issue (`Program::scratch_bytes_lane1`, computed
|
||||
in `Builder::finish_buffer_liveness`): by `Ctx::lane1_`'s rule 3 such an op touches only
|
||||
concurrent buffers, so an op with any other transient buffer never runs there, and one with no
|
||||
transient buffer counts. `Arena::init` takes both sizes, `arena_plan_bytes` charges both to the VRAM
|
||||
budget, and startup prints them (`arena: ... device + ... scratch + ... for the second lane = ...`).
|
||||
A lane-1 request larger than region 1 comes from an op that breaks rule 3 in its buffers too, so
|
||||
`Ctx::issue` fails the step naming the kernel (`RAD_E_SCRATCH`) rather than let it overrun the
|
||||
region. On Qwen3.8-27B with its DFlash2 drafter region 1 is 0 B against region 0's 50 MiB a card
|
||||
at speculation 7 (17 MiB without speculation).
|
||||
|
||||
**`rad_memset_async` refuses `RAD_MEM_HOST` on a card; the host backend cannot reproduce that.**
|
||||
`RAD_MEM_HOST` is pageable memory the GPU has never been shown, so the device backend returns
|
||||
`RAD_E_UNSUPPORTED` naming the rule (`core/device/aql.cpp`). On the host backend all memory kinds
|
||||
|
||||
+146
-34
@@ -280,7 +280,8 @@ weight.
|
||||
**`act_mul`** is `silu_mul` with its halves in two operands, so the multiplier can be any tensor:
|
||||
two column slices of a fused `gate_up`, or a gate and a separate per-layer input (EmbeddingGemma 2's
|
||||
per-layer-embedding block multiplies `gelu_tanh(gate(x))` by one). `act` is `silu`, `gelu` (exact
|
||||
erf), `gelu_tanh` or `sigmoid` (a GLU: `a` the gate half, `b` the value half). The activation is
|
||||
erf), `gelu_tanh`, `sigmoid` (a GLU: `a` the gate half, `b` the value half) or `quick_gelu`
|
||||
(`sigmoid` of the bf16-rounded `1.702 a`, the CLIP tower's fused form). The activation is
|
||||
rounded to `y`'s dtype before the product, as the unfused pair stores it.
|
||||
|
||||
**`seg_mean`** is mean pooling over a ragged batch: row `s` of `y` is the mean of `x`'s rows
|
||||
@@ -317,12 +318,12 @@ so a different op rather than a mode a library could ignore.
|
||||
|
||||
### Hyper-connections
|
||||
|
||||
`hc_project` is the control vector's projection (core/cvec.h): `h[s] -=
|
||||
scale * (h[s] . v) * v` for each of the `hc` streams of a row whose `on` flag (an int32 per row) is
|
||||
1, `v` being that layer's unit direction and `scale` the norm the file stored. It is llama.cpp's
|
||||
`hc_project` is the control vector's projection (core/cvec.h): `h[s] -= scale * (h[s] . v) * v`
|
||||
for each of the `hc` streams of a row whose `on` flag (an int32 per row) is 1, `v` being that
|
||||
layer's unit f32 direction and `scale` the norm the file stored. It is llama.cpp's
|
||||
`--cvec-mode project`, applied after a layer's write into the stream. A row whose flag is 0 is
|
||||
neither read nor written, so an unprojected request's stream is the stock model's; the direction table is f32 and the op is issued only by an architecture that was
|
||||
declared with one (`RadBuildCtx::cvec`).
|
||||
neither read nor written. It is declared only by an architecture given a vector
|
||||
(`RadBuildCtx::cvec`), and not issued on a pass where no row takes it (`RadBatch::control_vector`).
|
||||
|
||||
`hc_read` and `hc_write` are the gated residual pair a hyper-connection model has instead of a
|
||||
pre-norm and a residual add. The stream is `hc` times the model width; every block reads a mix of
|
||||
@@ -425,7 +426,7 @@ of the scalar kernels that serve the rows it cannot read.
|
||||
| `norm_add_norm_route` | `M`(range) `n` `eps`:f64 `dtype` `mult`:f64 `group` | `a`, `w_a`w, `x`:inout, `w_y`w → `y`; `w_r`w → `r`; `w_e`w → `q`, `qs` |
|
||||
| `join_add_scale` | `M`(range) `n` `eps`:f64 `dtype` | `d`, `w_d`w, `r`, `w_r`w, `w_j`w, `x`:inout, `s`w, `w_n`w? → `y`? |
|
||||
| `expert_scale` | `M`(range) `n_expert` `top_k` `dtype` | `ids`, `w_e`w, `ew`:inout |
|
||||
| `attn_paged_qrow` | `q_len`(range) `head_dim` `gqa` `block_size`/der `causal` `window` `q_dtype` `kv_dtype` `scale`:f64/opt `max_ctx`/opt `n_head`/opt `max_seqs`/opt | `q`, `kv_cache`, `block_table`, `seqused`, `k_descale`?, `v_descale`?, `cu_seqlens`? → `out` |
|
||||
| `attn_paged_qrow` | `q_len`(range) `head_dim` `gqa` `block_size`/der `causal` `window` `q_dtype` `kv_dtype` `scale`:f64/opt `max_ctx`/opt `n_head`/opt `max_seqs`/opt `prefill_fp8`/opt | `q`, `kv_cache`, `block_table`, `seqused`, `k_descale`?, `v_descale`?, `cu_seqlens`? → `out` |
|
||||
|
||||
Gemma's sandwich norms, each one kernel in place of a chain of `rmsnorm`, `add` and `mul_weight`:
|
||||
|
||||
@@ -841,20 +842,23 @@ the count from `tail`, as a GEMM takes its M from its operands.
|
||||
| `prefetch` | `bytes` | `w`w |
|
||||
|
||||
Reads the first `bytes` of a weight's stored form and writes nothing, so a kernel that streams the
|
||||
weight next finds those bytes in the on-die cache (64 MB on gfx1201). It is issued on the second
|
||||
lane beside a collective that leaves the card's memory idle (`rad_lane`); on the same lane it would
|
||||
only add its own time. Its layout hook answers RAD_LAYOUT_ANY (abi/rad_abi.h): it takes the bytes
|
||||
weight next finds those bytes in the on-die cache (64 MB on gfx1201). It is issued beside a
|
||||
collective that leaves the card's memory idle: on the second lane (`rad_lane`), or, where launches
|
||||
chain (`rad_chain_on`), as its chained form on the same lane right behind the GEMM before the
|
||||
collective, which waits for that GEMM only and does not hold the collective. A plain read on the
|
||||
same lane would only add its own time. Its layout hook answers RAD_LAYOUT_ANY (abi/rad_abi.h): it takes the bytes
|
||||
as the weight's GEMM stored them and claims no form. It changes no value.
|
||||
|
||||
## Attention
|
||||
|
||||
| op | params | operands |
|
||||
|---|---|---|
|
||||
| `attn_paged` | `q_len`(range) `head_dim` `gqa` `block_size`/der `causal` `window` `q_dtype` `kv_dtype` `scale`:f64/opt `max_ctx`/opt `n_head`/opt `max_seqs`/opt | `q`, `kv_cache`, `block_table`, `seqused`, `k_descale`?, `v_descale`?, `cu_seqlens`? → `out` |
|
||||
| `attn_paged` | `q_len`(range) `head_dim` `gqa` `block_size`/der `causal` `window` `q_dtype` `kv_dtype` `scale`:f64/opt `max_ctx`/opt `n_head`/opt `max_seqs`/opt `prefill_fp8`/opt | `q`, `kv_cache`, `block_table`, `seqused`, `k_descale`?, `v_descale`?, `cu_seqlens`? → `out` |
|
||||
| `attn_dense` | `M`(range) `head_dim` `gqa` `causal` `dtype` `scale`:f64/opt `max_seqlen`/opt `window`/opt `cu_div`/opt `block`/opt `window_right`/opt | `q`, `k`, `v`, `cu_seqlens` → `out` |
|
||||
| `attn_cross` | `M`(range) `head_dim` `gqa` `causal` `dtype` `scale`:f64/opt | `q`, `k`, `v`, `cu_seqlens`, `cu_k` → `out` |
|
||||
| `attn_na3d` | `M`(range) `head_dim` `kt` `kh` `kw` `dtype` `scale`:f64/opt | `q`, `k`, `v`, `geom` → `out` |
|
||||
| `attn_local_rel` | `M`(range) `head_dim` `n_head` `left` `right` `softcap`:f64 `cu_div`/opt `dtype` | `q`, `k`, `v`, `relk`, `pds`w, `cu_seqlens` → `out` |
|
||||
| `sam_attn` | `M`(range) `head_dim` `n_head` `grid_h` `grid_w` `window` `scale`:f64 `dtype` | `q`, `k`, `v`, `cu_seqlens`, `out`, `rel_pos_h`w, `rel_pos_w`w |
|
||||
| `kv_store` | `M`(range) `head_dim` `n_head_kv` `block_size` `kv_dtype` `k_scale`:f64/opt `v_scale`:f64/opt | `k`, `v`, `slot_mapping`, `kv_cache`:inout |
|
||||
| `rope` | `M`(range) `head_dim` `n_head` `n_head_kv` `theta`:f64 `scale`:f64 `mode` `rotary_dim`/opt `sections`/opt `yarn_factor`:f64/opt `yarn_low`:f64/opt `yarn_high`:f64/opt `yarn_magnitude`:f64/opt `ladder`/opt `llama3_factor`:f64/opt `llama3_low`:f64/opt `llama3_high`:f64/opt `llama3_orig`:f64/opt | `qkv`:inout, `positions` |
|
||||
| `rope_table` | `M`(range) `rot` `theta`:f64 `scale`:f64 `dtype` `yarn_factor`:f64/opt `yarn_low`:f64/opt `yarn_high`:f64/opt `yarn_magnitude`:f64/opt `head_dim`/opt `ladder`/opt | `positions` → `cos_sin` |
|
||||
@@ -867,6 +871,15 @@ verify, thousands in a prefill chunk, and libr4d has a different kernel for each
|
||||
`block_size` is read off the resolved kernel, not chosen: declare the group, declare the op, then
|
||||
ask `rad_kv_block_size()` (`spec.md` §7.2).
|
||||
|
||||
`prefill_fp8` is the set of products the caller accepts in e4m3 rather than exactly: 1 is
|
||||
Q·Kᵀ with the query rounded to e4m3 after the softmax scale, 2 is P·V with the probabilities rounded
|
||||
to e4m3, 3 is both, and absent is 0. It is a permission, like `all_reduce` with `exact` 0: libref
|
||||
and every exact kernel compute the exact form whatever it says, and a lossy kernel matches only the
|
||||
value it implements. libr4d has lossy rows for the h256/gqa6 prefill band over the fp8, fp8_v4
|
||||
and k6_v4 caches (`attn_prefill_h256_gqa6_fp8kv_qk8`, `_pv8`, `_qk8pv8`, and the same suffixes on
|
||||
`attn_prefill_h256_gqa6_fp8v4` and `attn_prefill_h256_gqa6_k6v4`); the engine states it from
|
||||
`--attn-prefill-fp8`.
|
||||
|
||||
`cu_seqlens` is optional and makes the batch ragged: `[n_seq+1]` i32, sequence `s` owning query rows
|
||||
`[cu[s], cu[s+1])` of the dense `q` and `out` blocks. Absent, every sequence has the same query
|
||||
length and the total query rows must be a multiple of `n_seq`. Pass it: the scheduler builds mixed
|
||||
@@ -912,6 +925,22 @@ softmax over the visible keys and the weighted sum of `v`, all in f32 and rounde
|
||||
reference computes this in 12-query blocks over 24-key windows with a Transformer-XL shift, giving
|
||||
every key outside the window a `-1e9` logit, so the sliding form is the same function.
|
||||
|
||||
**`sam_attn`** is Unlimited-OCR's DeepEncoder (SAM ViT-B/16) attention: windowed, with *decomposed*
|
||||
relative position. Each `cu_seqlens` segment is `grid_h * grid_w` rows in raster grid order (row
|
||||
`i_h * grid_w + i_w`). With `window > 0` the grid is padded to multiples of `window` with ZERO rows
|
||||
(deepencoder's `window_partition`, applied after `norm1`), cut into `window x window` tiles and each
|
||||
tile attends to all of its rows -- the pad rows are keys and values, so their logits (which carry the
|
||||
relative-position terms even though their `q` and `k` are zero) take part in the softmax and their
|
||||
`v` contributes nothing. `window` 0 is one tile over the whole segment (the global-attention layers).
|
||||
The logits are `scale * q.k + q.Rh[i_h, j_h] + q.Rw[i_w, j_w]`, each dot over the head's whole
|
||||
`head_dim`, with `i_h - j_h + L - 1` indexing `rel_pos_h` and `i_w - j_w + L - 1` indexing
|
||||
`rel_pos_w` (`L` the window, or the grid axis for a global layer); softmax in f32 with the max
|
||||
subtracted over the tile's keys, `out = sum p * v`, written back in segment row order with the pad
|
||||
rows dropped. The tables are `[2*L - 1, head_dim]` where `L = window`, or `max(grid_h, grid_w)` for
|
||||
a global layer; a geometry whose axes need a longer table has it resampled along dim 0 by
|
||||
`get_rel_pos`'s linear interpolation. `q`, `k` and `v` are the three column slices of one fused
|
||||
projection, so each may be a strided view of a `[M, 3 * n_head * head_dim]` buffer.
|
||||
|
||||
**`rope`'s multi-component modes.** `mrope`, `imrope` and `axial` rotate with NeoX pairing and let
|
||||
several position components drive different frequencies. `positions` is then `[C, M]`,
|
||||
component-major, and `sections` names how many of the `rotary_dim / 2` frequencies each component
|
||||
@@ -1251,14 +1280,16 @@ libref function says which (`libref/ref_audio.cpp`).
|
||||
|
||||
| op | params | operands |
|
||||
|---|---|---|
|
||||
| `conv1d` | `M`(range) `cin` `cout` `k` `dil` `act`/opt `dtype` `causal`/opt `stride`/opt `pad`/opt | `x`, `w`w, `cu_seqlens`, `res`? → `y`; `b`w? |
|
||||
| `conv1d` | `M`(range) `cin` `cout` `k` `dil` `act`/opt `dtype` `causal`/opt `stride`/opt `pad`/opt `cu_div`/opt | `x`, `w`w, `cu_seqlens`, `res`? → `y`; `b`w? |
|
||||
| `conv_t1d` | `M`(range) `cin` `cout` `stride` `dtype` `pad`/opt `k`/opt | `x`, `w`w, `b`w, `cu_seqlens` → `y` |
|
||||
| `snake` | `M`(range) `n` `dtype` `log`/opt | `x`, `alpha`w → `y`; `beta`w? |
|
||||
| `snake_aa` | `M`(range) `n` `ratio` `k` `log`/opt `dtype` | `x`, `alpha`w, `beta`w, `f_up`w, `f_down`w, `cu_seqlens` → `y` |
|
||||
| `cfg_topk_sample` | `M`(range) `n_vocab` `k` `rep` `cond_k`/opt `cfg`:f64 `temp`:f64/opt `stream` `dtype` `sup_lo`/opt `sup_hi`/opt `penalty`:f64/opt | `logits`, `seed`, `frame` → `ids`; `cfg`?, `lane`?, `hist`:inout? |
|
||||
| `rvq_embed` | `M`(range) `n_embd` `n_codes` `vocab` `off0` `scale`:f64 `dtype` `round`/opt | `codes`, `t0`w, `t1`w → `y` |
|
||||
| `cfg_topk_sample` | `M`(range) `n_vocab` `k` `rep` `cond_k`/opt `cfg`:f64 `temp`:f64/opt `stream` `dtype` `sup_lo`/opt `sup_hi`/opt `penalty`:f64/opt `top_p`:f64/opt | `logits`, `seed`, `frame` → `ids`; `cfg`?, `lane`?, `hist`:inout? |
|
||||
| `rvq_embed` | `M`(range) `n_embd` `n_codes` `vocab` `off0` `scale`:f64 `dtype` `round`/opt `clamp`/opt | `codes`, `t0`w, `t1`w → `y` |
|
||||
| `vq_encode` | `M`(range) `n` `dim` `bins` `dtype` | `x`:inout, `in_w`w, `in_b`w, `cb`w, `out_w`w, `out_b`w → `codes` |
|
||||
| `frame_mix_store` | `M`(range) `n_embd` `L` `stride` `rep`/opt `dtype` | `hid`, `logits`w, `scale`w, `lane`, `frame`, `status`, `dst`:inout |
|
||||
| `end_status` | `M`(range) `end` `rep` | `ids`, `lane`, `status`:inout |
|
||||
| `ras_pick` | `M`(range) `win` `lo` `hi` `rep`/opt `clear`/opt | `first`, `alt`, `lane`, `hist`:inout → `ids` |
|
||||
| `frame_store` | `M`(range) `n_codes` `stride` `rep`/opt `skip`/opt | `codes`, `lane`, `frame`, `status`, `dst`:inout |
|
||||
| `resample_nearest` | `M`(range) `n` `dtype` | `x` → `y` |
|
||||
| `fourier_embed` | `M`(range) `n` `round`/opt `dtype` | `t`, `w`w → `y` |
|
||||
@@ -1270,6 +1301,7 @@ libref function says which (`libref/ref_audio.cpp`).
|
||||
| `iota` | `M`(range) `start` `step` `period`/opt | → `y` |
|
||||
| `cu_repeat` | `M`(range) `mult` | `len` → `y` |
|
||||
| `int_affine` | `M`(range) `src` `mul` `add` | `x` → `y` |
|
||||
| `sub_i32` | `M`(range) | `x`, `s` → `y` |
|
||||
|
||||
**Frames.** A lane is one piece; a frame is one step of its language model, whose branches (the
|
||||
conditional first, then the unconditional) are consecutive rows, `rep` of them a lane.
|
||||
@@ -1282,14 +1314,34 @@ conditional first, then the unconditional) are consecutive rows, `rep` of them a
|
||||
`cond_k` > 0 only the entries where `c` reaches its `cond_k`-th largest value are. The `k`
|
||||
largest `g` (ties to the lower index) are kept, divided by `temp`, softmaxed in f32 and drawn by
|
||||
inverse CDF in descending `g`, `u = rad_philox_uniform_s(seed, 2^32 + frame, stream)`
|
||||
(`abi/rad_philox.h`); the pick goes to every one of the lane's `rep` slots. `logits`
|
||||
`[rep n, n_vocab]` f32 or bf16, `seed` `[n, 2]` u32 low word first, `frame` `[n]`.
|
||||
(`abi/rad_philox.h`); the pick goes to every one of the lane's `rep` slots. With `top_p` < 1
|
||||
(Fish Audio's draw) the kept list is cut first: over the softmax of every candidate's `g / temp`
|
||||
(its normaliser summed in index order), a kept rank whose inclusive cumulative probability in
|
||||
descending `g` exceeds `top_p` is dropped, rank 0 never, so the nucleus is taken over the whole
|
||||
distribution and the `k` cut applies after it. `logits` `[rep n, n_vocab]` f32 or bf16, `seed`
|
||||
`[n, 2]` u32 low word first, `frame` `[n]`.
|
||||
- `ras_pick`: Fish Audio's repetition-aware sampling, a choice between two draws of each lane:
|
||||
`ids[rep i] = alt[rep i]` when `first[rep i]` is in `[lo, hi)` and the lane's window holds it,
|
||||
else `first[rep i]`. The window `hist` `[lanes, win]` i32 is the lane's last `win` picks, oldest
|
||||
first, -1 empty (`clear` 1 empties it first, for a piece's first pick); the pick then enters it
|
||||
and the oldest leaves. A pick outside `[lo, hi)` (an end of speech) is never redrawn.
|
||||
- `end_status`: `status[lane[i]] = ids[rep i] == end ? -1 : ids[rep i]`.
|
||||
- `rvq_embed`: `codes` is code-major `[n_codes, rows]`, read at the operand's own strides (a block
|
||||
of a wider plane is a view);
|
||||
`y = bf16(bf16(t0[c_0 + off0] + bf16(sum_k t1[c_k + (k - 1) vocab])) * scale)`, or with `round` 1
|
||||
one f32 sum of every codebook's row in codebook order, times `scale`, rounded once to `y`'s dtype.
|
||||
A first code outside `t0` leaves its row unwritten; a later code outside `t1` adds nothing.
|
||||
With `clamp` n > 0 a code above `n - 1` reads row `n - 1` (before `off0` and the codebook's
|
||||
offset; a negative code still reads nothing): a codec whose codebooks are smaller than the heads
|
||||
that write its codes, as Fish Audio's 1024-entry residual codebooks under 4096-way heads.
|
||||
- `vq_encode`: one step of a residual vector quantiser with factorised, L2-normalised codes (DAC's,
|
||||
as Fish Audio's codec encodes a reference): per row of `x` `[rows, n]`, `e = in_w x + in_b`
|
||||
(`in_w` `[dim, n]`, a 1x1 convolution's weight); the code is the row of `cb` `[bins, dim]` of
|
||||
greatest cosine with `e`, `(e / max(|e|, 1e-12)) . (cb_c / max(|cb_c|, 1e-12))`, the lower index
|
||||
on a tie (0 when no score is above -inf), written to `codes[i]` at the operand's own stride; then
|
||||
`x -= out_w cb[code] + out_b` (`out_w` `[n, dim]`, the raw codebook row), rounded once into `x`.
|
||||
f32 arithmetic. A chain of these over a codec's codebooks, each quantising what the last left, is
|
||||
its residual quantiser.
|
||||
- `frame_store`: `dst[(lane n_codes + k) stride + frame - skip] = codes[k, rep i]` for every `k`,
|
||||
when `frame >= skip` and `status[lane] >= 0`: a frame's codes into its lane's history, each
|
||||
codebook a row over the lane's frames, so a run of a lane's frames is a block of `n_codes`
|
||||
@@ -1304,6 +1356,8 @@ conditional first, then the unconditional) are consecutive rows, `rep` of them a
|
||||
`y[j] = (src[j] < 0 ? 0 : x[src[j]]) mul[j] + add[j]` over three lists of integers of one length
|
||||
(`src` -1 a constant): the shapes and bounds a model derives from a pass's device geometry, such
|
||||
as a decoder's volume at each of its scales.
|
||||
- `sub_i32`: `y[i] = x[i] - s[0]`, int32: a device length less a device offset (a pipelined
|
||||
prefill's first piece takes its KV group's `seqused` less the second piece's rows).
|
||||
|
||||
**Windows.** The denoiser runs over windows of frames, each entry of a window step a lane's latent
|
||||
in a state buffer `stride` rows a lane (`lat_cu` bounds each entry's rows, `win_lane` names its
|
||||
@@ -1330,13 +1384,20 @@ input reads zero outside it.
|
||||
- `conv1d`: PyTorch's `[cout, cin, k]` weight, `k` odd, dilation `dil` and padding
|
||||
`dil (k - 1) / 2` a side, or with `causal` 1 (any `k`) `dil (k - 1)` on the left; `res` is added
|
||||
after the bias, then `act` `none`, `tanh` or `clamp`, `min(max(y, -1), 1)` (BigVGAN's output
|
||||
clamp; a NaN stays NaN). f32 accumulation, one rounding. With `stride` > 1 (bf16 rows only: the
|
||||
encoder's downsample) `pad` is required, `k` is any size, and the op is one sequence
|
||||
`cu_seqlens` = `[0, rows of x]`: output row `m` reads `x[m stride + tap dil - pad]` with zeros
|
||||
outside, PyTorch's zero-padded strided conv exactly (`k = 2 stride`, `pad = ceil(stride / 2)`
|
||||
gives `M / stride` rows), and `y` has
|
||||
`(rows + 2 pad - dil (k - 1) - 1) / stride + 1` rows exactly. An explicit `pad` without a
|
||||
stride, and an even `k` with neither, are refused.
|
||||
clamp; a NaN stays NaN). f32 accumulation, one rounding. A `stride` s > 1 comes in two forms.
|
||||
A causal one (the reach `dil (k - 1) + 1` at least s) pads `dil (k - 1) + 1 - s` on the left
|
||||
and keeps every s-th row: output row `o` of a sequence reads input rows `o s - pad + t dil`,
|
||||
and sequence `e`'s rows `[cu[e], cu[e+1])` become `[cu[e] / s, cu[e+1] / s)`, so every bound is
|
||||
a multiple of s; `res` and `y` have the output's rows (a causal codec encoder's downsampling,
|
||||
as Fish Audio's). `cu_div` reads the bounds in units that many input rows apart, as the other
|
||||
encoder ops do: sequence `e` is input rows `[cu[e] / cu_div, cu[e+1] / cu_div)`, each bound a
|
||||
multiple of `cu_div` times the stride, so one bounds array in samples serves every rate of an
|
||||
encoder. A non-causal one takes an explicit `pad` (bf16 rows only, the audio encoder's
|
||||
downsample): `k` is any size, the op is one sequence `cu_seqlens` = `[0, rows of x]`, output
|
||||
row `m` reads `x[m s + tap dil - pad]` with zeros outside, PyTorch's zero-padded strided conv
|
||||
exactly (`k = 2 s`, `pad = ceil(s / 2)` gives `M / s` rows), and `y` has
|
||||
`(rows + 2 pad - dil (k - 1) - 1) / s + 1` rows exactly. An explicit `pad` without a stride,
|
||||
and an even `k` with neither a causal nor a stride, are refused.
|
||||
- `conv_t1d`: PyTorch's `[cin, cout, k]` transposed weight, any `k` of at least a stride (two
|
||||
strides by default), padding `pad` (`(k - stride) / 2` by default, which needs `k - stride` even;
|
||||
0 is the causal form, whose full output's last `k - stride` rows are dropped; it may exceed a
|
||||
@@ -1685,7 +1746,6 @@ guidance and sampler in f32.
|
||||
| `d2s3d` | `M`(range) `C` `st` `sh` `sw` `drop`/opt `dtype` | `x`, `geom` → `y` |
|
||||
| `s2d3d` | `M`(range) `C` `st` `sh` `sw` `tpre`/opt `group`/opt `mode` `add`/opt `dtype` | `x`, `geom`, `y`:inout |
|
||||
| `pix_patch` | `M`(range) `p` `C` `order`/opt `dtype` | `x` → `y` |
|
||||
| `patch_pix8` | `M`(range) `p` `C` `order`/opt `dtype` | `x` → `y` |
|
||||
| `stft_logmel` | `M`(range) `hop` `nfft` `n_mel` `ch` `dtype` | `x`, `basis`w, `mel`w → `y` |
|
||||
| `bwe_up` | `M`(range) `ratio` `ch` `dtype` | `x`, `res` → `y` |
|
||||
| `vol_index` | `M`(range) | `geom` → `y` |
|
||||
@@ -1744,12 +1804,10 @@ stored (`rd`, the output's dtype unless said).
|
||||
frames prepended (frames `0 .. tpre - 1` again): `mode` copy writes the packed row, `mean`
|
||||
averages each run of `group` packed channels (f32 sum, divided, one rounding); with `add` 1
|
||||
`y = rd(y + v)`. `M` is x's rows.
|
||||
- `pix_patch` and `patch_pix8` are the patchifier both ways over dense 2-D operands whose shapes
|
||||
give the sizes: a `p x p` patch of `C` channels is one row of `C p p` values, channel `c`'s
|
||||
`(ph, pw)` at `c p p + pw p + ph` (`order` wh, LTX-2's) or `c p p + ph p + pw` (hw).
|
||||
`pix_patch` takes an image `[H, W C]` to `[H / p, (W / p) C p p]`; `patch_pix8` takes patch rows
|
||||
`[R, w C p p]` to RGB bytes `[R p, w p C]` by `to_rgba8`'s rule,
|
||||
`round(255 clamp(rd(rd(clamp(v, -1, 1) / 2) + 0.5), 0, 1))`, rd x's dtype.
|
||||
- `pix_patch` is the patchifier over dense 2-D operands whose shapes give the sizes: a `p x p`
|
||||
patch of `C` channels is one row of `C p p` values, channel `c`'s `(ph, pw)` at
|
||||
`c p p + pw p + ph` (`order` wh, LTX-2's) or `c p p + ph p + pw` (hw). It takes an image
|
||||
`[H, W C]` to `[H / p, (W / p) C p p]`.
|
||||
- `vol_index` writes a volume's voxel coordinates, the rotary positions of attention over it:
|
||||
`geom` = `(T, H, W)`, `y` i32 `[3, n]` component-major at its own row pitch, voxel
|
||||
`m = (t H + i) W + j`'s `(t, i, j)` at column `m`, for `m < min(n, T H W)`.
|
||||
@@ -1780,7 +1838,8 @@ stored (`rd`, the output's dtype unless said).
|
||||
`min(their extents, (tile - stride) scale p)` pixels, the neighbours read as their own blends
|
||||
left them (libref/ref_ltx.cpp writes the four-tile corner out), and a frame of a band within
|
||||
`min(their frames, (tile_t - stride_t) scale_t)` of its start is `blend_t` of the band before and
|
||||
this one; the byte is `patch_pix8`'s.
|
||||
this one; the byte is `to_rgba8`'s rule with rd `x`'s dtype,
|
||||
`round(255 clamp(rd(rd(clamp(v, -1, 1) / 2) + 0.5), 0, 1))`.
|
||||
- `stft_logmel` is each channel's causal log-mel spectrogram (the bandwidth extender's MelSTFT):
|
||||
`x [S, ch]`, `basis [2F, 1, nfft]` (the windowed DFT, real then imaginary rows,
|
||||
`F = nfft / 2 + 1`), `mel [n_mel, F]`; frame `t` reads samples `t hop + j - (nfft - hop)`, zero
|
||||
@@ -2244,8 +2303,9 @@ either way `x` is left unspecified. A row may always run the whole form, which k
|
||||
promise. The caller must not read a residual row it does not own after an `sp` 1 junction
|
||||
until a junction or reduction writes it whole again.
|
||||
|
||||
The norm-carrying forms are two-rank only. `ar_hc_write` and `ar_gather_hc_write` also have an
|
||||
exact-wire four-rank form. At other widths the arch blocks issue the plain ops.
|
||||
The norm-carrying forms are two-rank only, except `ar_rmsnorm_quant_i8`, which also has an
|
||||
exact-wire four-rank form (below), as `ar_hc_write` and `ar_gather_hc_write` do. At other widths
|
||||
the arch blocks issue the plain ops.
|
||||
|
||||
`ar_hc_write` is `all_reduce` of `y` followed by `hc_write` of the reduced `y`, for a block whose
|
||||
output feeds a gated residual rather than a norm; `y` is inout as `x` is above. It serves both
|
||||
@@ -2273,6 +2333,10 @@ message, with the junction as its tail -- one more block a row, which waits on a
|
||||
of the transport blocks (no cross-card handshake), acquires, and runs `rmsnorm_quant_i8`'s row at
|
||||
its own width. The bytes are the pair's; the launch the junction would take is saved.
|
||||
|
||||
`sp` is a four-rank form of the same row: libr4d serves it over P2P where the row has a residual
|
||||
and a post-norm, no `out_bf16`, and `n` of at most 8192 (the norm's register form), and runs the
|
||||
whole form elsewhere (the host mailbox included), which keeps every promise `sp` makes.
|
||||
|
||||
## Vocabulary edges
|
||||
|
||||
| op | params | operands |
|
||||
@@ -2548,6 +2612,33 @@ resolutions of one op. The one exception is `sample_chain` (below).
|
||||
| `sample_argmax` | `M`(range) `n_vocab` | `logits`, `params` → `token` |
|
||||
| `sample_merge_topk` | `M`(range) `n_cand` | `gathered`, `params` → `cand_idx`, `cand_val` |
|
||||
| `sample_logprobs` | `M`(range) `n_vocab` `k` `vocab_off`/opt | `logits`, `params` → `stats` |
|
||||
| `mtp_couple_propose` | `M`(range) `n_vocab` `round` `max_rounds` | `idx`:inout, `val`, `seq_ids`, `draw` → `state`:inout |
|
||||
| `mtp_couple_verify` | `M`(range) `n_cand` `n_vocab` | `cand_idx`, `cand_val`, `params`, `state` → `token`:inout |
|
||||
|
||||
`mtp_couple_propose` and `mtp_couple_verify` are the linear-MTP coupling (`--draft-coupling on`),
|
||||
and nothing else in the engine knows about coupling. Turning coupling on requires the
|
||||
linear serial draft chain: a block drafter (`RAD_DRAFT_BLOCK`) or no drafter at all is refused at
|
||||
bringup, because neither has a per-round draw to couple. The `spechub` plugin ships both rows and
|
||||
their host oracle in one library and marks them per row, so the device rows count as production
|
||||
kernels while the oracle stays reference; on a machine with no card only the oracle is left, and
|
||||
the gate refuses the coupling there. A `RADIANCE_KERNELS` list is exclusive:
|
||||
if it is set, it must name `spechub` or the coupled ops are not loaded at all.
|
||||
|
||||
`mtp_couple_propose` runs on a draft round's
|
||||
final reranked top-8 and samples the proposal `x ~ Q`, where `Q` is the FP64 softmax of those
|
||||
scores at temperature 1; it writes `x` into column 0 of `idx` and one state row per round. A row
|
||||
whose `seq_ids` does not name the card its draw was staged for, or whose shortlist is malformed,
|
||||
leaves column 0 alone with `status = -1`. `mtp_couple_verify` runs after `sample_pick`, over the same
|
||||
final candidate plane, and applies the maximal coupling: the draft is accepted when it equals the
|
||||
token the target itself drew at that position, and otherwise the token is a draw from the FP64
|
||||
residual `(P - Q)+`. Both use 53-bit uniforms at `params.pos`; a row whose state is not bound to
|
||||
that seed and position keeps the ordinary token. `P` is FP64-normalised where `sample_pick` is
|
||||
FP32/24-bit, so a coupled row realizes the ideal filtered target law and is **not** seed-identical
|
||||
to the ordinary pick.
|
||||
|
||||
`sample_temp` divides a row's logits by its `temp` and leaves a row whose `temp` is 0 or less, or
|
||||
exactly 1, as it is. The sampler relies on that: a step none of whose chain rows has another
|
||||
temperature does not issue the stage.
|
||||
|
||||
`sample_mask` is where a GBNF grammar lands: the state machine stays on the host, and what crosses
|
||||
is a token bitmask per sequence (~19 KB at a 151K vocab), cheap enough to upload every step. A set
|
||||
@@ -2574,10 +2665,18 @@ the usual rescale, pairs by value).
|
||||
| op | params | operands |
|
||||
|---|---|---|
|
||||
| `sample_dry` | `M` `n_vocab` `vocab_off`/opt | `logits`:inout, `params`, `history`, `breakers`? |
|
||||
| `sample_ngram_ban` | `M` `n_vocab` `vocab_off`/opt | `logits`:inout, `params`, `history`, `ngram`, `whitelist`? |
|
||||
| `sample_typical` | `M` `n_cand` | `cand_idx`:inout, `cand_val`:inout, `params` |
|
||||
| `sample_xtc` | `M` `n_cand` | `cand_idx`:inout, `cand_val`:inout, `params` |
|
||||
| `sample_chain` | `M` `n_vocab` `temp`:f64/opt `p`:f64/opt `min_p`:f64/opt `k`/opt | `logits`, `query`?, `u` → `draw` |
|
||||
|
||||
`sample_ngram_ban` is the windowed no-repeat-ngram ban (Unlimited-OCR's
|
||||
`SlidingWindowNoRepeatNgramProcessor`): every token that would complete an n-gram the last `window`
|
||||
tokens of the row's history already contain is set to -infinity. `ngram` is one i32
|
||||
`{n-gram length, window}` pair a row; the window bounds the n-gram's START index, so one that spans
|
||||
the window boundary is still searched. `window` <= 0 searches the whole staged history (the
|
||||
un-windowed processor) and `n` 0 turns the stage off, which is the default.
|
||||
|
||||
`sample_dry` is llama.cpp's DRY: it penalises, once, each token that would extend a repeated suffix
|
||||
of the history, by its longest such repeat. Sequence breakers are strings, so they are resolved
|
||||
against the vocabulary on the host: the row's `dry_rep_limit` carries the repeat limit the most
|
||||
@@ -2889,7 +2988,7 @@ contributes nothing, and a row with no visible key outputs zero. The softmax is
|
||||
rounded once. `scale` is positive and finite and comes from the original query/key head width,
|
||||
not the latent width (GLM: `1/sqrt(256)` against a latent of 512).
|
||||
|
||||
libr4d has two `mla_attn` rows, both at `latent_dim` 512, `block_size` 4 and up to 64 heads. The
|
||||
libr4d has three `mla_attn` rows, all at `latent_dim` 512, `block_size` 4 and up to 64 heads. The
|
||||
matrix row, `mla_attn_matrix_bf16`, ranks above the wave row and takes heads in multiples of 8: the
|
||||
heads are the WMMA tile's rows, so all of them share each latent load, and the probabilities enter
|
||||
it as bf16 high and low parts with f32 accumulation. At a multiple of 16 a tile holds 16 heads of
|
||||
@@ -2901,6 +3000,19 @@ by table position, with a second pass where the two differ. Other head counts ta
|
||||
workgroups and merge the f32 partials before narrowing, into the fixed scratch their hooks
|
||||
reserve; without scratch they compute unsplit.
|
||||
|
||||
At exactly 64 heads the rows row, `mla_attn_rows_bf16`, ranks above both. A workgroup takes one
|
||||
query row and all its heads, four waves to each group of sixteen, and loads each 16-token key chunk
|
||||
once for all of them, where the matrix row loads it once a tile of sixteen. The scores are
|
||||
`K Q^T`, tokens as the tile's rows and heads as its columns, so a head's running maximum and
|
||||
denominator stay in its lane; the four waves of a group each take a quarter of the latent's dot
|
||||
products and add the four partials in one order, and the probabilities reach the value product
|
||||
through a lane swap instead of LDS. The next chunk's keys are fetched while the current one is
|
||||
multiplied. A row's output does not depend on the other rows of the batch, so a run of rows gives
|
||||
the bytes the whole batch would. Under 32 rows (a decode step at one rank) too few workgroups fill the card, and its launcher
|
||||
runs the matrix row's kernel instead. It also takes multiples of 32 heads (two groups a
|
||||
workgroup), which no constraint routes to it. GLM-5.3 splits a prefill's MLA by rows under tensor
|
||||
parallelism, so each rank holds all 64 heads of its rows (ARCHITECTURES.md, `glm5next`).
|
||||
|
||||
`mla_project` moves a query into the latent and a latent result out of it, through the bf16
|
||||
weight `b` `[heads*2*head_dim, latent_dim]` that stores each head's key rows, then its value rows.
|
||||
`mode=absorb` multiplies `a` `[M, heads, head_dim]` by the head's key block as stored,
|
||||
|
||||
+37
-3
@@ -57,6 +57,7 @@ Five more exports are optional, each looked up by exactly this name:
|
||||
| `int rad_kernel_concurrent(int i)` | nonzero: kernel `i` touches nothing but its operands and scratch, so independent launches may overlap |
|
||||
| `int rad_kernel_collective(int i)` | nonzero: kernel `i` exchanges data with the other ranks' cards, so the engine keeps its own bulk link traffic away while it runs. 2: each launch ends that hold itself once the other ranks' bytes have landed, through the `link_gate` parameter (`rad_abi.h`). Without this export only the `all_reduce` op is a collective |
|
||||
| `int rad_plugin_reference(void)` | nonzero: a **reference implementation**, ranked below every unnamed library, refused for serving unless `--debug-accept-reference-kernels`, and what `rad-kbench` checks the others against. libref declares itself this way |
|
||||
| `int rad_kernel_reference(int i)` | per row: nonzero marks kernel `i` as a reference implementation and 0 as a production one, overriding `rad_plugin_reference` for that library. For a plugin that ships a device row and its host oracle side by side (`plugin/spechub`) |
|
||||
|
||||
---
|
||||
|
||||
@@ -361,10 +362,43 @@ says so with `RAD_ARCH_SERVES_IMPORTS(0)` (`qwen35_w8a8` does), and imports keep
|
||||
(`rad_op_resolved`) and is an error only if issued. The in-tree blocks do this for
|
||||
`qk_norm_rope_gate`.
|
||||
- **Read §8** if the model has a linear or recurrent block.
|
||||
- **Declare the second lane's window.** Work issued on the second lane (`rad_lane`,
|
||||
`abi/rad_runtime.h`) runs beside lane 0 in time, so every buffer it touches is named to
|
||||
`rad_buf_concurrent`, which keeps it live for the whole program: the planner cannot tell when
|
||||
lane 1 runs. An architecture whose lane-1 work lies in one stretch of its declared ops says so,
|
||||
calling `rad_lane1_window_begin(b)` before the first op of the stretch and
|
||||
`rad_lane1_window_end(b)` after the last, once each and in that order, at declare. A concurrent
|
||||
buffer is then live across the window and over its own declared uses only, so buffers used only
|
||||
outside the window (a drafter's, the heads') share its bytes again. What the plugin promises:
|
||||
it issues nothing on lane 1 outside the window. What the runtime does (`Ctx::issue`): an op
|
||||
issued on lane 1 outside the window fails the step, naming the window's op range and the op's
|
||||
position; an op issued on lane 0 outside the window, before or past it, joins lane 1 first when
|
||||
lane 1 has work pending, so the plugin need not join before the window ends; an op the core appends behind a
|
||||
declared one (runtime LoRA) counts at that op's position. The builder refuses a second `begin`,
|
||||
an `end` without a `begin`, twice or around no op, a `begin` never closed, and either call after
|
||||
declare. `qwen35_fp8` (with the plugins built from it) and `gemma3` declare one from the
|
||||
embedding's all-reduce to the final norm. On Qwen3.8-27B with its DFlash2 drafter at 64 sequences
|
||||
and speculation 7, on two R9700s, the activation arena went from 633.99 to 526.32 MiB a card, as
|
||||
without a second lane, and with the second lane's own scratch region
|
||||
([IMPLEMENTATION.md](IMPLEMENTATION.md)) the KV pool from 86 208 to 93 856 tokens.
|
||||
`tests/arch_test.cpp`'s builder applies the window to liveness as the core does, so the pinned
|
||||
graphs and steps are the ones the core plans; the runtime (`Ctx::issue`) is what refuses a lane-1
|
||||
op outside the window. Both calls are ABI 27 exports; a plugin that does not call them is
|
||||
unaffected.
|
||||
- **A block drafter may serve a shorter block.** `rad_drafter_short_block(b, block)`, called once
|
||||
after `rad_declare_drafter`, says the plugin declared its query pass at `block` rows a sequence as
|
||||
well as at `RadDrafterDecl::block`, with the same anchor convention, so the core may stage a step
|
||||
at either; the short block proposes `block - (RadDrafterDecl::block - depth)` tokens. The builder
|
||||
refuses it without a block drafter, at or above the drafter's own block, and where it would
|
||||
propose nothing. The engine runs it under `--draft-short-from` (GUIDE §4.6) and reads row `s` of
|
||||
the proposals at `s * proposal_pitch`; a block drafter's `proposal_pitch` defaults to its
|
||||
depth (a row holds the whole block's proposals and a short block fills its front) and is refused
|
||||
below it. The pass's block is `n_tok / n_seq`; a block the plugin has no ops for should fail the
|
||||
step (`rad_block_dflash2.h` does). Appended in ABI 27.
|
||||
- **Media preprocessing is the core's** (`core/mm`): resizing, patching, placeholder-token
|
||||
expansion and positions, in four processor families (Qwen-VL, Gemma 4, LFM2-VL, GLM-5.3) chosen
|
||||
by the container's `vision_config.model_type`. A vision model with another pipeline needs a core
|
||||
change.
|
||||
expansion and positions, in five processor families (Qwen-VL, Gemma 4, LFM2-VL, Unlimited-OCR,
|
||||
GLM-5.3) chosen by the container's `vision_config.model_type` (Unlimited-OCR's by its
|
||||
`model_type`). A vision model with another pipeline needs a core change.
|
||||
Audio goes through one of two feature extractors, Gemma 4's and Qwen3-ASR's (Whisper's), chosen
|
||||
by `audio_config.model_type`.
|
||||
- **A speech model says how it hears**, through the optional
|
||||
|
||||
+26
-4
@@ -18,7 +18,8 @@ live in `scripts/`:
|
||||
| [`scripts/`](#the-shell-harnesses) | bring a model up, measure it, assert on what comes back |
|
||||
|
||||
[`rad-avx-check`](#rad-avx-check), which checks a host kernel library against libref without a GPU,
|
||||
is built beside libavx rather than installed.
|
||||
is built beside libavx rather than installed, and [`r4d_selftest`](#r4d_selftest), libr4d's own
|
||||
check and kernel timer, into the build's `bin/`.
|
||||
|
||||
`rad-convert`, `rad-kbench` and `rad-tune` run the engine's startup with a different last step:
|
||||
the same plugins, in the same hierarchy, through the same declare phase, so they resolve kernels
|
||||
@@ -727,6 +728,28 @@ serves fails in either case: the selector would resolve to it and the step would
|
||||
|
||||
---
|
||||
|
||||
## r4d_selftest
|
||||
|
||||
```
|
||||
r4d_selftest <libr4d.so> [--case <row>]
|
||||
r4d_selftest <libr4d.so> --perf N K M [iters] (and the other --perf* modes in its usage text)
|
||||
```
|
||||
|
||||
With no mode it runs libr4d's catalogue and static checks, then each row's smoke and numeric cases
|
||||
in a child process of its own, the fusion claims compared byte for byte (ctest runs it as
|
||||
`r4d_selftest`, labels `slow`, `gpu`); `--case` runs one row in this process, as the reproducer.
|
||||
The `--perf*` modes time rows at one shape on a card. Two that cover the dense GEMMs:
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| `--perf N K M [iters]` | the fp8 decode GEMMs, and the fp8 head (`logits_gemm_fp8`) |
|
||||
| `--perfmxd N K M [iters]` | the dense OCP-MXFP4 rows (`gemm_mxfp4a8_gemv`, `_decode`, `_nt_m64`, `_tiled`) at one shape, with the weight bandwidth each reaches |
|
||||
|
||||
`--perfmx` is the MXFP4 expert GEMM (`M`, experts, `top_k`, skew), not the dense rows. `--cold MIB`
|
||||
times each launch alone behind a cache flush instead of back to back.
|
||||
|
||||
---
|
||||
|
||||
## rad-tokcheck
|
||||
|
||||
```
|
||||
@@ -794,9 +817,8 @@ The mode changes these settings itself:
|
||||
Everything else comes from the command line: run every candidate with the same flags, and the
|
||||
reference with the exact wire and a bf16 KV cache.
|
||||
|
||||
The control vector's switch is per request, and KLD mode serves none, so a deployment that has one
|
||||
loaded is scored with it **off**. `--control-vector on` starts the deployment default on, which is how
|
||||
the projection itself is scored (the switch still decides per request, and a request's false wins).
|
||||
A loaded control vector is applied at the deployment's default: `--control-vector on` scores every
|
||||
document with the projection, `--control-vector off` without it.
|
||||
|
||||
`--kld-out FILE` writes the report as JSON, and every position's KL, both NLLs and the argmax
|
||||
agreement to `FILE.rows` (`[positions, 4]` f32, reference row order), so two candidates can be
|
||||
|
||||
@@ -73,6 +73,11 @@ promotion truth; quick concurrency ladders within windows.
|
||||
4. ti8 **one-shot band** for 128 KiB–512 KiB lossy messages (currently every
|
||||
such message pays two-shot 1.5N + 2 syncs) — flagged upstream on #78.
|
||||
5. Draft-pass graph capture — only if low-concurrency latency ever matters.
|
||||
6. **The dense pipelined prefill at TP4** (`qwen35_fp8`, `qwen35_w8a8`, `gemma3`; GUIDE §4.5): a
|
||||
prefill step of one sequence in two pieces, every block boundary's all-reduce on the second lane
|
||||
at `overlap` 1, which at four ranks would take this table's `*_4rank_*_lane` rows (row 1). It
|
||||
runs at two ranks only; enabling it here (`g.world == 2` in both plugins' declare) needs a
|
||||
timing against the serial step at 18K-64K prompts and the chunk served.
|
||||
|
||||
## Interaction diagram
|
||||
|
||||
|
||||
Reference in new issue
Block a user