radiance 1.15.0

New models and formats:
- IQR for Qwen3.8-27B: weights on the int8 grid under GPTQ, a trellis down each GPTQ column
  (IQR-V2), and IQR-V3, a computed trellis code under one scale a row, kept at its codes' width in
  VRAM and decoded in the GEMM; 15 IQR-V3 recipes from ~2 to ~7 bits a weight
  (data/recipes/q38-27b-*-v3.recipe, docs/IQR.md)
- libhalo: a kernel library for Strix Halo (gfx1151), preferred there over libr3d
- Nemotron 3.5 Embed 1B and 8B (nemotron35_embed): text and image embeddings through a Pixtral
  tower, on the card and on the CPU
- Nemotron 3.5 Rerank 8B
- /v1/systemone: Cloudflare's clef and clef-flash, Convai Innovations' Laya and Mica beside
  LiquidAI d1; scored steps read the candidates' logits from the head table with no lm_head pass
- LFM2's 8-bit trunk: block-fp8 or int8 linears with the fused producers, and the d1-3B recipe
- DeepSeek-V4.1's reply format with DSML tool calls and typed argument tags

Weights on the drive:
- The file tier reads only the experts the pass routes rows to; the draft head's weights stay in
  the host pool
- A hot VRAM cache for routed experts read off the drive, reads deposited straight into free host
  pool slots, and copyless evictions; the file tier's counters are now ssd_*
- GLM-5 Next shards its routed experts by expert, not by width, so they can live on the drive
- The stall watch counts drive reads as progress, and the DMA lane's room check reads the lane's
  own completion fence

Quantisation tooling:
- --calib-corpus, --calib-dir and --calib-layers record each linear's input Hessian; beside
  --kld-record the reference's own run records them
- --kld-top N records a sparse KL reference (the N most likely tokens and the tail's mass)
- GPTQ in a third of the time with the same codes, trellis GPTQ on the card, vector codebooks
  with coordinate descent, and rad-convert --reuse repeated, each container supplying what the
  earlier ones lack

Speculation:
- Prompt lookup alone (--spec-ngram K, --spec-ngram-min/-max): each sequence keeps an index of its
  n-grams, and a proposal is verified only when its measured step cost says it pays;
  --draft-window adaptive follows it

Speed:
- IQR decode: the narrow tile splits K for four times the int8 tile's waves and folds each 128-K
  block once; at 8 tokens down and the output projections run in 0.61-0.82x and 0.70-0.92x FP8's
  time (2-6 bits); IQ6R-S-V3 with its DFlash2 drafter steps in 26.3 ms at TP2, against 29.4 ms
  before and FP8's 27.3
- Qwen MXFP4 feed-forward: the gated fold up to 16 rows, not 8
- libr4d: the gated prefill fold, the short-prompt split row, and the rows forms of rmsnorm and
  rope; KLATE again for the head-256 gqa6 paged prefill; gram_accum on the matrix cores

Features:
- /health, /v1/health and /ping answer 503 with "status": "stuck" once the device has advanced
  nothing for a minute or a queue has faulted, so a supervisor can restart a wedged server (#356)
- --image-gen-max-pixels and --image-gen-max-refs size an image generator's buffers (#344)
- The startup report lists only the options not at their default, with a count; -v lists all
  (#250)
- --preempt-wait-ms bounds how long a preempted prefill waits for its whole-recompute room
- --placement layer_offload spills dense layers so one --max-model-len sequence fits
- Startup refuses amdgpu with CWSR off and says how to fix it;
  --proceed-with-incompatible-configuration starts anyway under an UNSUPPORTED banner

Fixes:
- The n-gram read-ahead hands each row to the reader once and reads only as far ahead as the row
  cache holds, and pauses while decode reads: about one drive read a row instead of two (#355)
- A file-tier window reads each of its runs once, not once a run per run
- The decode split law's verify floor is bounded by the batch's workgroups: max_seqs 256 no longer
  declares 64x the scratch (#342)
- A prefetch DMA list's mark stays out of the signal pool until the engine has read it, and a
  prefill stage copies only the blocks its own tables name (#343)
- The split-KV row sum is read with fetch-inactive (#328)
- LFM2 on the host backend: libref and libavx serve the row-form ops it declares (#348)
- The preempted-prefill gate skips a KV group that holds no blocks (#352)
- Every request entry point bounded, gated and sanitised (JSON depth, invalid UTF-8, control bytes
  in the log, the dashboard's CSP, cross-origin browsers on the loopback-only routes); a prompt id
  outside the vocabulary refused at admission; --api-key "" refused at startup
- The telemetry the HTTP thread reads is atomic
- An RMS norm row no longer depends on how many rows its launch carries; prefill attention's
  rescale is decided by live rows only
- A --kld-record prefill chunk that finishes no sequence gets its logits on a tied-head model
- A kernel's lazily made counter block is zeroed outside the lock other ranks take (a TP2 first-step
  hang)

Changes: Plugin ABI 32. Every plugin exports a layout fingerprint of the ABI structs and the loader
refuses a plugin without it or with another (#302), so out-of-tree plugins must be rebuilt.
Appended: RadBuildCtx calib_* and gen_max_*, RadArchProbe gen_max_*, RadBatch score_only and
plugin_words, RadDeviceProps::unified, RadChatFormat arg_json_value_prefix.
This commit is contained in:
Deadcode committed 2026-10-30 22:01:01 +01:00
commit 9ed3ef7a7b
452 files changed
+167762 -1346

No files matched your search

+8
View File
@@ -375,6 +375,14 @@ a plain int8 trunk is refused.
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.
- **Narrower codes on the same grid.** A trunk linear stored as uN with a zero point, uN indexing
an int8 scalar codebook or a vector codebook of int8 codewords, or a bitshift trellis's codes,
each under a scale per (row, 128) and fwht128, or a computed trellis (libquant's `tcq_code=mad`,
its constants in a `trellis.mad` plane) under one f32 scale a row and one a 128-K block for all
rows (`scale.col`; a view of `scale,scale.col`), stays at its codes' width in VRAM: libr4d's
`gemm_iqr` rows decode it where they read it, and `embed_lookup_iqr` and `logits_gemm_iqr` do the
same for such an embedding and head. The IQR recipes (`data/recipes/q38-27b-iq{2..8}r*.recipe`,
[`docs/IQR.md`](IQR.md)) store 2.5 to 8 bits a weight on the int8 trunk's activation path.
- **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`.
+123 -23
View File
@@ -51,6 +51,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. 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) |
| With a card | `amdgpu.cwsr_enable=1` (the default). With compute wave save/restore off the driver cannot preempt a queue it must evict, and the card hangs and resets. Startup refuses to serve on cards with it off and says what to change; `--proceed-with-incompatible-configuration` starts anyway, **unsupported**, with a banner at the top of the log and of the startup report and `unsupported_configuration: true` in `/diagnostics` |
| Optional | OpenMP, used by the host kernel libraries if present |
| Optional | `libavformat-dev libavcodec-dev libavutil-dev libswscale-dev libswresample-dev` (ffmpeg 6+), for image, video and audio input. CMake option `RAD_WITH_FFMPEG`: `AUTO` (default) uses them when found, `ON` fails the configure without them, `OFF` builds without. A build without them starts and serves text, and refuses every image, video and audio part with HTTP 500; the only warning is the configure log line `radiance: no libavformat ...`. The diagnostics report says which (`media decoders`; `host.media` in `GET /diagnostics`) |
| Optional | `clang++` (or ROCm's), for `tests/r4d_emu` when the C++ compiler is g++; CMake 3.25+ for `CMakePresets.json` |
@@ -826,14 +827,7 @@ 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. `disk` reads rows
from the container through a row cache with direct reads on the host; about half of a step's rows
are first-seen, so steps wait on the drive. (That is libavx's `embed_lookup_q`. A host gather
without a row source of its own, such as libref's `embed_lookup_planes` over a GGUF table's planes,
reads through the mapping; the engine then asks for every page a step's rows cover before the
gather runs, so the drive answers them together rather than one fault at a time. A long gather
(a prefill chunk's) whose sampled rows are already resident is asked for beside the gather
instead, so a warm chunk does not wait for the asking: ~0.5 us a page, ~240 ms a rank for an
8192-token Engram chunk.
`--row-prefetch off` turns that off.) `ram` copies the table into host memory at load (12 to
are first-seen, so steps wait on the drive. `ram` copies the table into host memory at load (12 to
40 s more startup, depending on the page cache) and the card's gather kernel reads the pinned copy,
so a step has no host work. `vram` puts all of it on every card. `ram` needs the table's size free
after the pinned host pools and the prefix cache's host tier, with `--host-headroom-mib` to spare
@@ -1363,13 +1357,12 @@ radiance --model m.rad --spec-ngram 5 --draft-window adaptive # each sequence's
radiance --model m.rad --num-speculative-tokens 4 # a head drafts; lookup fills in where it declines
```
`--spec-ngram K` sets the window to K (a different `--num-speculative-tokens` is refused) and asks
the plugin to leave out any draft head the container carries (`RadBuildCtx::draft_head_off`), so
the head's weights take no memory: the choice for a model whose head does not fit, or does not pay.
A plugin that declares its head regardless is refused at startup. Without the flag, prompt lookup
still drafts for every sequence a declared head declines, and is the only drafter when speculation
is on (`--num-speculative-tokens N`) and the container has no head. Startup says which
(`speculation: prompt lookup only (--spec-ngram K)`), and the drafts count in `draft_n` /
`--spec-ngram K` sets the window to K (a different `--num-speculative-tokens` is refused) for a
container that declares no draft head; one that declares a head is refused at startup, because the
head would draft in lookup's place (serve it with `--num-speculative-tokens N`). Without the flag,
prompt lookup still drafts for every sequence a declared head declines, and is the only drafter when
speculation is on (`--num-speculative-tokens N`) and the container has no head. Startup says which
(`speculation: prompt lookup only -- this container declares no draft head`), and the drafts count in `draft_n` /
`draft_n_accepted` and the `radiance:draft_*` metrics like a head's. Prompt lookup reads the
committed sequence, so a step is not issued ahead of the previous one's readback.
@@ -2067,8 +2060,6 @@ by 0.002-0.003 nats.
| `--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 (§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 (§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 |
| `--row-prefetch MODE` | on | `on` or `off`: a host gather from a table read through the container's mapping (`--ngram-placement disk`) asks for its rows' pages before its kernel, or beside it when they are resident (§4.3); the output is the same either way |
| `--mapped-rewarm MODE` | on | `on` or `off`: at startup, the pages of such a table an earlier run left in the page cache, and the load's own allocations pushed out, are asked for again (at most half of the available memory), so the first requests after a restart do not read them from the drive |
**LoRA adapters** (§4.9.1)
@@ -2116,7 +2107,7 @@ by 0.002-0.003 nats.
| flag | default | |
|---|---|---|
| `--num-speculative-tokens N` | auto | speculative window; 0 disables. The ceiling under `--draft-window adaptive` |
| `--spec-ngram K` | 0 | prompt lookup alone: up to K drafts a step from the sequence's own n-grams, each proposal verified when it pays at the measured step cost; no draft head declared; sets the window to K (§4.6) |
| `--spec-ngram K` | 0 | prompt lookup alone: up to K drafts a step from the sequence's own n-grams, each proposal verified when it pays at the measured step cost; a container that declares a draft head is refused; sets the window to K (§4.6) |
| `--spec-ngram-min N`, `--spec-ngram-max N` | 2, 4 | the pattern lengths prompt lookup tries, longest first (at most 15), wherever it drafts |
| `--draft-window MODE` | fixed | `fixed` drafts N every step; `adaptive` follows each sequence's acceptance and the measured step cost, for a serial draft head or prompt lookup alone (§4.6) |
| `--draft-short-from N` | auto | a block drafter that declares a shorter block runs it from N decoding sequences on, its own block again two below or at one sequence; 0 never; auto never for a chain and 2 for a tree drafter, which then verifies the short block's nodes (§4.6) |
@@ -2177,6 +2168,7 @@ flags are refused on it, and so are the pixel bands.
| `--video-min-frames N`, `--video-max-frames N` | container's | the fewest and most frames sampled from a video |
| `--video-max-frame-tokens N` | container's | the most prompt tokens one frame may become; 0 is no cap. A token-budget processor (Gemma 4's) takes 70, 140, 280, 560 or 1120 |
| `--image-tokens N` | container's | a token-budget processor's image budget: Gemma 4's 70, 140, 280, 560 or 1120, which a request's `image_tokens` overrides; GLM-5.3's ceiling, at most `--mm-max-patches` / 4 (the checkpoint states 8000, which `auto` lowers to 4096). The pixel-band flags are refused on such a model |
| `--image-gen-max-pixels N`, `--image-gen-max-refs N` | the model's | an image generator's largest image, in pixels, and the reference pictures a request. The generator sizes its per-image and conditioning buffers, and so the activation arena, for them; on a card the weights nearly fill, a smaller image is what makes room. Larger requests are refused; a generator that keeps fixed buffers is named at startup. Images in flight follow `--max-num-seqs` |
| `--max-source-pixels N` | 67108864 | the largest image or frame the decoder accepts, before any resize |
**Quality measurement**, instead of serving; see [TOOLS.md](TOOLS.md#the-kl-mode)
@@ -2186,6 +2178,10 @@ flags are refused on it, and so are the pixel bands.
| `--kld-record DIR` | run `--kld-corpus` through prefill and write this model's log-probabilities at every scored position to `DIR`: the reference a quantised model is measured against |
| `--kld-ref DIR` | score this model against the reference in `DIR`: mean, median, 99/99.9/99.99th percentile KL divergence and top-1 agreement |
| `--kld-corpus FILE` | JSONL, one `{"prompt", "score_from"?, "source"?}` a line; `--kld-record` only |
| `--calib-corpus FILE` | instead of serving, run a JSONL corpus (`{"prompt"}` a line) through prefill once, every token, and record the calibration statistics the model keeps: the whole Hessian of each linear's input (docs/TOOLS.md) |
| `--calib-dir DIR` | where `--calib-corpus` writes them, one safetensors file per input; beside `--kld-record`, that run records them over the KL corpus too |
| `--calib-layers LO:HI` | record layers `LO`..`HI-1` only (default every layer), for a model whose statistics do not fit in host memory in one run |
| `--kld-top N` | `--kld-record` keeps each position's `N` most likely tokens exactly and the mass of the rest instead of the whole vocabulary, for a corpus too large for full rows; 0 (default) keeps the whole vocabulary |
| `--kld-out FILE` | the `--kld-ref` report as JSON, and every position's numbers in `FILE.rows` |
| `--kld-lora NAME` | run the documents through the `--lora` adapter `NAME` (§4.9.1), e.g. against a reference recorded from the merged checkpoint |
| `--kld-lora-sources PREFIX` | with `--kld-lora`, only the documents whose `source` starts with `PREFIX` run through the adapter; the rest run as the base, in the same steps |
@@ -2198,8 +2194,8 @@ flags are refused on it, and so are the pixel bands.
| `--debug-selection` | print the selection table |
| `--debug-placement` | print the placement plan |
| `--debug-draft-oracle FILE` | a verify-path test, not a drafter: with `--spec-ngram`, prompt lookup proposes from the token ids in `FILE` (a plain greedy run's continuation of the one prompt the test sends) with 30% of the drafts corrupted, so verifies accept and reject at every depth; the text must stay the plain run's |
| `--debug-tape-dump` | list the dispatches of the first recorded pass of each kind (`TAPEDUMP` lines on stderr, every rank) and which of them start unordered behind the one before |
| `--debug-accept-reference-kernels` | serve even when ops resolve to `libref`. Not a production configuration |
| `--proceed-with-incompatible-configuration` | start on a machine configuration startup refuses (§1.1: CWSR off where cards serve). **Unsupported**: all guarantees are off, and the log and the startup report say so |
| `--profile-ops` | per-op device timing |
| `--expert-stats FILE` | count the routed experts every layer selects, apart for prefill, decode, mixed steps and draft-head passes, and write them to `FILE` as JSON every 30 s and at shutdown (written through a temporary and a rename). Counted on the host from the routing histograms the core already copies back for the heat engine, so it adds no device work and no synchronisation; under expert parallelism each rank's slice is mapped to the model's expert ids through the container's directory |
| `--live` | the live terminal view (§6.4) |
@@ -2217,7 +2213,7 @@ flags are refused on it, and so are the pixel bands.
| `POST /v1/completions` | raw text completion |
| `POST /v1/embeddings` | needs a model with an embedding head, else 501 |
| `POST /v1/images/generations`, `POST /v1/images/edits` | OpenAI's images API; needs an image model (Qwen-Image 2.1), else 501 (§5.6) |
| `POST /v1/systemone` | LiquidAI d1's decisions over a state: named yes/no, choice and score questions answered as probabilities, nothing generated; needs a container converted as d1, else 501 (§5.13) |
| `POST /v1/systemone` | Decisions over a state: named yes/no, choice and score questions answered as probabilities, nothing generated; LiquidAI's d1, Cloudflare's clef and clef-flash with their joint head on the card, or Convai Innovations' Laya; needs a container converted as one, else 501 (§5.13). `POST /v1/decisions` is the same endpoint under LiteLLM's name |
| `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; 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) |
@@ -2984,6 +2980,107 @@ together. A single question is one pass of the whole prompt, tokenised as one te
Against d1's own runner in float32, on eight text cases (one and several questions, JSON and long log
states): every choice and every `input_tokens` equal, worst probability difference 0.0044.
#### clef and clef-flash
Cloudflare's clef (27B) and clef-flash (9B) are decision models on Qwen3.5 that answer the same
request, every question of it jointly: a joint schema head reads the backbone's final hidden state
at every prompt position, the mean over each question's instructions and each option's text, and
the lm_head rows of each option's tokens, and gives one logit an option. radiance runs that head
on the card, after the trunk, in the `clef_bf16` and `clef_fp8` plugins (`arch/clef_bf16`,
`arch/clef_fp8`: the qwen35 plugins' own code with `arch/common/rad_block_clef.h` after it): there
is no second process. The head's own tensors ship as
`joint_head.safetensors` beside the checkpoint and are added at convert; `joint_head_config.json`
beside them gives the head's geometry.
```sh
rad-convert /srv/models/clef-flash -o clef-flash.rad --arch clef \
--add /srv/models/clef-flash/joint_head.safetensors --set decision.type=clef
radiance --model clef-flash.rad --port 8000
```
`--arch clef` selects the `clef_bf16` and `clef_fp8` plugins, the qwen35 trunk built again with
the head after it; a container left as `qwen35` serves generation and answers `/v1/systemone`
with 501.
The request and the response are the same as d1's above; `/v1/decisions` is the same endpoint
under LiteLLM's name. What differs:
- One request is one prompt, the state and every question together, so questions are not shared
through the prefix cache; a state many requests share (the rules in front of each respondent)
is, with the head's own per-token rows beside the trunk's cache.
- `state` must be a non-empty string or JSON value; pictures answer 501 for now.
- A prompt longer than the context answers 400 with `context_length_exceeded` (clef's own code
cuts it silently). A request has at most 64 questions, 512 options and 8192 option tokens.
- The head runs on one rank, and the lm_head stays bf16 (a recipe that quantises it is refused).
- `GET /v1/models` reports `"decision": "clef"` in the model's capabilities.
Against clef's own head on the CPU reference, on a tiny model with random weights
(`tests/clef_decision_test.cpp`): worst probability difference 0.0004.
#### Laya
Convai Innovations' Laya checkpoints (`laya`, `laya-typed-decisions` on ModernBERT-large, and
`laya-multilingual` on mmBERT-base) are encoder decision models. Laya reads one sequence a
question, `[CLS] <type> question: <instructions> [SEP] [MASK] option ... [SEP] <state> [SEP]`, and
scores each option at its `[MASK]` with a small head after the encoder. radiance builds those
sequences in the server (`core/server/laya.cpp`, a rewrite of the `laya` package's own code) and
runs the encoder and head in the `laya` plugin (`arch/laya`), on the embedding path: no KV cache,
every question of a request in one step, each answered in its pooled row.
```sh
rad-convert /srv/models/laya-typed-decisions -o laya-typed-decisions.rad --set decision.type=laya
radiance --model laya-typed-decisions.rad --port 8000
```
rad-convert reads the release's folders: `encoder/config.json` for the geometry,
`rl_agent_config.json` for the sequence budget and the fitted temperatures, and `tokenizer/`. The
checkpoint's `config.json` already says `model_type: laya`, so `--set decision.type=laya` is
optional. A checkpoint as the `laya` package downloads it, with no `config.json` of its own,
converts the same way. The release ships f16 weights. rad-convert rounds the linears and tables to
bf16 itself, which is how the release computes them on a card, and records the rule in the
container's recipe.
The request and the response are the same as d1's above. What differs:
- A state longer than the room a question leaves is cut, as the `laya` package cuts it: to its
start, or to its end for a list of turns. `usage` reports the cut with the package's own keys:
`state_tokens`, `state_tokens_dropped`, `truncated` and `truncated_questions`.
- `confidence` is the package's: 1 minus the normalised entropy for choice and score. The fitted
temperatures are clamped to [0.5, 5], as the package clamps them.
- A choice has at most 255 options, and options that do not fit the sequence answer 400.
- `state` must be a non-empty string or JSON value. Pictures answer 501, and `/v1/embeddings`
answers 501 (the pooled row holds option logits, not a vector).
- `GET /v1/models` reports `"decision": "laya"` in the model's capabilities.
Against the `laya` package's own `Agent.predict` on the CPU reference, on a tiny model with random
weights (`tests/laya_decision_test.cpp`): every `usage` field equal, worst probability difference
0.0162 (0.0266 on a score's expected level).
#### Mica
Mica (`sky7350/Mica-v0.5-4B`, a fine-tune of Qwen3.5-4B) answers with d1's readout: one prompt a
question -- a fixed system message, the state, the question and its candidates under labels -- and
a softmax over the label tokens' logits at the prompt's last position (`No`/`Yes` for a yes/no
question, `A`, `B`, ... for a choice or a score). The qwen35 plugins serve it as they serve the base
model. The prompts and the response are built in the server (`core/server/mica.cpp`, a rewrite of
Mica's `contract.py` and `native.py`), and a request's questions share the state through the prefix
cache.
```sh
rad-convert /srv/models/Mica-v0.5-4B -o mica.rad --set decision.type=mica \
--set decision.mica.temperature=T --set decision.mica.noul_logit_bias=B
radiance --model mica.rad --port 8000
```
`T` and `B` are the release's calibration (`calibration.json`): one temperature for every question
type and a bias on a yes/no question's true logit. Unset, the temperature is 1 and the bias 0.
The request and the response are the same as d1's above. What differs: every prompt is Mica's exact
"plain" profile (its runtime's long-input mode, which approximates prompts over about 1K tokens, is
not served), and `GET /v1/models` reports `"decision": "mica"`. Against the contract fixtures Mica's
repository ships (`tests/mica_test.cpp`): every prompt byte for byte, every response value for
value.
### 5.14 Speech to text
A model whose architecture plugin says how it transcribes -- Qwen3-ASR, served as its checkpoint
@@ -3744,8 +3841,10 @@ The last block startup prints before `serving on` is `STARTUP REPORT`. A startup
it too, after the error, with what it had resolved, and ends with an `E` line repeating the error. It
is the part of a log to paste into an issue. Its sections:
- **CONFIGURATION**: every option `--help` lists, with the value in force and its source
(`default`, `command line`, an environment variable, or `auto`). An `auto` line carries the reason
- **CONFIGURATION**: the options not at their default, with the value in force and its source
(`command line`, an environment variable, or `auto`), then a count of the options at their
default; `-v` lists every option `--help` lists, and `/diagnostics` always carries every one. An
`auto` line carries the reason
under it: the drafter's depth, where the embedding and n-gram table went, the VRAM split, the
placement strategy, each sampler default and the file it came from. `--api-key` shows only `set` or
`not set`.
@@ -3763,7 +3862,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.14.0
I STARTUP REPORT -- radiance 1.15.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]
@@ -3799,6 +3898,7 @@ curl -s -H "Authorization: Bearer $KEY" localhost:8000/diagnostics | jq '.findin
| Message | Meaning | Action |
|---|---|---|
| `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 |
| `incompatible configuration: ...` and `radiance does not start on a configuration it does not support` | A machine setting known to break radiance (§1.1) | Make the change the line names (`Fix:`) |
| `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` |
+171
View File
@@ -0,0 +1,171 @@
# IQR: integer quantisation on the rotated int8 grid
IQ8R (`StillDeadcode/qwen3.8-27b-iq8r`) is Qwen3.8-27B with every trunk linear rotated by the
128-wide Hadamard (`transform=fwht128`), quantised to int8 with a bf16 scale per (row, 128 of K) by GPTQ
against the calibration Hessians, and served at `i8a8h`: the norm and gated producers write the
rotated int8 activation codes the GEMM reads (`qwen35_w8a8`). IQ6R .. IQ2R keep that recipe --
GPTQ, the rotation, integer codes, int8 activations -- and spend fewer bits on the weights.
## The formats
Every IQR weight is on IQ8R's grid: a value is an int8 times the scale of its group. A container
stores it narrower, and VRAM holds it at the same width: libr4d's IQR rows decode each code to its
int8 value where the weight is read (`r4d_iqr.h`; `gemm_iqr_nt_m64` up to 64 rows, `gemm_iqr_tiled`
for a prefill, `embed_lookup_iqr` and `logits_gemm_iqr` for the embedding and the head), with
rotated int8 activations on the `i8a8h` trunk:
| form | encoding | decoded as |
|---|---|---|
| signed | `iN*bf16[1x128]/fwht128`, N = 2..7 | sign extension |
| asymmetric | `uN*bf16[1x128]-uN[1x128]/fwht128` | code - zero |
| scalar codebook | `affine:codes=uN[1x1],scale=bf16[1x128],table=i8{1x2^N}/fwht128` | the entry |
| vector codebook | `affine:codes=uM[1x4],scale=bf16[1x128],grid=i8{E x 4}/fwht128` | the codeword's 4 values |
The embedding and the head decode the same forms, unrotated. The arithmetic is the int8 grid's
for every form: a narrower code changes the bytes read, not the values multiplied.
## The quantiser
`gptq` (libquant) over the rotated weight against the calibration Hessians:
- the codebooks are integer Lloyd tables (`data/codebooks/iqr-scalar.txt`) and k-means vector
codebooks (`iqr-vq2-4x256.txt`, `iqr-vq3-4x4096.txt`), fitted to the rotated weights;
- `rule=search` scales; `dyn=1` chooses a group's scale when GPTQ reaches it;
- `cd=N` coordinate descent after the loop, per code or, for a vector grid, per codeword;
- the head is fitted by GPTQ too, against the head's input Hessian.
Measured on layer 3 (output error, relative): the scalar codebook beats a uniform grid by 12-25% at
two to five bits; the asymmetric grid wins at six. A 256 x 4 vector codebook with one descent pass
has 19% less error than the scalar 2-bit codebook with eight; the 4096 x 4 one 13% less than scalar
3-bit.
## Where the bits go
The KL a quantised band of layers contributes adds up across bands to within a few percent, so a
mix is chosen by a model: KL = floor + sum over bands of share x (KL of the band's grid - floor).
On the 4-bit trunk the eight bands of eight layers carry 9, 4, 8, 11, 13, 12, 16 and 28 % of the KL:
the last layers are the most sensitive, and the projections of a layer about equally so. The
embedding and the head are cheap to keep wide (1.27B parameters each, 0.047 bpw a bit) and costly
to narrow at the higher sizes: a 4-bit embedding by round to nearest costs IQ8R +0.00058 KL, a 6-bit
one +0.00003.
The 2-bit trunk's bands weigh the same way (12, 6, 7, 8, 10, 10, 17 and 31 %, measured by raising
one band of the 256 x 4 trunk to four bits). `rule=search` per group and a narrower scale group do
nothing at two bits (the vector codebook's error is the same at groups of 128 and 64): the bits
go to wider codebooks instead, and each half bit of a 4-wide codebook halves the error (256, 512,
1024 and 4096 codewords: 2.125 to 3.125 bits a weight with the scale).
## Results
Qwen3.8-27B against the competition's private tiers 1 + 2 (mean KL to the bf16 model's top-512,
bpw over the text model's 26.9B parameters, embedding and head included):
| recipe | bpw | KL mean | top-1 | the GGUF at that size | its bpw | its KL |
|---|---:|---:|---:|---|---:|---:|
| `q38-27b-iq6r-l` | 6.935 | 0.00092 | 98.91% | UD-Q6_K_L | 7.089 | 0.00129 |
| `q38-27b-iq6r` | 6.375 | 0.00123 | 98.73% | UD-Q6_K | 6.431 | 0.00194 |
| `q38-27b-iq6r-s` | 6.061 | 0.00151 | 98.48% | UD-Q5_K_XL | 6.102 | 0.00268 |
| `q38-27b-iq5r` | 5.420 | 0.00300 | 98.00% | UD-Q5_K_S | 5.444 | 0.00428 |
| `q38-27b-iq5r-s` | 5.075 | 0.00426 | 97.66% | UD-Q4_K_XL | 5.115 | 0.00608 |
| `q38-27b-iq4r-l` | 4.780 | 0.00609 | 97.19% | UD-Q4_K_M | 4.790 | 0.00820 |
| `q38-27b-iq4r` | 4.457 | 0.00904 | 96.56% | UD-Q4_K_S | 4.461 | 0.01057 |
| `q38-27b-iq4r-s` | 4.137 | 0.01327 | 95.50% | UD-IQ4_XS | 4.132 | 0.01499 |
| `q38-27b-iq3r-l` | 3.798 | 0.01887 | 94.78% | UD-Q3_K_XL | 3.803 | 0.02403 |
| `q38-27b-iq3r` | 3.459 | 0.03043 | 93.59% | UD-IQ3_S | 3.474 | 0.03473 |
| `q38-27b-iq3r-s` | 3.148 | 0.04469 | 92.29% | UD-IQ3_XXS | 3.145 | 0.05052 |
| `q38-27b-iq2r-l` | 2.790 | 0.06937 | 90.32% | UD-Q2_K_XL | 2.816 | 0.07920 |
| `q38-27b-iq2r` | 2.469 | 0.12234 | 87.02% | UD-IQ2_S | 2.487 | 0.12976 |
IQ6R is also below UD-Q6_K_L (7.089 bpw, 0.00129) and IQ5R below UD-Q5_K_M (5.773, 0.00328). By
source, IQ4R's lead over UD-Q4_K_S is widest on agent traces and reasoning (0.71 to 0.74 of its
KL; on the 256K agentic traces 0.00595 against 0.00822) and narrowest on chat, Wikipedia and long
fiction (wildchat 0.99, wikimedia 0.98, pg19 0.95).
A base convert (one grid over the whole trunk) is one GPTQ pass over the bf16 checkpoint, 35 to
100 minutes on 16 threads. A recipe converted from scratch costs one such pass; the mixes were
assembled from the bases instead (`rad-convert --reuse` with every base, which copies each weight
whose options match a base's), a few minutes each.
## IQR-V2: a trellis down each GPTQ column
IQR-V2 keeps the rotation, GPTQ, the int8 grid and the int8 activations, and changes what a code
is: the trunk's codes are a bitshift trellis (QTIP's) of 2^12 states run down each column of the
rotated weight (`tcq=12`). A row's value is the table entry of its state, the state being the last
12 bits of the column's codes; a run of 256 rows (`tcq_rows`) is tail-biting, so no bits go to a
start state. Down a column every row shares the column's H_ii, so the Viterbi's metric is GPTQ's
own objective for that column, and GPTQ's feedback to the later columns stays exact. The tables
are 4096 integers in -127..127 (`data/codebooks/iqr-tcq-L12-k2..k7.txt`), trained by Lloyd
iterations on Viterbi paths over the rotated weights; the scale is E4M3 per (row, 128) under one
f32 for the tensor (`scale=fp8_e4m3 scale2=f32 block2=*x*`), which the trellis was searched against
at the bf16 of their product. The GEMM walks each column's states in the tile and reads their
values from the table in LDS (`gemm_iqr`), so V2 serves on the `i8a8h` trunk at its codes' width.
On layer 3 the trellis has 21-29% less output error than V1's best grid at every rate from 2 to 6
bits. The mixes are chosen as V1's by band shares, over 24 units (8 bands x gate_up / down / the
attention or delta-net projections) and the k = 2 .. 7 trellises plus int8, by an exact Pareto
merge. The embedding is a rotated trellis too (unrotated at load); the head stays V1's scalar
GPTQ table, where a trellis clipped its outliers.
| recipe | bpw | KL mean | top-1 | V1 at that size | its bpw | its KL | KL |
|---|---:|---:|---:|---|---:|---:|---:|
| `q38-27b-iq8r-v2` | 8.040 | 0.00047 | 99.18% | IQ8R | 8.505 | 0.00046 | +2% |
| `q38-27b-iq7r-v2` | 7.418 | 0.00061 | 99.11% | -- | | | |
| `q38-27b-iq6r-l-v2` | 6.937 | 0.00073 | 99.05% | IQ6R-L | 6.935 | 0.00092 | -21% |
| `q38-27b-iq6r-v2` | 6.375 | 0.00094 | 98.92% | IQ6R | 6.375 | 0.00123 | -24% |
| `q38-27b-iq6r-s-v2` | 6.062 | 0.00115 | 98.78% | IQ6R-S | 6.061 | 0.00151 | -24% |
| `q38-27b-iq5r-v2` | 5.423 | 0.00204 | 98.34% | IQ5R | 5.420 | 0.00300 | -32% |
| `q38-27b-iq5r-s-v2` | 5.076 | 0.00273 | 98.07% | IQ5R-S | 5.075 | 0.00426 | -36% |
| `q38-27b-iq4r-l-v2` | 4.784 | 0.00377 | 97.78% | IQ4R-L | 4.780 | 0.00609 | -38% |
| `q38-27b-iq4r-v2` | 4.457 | 0.00562 | 97.29% | IQ4R | 4.457 | 0.00904 | -38% |
| `q38-27b-iq4r-s-v2` | 4.130 | 0.00832 | 96.67% | IQ4R-S | 4.137 | 0.01327 | -37% |
| `q38-27b-iq3r-l-v2` | 3.798 | 0.01198 | 96.04% | IQ3R-L | 3.798 | 0.01887 | -37% |
| `q38-27b-iq3r-v2` | 3.458 | 0.01880 | 95.06% | IQ3R | 3.459 | 0.03043 | -38% |
| `q38-27b-iq3r-s-v2` | 3.145 | 0.02798 | 93.75% | IQ3R-S | 3.148 | 0.04469 | -37% |
| `q38-27b-iq2r-l-v2` | 2.792 | 0.04698 | 92.03% | IQ2R-L | 2.790 | 0.06937 | -32% |
| `q38-27b-iq2r-v2` | 2.467 | 0.07303 | 90.15% | IQ2R | 2.469 | 0.12234 | -40% |
IQ4R-L-V2 is below the official FP8 checkpoint (8.766 bpw, 0.00389) at 55% of its size, and IQ7R-V2
is below UD-Q6_K_XL (7.417 bpw, 0.00114) at the same size. IQ8R-V2 holds IQ8R's KL in 5% fewer
bits.
## IQR-V3: a computed trellis under one scale a row
IQR-V3 keeps V2's tail-biting trellis inside GPTQ and changes the code and the scale. A state's
value is computed from the state instead of read from a table (`tcq_code=mad`): with
h = (st * A + B) mod 2^32 from the low 24 bits of each factor, the value is
bytesum(h & 0x3F3F3F3F) - 126, a near-Gaussian int8 (A = 0xB5297B, B = 0x2545F491, stored as the
`trellis.mad` plane beside the table they generate). A reader needs a multiply-add, a mask and one
byte-sum dot product a value and no table, so the trellis grows to 2^16 states (`tcq=16`; 2^15 at
two bits) at no decode cost. The scale is one f32 a row (`block=1x* scale=f32`), applied after the
K loop, with the codes searched at a gain over the row's absmax that rises with the width
(`tcq_gain`: 1.04 at two bits, 1.08, 1.12, 1.16, then 1.24 at six and seven), and higher for the
projections the attention heads feed (`attn_output`, `ssm_out`: 1.36, 1.5 and 1.6 at five, six and
seven bits). GPTQ's damping is 0.01.
The GEMM decodes in the tile (`gemm_iqr`). At one token the GEMV dots each value's hash with its
activation byte repeated in all four bytes, so a 4-bit `ffn_gate_up` takes 0.58 of FP8's time
(V2 0.80), and a decoder layer's trunk GEMMs at 2048 tokens take 1.00-1.06x FP8's (V2
1.19-1.21x), since one scale a row folds as FP8's block scale does. The mixes are chosen as V2's,
from the k = 2 .. 7 bases and IQ8R's int8 grid at V2's sizes; IQ8R-V3 is IQ8R-V2's container, the
int8 grid both share.
| recipe | bpw | KL mean | top-1 | V2 at that size | its bpw | its KL | KL |
|---|---:|---:|---:|---|---:|---:|---:|
| `q38-27b-iq8r-v3` | 8.040 | 0.00047 | 99.18% | IQ8R-V2 | 8.040 | 0.00047 | 0% |
| `q38-27b-iq7r-v3` | 7.420 | 0.00060 | 99.12% | IQ7R-V2 | 7.418 | 0.00061 | -2% |
| `q38-27b-iq6r-l-v3` | 6.939 | 0.00072 | 99.04% | IQ6R-L-V2 | 6.937 | 0.00073 | -2% |
| `q38-27b-iq6r-v3` | 6.372 | 0.00088 | 98.93% | IQ6R-V2 | 6.375 | 0.00094 | -6% |
| `q38-27b-iq6r-s-v3` | 6.049 | 0.00106 | 98.83% | IQ6R-S-V2 | 6.062 | 0.00115 | -8% |
| `q38-27b-iq5r-v3` | 5.422 | 0.00182 | 98.38% | IQ5R-V2 | 5.423 | 0.00204 | -11% |
| `q38-27b-iq5r-s-v3` | 5.064 | 0.00249 | 98.15% | IQ5R-S-V2 | 5.076 | 0.00273 | -9% |
| `q38-27b-iq4r-l-v3` | 4.783 | 0.00342 | 97.86% | IQ4R-L-V2 | 4.784 | 0.00377 | -9% |
| `q38-27b-iq4r-v3` | 4.458 | 0.00512 | 97.45% | IQ4R-V2 | 4.457 | 0.00562 | -9% |
| `q38-27b-iq4r-s-v3` | 4.131 | 0.00762 | 96.90% | IQ4R-S-V2 | 4.130 | 0.00832 | -8% |
| `q38-27b-iq3r-l-v3` | 3.798 | 0.01129 | 96.16% | IQ3R-L-V2 | 3.798 | 0.01198 | -6% |
| `q38-27b-iq3r-v3` | 3.459 | 0.01698 | 95.35% | IQ3R-V2 | 3.458 | 0.01880 | -10% |
| `q38-27b-iq3r-s-v3` | 3.145 | 0.02584 | 94.02% | IQ3R-S-V2 | 3.145 | 0.02798 | -8% |
| `q38-27b-iq2r-l-v3` | 2.786 | 0.04241 | 92.62% | IQ2R-L-V2 | 2.792 | 0.04698 | -10% |
| `q38-27b-iq2r-v3` | 2.465 | 0.06807 | 90.54% | IQ2R-V2 | 2.467 | 0.07303 | -7% |
The design, the per-weight and GEMM measurements and the comparison with V1 and V2 are in the
IQR-V3 technical report (radiance.stilldeadco.de/whitepapers/iqr-v3.pdf).
+17 -10
View File
@@ -185,13 +185,18 @@ A staged pass reads the pool by block id, while `kv_store_streamed` writes the r
map names a slot (none before the group's first decode), so a staged pass also stores at identity
(`AttnGatedFP8::store_stage_identity`, GLM's plain store), after the mirror writer.
**Volume.** A layer's copy moves the mirror row up to the highest block id the pass can read, not the
whole context allocation. The bound is `KVManager::held_top_blocks`, one past the highest held block,
read every step after the step's blocks are ensured (`kvstream_bound_live`). It must never be low:
the attention would read whatever the previous layer left, which is wrong text, not a fault. It is
an upper bound because every id a table holds is held, the stage is identity-addressed from block 0,
and allocation is not assumed ascending. It counts every held block, including the prefix cache's;
0 (nothing held) stages the whole row.
**Volume.** A layer's copy moves only the blocks the step's own block tables name, not the whole
context allocation: its list carries one range per run of those ids (`kvstream_runs`), read every
step after the step's blocks are ensured (`kvstream_step_runs`). The ranges must never miss a block
the pass reads: the attention would read whatever the previous layer left, which is wrong text, not
a fault. They cover every read because the pass reaches the stage only through the step's tables,
the stage is identity-addressed as the mirror row is, and a prefix hit's cached blocks are in the
hit's table. Gaps of up to 16 blocks are copied through, and past 256 ranges the smallest gaps are,
so a fragmented table stays one short list. Blocks the prefix cache retains for other
conversations are not copied: they often hold the low ids, and a new sequence takes ids above them,
so a bound on the highest id a step names (or on the highest held one, as before) would still copy
every retained conversation, and each later prefill paid for all of them. A step whose sequences
are not known, or whose trunk pass takes the ring, copies up to `KVManager::held_top_blocks`.
### 3.6 The ABI surface
@@ -263,8 +268,8 @@ Capacity is bought in host RAM. Flash-Next fp8, two ranks, `--kv-resident 24576`
Per retained token: 6.00 KiB of mirror (host), 0.83 KiB of indexer and 0.50 KiB of stage (VRAM);
only the ring does not scale. Prefill comes out 3-5 % above the resident arm, because the VRAM the
cache no longer holds goes to experts that would otherwise be read over the link. The stage copy's
cost is its volume (the held bound moves 0.6 GiB a pass at 16k and 45 GiB at 160k, within 0.3 % of
the live KV), not its overlap, since it shares the link as an equal (§6.1). Capacity is bought with
cost is its volume (0.6 GiB a pass at 16k and 45 GiB at 160k, within 0.3 % of the live KV, a
figure the step's own ranges keep however much the prefix cache retains), not its overlap, since it shares the link as an equal (§6.1). Capacity is bought with
`--max-num-seqs`, inside the trained window, so no rope change is needed. Perplexity: 3.994 resident,
4.015 with a covering window, 4.014 with a fraction of it.
@@ -395,7 +400,9 @@ whole context resident during prefill (the group would still carve `n_layers x c
| a mirror nothing writes | the store must resolve to a kernel for the group's geometry | `a_declared_streamed_store_with_no_kernel_is_not_a_streamed_path`; `a_packed_cache_warns_that_the_layout_has_no_writer_and_serves_non_streamed`; `a_resolve_declared_for_another_group_does_not_enable_streaming` |
| the flag honoured with no streamed path | the capability gate | `a_model_whose_architecture_declares_no_streamed_ops_ignores_the_flag`; `a_streamed_op_exists_only_for_a_capable_architecture_and_a_ring` |
| a stage reading the previous layer's bytes | the ordering rule (§3.5.1) | `a_streamed_groups_layers_may_all_alias_one_pool_slot`; `scripts/kv-stage-parity-64k.sh` |
| a stage copying less than the pass reads | the `held_top_blocks` bound | `scripts/kv-stage-parity-64k.sh` |
| a stage copying less than the pass reads | the ranges of the step's own tables | `the_stage_ranges_cover_every_block_a_table_names`; `scripts/kv-stage-parity-64k.sh` |
| a stage copying what other conversations hold | the ranges of the step's own tables | `the_stage_ranges_leave_out_blocks_no_table_of_the_step_names` |
| a stage list's mark reused while the list still polls it, both cards stopped | the signal pool holds a mark until its list's engine is past the poll | `device_test` `a_dma_lists_mark_stays_out_of_the_pool_until_the_engine_has_read_it` |
| maps leaving the pool short of the probe | `kvstream_maps_charged` in both paths | `a_streamed_groups_maps_are_charged_before_the_pool_is_sized` |
| a dense-read sibling funded for one sequence | the `kvstream_dense` floor | `a_dense_read_groups_floor_holds_every_sequence_while_a_sibling_streams` |
| a recorded pass replayed against another view | `kvstream_view_key`; fixed addresses | `Ctx::pass_key`'s static assertion on `RadKVGroupBatch` |
+24 -4
View File
@@ -212,6 +212,7 @@ at once. Run it before adding a kernel plugin; the loader names only the first c
| `mul_weight` | `M`(range) `n` `dtype` `scalar`/opt | `x`, `w`w → `y` (w one element or one row) |
| `act_mul` | `M`(range) `n` `act` `dtype` | `a`, `b` → `y` (act(a)·b, two operands) |
| `seg_mean` | `M`(range) `n` `dtype` | `x`, `cu_seqlens` → `y` (one mean row a segment) |
| `seg_softmax_pool` | `M`(range) `n` `dtype` | `score`, `v`, `cu_seqlens` → `y` (one softmax-weighted row a segment) |
| `seg_mean_bf16_sum` | `M`(range) `n` `dtype` | `x`, `cu_seqlens` → `y` (BF16 sum, then BF16 quotient) |
| `pool_rows` | `M`(range) `n` `k` `mult`:f64/opt `dtype` | `x` → `y` (one mean row a window of k rows) |
| `pool_cols` | `M`(range) `n` `k` `mult`:f64/opt `dtype` | `x` → `y` (one mean column a window of k columns) |
@@ -292,6 +293,13 @@ rounded to `y`'s dtype before the product, as the unfused pair stores it.
`[cu[s], cu[s+1])`, summed in double and rounded once. `M` is the step's token count and bands the
op; the segment count is `cu_seqlens`' length less one. An empty segment is a zero row.
**`seg_softmax_pool`** is `seg_mean` with learned weights: row `s` of `y` is `v`'s rows
`[cu[s], cu[s+1])` summed with the softmax of their `score`s (one a row of `v`, f32, the maximum
subtracted) as the weights, the sum in f32 and rounded once. It is a query reading its few
candidates: clef's joint schema head routes each question over its options this way, the scores
the options' dot products with the question. `M` bands the op as `seg_mean`'s does, and an empty
segment is a zero row.
**`seg_mean_bf16_sum`** preserves the two BF16 stores of Nemotron 3.5 Rerank's masked
mean: sum the segment in f32, round the sum to BF16, divide by its valid-token count,
then round the quotient to BF16. Input and output are BF16; cumulative lengths are
@@ -540,7 +548,7 @@ second of a clip apart and attends in windows of eight seconds:
| `rmsnorm_had_quant_i8` | `M`(range) `n` `eps`:f64 `group` `dtype` `wadd`:f64/opt | `x`, `residual`:inout?, `w`w → `q`, `scale`, `out_bf16`? |
| `gated_had_quant_i8` | `M`(range) `n` `group` `dtype` `act`:str/opt `mode`/opt | `a`, `b`? → `q`, `scale` |
| `dequant` | `M`(range) `n` `group` `dtype` | `q`, `scale` → `y` |
| `gram_accum` | `M`(range) `n` `group` `dtype` | `a`, `a_scale`?, `h`:inout |
| `gram_accum` | `M`(range) `n` `group` `dtype` `upper`/opt | `a`, `a_scale`?, `h`:inout |
**`gram_accum`** characterises a quantiser's output:
`h[k1][k2] += sum over rows of dequant(a)[m][k1] * dequant(a)[m][k2]`, the Hessian a GPTQ packer
@@ -550,7 +558,10 @@ block. It is not `gemm_nt` with a transposed operand: that op contracts the last
and this one the first. It is the one op here that no forward pass issues; it runs under a
calibration flag and its result is read at convert time, in another process, through a file.
`dtype` says how `a` is read: `fp8a8` is E4M3 codes with an f32 dequant scale per (row, `group`
columns) in `a_scale`; `bf16` is a plain activation with no `a_scale` and no grouping.
columns) in `a_scale`; `bf16` is a plain activation with no `a_scale` and no grouping. `upper` 1
accumulates only `k2 >= k1`, the half a reader of the symmetric `h` needs, for half the work; the
entries below the diagonal are then outside the contract (libr4d adds whole 64-wide tiles, so it
writes some of them).
**Activation widths.** Which width a linear's activation takes follows from the weight. Where the
checkpoint ships E4M3 weights and a block scale plane, every linear is `fp8a8`
@@ -740,8 +751,8 @@ may not have arrived.
| `gemm_nt` | `M`(range) `N` `K` `dtype` | `a`, `b`w → `y` |
| `gemm_nt_f32` | `M`(range) `N` `K` `dtype` | `a`, `b`w → `y` |
| `gemm_nt_bias` | `M`(range) `N` `K` `dtype` `act`/opt | `a`, `b`w, `bias`w, `res`? → `y` |
| `gemm_nt_q` | `M`(range) `N` `K` `group` `dtype` `pb1`/opt `pb2`/opt `split_n`/opt | `a`, `a_scale`?, `b`w, `b_scale`w → `y`; `a_sum`?, `b_ref`w? |
| `gemm_nt_q_short` | `M`(range) `N` `K` `group` `dtype` `pb1`/opt `pb2`/opt `split_n`/opt | `a`, `a_scale`?, `b`w, `b_scale`w → `y`; `a_sum`?, `b_ref`w? (the narrow fp8 row with the short-prompt split rule: N <= 512, K <= 5120 and 41..64 rows run unsplit) |
| `gemm_nt_q` | `M`(range) `N` `K` `group` `dtype` `pb1`/opt `pb2`/opt `split_n`/opt `w_rb`/opt | `a`, `a_scale`?, `b`w, `b_scale`w → `y`; `a_sum`?, `b_ref`w? |
| `gemm_nt_q_short` | `M`(range) `N` `K` `group` `dtype` `pb1`/opt `pb2`/opt `split_n`/opt `w_rb`/opt | `a`, `a_scale`?, `b`w, `b_scale`w → `y`; `a_sum`?, `b_ref`w? (the narrow fp8 row with the short-prompt split rule: N <= 512, K <= 5120 and 41..64 rows run unsplit) |
| `gemm_nt_q_bias` | `M`(range) `N` `K` `group` `dtype` | `a`, `a_scale`, `b`w, `b_scale`w, `bias`w → `y` |
`nt` is A row-major `[M,K]` times B transposed `[N,K]`, giving `[M,N]`: the layout every weight in
@@ -785,6 +796,15 @@ weight element (n, k) is `(code - zero) * scale`, one f16 scale and one integer
ParoQuant grids (the four 4- and 5-bit ones) take parts (`pb1`, `pb2`); `w2a8` and `w4a8_asym` do
not, and none has a bias form.
`w_rb` is the weight rows one int8 scale covers, when the weight's form makes it more than one: a
trellis on libquant's `tcq_rb` grid, each value read against its block's largest scale. Absent, 1.
An IQR weight under one f32 scale a row and one f32 factor a 128-K block for all rows (`kRowF32`,
a computed trellis's form) needs none: `gemm_iqr_*` fold the block's factor with the activation's
per-128 scale and take the row's in the epilogue.
A kernel may then fold one scale a block of rows: libr4d's `gemm_iqr_tiled` does (its form says
how many), as do `gemm_i8a8_rb8_tiled` and `gemm_i8a8_rb32_tiled` for an int8 weight whose
per-row scale plane holds each block's one value in each row.
`split_n` is the output width whose K split the call takes, when it is a row slice of a wider
linear (a rank's share of a weight whose rows do not divide among the ranks, issued as two slices).
libr4d's narrow fp8a8 and i8a8 kernels pick their K split from N alone, and the split sets the order
+19 -1
View File
@@ -23,9 +23,11 @@ quantisers, and §13 building, installing and the search path.
```c
#include "rad_abi.h" /* required */
#include "rad_abi_layout.h" /* required: the layout fingerprint */
#include "rad_plugin.h" /* optional helpers -- see §6 */
uint32_t rad_plugin_abi_version(void) { return RAD_ABI_VERSION; }
RAD_PLUGIN_ABI_LAYOUT_EXPORT /* uint64_t rad_plugin_abi_layout(void) */
const RadPluginInfo* rad_plugin_info(void) {
static const RadPluginInfo i = {
@@ -42,7 +44,16 @@ const RadKernelInfo* rad_kernel_at(int i);
A plugin whose `rad_plugin_abi_version` differs from the engine's is refused at load, by name, with
both numbers printed. Return the macro, not the integer, and rebuild when it changes; it changes
with any shape change in a header a plugin compiles against (`rad_abi.h` lists them).
with any shape change in a header a plugin compiles against (`rad_abi.h` lists them), a field
appended to a struct included, and the release that ships the change assigns the number: a tree of
your own never bumps it for its own fields.
`rad_plugin_abi_layout` is a fingerprint of those headers' struct layouts as your plugin was
compiled (every struct's size and every field's offset and size, `rad_abi_layout_rows.h`). A plugin
whose fingerprint differs from the engine's under the same version -- built against another tree's
headers that gave a different layout the same number -- is refused with both fingerprints printed,
and so is one that does not export it. Every kind of plugin (kernel, architecture, quantiser)
exports both.
`build_target` is printed, not trusted: the targets the library was built for (`"gfx1100"`,
`"gfx11-generic"`, several separated by spaces or commas), `"host"` for CPU kernels, or `""` for a
@@ -436,6 +447,13 @@ blk.*.ffn_*_exps.*.weight myquant bits=3 group=64
quantiser does not declare is refused before anything is quantised. Two plugins naming the same
quantiser are refused, both named.
A quantiser that can use a card exports `int rad_quant_devices(const int* ids, int n)`
(`RadQuantDevicesFn`). `rad-convert --gpus 0,1` calls it once, before the first weight; without
the flag the plugin runs on the host. Which device a weight ran on is not recorded anywhere, so the
planes must be the host's byte for byte: libquant's trellis GPTQ keeps the host's operations and
their order on the card (`tests/quant_tcq_gpu_test.cpp` compares the two). Return
`RAD_E_UNSUPPORTED` from a build with no device path.
The core decodes the `plain` and `affine` schemes. Your own scheme is decoded by your `decode`
hook, which the oracle, `rad-kbench` and `rad-convert`'s error report use; return
`RAD_E_UNSUPPORTED` for a scheme you did not write. Serving a new encoding also needs a kernel
+53
View File
@@ -129,6 +129,8 @@ rad-convert [options] <input> -o <model.rad>
--changed FILE with --reuse: checkpoint tensors (one name a line) that differ from
the --reuse container's source; every weight that reads one is converted
--in-place with --reuse: extend that container instead of writing a new one
--gpus LIST the cards (HIP device numbers, comma separated) quantisers may run on;
large weights then run two at a time. The bytes are the host's
--plan-only declare, plan every weight's encoding, print the plan, and stop
--report N the worst N quantisation errors to print (default 20)
-v, --verbose
@@ -831,6 +833,17 @@ reference with the exact wire and a bf16 KV cache.
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.
**The sparse reference.** A full row is the vocabulary in f16, so ten million positions of a
248K-token vocabulary would be 5 TB. `--kld-record DIR --kld-top N` keeps, per position, the `N`
most likely tokens exactly (f32 log p) and the mass of every other token, summed from the full row
(one minus the head would cancel to noise on a confident position): 8 bytes a token, 4 KiB a
position at `N` = 512. `--kld-ref` reads the form from the manifest and scores the KL between the
two distributions coarsened to the reference's `N` tokens and one bucket for the rest. By the
data-processing inequality that is at most the full KL; it loses only how each model spreads the
tail inside the bucket, which is small where the reference's tail mass is small and nothing on a
confident position. The report's `ref_form` says which form a number was scored against, and
numbers from the two forms do not compare.
`--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
compared position by position.
@@ -842,6 +855,46 @@ with `PREFIX` through it and the rest as the base, in the same steps. The steps
all-adapter and all-base runs with the same flags, so each document's rows should be byte for byte
theirs: that is how a mixed batch is checked.
## The calibration mode
```
radiance --model BF16.rad ... --calib-corpus CORPUS.jsonl --calib-dir DIR [--calib-layers LO:HI]
```
Records GPTQ's Hessian, `H = sum over tokens of x x^T`, of the whole input of every linear in a
dense bf16 trunk (`qwen35_bf16`), over a corpus. Like the KL mode it replaces the server: every
document goes through prefill once, with the prefix cache and speculation off so that each corpus
token is counted exactly once. A document is submitted only while the whole lengths of those in
flight, its own included, fit the KV pool at once, so none is preempted (a re-prefill would count
its tokens twice), and a run that preempts all the same fails. The corpus is the KL mode's JSONL;
only `prompt` is read.
`--calib-dir` beside `--kld-record` (no `--calib-corpus`) records both in one run: the reference
over `--kld-corpus`, and the Hessians over the same tokens, fed the same way.
Under tensor parallelism a linear split by its input columns (`o_proj`, the delta net's
`out_proj`, `down_proj`) sees only its rank's columns, and a Gram of those is one diagonal block
of H. The tap gathers such an input to its whole width before taking the Gram, so the files hold
the whole matrix at any `--tp`. One rank records each layer (layer modulo the rank count): its card
sums a step's rows into an f32 scratch (`gram_accum`, upper triangle only), and the host adds the
step's sum into an accumulator of the packed upper triangle. The host holds every recorded input of
its rank, 786 MB a layer at Qwen3.8-27B (50 GB for 64 layers), so a large model is recorded in
several runs over the same corpus, each with its own `--calib-layers`; the run whose range ends at
the last layer also records the lm_head's input.
The files, written once the corpus is through: `DIR/<checkpoint prefix>.<layer>.<site>.safetensors`
per input, each holding `hessian_upper`, f32 `[k (k + 1) / 2]` (row `i`'s entries `k2 = i .. k-1`
after row `i-1`'s), with metadata `k`, `rows` and `linears`, the checkpoint linears that read the
input (q, k and v share one; so do gate and up). H is the raw sum: divide by `rows` for the mean
second moment.
```python
import numpy as np, safetensors.numpy as st
t = st.load_file("model.language_model.layers.3.mlp.down_proj.input.safetensors")["hessian_upper"]
k = int((np.sqrt(8 * t.size + 1) - 1) / 2)
H = np.zeros((k, k), np.float32); H[np.triu_indices(k)] = t; H = H + np.triu(H, 1).T
```
---
## The shell harnesses