From feda897fa27d3b3a6c1e403aa516f83ddde68e07 Mon Sep 17 00:00:00 2001 From: Ed Addario Date: Thu, 12 Mar 2026 20:05:29 +0000 Subject: [PATCH] Enhanced scaling factor --- src/llama-quant.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/llama-quant.cpp b/src/llama-quant.cpp index 49d26601da..a8e6e9e17e 100644 --- a/src/llama-quant.cpp +++ b/src/llama-quant.cpp @@ -1428,7 +1428,10 @@ static std::unordered_map target_bpw_type( if (statistics_data) { if (auto it = statistics_data->find(remapped_name); it != statistics_data->end() && !it->second.empty()) { const auto & ts = it->second; - scaling_factor = 1.0f + std::log1p(std::max(0.0f, ts[KURTOSIS])) * std::max(1.0f, std::isnan(ts[GAIN]) ? 1.0f : ts[GAIN]); + const float gain = std::isnan(ts[GAIN]) ? 1.0f : ts[GAIN]; + const float alignment = std::isfinite(ts[COSSIM]) ? std::max(0.0f, 1.0f - ts[COSSIM]) : 0.0f; + const float concentration = 1.0f - std::clamp(ts[H_NORM], 0.0f, 100.0f) / 100.0f; + scaling_factor = 1.0f + std::log1p(std::max(0.0f, ts[KURTOSIS])) * std::max(1.0f, gain) * (1.0f + alignment) * (1.0f + concentration); } }