Merge Gemma 4 31B: PRs #74, #75, #81 and #86 (sfjes, keptn42), with fixes

The gemma4_bf16 architecture (sliding and global attention, the proportional RoPE ladder, the
assistant head as a drafter that reads the trunk's cache, the vision tower), its w4a8 decode
junctions, the h512/gqa8 and h256/gqa2 attention kernels, compressed-tensors int4 import, multi-EOS
from generation_config, the call/reasoning reply format, a window group that keeps the keys a
prefill chunk still reads, and window snapshots in checkpoint slots so a prefix hit on a
sliding-window trunk resumes.

Fixes on top: the investigation switches and diagnostic blocks out of the served paths; int4 import
through the checkpoint import framework; attention_k_eq_v from the config; the fused junctions only
where every reader takes their pair; a shared-KV head binds no group of its own; the compose file
without HSA_ENABLE_IPC_MODE_LEGACY (TP2 fails with it on ROCm 10.1); a checkpoint carries a window
only where a hit resumes from it; the README says the linked container is keptn42's calibrated GPTQ
build and what the in-tree recipe gives.
This commit is contained in:
Deadcode committed 2026-10-12 20:46:37 +02:00
84 files changed
+10292 -230

No files matched your search

+30
View File
@@ -98,6 +98,36 @@ AVX_KERNEL(rmsnorm) {
return RAD_OK;
}
/* ------------------------------------------------------------------ rmsnorm_p */
/* y = x * rsqrt(mean(x^2) + eps) -- the rmsnorm with no gain. Same one-conversion, two-pass shape
* and same four-accumulator sum of squares as rmsnorm; the only difference is there is no weight
* to widen and no gain to multiply in, because the op has no `w` at all. */
AVX_KERNEL(rmsnorm_p) {
if (!rad_args_have(a, 2)) return RAD_E_INVAL;
const RadTensor *x = &a->t[0], *y = &a->t[1];
const int64_t n = p_int(a, "n", 0);
const float eps = p_f32(a, "eps", 1e-6f);
if (n <= 0) return RAD_E_SHAPE;
const int64_t rows = rows_of(x, n);
if (rows <= 0 || numel(y) < rows * n) return RAD_E_SHAPE;
AVX_PARALLEL_FOR_IF(rows * n >= AVX_PAR_MIN)
for (int64_t r = 0; r < rows; ++r) {
float* sx = scratch_f32((size_t)n);
float* sy = scratch_f32_b((size_t)n);
const float* v = in_row(x, rowoff(x, r, n), n, sx);
const float ss = row_sumsq(v, n);
const float s = 1.0f / std::sqrt(ss / (float)n + eps);
const vf vs = vf_set1(s);
int64_t i = 0;
for (; i + VF_N <= n; i += VF_N)
vf_storeu(sy + i, vf_mul(vf_loadu(v + i), vs));
for (; i < n; ++i) sy[i] = v[i] * s;
out_row(y, rowoff(y, r, n), n, sy);
}
return RAD_OK;
}
/* ------------------------------------------------------------------ rmsnorm_add */
/* residual_out = x + residual; y = rmsnorm(residual_out) * (w + wadd), with the variance from the
* unrounded sum and the multiply from the narrowed one. */