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

+24 -12
View File
@@ -82,6 +82,10 @@ struct R4DArgs {
// The engine's chained launch (RadKernelChainFn, r4d_chain.h): the decode path launches its
// chained forms. fill_paged sets it from the resolved `chain` parameter.
int chain;
// A tree verify (attn_paged_qrow_tree, docs/OPS.md): RadBatch::spec_parent, one int32 a query
// row, -2 for an ordinary causal row, else the row's parent's index within its sequence's rows
// (-1 for the block's first). Read only by the O_TREE instances; null elsewhere.
const int* spec_parent;
};
// Rows of q and out. The split-KV scratch is laid out by dense query row, so the host sizing hook
@@ -129,6 +133,9 @@ long r4d_attn_decode_h128_gqa2w_scratch_bytes(const R4DArgs* a);
// ...with q at R4DArgs::q_ld (attn_paged_qrow).
int r4d_attn_decode_h256_gqa2_qld_fp8kv (const R4DArgs* a, hipStream_t stream);
int r4d_attn_decode_h256_gqa2_qld_bf16kv (const R4DArgs* a, hipStream_t stream);
// ...and a tree verify's mask from R4DArgs::spec_parent (attn_paged_qrow_tree).
int r4d_attn_decode_h256_gqa2_qld_tree_fp8kv (const R4DArgs* a, hipStream_t stream);
int r4d_attn_decode_h256_gqa2_qld_tree_bf16kv (const R4DArgs* a, hipStream_t stream);
// The geometry the attention kernels above are compiled for, so a caller can check a model
// before the first launch.
void r4d_attn_dims(int* head_dim, int* gqa, int* block_size, int* max_decode_rows);
@@ -291,18 +298,22 @@ void r4d_ar_ipc_enable_peer(long peer);
// VRAM. Zeroed; the address is valid on every card and the CPU. Startup-only.
long r4d_ar_host_alloc(long size);
void r4d_ar_host_free(long p);
// `stage`, the last argument of every 2-rank kernel below: 0, or a host-mailbox instance's mirror
// of its slots in this card's VRAM (same layout), which the reader's push check fills as it reads
// the slot so the reduce reads VRAM instead of the link a second time (r4d_ar_seq.h).
// Exact sum, fp32 accumulate, bf16 / fp16 / fp32 payload (dtype 0 / 1 / 2).
void r4d_ar_oneshot_2rank_exact(long peer_scratch, long my_scratch, long peer_flags, long my_flags,
long seq_ctrs, long slot_stride16, long inp, long out, long n_elem,
long dtype, long stream, long nblocks, long nthreads, long drain,
long acq);
long acq, long stage = 0);
// Same topology, with the wire payload Walsh-Hadamard rotated and quantised to 6 bits per element
// in groups of 64 (plus a bf16 scale per group). Lossy; bf16 / fp16 payload only. loc_pack is this
// rank's own packed copy, so the reduce folds exactly the bytes it sent.
void r4d_ar_oneshot_2rank_wht6(long peer_scratch, long my_scratch, long peer_flags, long my_flags,
long seq_ctrs, long loc_pack, long slot_stride_bytes,
long scale_off_bytes, long inp, long out, long n_elem, long dtype,
long stream, long nblocks, long nthreads, long drain, long acq);
long stream, long nblocks, long nthreads, long drain, long acq,
long stage = 0);
// The exact all-reduce of `y` [M][n] bf16 with hc_write as its epilogue: h[r][c*n + i] +=
// inj[r][c] * y[r][i] over the reduced y, byte-identical to all_reduce then hc_write. `irow` and
// `hrow` are the pitches of inj [M][hc] and h [M][hc*n] in elements; y is tight. A non-zero `gate`
@@ -311,7 +322,7 @@ void r4d_ar_oneshot_2rank_wht6(long peer_scratch, long my_scratch, long peer_fla
void r4d_ar_hc_write(long peer_scratch, long my_scratch, long peer_flags, long my_flags,
long seq_ctrs, long slot_stride16, long y, long inj, long h, long M, long n,
long hc, long irow, long hrow, long stream, long nblocks, long nthreads,
long drain, long acq, long gate, long gate_ctr);
long drain, long acq, long gate, long gate_ctr, long stage = 0);
// The same with the MoE gather as its prologue: y is produced, not read, from the routed experts'
// rows `ye` [M*top_k][ye_ld] summed to token order by weights `ew` [M][ew_ld] and `sorted`
// [M*top_k], with the shared arm `sh` [M][sh_ld] and its gate `sg` folded when both are non-zero.
@@ -323,7 +334,8 @@ int r4d_ar_gather_hc_write(long peer_scratch, long my_scratch, long peer_flags,
long n, long hc, long irow, long hrow, long ye, long ew, long sorted,
long sh, long sg, long ye_ld, long ew_ld, long sh_ld, long sg_ld,
long top_k, long sig, long stream, long nblocks, long nthreads,
long drain, long acq, long inv, long gate, long gate_ctr);
long drain, long acq, long inv, long gate, long gate_ctr,
long stage = 0);
// r4d_ar_hc_write and r4d_ar_gather_hc_write on the rotated 6-bit wire (r4d_ar_oneshot_2rank_wht6's
// format, loc_pack and scratch split): byte-identical to all_reduce on that wire then hc_write,
// with `ye` non-zero preceded by moe_gather. Gather operands as r4d_ar_gather_hc_write; its slot
@@ -336,7 +348,7 @@ int r4d_ar_hc_write_wht6(long peer_scratch, long my_scratch, long peer_flags, l
long irow, long hrow, long ye, long ew, long sorted, long sh, long sg,
long ye_ld, long ew_ld, long sh_ld, long sg_ld, long top_k, long sig,
long stream, long nblocks, long nthreads, long drain, long acq,
long gate, long gate_ctr);
long gate, long gate_ctr, long stage = 0);
int r4d_ar_max_blocks(void); // the two 2-rank kernels
void r4d_ar_wht6_dims(int* group, int* bits, int* chunk_elems); // rotated-6-bit payload only
@@ -349,7 +361,7 @@ void r4d_ar_gather_2rank(long peer_scratch, long my_scratch, long peer_flags, lo
long seq_ctrs, long slot_stride16, long inp, long out, long n_elem,
long dtype, long rank, long row_elems, long stream, long nblocks,
long nthreads, long drain, long acq, long dpitch,
long spitch);
long spitch, long stage = 0);
// ---- all-reduce: one-shot, push, 4 or 8 ranks over P2P -------------------------------------
// The same algorithm at width (r4d_ar_oneshot_Nrank_exact.hip). Peer arguments are in ascending
@@ -703,8 +715,8 @@ void r4d_moe_gemm_pin_down_dec(int pin);
void r4d_hc_read_pin_prefill(int form);
// Test hook: pins the gated residual read's decode kernels. 0 is the launcher's rule (kernels A and
// B as one grid at one to seven rows where the per-stream counters exist, the tiled up-mix's K
// passes pipelined from eight rows), 1 the kernels the rule replaced (A, then the up-mix in a second
// launch; the tiled up-mix's passes in sequence). Bit-identical; r4d_selftest compares their bytes
// passes pipelined from eight rows), 1 the two-grid form (A, then the up-mix in a second launch;
// the tiled up-mix's passes unpipelined). Bit-identical; r4d_selftest compares their bytes
// and --perfhc times both.
void r4d_hc_read_pin_decode(int form);
// Test hook: pins the MLA matrix row's key load. 0 is the launcher's rule (sixteen-byte vectors
@@ -821,7 +833,7 @@ int r4d_ar_rmsnorm_quant_fp8(long peer_scratch, long my_scratch, long peer_flag
int M, int n, float eps, float wadd, int w_f32,
int r_ld, int y_ld, int q_ld, int s_ld, long stream,
int nblocks, int nthreads, int drain, int acq, int wire,
long loc_pack, long loc_scale_off, long wp = 0);
long loc_pack, long loc_scale_off, long wp = 0, long stage = 0);
int r4d_ar_rmsnorm_quant_fp8_chunk_elems(void);
// Its rotated int8 form, as r4d_rmsnorm_had_quant_i8g: the reduction and the norm unchanged, the
// norm's pass quantised by had_quant_act_i8g's rule. No post-norm.
@@ -831,7 +843,7 @@ int r4d_ar_rmsnorm_had_quant_i8g(long peer_scratch, long my_scratch, long peer_
int M, int n, float eps, float wadd, int w_f32,
int r_ld, int y_ld, int q_ld, int s_ld, long stream,
int nblocks, int nthreads, int drain, int acq, int wire,
long loc_pack, long loc_scale_off);
long loc_pack, long loc_scale_off, long stage = 0);
// The same IPC with the sandwich-norm junction after it (r4d_rmsnorm_quant_i8.hip): post-norm of
// the reduced `x` (`wp`), the residual add, the [1] scalar (`sc`), the norm (`w`) and the w4a8
@@ -840,7 +852,7 @@ int r4d_ar_rmsnorm_quant_i8(long peer_scratch, long my_scratch, long peer_flags
long seq_ctrs, long slot_stride16, long x, long res, long w, long wp,
long sc, int sc_f32, long y, long q, long s, int M, int n, float eps,
float wadd, int w_f32, int r_ld, int y_ld, long stream, int nblocks,
int drain, int acq);
int drain, int acq, long stage = 0);
// ...and at four ranks, on the wide family's transport: r4d_ar_oneshot_4rank_exact's IPC
// arguments (peers in ascending rank, this rank's own, the counters, the slot stride), `pub`, the
// engine's link gate with the instance's landed counter (0 for none; r4d_ar_seq.h), and, with
@@ -913,7 +925,7 @@ void r4d_ar_ln_had_quant_i8(long peer_scratch, long my_scratch, long peer_flags,
long x, long residual, long wgain, long out_bf16, long q, long s,
int M, int K, int had, float eps, float wadd,
long stream, int nblocks, int nthreads, int drain, int acq,
int wire = 0);
int wire = 0, long stage = 0);
// An elementwise gated product, then the same Hadamard and int8 quantiser. Mode 0 is silu(a)*b
// (down_proj's input, vLLM's silu_and_mul); mode 1 is sigmoid(a)*b (o_proj's input, since
// Qwen3_5Attention computes attn_output * sigmoid(gate)). Strides are in elements and may be 0 for