Commit e683365a7 for llama.cpp
commit e683365a74d5a09b184b3faf3dee240129439b80
Author: Aman Gupta <amangupta052@gmail.com>
Date: Tue Nov 24 20:47:28 2026 +0800
model : inkling2 clip with ggml_l2_norm (#32940)
Assisted-by: Claude Opus 5.5
diff --git a/src/models/inkling2.cpp b/src/models/inkling2.cpp
index 45477a69e..4a685fd16 100644
--- a/src/models/inkling2.cpp
+++ b/src/models/inkling2.cpp
@@ -167,12 +167,8 @@ ggml_tensor * llama_model_inkling2::graph::clip(ggml_tensor * cur, ggml_tensor *
cur = ggml_mul(ctx0, cur, scale);
}
- ggml_tensor * norm = ggml_sqrt(ctx0, ggml_sum_rows(ctx0, ggml_sqr(ctx0, cur)));
- norm = ggml_scale_bias(ctx0, norm, 1.0f, 1e-6f);
-
- ggml_tensor * factor = ggml_div(ctx0, ggml_fill(ctx0, norm, threshold), norm);
-
- return ggml_mul(ctx0, cur, ggml_clamp(ctx0, factor, 0.0f, 1.0f));
+ // x*min(1, t/|x|) = t*x/max(|x|, t), and l2_norm(x, eps) = x/max(|x|, eps)
+ return ggml_scale(ctx0, ggml_l2_norm(ctx0, cur, threshold), threshold);
}
// attention over the depth: mix the earlier block outputs and cur with learned queries