radiance 1.14.0

New models and formats:
- libr3d: a kernel library for RDNA3 (gfx11) cards
- nomic-embed-text-v2-moe (the nomicbert plugin)
- Gemma 4 E2B with its per-layer MLP width, and Google's unmodified E2B/E4B directories in bf16
- DeepSeek-V4.1-Flash converted straight from its release: the Engram tables, the fused imatrix and
  rad-convert --chat-template for a release that ships no template
- GGUF Q8_0, Q4_K and Q6_K tensors import as their planes; rad-convert writes them without a recipe
- Qwen3.8-Flash-Next-FP8 converts and serves through qwen4exp_fp8

Speed:
- hc_read's decode kernels as one grid (34.7 -> 25.2 us at 4 rows) and its tiled up-mix pipelined
- gemm_fp8a8: the narrow form's scales staged through LDS (Flash-Next int8 at 32 rows 83.6 -> 68.3
  us), the gated three-tile form at 8 waves (gate_up at 48 rows 272.9 -> 180.6 us)
- Qwen3.8-27B: the delta net's out-projection read beside its decode recurrent update (x1 19.40 ->
  19.10 ms a step), and the verify's split-KV attention sized by context depth (x3 at 180K 42.4 ->
  40.3 ms a step)
- Hy-Memory (HYV3) decode: fused QK norm, RoPE and KV store, residual adds folded into the norms,
  coalesced one-token expert GEMMs
- spechub: the coupled verify walks the live candidates only (151 -> 31 us a launch)

Speculation:
- DFlash2: lossless coupled acceptance at T > 0 (--draft-coupling on)
- A block drafter's proposals verified as a tree, on by default for the Gemma 4 31B's DFlash2, with
  a block-16 tree that runs its short block under load

Features:
- Decode-hot residency: --draft-expert-placement host, --expert-profile, --expert-pin-top, and
  --expert-stats FILE for the routed experts each layer selects
- --ngram-placement ram=DIR: one n-gram table shared by engines on separate cards
- Prefix cache: --prefix-resume exact (default) resumes a hit on the cold run's own chunk grid, so it
  answers bit-identically; snapshots at a head other prompts share, from 528-token prompts, and for
  tip-only one drafter window below the tip; hits on models whose KV groups have different block
  sizes; the snapshot store keeps a floor of 8 ahead of --host-headroom-mib
- Typed tool-call argument tags; rad-chatparse --request renders and reads back one request as the
  server does
- MiniMax-H3: keyframes ride a latent upscale
- Gemma 3's fused all-reduce junction on the lossy wire

Fixes:
- A speculative step shorter than its band (an MTP step of 4 rows at gqa 8) no longer stops the
  engine with a scratch refusal at issue (#293)
- --p2p off: prefill back to 1.12.0's rate; 1.13.0's push check read a host-memory slot over the link
  twice (#323)
- A chat template that cannot render a conversation is refused at load, not mid-request
- imatrix entries found under llama.cpp's spelling; the W4A8 prefill's tail scale read; the GDN conv
  kernels on an f32 weight; dense integer rows at the group they compute (a Q8_0 weight at group 32)
- --expert-profile refuses a profile recorded on another model
- hc_read's one-grid wait traps past its deadline instead of reading a stale value

Changes: Plugin ABI 31, unchanged. RADIANCE_DRAFT_TREE, DFLASH2_TREE_NODES, DFLASH2_TREE_TEMP and
DFLASH_Q_TEMP are gone (trees run where the probe says they pay; temperatures 1.25 / 0.6).
This commit is contained in:
Deadcode committed 2026-10-29 12:04:24 +01:00
1 parent 481fcd5df0
commit 4a61d7296b
160 files changed
+8790 -6819

No files matched your search

+119 -1
View File
@@ -123,6 +123,18 @@ static const RadOperandSpec oAttnPaged[] = {
{ "cu_seqlens", RAD_OPD_IN, 1 }, /* absent = one q_len for the whole batch */
{ "out", RAD_OPD_OUT, 0 },
};
/* attn_paged_qrow with a tree verify's parents (RadBatch::spec_parent, rad_drafter_tree). */
static const RadOperandSpec oAttnPagedTree[] = {
{ "q", RAD_OPD_IN, 0 },
{ "kv_cache", RAD_OPD_IN, 0 },
{ "block_table", RAD_OPD_IN, 0 },
{ "seqused", RAD_OPD_IN, 0 },
{ "k_descale", RAD_OPD_IN, 1 },
{ "v_descale", RAD_OPD_IN, 1 },
{ "cu_seqlens", RAD_OPD_IN, 1 },
{ "out", RAD_OPD_OUT, 0 },
{ "spec_parent", RAD_OPD_IN, 0 },
};
/* attn_paged with gate_quant_fp8 folded into its merge: attn_paged's parameters plus the two of
* gate_quant_fp8's that are not implied (its `n` is `head_dim`, its rows attn_paged's (token,
@@ -700,6 +712,28 @@ static const RadOperandSpec oDflashSelect[] = {
{ "succ", RAD_OPD_WEIGHT, 0 },
{ "tokens", RAD_OPD_OUT, 0 },
};
/* dflash_tree: dflash_select's, plus the node count, the softmax temperature and the parents. */
static const RadParamSpec pDflashTree[] = {
{ "M", RAD_P_INT, RAD_REQUIRED },
{ "steps", RAD_P_INT, RAD_REQUIRED },
{ "top_k", RAD_P_INT, RAD_REQUIRED },
{ "rank", RAD_P_INT, RAD_REQUIRED },
{ "n_vocab", RAD_P_INT, RAD_REQUIRED },
{ "anchor_stride", RAD_P_INT, RAD_OPTIONAL },
{ "nodes", RAD_P_INT, RAD_REQUIRED },
{ "temp", RAD_P_F64, RAD_OPTIONAL },
{ "dtype", RAD_P_STR, RAD_REQUIRED },
};
static const RadOperandSpec oDflashTree[] = {
{ "cand", RAD_OPD_IN, 0 },
{ "unary", RAD_OPD_IN, 0 },
{ "hp", RAD_OPD_IN, 1 },
{ "anchor", RAD_OPD_IN, 0 },
{ "pred", RAD_OPD_WEIGHT, 0 },
{ "succ", RAD_OPD_WEIGHT, 0 },
{ "tokens", RAD_OPD_OUT, 0 },
{ "parents", RAD_OPD_OUT, 0 },
};
/* ------------------------------------------------------------------------------ collectives */
static const RadParamSpec pAllReduce[] = {
@@ -3131,6 +3165,11 @@ static const RadOpSchema kSchemas[] = {
"attn_paged, parameter for parameter and value for value, with q read at its own row "
"pitch: a column slice of a wider row -- the q part of a fused [q|k|v] projection -- read "
"where it lies rather than lifted into a dense block first."),
SCHEMA("attn_paged_qrow_tree", pAttnPaged, oAttnPagedTree,
"attn_paged_qrow over a tree verify (rad_drafter_tree): spec_parent is -2 for an "
"ordinary causal row, else the row's parent's index within its sequence's rows (-1 for "
"the block's first row). Inside the block such a row sees itself and its ancestors "
"only, and its window is measured from the block's first position plus its depth."),
SCHEMA("attn_paged_gate_quant", pAttnPagedGq, oAttnPagedGq,
"attn_paged followed by gate_quant_fp8 over its output, in the split-KV merge: each "
"merged (token, head) row is gated, rounded, written to `out` and quantised to E4M3 "
@@ -3237,6 +3276,12 @@ static const RadOpSchema kSchemas[] = {
"positions, and the greedy walk that turns a block of independent top-k sets into one "
"path. Only the K edges leaving the previous pick are scored, because the walk is "
"serial and the other K-1 rows of the score matrix are never read."),
SCHEMA("dflash_tree", pDflashTree, oDflashTree,
"dflash_select's lattice and edge scores grown best-first into a tree of `nodes` nodes: "
"a taken node's children are the valid candidates at the next position, each with log "
"probability parent + log_softmax(score / temp) over them; each round takes the largest "
"untaken child (ties to the first pushed). tokens and parents list the taken nodes in "
"order, a parent as its node index, 0 for the anchor."),
SCHEMA("all_reduce", pAllReduce, oAllReduce,
"sum over the tensor-parallel group. `exact` separates the exact sum from the "
"quantised wire and a caller that does not declare it gets no kernel. At 4 and 8 ranks "
@@ -3907,6 +3952,15 @@ static const RadConstraint cAttnDecodeH256Gqa2Fp8[] = {
C_GE("window", 0), C_EQ("head_dim", 256), C_EQ("gqa", 2), C_EQ("block_size", 16),
C_GE("causal", 0), C_LE("q_len", 32), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "fp8_e4m3"),
};
/* attn_paged_qrow_tree on the same kernel: causal only (a tree has no two-sided reading). */
static const RadConstraint cAttnTreeDecodeH256Gqa2Fp8[] = {
C_GE("window", 0), C_EQ("head_dim", 256), C_EQ("gqa", 2), C_EQ("block_size", 16),
C_EQ("causal", 1), C_LE("q_len", 32), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "fp8_e4m3"),
};
static const RadConstraint cAttnTreeDecodeH256Gqa2Bf16[] = {
C_GE("window", 0), C_EQ("head_dim", 256), C_EQ("gqa", 2), C_EQ("block_size", 16),
C_EQ("causal", 1), C_LE("q_len", 32), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "bf16"),
};
static const RadConstraint cAttnDecodeH256Gqa2Bf16[] = {
C_GE("window", 0), C_EQ("head_dim", 256), C_EQ("gqa", 2), C_EQ("block_size", 16),
C_GE("causal", 0), C_LE("q_len", 32), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "bf16"),
@@ -4442,6 +4496,12 @@ static const RadConstraint cDflashSelect[] = {
C_GE("steps", 1), C_GE("top_k", 1), C_LE("top_k", 32),
C_DIV("rank", 32), C_LE("rank", 512), C_IN("dtype", "bf16"),
};
/* dflash_tree's frontier (nodes x top_k children) and its node table live in LDS. */
static const RadConstraint cDflashTree[] = {
C_GE("steps", 1), C_LE("steps", 63), C_GE("top_k", 1), C_LE("top_k", 32),
C_DIV("rank", 32), C_LE("rank", 512), C_GE("nodes", 1), C_LE("nodes", 63),
C_IN("dtype", "bf16"),
};
/* The sandwich-norm joins hold 24 elements a thread over a 256-thread block (n <= 6144), and the
* route form quantises in whole 128-column groups. pair_argmax takes any row; expert_scale's top_k
* is the router's, at most 64. */
@@ -6630,6 +6690,28 @@ static const RadKernelInfo kKernels[] = {
r4d_rad_attn_qrow_decode_h256_gqa2_scratch,
nullptr, nullptr, nullptr },
/* The same under attn_paged_qrow_tree: a tree verify's mask (O_TREE instances), causal only. */
{ "attn_qrow_tree_decode_h256_gqa2_fp8kv", "attn_paged_qrow_tree", "attn",
"paged attention over a tree verify, q at its own row pitch, sliding window, split-KV",
"head_dim 256, 2 queries per kv head, paged block 16, q_len*gqa <= 64, causal",
"bf16 query (any row pitch, a multiple of 4), fp8-e4m3 kv cache with per-(seq,head) descales, "
"i32 parents, bf16 out, f16 partials",
RAD_DOMAIN_DEVICE, R4D_PRIO_ATTN_DECODE,
ROW(cAttnTreeDecodeH256Gqa2Fp8), ROW(tAttnSplit), nullptr,
nullptr, nullptr, r4d_rad_attn_qrow_tree_decode_h256_gqa2_fp8,
r4d_rad_attn_qrow_decode_h256_gqa2_scratch,
nullptr, nullptr, nullptr },
{ "attn_qrow_tree_decode_h256_gqa2_bf16kv", "attn_paged_qrow_tree", "attn",
"paged attention over a tree verify, q at its own row pitch, sliding window, split-KV",
"head_dim 256, 2 queries per kv head, paged block 16, q_len*gqa <= 64, causal",
"bf16 query (any row pitch, a multiple of 4), bf16 kv cache, i32 parents, bf16 out, f16 partials",
RAD_DOMAIN_DEVICE, R4D_PRIO_ATTN_DECODE,
ROW(cAttnTreeDecodeH256Gqa2Bf16), ROW(tAttnSplit), nullptr,
nullptr, nullptr, r4d_rad_attn_qrow_tree_decode_h256_gqa2_bf16,
r4d_rad_attn_qrow_decode_h256_gqa2_scratch,
nullptr, nullptr, nullptr },
/* Head_dim 128 at gqa 8 under attn_paged_qrow (cAttnQrowH128G8Fp8 says why). */
{ "attn_qrow_h128_gqa8_fp8kv", "attn_paged_qrow", "attn",
"paged attention, any window, causal or not, split-KV (draft block); q at any row pitch",
@@ -6818,6 +6900,27 @@ R4D_WIN_PAIR(512, 1) R4D_WIN_PAIR(512, 2) R4D_WIN_PAIR(512, 4) R4D_WIN_PAIR(512,
#undef R4D_WIN_PAIR
#undef R4D_WIN_ROW
/* ...and under attn_paged_qrow_tree, the scalar kernel with a tree verify's mask (the launch
* refuses a non-causal one and never takes the WMMA kernel). */
#define R4D_WIN_TREE_ROW(HD, G, KVN, KVS, C, KVDOC) \
{ "attn_qrow_tree_h" #HD "_gqa" #G "_" #KVN, "attn_paged_qrow_tree", "attn", \
"paged attention over a tree verify, q at its own row pitch, any window, causal", \
"head_dim " #HD ", " #G " queries per kv head, paged block 16, any q_len, varlen", \
"bf16 query (any row pitch), " KVDOC " kv cache, i32 parents, bf16 out, f32 partials", \
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY, \
ROW(C), NOTUNE, \
nullptr, nullptr, r4d_rad_attn_window_tree_h##HD##_gqa##G##_##KVS, \
r4d_rad_attn_window_h##HD##_scratch, \
nullptr, nullptr, nullptr },
#define R4D_WIN_TREE_PAIR(HD, GQ) \
R4D_WIN_TREE_ROW(HD, GQ, bf16kv, bf16, cWinH##HD##G##GQ##Bf16, "bf16") \
R4D_WIN_TREE_ROW(HD, GQ, fp8kv, fp8, cWinH##HD##G##GQ##Fp8, "fp8-e4m3 (per-(seq,head) descales)")
R4D_WIN_TREE_PAIR(256, 1) R4D_WIN_TREE_PAIR(256, 2) R4D_WIN_TREE_PAIR(256, 4)
R4D_WIN_TREE_PAIR(256, 8) R4D_WIN_TREE_PAIR(512, 1) R4D_WIN_TREE_PAIR(512, 2)
R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8)
#undef R4D_WIN_TREE_PAIR
#undef R4D_WIN_TREE_ROW
{ "attn_prefill_h256_gqa12_fp8kv", "attn_paged", "attn",
"paged causal attention, query-tiled (prefill / chunked prefill)",
"head_dim 256, 12 queries per kv head, paged block 4, varlen",
@@ -9015,6 +9118,16 @@ R4D_WIN_PAIR(512, 1) R4D_WIN_PAIR(512, 2) R4D_WIN_PAIR(512, 4) R4D_WIN_PAIR(512,
nullptr, nullptr, r4d_rad_dflash_select, nullptr, nullptr, nullptr,
r4d_shape_dflash_select },
{ "dflash_tree_bf16", "dflash_tree", "dflash",
"DFlash2's candidate lattice grown best-first into a tree (rad_drafter_tree): the selector's "
"edge scores for each taken node's children, one workgroup a sequence",
"top_k <= 32, rank a multiple of 32 and <= 512, steps and nodes <= 63: the frontier and the "
"node table are LDS extents",
"i32 candidate ids, f32 unary logits, bf16 hp and both codebooks, i32 tokens and parents out",
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY,
ROW(cDflashTree), NOTUNE,
nullptr, nullptr, r4d_rad_dflash_tree, nullptr, nullptr, nullptr, nullptr },
/* pair_argmax, the sandwich-norm joins and expert_scale. The joins and expert_scale have no
* opd_shape: libref has no row for them, and tests/r4d_emu holds their source to the replaced chain
* bit for bit on the host. pair_argmax is described as libref describes it. */
@@ -10034,6 +10147,8 @@ extern "C" int rad_kernel_chain(int i) {
* plain, and the backend chains only the kernels named r4dchain* */
"attn_decode_h256_gqa2_fp8kv", "attn_decode_h256_gqa2_bf16kv",
"attn_qrow_decode_h256_gqa2_fp8kv", "attn_qrow_decode_h256_gqa2_bf16kv",
/* ...and their tree verify forms (O_TREE instances, the same launch) */
"attn_qrow_tree_decode_h256_gqa2_fp8kv", "attn_qrow_tree_decode_h256_gqa2_bf16kv",
/* the fused junction: its tail form (the two-shot with the junction after it) only */
"ar_rmsnorm_quant_i8", "ar_rmsnorm_quant_i8_4rank",
/* the 31B's full layers: the windowed attention and its merge (r4d_attn_paged_window.hip,
@@ -10041,6 +10156,9 @@ extern "C" int rad_kernel_chain(int i) {
"attn_qrow_h512_gqa2_fp8kv", "attn_qrow_h512_gqa2_bf16kv",
"attn_qrow_h512_gqa4_fp8kv", "attn_qrow_h512_gqa4_bf16kv",
"attn_qrow_h512_gqa8_fp8kv", "attn_qrow_h512_gqa8_bf16kv",
"attn_qrow_tree_h512_gqa2_fp8kv", "attn_qrow_tree_h512_gqa2_bf16kv",
"attn_qrow_tree_h512_gqa4_fp8kv", "attn_qrow_tree_h512_gqa4_bf16kv",
"attn_qrow_tree_h512_gqa8_fp8kv", "attn_qrow_tree_h512_gqa8_bf16kv",
"quant_act_i8",
/* DFlash2's query and context passes: the narrow fp8 GEMMs (the gated gate_up among
* them), the activation quantiser, the norms, the conv projection, the opening
@@ -10058,7 +10176,7 @@ extern "C" int rad_kernel_chain(int i) {
* selector */
"sample_temp_f32", "sample_topk_f32", "sample_merge_topk_f32", "sample_pick_f32",
"ar_gather_4rank", "gemm_w8a8_nt_m64", "rowtopk_bf16", "rowtopk_merge",
"dflash_select_bf16",
"dflash_select_bf16", "dflash_tree_bf16",
/* the weight read beside a collective (its blocks add before reading, r4d_prefetch.hip) */
"prefetch",
};