Archived
libr4d: gqa 7 at head_dim 128
Nanbeige4.3-33B is 56 query heads over 8 KV heads at head_dim 128: seven queries a KV head, the same ratio at one rank and at two. The gqa-8 unit cannot express it -- its decode body holds 64 rows of q_len * gqa, and 64 is not a multiple of 7 -- so instantiate the shared body at 21 warps: 336 rows, the same 48 query positions a block as gqa 8, and a 63-row decode cap (nine query positions). Four rows: prefill and decode over bf16 and fp8-e4m3 KV. The gqa-8 defaults stay as they were. G8_MAX_DECODE_ROWS, G8_P_NWARPS and G8_P_TILE become #ifndef guards the including unit can win; nothing changes for gqa 8, which is the only other unit including this file today. The rows state the ratio and both bounds, so a verify wider than nine query positions takes the prefill kernel. Without this no checkpoint with that geometry serves at all: declare names no row for it, and the server stops in startup with nothing selected for attn_paged. Tested against the model's own releases, which need no change to the engine. llama.cpp 0.9.0-dev on the same two Radeon AI PRO R9700 measures 1192 tok/s prefill and 23.1 tok/s decode: official FP8, TP=2 34 GiB 4014 tok/s prefill 33.3 tok/s decode official INT4, TP=2 20 GiB 3677 tok/s prefill 53.2 tok/s decode official INT4, TP=1 20 GiB 2355 tok/s prefill 29.6 tok/s decode On the FP8 release (compressed-tensors FP8_BLOCK, imported as it ships), 17 * 23 -> 391, 9.11 against 9.8 -> 9.8, 100 - 9 -> 91, every one ending on eos, matching llama.cpp. The INT4 release does not import as it stands: it carries u4*bf16[1x32]-u4[1x32] while these linears read u4*f16[1x128]-u4[1x128], so a recipe re-blocks it onto the served grid, which measures 9.5e-02 relative Frobenius (both grids are four bits, so the bytes are the same and only the scales move). The answers stay right at that error, and moving about half the bytes a token it decodes faster on the coarser codes than fp8 does. At 20 GiB it also fits one card. A Q5_K_M GGUF of this model is no use as a way in: it wants an arch plugin and a conversion of values that are already quantised, and even then the same questions come out 7 * 3, 9.1 against 9.1 and 10 - 9. The two releases above are the way in; nothing here depends on the GGUF. Also: the gqa 7 rows against libref on the real 33B weights, 216/216 cases, and rad-kbench -m with every fusion byte-identical (worst rel-L2 2.08e-3).
This commit is contained in:
1 parent
c6ef279a12
commit
f3e4d11872
5 files changed
+103
-1
No files matched your search
@@ -4593,6 +4593,28 @@ static const RadConstraint cAttnDecodeH128G8Bf16[] = {
|
||||
C_GE("causal", 0), C_LE("q_len", 8), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "bf16"),
|
||||
};
|
||||
|
||||
/* Seven queries per kv head at head_dim 128 (Nanbeige4.3-33B: 56 query heads over 8), from
|
||||
* r4d_attn_paged_h128_gqa7.hip. Same body and the same 48 query positions a prefill block as the
|
||||
* gqa-8 pair above, at 21 warps rather than 24 because 7 does not divide 384 rows. The decode leg
|
||||
* holds 63 rows of q_len * gqa, so nine query positions where gqa 8 stops at eight; a wider verify
|
||||
* takes the prefill kernel. */
|
||||
static const RadConstraint cAttnPrefillH128G7Fp8[] = {
|
||||
C_EQ("window", 0), C_EQ("head_dim", 128), C_EQ("gqa", 7), C_EQ("block_size", 16),
|
||||
C_EQ("causal", 1), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "fp8_e4m3"),
|
||||
};
|
||||
static const RadConstraint cAttnPrefillH128G7Bf16[] = {
|
||||
C_EQ("window", 0), C_EQ("head_dim", 128), C_EQ("gqa", 7), C_EQ("block_size", 16),
|
||||
C_EQ("causal", 1), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "bf16"),
|
||||
};
|
||||
static const RadConstraint cAttnDecodeH128G7Fp8[] = {
|
||||
C_EQ("window", 0), C_EQ("head_dim", 128), C_EQ("gqa", 7), C_EQ("block_size", 16),
|
||||
C_GE("causal", 0), C_LE("q_len", 9), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "fp8_e4m3"),
|
||||
};
|
||||
static const RadConstraint cAttnDecodeH128G7Bf16[] = {
|
||||
C_EQ("window", 0), C_EQ("head_dim", 128), C_EQ("gqa", 7), C_EQ("block_size", 16),
|
||||
C_GE("causal", 0), C_LE("q_len", 9), C_IN("q_dtype", "bf16"), C_IN("kv_dtype", "bf16"),
|
||||
};
|
||||
|
||||
/* head_dim 128 at ratio ONE: plain MHA (the Unlimited-OCR decoder, 10 query heads over 10), from
|
||||
* r4d_attn_paged_h128_gqa1.hip. The decode leg caps at 64 query rows, which at this ratio is a
|
||||
* plain q_len <= 64; the prefill leg has no query-row cap. */
|
||||
@@ -7948,6 +7970,47 @@ R4D_WIN_TREE_PAIR(512, 4) R4D_WIN_TREE_PAIR(512, 8)
|
||||
nullptr, nullptr,
|
||||
r4d_shape_attn_paged },
|
||||
|
||||
/* Seven queries per kv head at head_dim 128, from r4d_attn_paged_h128_gqa7.hip: Nanbeige4.3-33B,
|
||||
* 56 query heads over 8, the same ratio at one or two ranks. 48 query positions a prefill block
|
||||
* (21 warps), and a decode workgroup of 63 rows -- nine query positions. */
|
||||
{ "attn_prefill_h128_gqa7_fp8kv", "attn_paged", "attn",
|
||||
"paged causal attention, query-tiled (prefill / chunked prefill)",
|
||||
"head_dim 128, 7 queries per kv head, paged block 16, varlen",
|
||||
"bf16 query, fp8-e4m3 kv cache with per-(seq,head) descales, bf16 out",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_ATTN_PREFILL,
|
||||
ROW(cAttnPrefillH128G7Fp8), NOTUNE,
|
||||
nullptr, nullptr, r4d_rad_attn_prefill_h128_gqa7_fp8, nullptr, nullptr, nullptr,
|
||||
r4d_shape_attn_paged },
|
||||
|
||||
{ "attn_prefill_h128_gqa7_bf16kv", "attn_paged", "attn",
|
||||
"paged causal attention, query-tiled (prefill / chunked prefill)",
|
||||
"head_dim 128, 7 queries per kv head, paged block 16, varlen",
|
||||
"bf16 query, bf16 kv cache, bf16 out",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_ATTN_PREFILL,
|
||||
ROW(cAttnPrefillH128G7Bf16), NOTUNE,
|
||||
nullptr, nullptr, r4d_rad_attn_prefill_h128_gqa7_bf16, nullptr, nullptr, nullptr,
|
||||
r4d_shape_attn_paged },
|
||||
|
||||
{ "attn_decode_h128_gqa7_fp8kv", "attn_paged", "attn",
|
||||
"paged attention, causal or not, split-KV (decode / speculative verify / draft block)",
|
||||
"head_dim 128, 7 queries per kv head, paged block 16, q_len*gqa <= 63, 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(cAttnDecodeH128G7Fp8), ROW(tAttnSplit), nullptr,
|
||||
nullptr, nullptr, r4d_rad_attn_decode_h128_gqa7_fp8, r4d_rad_attn_decode_h128_gqa7_scratch,
|
||||
nullptr, nullptr,
|
||||
r4d_shape_attn_paged },
|
||||
|
||||
{ "attn_decode_h128_gqa7_bf16kv", "attn_paged", "attn",
|
||||
"paged attention, causal or not, split-KV (decode / speculative verify / draft block)",
|
||||
"head_dim 128, 7 queries per kv head, paged block 16, q_len*gqa <= 63, no window",
|
||||
"bf16 query, bf16 kv cache, bf16 out, f16 partials",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_ATTN_DECODE,
|
||||
ROW(cAttnDecodeH128G7Bf16), ROW(tAttnSplit), nullptr,
|
||||
nullptr, nullptr, r4d_rad_attn_decode_h128_gqa7_bf16, r4d_rad_attn_decode_h128_gqa7_scratch,
|
||||
nullptr, nullptr,
|
||||
r4d_shape_attn_paged },
|
||||
|
||||
{ "attn_prefill_h128_gqa2_fp8kv", "attn_paged", "attn",
|
||||
"paged causal attention, query-tiled (prefill / chunked prefill)",
|
||||
"head_dim 128, 2 queries per kv head, paged block 16, varlen",
|
||||
|
||||
Reference in new issue
Block a user