radiance 1.5.0

- Gemma 4 31B (PRs #74, #75, #81, #86; sfjes, keptn42): sliding and global attention with their
  own kernels, the assistant head as a drafter that reads the trunk's cache, the vision tower, a
  fused w4a8 decode step, bf16 and compressed-tensors int4 checkpoints, and window snapshots so a
  prefix hit on a sliding-window model resumes instead of prefilling again.
  deploy/compose/gemma4-31b-w4a8.yaml serves keptn42's container on two cards
- ParoQuant (PRs #65, #66, #67; malic): Qwen3.8-27B checkpoints with learned Givens rotations,
  as int4, int5 and MXFP4, imported without re-quantising, the prefill's rotations on the matrix
  cores. deploy/compose/qwen3.8-27b-paro.yaml serves them on one card. A ParoQuant container made
  with the PR builds is refused: convert it again with --reuse <old container>
- Gemma 4 26B-A4B with z-lab's DFlash drafter (PR #88; Perire): arch/gemma4 serves Google's bf16
  checkpoint with the routed experts in block fp8 or bf16 (data/recipes/gemma4-26b-a4b-df*.recipe),
  and libr4d gains its windowed paged attention, the fused sandwich-norm joins, expert_scale and
  the sharded draft head's pair_argmax. A prefill chunk runs as two slices with its all-reduces
  beside the compute, bit-exact with the whole step. The 31B's global layers take the windowed
  attention too: an 11.5K-token prefill on two R9700s in 3.1 s instead of 4.9
- a startup that logs nothing for two minutes says where it waits (#89): the system call (a KFD
  request by name), the library that made it, and its stack, which addr2line resolves against the
  binary
- the prefix cache is kept in VRAM and host memory only (#70): the disk tier wrote every block and
  snapshot a prompt produced, and its copies never outlived the process. --prefix-cache-host-mib
  is renamed --prefix-cache-mib; --prefix-cache-dir and --prefix-cache-disk-mib are removed, and
  startup refuses all three with what replaced them. The compose files no longer mount /data, and
  .env no longer needs RADIANCE_STATE
- --prefix-cache-ttl S (default 3600, 0 never): a conversation no request has used for that long
  leaves the cache, whichever tier holds it; radiance:prefix_cache_expired_total counts them. A
  full host tier now drops its least recently used conversations
- --vision-tower-placement vram|ram (#84): ram keeps an encoder tower in pinned host memory and
  gives its VRAM to the KV cache, read over the link once an image
- timings carry ttft_ms and total_ms (#85): the server's own time from the request body's arrival
  to the first and the last token, queueing and tokenisation included
- a KV-cache recall that found a moved expert with nowhere to go stopped halfway and leaked the
  slots it had already freed: after it every recall failed, the cache stayed short until a
  restart, and requests failed with HTTP 500. A recall now waits for the slots it is owed and
  always finishes
- a tool result or tool-call arguments that are not JSON are no longer refused as nesting past
  1024 levels for their unmatched brackets (#90): only text that parses as JSON is held to the
  bound, since nothing else is parsed into a tree
- the host-pool refusal names the limit that applies to pinned memory (RAM less 1/64 and
  1.5 GiB), not ttm.pages_limit
- --embedding-placement auto, removed in 1.3.0, is refused with what replaced it
- for out-of-tree kernel libraries: gemm_nt_q gains two operands (pb1, pb2, the part bounds), and
  the loader requires identical op schemas, so a library built against 1.4.0 must be rebuilt. For
  architecture plugins, rad_op_declared(b, op) asks whether an op is in the loaded vocabulary
  without declaring it
This commit is contained in:
Deadcode committed 2026-10-13 19:35:16 +02:00
commit b93b531f63
127 files changed
+9609 -4796

No files matched your search

+130 -1
View File
@@ -14,7 +14,8 @@ into the id an architecture plugin claims.
| `arch/qwen35moe_fp8` | `qwen35moe` | `fp8_e4m3` | `qwen35_fp8` with the feed-forward routed |
| `arch/qwen4exp_fp8` | `qwen4exp` | *(empty)* | Qwen4-Exp (Qwen3.8-Flash-Next), a bf16 checkpoint quantised at convert |
| `arch/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_bf16` | `i4` (group-128 codes, f16 scale) | Gemma 4 31B dense (text): two attention classes — sliding-window and proportional-RoPE global (`attention_k_eq_v`) — over one GemmaRMSNorm stream, GELU ffn, two KV groups, softcapped logits, tied scaled embedding; served from a CT-INT4 (QAT w4a16) checkpoint. Optional draft head: Google's assistant (`rad-convert --draft-model`), a serial head with no cache of its own (`rad_drafter_shared_kv`) |
| `arch/gemma4_bf16` | `gemma4` | `compressed-tensors` | Gemma 4 31B dense (text): two attention classes — sliding-window and proportional-RoPE global (`attention_k_eq_v`) — over one GemmaRMSNorm stream, GELU ffn, two KV groups, softcapped logits, tied scaled embedding; served from a CT-INT4 (QAT w4a16) checkpoint as group-128 int4 codes with an f16 scale. Optional draft head: Google's assistant (`rad-convert --draft-model`), a serial head with no cache of its own (`rad_drafter_shared_kv`) |
| `arch/gemma4` | `gemma4` | *(empty)* | Gemma 4 text from Google's bf16 checkpoint — the 26B-A4B MoE (a dense and a routed arm side by side) and the dense sizes without per-layer embeddings — with z-lab's DFlash drafter; routed experts bf16 or block fp8, as the recipe chose |
This document is the geometry of each, and the handful of readings that are **arithmetically
silent** — wrong in a way that produces fluent output and no error anywhere.
@@ -447,3 +448,131 @@ The traps:
is a real one; the processor stages exactly those plus zero frames to whole rows, which
reproduces every row the reference keeps.
---
# `gemma4` — Gemma 4 text, and its DFlash drafter
`arch/gemma4` serves a container converted from Google's bf16 checkpoint (`Gemma4ForConditionalGeneration`
or `Gemma4ForCausalLM`), the recipe choosing what is fp8: gemma-4-26B-A4B-it, and the dense sizes
without per-layer embeddings. The CT-INT4 31B release is `arch/gemma4_bf16`'s. A z-lab DFlash
drafter is merged at convert time (`--draft-model`); the recipes are
`data/recipes/gemma4-26b-a4b-df*.recipe`. The reference is transformers' `modeling_gemma4`.
```
gemma-4-26B-A4B-it
30 layers, hidden 2816, vocab 262144 tied to the embedding, rms_norm_eps 1e-6
layer_types: five sliding_attention then one full_attention, five times
sliding 16 heads / 8 kv x 256, rope theta 1e4 over the whole head, window 1024
full 16 heads / 2 kv x 512, PROPORTIONAL rope theta 1e6 over a quarter of it, K = V
attention scale 1: q and k RMS-normed per head with a gain, v with none
sandwich norms, plain gains (x_hat * w)
the feed-forward is two arms reading the same residual, summed:
dense pre_feedforward_layernorm -> gate|up 2112 (gelu-tanh) -> down -> post_feedforward_layernorm_1
routed router -> softmax -> top 8 of 128 -> renormalised -> * per_expert_scale[expert];
pre_feedforward_layernorm_2 -> 128 experts of 704 (gelu-tanh) -> post_feedforward_layernorm_2
sum -> post_feedforward_layernorm -> residual add
layer_scalar multiplies the residual stream at the end of every layer
embedding * sqrt(2816) as a bf16; final norm; tied head; final_logit_softcapping 30
DFlash a small Qwen3-shaped block drafter: an anchor and block - 1 mask tokens denoised in one
pass over the trunk's hidden states at target_layer_ids; drafts read off the TARGET's head
```
The readings that stay plausible when wrong:
- **Proportional rope is not a partial rotary.** The full layers rotate the first 64 frequency
pairs of the 512-wide head at theta^(-2j/512) — the exponent divides by the HEAD — with pair j
channels (j, j + 256), and leave the other 192 pairs at frequency zero. `rope` with
`rotary_dim` 128 pairs (j, j + 64) at theta^(-2j/128): a different function that still produces
fluent text. The plugin declares a full-width NeoX `rope` whose frequencies past pair 63 are
divided by 1e30 through the YaRN ramp `rope` already carries, a step at 63.5..64.
- **V on a full layer is the un-normed, un-rotated k projection**, RMS-normed with a unit gain, so
the value norm reads `k` before the key norm writes it.
- **The router does not read the feed-forward's input.** It reads the residual stream through a
gainless norm times its own `scale` vector times hidden^-0.5, while the experts read
pre_feedforward_layernorm_2's output. `per_expert_scale` multiplies the weight AFTER the
renormalised top-k.
- **The arms' two post-norms are per arm**, so under tensor parallel each arm's partial sum is
reduced before its norm. The partials share one [2T, hidden] buffer, dense rows first -- each
slice's own run of it when a prefill chunk is cut in two -- so one all-reduce carries both.
- **The embedding scale is sqrt(hidden) rounded to bf16**: 53.0, not 53.066. The drafter reads the
same scaled embedding.
- **The sliding layers' KV group is `RAD_KV_FULL`**, with the window on the attention op. A
`RAD_KV_WINDOW` group is not prefix-cached, so a hit on it reuses nothing and re-prefills; as
FULL the hit is kept. The planner gives every paged group the same block count, so the recycling
a window group would buy is worth nothing here.
- **The drafter's sliding layers are causal and its full layer is not**, and its logits' softcap
is ignored on purpose: a draft is an argmax and the cap is strictly increasing.
**Tensor parallel.** Heads split by rank, o and down by column with an all-reduce, the vocabulary
by row. The full layers' two KV heads are replicated past two ranks. Routed experts are
expert-parallel, 128 / world whole experts a rank, because a 704-wide expert has no block-aligned
width split; the router is replicated, so every rank agrees on the routing without a collective.
The drafter's head is vocab-sharded with the trunk's: each rank's top-2 are all-gathered and
`pair_argmax` picks the winner (two a rank, because a row-interleaved `all_gather` moves 16-byte
words and one pair is 8 bytes).
**The prefill overlap.** At more than one rank, a prefill chunk of two routed passes or more (4096
tokens, at the 2048-token pass) runs as two slices, and the trunk's all-reduces ride the runtime's
second lane beside the other slice's compute: slice A's attention reduction runs under slice B's
output projection, slice B's under slice A's two arms, and so on through the layer. Attention runs
whole, since it reads every row's keys. The cut is a whole number of routed passes and both slices
are above every row band the sliced kernels have, so the step issues the same kernels over the
same rows and its output is the whole step's, bit for bit. On 4x R9700 the reductions were 47% of
a 20K-token prefill under `--profile-ops`; a model of the measured times puts the overlap at up to
a quarter off an unprofiled prefill. The per-op profile syncs every op, so it cannot show it --
time a prefill without `--profile-ops`. A step that runs whole -- every decode and verify step --
takes the second lane for the dense arm instead, beside the routed arm, which needs nothing of it
until the feed-forward join: at decode the dense arm's GEMMs are a few rows, latency-bound and far
from the bandwidth the experts take, and its reductions stay on lane 0. On two R9700s the sliced
prefill gives the whole chunk's text and logprobs exactly, at 2048- and 8192-token chunks; the
startup notes say which form each step takes.
**The draft head in fp8.** The drafter's head is the widest read on the draft path: the target's
bf16 table, 352 MiB a rank at tp 4, every draft pass. A container converted with the line
`dflash.draft_head.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16` (the three `-df` recipes
carry it) stores a block-fp8 copy of the table under that name, and the head reads the copy at
fp8a8 instead -- half the bytes, for 176 MiB a rank more. Drafts are verified, so the coarser
logits can change what is proposed and never what is accepted; `draft_n_accepted` says whether
they propose worse. A container without the copy reads the bf16 table as before, and the startup
note names which head is in use.
**FP8 experts.** The experts are ~90% of the weight bytes, so each projection is served as the
container holds it, per layer: bf16 by `moe_gemm`, block fp8 by `moe_gemm_q`. gate_up `[1408, 2816]`
is whole 64-row tiles and 128-blocks. down `[2816, 704]` is not — the fp8 grouped GEMM reads K in
whole 128-column blocks — so it stays bf16 unless the checkpoint's experts were padded to 768 before
conversion (zero rows of gate and up, zero columns of down: exact). The fp8 tables are split by
expert parity, so a rank holds an even number of experts.
**Kernels.** libr4d serves all of the trunk's attention on its windowed kernels -- the sliding
layers (h256, gqa 2) and the full layers at gqa 8, 4 and 2 (one or two, four, eight ranks) --
plus `pair_argmax` and the fusions: the two sandwich-norm joins (`norm_add_norm`,
`join_add_scale`), `norm_add_norm_route` -- on a layer whose gate_up is block fp8, the attention
join writing the router's input and the experts' fp8 codes from the norm it already takes, in place
of an `rmsnorm` and an `rmsnorm_quant_fp8` -- `expert_scale`, and `attn_paged_qrow`, the sliding
layers' attention reading q where the fused qkv projection left it. The plugin declares each one's
unfused form where nothing serves it -- the rmsnorm / add chain, `embed_lookup` + `mul`, a `cast`
lifting q for `attn_paged` -- and the startup notes say which were taken. libref and libavx do not
declare these ops, so the plugin asks whether one is declared before it asks for it
(`rad_op_declared`), and a deployment without libr4d's device rows -- a CPU-only build, the host
backend -- runs the chains. On a card the fused joins and libr4d's chain differ by the order of
the chain's reductions, not bit for bit: the joins round as the host chain does (tests/r4d_emu).
The drafter's residual add, norm and fp8 quantiser of x are one libr4d `rmsnorm_quant_fp8` launch
an input (ten a draft pass), and the `add` / `rmsnorm` / `quant_act_fp8` chain where nothing serves
it. The sliding layers' attention stays on the windowed kernel because only it reads q in place:
plain `attn_paged` at h256/gqa2 -- the dense 31B's sliding layers -- takes libr4d's h256/gqa2
leg, which rad-kbench times at 0.26-0.71 of the windowed kernel at decode and 0.43-0.67 at
prefill. A drafter head sharded over more than one rank needs `pair_argmax` on the card.
**A drafter that is not working still writes fluent text.** Every draft is verified, so a broken
drafter costs speed and nothing else: judge it by `draft_n_accepted` (about a third of `draft_n` on
prose, at about two tokens a step), not by the reply. The trap that showed it: the buffer planner
takes liveness from DECLARATION order, so the tap copy into `dflash_src` is declared at the end of
the layer it taps, where it is issued. Declared once after the trunk, it let the planner share
`dflash_src` with `moe_edn`, which every MoE layer writes, whenever the sizes allowed it
(`--max-num-seqs 16` did): 2% acceptance, slower than no speculation, and nothing in the text to
say so. arch_test holds the two live ranges to overlap.
**Not declared.** The vision tower (`arch/embgemma2` declares Gemma 4's, for an encoder): a container
that carries one is served with `--mm-max-patches 0`. An fp8 attention or dense arm — under a tenth
of the weight bytes, and the dense arm's 2112 is not whole 128-blocks either.
+6 -5
View File
@@ -128,16 +128,18 @@ the cards the engine runs on.
| `qwen3.6-35b-a3b.yaml` | `qwen3.6-35b-a3b-fp8.rad` | Qwen3.6-35B-A3B, FP8 |
| `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; the int5 and MXFP4 containers serve from it too |
| `qwen3.8-27b-bf16.yaml` | `qwen3.8-27b-bf16.rad` | Qwen3.8-27B in bf16 |
| `gemma4-31b-w4a8.yaml` | `gemma4-31b-w4a8.rad` | Gemma 4 31B, int4 trunk with int8 activations, its assistant head as the MTP drafter, vision tower |
| `minicpm5-2b.yaml` | `minicpm5-2b-fp8.rad` | MiniCPM5-2B FP8 with its DSpark drafter |
| `minicpm5-2b-bf16.yaml` | `minicpm5-2b-bf16.rad` | MiniCPM5-2B in bf16 with its DSpark drafter |
| `embeddinggemma2.yaml` | `embeddinggemma2-bf16.rad` | EmbeddingGemma 2 in bf16: text, image, video and audio embeddings on one card |
The container names are the files the README's model table downloads or converts.
Copy the directory to the serving host and fill in `.env` from `.env.example`. It sets the image,
the models directory (mounted read-only at `/models`), a writable state directory (`/data`, where
the prefix cache's disk tier lives), the API key, the port, and the user and GPU groups the server
runs as. The models directory has to be on a local filesystem that does direct I/O, such as ext4,
the models directory (mounted read-only at `/models`), the API key, the port, and the user and GPU
groups the server runs as. The models directory has to be on a local filesystem that does direct I/O, such as ext4,
XFS or btrfs: Qwen3.8-Flash-Next reads its n-gram table from the container that way. On btrfs with
compression on, the extents it stored compressed are read through the page cache instead, which
works but loses what the direct reads are for; a container copied into a directory set `chattr +C`
@@ -150,6 +152,5 @@ docker compose -f flashnext.yaml down # stop
```
Each model takes both cards and the same port, so run one at a time: `down` one before `up` on
another. The server runs as the host user given in `.env`, so the files it writes under `/data`
belong to that user. `/health`, `/ping` and the dashboard page answer without the API key, and the
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`.
+46 -24
View File
@@ -335,6 +335,11 @@ rad-convert ~/models/ukisai/Swift-1.5-Qwen3.8-27b -o swift-27b-fp8.rad \
--draft-model ~/models/z-lab/Qwen3.8-27B-DFlash2 --recipe data/recipes/q38-27b-fp8block-df2.recipe \
--set quantization_config.quant_method=fp8 --set quantization_config.fmt=e4m3 \
--set "quantization_config.weight_block_size=128 128" --set quantization_config.activation_scheme=dynamic
# gemma-4-26B-A4B-it with z-lab's DFlash drafter, the routed experts' gate_up as block fp8 (served by
# arch/gemma4; docs/ARCHITECTURES.md says why down stays bf16 unless the experts were padded to 768)
rad-convert ~/models/google/gemma-4-26B-A4B-it -o gemma4-26b-a4b-df.rad \
--draft-model ~/models/z-lab/gemma-4-26B-A4B-it-DFlash --recipe data/recipes/gemma4-26b-a4b-df.recipe
```
A checkpoint directory's `model.safetensors.index.json` decides which shard each tensor is read
@@ -574,6 +579,7 @@ Related flags:
--host-pool-mib 8192 # pinned host tier for weights
--embedding-placement vram # keep the token embedding on the card (below)
--ngram-placement ram # an n-gram table in RAM instead of read from disk (below)
--vision-tower-placement ram # the encoder towers in host memory, their VRAM to the KV cache (below)
--weights-disk-tier # stream what fits neither from the container; needs O_DIRECT
```
@@ -605,6 +611,21 @@ container cannot write them.
radiance --model m.rad --tp 2 --embedding-placement vram # the table on the cards
```
**The encoder towers** -- a vision tower, and an audio encoder where a model has one -- are read
once an image, a clip or a recording, never on a text step. On the card (`vram`, the default) they
are weights like any other and the KV pool is carved from what is left: Qwen3.8-27B's vision tower
is 0.86 GiB a card, about 24,000 tokens of fp8 context. `--vision-tower-placement ram` pins them in
host memory of their own, every rank a whole tower, on top of `--host-pool-mib`, and their kernels
read the weights over the link in place: that VRAM goes to the KV cache, and every image costs one
read of the tower over the link (about 55 ms for 0.86 GiB on PCIe 4.0 x16). Text-only requests do
not touch it. A tower is every weight the model's architecture declares read once per request.
`ram` is refused, naming the reason, where the model has no tower, where `--mm-max-patches 0`
declared none, or where the host cannot pin it.
```sh
radiance --model qwen3.8-27b-fp8.rad --tp 1 --vision-tower-placement ram
```
**An n-gram table** (Qwen3.8-Flash-Next's is 47.7 GiB) is read a few rows a token, which is why it
can live off the card at all. `disk` reads its rows from the container through a row cache and
direct reads on the host; about half of a step's rows are first-seen, so steps wait on the drive.
@@ -925,26 +946,25 @@ serve. A conversation that comes back before that resumes from VRAM; one that co
restored from host memory and keeps its host copy, so its next turn copies only what that turn
added. There is no idle threshold on the way out of VRAM.
With a disk tier the same happens one level down: every host copy is written on to disk in the
background and keeps its host slot, and once the write has landed the slot can be given up for
nothing. A full host tier gives up its oldest slots when a new copy or a restore needs one, so a
conversation that no longer fits in host memory is on disk already rather than lost.
A full host tier drops its least recently used conversations to make room. Nothing is written to a
drive: the prefix cache lives in VRAM and host memory only.
**Every stored conversation expires.** One that no request has used for `--prefix-cache-ttl`
seconds (an hour by default) is taken out of whichever tier holds it — its VRAM blocks go back to
the pool, its host slot back to the arena, its snapshots back to the store. It is not moved
anywhere first. A conversation in use stays: a hit or a new turn counts as a use, and a system
prompt that several conversations share stays for as long as any of them is used.
```sh
radiance --model m.rad \
--prefix-cache-host-mib 8192 \
--prefix-cache-disk-mib 65536 --prefix-cache-dir /var/cache/radiance
radiance --model m.rad --prefix-cache-mib 8192 --prefix-cache-ttl 3600
```
- `--prefix-cache-host-mib N` — **this is the switch.** Without a size, nothing is copied. It holds
- `--prefix-cache-mib N` — **this is the switch.** Without a size, nothing is copied. It holds
attention blocks only; a hybrid model's linear-state snapshots are in host memory already, in the
`--checkpoint-slots` store. Size it for the conversations you expect to come back: one that does
not fit comes back from disk instead.
- `--prefix-cache-disk-mib N` — the disk tier's size. Everything that reaches host memory is
written here too, snapshots included, so a full snapshot store detaches its least recently used
snapshot instead of losing it.
- `--prefix-cache-dir DIR` — where the disk tier lives. **Not `--weights-disk-tier`**, which is about
*weights*. The disk tier holds conversation content unencrypted.
not fit is prefilled again.
- `--prefix-cache-ttl S` — seconds an unused conversation is kept (default 3600). `0` keeps
everything until the memory is wanted.
- Recovering a 200K-token turn costs a copy over PCIe; recomputing it costs minutes.
On a hybrid model the recurrent state matters as much as the attention blocks — restoring the
@@ -1092,15 +1112,15 @@ one line naming each one the command line moved.
| `--host-pool-mib N` | 0 | pinned host tier (weights) |
| `--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. See §4.3 |
| `--ngram-placement WHERE` | auto | `auto`, `vram`, `ram` or `disk`: an n-gram table on the card, as a copy in RAM made at load and read by the card, or read from the container. See §4.3 |
| `--vision-tower-placement WHERE` | vram | `vram` or `ram`: the encoder towers (vision, and audio where a model has one) on the card, or pinned in host memory beside `--host-pool-mib` and read in place once an image. See §4.3 |
| `--weights-disk-tier` | off | read weights that fit neither VRAM nor the host pool from the container (O_DIRECT); routed experts a layer at a time |
**Idle session tiers**
| flag | default | |
|---|---|---|
| `--prefix-cache-host-mib N` | 0 (off) | copy finished conversations' KV to host memory |
| `--prefix-cache-disk-mib N` | 0 (off) | and copy them on to disk |
| `--prefix-cache-dir DIR` | — | where the disk tier keeps them |
| `--prefix-cache-mib N` | 0 (off) | copy finished conversations' KV to host memory |
| `--prefix-cache-ttl S` | 3600 | seconds an unused conversation is kept, in VRAM or host memory; `0` never expires |
**Placement and state**
@@ -1109,7 +1129,7 @@ one line naming each one the command line moved.
| `--placement MODE` | auto | `all_vram`, `layer_offload`, `expert_tiered`, `auto` |
| `--deterministic` | off | pin placement to the loader's plan, so the resident set cannot change under the heat engine |
| `--checkpoint-interval N` | 2048 | linear-attention state checkpoint interval, in tokens |
| `--checkpoint-slots N` | 8 | linear-state (hybrid) or sliding-window snapshots the server may hold at once, **in total**, not per sequence. They live in pinned host memory, not VRAM: one slot is a snapshot of every rank's shard (113 MB on Flash-Next at `--tp 2`; on Gemma 4 31B the 1024-token window of every sliding layer, 406 MiB at `--tp 2`), allocated at startup. A snapshot is copied off the card after the step that produced it and back before the step that resumes from it. With a disk tier a full store detaches its least recently used snapshot to disk instead of losing it |
| `--checkpoint-slots N` | 8 | linear-state (hybrid) or sliding-window snapshots the server may hold at once, **in total**, not per sequence. They live in pinned host memory, not VRAM: one slot is a snapshot of every rank's shard (113 MB on Flash-Next at `--tp 2`; on Gemma 4 31B the 1024-token window of every sliding layer, 406 MiB at `--tp 2`), allocated at startup. A snapshot is copied off the card after the step that produced it and back before the step that resumes from it. A full store retires its least recently used snapshot |
| `--checkpoint-policy NAME` | geometric-backoff | also `tip-only`, `keep-all` |
| `--no-prefix-cache` | — | disable prefix caching |
@@ -1617,7 +1637,8 @@ view, for one) reads it unchanged:
"prompt_per_token_ms": 4.0, "prompt_per_second": 250.0,
"predicted_n": 64, "predicted_ms": 711.0,
"predicted_per_token_ms": 11.29, "predicted_per_second": 88.6,
"draft_n": 78, "draft_n_accepted": 37
"draft_n": 78, "draft_n_accepted": 37,
"ttft_ms": 297.5, "total_ms": 1008.5
}
```
@@ -1631,6 +1652,8 @@ view, for one) reads it unchanged:
| `predicted_ms` | from the first generated token to the last |
| `predicted_per_second`, `predicted_per_token_ms` | the `predicted_n − 1` tokens after the first, over `predicted_ms`. The first token is the prefill's product. It is the same figure as `/metrics`' time per output token, and with speculative decoding it counts every token a step accepts |
| `draft_n`, `draft_n_accepted` | speculative tokens proposed for this request and how many were accepted. Present when any were proposed, as llama.cpp does |
| `ttft_ms` | the server's time to first token: from the moment it had the whole request body to the first generated token. It holds parsing the request, rendering the chat template, tokenising, the wait for admission and the prefill. The time the body took to reach the server is not in it, so a client on a slow link can tell the server's share of the time it measured from the network's. Not a llama.cpp field |
| `total_ms` | from the same moment to the last generated token: `ttft_ms + predicted_ms`. Not a llama.cpp field |
Milliseconds are wall-clock milliseconds, and the rates are tokens per second. A rate whose count
or time is zero is `null`. A request with several choices (`n`, or a batch of prompts) sums the
@@ -1825,6 +1848,7 @@ lists the efforts the chat template takes, or is `null` when it takes any. `serv
| `attn_cached_tokens_total`, `linear_cached_tokens_total` | prefix reuse, both halves |
| `linear_checkpoints_written_total`, `linear_prefix_cache_hit_rate` | |
| `prefix_cache_evictions_total`, `prefix_cache_ckpt_evictions_total` | |
| `prefix_cache_expired_total`, `prefix_cache_ckpt_expired_total` | what `--prefix-cache-ttl` took (§4.8) |
| `num_requests_preempted` | |
| `http_queue_depth`, `http_responses_total`, `http_admission_rejected_total` | |
| `client_disconnect_total`, `stream_overflow_total` | |
@@ -1892,8 +1916,6 @@ TLS-terminating reverse proxy in front:
radiance --model m.rad --host 127.0.0.1 --port 8000 --api-key "$KEY"
```
Also note `--prefix-cache-disk-mib` writes **conversation content unencrypted** under `--prefix-cache-dir`.
### 6.7 Restarting and stopping
Nothing here is a daemon; run it under systemd, a supervisor or `nohup`. `scripts/fnstop.sh` stops
@@ -1935,7 +1957,7 @@ of a log to paste into an issue.
fix. Every warning is also printed as a `W` line of its own.
```
I STARTUP REPORT -- radiance 1.4.0
I STARTUP REPORT -- radiance 1.5.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]
@@ -1976,9 +1998,9 @@ curl -s -H "Authorization: Bearer $KEY" localhost:8000/diagnostics | jq '.findin
| `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 do without: a larger `--host-pool-mib` (RAM permitting), `--kv-cache-dtype fp8`, or fewer/shorter sessions. See §4.3 |
| The server dies with no log line, on a request it had been serving fine | A kernel whose code object had never been loaded could not be: the card has no room left. HIP faults inside the launch rather than returning an error, so there is nothing to print | A card left with too little room for a first launch — see §4.3. Set `--gpu-headroom-mib` to the value the startup warning names. `coredumpctl info` names the kernel; `AMD_LOG_LEVEL=1` prints `HSA_STATUS_ERROR_OUT_OF_RESOURCES` just above the fault |
| KV in VRAM stays high with one session and nothing moves | The idle tiers are **off** — they are sized, and with no size nothing is copied | Pass `--prefix-cache-host-mib N` |
| KV in VRAM stays high with one session and nothing moves | The idle tiers are **off** — they are sized, and with no size nothing is copied | Pass `--prefix-cache-mib N` |
| `out of memory` / `the carve reserved N of address space and the card would not back it` | Something else is holding VRAM | Check with `rocm-smi`; stop the other process. The budget is stated before allocation, so the log says what it asked for |
| `pool allocation refused` with `backing allocation of … refused` on the second card, after the first card's pools succeeded | The VRAM budget is measured before any rank allocates. A card that refuses its weights pool lost that memory to another process in between (the line below the refusal says how much is free now). A refused `host_pool` is pinned memory: **every rank pins its own `--host-pool-mib`**, so `--tp 2` pins it twice, and the amdgpu driver caps pinned memory system-wide at `ttm.pages_limit`, half of RAM by default | Stop the other process (`rocm-smi --showpids`). For the host pool, keep `--tp` × `--host-pool-mib` under the cap the refusal names, or raise it with the kernel parameter `ttm.pages_limit` |
| `pool allocation refused` with `backing allocation of … refused` on the second card, after the first card's pools succeeded | The VRAM budget is measured before any rank allocates. A card that refuses its weights pool lost that memory to another process in between (the line below the refusal says how much is free now). A refused `host_pool` is pinned memory: **every rank pins its own `--host-pool-mib`**, so `--tp 2` pins it twice, and the amdgpu driver caps what every process together pins at RAM less 1/64 and 1.5 GiB. The pool is locked user memory, which `ttm.pages_limit` does not count | Stop the other process (`rocm-smi --showpids`). For the host pool, keep `--tp` × `--host-pool-mib` under both the cap and the available RAM the refusal names. `amdgpu.no_system_mem_limit=1` lifts the driver's cap, but not the RAM |
| `host_pool: backing allocation of … refused: rad_dev_alloc(…): locking piece K of N`, and `failed to pin userptr` in `journalctl -k` | The IOMMU would not DMA-map one piece of the pinned host pool. Pinned host memory is locked in pieces of at most 1 GiB because an Intel VT-d host in scalable mode was seen to refuse any single pin above about 2.5 GiB; a piece failing means this machine refuses smaller pins still, or a total its IOMMU will not map | Keep IOMMU translation on: `iommu=pt` lets every pin through but on that host also removed peer access between the cards, which moves every all-reduce onto the slower host-memory path. Report the kernel version, the IOMMU mode and the refusal line |
| `a synchronisation has waited 5 s` naming a kernel, then `no queue has advanced`, then `HW Exception … GPU Hang` and a reset in `journalctl -k` (`MES failed to respond to msg=REMOVE_QUEUE`, `MODE1 reset`) | The card stopped running the queue. The kernel named is where it stopped, not necessarily why. The driver resets the whole card, VRAM included, and the engine is aborted. The usual cause is compute wave save/restore being off: the driver evicts a process's queues whenever host memory the card maps is moved under memory pressure, and with `cwsr_enable=0` it cannot preempt a running queue, so the eviction waits for a queue a serve never lets drain. A voltage offset or other clock instability is the other cause seen on R9700s. If the stall line says the queues **advanced**, the wait was long rather than stuck, and nothing is wrong | `cat /sys/module/amdgpu/parameters/cwsr_enable` must print `1` (the startup report warns when it is `0`); set `amdgpu.cwsr_enable=1`, rebuild the initramfs and reboot. Remove any `OD_VDDGFX_OFFSET` (`pp_od_clk_voltage`). A reset puts the power cap, fan curve and voltage offset back to firmware defaults, so re-apply them before every start rather than once at boot. Keep the devcoredump under `/sys/class/drm/card*/device/devcoredump/data`; a reboot loses it. `docker inspect` shows exit code 0 for a container Docker has already restarted, which says nothing about how the old process ended |
| `--draft-model is not implemented` | This engine loads its drafter from the container | `rad-convert --draft-model DIR` at conversion time |
+63
View File
@@ -298,6 +298,60 @@ rounding.
-log(max_timescale) / max(n/2 - 1, 1))`, each step in f32 as the reference's torch expressions
are, then rounded.
### Gemma 4's fusions: the sandwich-norm joins, `expert_scale`, `attn_paged_qrow` — no reference row
| op | params | operands |
|---|---|---|
| `norm_add_norm` | `M`(range) `n` `eps`:f64 `dtype` | `a`, `w_a`w, `x`:inout, `w_y`w → `y` |
| `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` |
Gemma's sandwich norms, each one kernel in place of a chain of `rmsnorm`, `add` and `mul_weight`.
`norm_add_norm` is `t = rmsnorm(a) * w_a; x += t; y = rmsnorm(x) * w_y` -- a post-norm, the
residual add, the next pre-norm. `join_add_scale` is `x = (x + rmsnorm(rmsnorm(d) * w_d +
rmsnorm(r) * w_r) * w_j) * s` -- two arms' post-norms, their sum, its norm, the residual add and a
one-element layer scalar (Gemma 4's MoE feed-forward) -- and, given `w_n` and `y` (both or
neither), `y = rmsnorm(x) * w_n` over the `x` it writes: the next layer's input norm, or the final
norm after the last layer, which would otherwise be a launch of its own reading that `x` back.
Every value the chain stores is rounded to the activation dtype at the same point, so the two
differ from the chain only in the order a sum of squares is added in: with the same order they are
bit-identical to it, and against a chain summed in another block width a norm factor can differ in
its last bit.
`norm_add_norm_route` is `norm_add_norm` and, from the same norm of the `x` it writes, a MoE
layer's two routed inputs: `r = rmsnorm(x) * w_r * mult` -- `rmsnorm`'s expression with `mult` --
and `q`, `qs` = `rmsnorm_quant_fp8` of `x` under `w_e`: E4M3 codes of the bf16-rounded norm, an
f32 scale per (row, `group` columns) of `amax / 448` (1 for an all-zero group), the value over it
clamped to +-448. `n` is whole groups and `group` 128. In Gemma 4 it replaces the router's
`rmsnorm` and the experts' `rmsnorm_quant_fp8`, two launches a layer that read back the `x` the
join had just written.
`expert_scale` is `ew[t, k] = ew[t, k] * w_e[ids[t, k]]` over `[M, top_k]`, `w_e` an `[n_expert]`
table and an id outside it reading 0: Gemma 4's per_expert_scale on the renormalised routing
weights, in place of an `embed_lookup` of the table by the ids and a `mul` into the weights. One
product rounded once, so the pair's value bit for bit.
`attn_paged_qrow` is `attn_paged` -- the same parameters, operands and values -- with `q` read at
its own row pitch: a column slice of a wider row, the q part of a fused `[q|k|v]` projection, read
where it lies instead of lifted into a dense block by a `cast` first. It is a name of its own
because an `attn_paged` kernel may refuse a pitched `q` (libr4d's other attention kernels do, with
`RAD_E_STRIDE`, at the first step), and under `attn_paged` whichever library is first in `--kernels` wins the op: an
architecture handing it the slice would depend on an order it cannot see. Asked for by name, the op
resolves to a library that reads the pitch or to nothing, and the architecture lifts `q` for
`attn_paged` where it is nothing.
**libref has no row for any of them, on purpose.** An architecture asks for a join and declares the
chain where it does not resolve (`rad_op_resolved`), and a reference row would resolve it
everywhere -- so a model loaded without the library that serves the join would resolve it to the
reference and be refused at serve, instead of running the chain on libr4d or libavx. libr4d
declares them, with device rows only, so the host backend runs the chains too. With no oracle, its
kernels are held to a chain summed in their own block order, bit for bit, by `tests/r4d_emu`. No row
declares `replaces`: rad-kbench's fusion oracle runs the replaced chain out of the fusing library's
own rows and compares bytes, and libr4d's `rmsnorm` adds its sums of squares in another block
order, which can move a norm factor's last bit.
## Quantisation and rotation
| op | params | operands |
@@ -652,6 +706,7 @@ and adding 0.0f is exact, so a block sum over 8 wave partials and over 32 are th
| `moe_gather` | `M`(range) `n` `top_k` `dtype` `act`:str/opt | `y_expert`, `expert_w`, `sorted_tok`, `shared`?, `shared_gate`? → `y` |
| `row_topk` | `M`(range) `N` `R` `vocab_off`/opt `dtype` | `x` → `idx`, `val`, `pairs`? |
| `row_topk_merge` | `M` `R` `world_size` `dtype` | `gathered` → `idx`, `val` |
| `pair_argmax` | `M`(range) `n` `dtype` | `pairs` → `idx`, `val`? |
| `logit_rerank` | `M`(range) `R` `n_vocab` `n_embd` `vocab_off`/opt `dtype` | `x`, `head`w, `idx_in` → `idx`, `val`, `pairs`? |
`row_topk` and `row_topk_merge` are a pair, and the second only means anything with the first's
@@ -667,6 +722,14 @@ over the unsharded plane element for element. A slot a shard could not fill carr
`pairs` and is dropped -- a sentinel rather than a -inf value, because a masked logit takes that
value legitimately.
`pair_argmax` is the merge at R = 1, for a vocab-sharded draft head that wants each position's
winner as a proposal: `idx` gets the id of the largest value among a row's `n` gathered pairs,
ties to the lower id, a negative id skipped, -1 (and -inf in `val`) when nothing is valid --
written one element a row at the output's own pitch, which is what a block drafter's contiguous
proposal needs. It is not `row_topk_merge` with R = 1 because a rank still sends R >= 2 pairs: a
row-interleaved `all_gather` moves whole 16-byte words and one pair is 8 bytes, so `n` is
`world_size * R` and the op takes the top-1 of all of them.
`logit_rerank` is the second half of a COARSE top-R. A speculative step can afford a cheap draft
head -- the target verifies every proposal, so a worse draft costs acceptance and never a token --
but a head quantised hard enough to be cheap also picks a different top-1 often enough to matter.
+2 -3
View File
@@ -547,7 +547,7 @@ need nothing but `curl` and `jq`. Scripts resolve each other by `$(dirname "$0")
it is on. `oracle.sh` starts its own server and stops whatever listens on its port (`P`, default
8302). Everything else — `cstep2.sh`, `ident.sh`, `tierident.sh`, `tiercross.sh`, `mctools.sh`,
`mcstream.sh`, `hfget.sh`, `convfn.sh`, `convdspark.sh`, `fnpf.sh`, `fnconc.sh`, `fndrop.sh`,
`apikeys.sh`, `diskstall.py`, `cardclock.py` — leaves a live serve alone.
`apikeys.sh`, `cardclock.py` — leaves a live serve alone.
`fndrop.sh` is the one to read the description of first: it leaves the PROCESS alone and
deliberately disconnects clients from it, which is not the same promise.
@@ -583,7 +583,6 @@ deployment. `P` selects the port.
| `apikeys.sh` | whether the server does what oai.cpp says about request keys: every rejected one refused by name, every inert one accepted, every accepted one honoured | `P` |
| `cstep2.sh` | steady-state decode ms/step at concurrency | `P` `LEVELS` `MT` `WIN` |
| `ident.sh` | run-to-run reproducibility at a fixed configuration: one hash per (temperature, question) | `P` |
| `diskstall.py` | what restoring a conversation from the disk tier costs: the returning request's time to first token, and the longest stall it puts on a stream decoding beside it | `--port` `--session` `--fill` |
| `cardclock.py` | what holds each card's clock under a sustained load (power limit, temperature or current limit, or the top of the voltage/frequency curve) and which card the tensor-parallel step waits for, with the engine's step counters per window beside it. Drives its own greedy load; `--watch` only samples while real traffic drives the server. Never writes to a card | `--port` `--conc` `--gen` `--seconds` `--window` `--seed` `--watch` `--json` `--compare` |
`fndrop.sh` exists because a disconnect reaps a request at an arbitrary point in the step loop, and
@@ -639,7 +638,7 @@ model's output.
| | |
|---|---|
| `tierident.sh` | does a session that left VRAM come back byte for byte, both halves? `P` `H` `N` `TO_HOST` `TO_DISK` `FILL` |
| `tierident.sh` | does a session that left VRAM come back byte for byte, both halves, after a full host tier, and (with `TTL`) after it expired? `P` `H` `N` `TO_HOST` `FILL` `TTL` |
| `tiercross.sh` | the same with **two** sessions in flight — the only way to see one being served the other's context |
| `mctools.sh` | the tool-call shapes hardest to parse — an array argument, two calls in one reply, prose before a call, plain chat with tools available. Asserts `finish_reason` and that no `<function`/`<param`/CDATA marker reaches content |
| `mcstream.sh` | tool-call replies **streamed**, asserting on raw SSE fragments. Content cannot be retracted once sent, so a repair applied at the end is not a fix — this is the check that sees the difference |
+1 -4
View File
@@ -99,10 +99,7 @@ than stacked over. The result is resolved and checked exactly as a converted con
Startup says what the rotary is (`rope: YaRN factor 2 over 262144 trained positions -- the rotary
reaches 524288`) and warns when `--max-model-len` is past what it covers -- also with no scaling
at all, past the trained length. A persisted prefix cache (`--prefix-cache-dir`) is fingerprinted
with the resolved rotary of the target and the drafter, so a store written under a different
one -- another `--rope-scaling`, or a container converted with YaRN -- is not reused: every cached
key was rotated differently.
at all, past the trained length.
The flag is for trying a factor, or serving a container whose source checkpoints are not at hand;
a deployment that settles on one can convert it in as above and drop the flag.