- k_l2_clip / vetta_l2_clip: exact strata Q/R/K per-head L2 clip — v = x*scale
(scale nullable), fac = min(1, clip/(sqrt(sum v^2)+1e-6)), optional tau
fac *= 1 + 0.1*log(max(1,(pos+1)/8192)) (kLogScaleAlpha=0.1, floor=8192);
x = v*fac, in place. Config: qk_clip=22.627, rel_clip=8.0; tau=!is_swa.
- k_relpos_bias / vetta_relpos_bias: rel_bias[h,dist] = sum_rc R[h,rc] *
rel_proj[rc,dist] for dist < lim=min(pos+1,rel_extent). R pre-clipped
[n_head,d_rel=16], rel_proj [d_rel,rel_extent=1024] (rel_logits_proj.proj).
- k_kv_store / vetta_kv_store: K (pre-clipped) stored as-is, V RMS-normalized
(rsqrt(mean v^2 + eps)), into a contiguous f32 KV cache [n_kv,seq,hd] at pos.
(Paged FP16/FP8 KV pool is a later perf refinement; contiguous f32 first.)
- Combined parity test vs CPU oracles: l2_clip (scale+tau and plain), relpos
bias, kv_store (K exact, V <1e-5). These complete the k2 attention prep; with
gemm_bf16 (projections) + shortconv4 + flash_swa_gqa the full attention block
can now be composed.
Verified: RUSTFLAGS="-D warnings" cargo test --workspace = 97/97 PASS;
lean proofs (4 files, 42 theorems) green; GPU 14/14 (--features hip).