From f45b59a5c3ba2b6c304bc48c8f6a669f4c012b15 Mon Sep 17 00:00:00 2001 From: Francis Couture-Harpin Date: Thu, 12 Mar 2026 13:11:53 -0400 Subject: [PATCH] Revert "quantize : assume the neutral prior is equal imatrix weights" This reverts commit 46a8601140d3e1891316c93f8ea4ed4c73fe7f55. Going towards 1 is more stable than towards the mean, which can otherwise still be 0 and cause problems. --- tools/quantize/quantize.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tools/quantize/quantize.cpp b/tools/quantize/quantize.cpp index 8c2a9e1342..a559109ccf 100644 --- a/tools/quantize/quantize.cpp +++ b/tools/quantize/quantize.cpp @@ -291,15 +291,8 @@ static int load_imatrix(const std::string & imatrix_file, std::vectordata)[j]; if (count > 0.0f) { - float sumw = 0.0f; for (int64_t i = 0; i < ne0; ++i) { - sumw += ((const float *) sums->data)[j*ne0 + i]; - } - // the neutral prior is equal weights, and it should reduce the variance by weighted-averaging with the mean - const float prior_value = sumw / ne0; - - for (int64_t i = 0; i < ne0; ++i) { - e[j*ne0 + i] = (((const float *) sums->data)[j*ne0 + i] + prior_value * prior_weight) / (count + prior_weight); + e[j*ne0 + i] = (((const float *) sums->data)[j*ne0 + i] + prior_weight) / (count + prior_weight); } } else { // Partial imatrix data, this tensor never got any input during calibration