Archived
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).
24 lines
1.3 KiB
Plaintext
24 lines
1.3 KiB
Plaintext
// R4D attention at seven queries per KV head, head_dim 128: Nanbeige4.3-33B (56 query heads over
|
|
// 8 KV heads). Geometry only; r4d_attn_paged_gqa8.hip is the body. The ratio changes two bounds,
|
|
// both stated in the row table:
|
|
//
|
|
// decode verify width 64 / gqa = 9 query positions (63 rows of q_len * gqa)
|
|
// prefill block width 336 / gqa = 48 query positions
|
|
//
|
|
// The gqa-8 unit runs 24 warps because ROWS = NWARPS * 16 is both the tile's query rows and a
|
|
// multiple of the ratio. Seven divides neither 384 (24 warps) nor 64, so this unit takes 21 warps
|
|
// -- 336 rows, the same 48 query positions a block as the gqa-8 unit, at seven eighths of the
|
|
// rows -- and a 63-row decode cap, which is nine query positions rather than eight. Both numbers
|
|
// are compile-time geometry (BLOCK_Q = ROWS / GQA in the prefill kernel); a 24-warp instantiation
|
|
// would leave six rows mapping outside the tile's query positions, so they are not tuning knobs.
|
|
//
|
|
// No head_dim 256 leg: Nanbeige is 128 throughout, and a second instantiation would widen the
|
|
// module for a geometry nothing serves.
|
|
#define R4D_ATTN_GQA 7
|
|
#define R4D_ATTN_H128 1
|
|
#define R4D_ATTN_H256 0
|
|
#define G8_MAX_DECODE_ROWS 63
|
|
#define G8_P_NWARPS 21
|
|
|
|
#include "r4d_attn_paged_gqa8.hip"
|