[Core] batched full-attn layer (M=B) bit-exact + l2_clip per-token tau

layer_forward_full_batched mirrors layer_forward_full at M=B: 3-query mix
[B*3,h] split strided via gather_channel(nq=3) into in0/in1/in2 with separate
q/k/v norms; DYNAMIC ShortConv K/V via shortconv4_prefill_par(dyn_taps[B,n_kv,4])
(already supported dyn path, no new kernel); Q/R l2_clip with per-token tau;
global flash window=0; MoE sublayer identical to batched SWA.

k_l2_clip gains pos_arr (device [M]): tau uses pos_arr[r/scale_rows] per token
(full-attn) else scalar pos. l2_clip passes null (M=1 unchanged); l2_clip_batched
takes Option<&DeviceBuf> pos_arr.

layer_full_batched_parity (real weights ip=5, B=8, f16 KV + device MoE):
cur[B,h] BIT-EXACT (0.0) AND KV byte-identical vs 8 sequential M=1 calls.
Both layer types (SWA + full-attn) now batched and verified.
This commit is contained in:
adm committed 2026-12-02 00:24:37 +01:00
1 parent 3dbb6bb1b4
commit 1aaf7f12c2
4 files changed
+170 -13

No files matched your search

+1 -1
View File
@@ -149,7 +149,7 @@ int vetta_attn_res_mix(const float* blocks, const float* cur, const float* queri
// k_l2_clip: per-head L2 clip + optional per-dim scale + optional tau (in place).
int vetta_l2_clip(float* x, const float* scale, int rows, int hd, float clip,
int apply_tau, int pos, int scale_rows, vetta_stream_t stream);
int apply_tau, int pos, int scale_rows, const int32_t* pos_arr, vetta_stream_t stream);
// k_relpos_bias: rel_bias[h,dist] = sum_rc R[h,rc]*rel_proj[rc,dist], dist<lim.
int vetta_relpos_bias(const float* r, const float* rel_proj, float* rel_bias,