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

+10 -1
View File
@@ -72,7 +72,11 @@ using std::max;
#ifndef G8_BLOCK_SIZE
#define G8_BLOCK_SIZE 16
#endif
#define G8_MAX_DECODE_ROWS 64 // q_len * gqa a single decode workgroup can hold: q_len <= 8
/* q_len * gqa a single decode workgroup can hold: q_len <= 8 here. An including unit may raise it
* to 128 (eight waves): gqa 16 then verifies 7 drafts in the decode kernel, as gqa 8 does. */
#ifndef G8_MAX_DECODE_ROWS
#define G8_MAX_DECODE_ROWS 64
#endif
#define G8_P_NWARPS 24
#define G8_P_TILE 48
@@ -152,6 +156,11 @@ static int g8_decode_launch(const R4DArgs* a, RadStream stream,
dim3(splits, a->kv_heads, a->num_seqs), dim3(32), 0, *a, splits);
else if (nw == 2) G8_LAUNCH(2);
else if (nw == 3) G8_LAUNCH(3);
#if G8_MAX_DECODE_ROWS > 64
/* Five to eight waves take eight; a wave past the last query row computes a copy of it and
* stores nothing. */
else if (nw > 4) G8_LAUNCH(8);
#endif
else G8_LAUNCH(4);
#undef G8_LAUNCH
if (emit_rc != RAD_OK) return -5;