ops: attn_dense at head_dim 80 and grid_embed_cpe, for the C-RADIO tower

attn_dense at head_dim 80 without GQA (C-RADIO's ViT heads), and grid_embed_cpe, RADIO's cropped
position embedding: the table resampled half-pixel bilinear onto a square and cropped to the
grid, with the class and register rows ahead of each segment. libref, libavx and libr4d; ref_test,
avx_check_hand and selftest cases; docs/OPS.md.
This commit is contained in:
keptn42 committed 2026-11-04 22:08:53 +01:00
1 parent 2420b2b383
commit b466c91b26
17 files changed
+426 -2

No files matched your search

+6 -1
View File
@@ -2,7 +2,7 @@
// an optional two-sided window, i - j < window behind and j - i < wright ahead (wright is
// `window_right`, or `window` for the symmetric |i - j| < window), or causal with an optional
// window behind (a codec's sliding layers, a text encoder's prompt). bf16 in and out, f16
// operands, f32 accumulate. Head widths 64, 256 and 512 are compiled; each (head_dim, gqa) pair
// operands, f32 accumulate. Head widths 64, 80, 256 and 512 are compiled; each (head_dim, gqa) pair
// is a row.
//
// Core from the vision kernel (r4d_attn_vit_h72_bf16.hip): S^T = K.Q^T, so the wave32
@@ -304,6 +304,7 @@ void r4d_attn_dense_kernel(const uint16_t* __restrict__ gq, const uint16_t* __re
// ---- launch ----------------------------------------------------------------------------------
// One instantiation per (head_dim, gqa), at a workgroup shape picked for it:
// h64 gqa1: 8 query blocks of 16, K/V tiles of 64 keys (the vision towers' heads)
// h80 gqa1: the same shape, five 16-wide k-tiles a head (C-RADIO's heads)
// h256 gqa1: 8 query blocks of 16, tiles of 32 (LDS: 37 KiB)
// h256 gqa2, 4, 8: 8, 4, 2 query blocks x the heads, tiles of 32 (LDS: 37 KiB)
// h512 gqa2, 4, 8: 4, 2, 1 query blocks x the heads x 2 head halves, tiles of 16 (LDS: 57 KiB)
@@ -353,6 +354,10 @@ extern "C" int r4d_attn_dense_bf16(const void* q, const void* k, const void* v,
return r4d_attn_dense_launch<64, 1, 8, 1, 64>(q, k, v, o, cu_seqlens, num_seqs, max_seqlen,
n_head_kv, scale, window, wright, block,
cdiv, causal, q_ld, k_ld, v_ld, o_ld, s);
if (head_dim == 80 && gqa == 1)
return r4d_attn_dense_launch<80, 1, 8, 1, 64>(q, k, v, o, cu_seqlens, num_seqs, max_seqlen,
n_head_kv, scale, window, wright, block,
cdiv, causal, q_ld, k_ld, v_ld, o_ld, s);
#define R4D_DENSE(HD, G, NQB, DS, T) \
return r4d_attn_dense_launch<HD, G, NQB, DS, T>(q, k, v, o, cu_seqlens, num_seqs, max_seqlen, \
n_head_kv, scale, window, wright, block, \