radiance 1.15.0

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

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

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

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

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

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

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

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

No files matched your search

+137 -2
View File
@@ -23,6 +23,7 @@
*/
#include "r4d_plugin.h"
#include "rad_abi_layout.h"
#include <cstdlib>
#include <cstring>
@@ -849,6 +850,9 @@ static const RadParamSpec pGemmNtQ[] = {
/* The width whose K split a row slice of a wider linear takes (docs/OPS.md); only the narrow
* fp8a8 / i8a8 rows split K by N, and they read it. */
{ "split_n", RAD_P_INT, RAD_OPTIONAL },
/* The weight rows one int8 scale covers, when the weight's form makes it more than one (a
* trellis on libquant's tcq_rb grid); the rb8 tile reads it (docs/OPS.md). */
{ "w_rb", RAD_P_INT, RAD_OPTIONAL },
};
/* docs/OPS.md's `gemm_nt_q` is `a`, `a_scale`, `b`w, `b_scale`w -> `y`. Two of libr4d's six
* quantised GEMMs need a seventh operand. RadLayout can declare aux streams beside a weight, but
@@ -1238,6 +1242,7 @@ static const RadParamSpec pGramAccum[] = {
{ "n", RAD_P_INT, RAD_REQUIRED },
{ "group", RAD_P_INT, RAD_REQUIRED },
{ "dtype", RAD_P_STR, RAD_REQUIRED },
{ "upper", RAD_P_INT, RAD_OPTIONAL }, /* 1: only k2 >= k1 is accumulated (H is symmetric) */
};
static const RadOperandSpec oGramAccum[] = {
{ "a", RAD_OPD_IN, 0 },
@@ -1920,6 +1925,15 @@ static const RadOperandSpec oSegMean[] = {
{ "cu_seqlens", RAD_OPD_IN, 0 },
{ "y", RAD_OPD_OUT, 0 },
};
static const RadParamSpec pSegPool[] = {
P_INT("M"), P_INT("n"), P_STR("dtype"),
};
static const RadOperandSpec oSegPool[] = {
{ "score", RAD_OPD_IN, 0 },
{ "v", RAD_OPD_IN, 0 },
{ "cu_seqlens", RAD_OPD_IN, 0 },
{ "y", RAD_OPD_OUT, 0 },
};
/* docs/OPS.md's `qk_norm_rope`: a fused [q | k | v] row in place, theta and not a table. */
static const RadParamSpec pQkNormRope[] = {
P_INT("M"), P_INT("head_dim"), P_INT("n_head"), P_INT("n_head_kv"), P_F64("theta"),
@@ -2999,6 +3013,10 @@ static const RadOpSchema kSchemas[] = {
SCHEMA("seg_mean", pSegMean, oSegMean,
"Row s of y is the mean of x's rows [cu_seqlens[s], cu_seqlens[s+1]), summed in f64 "
"and rounded once; an empty segment is zeros."),
SCHEMA("seg_softmax_pool", pSegPool, oSegPool,
"Row s of y is v's rows [cu_seqlens[s], cu_seqlens[s+1]) summed with the softmax of "
"their scores (one a row, f32, the maximum subtracted) as weights, in f32 and rounded "
"once; an empty segment is zeros."),
SCHEMA("seg_mean_bf16_sum", pSegMean, oSegMean,
"BF16 masked mean: f32 segment sum rounded to BF16 before division, then BF16 output."),
SCHEMA("qk_norm_rope", pQkNormRope, oQkNormRope,
@@ -4877,6 +4895,25 @@ static const RadConstraint cGemmNtI8A8Tiled[] = {
C_DIV("K", R4D_FP8_BLOCK), C_DIV("N", R4D_FP8_BLOCK), C_EQ("group", R4D_FP8_BLOCK),
C_IN("dtype", "i8a8 i8a8h"),
};
/* The rb8 and rb32 tiles': a weight scale per whole 8- or 32-row blocks (`w_rb` a multiple). */
static const RadConstraint cGemmNtI8A8Rb8Tiled[] = {
C_DIV("K", R4D_FP8_BLOCK), C_DIV("N", R4D_FP8_BLOCK), C_EQ("group", R4D_FP8_BLOCK),
C_IN("dtype", "i8a8 i8a8h"), C_GE("w_rb", 8), C_DIV("w_rb", 8),
};
static const RadConstraint cGemmNtI8A8Rb32Tiled[] = {
C_DIV("K", R4D_FP8_BLOCK), C_DIV("N", R4D_FP8_BLOCK), C_EQ("group", R4D_FP8_BLOCK),
C_IN("dtype", "i8a8 i8a8h"), C_GE("w_rb", 32), C_DIV("w_rb", 32),
};
/* The IQR weights (r4d_gemm_iqr.hip): the int8 twins' bands over a weight kept at its codes' width.
* K a multiple of 256, the narrow tile's K step, which both rows check so they serve one band. */
static const RadConstraint cGemmNtIqrM64[] = {
C_LE("M", 64), C_DIV("K", 256), C_DIV("N", 16), C_EQ("group", R4D_FP8_BLOCK),
C_IN("dtype", "i8a8 i8a8h"),
};
static const RadConstraint cGemmNtIqrTiled[] = {
C_DIV("K", 256), C_DIV("N", R4D_FP8_BLOCK), C_EQ("group", R4D_FP8_BLOCK),
C_IN("dtype", "i8a8 i8a8h"),
};
/* libr4d's `K DIV 4`, renamed to docs/OPS.md's `n` as in every quantiser row here. */
static const RadConstraint cQuantActFp8[] = {
C_DIV("n", 4), C_EQ("group", R4D_FP8_BLOCK), C_IN("dtype", "bf16"),
@@ -5668,12 +5705,25 @@ static const RadKernelInfo kKernels[] = {
{ "embed_lookup_bf16", "embed_lookup", "vocab",
"embedding gather, one workgroup a token",
"any n_embd and n_vocab; a negative or out-of-range id writes a zero row",
"i32 tokens, bf16 table and output",
"i32 tokens, a plain bf16 table and bf16 output",
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY,
ROW(cBf16Row), NOTUNE,
nullptr, nullptr, r4d_rad_embed_lookup, nullptr, nullptr, nullptr,
nullptr, nullptr, r4d_rad_embed_lookup, nullptr, r4d_rad_layout_embed_bf16, nullptr,
r4d_shape_embed_lookup },
{ "embed_lookup_iqr", "embed_lookup", "vocab",
"embedding gather over an IQR table kept at its codes' width: a workgroup a token and 128 "
"columns, each thread a value decoded from its codes, the 128-wide Hadamard of a rotated table "
"undone in LDS",
"n_embd a multiple of 128; a negative or out-of-range id writes a zero row",
"i32 tokens, an IQR table (r4d_iqr.h: uB codes under a table or a zero, or a 4096-state "
"trellis, rotated or not), bf16 output; each value the form's int8 times its row's scale, the "
"rotation undone in f32 and rounded once, as the table widened to bf16 would hold it",
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY,
ROW(cBf16Row), NOTUNE,
nullptr, nullptr, r4d_rad_embed_lookup_iqr, nullptr, r4d_rad_layout_iqr_embed,
r4d_rad_relayout_iqr_embed, r4d_shape_embed_lookup },
{ "embed_lookup_q_bf16", "embed_lookup_q", "vocab",
"quantised embedding gather, four entries a thread",
"any n_embd and n_vocab; a negative or out-of-range id writes a zero row",
@@ -5826,6 +5876,16 @@ static const RadKernelInfo kKernels[] = {
ROW(cBf16Row), NOTUNE,
nullptr, nullptr, r4d_rad_seg_mean },
{ "seg_softmax_pool_bf16", "seg_softmax_pool", "elem",
"a segment's rows summed with the softmax of their scores as weights: one row a cu_seqlens "
"segment",
"any n; a thread an output column, one workgroup row a segment, the softmax formed in f32 by "
"every thread",
"bf16 scores, rows and out, f32 weights and sum, one rounding",
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY,
ROW(cBf16Row), NOTUNE,
nullptr, nullptr, r4d_rad_seg_softmax_pool },
{ "qk_norm_rope_bf16", "qk_norm_rope", "attn",
"per-head RMS norm of q and k (and optionally v, unit gain) with rotary on q and k, in place",
"head_dim up to 1024, a multiple of 32 for neox (rotary_dim / 2 a multiple of 32) and gptj; "
@@ -6355,6 +6415,19 @@ static const RadKernelInfo kKernels[] = {
r4d_rad_layout_i8_logits, r4d_rad_relayout_i8_logits,
nullptr, r4d_rad_unrelayout_i8_logits },
{ "logits_gemm_iqr", "logits_gemm", "vocab",
"logits_gemm_i8 over an IQR head kept at its codes' width: each lane's sixteen codes read at "
"their width and looked up in the head's table by byte permutes, then the int8 head's matvec "
"or WMMA tile",
"logits_gemm_fp8's: any M, n_embd a multiple of 128",
"bf16 x, an IQR head (r4d_iqr.h's lm form: 2- to 6-bit codes indexing an int8 table, a bf16 "
"scale per ROW per 128 columns in the row's tail), F32 LOGITS OUT, fp32 accumulate",
RAD_DOMAIN_DEVICE, R4D_PRIO_LOGITS_FP8,
ROW(cLogitsGemmFp8), NOTUNE,
nullptr, nullptr, r4d_rad_logits_gemm_iqr, nullptr,
r4d_rad_layout_iqr_logits, r4d_rad_relayout_iqr_logits,
nullptr, r4d_rad_unrelayout_iqr_logits },
/* ---------------------------- the decomposed sampler chain (r4d_sample_stages_f32.hip) ------
*
* Distinct from sample_chain, which fuses temperature, softmax, top_k, top_p, min_p and the draw
@@ -8113,6 +8186,56 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8)
r4d_rad_layout_i8_block, r4d_rad_relayout_i8_block,
nullptr, r4d_rad_unrelayout_i8_block },
{ "gemm_i8a8_rb8_tiled", "gemm_nt_q", "gemm",
"gemm_i8a8_tiled at a weight scale constant over 8 rows: one scale a lane a tile, the int32 "
"accumulator started at 0x4B400000 so a slot reads as f32 with no conversion, the fp8 fold",
"the i8 row's, at w_rb a multiple of 8",
"i8 A with an f32 scale per (row, 128 K), i8 W with a bf16 scale per 8 ROWS per 128 K (each row "
"of the plane holding its block's), bf16 C; dtype i8a8h as the i8 row",
RAD_DOMAIN_DEVICE, R4D_PRIO_GEMM_FP8_TILED + 1,
ROW(cGemmNtI8A8Rb8Tiled), NOTUNE,
nullptr, nullptr, r4d_rad_gemm_i8a8_rb8_tiled, nullptr,
r4d_rad_layout_i8_block, r4d_rad_relayout_i8_block,
nullptr, r4d_rad_unrelayout_i8_block },
{ "gemm_i8a8_rb32_tiled", "gemm_nt_q", "gemm",
"gemm_i8a8_rb8_tiled at a weight scale per 32 rows: one scale a wave, the fp8 tile's fold and "
"registers",
"the i8 row's, at w_rb a multiple of 32",
"i8 A with an f32 scale per (row, 128 K), i8 W with a bf16 scale per 32 ROWS per 128 K (each "
"row of the plane holding its block's), bf16 C; dtype i8a8h as the i8 row",
RAD_DOMAIN_DEVICE, R4D_PRIO_GEMM_FP8_TILED + 2,
ROW(cGemmNtI8A8Rb32Tiled), NOTUNE,
nullptr, nullptr, r4d_rad_gemm_i8a8_rb32_tiled, nullptr,
r4d_rad_layout_i8_block, r4d_rad_relayout_i8_block,
nullptr, r4d_rad_unrelayout_i8_block },
{ "gemm_iqr_nt_m64", "gemm_nt_q", "gemm",
"gemm_i8a8_nt_m16 over an IQR weight (r4d_iqr.h) kept at its codes' width: each wave fetches its "
"16 rows' codes a K tile ahead and decodes each 64-K supertile into its int8 fragments just "
"before the supertile's WMMA steps (tables and trellis states from LDS)",
"M <= 64; K a multiple of 256; N a multiple of 16, and of a trellis's run",
"i8 A with an f32 scale per (row, 128 K), W an IQR form's codes, decoding to int8 values with a "
"scale per row per 128 K (bf16, or E4M3 under an f32; on a tcq_rb trellis its block's), bf16 C; "
"the int8 narrow tile's split, accumulation and fold, so its output bytes",
RAD_DOMAIN_DEVICE, R4D_PRIO_GEMM_FP8_M16,
ROW(cGemmNtIqrM64), NOTUNE,
nullptr, nullptr, r4d_rad_gemm_iqr_m64, r4d_rad_gemm_iqr_m64_scratch,
r4d_rad_layout_iqr, r4d_rad_relayout_iqr,
nullptr, r4d_rad_unrelayout_iqr },
{ "gemm_iqr_tiled", "gemm_nt_q", "gemm",
"the prefill GEMM over an IQR weight: the call decodes the weight's codes into the int8 fragment "
"plane in its scratch, once, and runs gemm_i8a8_tiled (or its rb8 / rb32 fold on a tcq_rb "
"trellis) over it",
"any M; K a multiple of 256 and N of 128",
"as gemm_iqr_nt_m64, through the int8 prefill tile's arithmetic and output bytes",
RAD_DOMAIN_DEVICE, R4D_PRIO_GEMM_FP8_TILED,
ROW(cGemmNtIqrTiled), NOTUNE,
nullptr, nullptr, r4d_rad_gemm_iqr_tiled, r4d_rad_gemm_iqr_tiled_scratch,
r4d_rad_layout_iqr, r4d_rad_relayout_iqr,
nullptr, r4d_rad_unrelayout_iqr },
/* Band read off the entry point's own rejection tests, not a kernel-side row. */
{ "gemm_w8a8_nt_m64", "gemm_nt_q", "gemm",
"skinny GEMM with an 8-bit weight and an 8-bit activation: the promoted linears of the INT4 "
@@ -8545,6 +8668,17 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8)
/* No opd_shape, for logit_rerank's reason: the declared shape and the stored row differ. */
nullptr, r4d_rad_unrelayout_i8_logits },
{ "logit_rerank_iqr", "logit_rerank", "select",
"logit_rerank over an IQR head: the same candidates rescored against logits_gemm_iqr's rows",
"logit_rerank's: any M, R <= 32, bf16 x and the IQR lm_head rows logits_gemm_iqr stores",
"bf16 in, f32 values + i32 ids out, ties to the lower id",
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY,
ROW(cLogitRerank), NOTUNE,
nullptr, nullptr, r4d_rad_logit_rerank_iqr, nullptr,
r4d_rad_layout_iqr_logits, r4d_rad_relayout_iqr_logits,
/* No opd_shape, for logit_rerank's reason: the declared shape and the stored row differ. */
nullptr, r4d_rad_unrelayout_iqr_logits },
{ "rowtopk_merge", "row_topk_merge", "select",
"the global top-R of world_size all-gathered per-rank candidate sets",
"any M, R <= 32; `gathered` is [M, world_size * R, 2] f32 pairs, an int32 id in the first slot; "
@@ -10169,6 +10303,7 @@ extern "C" int r4d_record_dispatches(const void** fns, int cap) {
}
extern "C" uint32_t rad_plugin_abi_version(void) { return RAD_ABI_VERSION; }
RAD_PLUGIN_ABI_LAYOUT_EXPORT
extern "C" const RadPluginInfo* rad_plugin_info(void) { return &kInfo; }
extern "C" int rad_kernel_schema_count(void) {