Merge upstream main (v1.15.1 -> v1.17.0, 152 commits) into the SYCL port

Conflicts, both sides kept:
- abi: RAD_ABI_VERSION 37 (upstream); the fork's RadBuildCtx.plain_norm after upstream's
  expert_file_tier, widened to int64_t so it starts past ABI 37's 208-byte struct instead of in
  its tail padding (abi_layout_test); RadSyclStream rows after RadShapeGen*.
- arch/common/rad_block_gdn_fp8.h: upstream's q8_rot guard and the fork's o_plain guard
  combined; the decode-row q_o.step only where q_o is declared (!o_plain).
- docs/OPS.md: upstream's optional params on sample_logprobs, the fork's q_temp on
  mtp_couple_propose.

Also ignores /baseline-models/ (local model copies).

Host tests: arch_test's MTP lint/graph-pin failures are unchanged from before the merge (the
fork's mtp.fc LinearFP8, 10a99a5); avx_check's hand-built moe_gemm_q w4a8 case also fails on
upstream's own files; images/videos need FFmpeg; three binaries over their CPU budget on this VM.
SYCL card tests 3/3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
claudeandClaude Opus 5.5 committed 2026-11-07 22:13:08 +01:00
commit 45f3b510c7
365 files changed
+56942 -6331

No files matched your search

+383 -5
View File
@@ -18,11 +18,14 @@ 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, or Qwen's FP8 release as it ships |
| `arch/glm5next` | `glm5next` | *(empty)* | GLM-5.3-Flash from AMD's Quark MXFP4 export: four mHC residual streams over 34 KDA and 11 sparse latent-attention (MLA) layers with a DSA indexer, 288 MXFP4 experts at top-8 under sigmoid routing, block-FP8 attention and dense layers at f32 scales, each weight served as stored; its MTP layer is a serial drafter. Pictures through its vision tower (`arch/common/rad_block_glm_vision.h`); bf16 KV |
| `arch/bailing_hybrid` | `bailinghybrid` | *(empty)* | Ling-3.0-flash and its fine-tunes (Ling-3.0-flash-Sante) from the bf16 checkpoint: 35 KDA and 7 dense latent-attention (MLA) layers with a rotary part and a head-wise gate, 512 experts at top-8 under group-limited sigmoid routing with an ungated shared expert, the routed experts as the recipe stores them (`data/recipes/ling3-w4a8-rtn.recipe`); its MTP layer is a serial drafter; bf16 KV |
| `arch/nemotronh` | `nemotronh` | *(empty)* | Nemotron-3.5-Bolt-74B-A9B (`nemotron_h_omni` around `nemotron_h_puzzle`), its language model from the bf16 checkpoint: 40 Mamba-2, 40 latent-MoE and 8 NoPE attention blocks in the order `layers_block_type` gives, 240 to 496 ungated relu^2 experts a layer in a 1024-wide latent with a relu^2 shared expert; linears and experts as the recipe stores them (`data/recipes/nemotron74-fp8.recipe`, `nemotron74-w4nl64-gptq.recipe`); pictures and video through its C-RADIO tower (`arch/nemotronh/radio.h`); bf16 KV |
| `arch/lfm2_bf16` | `lfm2` | *(empty)* | LiquidAI's LFM2 and LFM2-VL, bf16, one rank |
| `arch/spark25_bf16` | `spark25` | *(empty)* | Spark X2.6, bf16 checkpoint, mixed sliding/full attention, TP1 or TP with exact collectives ([geometry](#spark25-spark-x26)). Optional DSpark drafter when the container already holds `draft.*` tensors, TP1 only. |
| `arch/embgemma2` | `embeddinggemma2` | *(empty)* | EmbeddingGemma 2: a bidirectional encoder with Gemma 4's vision tower and audio conformer, pooled to one vector |
| `arch/nomicbert` | `nomicbert` | *(empty)* | nomic-embed-text-v2-moe: a bidirectional post-norm encoder, 12 layers with 8 experts at top 2 on every second layer, mean-pooled to one vector an input |
| `arch/nemotron35_embed` | `mistral3` | *(empty)* | Nemotron 3.5 Embed 1B/8B and Rerank 8B: native BF16 bidirectional text/image retrieval with a Pixtral tower, TP1 ([geometry and contracts](#nemotron35_embed-embedding-models)) |
| `arch/gemma4_bf16` | `gemma4` | `compressed-tensors` | Gemma 4 31B dense, and the E2B/E4B form at one rank, with its vision tower: sliding-window and proportional-RoPE global (`attention_k_eq_v`) attention, GELU ffn, softcapped logits; int4 codes with an f16 scale per 128 from Google's CT-INT4 (QAT) release or from bf16, served w4a8, or int8 codes on the same grid from bf16 (w8a8, the Q8 container). Optional draft model (`rad-convert --draft-model`): Google's assistant, with no cache of its own (`rad_drafter_shared_kv`), or z-lab's DFlash drafter, the block `arch/gemma4` serves (`arch/common/rad_gemma4_dflash.h`), or RedHatAI's DFlash2 speculator (`arch/common/rad_block_dflash2.h`) |
| `arch/gemma4_bf16` | `gemma4` | `compressed-tensors` | Gemma 4 31B dense, the E2B/E4B form at one rank, and the 12B (`gemma4_unified`, its image and audio embedders in place of a tower), with its vision tower: sliding-window and proportional-RoPE global (`attention_k_eq_v`) attention, GELU ffn, softcapped logits; int4 codes with an f16 scale per 128 from Google's CT-INT4 (QAT) release or from bf16, served w4a8, or int8 codes on the same grid from bf16 (w8a8, the Q8 container). Optional draft model (`rad-convert --draft-model`): Google's assistant, with no cache of its own (`rad_drafter_shared_kv`), or z-lab's DFlash drafter, the block `arch/gemma4` serves (`arch/common/rad_gemma4_dflash.h`), or RedHatAI's DFlash2 speculator (`arch/common/rad_block_dflash2.h`) |
| `arch/gemma3` | `gemma3` | *(empty)* | Gemma 3 dense text (TranslateGemma 27B) from the bf16 checkpoint: sliding-window and global attention at one head geometry, GemmaRMSNorm, GELU ffn; linears bf16, or int8, MXFP4 or asymmetric int4 over an activation scaled per (row, 128), as the recipe stores them. Optional DFlash2 drafter (`rad-convert --draft-model`) |
| `arch/gemma4` | `gemma4` | *(empty)* | Gemma 4 text from Google's bf16 checkpoint (the 26B-A4B MoE and the dense sizes without per-layer embeddings) with z-lab's DFlash drafter; routed experts bf16 or block fp8 |
| `arch/qwenimage21` | `qwenimage21` | *(empty)* | Qwen-Image 2.1 and 2.1-Turbo, an image generator, from the diffusers pipeline directory; DiT and text encoder bf16 or block fp8 |
@@ -35,6 +38,7 @@ plugin claims.
| `arch/minimaxmusic3` | `minimaxmusic3` | *(empty)* | MiniMax-Music3, songs from a description and lyrics: a Qwen3-8B frame model, a depth decoder, a flow-matching DiT and a DAC vocoder, from the diffusers pipeline directory, bf16 |
| `arch/breeze` | `breeze` | *(empty)* | Breeze-TTS-2, speech from text and a description of the voice: a T5Gemma 2 text encoder, a Qwen3 backbone with a 16-codebook depth decoder and the Qwen3-TTS 12 Hz codec, from the release directory, bf16, one card |
| `arch/fishomni` | `fishomni` | `bsgemm-moe` | Fish Audio drama-3, speech from text with speaker tags and inline direction, its voices cloned from reference clips: the Qwen3.5-35B-A3B backbone with its routed experts block fp8 at f32 scales and everything else bf16, a 13-layer codebook tower over the backbone's full-attention cache, and Fish S2's modified DAC, encoder and decoder (`codec.pth`, read as data); from the release directory, two cards |
| `arch/hunyuan3d2` | `hunyuan3d2` | *(empty)* | Hunyuan3D-2's shape model (hunyuan3d-dit-v2-0), an untextured 3-D shape from one picture: DINOv2-giant over the picture, a FLUX-shaped flow-matching DiT (16 double-stream and 32 single-stream blocks of 1024) over a set of 3072 latents, and the shape VAE's geometry decoder, whose occupancy field the core samples on a grid and meshes; from the release folder (config.yaml and one safetensors), its fp16 weights cast to bf16 (`data/recipes/hunyuan3d-2-bf16.recipe`) |
| `arch/minimaxh3` | `minimaxh3` | *(empty)* | MiniMax-H3, a video with its stereo soundtrack from text, between keyframes or from reference media: Qwen3-VL-32B's language model as the text encoder, a 33B single-stream diffusion transformer, a tiled ViT video decoder and a BigVGAN audio decoder, from the diffusers pipeline directory; linears block fp8 (`data/recipes/minimax-h3-fp8.recipe`), or the DiT's per-token linears int8, served w8a8 (`minimax-h3-w8a8.recipe`); a curve-form checkpoint, whose timestep embeddings ship as a table, by the `minimax-h3-curve-*` recipes |
| `arch/ltx2` | `ltx2` | *(empty)* | LTX-2.5 (base and distilled), a video with its stereo soundtrack from text or from text and a first frame: Gemma 4's language model and two text connectors, the duration head, a dual-stream audio-video DiT with four-way guidance, the causal video VAE (tiled past the default canvas) or the diffusion decoder, the audio VAE with a BigVGAN vocoder and bandwidth extension, the x2 latent upsampler; bf16 or block fp8, one card |
@@ -68,6 +72,164 @@ comes first in one and second in the other. The tables, by plugin:
---
# `spark25`: Spark X2.6
`model_type: spark2_5` / `Spark2_5ForCausalLM`. The 4B checkpoint has 36 layers, hidden size
2560, 16 query heads and 4 KV heads at head dimension 256, a 10240-wide gated MLP and a tied
131072-token embedding. It has no q/k norms or projection biases. The residual is accumulated in
f32; norms write bf16 before the projections.
The checkpoint's fused Q/K/V matrix is split by rows in that order at conversion; gate and up are
joined in that order. The MLP uses **exact erf GELU**, not `gelu_mul`'s tanh approximation. Each
attention head's output is multiplied by its own sigmoid gate before the output projection.
`layer_types` is authoritative: sliding layers use window 512 and full-head NeoX rotary at theta
10000; full layers use 64 rotary dimensions at theta 5000000. Both use the full KV group, with the
window applied by the local attention op, so prefix caching remains valid.
## Tensor parallelism
A rank's attention slice is whole GQA groups, so a world that does not divide 4 KV heads still
shards cleanly: the three ranks of a 3-rank world take 2, 1 and 1 KV heads with the query heads
that belong to them. Above the KV-head count the KV heads are replicated and one group's query
heads are split between the ranks sharing its KV head, so every query head still attends the KV
head the checkpoint gave it -- a rank's own `gqa` can then be smaller than the checkpoint's, while
the KV cache it stores is a replica of its peer's. The gate and output projections take the
matching row and column spans, and the tied embedding and lm_head take the contiguous vocabulary
shard `rad_arch.h`'s `shard_begin` describes, because that is the split the sampler's candidate
merge assumes.
The FFN splits by channels, whole 128-column blocks where the width has them, and a rank's
`[gate | up]` keeps both parts the same width. Every split dimension is covered exactly once at
every world from 1 to 8, asserted in `spark25_arch_test`.
Column-sharded projection outputs are partial sums. Each layer issues two exact bf16
`all_reduce`s on the projection buffer, rounding the merged output to bf16 **before** widening it
and adding it to the f32 residual. This preserves the reference's BF16 projection-output boundary
without rounding away the residual's low bits. Sharding still changes the dot-product reduction
order, so it does not promise bitwise parity with one card. The embedding uses one exact f32
`all_reduce` over its widened, disjoint token rows. TP1 declares no collectives. At TP>1, declaration
requires the exact fp32 embedding reduction and every exact bf16 projection reduction to resolve;
otherwise it fails with `RAD_E_UNSUPPORTED` rather than running rank-local partial outputs. libr4d
serves these collectives at 2, 3, 4 and 8 ranks; other widths resolve only on a library with a
general `all_reduce` (libref), so a card deployment is limited to those worlds.
Both plugins reject multi-rank declarations if a required exact collective cannot be resolved;
otherwise a missing reduction would silently leave rank-local projections in the residual.
The tokenizer and its template come from the checkpoint; the architecture declares the
`<think>`/`</think>` reasoning markers and the `<tool_call>name<arg_key>...` tool-call format.
Other gate activations and rotary-scaling overrides are not implemented.
## Rotated int8 (IQ8R)
`arch/spark25_w8a8` serves a trunk whose linears use the fwht128-rotated int8 grid: per-128 int8
activation codes feed `i8a8h` GEMMs, while the embedding and small per-head gate remain BF16 and
normalisation gains remain FP32. Exact GELU runs before the down projection's separate Hadamard
quantiser. The output head may be BF16 or a separately quantised int8 table. The descriptor is
`w8a8_fwht128`; the container must set `quantization_config.quant_method=w8a8` and
`quantization_config.fmt=fwht128`.
The full recipe, `data/recipes/spark-x26-4b-iq8r.recipe`, is an explicit speed/size tradeoff, not a
quality-preferred default. `data/recipes/spark-x26-4b-iq8r-keep12.recipe` leaves layers 0–11 in
BF16 and is the tested quality-preferred allocation (6.09 GB / 5.67 GiB). The full IQ8R container
is 4.52 GiB; BF16 is 8.29 GiB. The measured comparison used top-128-plus-tail KL, with the full
variant's maximum 11.883 and keep12's maximum 0.247 over 31,391 held-out positions. These are
coarsened distribution-parity measurements, not full-vocabulary KL or task-benchmark scores. The
source revision and replay commands, tail details, hashes, calibration/evaluation provenance, and
limits are in [`SPARK25-IQ8R.md`](SPARK25-IQ8R.md). The cited numbers require the shared prefill
softmax fix #362 (`7480da3d46b0475d9d77966e31284cc19072759`); they are not evidence for standalone
#363 without that prerequisite.
The BF16 plugin records the calibration Grams with `RADIANCE_CALIB_DIR`, `RADIANCE_CALIB_TOKENS`,
and `RADIANCE_SPARK_CALIB_LAYERS=lo:hi`; use TP=1 to retain off-diagonal cross-rank terms. Drive
a representative corpus through prefill with prefix caching and speculation disabled. Each layer
slice writes six RADGRAM2 files. The published calibration manifest and dataset revision are
recorded in [`SPARK25-IQ8R.md`](SPARK25-IQ8R.md); calibration completeness is not a measure of
quality.
A column-sharded input must have a 128-column-aligned offset and width. When possible, FFN sharding
partitions whole 128-channel groups with a ragged remainder-first split. Spark's 10,240-channel FFN
has 80 groups, so TP=3 gets 27/27/26 groups and is aligned; TP=3 is not inherently refused. The
architecture rejects a particular computed span only if it is not group-aligned. Actual serving
also requires the selected kernels and collectives to support the world size. `tests/spark25_iq8r.py`
compares a deterministic quantised fixture with the Transformers reference, including top-10
probabilities across cached decoding; `--wide-tp --tp N` checks aligned attention/FFN shards for
N=1..8. Use a GPU-denying device cgroup for this CPU fixture on shared machines.
## DSpark drafting
Both Spark plugins declare a DSpark graph when the container already carries `draft.*` tensors
(the presence of `draft.markov_w1.weight` is the switch). Building that container from XHToken's
standalone GGUF is not in this change.
The container's `draft.target_layer_ids` are the ids of the layers that *consume* each tap, so they
are one above the taps `arch/spark25_bf16` and `arch/spark25_w8a8` copy out of the residual stream:
3, 11, 19, 26 and 34 become the taps after layers 2, 10, 18, 25 and 33. The drafter's five
`fc_norm` rows -- one gain per tap -- are the `fc_norm_t0` ... `fc_norm_t4` vectors the graph
declares.
`arch/common/rad_block_dspark_bf16.h` is the drafter's graph, declared by both Spark plugins after
the trunk when the container carries `draft.markov_w1.weight`. It is its own block: the MiniCPM5
DSpark block (`rad_block_dspark.h`) has Q/K norms, SiLU and an fp8 activation grid, and Spark's has
none of those. Per pass it encodes the taps the trunk copied into `dflash_src` (each tap RMS-normed
by its own `fc_norm_t<i>`, concatenated, projected by `fc`, normed by `output_norm_enc`), embeds the
anchor token, runs the five bf16 sliding-window layers over the drafter's own KV group, then scores
the vocabulary through the trunk's tied table. At each position, the rank-256 Markov head adds
`sum_r w1[previous,r] * w2[token,r]` to the draft-head logit for **every** vocabulary token and
greedily selects the greatest biased score (ties to the lower token id); that selected token is the
next position's predecessor. This follows the pinned reference's serial greedy walk, not a top-K
walk or joint-path heap. The head writes F32 logits before the walk, but numerical identity is not
established: the reference CPU chooses the last equal maximum, its GPU reduction has backend-specific
tie ordering, and this graph chooses the lower token id. Reduction order can also change near-tie
results; real reference proposal parity remains unvalidated. A
retained confidence projection is not used: it neither rescales logits nor changes proposals;
adaptive depth is not implemented by this fixed-depth graph.
Sliding attention uses a separate `attn_paged_anchor_window` operation because ordinary
`attn_paged` measures its window from each query row. For a configured 512-token history, the
reference uses `n_swa = 513`: every draft query shares the anchor's exact inclusive key range,
`[anchor - 512, anchor]` for causal attention, or the anchor's lower cutoff and the staged context's
upper end for non-causal attention. The same 513-token width is declared for attention, the drafter
KV group and scheduler staging; cache recycling and rollback boundaries still require independent
runtime validation. Both new operations have distinct names, so an older device library that
does not implement these semantics refuses the graph rather than resolving a similar-looking op.
The drafter is declared only at one rank: its `fc` is unsharded and its head scores the full
vocabulary, so a `--tp` above 1 is refused at declaration rather than served half-sharded.
DSpark's acceptance, latency and throughput on this exact graph are not measured yet (figures taken
with an approximate window and a candidate-pruned walk do not carry over); run the QoS harness below
before quoting any. The W8A8 caller shares the bf16 drafter graph. Verification against the target
does not by itself show that drafting keeps acceptance, latency or the generated text under every
serving schedule.
`scripts/dspark_qos_regression.py` is an unvalidated two-server QoS harness, not evidence that
runtime gates pass. In particular, it treats missing metrics as zero, aggregate proposed versus
accepted counts cannot prove a partial rejection, and a stop finish reason does not prove an
explicit stop sequence was encountered. `--prefix-cache-mib 0` does not disable the VRAM prefix
cache; use `--no-prefix-cache` for that. See `docs/DSPARK-370-DEVICE-FOLLOWUP.md` for the
limitations and serial diagnostic receipts. Controlled KV rollback/eviction, acceptance quality,
and QoS measurements remain open; CPU tests and matching sample text cannot establish them.
For a CPU differential against the reference implementation's `configuration_spark.py` and
`modeling_spark.py`, with Python's torch, transformers and safetensors installed:
```sh
python3 tests/spark25_reference.py --reference /path/to/XHToken-Spark-X2.6-4B --build build
python3 tests/spark25_reference.py --reference /path/to/XHToken-Spark-X2.6-4B --build build --tp 3
SPARK25_REFERENCE_TEMPLATE=/path/to/XHToken-Spark-X2.6-4B/chat_template.jinja \
build/tests/spark25_chat_test
```
The first builds a small deterministic checkpoint and compares prefill, chunked prefill and cached
decode against the reference with GPUs hidden; `--tp` runs the same fixture over that many fake host
ranks, which is how the sharding and the collectives are checked without cards. ROCm may still open
GPU device nodes while probing even with visibility masks; on a shared machine run the CPU
comparison in a device cgroup that denies access to `/dev/kfd` and the GPU render nodes. The last
also exercises the checkpoint's actual chat template, which is not redistributed in this tree.
---
# `llama`: the plain decoder
`model_type: llama` with `LlamaForCausalLM`. Every layer is full attention; unlike `qwen35_fp8`
@@ -593,12 +755,14 @@ Traps:
- **MTP concatenates the normalized embedding first,** the normalized previous hidden second.
- **No RoPE anywhere** (`qk_rope_head_dim` 0); the indexer's only rotation is the Hadamard.
**KV groups.** Five, all bf16 or wider; a `--kv-cache-dtype` other than bf16 is refused at
declare.
**KV groups.** Five. `--kv-cache-dtype fp8` narrows `kv_latent` alone to E4M3, stored at
`kv_store`'s default descale of 1 and read by the `mla_attn` fp8kv rows (docs/OPS.md); the other
four keep the dtypes below whatever the flag, and a cache dtype other than bf16 or fp8 is refused
at declare.
| group | kind | per layer | layers |
|---|---|---|---|
| `kv_latent` | `RAD_KV_FULL`, bf16, 1 head of 256, block 4 | the 512-wide normed latent, its two halves in the K and V slots | 11 MLA + MTP |
| `kv_latent` | `RAD_KV_FULL`, bf16 (E4M3 under fp8), 1 head of 256, block 4 | the 512-wide normed latent, its two halves in the K and V slots | 11 MLA + MTP |
| `kv_dsa_index` | `RAD_KV_FULL`, u8, block 4 | one page a pooled key: 128 E4M3 codes and their f32 scale (`dsa_pool`'s cache form) | 11 MLA + MTP |
| `kv_index_tail` | `RAD_KV_LINEAR`, bf16, `[4 + spec, 256]` | the key and gate rows not yet pooled; the ring is wider by the draft depth so a rejected draft rolls back | 11 MLA + MTP |
| `kv_kda` | `RAD_KV_LINEAR`, f32, 128 x 128 a head | the recurrent state, 64 / tp heads a rank | 34 KDA |
@@ -608,7 +772,7 @@ The latent and the index are replicated: every rank keeps the whole latent cache
declares both so (`rad_kv_group_replicated`), which lets the host tier (`--prefix-cache-mib`) hold
each once a slot: 49.59 KiB a 4-token block at any rank count (`kv_latent` 48.00 KiB over its 12
layers, `kv_dsa_index` 1.59 KiB), 12.4 KiB a token, where a copy per rank would make a slot
396.75 KiB at eight. The model is a hybrid, so a prefix-cache hit is usable only from a state
396.75 KiB at eight. Under fp8 `kv_latent` is 24.00 KiB a block, 6.4 KiB a token in all. The model is a hybrid, so a prefix-cache hit is usable only from a state
checkpoint at or below it, and `--checkpoint-interval` decides how much of a shared system prompt
is reused.
@@ -812,6 +976,82 @@ the four depths above.
---
# `bailing_hybrid`: Ling-3.0-flash
`arch/bailing_hybrid` serves Ling-3.0-flash (`model_type: bailing_hybrid`, BailingMoeV3ForCausalLM)
and its fine-tunes from the bf16 checkpoint. The reference is vLLM's `bailing_moe_v3.py` and
SGLang's; the HF `modeling_bailing_moe_v3.py` agrees except for the SwiGLU clamp (below). The plugin
reuses GLM-5.3's KDA core (`KdaState`), sigmoid router (`GlmRouter`, with groups) and draft head
(`GlmMtp`), and `MoeFP8`; its KDA and MLA blocks are in the plugin file.
```
42 layers, hidden 2560, vocab 157184 (embedding and lm_head separate), rope_theta 6e6
layers 5, 11, ..., 41 ((l + 1) % 6 == 0): dense MLA
q 2560 -> 32 x (128 nope + 64 rope), no q LoRA; kv_a 2560 -> 512 + 64: the latent (RMS-normed)
and the rotary key, both cached; kv_b 512 -> 32 x (128 + 128)
rotary over 64 dims, interleaved pairs (HF de-interleaves, then rotates by halves): `gptj`
scores scaled by 1/sqrt(192); a sigmoid gate per head (2560 -> 32); o 4096 -> 2560 (`dense`)
the other 35 layers: KDA, 32 heads of 128
q, k, v 2560 -> 3 x 4096, each with a causal depthwise conv of width 4 + SiLU
forget gate per channel, full rank (`f_proj` 2560 -> 4096, no_kda_lora), lower bound -5
(safe gate); beta per head (2560 -> 32); output gate full rank (`g_proj`), sigmoid-gated
RMS norm per head
feed-forward: layers 0-1 dense SwiGLU 2 x 6144; layers 2-41 MoE
512 routed experts of 768 at top-8, sigmoid scores, correction bias (`expert_bias`), 8 groups of
64 ranked by the sum of their two best biased scores, 4 kept (noaux_tc); weights normalized
and scaled by 2.5; one shared expert of 768 without a gate
SwiGLU clamped where `expert_swiglu_limit_list` / `share_expert_swiglu_limit_list` say: the
routed experts at 4 in layers 35-41, the shared one at 5 (34-39) and 7 (40-41)
MTP: checkpoint layer 42 -- enorm, hnorm, eh_proj 5120 -> 2560, one MLA layer with the full MoE,
final_layernorm; the trunk's embedding and lm_head
```
Traps:
- **The clamp is taken after the SiLU.** vLLM (`SwigluStepAndMul`) and SGLang compute
`min(silu(gate), L) * clamp(up, -L, L)`; GLM-5.3's `swiglu_clamped` clips the gate before the
SiLU, which at L = 4 caps a large gate at `silu(4) = 3.93` instead of 4. The plugin issues
`swiglu_step`. HF's reference model ignores the lists entirely; the served form is the one the
checkpoint is evaluated with. The routed and the shared arm clamp at different values, often in
different layers (`MoeFP8::Config::shared_swiglu_limit`).
- **Routing is group-limited.** `router_sigmoid_group_topk`: a group's rank is the sum of its two
highest `p + bias`, only the experts of the four best groups are candidates. A single-group
top-8 picks other experts with every shape valid.
- **The query is two projections.** The checkpoint's q rows are per head [nope 128 | rope 64]; the
plugin maps them as two weights (row maps over `q_proj`) into two plain planes, `[T, 32 * 64]`
for `rope` and `[T, 32 * 128]` for the absorption. A single `[T, 32, 192]` plane with column
views turns the wrong rows on libavx, whose `rope` reads a rank-3 operand's head stride as its
row stride.
- **The cache row is [latent | rotary key].** One KV head of 288, the row's first half in the K
slot and the second in the V slot, so `kv_store` writes the 576-wide row contiguously and
`mla_attn_paged` reads it as `[pages, 1, block, 576]`. Scores are taken in the latent; the head
gate multiplies the attention's latent output before the expansion, a reordering of HF's gate on
the expanded values that only rounding tells apart.
- **The pre-tokeniser's pattern has possessive quantifiers** (`[^\r\n\p{L}\p{N}]?+\p{L}+`,
` ?[^\s\p{L}\p{N}]++[\r\n]*`). Both are one class followed by classes that share no codepoint
with it, which the tokenizer compiles as greedy (core/text/tokenizer_regex.cpp); the ids match
HuggingFace's.
**KV groups.**
| group | kind | per layer | layers |
|---|---|---|---|
| `kv_latent` | `RAD_KV_FULL`, bf16, 1 head of 288, block 16 | the 512-wide normed latent and the 64-wide rotated key | 7 MLA + MTP |
| `kv_kda` | `RAD_KV_LINEAR`, f32, 128 x 128 a head | the recurrent state, 32 / tp heads a rank | 35 KDA |
| `kv_kda_conv` | `RAD_KV_CONV`, bf16, width 4 | the convolution history, 3 x 4096 / tp channels a rank | 35 KDA |
The latent is replicated: every rank computes and stores the whole row.
**Tensor parallelism.** At 1, 2 or 4 ranks. KDA and MLA split their 32 heads (with them the q/k/v
rows, the convolution taps and the state; the MLA's q, kv_b and gate rows and o's columns); kv_a
and the latent are replicated. The dense feed-forward splits its 6144 columns. A routed expert's
768 columns are six 128-column blocks: halves at two ranks, and at four 2, 2, 1, 1 blocks rotated
by the expert's number mod 4 (`moe_gemm_q_mod4`), so every rank carries six blocks per four
experts. The shared expert splits the same way, unrotated. A calibration run
(`RADIANCE_CALIB_DIR`) and bf16 experts give every rank whole experts instead.
---
# Sample size
Top-1 agreement between two numeric formats is one Bernoulli trial per prompt, so at p ≈ 0.93 its
@@ -1305,6 +1545,31 @@ gemma-4-E2B-it) at one rank:
- The vision tower's clipped linears (`use_clipped_linears`) clamp each projection's input and
output to the bounds the checkpoint stores (`rad_block_gemma4_vision.h`).
**The 12B form.** Gemma 4 12B (`gemma4_unified`, served through the arch id's alias) has no vision
tower and no audio encoder; `rad_block_gemma4_unified.h` holds what replaces them:
- A picture's patch is a whole 48 x 48 pooling window, its values u / 255 (the processor's Gemma 4
family with merge 1). The embedder is a LayerNorm over the patch, a linear with its bias, a
LayerNorm, the column's and the row's learned rows, a LayerNorm, the weightless RMS norm and a
projection. The LayerNorms take nn.LayerNorm's eps of 1e-5, which no config states. The position
table `[1120, 2, width]` is read as its two taps of dimension 1, computed at convert, so a
container needs a recipe rule to store them (`gemma4-12b-bf16`, `gemma4-12b-i8g`). One patch is
one row: `--mm-max-patches` counts rows here, and 1120 holds the largest picture.
- An audio clip is frames of 640 samples (40 ms at 16 kHz) as they are, the last zero-padded, one
token each: a weightless RMS norm and a 640 -> width projection. A clip is cut at
`audio_seq_length` (750 frames, 30 s).
- **A picture's rows read both ways.** With `use_bidirectional_attention: "vision"` (the 12B and the
31B) a picture's or video frame's placeholders attend to each other both ways on the sliding
layers; the global layers stay causal. That is transformers' Gemma 4 mask
(`create_masks_for_vision_model`), KerasHub's and vLLM's; transformers' `gemma4_unified` forward
overlays every layer, which differs little on most pictures. The scheduler ends no prefill chunk
inside such a run (`Scheduler::bidi_fit`), the trunk pass names its runs (`RadBatch::n_bidi`), and
each sliding layer attends a run's rows a second time with `attn_paged` at `causal` 0 over the
cache up to the run's end, written over their causal result. The window stays, as in
transformers' mask (the window AND (causal OR the same picture)): it bounds the keys behind a row.
A run longer than the window (1120 soft tokens against 1024) is read with `attn_paged_ahead`, whose
window bounds the keys behind only, so its first rows see the run's far end. Read causally, the 12B answers pictures differently and often wrongly (on DocVQA, "The image does not
provide information" for an answer it reads off the page).
NVIDIA's DFlash drafter states `dflash_config.causal: false`, with every layer sliding; that flag
sets the sliding layers' causality. The recipes are `gemma4-e4b-bf16-df`, `-w8a8-df`, `-w4a8` and
`-w4a8-df`. The bf16 container's KL to HF bf16 is 0.0015 with bf16 KV and 0.014 with fp8 KV, so
@@ -1805,6 +2070,79 @@ same model and this engine 0.8%. The transcripts match word for word.
---
# `nemotronh`: Nemotron-3.5-Bolt-74B-A9B
`arch/nemotronh` serves the language model of Nemotron-3.5-Bolt-74B-A9B (`model_type:
nemotron_h_omni`, NemotronH_Omni_Reasoning_V3; the text model is `llm_config`, `nemotron_h_puzzle`)
from the bf16 checkpoint. The reference is vLLM's `nemotron_h.py` and `mamba_mixer2.py`; NVIDIA's HF
`modeling_nemotron_h.py` agrees except for the CPU scan (below). The plugin reuses `MoeFP8` for the
routed arm and `AttnFP8` for attention; its Mamba-2 block and the latent feed-forward around
`MoeFP8` are in the plugin file.
```
88 blocks, hidden 4096, vocab 131072 (embedding and lm_head separate), RMS eps 1e-5; each block one
mixer behind its own norm and a residual add, the type from `layers_block_type`
40 Mamba-2: 128 heads of 64 in 8 groups, state 128
in_proj 4096 -> z 8192 | x 8192 | B 1024 | C 1024 | dt 128, no bias
x|B|C through a causal depthwise conv of width 4 with bias, then SiLU
dt' = softplus(dt + dt_bias), unclamped; A = -exp(A_log); a D skip per head
y = scan(x, B, C, dt'); RMSNormGated: norm over groups of 1024 of y * silu(z), times 8192 gains
out_proj 8192 -> 4096
40 latent MoE: router on the normed hidden state (sigmoid, a correction bias for the selection
only, one group, top-9, normalized, x5)
fc1_latent_proj 4096 -> 1024; routed experts in the latent, ungated: down(relu(up(x))^2);
per layer (`block_configs`) 240 to 496 experts of 1536 to 2560; fc2_latent_proj 1024 -> 4096
one shared expert on the hidden state, 4096 -> 5376 -> 4096, relu^2
8 attention: 32 query heads, 2 KV heads of 128, no position encoding
```
Traps:
- **The layer count is not stated.** `llm_config` has no `num_hidden_layers`; HF derives it from
`block_configs`. The checkpoint reader counts `layers_block_type` when the key is absent, and
flattens the array of objects `block_configs` into `block_configs.<l>.<field>`, from which the
plugin reads each routed layer's experts, width and top-k.
- **dt is not clamped.** `time_step_limit` is (0, inf), and vLLM passes exactly that to its scan.
HF's CPU path `torch_forward` clamps dt' below at `time_step_min` (0.001), which in the first
layers moves 13 % of the (token, head) steps, and it is also wrong past its first 128-token chunk
(the state handoff between chunks): HF on the CPU is no reference beyond 128 tokens.
- **The gated norm normalises the product, per group.** `norm(y * silu(z)) * w` with the RMS over
1024 channels (8 groups of the 8192), not `norm(y) * w * silu(z)` (the delta net's
`gdn_gated_rmsnorm`). Served as `act_mul` (silu), a gainless `rmsnorm` over rows of 1024 and
`mul_weight`; a rank's heads are whole groups.
- **The router reads the hidden state, the experts the latent.** `MoeFP8` runs at the latent width
(`Config::router_k` sizes the router, `Wire::route` feeds it); fc2 is linear and has no bias, so
each rank applies it to its partial latent sum and one all-reduce over the hidden width sums the
routed and shared arms (`Config::no_reduce`).
- **relu^2 is `act_mul`'s relu over one operand twice:** relu(x) * x, rounded once, which is
torch's `relu(x) ** 2` in bf16 bit for bit.
- **The bf16 checkpoint has no BOS in its template.** Its chat template sets none, as llama.cpp
does for the MoE form.
**KV groups.**
| group | kind | per layer | layers |
|---|---|---|---|
| `kv_attn` | `RAD_KV_FULL`, bf16, 2 / tp heads of 128 (1 at four ranks, replicated over a pair), block 16 | keys and values | 8 attention |
| `kv_ssm` | `RAD_KV_LINEAR`, f32, 64 x 128 a head | the recurrent state, 128 / tp heads a rank | 40 Mamba-2 |
| `kv_ssm_conv` | `RAD_KV_CONV`, bf16, width 4 | the convolution history, (8192 + 2048) / tp channels a rank | 40 Mamba-2 |
| `kv_draft` | `RAD_KV_WINDOW` (1024), bf16, 2 / tp heads of 128 (1 at four ranks, replicated over a pair), block 16 | the LiLiCorr drafter's keys and values | its 5 layers, past the trunk |
**Speculation.** With drafts the scan keeps `ssd_update`'s anchor form (the committed state and a
scratch of per-token records: decay, `dt' x`, B), at most 31 drafts a step. NVIDIA's LiLiCorr block
drafter proposes 7: 32 query heads over 2 KV heads of 128, which four ranks replicate as the trunk's
attention does (`drafter_geom`'s `kv_repl_ok`: each rank reads its head's k and v rows at `kv_off`,
and `attn_paged_sink` runs at gqa 8 instead of 16). A verify's 8 query rows run the trunk's
attention in the split-KV decode kernel a plain decode runs, at gqa 16 (one and two ranks) in eight
waves as at gqa 8 (four) in four, so each row is the single-row decode at its position bit for bit
while each of the split law's segments holds one 16-key tile (a context up to 2048 tokens: 256
segments at a decode, 128 at a verify). Past that the partition differs and a near-tie can flip
greedy text, as `ident.sh` allows ([TOOLS](TOOLS.md)).
**Vision.** `arch/nemotronh/radio.h` serves the C-RADIO (v4-H) tower and its `mlp1` projector when
the container holds them (`vision_config.model_type` `radio`): pictures, and video in tubelets of
two frames, through `core/mm`'s `Radio` family.
# `minimaxmusic3`: MiniMax-Music3, songs
`arch/minimaxmusic3` declares an audio generator (`rad_declare_audio_generator`), which makes the
@@ -2337,3 +2675,43 @@ with and without a first frame; diffusers on CUDA and on the CPU differ from eac
On an R9700 (libr4d) the same five renders land within 0.15% of diffusers' CUDA rows, every op
agreeing with its host reference under the op oracle. Block fp8 moves the random model's rows by
0.2 to 0.4% (the card's fp8a8 GEMMs, the CPU's fp8 codes widened to bf16).
# `hunyuan3d2`: Hunyuan3D-2, a 3-D shape from a picture
`arch/hunyuan3d2` declares a shape generator (`rad_declare_shape_generator`), which makes the
program one the engine drives through `core/gen/shape_driver.h`: SCOND runs the image encoder over
the picture and `cond_in` over its rows and over the unconditioned branch's zeros, into the lane;
SSTEP is one denoising step of both branches together; SLATENT runs the shape VAE's latent network
and leaves the geometry decoder's keys and values in the lane; each SQUERY pass is the geometry
decoder at up to 32768 points the core chose. The core samples the grid coarse to fine (FlashVDM's
hierarchical decoding with full attention) and meshes the finest level with marching cubes. A
request is a lane; two hold state at once. It is served on Hunyuan3D-2's own routes, `/generate`,
`/send` and `/status/{uid}` ([GUIDE §5.17](GUIDE.md)), bf16 on one card. The checkpoint is the
release's hunyuan3d-dit-v2-0 folder: config.yaml (its keys under their dotted paths) and one
safetensors holding `model.`, `conditioner.` and `vae.`.
```
picture the alpha's box at 85% of the picture's square, centred on white (OpenCV's INTER_AREA),
512 x 512 (INTER_CUBIC), then 518 x 518 (bilinear) normalised by ImageNet's statistics,
in 37 x 37 patches of 14 x 14, f32 into the patch projection
encoder DINOv2-giant: 40 layers of 1536 (24 heads of 64), LayerNorm eps 1e-6, SwiGLU 4096 with
biases, layer scales on both branches, the class token and a learned position table;
the last hidden state after the final LayerNorm, 1370 rows. The unconditioned branch is
zeros, so its rows after cond_in are cond_in's bias
DiT FLUX's layout without a rotary: 16 double-stream blocks (the conditioning and the latent
each with their own weights, one joint attention) and 32 single-stream blocks
(linear1 = [qkv | mlp], linear2 over [attn | gelu_tanh(mlp)]), width 1024, 16 heads of
64, q and k RMS-normed per head (eps 1e-6), LayerNorms without affine modulated as
(1 + scale) LN(x) + shift with gates and no tanh. The timestep embedding is the sinusoid
of 1000 sigma at a period of 1000 (the reference passes its time factor where
timestep_embedding takes max_period), then time_in. Rows a step: [cond | latent] for
the picture's branch and [latent | cond] for the unconditioned one, so each branch is
one attention run and the two latents one run for the latent stream's ops
sampler flow matching from sigma 0 (noise) to 1: Euler on numpy's linspace(0, 1, steps), the
last grid point's evaluation (a zero step in the reference) skipped; guidance 5
VAE latent / scale_factor, post_kl 64 -> 1024, 16 self-attention blocks (q, k, v and the
geometry decoder's k, v are head-interleaved in the checkpoint and gathered per head at
conversion; per-head LayerNorms on q and k, exact GELU MLP 4096)
geometry a point's [x | sin | cos] at 8 octaves (51 values, f32, point_fourier), query_proj, one
cross-attention block over the latent rows (its own MLP), ln_post (eps 1e-5), a logit
```
+8 -2
View File
@@ -7,7 +7,8 @@ Docker, an AMD GPU and an `amdgpu` kernel driver that supports ROCm 10.1. It doe
compiler or FFmpeg.
The image is published as [`stilldeadcode/radiance`](https://hub.docker.com/r/stilldeadcode/radiance),
with its kernels built for `gfx1201`: `docker pull stilldeadcode/radiance`. Build it yourself for
with its kernels built for RDNA4 (`gfx1201`, libr4d), RDNA3 (`gfx11-generic`, libr3d) and Strix Halo
(`gfx1151`, libhalo): `docker pull stilldeadcode/radiance`. Build it yourself for
other cards or another commit. The examples below use `radiance`, the tag a local build gets; with
the published image, write `stilldeadcode/radiance` instead.
@@ -26,7 +27,7 @@ docker/build.sh -j 8 # cap compile jobs (a device kernel takes
docker/build.sh -J 4 # tests at a time (default: the compile jobs)
docker/build.sh -B 5 # every test's CPU budget times 5, for a host slower per thread
docker/build.sh -E tokenizer_perf_test # leave tests matching a regex out of the test stage
docker/build.sh -t 'gfx1200;gfx1201' # GPU architectures to compile kernels for (default gfx1201)
docker/build.sh -t 'gfx1200;gfx1201' # GPU architectures (default 'gfx1201;gfx11-generic;gfx1151')
docker/build.sh -r <commit> # any other commit
docker/build.sh --target build # stop at a stage, tagged radiance-<stage>
```
@@ -143,13 +144,18 @@ the cards the engine runs on.
| `sage-a1.5-mxfp4-df2.yaml` | `sage-a1.5-mxfp4-df2.rad` | The same with the trunk, the experts and the drafter at MXFP4; ten 262,144-token sessions |
| `qwen3.8-27b-fp8.yaml` | `qwen3.8-27b-fp8.rad` | Qwen3.8-27B FP8 with its DFlash2 drafter and vision tower |
| `qwen3.8-27b-mxfp4.yaml` | `qwen3.8-27b-mxfp4.rad` | Qwen3.8-27B with AMD's Quark AWQ-MXFP4 trunk, its DFlash2 drafter and vision tower |
| `qwen3.8-27b-iqr-v4.yaml` | `qwen3.8-27b-${IQR_V4}.rad` | Qwen3.8-27B in IQR-V4 at the size `IQR_V4` names (default `iq4r-s-v4`), its DFlash2 drafter and vision tower |
| `qwen3.8-27b-paro.yaml` | `qwen3.8-27b-paro-int4.rad` | Qwen3.8-27B ParoQuant int4 (learned rotations) with its DFlash2 drafter and vision tower, on one card; the int5 and MXFP4 containers serve from it too |
| `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 |
| `gemma4-31b-heretic-ara-w4a8.yaml` | `gemma4-31b-heretic-ara-w4a8.rad` | The same for Gemma 4 31B heretic-ara (refusals removed) |
| `gemma4-12b-bf16.yaml` | `gemma4-12b-bf16.rad` | Gemma 4 12B in bf16, its assistant head as the MTP drafter, pictures and audio through the 12B's embedders, on two cards |
| `gemma4-12b-i8g.yaml` | `gemma4-12b-i8g.rad` | The same with the trunk at int8 (i8a8), on one card |
| `nemotron-3.5-bolt-e4b-bf16.yaml` | `nemotron-3.5-bolt-e4b-bf16.rad` | NVIDIA-Nemotron-3.5-Bolt-E4B (Gemma 4 E4B) in bf16 with NVIDIA's DFlash drafter, the vision tower in pinned host memory, on one card |
| `nemotron-3.5-bolt-e4b-i8g.yaml` | `nemotron-3.5-bolt-e4b-i8g.rad` | The same with the trunk at int8 (i8a8) |
| `nemotron-3.5-bolt-e4b-a4.yaml` | `nemotron-3.5-bolt-e4b-a4.rad` | The same with the feed-forward at four bits (GPTQ), attention and layers 19-23 at i8a8 |
| `nemotron-3.5-bolt-74b-w4a8.yaml` | `nemotron-3.5-bolt-74b-w4a8.rad` | NVIDIA-Nemotron-3.5-Bolt-74B-A9B with four-bit experts and a block-FP8 trunk, NVIDIA's LiLiCorr drafter, vision, on two cards |
| `nemotron-3.5-bolt-74b-fp8.yaml` | `nemotron-3.5-bolt-74b-fp8.rad` | NVIDIA-Nemotron-3.5-Bolt-74B-A9B in block FP8 with NVIDIA's LiLiCorr drafter, vision, on four cards |
| `translategemma-27b.yaml` | `translategemma-27b-mxfp4-gptq.rad` | TranslateGemma 27B MXFP4 with its chat template (`gemma3.jinja`) |
| `glm53-flash.yaml` | `glm53-flash-mxfp4.rad` | GLM-5.3-Flash, MXFP4 experts and block-FP8 attention, on eight cards |
| `minicpm5-2b.yaml` | `minicpm5-2b-fp8.rad` | MiniCPM5-2B FP8 with its DSpark drafter |
+162 -32
View File
@@ -316,6 +316,7 @@ and runs.
| `fishomni` | Fish Audio drama-3, speech from text with speaker tags and inline direction (§5.15) |
| `minimaxh3` | MiniMax-H3 and FastH3, video with its stereo soundtrack from text (§5.16) |
| `ltx2` | LTX-2.5, video with its stereo soundtrack from text or a first frame (§5.16) |
| `hunyuan3d2` | Hunyuan3D-2's shape model, an untextured 3-D mesh from one picture (§5.17) |
**4. Falling back to the reference library is fatal.** If any op resolves to `libref`, the engine
refuses to start and names the ops, because serving from it is orders of magnitude slower with nothing
@@ -708,7 +709,8 @@ radiance --model m.rad --debug-placement # the placement plan only
The card is split into resident weights and the paged KV pool. The engine derives the split from the
card and the model; no flag states either pool. Its inputs: `--gpu-headroom-mib` leaves card space
alone, `--max-model-len` and `--max-num-seqs` bound the cache, and `--host-pool-mib` decides which
alone, `--gpu-memory-mib` claims a size (headroom is the card less that; give one of the two),
`--max-model-len` and `--max-num-seqs` bound the cache, and `--host-pool-mib` decides which
experts must stay on the card. The startup receipt prints every term. With no visible card (the host
backend) half of RAM stands in for the card and is split the same way; the weights pool is then host
memory, holding the weights a host kernel cannot read where the container stores them.
@@ -784,6 +786,7 @@ Related flags:
```sh
--gpu-headroom-mib 96 # VRAM left unclaimed on every card
# --gpu-memory-mib 28000 # the same knob as a claim; not with --gpu-headroom-mib
--kv-cache-dtype fp8 # halve what a token of context costs (a real quantisation)
--host-pool-mib 8192 # pinned host tier for weights
--embedding-placement vram # keep the token embedding on the card (below)
@@ -859,15 +862,35 @@ the pinned total is twice the table: set `amdgpu.no_system_mem_limit=1` (the cap
and 1.5 GiB) or the second pin can be refused. The kernel charges the tmpfs pages to the memory
cgroup of the engine that filled them.
`--ngram-placement disk=DIR` reads the table from its own file, `DIR/ngram-<id>.bin`, instead of from
the container: a table on a faster or separate drive (an Optane beside a model on a large NVMe, or a
model on a hard disk with its table on an SSD) at no host memory. The first start fills the file from
the container (the table's size free in `DIR`, written under `.part` and renamed, so the real name is
always complete); later starts check samples of it against the container and reuse it. The `<id>` is
`ram=DIR`'s, so a file never serves another model; remove the file to have it filled again. Reads go
to it as `disk` reads the container, through the row cache with direct I/O, so `DIR`'s filesystem must
support `O_DIRECT` (tmpfs since Linux 6.6 does, but a tmpfs is what `ram` is for).
**`--weights-disk-tier`** serves a model larger than the card and the host pool together, with every
step paced by the drive. A routed expert that fits neither lives only in the container. Before each
routed layer's first expert op, on every pass, the engine reads all that layer's on-disk experts into
one of two VRAM buffers (a router's picks are not known on the host, and a prefill chunk routes to
nearly all of them). The buffers come out of the weight budget (the plan's `file buffers` line), and
the reads go through four 32 MiB pinned windows out of `--host-pool-mib`, as long runs that skip
resident experts. It is meant for running a checkpoint as shipped, to calibrate or compare against.
The bf16 Qwen3.8-Flash-Next (335 GiB) runs on two cards at about 28 s a step, the same at one token as
at 32K, so use large prefill steps:
routed layer's first expert op, on every pass, the engine reads the layer's on-disk experts that its
rows route to into one of two VRAM buffers: the layer's router has run by then, and its counts are
copied back first (one wait on the card per routed layer), so an expert no row routes stays on the
drive. A step whose rows route nearly every expert, 64 rows an expert on average (3277 tokens for
Qwen3.8-Flash-Next's 512 experts at top-10), reads its layers whole instead, each one while the card
computes the one before, with no wait on the card. The buffers come out of the weight budget (the
plan's `file buffers` line), and the reads go through four 32 MiB pinned windows out of
`--host-pool-mib`, as long runs that skip resident experts. Without `--deterministic` the host pool
is also a cache of the drive: an expert read from it is kept in a free pool slot, and a full pool
gives its coldest expert back to the drive for a warmer one. It is meant for running a checkpoint
as shipped, to calibrate or compare against. The bf16 Qwen3.8-Flash-Next (335 GiB) runs on two
cards at about 28 s a 32K-token step, so use large prefill steps:
GLM-5.3-Flash lays its routed experts out by what the deployment needs. At four and eight cards each
MXFP4 expert is split by width across every card, the shape its kernels are tuned for, and every expert
must then fit in VRAM and the host pool. A container with any expert in another format stays whole. `--weights-disk-tier` keeps them whole on one card each, so they
can stay on the drive, at about a third of the prefill speed and two thirds of the decode speed on 4 x
R9700. Two cards always keep them whole.
```sh
rad-convert /srv/models/Qwen/Qwen3.8-Flash-Next -o flashnext-bf16.rad --max-ctx 4096 # no recipe: bf16
@@ -884,9 +907,10 @@ plane grows into what it releases, so a model whose experts do not fit never str
for unused cache.
**Headroom.** `--gpu-headroom-mib` is kept for allocations the engine does not make, chiefly a
kernel's code object, which HIP loads at the kernel's first launch. With too little left, the first
kernel that has never run (a draft head's, a sampler chain's) fails its load and faults inside the
HIP runtime: a segfault in a correct kernel on a server that had been serving.
kernel's code object, which HIP loads at the kernel's first launch. `--gpu-memory-mib N` is the same
knob written as a claim: headroom is the card less N. The two flags cannot be combined. With too
little left, the first kernel that has never run (a draft head's, a sampler chain's) fails its load
and faults inside the HIP runtime: a segfault in a correct kernel on a server that had been serving.
Once everything is allocated, startup logs `card N settled at ... free`. Memory taken after the budget
read the card (another process such as a desktop, or a driver allocation) comes out of the headroom,
@@ -911,8 +935,9 @@ takes the model's training context.
`--kv-cache-dtype fp8` is an E4M3 cache with per-(sequence, head) descales. It halves what a token of
context costs, which at a production context is most of the pool. It is a real quantisation that
changes the output slightly, so it is only ever set explicitly. Every architecture serves both
widths except GLM-5.3-Flash (`glm5next`), whose latent-attention cache is bf16 only and which refuses
`fp8` at startup. The flag sets every attention cache of the deployment, a drafter's (DSpark,
widths. On GLM-5.3-Flash (`glm5next`) `fp8` narrows the latent-attention cache alone, to E4M3 at a
descale of 1 (half its bf16 size); the DSA index, its key tail and the KDA caches keep their own
widths. The flag sets every attention cache of the deployment, a drafter's (DSpark,
DFlash2) included. The delta-net state and the QSA indexer's key tail are recurrent state and keep their own
widths.
@@ -1127,8 +1152,27 @@ chunk's time, and every sequence decoding beside it waits that long for its next
`--prefill-interleave 2`, after a step that carried a chunk while other sequences were decoding,
the next two steps carry decode rows only and admit nothing, then the next chunk is scheduled. The prompt's time to first token grows by those steps and the
decoders keep their cadence. A lone prefill is not held, nor is the step after a prompt's last
chunk. `0` (the default) schedules as before. `/stats` counts the decode-only steps the hold
inserted as `steps_held`, `/metrics` as `radiance:engine_steps_held_total`.
chunk. `0` schedules as before. `/stats` counts the decode-only steps the hold inserted as
`steps_held`, `/metrics` as `radiance:engine_steps_held_total`.
Served default: `--prefill-interleave auto:1` (below), so decoding sessions keep about half their
rate while prompts prefill; `--deterministic`, KL mode and generators keep 0, and an explicit `N`
or `auto[:SHARE]` is kept as given. Measured on Qwen3.8-Flash-Next (fp8, TP2, MTP 3, 8 sessions
decoding beside 64K prompts): 12.3 -> 40.9 decode tokens/s a session, aggregate prefill 3.7K ->
1.8K tokens/s, time to first token 17 -> 36 s. `--prefill-interleave 0` restores the old schedule.
`--prefill-interleave auto` sizes the hold from measured step times instead: after each such chunk,
as many decode-only steps as fit in a quarter of a chunk step's time at a decode step's (running
means of both, at most 64 steps; one until a decode step has been timed). `auto:SHARE` uses SHARE
of the chunk step's time instead of a quarter (0 < SHARE <= 4; `auto:1` gives decode as much time
as prefill). With the quarter the prefill gives up at most a fifth of its rate however many
sequences decode, and the decoders get several steps where a decode step is cheap beside a chunk,
none where one costs more than that quarter (they still ride every chunk). In the scheduler's host simulation of 32 prompts of 128K tokens sent at once, each
then decoding 512 tokens (2048-token chunks, MTP 3, step costs fitted to a lone prefill and to
decode alone), auto raised the decode rate of the sequences decoding while prompts still waited
from 6.5 to 31 tokens/s each and delayed the last first token by 6 %. Because the hold follows the
device's timing, which steps carry a chunk differs from run to run; a number schedules the same
steps every time.
**A prefill alone in its step can carry several intervals** (`--prefill-span N`, default 1). A
chunk ends on every checkpoint interval, so a prompt is otherwise prefilled one interval a step.
@@ -2045,8 +2089,8 @@ by 0.002-0.003 nats.
| flag | default | |
|---|---|---|
| `--max-num-batched-tokens N` | 2048 | largest token count one step may carry |
| `--prefill-interleave N` | 0 (off) | decode-only steps after each prefill chunk while other sequences decode (§4.5), at most 64 |
| `--preempt-wait-ms N` | 5000 | how long a preempted prefill may wait for its whole-recompute gate before reclaiming cache blocks and preempting lowest-priority running requests until one overdue request can prefill; `0` falls back on the next step |
| `--prefill-interleave N` | auto:1 (0 under `--deterministic`, KL mode, generators) | decode-only steps after each prefill chunk while other sequences decode (§4.5), at most 64; `auto` fits them in a quarter of the chunk step's measured time, `auto:SHARE` in SHARE of it (0 < SHARE <= 4); `0` lets every step carry a chunk |
| `--preempt-wait-ms N` | 5000 | how long a preempted prefill may wait for its whole-recompute gate before reclaiming cache blocks and preempting lowest-priority running requests until one overdue request can prefill; `0` falls back on the next step. A preempted request publishes what it computed to the prefix cache, as a finished one does, so its recompute adopts its prompt instead of computing it again; under pressure the cache gives those blocks back, the newest last, before another request is preempted |
| `--busy-prefill-chunk MODE` | auto | a prefill chunk's share of a step that has other work: `auto` leaves decode rows and waiting requests their room (§4.5), `off` takes the whole step, `N` holds it to N tokens |
| `--max-num-seqs N` | 256 | largest number of sequences one step may carry |
| `--max-model-len N` | 0 | context bound; 0 takes the model's training context |
@@ -2057,6 +2101,7 @@ by 0.002-0.003 nats.
| flag | default | |
|---|---|---|
| `--gpu-headroom-mib N` | 96 | VRAM left unclaimed on every card |
| `--gpu-memory-mib N` | 0 (use `--gpu-headroom-mib`) | VRAM claimed on every card; inverse of `--gpu-headroom-mib`. Give one (§4.3) |
| `--kv-cache-dtype T` | bf16 | `bf16`, `fp8`, or on Qwen3.8-27B and Qwen3.8-Flash-Next `fp8_v4` or `k6_v4` (§4.4) |
| `--state-cache-dtype T` | f32 | `f32` or `f16`: the recurrent (delta-net) state cache; f16 halves the state memory and is lossy, `qwen35` plugins only (§4.4) |
| `--attn-prefill-fp8 MODE` | off | `off`, `qk`, `pv` or `both`: the prefill attention's Q·Kᵀ, P·V or both in E4M3 over an `fp8`, `fp8_v4` or `k6_v4` cache; lossy, Qwen3.8-27B (§4.4) |
@@ -2064,7 +2109,7 @@ by 0.002-0.003 nats.
| `--kv-resident N` | 0 (off) | stream the sparse attention group's KV from pinned host memory, keeping a ring of N tokens on the card. Raised to 32 768 and to one decode step's selection; a ring that covers the context streams nothing. Ignored with a warning on an architecture that cannot stream (§4.4.1, [KV-STREAMING.md](KV-STREAMING.md)) |
| `--host-headroom-mib N` | 4096 | host RAM left free for the system when startup pins host memory — kept for the unpooled allocations, staging and page cache (§4.3). A snapshot store's floor takes back the shortfall from it, down to 1 GiB, rather than come up with none (`--checkpoint-slots`, §4.8) |
| `--embedding-placement WHERE` | ram | `ram` or `vram`: the token embedding pinned in host memory beside `--host-pool-mib` and read in place, or on the card (§4.3) |
| `--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) |
| `--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); `ram=DIR` shares the RAM copy between engines, `disk=DIR` reads the table from its own file in `DIR` |
| `--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 |
@@ -2132,7 +2177,7 @@ by 0.002-0.003 nats.
| `--allow-host NAME` | — | a `Host` name the keyless loopback-only routes accept besides the loopback names; repeatable (§6.6) |
| `--trusted-proxy CIDR` | — | a network whose sockets may name the client behind them, via `X-Forwarded-For`, for the log; vouching changes attribution, never access; repeatable (§6.6) |
| `--served-model-name NAME` | container's name | the model id `/v1/models` lists, the metrics carry and a response names when its request named none. A request may name any model; the loaded one serves it |
| `--mm-max-patches N` | auto | patches one vision-encoder pass carries, and so the largest image (a patch is 16x16 pixels, 14x14 on GLM-5.3). `auto` is 16384 when the container carries a vision tower; 0 serves text only and keeps the tower off the card. A pass is not one tower invocation: inside it the tower batches at most 8 tiles per weight read, and the pass size may reduce that (4 tiles at the 64-pixel grid with the default 16384 patches); a picture contributes a separate pass per grid. See the concurrency notes for Unlimited-OCR (§5.17) |
| `--mm-max-patches N` | auto | patches one vision-encoder pass carries, and so the largest image (a patch is 16x16 pixels, 14x14 on GLM-5.3). `auto` is 16384 when the container carries a vision tower; 0 serves text only and keeps the tower off the card. A pass is not one tower invocation: inside it the tower batches at most 8 tiles per weight read, and the pass size may reduce that (4 tiles at the 64-pixel grid with the default 16384 patches); a picture contributes a separate pass per grid. See the concurrency notes for Unlimited-OCR (§5.18) |
| `--override-chat-template PATH` | container's | a Jinja chat template file served in place of the container's. The reply format (reasoning markers, tool calls) is derived from it too, unless the architecture plugin declares one. An unreadable or empty file stops startup |
| `--max-queued-requests N` | 8 × `--max-num-seqs` | requests admitted and unfinished at once; past it, 429 |
| `--http-threads N` | one per hardware thread, at least 4 | HTTP workers kept while idle |
@@ -2229,6 +2274,7 @@ flags are refused on it, and so are the pixel bands.
| `POST /v1/audio/speech` | OpenAI's speech API, whole or streamed: speech from a speech model (Breeze-TTS-2, `instructions` describing the voice; drama-3, speakers and direction in the input); songs from a music model (MiniMax-Music3), `input` the lyrics and `instructions` the song; else 501 (§5.15) |
| `GET /v1/audio/speech/stream` (WebSocket) | vLLM-Omni's realtime speech session: text streamed in, each sentence's audio streamed out as soon as the sentence is complete; needs an audio generation model (§5.15) |
| `POST /v1/videos`, `GET /v1/videos[/:id[/content]]`, `DELETE /v1/videos/:id` | OpenAI's video jobs: a video with its soundtrack from a prompt, made in the background and downloaded as MP4; needs a video model (MiniMax-H3), else 501 (§5.16) |
| `POST /generate`, `POST /send`, `GET /status/:uid` | Hunyuan3D-2's API server's routes: a 3-D mesh (GLB, OBJ, PLY or STL) from a picture, at once or in the background; needs a shape model (Hunyuan3D-2), else 501 (§5.17) |
| `POST /v1/messages`, `POST /v1/messages/count_tokens` | Anthropic's Messages API, for Claude Code and the Anthropic SDKs (§5.9, §5.11) |
| `POST /v1/responses`, `POST /v1/responses/input_tokens` | OpenAI's Responses API, for Codex and the OpenAI SDKs' `responses` client (§5.9) |
| `POST /completion`, `/completions`, `POST /infill` | llama-server's native completion and fill-in-the-middle, for llama.vim, llama.vscode and clients of llama-server's own API (§5.9) |
@@ -2638,7 +2684,7 @@ passes but not launches (the UNet runs once per image and branch), so two take t
|---|---|
| `model` | accepted and not enforced: one server serves one model |
| `messages` / `prompt` / `input` | chat / completion / embedding |
| `images_config` | image models only: the processor mode the request wants, by name (`gundam`, `base`) or as an object restating the served sizes; a geometry the model does not serve is refused (Unlimited-OCR, §5.17) |
| `images_config` | image models only: the processor mode the request wants, by name (`gundam`, `base`) or as an object restating the served sizes; a geometry the model does not serve is refused (Unlimited-OCR, §5.18) |
| `max_tokens`, `max_completion_tokens`, `n_predict` | default: what the context leaves after the prompt (`--default-max-tokens`); -1 is llama-server's "no limit", the same without the default. Clamped to what the context leaves, and to `--max-tokens-cap`, rather than refused (§5.8) |
| `temperature` | [0, 2] |
| `top_p` | (0, 1] |
@@ -2856,6 +2902,7 @@ each field is read, taken without effect, or refused by name.
| `role: "system"` in `messages` | after the head of the conversation, its text joins a user message at its position, since templates read a system message only at the head: as a text block ahead of the user message right after it, else after the one right before it, else as a user message of its own, so no two user turns follow each other. `clear_at: "next_user_message"` stops rendering it once a later user message (a `tool_result`-only one included) exists. An effort-only message (no text, `output_config: {"effort": ...}`) sets the effort from the next user message on. Blocks other than text (`tool_addition`, ...) are refused |
| `tools`, `tool_choice` | client tools; server tools (`web_search_…`, `code_execution_…`) are refused. `tool_choice` as an object (`auto`, `any`, `tool`, `none`, `disable_parallel_tool_use`) or a string (`"auto"`, `"none"`, `"any"`); `any` is the chat path's `required` (§5.4) |
| `max_tokens`, `temperature`, `top_p`, `top_k`, `stop_sequences`, `stream` | as on the chat path; `max_tokens` is optional there too |
| `min_p`, `presence_penalty`, `frequency_penalty`, `repetition_penalty`, `repeat_last_n` | not Anthropic's: the chat path's fields with its ranges and meaning (§5.7), for clients that speak only this format. The penalties count a token's occurrences in the last `repeat_last_n` tokens of prompt and reply (64 by default, `--repeat-last-n`), as llama.cpp does |
| `thinking` | `enabled` (its `budget_tokens` is the chat request's `thinking_token_budget`), `adaptive`, `disabled`, `between_tools` (off). `display` and `block_binding` are taken: the reasoning comes back whole, with an empty `signature` |
| `output_config` | `effort` (`low`, `medium`, `high`, `xhigh`, `max`) is the chat request's `reasoning_effort`, which the template reads in its own level names: a level it does not take is refused with the ones it does, and `--reasoning-effort-map` renames them (§4.9). `format` (`{"type": "json_schema", "schema": ...}`, or the older top-level `output_format`) is a `response_format` (§5.5). `task_budget` is taken |
| `context_management` | validated; the conversation is served as sent, and the answer says so: `"context_management": {"applied_edits": []}`, on `message_delta` in a stream |
@@ -3526,7 +3573,53 @@ The MP4's soundtrack is 48 kHz stereo. LTX-2.5 runs on one card; `--tp` above 1
Gemma 4 text encoder (13 GiB in fp8) does not fit a 32 GB card beside the DiT: serve it with
`--vision-tower-placement ram`, which keeps it in pinned host memory and reads it once a prompt.
### 5.17 Documents: Unlimited-OCR
### 5.17 3-D shapes: `/generate`
A shape generation model (Hunyuan3D-2) makes an untextured 3-D mesh from one picture of an object.
It answers Hunyuan3D-2's own API server's routes, so that server's clients (its Blender add-on,
scripts written against it) work unchanged: `POST /generate` makes the shape while the request
waits and answers with the file; `POST /send` makes it in the background and answers at once with
`{"uid": ...}`; `GET /status/{uid}` reports `{"status": "processing"}` (with `steps_done` of
`steps`), then `"completed"` with the file as base64 in `model_base64`, or `"error"` with its
`message`.
```sh
# The shape model is tencent/Hunyuan3D-2's hunyuan3d-dit-v2-0 folder: config.yaml and
# model.fp16.safetensors. Its weights ship in fp16 and are cast to bf16 at conversion.
rad-convert Hunyuan3D-2/hunyuan3d-dit-v2-0 --recipe data/recipes/hunyuan3d-2-bf16.recipe \
-o hunyuan3d-2-bf16.rad
radiance --model hunyuan3d-2-bf16.rad
curl -s http://localhost:8000/generate -H 'Content-Type: application/json' \
-d "{\"image\": \"$(base64 -w0 penguin.png)\"}" -o penguin.glb
```
- **`image`** is the picture as base64 (a data URL is taken too). Give it an alpha channel that cuts
the object out: the reference removes an opaque picture's background with rembg first, which this
server does not, so an opaque picture is taken whole, background and all. The picture is prepared
as the reference prepares it: the alpha's bounding box scaled to 85% of the square that holds the
picture, centred on white, 512 x 512, then the image encoder's 518 x 518.
- **`num_inference_steps`** counts sigma grid points (50, so 49 evaluations, by default; 2 to
200); **`guidance_scale`** is the classifier-free guidance against the unconditioned branch (5
by default); **`seed`** makes a shape repeatable (1234 when absent, as the reference).
- **`octree_resolution`** is the grid's cells a side the field is sampled on (256 by default, 16
to 512). The grid is sampled coarse to fine, as FlashVDM's hierarchical decoding does: the whole
grid at the coarsest level (the resolution halved while it stays at least 63), then only the
points near the surface at each finer level; with `"volume_decoding": "dense"` every point of
the finest grid is sampled instead, as the reference's default decoder does (slower, the same
field). The surface is marching cubes over the finest grid at level 0.
- **`type`** is the file: `glb` (the default; positions, smooth normals and faces), `obj`, `ply`
(binary) or `stl` (binary). The mesh is the raw surface, as the reference's `/generate` returns
it without texturing: no floater removal or face reduction.
- **`texture`** true (Hunyuan3D-Paint) is refused: this server makes the untextured shape. So are
the reference's `text` (its text-to-image front end) and `mesh` (re-texturing) inputs.
A shape is about 3 TFLOP of conditioning, 18 TFLOP a denoising step (both branches) and 34 MFLOP
a sampled grid point. The model runs on one card (2.2B parameters, 4.4 GiB in bf16); `--tp` above 1
is refused. The licence (Tencent Hunyuan 3D 2.0 Community License) does not cover the European
Union, the United Kingdom or South Korea.
### 5.18 Documents: Unlimited-OCR
`unlimited-ocr` (baidu/Unlimited-OCR, bf16; the converted container is
[Aijuus/unlimited-ocr-bf16](https://huggingface.co/Aijuus/unlimited-ocr-bf16), with its recipe;
@@ -3608,7 +3701,7 @@ completions entry point), so prompt parity with the reference is a chat-endpoint
### 6.1 The dashboard
Open `http://<host>:<port>/` in a browser. It has three tabs.
Open `http://<host>:<port>/` in a browser. It has four tabs.
**Dashboard**: the live strip across the top (decode step time, decode and prefill throughput,
requests in flight, KV cache in VRAM, draft acceptance), then cards for the batch, memory and
@@ -3619,7 +3712,7 @@ The KV cache meter splits what it holds into two segments:
```
KV cache 3.3 / 4.5 GiB · 75.5%
▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
20.8k tok read by running requests · 369.3k kept for reuse
20.8k tok read by running requests | 369.3k kept for reuse
```
The full-strength segment is context running requests are reading; the dim segment is prefix cache,
@@ -3630,7 +3723,7 @@ from the total fill, since a full pool causes preemption.
The decode step tile carries two figures and a percentage under the big number:
```
best 14.79ms · recent 15.21ms · now 97% of best
best 14.79ms | recent 15.21ms | now 97% of best
```
Both are window means of single-sequence decode steps, measured by the engine:
@@ -3674,14 +3767,17 @@ The decode, prefill, requests-in-flight and draft-acceptance tiles carry a line
which the page computes from its own polls:
```
best 58 · recent 54 · now 93% of best@c4
best 58.0 | recent 54.0 | now 93% of best@c4
```
`best` (`highest` on requests in flight and acceptance) is the extreme this page has seen at the
current concurrency, `recent` the mean of its last 30 samples there (15 s at one poll every 500 ms;
5 s for prefill), and `now` the current value as a share of the extreme. Past one sequence the line
current concurrency, `recent` the mean of the last 15 s there (5 s for prefill), and `now` the
current value as a share of the extreme. The windows are kept by elapsed time rather than sample
count, so a span means the same span whatever rate is set on Advanced. Past one sequence the line
names its concurrency (`@c4`); requests in flight keeps a single set. Reloading the page resets these
figures, a server restart does not. While nothing runs, the big figure reads 0 and the line keeps its
figures, and so does a server restart: the page notices the engine's new start time and
inherits nothing from the run before it. While nothing runs, the big figure reads 0 and the line
keeps its
last figures without `now`.
Draft acceptance is reported as two ratios with different denominators. A draft position is
@@ -3689,8 +3785,8 @@ verified only when every earlier one passed, so:
- **accepted / reached** (conditional): of the drafts verified at a position, the share that passed.
The acceptance tile, the Speculation panel's large "conditionally accepted" figure and the
per-position bars show it. The headline is the last poll's; the tile's `recent` pools the last 30
polls that drafted as a ratio of sums.
per-position bars show it. The headline is the last poll's; the tile's `recent` pools the polls
that drafted in the last 15 s as a ratio of sums.
- **accepted / drafted**: of every drafted token, the share that became text, since the process
started. The Speculation panel's "Accepted of drafted", `draft_accept` on `/stats` and
`radiance:draft_acceptance_ratio` on `/metrics` show it.
@@ -3700,6 +3796,30 @@ passing 56%, 75% and 77% of the time they are reached, a step reaches 1 + 0.56 +
positions on average and accepts 0.56 + 0.42 + 0.32 = 1.30 tokens: 66% accepted / reached against
1.30 / 3 = 43% accepted / drafted.
Under the live request table, **history** keeps every finished request a poll saw. A request is in
`/stats` only while it exists -- a finished row leaves the payload within about 20 ms to half a
second -- so without this the numbers would be gone before they could be read. The last 200 are
kept in this browser's `localStorage`, not on the server, and rows are keyed by the engine's start
and the request id, so a second tab or a reload keys a request alike rather than counting it twice.
A request that began and finished between two polls cannot be sampled at all; those are counted in
a grey row so the total still adds up. **clear** empties it, and the marker it leaves is a
timestamp every tab honours, so a clear in one window is a clear in all of them.
The line above the table summarises those rows: how many are done, then decode rate, prefill rate
and time to first token. The first two carry their mean over all the rows and, where enough
rows exist, the same mean over the last 20 and the last 5; time to first token is a median
over all the rows, with no windows. A window appears only once enough rows
exist for it to be a different question: with 12 rows stored, the mean over the last 20 would just
be the mean over all 12, so only *last 5* shows. At exactly 20 rows *last 20* repeats the overall
mean; from 21 up the three figures are three different questions.
These are means of per-request rates, not the pooled rate the tiles above show: one long request
does not get to decide the headline. On this line a dot separates one category from the next and a
pipe separates the windows within a category.
The download icon beside the **Requests** heading saves those stored rows as
`radiance-history.json`, indented, from the browser -- it is the same data **clear** would discard,
so a run worth keeping can be written out before it is cleared.
**Sessions**: one row per stored conversation: how many tokens, which tier it is in, and whether its
linear half is still reachable. Sizes overlap and cannot be added: two sessions sharing a system
prompt share its blocks.
@@ -3709,6 +3829,14 @@ scheduler clamps reuse to the last linear checkpoint. That verdict is the tab's
**Model**: the resolved graph: every op, which library serves it, and what did not resolve.
**Advanced**: two editable poll intervals -- *Idle interval* while nothing runs and *Busy interval*
while a request is in flight, each clamped to 100-5000 ms. Set them equal for one fixed rate; the
summary beside the panel title names what is set. The values live in the browser, not on the
server, so they
survive a restart and apply to this browser only. Polling pauses on every view but Dashboard, so
the figures hold while you are reading another page -- for about a minute. Past 60 s the
next poll drops the windows, since there is nothing left to compare them against.
### 6.2 The JSON behind it
```sh
@@ -3778,7 +3906,9 @@ Two pitfalls:
- Step time is not wall-clock over steps. Use `engine_step_seconds_decode_total /
engine_steps_decode_total`, which charges only decode; wall-clock also charges idle and prefill.
`deploy/grafana/radiance.json` charts both families over time, on Prometheus or VictoriaMetrics.
`deploy/grafana/radiance.json` charts both families over time, on Prometheus or VictoriaMetrics. Its first screen shows
totals over the selected time range (prompt tokens in, prompt tokens read from cache, prompt tokens
computed, tokens out, requests) and the live status; the detail panels are below.
### 6.4 The live terminal view
@@ -3895,7 +4025,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.15.1
I STARTUP REPORT -- radiance 1.17.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]
+51
View File
@@ -169,3 +169,54 @@ int8 grid both share.
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).
## IQR-V4: measured widths, a vocabulary-weighted head and faster kernels
IQR-V4 keeps V3's computed trellis and its one f32 scale a row, and changes how the bits are spent and
how the GEMMs read them. GPTQ runs in act order inside the column trellis (`tcq_order=1`: the columns
are fitted in descending Hessian diagonal and the codes stored in column order), and the FFN weights'
trellis runs grow to 512 or 1024 rows (`tcq_rows`). The projections the attention heads feed
(`attn_output`, `ssm_out`) take a bf16 scale a (row, 128) block from five bits up (`group=128
scale=bf16 dyn=1`), where V3's code reached its resolution first. The widths come from measured
prices: each band of eight layers and projection is priced by the KL a width step costs it, measured
at the 2/3-, 3/4- and 4/5-bit boundaries and shrunk halfway to the model's prices, and layer 63's
`ffn_gate_up`, the one tensor whose price is several times its band's, sits one width up (the V4S
entries, to IQ3R-L); from IQ4R-S up the model's prices are as good and are kept (V4W).
The vocabulary edges carry about a tenth of every entry's bytes. The lm_head's KL weighs each
vocabulary row by its token's probability, so below IQ6R-L the head is vocabulary-weighted: its rows
are four width classes of the computed trellis (`output.k<B>`, a 256-row run a class, chosen by the
row's probability-weighted output error at a 4.0, 4.5 or 5.0 b mean; `data/vhead/`, `tools/vhead.py`),
decoded in one launch by `logits_gemm_vocab` with the head input held at 16 bits and the logits
gathered back into vocabulary order. At 1 to 16 tokens it is faster than the int8 head it replaces.
IQ6R-L-V4 to IQ8R-V4 keep the int8 head, now GPTQ'd against the head's input Hessian, which costs no
bytes and lowers the median KL about 10%.
The kernels: the one-token GEMV gives each 16-row tile a block whose waves split K, so a GEMM's tiles
finish together instead of trailing off on a few long waves; a 16-token tile without block barriers serves 2 to 16 tokens; and
the activation quantisers after `gate_up`, the delta net's decode fold and the attention gate are folded
into the kernels that produce their input. On Qwen3.8-27B at TP1 IQ4R-S-V4 decodes one stream 4% faster
than the MXFP4 checkpoint at 5x lower KL, and IQ3R-S-V4 is faster at every concurrency.
| recipe | bpw | KL mean | top-1 | V3 at that size | its bpw | its KL | KL |
|---|---:|---:|---:|---|---:|---:|---:|
| `q38-27b-iq8r-v4` | 8.040 | 0.00046 | 99.22% | IQ8R-V3 | 8.040 | 0.00047 | -2% |
| `q38-27b-iq7r-v4` | 7.420 | 0.00059 | 99.15% | IQ7R-V3 | 7.420 | 0.00060 | -2% |
| `q38-27b-iq6r-l-v4` | 6.939 | 0.00068 | 99.08% | IQ6R-L-V3 | 6.939 | 0.00072 | -6% |
| `q38-27b-iq6r-v4` | 6.439 | 0.00081 | 98.96% | IQ6R-V3 | 6.372 | 0.00088 | -8% |
| `q38-27b-iq6r-s-v4` | 6.063 | 0.00100 | 98.86% | IQ6R-S-V3 | 6.049 | 0.00106 | -6% |
| `q38-27b-iq5r-v4` | 5.433 | 0.00154 | 98.60% | IQ5R-V3 | 5.422 | 0.00182 | -15% |
| `q38-27b-iq5r-s-v4` | 5.071 | 0.00223 | 98.33% | IQ5R-S-V3 | 5.064 | 0.00249 | -10% |
| `q38-27b-iq4r-l-v4` | 4.793 | 0.00297 | 98.07% | IQ4R-L-V3 | 4.783 | 0.00342 | -13% |
| `q38-27b-iq4r-v4` | 4.473 | 0.00444 | 97.69% | IQ4R-V3 | 4.458 | 0.00512 | -13% |
| `q38-27b-iq4r-s-v4` | 4.142 | 0.00643 | 97.12% | IQ4R-S-V3 | 4.131 | 0.00762 | -16% |
| `q38-27b-iq3r-l-v4` | 3.804 | 0.00917 | 96.61% | IQ3R-L-V3 | 3.798 | 0.01129 | -19% |
| `q38-27b-iq3r-v4` | 3.472 | 0.01495 | 95.74% | IQ3R-V3 | 3.459 | 0.01698 | -12% |
| `q38-27b-iq3r-s-v4` | 3.157 | 0.02241 | 94.75% | IQ3R-S-V3 | 3.145 | 0.02584 | -13% |
| `q38-27b-iq2r-l-v4` | 2.797 | 0.03602 | 93.29% | IQ2R-L-V3 | 2.786 | 0.04241 | -15% |
| `q38-27b-iq2r-v4` | 2.470 | 0.06113 | 91.23% | IQ2R-V3 | 2.465 | 0.06807 | -10% |
IQ4R-L-V4 is 24% below the official FP8 checkpoint's KL (8.766 bpw, 0.00389) at 55% of its size, and
IQ2R-L-V4, at 2.8 bpw, is below the AWQ-tuned MXFP4 checkpoint (4.994 bpw, 0.03824). The design, the
kernels and the measurements are in the IQR-V4 technical report
(radiance.stilldeadco.de/whitepapers/iqr-v4.pdf).
+9363 -2377
View File
File diff suppressed because it is too large. Load diff
+205 -13
View File
@@ -205,10 +205,12 @@ at once. Run it before adding a kernel plugin; the loader names only the first c
| `layernorm` | `M`(range) `n` `eps`:f64 `dtype` | `x`, `w`w, `b`w? → `y` |
| `grid_embed` | `M`(range) `n` `side` `dtype` | `x`:inout, `table`w, `coord` |
| `grid_embed_aa` | `M`(range) `n` `side` `dtype` | `x`:inout, `table`w, `coord` |
| `grid_embed_cpe` | `M`(range) `n` `side` `dtype` `n_prefix`/opt | `x`:inout, `table`w, `coord`, `prefix`w? |
| `add` | `M`(range) `n` `dtype` `div`:f64/opt | `a`, `b` → `y` |
| `mul` | `M`(range) `n` `dtype` | `a`, `b` → `y` |
| `silu_mul` | `M`(range) `n` `dtype` | `gate_up` → `y` (splits `[M,2n]` into gate·up) |
| `swiglu_clamped` | `M`(range) `n` `limit`:f64 `dtype` | `gate_up` → `y` |
| `swiglu_step` | `M`(range) `n` `limit`:f64 `dtype` | `gate_up` → `y` |
| `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) |
@@ -266,6 +268,13 @@ clip.
libr4d's `swiglu_clamped_bf16` serves bf16 in and out at any width, pitched rows, `M` up to
65535.
`swiglu_step` clips in the other order, as Ling-3.0 is served by vLLM and SGLang (vLLM's
`SwigluStepAndMul`): `min(silu(gate), limit) * clamp(up, -limit, limit)` in f32, rounded once. The
SiLU is taken first and its value clipped above, so a gate far past `limit` gives exactly `limit`
where `swiglu_clamped` gives `silu(limit)` (3.93 at a limit of 4). HF's reference model for Ling-3.0
ignores the clamp; the served form is the one checkpoints are evaluated with.
libr4d's `swiglu_step_bf16` serves it as `swiglu_clamped_bf16` does.
**`add` and `mul`** broadcast a `b` of exactly `n` elements along the rows of a taller output (a
bias add). Nothing else broadcasts, in these or any other elementwise op. `add`'s `div` divides
the sum after its rounding, `y = rd(rd(a + b) / div)` with `rd` `y`'s dtype (absent, 1: the plain
@@ -285,9 +294,10 @@ weight.
**`act_mul`** is `silu_mul` with its halves in two operands, so the multiplier can be any tensor:
two column slices of a fused `gate_up`, or a gate and a separate per-layer input (EmbeddingGemma 2's
per-layer-embedding block multiplies `gelu_tanh(gate(x))` by one). `act` is `silu`, `gelu` (exact
erf), `gelu_tanh`, `sigmoid` (a GLU: `a` the gate half, `b` the value half) or `quick_gelu`
(`sigmoid` of the bf16-rounded `1.702 a`, the CLIP tower's fused form). The activation is
rounded to `y`'s dtype before the product, as the unfused pair stores it.
erf), `gelu_tanh`, `sigmoid` (a GLU: `a` the gate half, `b` the value half), `quick_gelu`
(`sigmoid` of the bf16-rounded `1.702 a`, the CLIP tower's fused form) or `relu`, which over one
tensor in both operands is `relu(x)²` (Nemotron-H's ungated experts). The activation is rounded
to `y`'s dtype before the product, as the unfused pair stores it.
**`seg_mean`** is mean pooling over a ragged batch: row `s` of `y` is the mean of `x`'s rows
`[cu[s], cu[s+1])`, summed in double and rounded once. `M` is the step's token count and bands the
@@ -333,6 +343,14 @@ half-pixel centres, widened by the scale when the grid is smaller than the table
normalised to sum to one; separable, f32, rounded once. A different function from `grid_embed`'s,
so a different op rather than a mode a library could ignore.
**`grid_embed_cpe`** is RADIO's cropped position embedding: the table resampled with
`F.interpolate(mode="bilinear", align_corners=False)` and no antialias onto a square whose side is
the grid's larger one, of which the grid keeps the top-left `h x w`. Per axis two taps at
`(i + 0.5) * side / d - 0.5`, clamped at 0 and into the table, blended along the row first as torch's
kernel does; f32, rounded once before the add. A row whose row coordinate is negative is one of
`n_prefix` learned rows a segment carries ahead of its patches (RADIO's class and register tokens),
the column naming which: it gets `prefix[k]` instead.
### Hyper-connections
`hc_project` is the control vector's projection (core/cvec.h): `h[s] -= scale * (h[s] . v) * v`
@@ -499,6 +517,20 @@ depth, the position its token takes once its path is committed. Causal layers on
`attn_paged_tree`; libr4d `attn_paged_qrow_tree` at h256/gqa2 on the split-KV decode kernel and at
every geometry of the windowed kernels, to 64 rows a block.
| op | params | operands |
|---|---|---|
| `attn_paged_ahead` | `q_len`(range) `head_dim` `gqa` `block_size`/der `causal` `window` `q_dtype` `kv_dtype` `scale`:f64/opt `max_ctx`/opt `n_head`/opt `max_seqs`/opt `prefill_fp8`/opt | `q`, `kv_cache`, `block_table`, `seqused`, `k_descale`?, `v_descale`?, `cu_seqlens`? → `out` |
| `attn_paged_qrow_ahead` | `q_len`(range) `head_dim` `gqa` `block_size`/der `causal` `window` `q_dtype` `kv_dtype` `scale`:f64/opt `max_ctx`/opt `n_head`/opt `max_seqs`/opt `prefill_fp8`/opt | `q`, `kv_cache`, `block_table`, `seqused`, `k_descale`?, `v_descale`?, `cu_seqlens`? → `out` |
`attn_paged_ahead` is `attn_paged` at `causal` 0 with a window that bounds the keys behind a row
only: key `j` is visible to row `i` when `i - j < window` and `j < seqused`, so every key after the
row is. `attn_paged` reads a non-causal window two-sided (`|i - j| < window`). Gemma 4's sliding
layers read a picture's rows this way (transformers' mask is the window AND (causal OR the same
picture)), and the two differ only for a picture longer than the window. `window` is at least 1.
`attn_paged_qrow_ahead` is the same with `q` at its own row pitch, as `attn_paged_qrow`. libr4d
serves both at h256, 1 to 8 queries per kv head, on the windowed kernels; no other library
declares them, so a plugin asking for them learns whether a card serves the geometry.
Of the ops above, libref serves only `attn_paged_tree`, which is not a fusion but `attn_paged`'s
tree form. It has no row for any of the fusions, deliberately. An architecture asks for a fusion and declares
the chain where it does not resolve (`rad_op_resolved`); a reference row would make it resolve
@@ -927,6 +959,8 @@ as the weight's GEMM stored them and claims no form. It changes no value.
| op | params | operands |
|---|---|---|
| `attn_paged` | `q_len`(range) `head_dim` `gqa` `block_size`/der `causal` `window` `q_dtype` `kv_dtype` `scale`:f64/opt `max_ctx`/opt `n_head`/opt `max_seqs`/opt `prefill_fp8`/opt | `q`, `kv_cache`, `block_table`, `seqused`, `k_descale`?, `v_descale`?, `cu_seqlens`? → `out` |
| `attn_paged_anchor_window` | same parameters as `attn_paged` | same operands as `attn_paged` → `out` |
| `attn_paged_sink` | `q_len`(range) `head_dim` `gqa` `block_size`/der `causal` `window` `q_dtype` `kv_dtype` `scale`:f64/opt `max_ctx`/opt `n_head`/opt `max_seqs`/opt `prefill_fp8`/opt | `q`, `kv_cache`, `block_table`, `seqused`, `k_descale`?, `v_descale`?, `cu_seqlens`?, `sinks`w → `out` |
| `attn_dense` | `M`(range) `head_dim` `gqa` `causal` `dtype` `scale`:f64/opt `max_seqlen`/opt `window`/opt `cu_div`/opt `block`/opt `window_right`/opt | `q`, `k`, `v`, `cu_seqlens` → `out` |
| `attn_cross` | `M`(range) `head_dim` `gqa` `causal` `dtype` `scale`:f64/opt | `q`, `k`, `v`, `cu_seqlens`, `cu_k` → `out` |
| `attn_na3d` | `M`(range) `head_dim` `kt` `kh` `kw` `dtype` `scale`:f64/opt | `q`, `k`, `v`, `geom` → `out` |
@@ -945,8 +979,18 @@ as the weight's GEMM stored them and claims no form. It changes no value.
| `qkv_norm_rope` | `M`(range) `head_dim` `n_head` `n_head_kv` `theta`:f64 `eps`:f64 `scale`:f64/opt `mode`/opt `rotary_dim`/opt `ladder`/opt `wadd`:f64/opt `v_from_k`/opt `v_norm`/opt `dtype` | `q`:inout, `k`:inout, `v`:inout, `positions`, `q_w`w, `k_w`w |
| `qkv_norm_rope_kv_store` | `M`(range) `head_dim` `n_head` `n_head_kv` `theta`:f64 `eps`:f64 `scale`:f64/opt `mode`/opt `rotary_dim`/opt `ladder`/opt `wadd`:f64/opt `v_from_k`/opt `dtype` `v_norm`/opt `block_size` `kv_dtype` `k_scale`:f64/opt `v_scale`:f64/opt | `q`:inout, `k`:inout, `v`:inout, `positions`, `q_w`w, `k_w`w, `slot_mapping`, `kv_cache`:inout |
**`attn_paged_sink`** is `attn_paged` with a learned logit a query head beside the keys: `sinks`
`[n_head]` f32, in the scaled-score domain, joins each row's softmax maximum and denominator and
carries no value, so `out = Σ_j p_j v_j` with `p_j = exp(s_j) / (Σ_k exp(s_k) + exp(sink))`. A row
with no visible key stays zero. It has its own name so that no `attn_paged` kernel which does not
know the operand can be chosen for it (LiLiCorr's drafter, and gpt-oss's sinks have the same form).
**`attn_paged`**'s band is `q_len`, not `M`: one query row at decode, `1 + n_spec` at a speculative
verify, thousands in a prefill chunk, and libr4d has a different kernel for each band.
`attn_paged_anchor_window` has the same layout but different visibility: the first query position
in each sequence is the shared anchor for every query row, with the lower-bound predicate
`anchor - key < window`; causal mode additionally masks keys after the anchor. It is a distinct op
name so an older plugin cannot silently interpret this as per-query `attn_paged`.
`block_size` is read off the resolved kernel, not chosen: declare the group, declare the op, then
ask `rad_kv_block_size()` (`spec.md` §7.2).
@@ -1908,6 +1952,24 @@ over its encoded rows after the VAE encoder's fold. The weight is a declared con
rows at a time, so each item's draws start at `e = 0`. MiniMax-H3: `n` 96, `stream` 2, `aug`
0.999.
## Shape generation
The op a shape generator (Hunyuan3D-2, `rad_declare_shape_generator`) needs beyond an image
generator's: the embedding of the points its geometry decoder is queried at. Its encoder, denoiser
and decoder are otherwise built of the image and video generators' ops (`rms_mod` `norm` layer,
`gate_add` `act` none, `flow_euler`, `attn_cross`).
| op | params | operands |
|---|---|---|
| `point_fourier` | `M`(range) `n` `freqs` `pi`/opt `dtype` | `x` → `y` |
- `point_fourier`: row m of `y` is `[x | sin(x_i f_j) | cos(x_i f_j)]` over `x`'s `n` values, the
sines and then the cosines each `i`-major then `j`, with `f_j = 2^j` for `j < freqs` (times pi
with `pi` 1), so `y` is `[M, n (2 freqs + 1)]`: the shape VAE's FourierEmbedder with its input
included. The products are f32 (exact without pi, a power of two), the sine and cosine f32 and
rounded once to `y`'s dtype. `freqs` is at most 30. libr4d's `point_fourier_f32` serves f32 in
and out with the device's `sinf` and `cosf`.
## LTX-2
The ops LTX-2's audio-video transformer adds (`libref/ref_ltx.cpp`): its rotary over fractional
@@ -2044,6 +2106,7 @@ The VAEs' convolutions are `conv3d_ndhwc` with `tpad` and the audio VAE's `conv2
| `router_gemm_topk_scatter` | `M`(range) `K` `n_expert` `n_local`/opt `top_k` `norm` `dtype` `expert_base`/opt `protect`:str/opt | `a`, `b`w, `gate_b`w? → `logits`, `expert_ids`, `expert_w`, `sorted_tok`, `expert_offset`, `expert_count`, `gate`? |
| `moe_gemm` | `M`(range) `N` `K` `n_expert` `top_k` `a_order` `dtype` | `a`, `w`wt, `sorted_tok`, `expert_offset` → `y` |
| `router_sigmoid_topk` | `M`(range) `n_expert` `top_k` `norm` `route_scale`:f64 `dtype` | `logits`, `bias`w → `ids`, `weights` |
| `router_sigmoid_group_topk` | `M`(range) `n_expert` `top_k` `n_group` `topk_group` `norm` `route_scale`:f64 `dtype` | `logits`, `bias`w → `ids`, `weights` |
| `router_sigmoid_topk_scatter` | `M`(range) `n_expert` `n_local`/opt `top_k` `norm` `route_scale`:f64 `dtype` `expert_base`/opt `protect`:str/opt | `logits`, `bias`w → `ids`, `weights`, `sorted_tok`, `expert_offset`, `expert_count`, `gate`?, `inverse`? |
| `moe_scatter_inv` | `M`(range) `n_expert` `top_k` `expert_base`/opt `protect`:str/opt | `expert_ids` → `sorted_tok`, `expert_offset`, `expert_count`, `inverse` |
| `moe_gather_inv` | `M`(range) `n` `top_k` `dtype` `act`:str/opt | `y_expert`, `expert_w`, `inverse`, `shared`?, `shared_gate`? → `y` |
@@ -2173,8 +2236,8 @@ expert, and the weights are the selected `p`, never the biased ranks. With `norm
`p * (route_scale / (sum + 1e-20))` over the row's selected `p`, with `norm` 0 `p * route_scale`;
`route_scale` is positive and finite. A rank that is NaN or `-inf` is never selected, and a row
with fewer than `top_k` selectable experts has no defined selection (libref refuses it).
Grouped selection (`n_group > 1`) is not this op. GLM-5.3 routes 8 of 288 experts in one group
with `route_scale` 2.5.
Grouped selection (`n_group > 1`) is `router_sigmoid_group_topk`, below. GLM-5.3 routes 8 of 288
experts in one group with `route_scale` 2.5.
libr4d's `router_sigmoid_topk_f32` takes up to 512 experts and `top_k` up to 32, f32 logits, bias
and weights, i32 ids, pitched rows, `M` up to 65535. It selects in one wave per row: each lane
@@ -2183,6 +2246,16 @@ takes the largest key below round `j-1`'s winner. A row without NaN ranks gives
serial scan with a strict `>`. A NaN rank is never selected, and a row with fewer than `top_k`
other ranks names expert 0 in its empty slots, weighted by expert 0's `p`.
**`router_sigmoid_group_topk`** is the group-limited form (DeepSeek-V3's `noaux_tc` with
`n_group > 1`, Ling-3.0's 8 groups of 64 experts, 4 kept). The experts fall into `n_group` equal
groups of at least two; a group's rank is the sum of its two largest `p + bias`; the `topk_group`
best groups are kept, ties to the lower group; the selection is `router_sigmoid_topk`'s over the
kept groups' experts only, and the weights are the same. `top_k` is at most the kept experts.
libr4d's `router_sigmoid_group_topk_f32` is `router_sigmoid_topk_f32`'s wave with the groups ranked
first, a lane a group: up to 512 experts in up to 32 groups, `top_k` up to 32, pitched rows, `M` up
to 65535.
**`router_sigmoid_topk_scatter`** (device-only) is `router_sigmoid_topk` and `moe_scatter` over its
`ids` in one launch, and with `gate` `[M, 1]` also the `fill` of an ungated shared arm's gate with
1 (GLM-5.3's shared expert has no gate, and the gather reads one). `n_expert`, `n_local`,
@@ -2294,6 +2367,7 @@ wrong.
| op | params | operands |
|---|---|---|
| `kda_update` | `M`(range) `heads` `head_k` `head_v` `lower_bound`:f64 `scale`:f64 `l2_eps`:f64 `mode` `dtype` `state_form`/opt | `q`, `k`, `v`, `a`, `b`, `A_log`w, `dt_bias`w, `state`:inout, `state_idx`, `cu`, `num_accepted`?, `has_init`? → `o` |
| `ssd_update` | `M`(range) `heads` `head_dim` `d_state` `groups` `mode` `dtype` `state_form`/opt | `x`, `B`, `C`, `dt`, `A_log`w, `dt_bias`w, `D`w, `state`:inout, `state_idx`, `cu`, `num_accepted`?, `has_init`? → `o` |
| `gdn_conv_prep` | `M`(range) `head_k` `head_v` `chunk`/der `conv_width` `l2_eps`:f64/opt `softplus_thr`:f64/opt | `x`, `w`w, `b`w?, `A_log`w, `dt_bias`w, `conv_state`:inout, `cu`, `a`?, `b_gate`?, `cache_idx`?, `has_init`? → `q`,`k`,`v`,`g`,`beta` |
| `gdn_conv_update` | `q_len`(range) `head_k` `head_v` `conv_width` `max_query_len`/opt | `x`, `w`w, `b`w?, `conv_state`:inout, `state_idx`, `num_accepted`, `cu` → `q`,`k`,`v` |
| `gdn_kkt_solve` | `M`(range) `head_k` `chunk`/der | `k`, `beta`, `g`, `cu` → `A` |
@@ -2336,6 +2410,26 @@ Under `anchor`, `verify` replays the accepted prefix in a separate dispatch befo
no value row overwrites factors another is still reading. A sequence whose window or slots are
out of bounds is skipped on the device, not refused.
**`ssd_update` is Mamba-2's selective state update** (the SSD recurrence, token by token). Per token
and head `h`, with `g = h / (heads / groups)` the head's B/C group:
dt' = softplus(dt[h] + dt_bias[h]) A = -exp(A_log[h])
S = e^{dt' A} S + dt' x[h] B[g]^T o[h] = S C[g] + D[h] x[h]
It is a delta-net head without the delta: one scalar decay per head and token, no beta and no l2
norm on B or C, and the skip term `D`, so the gdn ops cannot run it. dt is not clamped: the
checkpoints carry `time_step_limit = (0, inf)`, which mamba_ssm's kernels and vLLM pass, while
transformers' CPU fallback clamps at `time_step_min`, which on a real prompt binds for about one
(token, head) pair in eight. softplus is the identity above 20, as in torch and mamba_ssm.
`state` is f32 `[slots, heads, head_dim, d_state]`; `x` and `o` may be `[M, heads, head_dim]` or
flat, `B` and `C` `[M, groups, d_state]` or flat, `dt` one value per (token, head). Heads read their
group in blocks (heads `0 .. heads/groups - 1` read group 0), the mamba_ssm convention, not
round-robin. `o` excludes the model's gated norm. The rollback contract is `kda_update`'s, in both
forms. Under `anchor` the scratch holds, per head, the replay count and one record per window token:
the decay `e^{dt' A}`, `u = dt' x` (`head_dim`) and `B` (`d_state`), as many as the
`[head_dim, d_state]` block holds and at most 32 (a 64 x 128 head holds 42). The replay applies a
record with the window's own update, so the committed state is the per-candidate one bit for bit.
**Speculative rollback is part of the schema** (`spec.md` §10). The recurrent state and the conv
window have already absorbed rejected tokens, so the state cache is a rolling window of
`conv_width-1 + n_spec` entries read at the slot the last accepted token left, and a rejection is a
@@ -2529,6 +2623,7 @@ whole form elsewhere (the host mailbox included), which keeps every promise `sp`
| `ngram_ids` | `M`(range) `heads` `ngram` `eos` | `tok`, `state`:inout, `cu`, `mult`w, `vocab_sizes`w, `offsets`w, `cache_idx`?, `has_init`?, `num_accepted`? → `ids`, `ahead_ids`? |
| `ple_gate` | `M`(range) `n` `hc` `eps`:f64 `dtype` `wadd`:f64/opt `gate_eps`:f64/opt | `k`, `q`, `v`, `w_key`w, `w_query`w, `w_conv`w → `gv`, `gvn` |
| `ple_conv` | `M`(range) `n` `width` `dilation` `dtype` | `x`, `w`w, `conv_state`:inout, `cu`, `resid`?, `cache_idx`?, `has_init`?, `num_accepted`? → `y` |
| `ple_conv_bias` | `M`(range) `n` `width` `dilation` `dtype` | `x`, `w`w, `conv_state`:inout, `cu`, `resid`?, `cache_idx`?, `has_init`?, `num_accepted`?, `b`w → `y` |
| `causal_conv1d` | `M`(range) `n` `width` `dtype` | `x`, `w`w, `conv_state`:inout, `cu`, `cache_idx`?, `has_init`?, `num_accepted`? → `y` |
`logits_gemm` is separate from `gemm_nt` because `lm_head` is its own access class
@@ -2760,6 +2855,15 @@ prefill's question and `num_accepted` decode's.
The residual add is folded in because the reference is `gv + silu(conv(gvn))` and both tensors are
`[M, hc*n]`. `resid` absent leaves the plain convolution.
### `ple_conv_bias`
y[t] = resid[t] + silu( b[c] + sum_j w[c][j] * x[t - (width-1-j)*dilation] )
`ple_conv` with `b`, a per-channel bias inside the activation, before `y`. At dilation one with no
`resid` it is Mamba-2's `conv1d` over its `[x | B | C]` channels, so the Mamba block keeps the
window and rollback contract above. It is an op of its own, as `attn_paged_sink` is beside
`attn_paged`, so the architectures that issue `ple_conv` keep their operand list.
### `causal_conv1d`
y[t] = sum_j w[c][j] * x[t - (width-1-j)]
@@ -2793,7 +2897,7 @@ resolutions of one op. The one exception is `sample_chain` (below).
| `sample_pick` | `M`(range) `n_cand` | `cand_idx`, `cand_val`, `params` → `token` |
| `sample_argmax` | `M`(range) `n_vocab` | `logits`, `params` → `token` |
| `sample_merge_topk` | `M`(range) `n_cand` | `gathered`, `params` → `cand_idx`, `cand_val` |
| `sample_logprobs` | `M`(range) `n_vocab` `k` `vocab_off`/opt | `logits`, `params` → `stats` |
| `sample_logprobs` | `M`(range) `n_vocab` `k` `vocab_off`/opt | `logits`, `params`? → `stats` |
| `mtp_couple_propose` | `M`(range) `n_vocab` `round` `max_rounds` `q_temp`:f64/opt | `idx`:inout, `val`, `seq_ids`, `draw` → `state`:inout |
| `mtp_couple_verify` | `M`(range) `n_cand` `n_vocab` | `cand_idx`, `cand_val`, `params`, `state` → `token`:inout |
| `dflash_couple_propose` | `M`(range) `steps` `top_k` `rank` `n_vocab` `anchor_stride` `max_rounds` `q_temp`:f64/opt | `cand`, `unary`, `hp`?, `anchor`, `pred`w, `succ`w, `seq_ids`, `draw`, `tokens`:inout → `state`:inout |
@@ -2852,7 +2956,8 @@ llama.cpp's: 0 turns the stage off for the row, and a negative value takes the w
`sample_logprobs` serves an OpenAI `logprobs` field or llama-server's `n_probs`. It runs on the raw
logits, before any stage has touched them, and only for a row whose flags carry `RAD_SP_LOGPROBS`;
other rows are not written. `stats` is `[M, 2 + 2k]` f32: the row's maximum, the sum of
other rows are not written. Without `params` every row is written (a drafter's candidate logprobs,
`lili_cand`). `stats` is `[M, 2 + 2k]` f32: the row's maximum, the sum of
`exp(l - max)` over it, and its `k` largest as (id, logit) pairs, descending, ties to the lower id,
the id written as a float (exact below 2^24) and global under a split vocabulary (`vocab_off`
added). A slot past the vocabulary is id -1, logit -infinity. `k` is geometry, the one width every
@@ -2923,7 +3028,8 @@ order, not a slow one.
| `dsa_pool` | `M`(range) `n` `ratio` `dtype` `block_size`/opt | `kg`, `ape`w → `q`, `scale`; `page`?, `cache`:inout? |
| `dsa_query` | `M`(range) `n` `dtype` | `x` → `q`, `scale` |
| `dsa_score` | `M`(range) `n` `heads` `blocks` `seqs` `dtype` `row_part`/opt | `q`, `q_scale`, `gate`, `k`, `k_scale`?, `bt`, `cu`, `nc` → `score`, `cu_part`? |
| `mla_attn` | `M`(range) `latent_dim` `heads` `blocks` `block_size` `scale`:f64 `dtype` | `q`, `kv`, `bt`, `length` → `out` |
| `mla_attn` | `M`(range) `latent_dim` `heads` `blocks` `block_size` `scale`:f64 `dtype` `kv_dtype`/opt | `q`, `kv`, `bt`, `length` → `out` |
| `mla_attn_paged` | `M`(range) `heads` `latent_dim` `rope_dim` `block_size` `scale`:f64 `dtype` | `q`, `q_rope`?, `kv`, `block_table`, `seqused`, `cu_seqlens`, `gate`? → `out` |
| `mla_project` | `M`(range) `heads` `head_dim` `latent_dim` `mode` `dtype` | `a`, `b`w → `y` |
| `qsa_score` | `M`(range) `n` `heads` `blocks` `seqs` `dtype` | `q`, `bk`, `bt`, `cu`, `nc` → `score` |
| `qsa_select` | `M`(range) `blocks` `topk` `ratio` `seqs` `signed`/opt | `score`, `bt`, `nc`, `pos`, `cu` → `sel`, `nsel`, `seqused` |
@@ -3248,7 +3354,9 @@ fold only after each head's ReLU.
the tail) and is the causal bound: no slot at or past it is read. A missing or out-of-range page
contributes nothing, and a row with no visible key outputs zero. The softmax is f32 and `out` is
rounded once. `scale` is positive and finite and comes from the original query/key head width,
not the latent width (GLM: `1/sqrt(256)` against a latent of 512).
not the latent width (GLM: `1/sqrt(256)` against a latent of 512). `kv_dtype`, when given, is the
cache's dtype and may differ from `dtype`: `fp8_e4m3` is a cache `kv_store` wrote at its default
descale of 1, so each code is read as the value itself.
libr4d has three `mla_attn` rows, all at `latent_dim` 512, `block_size` 4 and up to 64 heads. The
matrix row, `mla_attn_matrix_bf16`, ranks above the wave row and takes heads in multiples of 8: the
@@ -3275,6 +3383,35 @@ runs the matrix row's kernel instead. It also takes multiples of 32 heads (two g
workgroup), which no constraint routes to it. GLM-5.3 splits a prefill's MLA by rows under tensor
parallelism, so each rank holds all 64 heads of its rows (ARCHITECTURES.md, `glm5next`).
Each of the three has an E4M3-cache twin (`mla_attn_fp8kv`, `mla_attn_matrix_fp8kv`,
`mla_attn_rows_fp8kv`) on the same constraints plus `kv_dtype` `fp8_e4m3`, ranked above all three
bf16 rows and in their order. The kernels are the bf16 rows' with the key load decoding E4M3:
every E4M3 value is a bf16, so the decoded tile is exact and the rest of the arithmetic is the bf16
instance's. The bf16 rows state no `kv_dtype` and their launchers refuse an E4M3 cache.
`mla_attn_paged` is the dense, causal form for a model whose MLA keeps a rotary part beside the
latent (Ling-3.0: latent 512, rotary 64, every key visible). A token's cache row is the normed
latent followed by the rotated key part, `latent_dim + rope_dim` wide; it is stored as one KV head
of half that width, its first half in the K slot and the rest in the V slot, so `kv` is
`[pages, 1, block_size, latent_dim + rope_dim]`. `q` is the absorbed query `[M, heads,
latent_dim]` and `q_rope` its rotated part `[M, heads, rope_dim]`, each at its own row and head
pitch. A score is `scale * (q . latent + q_rope . rope)`, `scale` from the original head width
(`(nope + rope)^-0.5`), and the value is the latent. Sequences, positions and the causal bound are
`attn_paged`'s: sequence `s` owns query rows `[cu[s], cu[s+1])`, `seqused[s]` is its context after
the step, row `i` of it sits at position `seqused[s] - qlen + i` and sees keys `0..position` through
`block_table[s]`. An unmapped page contributes nothing and a row with no visible key outputs zero.
With `gate` `[M, >= heads]` (a head's gate logit) the output is
`bf16(bf16(out) * bf16(sigmoid(gate)))`, Ling's head-wise attention gate taken on the latent, ahead
of the expansion. The softmax is f32 and `out` rounded once before the gate.
libr4d's `mla_attn_paged_bf16` serves `latent_dim` 512 and `rope_dim` 64, up to 64 heads, pages of
up to 256 tokens: a wave a (query row, head), its lanes holding 16 latent and 2 rotary columns each,
so a score is one wave sum. A short batch splits each row's history over waves and joins the f32
partials. The split count comes from the head count alone, never from the rows of the launch or
its longest table, so a row's bytes do not depend on its batch: a speculative verify of `k + 1`
rows must give, bit for bit, the single-row decodes at the same positions, or greedy output
differs from the run without speculation. That holds up to 32 rows a launch, the rows the scratch
hook sizes for; a larger batch takes as many splits as its scratch holds.
`mla_project` moves a query into the latent and a latent result out of it, through the bf16
weight `b` `[heads*2*head_dim, latent_dim]` that stores each head's key rows, then its value rows.
`mode=absorb` multiplies `a` `[M, heads, head_dim]` by the head's key block as stored,
@@ -3284,16 +3421,35 @@ accumulate in f32 and round once to bf16. The KV cache stays latent; only this w
per-head width. Its rows are head-major, so a tensor-parallel slice of whole heads is a row range.
`a` and `y` may also be `[M, heads*width]`, heads contiguous, with their own token pitch.
libr4d's `mla_project_bf16` serves `head_dim` 256 and `latent_dim` 512, up to 64 heads, pitched
tensors. It takes up to eight rows a thread (`absorb`) or a wave (`expand`), loading each weight
element once for them, with every row's sum in the same order whatever the group, so a row's bytes
do not depend on the batch.
libr4d's `mla_project_bf16` serves `head_dim` 128 or 256 and `latent_dim` 512, up to 64 heads,
pitched tensors. It takes up to eight rows a thread (`absorb`) or a wave (`expand`), loading each
weight element once for them, with every row's sum in the same order whatever the group, so a row's
bytes do not depend on the batch.
## Draft heads
A drafter is an ordinary graph over ordinary ops except at its two ends: what proposes the
candidates, and what enters the head from the trunk.
### DSpark
| op | params | operands |
|---|---|---|
| `dflash_markov_greedy` | `M` `steps` `rank` `n_vocab` `anchor_stride`/opt `dtype` | BF16 `logits`, `anchor`, `pred`w, `succ`w → `tile_scores`, `tile_tokens`, `tokens` |
| `dflash_markov_greedy_f32` | `M` `steps` `rank` `n_vocab` `anchor_stride`/opt `dtype` | F32 `logits`, `anchor`, `pred`w, `succ`w → `tile_scores`, `tile_tokens`, `tokens` |
`dflash_markov_greedy` implements the DSpark full-vocabulary greedy walk, not DFlash2's
candidate-lattice selector. For every position it adds `sum_r pred[previous,r] * succ[token,r]`
to every vocabulary logit, chooses the greatest biased score (ties to the lower token id), and
uses that id as the next predecessor. The explicit tile outputs are scratch for the device's
vocabulary-wide reduction; their row pitches may differ. The F32 variant uses the same BF16
codebooks (`dtype=bf16`) but takes F32 base logits; it is a separate operation so an older BF16-only
kernel cannot silently resolve it. The DSpark graph uses `logits_gemm` and the F32 variant. The
pinned llama.cpp reference also uses F32 base logits, but reduction orders may differ. Its CPU
argmax chooses the last equal maximum; its GPU reduction uses a backend-specific order. This op's
lower-id tie rule is not a claim of reference tie equivalence. Near-tie proposal equivalence is
therefore not established.
### DFlash2
| op | params | operands |
@@ -3351,6 +3507,42 @@ inside one workgroup. Written literally it is `steps` full-vocabulary `[rank, n_
products; through this operand it is a codebook gather. The only approximation is the top-K
candidate set, which can cost acceptance and nothing else.
### LiLiCorr
| op | params | operands |
|---|---|---|
| `lili_cand` | `M`(range) `k` `world` `steps` `n` `dtype` `eps`:f64/opt `row_k`/opt | `stats`, `pas`, `ln_w`w, `ln_b`w, `up_w`w, `up_b`w, `slot`w, `rank`w → `cand`, `feat`, `base` |
| `lili_attn` | `M`(range) `steps` `k` `n_head` `head_dim` `dtype` `scale`:f64/opt | `qkv`, `rel`w, `same`w → `out` |
| `lili_factor` | `M`(range) `L` `n` `dtype` | `h`, `a` → `y` |
| `lili_walk` | `M`(range) `steps` `k` `n` `dtype` `eps`:f64/opt `scale`:f64/opt | `edges`, `aout`, `cand` → `tokens`, `scores`? |
LiLiCorr (Nemotron-3.5-Bolt's drafter) is a DFlash2 backbone whose head is a candidate correlator:
each draft position keeps the target head's top-k, and a small transformer over all positions'
candidates scores the edges between consecutive positions. A sequence's lattice is `steps` positions
of `k` candidates, row `s * k + j`, the sequences one after another.
**`lili_cand`** reads `stats` `[M, world * (2 + 2 row_k)]` f32, each rank's `sample_logprobs` row
row-interleaved (`row_k` >= `k` pairs, by default `k`: a caller widens a rank's row to whole 16-byte
words for the all-gather, 9 pairs where it keeps 8), and merges them as one row would be read: the log-normaliser from the maxima and
the rescaled sums, the `k` largest pairs by value, ties to the lower id. `cand` `[M, k]` i32 holds
those ids. With `lp_j = logit_j - lse`, row `m * k + j` of `feat` is
`silu(up_w · layernorm([lp_j, exp lp_j, lp_j - lp_0, j/(k-1), j == 0]; ln_w, ln_b, eps) + up_b)`
and of `base` `pas[m] + slot[m % steps] + rank[j]`: the lattice row's additive part, to which the
token and feature projections are added by their GEMMs' residual operand.
**`lili_attn`** is attention within each lattice, every row seeing every row: `qkv` is
`[M, 3 * n_head * head_dim]` as q | k | v, and the score is
`q_i · k_j * scale + rel[h][s_i - s_j + steps] + (s_i == s_j ? same[h] : 0)` with `s_i = i / k`.
**`lili_factor`** writes `[h_i | a_s | h_i * a_s]`, `s = i / L`: a lattice row beside its sequence's
anchor and their product, the input of the factor projection `W [x, a, x * a] + b`.
**`lili_walk`** normalises each candidate's outgoing and incoming vector (`edges`, `[out | in]`) and
the anchor's outgoing one (`aout`) as `v / max(|v|, eps)`, scores `start[j] = scale * aout · in[0][j]`
and `pair[s][i][j] = scale * out[s][i] · in[s + 1][j]`, and walks greedily from the start, the first
index winning a tie: `tokens[m][s] = cand[m * steps + s][p_s]`. `scores` `[M, steps, k, k]` is the
score tensor vLLM builds (row 0 the start for every `i`), for checking.
### `mtp_enter`
| op | params | operands |
+177
View File
@@ -0,0 +1,177 @@
# Spark X2.6 4B IQ8R: recipes, provenance, and validation
`arch/spark25_w8a8` serves Spark X2.6's six dense projections per layer on the `fwht128` rotated
int8 grid. It requires `quantization_config.quant_method=w8a8` and
`quantization_config.fmt=fwht128`; activations use `had_quant_act_i8g` and weights use `gemm_nt_q`
with `dtype=i8a8h`. The embedding and small per-head attention gate stay BF16; norm gains stay
FP32. Calibration is TP=1 so the Gram matrices retain cross-rank terms.
## Recipe choice
The container format does not choose a recipe or change a launcher default. Select one explicitly
when converting a BF16 source checkpoint:
| Allocation | Recipe | Published container size | Measured distribution parity | Performance note |
|---|---|---:|---|---|
| Quality-preferred tested hybrid | `data/recipes/spark-x26-4b-iq8r-keep12.recipe` | 5.67 GiB (6,092,100,608 bytes) | 99.111% top-1 agreement; top-128-plus-tail KL mean 0.000677, p99 0.00923, p99.9 0.04013, max 0.24712 | About 12% less prefill and 17% less decode throughput than full IQ8R in the reported single-card comparison |
| Full IQ8R, explicit speed/size tradeoff | `data/recipes/spark-x26-4b-iq8r.recipe` | 4.52 GiB (4,853,470,208 bytes) | 98.595% top-1 agreement; top-128-plus-tail KL mean 0.004077, p99 0.04960, p99.9 0.34814, max 11.8832; 13 positions exceed 1 nat | Prefill 11.8k / 11.8k / 11.3k tok/s at 1.1k / 4.4k / 9.9k-token prompts; decode 93.7 tok/s at short context and 88.9 tok/s at 4.4k context |
| Source BF16 | no recipe | 8.29 GiB | reference | Baseline |
For the keep12 allocation, six explicit rules cover each projection in layers 12–35. Layers 0–11
have no matching rule and retain their BF16 checkpoint encoding. The output head remains RTN in both
IQ8R recipes; unmatched tensors (including the embedding and attention gate) retain their source
encoding. The full recipe is not quality-preferred and is not applied implicitly. Neither measured
allocation establishes task accuracy or universal quality for all prompts and uses.
The reported KLD values above are **not exact full-vocabulary KL**. They use Radiance's sparse
`--kld-top 128` form: the reference's top 128 token probabilities plus one bucket for all remaining
probability mass, compared with the candidate on the same coarsened support. The 31,391 positions
are from a 32-document held-out evaluation; the keep12 maximum is below one nat on this set, not a
claim about all inputs. Perplexity ratios were 1.00178 (keep12) and 1.00409 (full IQ8R).
## Calibration and evaluation provenance
The published calibration dataset is
[`gostar77/spark-x2.6-4b-iq8r-calibration`](https://huggingface.co/datasets/gostar77/spark-x2.6-4b-iq8r-calibration),
revision `4b622fa2ecca376a02a83ef23ec6dfb3b7cdc52b`. Its `CALIBRATION-MANIFEST.json` records
Spark X2.6 4B, `RADGRAM2`, TP=1, all 36 layers and six projection types. It contains 216 validated
Gram files (21,290,294,016 bytes; about 19.83 GiB) accumulated over 65,660 tokens. The prompts
were 100 selected document beginnings from `swift15-public-corpus`, with selection seed `20261031`
and every fourth candidate wrapped in the Spark chat format. The published dataset is CC BY-SA 4.0;
its `SHA256SUMS` covers the Gram files. The local manifest used for this record is
`/mnt/gostar_data/radiance-builds/hf-publish/spark-x2.6-4b-iq8r-calibration/CALIBRATION-MANIFEST.json`
(SHA-256 `f2225de42cfc885dca2720128143487296a5ba8c33cc797de0bac2b2bcebf007`); its local
`SHA256SUMS` has SHA-256 `f8d14fc575875e33045c2231013e87da52da8db4e21f692c363464d858dbbb18`.
The evaluation manifest is
`/mnt/gostar_data/radiance-builds/spark-x2-6-iq8r/independent-chat-eval.manifest.json`
(SHA-256 `a8528f193986b7267b7ec5b5a447c0d1f5271d5c2f7f004ceb8ba543e5168f4d`). It identifies a
separate held-out source file, `/mnt/gostar_data/radiance-calib/qwen3.8-flash-next-base-w5dn64/corpus/heldout.jsonl`
(source SHA-256 `2c3935512dbf0b09c8fea88be19f7d31447a540de57133a54f97e6e172f15532`), selection seed
`7132026`, and 8 examples each from tools, math, prose, and code. Two high-overlap candidates were
excluded; the manifest describes a sampled 20-gram overlap check against the 100 diverse calibration
documents and the original nine. That check is not proof of zero semantic overlap. Math/tool rows
score assistant continuations; prose/code rows score text after 32 tokens. The resulting local KLD
corpus is `/mnt/gostar_data/radiance-builds/spark-x2-6-iq8r/independent-chat-eval.jsonl`
(SHA-256 `468d9c6037a17475688ba432d804618c10d15288b4d5fe538b7ac4c0ab725ace`).
The recorded matched-reference artifacts are local and were not copied into this repository:
- BF16 sparse reference: `/mnt/gostar_data/radiance-builds/spark-x2-6-iq8r/rowfix-bf16-ref128/`
(`kld.json` SHA-256 `b722b8a956b747dd932413204d9ae0775bd2bd50377f0466134cc922ad83b026`).
- Full IQ8R report and per-row file: `rowfix-diverse-kld.json` and
`rowfix-diverse-kld.json.rows` (report SHA-256
`0f7368c83a3c9a896aa42bcbdf8022db526517f7fc4a9e680747ccd2b66bdee9`).
- Keep12 report and per-row file: `rowfix-keep12-kld.json` and
`rowfix-keep12-kld.json.rows` (report SHA-256
`d6b577c1e6f7fc5c40814744bea22079998562229eaa2b2a892274544a149dbf`).
- `rowfix-keep12-kld.json` records `ref_form: "top-128 + tail"`, reference `rowfix-bf16-ref128`,
`all.positions: 31391`, mean KL `0.0006770557376511436`, maximum KL `0.2471124678850174`, and
99.1112% top-1 agreement. These are coarsened top-128-plus-tail KL values, not exact
full-vocabulary KL. `rowfix-diverse-kld.json` uses the same `rowfix-bf16-ref128` reference and
31,391 positions. The reference metadata records corpus FNV-1a `17d9069a2711c745`; the companion
`.json.rows` files contain the per-position score rows (KL, candidate NLL, reference NLL, top-1
match).
The measured rowfix comparison used Radiance source commit `54f2602367eb96ca08674095f7e32506fd7d752b`
(the build tree points to `/mnt/gostar_data/radiance-worktrees/spark-x2-6`), `libr4d@0.5.0`, TP=1,
BF16 KV, `--max-model-len 4096`, `--max-num-seqs 1`, `--max-num-batched-tokens 128`, no speculation,
and prefix cache disabled. The prerequisite shared prefill correction is #362,
`7480da3d46b0475d9d77966e31284cc19072759`. **Those parity figures are for the tree with #362**;
#363's original `5024aea` ancestry did not contain it. Do not attribute these numbers to standalone
#363 or to a build without #362. A fresh GPU TP2 validation is separate and remains outstanding.
Published container checksums from `/mnt/gostar_data/radiance-builds/hf-publish/SHA256SUMS`
(SHA-256 `3c14ea79cb8b7b3aba8807dd43101aa84110636e914eb2008eb2ba3a387e3d1b`):
| Container | SHA-256 |
|---|---|
| `spark-x2.6-4b-radiance-bf16.rad` | `39694f258a3bb1e8367690a5d26762061226f3166125e929c6e33a4981583b6c` |
| `spark-x2.6-4b-radiance-iq8r-diverse.rad` | `2f6982f12b43d1e7621326c5c05a3764ef62defbbd4f59c708f9db698a14b0e5` |
| `spark-x2.6-4b-radiance-iq8r-keep12.rad` | `5a12f1f4c6cb1b2a545344bcb800cd829dc53de6cefa7a6bd9d4e2ed9fee2740` |
## Sharding alignment
A shard must own whole 128-column scale groups for a column-sharded IQ8R input; the architecture
rejects any computed span whose count is not group-aligned. It splits the FFN in whole 128-channel
units when the model width permits, using a ragged remainder-first partition. For Spark's
10,240-channel FFN there are 80 such units: TP=3 gets 27, 27, and 26 groups (3,456, 3,456, and
3,328 channels), all aligned. TP=3 is **not** categorically unaligned or unsupported. The synthetic
wide fixture checks TP=1..8; actual device support still depends on the selected kernel library and
required collectives. Calibration itself remains TP=1.
## Reproduce matched KLD and tail replays
Use a private output directory; the reference is immutable once recorded. The harness hashes the
checkpoint, executable, corpus, evaluation manifest, and **kernel, architecture and optional quantizer
shared-object inventories** into `run.json`. This includes the architecture graph plugin, not only
`libr4d.so`; an optional source revision is context, not proof that a binary was built from it. The
inventory must remain unchanged during the measurement. These probes accept one explicit home, not
a colon-separated home search path. They replay the same corpus against BF16 once and score each
candidate with fixed chunking/cache/TP flags. A reference `provenance.json` binds the BF16 model bytes,
corpus, runtime/plugins, settings and recorded data files. `--reuse-reference` requires this binding
to match; legacy unbound references must be recorded afresh, not relabelled with the supplied model.
The harness snapshots inputs before recording, checks them immediately afterward before publishing
provenance, and checks them again before publishing the run receipt. These checks detect persistent
changes, not a concurrent change that is reverted between checks; keep inputs immutable throughout.
A retry removes any previous `run.json` before measurement, so retain old receipts separately.
Reports and per-position score files are hashed into the run receipt as well:
```sh
python3 tests/spark25_quality.py \\
--radiance "$BUILD/bin/radiance" --home "$BUILD/radiance_home" \\
--reference "$BF16" \\
--corpus /mnt/gostar_data/radiance-builds/spark-x2-6-iq8r/independent-chat-eval.jsonl \\
--provenance /mnt/gostar_data/radiance-builds/spark-x2-6-iq8r/independent-chat-eval.manifest.json \\
--calibration-manifest /mnt/gostar_data/radiance-builds/hf-publish/spark-x2.6-4b-iq8r-calibration/CALIBRATION-MANIFEST.json \\
--source-root "$PWD" --out "$RUN" \\
--candidate "full=$FULL_IQ8R" --candidate "keep12=$KEEP12"
```
Run that process inside the host's exclusive GPU/device scope for `libr4d`. To replay a candidate's
highest-KL rows, run the following **inside the same kind of device scope**. The tool validates the
report's reference/corpus/model identities, report/row hashes, reference binding, and current runtime,
model and plugin hashes against `run.json`, then starts its own private candidate server with the
scoring run's TP, BF16 KV, model/chunk limits, speculation0 and prefix-cache-off settings. It verifies
the private served ID and the consumed prefix/completion/cache counts. Arbitrary external `--url`
servers are not accepted: a served alias alone cannot prove which checkpoint was loaded.
```sh
python3 tests/spark25_kld_tail.py \\
--run "$RUN/run.json" \\
--reference "$RUN/bf16-top128-ref" --report "$RUN/full-kld.json" \\
--out "$RUN/full-tail-replay.json"
```
The replay compares candidate top-20 log-probabilities with the stored reference top-20 for the
selected rows. The full corpus KLD report remains the top-128-plus-tail metric; top-20 replay is a
focused diagnostic, not a replacement for the full evaluation.
## Reproducible serving QoS smoke
Run this separately for each model, one process/container at a time and under an exclusive device
scope. It reuses the same evaluation prompts, disables prefix caching and speculation, and stores
per-request latency plus p50/p95/max and aggregate generated-token throughput at each concurrency.
These are end-to-end request measurements (prefill plus decode and service overhead), not decode-only
throughput or task scores. Every response must report positive integer prompt usage and exactly
`--max-tokens` generated tokens with a `length` finish (EOS is ignored for this fixed-work smoke).
Missing, zero or short counts fail the run rather than producing a successful throughput receipt.
The prompt file is parsed and hashed from the same byte snapshot and rechecked before receipt; the
private server uses a unique served model ID and is checked for identity and liveness. Requests per
repeat must be at least the largest requested concurrency. This is a client concurrency level, not
proof that requests actually overlapped in a server batch. Runtime/model/plugin hashes are also
checked again before writing the receipt; use a fresh `--out`:
```sh
python3 tests/spark25_qos.py \\
--radiance "$BUILD/bin/radiance" --home "$BUILD/radiance_home" \\
--model "$KEEP12" \\
--prompts /mnt/gostar_data/radiance-builds/spark-x2-6-iq8r/independent-chat-eval.jsonl \\
--source-root "$PWD" --out "$RUN/keep12-qos" \\
--concurrency 1,4,8 --requests 16 --repeats 3 --max-tokens 32
```
Use identical flags, prompt file and `RADIANCE_HOME` for BF16 and full IQ8R; run them sequentially
on the same device allocation. This smoke is a reproducible validation command, not a completed
concurrent/long-context QoS certification. The held-out distribution comparison is not an external
benchmark and does not establish universal model quality.
+2 -2
View File
@@ -443,8 +443,8 @@ comparison with the recording runs either way. `--no-cache` runs it regardless.
Against a container (`-m`), weight operands are read from it: each weight's canonical planes,
which the kernel under test gets through its own `layout`/`relayout` hooks and the oracle gets
decoded, and every expert of a weight table. This is the only test of the artifact and of the
layout hooks.
decoded, and every expert of a weight table, laid out expert by expert and stacked. This is the
only test of the artifact and of the layout hooks.
```sh
rad-kbench -m flashnext-w4.rad --home $RADIANCE_HOME --bench --report kbench.md