libr4d: a non-causal window that bounds the keys behind a row only

attn_paged_ahead and attn_paged_qrow_ahead are attn_paged at causal 0
where `window` limits the keys behind a row and every later key of the
sequence is visible. The windowed kernels take it as a launch flag (h256,
1 to 8 queries per kv head). Gemma 4's sliding layers read a picture's
rows with transformers' mask, the window AND (causal OR the same
picture), which this is for a picture longer than the window. Emulator
cases for the scalar, split and WMMA kernels.
This commit is contained in:
keptn42 committed 2026-11-04 07:21:07 +01:00
1 parent eb3aa7eae7
commit a0ea6ad1ba
5 files changed
+110 -9

No files matched your search

+7
View File
@@ -211,6 +211,13 @@ int r4d_rad_attn_qrow_tree_decode_h256_gqa2_bf16(const RadArgs*, RadStream);
R4D_WIN_TREE_DECL(256, 1) R4D_WIN_TREE_DECL(256, 2) R4D_WIN_TREE_DECL(256, 4) R4D_WIN_TREE_DECL(256, 8)
R4D_WIN_TREE_DECL(512, 1) R4D_WIN_TREE_DECL(512, 2) R4D_WIN_TREE_DECL(512, 4) R4D_WIN_TREE_DECL(512, 8)
#undef R4D_WIN_TREE_DECL
/* attn_paged_ahead and attn_paged_qrow_ahead (docs/OPS.md): the windowed kernels with a non-causal
* window that bounds the keys behind only. */
#define R4D_WIN_AHEAD_DECL(HD, G) \
int r4d_rad_attn_window_ahead_h##HD##_gqa##G##_bf16(const RadArgs*, RadStream); \
int r4d_rad_attn_window_ahead_h##HD##_gqa##G##_fp8 (const RadArgs*, RadStream);
R4D_WIN_AHEAD_DECL(256, 1) R4D_WIN_AHEAD_DECL(256, 2) R4D_WIN_AHEAD_DECL(256, 4) R4D_WIN_AHEAD_DECL(256, 8)
#undef R4D_WIN_AHEAD_DECL
/* dflash_tree (r4d_dflash_tree_bf16.hip): dflash_select's lattice grown best-first into a tree. */
int r4d_rad_dflash_tree(const RadArgs*, RadStream);
/* The top-1 of a row of all-gathered (id, value) pairs, written one id a row: the vocab-sharded