radiance 1.11.0

New models:
- GLM-5.3-Flash reads pictures: its vision tower and processor (--image-tokens sets the budget),
  with decode kernels for a few rows and the DSA indexer split over the ranks
- Sage-A1.5 (fp8 and MXFP4) with its vision tower and a DFlash2 drafter
- Unlimited-OCR (bf16)
- Gemma 4 31B with z-lab's DFlash and RedHatAI's DFlash2 drafters; at four cards its all-reduces
  are fused with the junctions, overlapped with the compute and sent compressed
- Ornith-1.5-35B-A3B w4a8 compose files

Speed:
- Block drafters (DFlash, DFlash2) accept their drafts on the card, and the next step is issued
  ahead
- The four-rank all-reduce is faster for every --tp 4 model
- qwen35_w8a8: the norms and SiLU write the int8 linears' operands directly
- --attn-prefill-fp8 off|qk|pv|both: fp8 QK and PV legs for the h256 prefill attention (about +20%
  prefill on a 221K-token prompt for the 27B MXFP4 at TP2); lossy, off by default

Features:
- Control vectors: --control-vector off|on|disabled (disabled by default), a per-request switch,
  and the published Qwen3.8-Flash-Next refusal-direction vector (its license is in NOTICE)
- Krea 2: the `rebalance` request field, as ComfyUI's ConditioningKrea2Rebalance
- Cards with a small PCI BAR run, with kernel arguments kept in host memory
- Dashboard: live acceptance figures; statsdump rotates its file at a size cap
- KV caches every rank holds whole (GLM-5.3's latent and index caches) take one host-tier slot

Fixes:
- Long conversations taking turns no longer fall back to an early snapshot: a host-tier restore
  makes room as memory pressure does and waits a step for the previous turn's release (two
  conversations of 142K and 147K tokens sent back to back: 31.3 s per turn before, 2.8 s now)
- Kernels before Linux 6.16 (amdgpu below 3.64) no longer hang at startup: virtual memory
  management is turned off there, with a warning
- Gemma 4 dense scales its token embeddings as Hugging Face does (bf16), which changes its output
- The four-rank all-reduce fences prefill-sized messages, for a rare divergence after a fresh start
- GLM-5.3: every refusal names the setting and the reason; its template keeps string content
- Several pictures in one request no longer refuse processors that take one image at a time

Changes: Plugin ABI 26: out-of-tree plugins must be rebuilt. The environment switches the PRs
added are fixed rules or flags now (R4D_ATTN_FP8 is --attn-prefill-fp8).
This commit is contained in:
Deadcode committed 2026-10-23 11:57:52 +02:00
210 files changed
+14363 -2138

No files matched your search

+105 -12
View File
@@ -1398,6 +1398,40 @@ int ref_chan_stats_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* ou
return o.finish("chan_stats", operand, out);
}
/* The SAM tower's attention (ref_sam_attn.cpp): a row of `n_head * head_dim`, one raster
* grid_h x grid_w segment a cu entry, and the two rel_pos tables. Their length follows the contract
* in arch/common/rad_block_sam.h: 2*maxdist-1 rows with maxdist the window, or the longer grid axis
* for a global layer (which is the length a resampled table needs; the op resamples along dim 0
* either way). */
int ref_sam_attn_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) {
const int64_t M = gi(p, n_p, "M", 0);
const int64_t hd = gi(p, n_p, "head_dim", 0);
const int64_t nh = gi(p, n_p, "n_head", 0);
const int64_t gh = gi(p, n_p, "grid_h", 0);
const int64_t gw = gi(p, n_p, "grid_w", 0);
const int64_t win = gi(p, n_p, "window", 0);
if (M <= 0 || hd <= 0 || nh <= 0 || gh <= 0 || gw <= 0 || win < 0) return RAD_E_UNSUPPORTED;
/* A shape hook answers "describe this geometry", so an unbuildable one spells E_UNSUPPORTED
* (the harness convention); the kernels' own launch checks report E_SHAPE for the same
* inputs. */
const int64_t W = nh * hd;
const int64_t S = n_seq_of(p, n_p);
const int64_t maxd = win > 0 ? win : (gh > gw ? gh : gw);
const int64_t tab = 2 * maxd - 1;
const uint32_t D = act_dt(p, n_p);
Opd o;
o.t(D, { M, W }); /* q */
o.t(D, { M, W }); /* k */
o.t(D, { M, W }); /* v */
/* [0, ..., M], the batch's shape, not a draw. */
o.t_idx({ S + 1 }, 0, -1, (uint32_t)RAD_OPD_F_IDX_CU); /* cu_seqlens */
o.t(D, { M, W }); /* out */
o.t(D, { tab, hd }); /* rel_pos_h */
o.t(D, { tab, hd }); /* rel_pos_w */
return o.finish("sam_attn", operand, out);
}
int ref_kv_store_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) {
const int64_t M = gi(p, n_p, "M", 0);
const int64_t hd = gi(p, n_p, "head_dim", 0);
@@ -1669,8 +1703,55 @@ int ref_moe_scatter_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* o
return o.finish("moe_scatter", operand, out);
}
/* `a_order` decides the activation's row count: one per token, or one per (token, slot) in
* scatter order. */
/* The two shape lists concatenated, with `expert_ids` named ONCE as an output -- it is what the
* selection writes and what the sort reads. The sort's three outputs are sized by THIS RANK'S
* SLICE (`n_local`, absent means the slice is the router), exactly as in libr4d's shape. */
int ref_router_topk_scatter_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) {
const int64_t M = gi(p, n_p, "M", 0);
const int64_t ne = gi(p, n_p, "n_expert", 0);
const int64_t k = gi(p, n_p, "top_k", 0);
const int64_t nl = gi(p, n_p, "n_local", ne);
if (M <= 0 || ne <= 0 || k <= 0 || k > ne || nl <= 0 || nl > ne) return RAD_E_UNSUPPORTED;
const uint32_t D = act_dt(p, n_p);
Opd o;
o.t(D, { M, ne }); /* logits */
o.t((uint32_t)RAD_I32, { M, k }); /* expert_ids */
o.t(D, { M, k }); /* expert_w */
o.t((uint32_t)RAD_I32, { M * k }); /* sorted_tok */
o.t((uint32_t)RAD_I32, { nl + 1 }); /* expert_offset */
o.t((uint32_t)RAD_I32, { nl }); /* expert_count */
return o.finish("router_topk_scatter", operand, out);
}
/* The router GEMM's list, the pair's list, and -- with the gate present -- the gate's one-column
* list, with `logits` named once as the GEMM's output. `gate_b`/`gate` come together or not: the
* operand count carries it, as in libr4d's shape. */
int ref_router_gemm_topk_scatter_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) {
const int64_t M = gi(p, n_p, "M", 0);
const int64_t K = gi(p, n_p, "K", 0);
const int64_t ne = gi(p, n_p, "n_expert", 0);
const int64_t k = gi(p, n_p, "top_k", 0);
const int64_t nl = gi(p, n_p, "n_local", ne);
if (M <= 0 || K <= 0 || ne <= 0 || k <= 0 || k > ne || nl <= 0 || nl > ne)
return RAD_E_UNSUPPORTED;
const uint32_t D = act_dt(p, n_p);
Opd o;
o.t(D, { M, K }); /* a */
o.t(D, { ne, K }); /* b: the router */
o.t(D, { 1, K }); /* gate_b: the shared expert's gate */
o.t(D, { M, ne }); /* logits */
o.t((uint32_t)RAD_I32, { M, k }); /* expert_ids */
o.t(D, { M, k }); /* expert_w */
o.t((uint32_t)RAD_I32, { M * k }); /* sorted_tok */
o.t((uint32_t)RAD_I32, { nl + 1 }); /* expert_offset */
o.t((uint32_t)RAD_I32, { nl }); /* expert_count */
o.t(D, { M, 1 }); /* gate */
return o.finish("router_gemm_topk_scatter", operand, out);
}
/* `a_order` decides the activation's row count: one per token, or one per (token, slot) already
* in the scatter's order. A described case that got this wrong would build the operand at the
* extent the WRONG reading wants, and the fault it names would go unseen. */
static inline bool sorted_a_order(const RadParam* p, int n_p) {
const char* s = gs(p, n_p, "a_order");
return s && std::strcmp(s, "sorted") == 0;
@@ -2321,6 +2402,28 @@ int ref_sample_dry_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* ou
return penalty_shape(p, n_p, operand, "sample_dry", true, out);
}
/* The n-gram ban reads the same history the two penalty stages do and writes the logits in place,
* and adds one small plane beside them: `ngram`, an i32 {n-gram length, window} pair a row. It is
* a plane of its own rather than fields in `params` because the params row is a fixed 24-word wire
* format shared by every sampler op (and recorded in the kbench fixtures). Drawn in 0..63 so both
* a length inside the 64-token history and the 0 (= off) and whole-window forms occur.
*
* The optional `whitelist` bitmask is sample_mask's plane shape (word w bit b covers column
* 32w + b, a SET bit marking an exempt token), addressed by the sampled row itself; a random draw
* fills it with random bits, so a sweep exercises exemptions as often as plain bans. */
int ref_sample_ngram_ban_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) {
int64_t M = 0, nv = 0;
if (sample_vocab(p, n_p, &M, &nv) < 0) return RAD_E_UNSUPPORTED;
Opd o;
o.t((uint32_t)RAD_F32, { M, nv }); /* logits, INOUT */
sample_params(o, M, REF_SAMPLE_HIST, 0); /* params */
o.t_idx({ M, (int64_t)REF_SAMPLE_HIST }, nv, -1,
(uint32_t)RAD_OPD_F_IDX_HISTORY); /* history */
o.t_idx({ M, 2 }, 64, -1, 0); /* ngram: {n, window} */
o.t((uint32_t)RAD_I32, { M, (nv + 31) / 32 }); /* whitelist, optional */
return o.finish("sample_ngram_ban", operand, out);
}
int ref_sample_temp_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) {
int64_t M = 0, nv = 0;
if (sample_vocab(p, n_p, &M, &nv) < 0) return RAD_E_UNSUPPORTED;
@@ -3534,16 +3637,6 @@ int ref_tile_stitch_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* o
return o.finish("tile_stitch", operand, out);
}
int ref_patch_pix8_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) {
const int64_t M = gi(p, n_p, "M", 0), pp = gi(p, n_p, "p", 0), C = gi(p, n_p, "C", 0);
const int64_t w = cols_for(M, 1), R = w ? M / w : 0;
if (!w || pp <= 0 || C <= 0) return RAD_E_UNSUPPORTED;
Opd o;
o.t(act_dt(p, n_p), { R, w * C * pp * pp }); /* x: patch rows */
o.t((uint32_t)RAD_U8, { R * pp, w * pp * C }); /* y: bytes */
return o.finish("patch_pix8", operand, out);
}
int ref_stft_logmel_shape(const RadParam* p, int n_p, int operand, RadOpdDesc* out) {
const int64_t M = gi(p, n_p, "M", 0), hop = gi(p, n_p, "hop", 0), nfft = gi(p, n_p, "nfft", 0);
const int64_t nm = gi(p, n_p, "n_mel", 0), ch = gi(p, n_p, "ch", 0), F = nfft / 2 + 1;