From c013cd876b9551c514a4f55de55909a7be2f6b63 Mon Sep 17 00:00:00 2001 From: Kawrakow Date: Mon, 3 Aug 2026 10:42:17 +0300 Subject: [PATCH] Do not quantize integer tensors (#2246) --- src/llama-quantize.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/llama-quantize.cpp b/src/llama-quantize.cpp index 39a597b6..72fd197b 100644 --- a/src/llama-quantize.cpp +++ b/src/llama-quantize.cpp @@ -1452,8 +1452,13 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s llama_format_tensor_shape(tensor).c_str(), ggml_type_name(tensor->type)); + bool quantize = tensor->type != GGML_TYPE_I32 && + tensor->type != GGML_TYPE_I64 && + tensor->type != GGML_TYPE_I16 && + tensor->type != GGML_TYPE_I8; // i.e., do not quantize tensors holding int values + // This used to be a regex, but has an extreme cost to compile times. - bool quantize = name.rfind("weight") == name.size() - 6; // ends with 'weight'? + quantize &= name.rfind("weight") == name.size() - 6; // ends with 'weight'? // quantize only 2D and 3D tensors (experts) quantize &= (ggml_n_dims(tensor) >= 2);