Archived
libr4d: the gdn conv kernels read an f32 weight -- a GGUF ships ssm_conv1d in f32
llama.cpp keeps a Gated DeltaNet's ssm_conv1d unquantised, in f32, and a container converted from a GGUF holds it so. The three kernels that read the convolution weight, gdn_conv_prep, gdn_conv_update and the convolution gdn_conv_recurrent_update folds in, read bf16, so their shims refuse an f32 weight. The weight's element type is now a template parameter of all three. r4d_gdn_conv_tap.h, which already holds the arithmetic the fold shares with the standalone path, gives the vector a channel's taps are loaded as (ushort4 or float4) and the widening of one tap, exact for either type. The shims take a bf16 or an f32 weight and pick the instance by its dtype; any other dtype is still refused. The raw entry points keep their signatures. r4d.h gets an f32 twin of each standalone one, r4d_gdn_conv_prep_w4_h128_bf16_f32wgt and r4d_gdn_conv_update_w4_h128_bf16_f32wgt, rather than a flag, so no caller of the bf16 ones changes. The fold has no raw entry point; its CV parameter now also says the weight's type (1 bf16, 2 f32), which leaves every existing instance's template arguments and name as they were. That is twelve new conv instances and sixteen new fold ones. The bf16 instances compile to the same code. Built before and after with the build's flags, all 116 kernels of the two units have the same instructions, resource counts and metadata; only the conv kernels' names change with the added template argument. The bf16 reads keep their shape: widening gdn_conv_update's ushort4 to a float4 before use reorders its loads. The f32 conv instances use no scratch, conv_prep 56 to 57 VGPRs (53 at bf16) and conv_update 108 (96 at bf16, 12 waves per SIMD instead of 16); each f32 fold instance has exactly its bf16 twin's counts. r4d_selftest gets three cases for the card. gdn_conv_prep and gdn_conv_update over an f32 weight holding bf16's values must write the bytes they write over the bf16 weight: q, k and v, g and beta at prefill, and the conv state. The sequences are uneven; at prefill two are seeded from their cache, one of them over two chunks, and a one-token one is not. Outputs are poisoned, the cache must move and an f16 weight must be refused. The fold over the f32 weight must match the pair over the bf16 one, byte for byte as the fold already does at bf16. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d73abc28d5
commit
64c3dc9893
8 files changed
+323
-52
No files matched your search
+3
-3
@@ -7262,7 +7262,7 @@ R4D_WIN_PAIR(512, 1) R4D_WIN_PAIR(512, 2) R4D_WIN_PAIR(512, 4) R4D_WIN_PAIR(512,
|
||||
"gdn prefill preamble: causal conv + qkv split + qk l2norm + gating + per-chunk cumsum "
|
||||
"[UNVALIDATED: DPP row_xmask rewrite never correctness-gated]",
|
||||
"conv width 4, head_k/head_v 128, chunk 64, varlen, conv state read and rewritten in place",
|
||||
"bf16 x / weights / conv state / q,k,v out, fp32 a,b and gate/beta out",
|
||||
"bf16 x / conv state / q,k,v out, bf16 or f32 weights, fp32 a,b and gate/beta out",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY,
|
||||
ROW(cGdnConvPrep), NOTUNE,
|
||||
nullptr, nullptr, r4d_rad_gdn_conv_prep },
|
||||
@@ -7272,7 +7272,7 @@ R4D_WIN_PAIR(512, 1) R4D_WIN_PAIR(512, 2) R4D_WIN_PAIR(512, 4) R4D_WIN_PAIR(512,
|
||||
"gdn decode conv: rolling speculative window over the conv state cache, writes q/k/v "
|
||||
"[UNVALIDATED: DPP row_xmask rewrite never correctness-gated]",
|
||||
"conv width 4, head_k/head_v 128, state cache width-1 + num_spec, read at accepted offset",
|
||||
"bf16 x / weights / conv state / q,k,v out",
|
||||
"bf16 x / conv state / q,k,v out, bf16 or f32 weights",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY,
|
||||
ROW(cGdnConvUpdate), NOTUNE,
|
||||
nullptr, nullptr, r4d_rad_gdn_conv_update },
|
||||
@@ -7301,7 +7301,7 @@ R4D_WIN_PAIR(512, 1) R4D_WIN_PAIR(512, 2) R4D_WIN_PAIR(512, 4) R4D_WIN_PAIR(512,
|
||||
"workgroup convolves its key head's q and k and its value head's v into LDS, and the last "
|
||||
"workgroup of a key head to arrive rewrites that head's conv state",
|
||||
"head_k/head_v 128, conv width 4, a sequence's window at most 8 tokens, the fused row norm",
|
||||
"bf16 x / conv weights / conv state / a,b / out; the state cache is f32 or f16. "
|
||||
"bf16 x / conv state / a,b / out, bf16 or f32 conv weights; the state cache is f32 or f16. "
|
||||
"Byte-identical to gdn_conv_update followed by gdn_recurrent_update",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY,
|
||||
ROW(cGdnConvRecurrentUpdate), NOTUNE,
|
||||
|
||||
Reference in new issue
Block a user