From d857e5192ec34b6b6b4c98e24baa738309faf97b Mon Sep 17 00:00:00 2001 From: slaren Date: Thu, 6 Jun 2024 22:43:22 +0200 Subject: [PATCH] quantize : check imatrix for nan/inf values --- llama.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/llama.cpp b/llama.cpp index 32264a008..8b675ea99 100644 --- a/llama.cpp +++ b/llama.cpp @@ -15237,6 +15237,14 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s if (imatrix_data) { LLAMA_LOG_INFO("================================ Have weights data with %d entries\n",int(imatrix_data->size())); qs.has_imatrix = true; + // check imatrix for nans or infs + for (const auto & kv : *imatrix_data) { + for (float f : kv.second) { + if (!std::isfinite(f)) { + throw std::runtime_error(format("imatrix contains non-finite value %f\n", f)); + } + } + } } }