libr4d: the gqa16 decode takes a verify of eight rows, so a draft step matches its single-row decodes

The h128/gqa16 decode row stopped at q_len 4 (64 query-head rows a workgroup), so LiLiCorr's
verify of 7 drafts and the anchor (q_len 8) ran the query-tiled prefill kernel while a plain decode
runs the split-KV one: no verify row was the single-row decode at its position, and greedy text
with the drafter left the text without it within a few hundred characters at one and two ranks.
The gqa16 unit raises G8_MAX_DECODE_ROWS to 128, which compiles an eight-wave arm into the gqa8
body's decode launch; gqa8 and every other unit compile as before. The rows take q_len <= 8.

Selftest: the numeric cases at q_len 8, and attn_verify_bits_case, eight verify rows against eight
single decodes bit for bit at 120, 700 and 2048 keys (gqa 16, and gqa 8 for four ranks).
docs/ARCHITECTURES.md: past 2048 keys the split law partitions a verify and a decode differently,
so a near-tie can still flip greedy text.
This commit is contained in:
keptn42 committed 2026-11-04 22:08:53 +01:00
1 parent 72160a9cff
commit 7cad854f2b
5 files changed
+121 -8

No files matched your search

+6 -5
View File
@@ -4631,7 +4631,8 @@ static const RadConstraint cAttnDecodeH128G2Bf16[] = {
C_EQ("window", 0), C_EQ("head_dim", 128), 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"),
};
/* Sixteen queries per KV head at head_dim 128 (Nemotron-H's 32 over 2): q_len <= 4 at decode. */
/* Sixteen queries per KV head at head_dim 128 (Nemotron-H's 32 over 2): q_len <= 8 at decode, eight
* waves, so a verify of LiLiCorr's 7 drafts runs the decode kernel a plain decode runs. */
static const RadConstraint cAttnPrefillH128G16Fp8[] = {
C_EQ("window", 0), C_EQ("head_dim", 128), C_EQ("gqa", 16), C_EQ("block_size", 16),
C_EQ("causal", 1), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "fp8_e4m3"),
@@ -4642,11 +4643,11 @@ static const RadConstraint cAttnPrefillH128G16Bf16[] = {
};
static const RadConstraint cAttnDecodeH128G16Fp8[] = {
C_EQ("window", 0), C_EQ("head_dim", 128), C_EQ("gqa", 16), C_EQ("block_size", 16),
C_GE("causal", 0), C_LE("q_len", 4), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "fp8_e4m3"),
C_GE("causal", 0), C_LE("q_len", 8), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "fp8_e4m3"),
};
static const RadConstraint cAttnDecodeH128G16Bf16[] = {
C_EQ("window", 0), C_EQ("head_dim", 128), C_EQ("gqa", 16), C_EQ("block_size", 16),
C_GE("causal", 0), C_LE("q_len", 4), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "bf16"),
C_GE("causal", 0), C_LE("q_len", 8), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "bf16"),
};
/* Key rename: libr4d writes C_IN("q_dtype","bf16") and C_IN("kv_dtype","bf16"); docs/OPS.md's
* `attn_dense` has one `dtype`. The predicate is unchanged.
@@ -7960,7 +7961,7 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8)
{ "attn_decode_h128_gqa16_fp8kv", "attn_paged", "attn",
"paged attention, causal or not, split-KV (decode / speculative verify)",
"head_dim 128, 16 queries per kv head, paged block 16, q_len*gqa <= 64, no window",
"head_dim 128, 16 queries per kv head, paged block 16, q_len*gqa <= 128, no window",
"bf16 query, fp8-e4m3 kv cache with per-(seq,head) descales, bf16 out, f16 partials",
RAD_DOMAIN_DEVICE, R4D_PRIO_ATTN_DECODE,
ROW(cAttnDecodeH128G16Fp8), ROW(tAttnSplit), nullptr,
@@ -7970,7 +7971,7 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8)
{ "attn_decode_h128_gqa16_bf16kv", "attn_paged", "attn",
"paged attention, causal or not, split-KV (decode / speculative verify)",
"head_dim 128, 16 queries per kv head, paged block 16, q_len*gqa <= 64, no window",
"head_dim 128, 16 queries per kv head, paged block 16, q_len*gqa <= 128, no window",
"bf16 query, bf16 kv cache, bf16 out, f16 partials",
RAD_DOMAIN_DEVICE, R4D_PRIO_ATTN_DECODE,
ROW(cAttnDecodeH128G16Bf16), ROW(tAttnSplit), nullptr,