libr4d: qkv_norm_rope -- q/k/v norms and both rotaries of separate projections in one dispatch

An attention block with separate q, k and v projections and per-head
norms (Gemma 4) runs five single-pass ops between the projections and the
cache store: rmsnorm_p on v (or on the raw k where v is k), rmsnorm over
the q heads, rmsnorm over the k heads, rope on q, rope on k.
qkv_norm_rope does them in one dispatch, one workgroup a (token, head).

Byte-identical to the five: the same norm widths r4d_act_threads picks
and rope's ladders, head included. The row is constrained to head_dim
256..512 in steps of 256; other shapes keep the five. The selftest
compares both of Gemma 4 31B's attention classes at M 1/4/40.
This commit is contained in:
keptn42 committed 2026-10-11 02:23:39 +00:00
1 parent dd6a7071a8
commit d90d90e43a
6 files changed
+338

No files matched your search

+1
View File
@@ -142,6 +142,7 @@ set(R4D_UNITS
"r4d_sample_stages_f32|"
"r4d_quant_act_i8|"
"r4d_rmsnorm_quant_i8|"
"r4d_qkv_norm_rope|"
"r4d_had_quant_act_i8|"
"r4d_rmsnorm_had_quant_i8|"
"r4d_ar_ln_had_quant_i8|"