libr4d: Gemma 3's rows -- windowed h128/gqa2 attention, qkv_norm_rope at h128 without a value norm, ar_rmsnorm_post_quant_fp8

- r4d_attn_paged_h128_gqa2w.hip: decode and query-tiled prefill at head_dim 128, gqa 2,
  window >= 1, instantiations of the h256/gqa6 templates with WIN = 1 (as h256_gqa2 for
  Gemma 4); the h128/gqa2 rows keep window 0.
- qkv_norm_rope: head_dim 128, and an optional v_norm (0 leaves v alone).
- ar_rmsnorm_post_quant_fp8: ar_rmsnorm_quant_fp8 with a post-norm of the reduced sum against
  w_post before the residual add (the sandwich junction), exact wire only. Its own op: an
  optional seventh operand on ar_rmsnorm_quant_fp8 broke every plugin issuing its six.
r4d_selftest: the windowed rows against the inline oracle over a history past the window, and
qkv_norm_rope at h128 / v_norm 0 byte-identical to its chain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mici81andClaude Opus 5.5 authored and StillDeadcode committed 2026-10-19 10:44:46 +02:00
1 parent 37deff85ca
commit f92cce07f1
11 files changed
+291 -19

No files matched your search

+21
View File
@@ -186,6 +186,7 @@ extern "C" int r4d_rad_attn_prefill_h256_bf16(const RadArgs* a, RadStream s) {
static int64_t decode_scratch_bytes_of(const R4DArgs* r, int which) {
if (which == 1) return (int64_t)r4d_attn_decode_h128_gqa4_scratch_bytes(r);
if (which == 2) return (int64_t)r4d_attn_decode_h256_gqa2_scratch_bytes(r);
if (which == 3) return (int64_t)r4d_attn_decode_h128_gqa2w_scratch_bytes(r);
return (int64_t)r4d_attn_decode_h256_gqa6_scratch_bytes(r);
}
@@ -297,3 +298,23 @@ extern "C" int r4d_rad_attn_decode_h256_gqa2_bf16(const RadArgs* a, RadStream s)
if (rc != RAD_OK) return rc;
return r4d_attn_decode_h256_gqa2_bf16kv(&r, (hipStream_t)s);
}
/* Gemma 3 sliding window (head_dim 128, gqa 2, window 1024) decode; its prefill entry points
* are in r4d_attn_paged_h128_gqa2w.hip. */
extern "C" int64_t r4d_rad_attn_decode_h128_gqa2w_scratch(const RadArgs* a) {
return decode_scratch(a, 128, 3);
}
extern "C" int r4d_rad_attn_decode_h128_gqa2w_fp8(const RadArgs* a, RadStream s) {
R4DArgs r;
int rc = decode_common(a, &r, 128, 3);
if (rc != RAD_OK) return rc;
return r4d_attn_decode_h128_gqa2w_fp8kv(&r, (hipStream_t)s);
}
extern "C" int r4d_rad_attn_decode_h128_gqa2w_bf16(const RadArgs* a, RadStream s) {
R4DArgs r;
int rc = decode_common(a, &r, 128, 3);
if (rc != RAD_OK) return rc;
return r4d_attn_decode_h128_gqa2w_bf16kv(&r, (hipStream_t)s);
}