From d16945730eac146d87d158a97ef053f845921f01 Mon Sep 17 00:00:00 2001 From: Ed Addario Date: Sat, 27 Sep 2025 17:25:29 +0100 Subject: [PATCH] Refactor outlier trimming --- src/llama-quant.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/llama-quant.cpp b/src/llama-quant.cpp index 0386352014..df36a705c2 100644 --- a/src/llama-quant.cpp +++ b/src/llama-quant.cpp @@ -847,8 +847,7 @@ static std::unordered_map target_bpw_type( if (n == 0) { return 0.0; } if (n < 50) { return std::accumulate(v.begin(), v.end(), 0.0); } // use all samples for small datasets - int64_t k = (int64_t) std::floor(0.02 * (double)n); // trim 2% from each tail of the distribution - k = std::clamp(k, 0, std::min(n / 32, n / 2 - 1)); // cap trimming at ~3% (1/32) or half the samples - 1 + int64_t k = (int64_t) std::floor(0.025 * (double)n); // trim 2.5% from each tail of the distribution std::sort(v.begin(), v.end()); return std::accumulate(v.begin() + k, v.begin() + (n - k), 0.0); };