Archived
attn prefill h256: the small-launch KV split for every GQA geometry
The KV split of the head-256 / GQA-6 prefill kernel (few workgroups -> split the KV walk into segments, f32 partials, the split-KV merge with a cu span) now serves every head-256 prefill row: GQA 12 (4-token pages: fp8, bf16, fp8_v4, k6_v4), GQA 6 with 4-token pages (the same four), GQA 8, GQA 4 and GQA 2 (fp8, bf16). The fewer KV heads a rank holds, the more it matters: at TP 2 Qwen4-Exp (GQA 12) and Qwen3.5-35B-A3B (GQA 8) keep one KV head per rank, so a 53-row tail runs 2 workgroups on 32 WGPs. The host side (the law, the scratch sweep, the scratch-capped count, R4D_PREFILL_SPLITS, the merge launch) moves into r4d_attn_prefill_split.h; each unit passes its own geometry (query rows per workgroup = 24 * 16 / gqa, tile 48). The GQA-6 unit is refactored onto it with the same law (Qwen3.8-27B in the engine: greedy top-5 logprobs bit-identical before and after at 300 positions after 25k and 41k prompts). Left unsplit: GQA-2 launches with a sliding window (the partition has no window floor; a 1024 window walks at most ~26 tiles), the lossy e4m3 legs, and the head-128 / head-64 legs sharing the bodies. Split count, one sequence, N query rows -> S: GQA 12 with 1 KV head: 1-32 -> 32, 53 -> 16, 160 -> 6, 1024 -> 1; GQA 8 with 1 KV head: 53 -> 16, 345 -> 4; GQA 2 with 4 KV heads: up to 160 -> 8. Scratch at declare at most 25.4 MB per row. Split vs unsplit: at most 0.000488 (fp8 KV) and 0.0039 (bf16, fp8_v4, k6_v4; about 1 bf16 ulp). Tests: the split tests generalised over geometry for all 18 split rows (query lengths 1-640 over 8k-20k keys, empty segments, ragged batches, pipelined pieces, poisoned scratch, oracle rows at each tile edge, declare-time scratch): 1782 ok; the mixed-step case over 9 geometry x cache pairs: 54 ok. Every kernel that existed before is byte-identical (311 of 311). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
22df1c7264
commit
96bc0465b3
8 files changed
+433
-226
No files matched your search
@@ -132,6 +132,7 @@ int64_t r4d_rad_attn_decode_h128_scratch(const RadArgs*);
|
||||
* windowed prefill (the gqa6 leg's r4d_attn_prefill_kernel with WIN on). */
|
||||
int r4d_rad_attn_prefill_h256_gqa2_fp8 (const RadArgs*, RadStream);
|
||||
int r4d_rad_attn_prefill_h256_gqa2_bf16 (const RadArgs*, RadStream);
|
||||
int64_t r4d_rad_attn_prefill_h256_gqa2_scratch(const RadArgs*);
|
||||
int r4d_rad_attn_decode_h256_gqa2_fp8 (const RadArgs*, RadStream);
|
||||
int r4d_rad_attn_decode_h256_gqa2_bf16 (const RadArgs*, RadStream);
|
||||
int64_t r4d_rad_attn_decode_h256_gqa2_scratch(const RadArgs*);
|
||||
@@ -299,6 +300,7 @@ int64_t r4d_rad_quant_cols_fp8_scratch(const RadArgs*);
|
||||
* row's constraint value) is 8, against the gqa6 leg's 10. */
|
||||
int r4d_rad_attn_prefill_h256_gqa8_fp8 (const RadArgs*, RadStream);
|
||||
int r4d_rad_attn_prefill_h256_gqa8_bf16(const RadArgs*, RadStream);
|
||||
int64_t r4d_rad_attn_prefill_h256_gqa8_scratch(const RadArgs*);
|
||||
int r4d_rad_attn_decode_h256_gqa8_fp8 (const RadArgs*, RadStream);
|
||||
int r4d_rad_attn_decode_h256_gqa8_bf16 (const RadArgs*, RadStream);
|
||||
int64_t r4d_rad_attn_decode_h256_gqa8_scratch(const RadArgs*);
|
||||
@@ -318,6 +320,7 @@ int64_t r4d_rad_attn_decode_h128_gqa1_scratch(const RadArgs*);
|
||||
* (r4d_attn_paged_h256_gqa4.hip). */
|
||||
int r4d_rad_attn_prefill_h256_gqa4_fp8 (const RadArgs*, RadStream);
|
||||
int r4d_rad_attn_prefill_h256_gqa4_bf16(const RadArgs*, RadStream);
|
||||
int64_t r4d_rad_attn_prefill_h256_gqa4_scratch(const RadArgs*);
|
||||
int r4d_rad_attn_decode_h256_gqa4_fp8 (const RadArgs*, RadStream);
|
||||
int r4d_rad_attn_decode_h256_gqa4_bf16 (const RadArgs*, RadStream);
|
||||
int64_t r4d_rad_attn_decode_h256_gqa4_scratch(const RadArgs*);
|
||||
@@ -335,6 +338,7 @@ int64_t r4d_rad_attn_decode_h128_gqa2_scratch(const RadArgs*);
|
||||
* another instantiation (r4d_attn_paged_h256_gqa12.hip). */
|
||||
int r4d_rad_attn_prefill_h256_gqa12_fp8 (const RadArgs*, RadStream);
|
||||
int r4d_rad_attn_prefill_h256_gqa12_bf16(const RadArgs*, RadStream);
|
||||
int64_t r4d_rad_attn_prefill_h256_gqa12_scratch(const RadArgs*);
|
||||
int r4d_rad_attn_decode_h256_gqa12_fp8 (const RadArgs*, RadStream);
|
||||
int r4d_rad_attn_decode_h256_gqa12_bf16 (const RadArgs*, RadStream);
|
||||
int r4d_rad_attn_decode_gq_h256_gqa12_fp8(const RadArgs*, RadStream);
|
||||
@@ -345,6 +349,7 @@ int64_t r4d_rad_attn_decode_h256_gqa12_scratch(const RadArgs*);
|
||||
* the decode rows' constraint value. */
|
||||
int r4d_rad_attn_prefill_h256_gqa6_fp8 (const RadArgs*, RadStream);
|
||||
int r4d_rad_attn_prefill_h256_gqa6_bf16(const RadArgs*, RadStream);
|
||||
int64_t r4d_rad_attn_prefill_h256_gqa6_scratch(const RadArgs*);
|
||||
int r4d_rad_attn_decode_h256_gqa6_fp8 (const RadArgs*, RadStream);
|
||||
int r4d_rad_attn_decode_h256_gqa6_bf16 (const RadArgs*, RadStream);
|
||||
int64_t r4d_rad_attn_decode_h256_gqa6_scratch(const RadArgs*);
|
||||
@@ -356,18 +361,22 @@ int r4d_rad_attn_decode_gq_h256_gqa6_bf16(const RadArgs*, RadStream);
|
||||
/* The fp8_v4 and k6_v4 caches on both: prefill, decode, and decode with the gate and quantiser in
|
||||
* the merge (R4D_ATTN_V4 in r4d_attn_paged_gqa8.hip). */
|
||||
int r4d_rad_attn_prefill_h256_gqa12_fp8v4(const RadArgs*, RadStream);
|
||||
int64_t r4d_rad_attn_prefill_h256_gqa12_fp8v4_scratch(const RadArgs*);
|
||||
int r4d_rad_attn_decode_h256_gqa12_fp8v4(const RadArgs*, RadStream);
|
||||
int r4d_rad_attn_decode_gq_h256_gqa12_fp8v4(const RadArgs*, RadStream);
|
||||
int64_t r4d_rad_attn_decode_h256_gqa12_fp8v4_scratch(const RadArgs*);
|
||||
int r4d_rad_attn_prefill_h256_gqa12_k6v4(const RadArgs*, RadStream);
|
||||
int64_t r4d_rad_attn_prefill_h256_gqa12_k6v4_scratch(const RadArgs*);
|
||||
int r4d_rad_attn_decode_h256_gqa12_k6v4(const RadArgs*, RadStream);
|
||||
int r4d_rad_attn_decode_gq_h256_gqa12_k6v4(const RadArgs*, RadStream);
|
||||
int64_t r4d_rad_attn_decode_h256_gqa12_k6v4_scratch(const RadArgs*);
|
||||
int r4d_rad_attn_prefill_h256_gqa6_fp8v4(const RadArgs*, RadStream);
|
||||
int64_t r4d_rad_attn_prefill_h256_gqa6_fp8v4_scratch(const RadArgs*);
|
||||
int r4d_rad_attn_decode_h256_gqa6_fp8v4(const RadArgs*, RadStream);
|
||||
int r4d_rad_attn_decode_gq_h256_gqa6_fp8v4(const RadArgs*, RadStream);
|
||||
int64_t r4d_rad_attn_decode_h256_gqa6_fp8v4_scratch(const RadArgs*);
|
||||
int r4d_rad_attn_prefill_h256_gqa6_k6v4(const RadArgs*, RadStream);
|
||||
int64_t r4d_rad_attn_prefill_h256_gqa6_k6v4_scratch(const RadArgs*);
|
||||
int r4d_rad_attn_decode_h256_gqa6_k6v4(const RadArgs*, RadStream);
|
||||
int r4d_rad_attn_decode_gq_h256_gqa6_k6v4(const RadArgs*, RadStream);
|
||||
int64_t r4d_rad_attn_decode_h256_gqa6_k6v4_scratch(const RadArgs*);
|
||||
|
||||
Reference in new issue
Block a user