From b09662f86aefb5750842c9d68dac42db9054e90c Mon Sep 17 00:00:00 2001 From: Ed Addario Date: Sun, 21 Sep 2025 16:19:49 +0100 Subject: [PATCH] Refactor estimate_lambda() --- src/llama-quant.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/llama-quant.cpp b/src/llama-quant.cpp index beac311d50..63779ded48 100644 --- a/src/llama-quant.cpp +++ b/src/llama-quant.cpp @@ -982,8 +982,8 @@ static std::unordered_map target_bpw_type( double s2 = 0.0; for (int64_t j = 0; j < n_per_row; ++j) { const double w = v ? std::max(0.0f, v[j]) : 1.0; - const double aw2 = std::sqrt(w) * a[j]; - const double z = aw2 * aw2; + const double aw = std::sqrt(w) * a[j]; + const double z = aw * aw; s1 += z; s2 += z * z; } @@ -992,7 +992,7 @@ static std::unordered_map target_bpw_type( if (s1 > 0.0) { const auto n = (double)n_per_row; const double c = std::max(0.0, s2 / (s1 * s1 + epsilon) - 1.0 / n); - l = (float) std::clamp(8.0 * (c / (c + 1.0)), 0.0, 12.0); + l = (float)std::clamp(8.0 * (c / (c + 1.0)), 0.0, 12.0); } lambdas[(size_t)s] = l;