From a74b410f5f6bd11ff42cc1f40fa93242d0f67940 Mon Sep 17 00:00:00 2001 From: Ed Addario Date: Thu, 25 Sep 2025 19:49:47 +0100 Subject: [PATCH] Move is_iq() into a lambda and remove unused variables --- src/llama-quant.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/llama-quant.cpp b/src/llama-quant.cpp index 0f05c8f956..af564ce03e 100644 --- a/src/llama-quant.cpp +++ b/src/llama-quant.cpp @@ -727,11 +727,28 @@ static std::unordered_map target_bpw_type( return (double)bytes * 8.0 / (double)ggml_nelements(t); }; - auto is_compatible = [&](const ggml_tensor * t, const ggml_type typ) -> bool { + auto is_compatible = [](const ggml_tensor * t, const ggml_type typ) -> bool { const int64_t blck = ggml_blck_size(typ); return blck <= 1 || (t->ne[0] % blck) == 0; }; + auto is_iq = [](const enum ggml_type t) { + switch (t) { + case GGML_TYPE_IQ1_S: + case GGML_TYPE_IQ1_M: + case GGML_TYPE_IQ2_XXS: + case GGML_TYPE_IQ2_XS: + case GGML_TYPE_IQ2_S: + case GGML_TYPE_IQ3_XXS: + case GGML_TYPE_IQ3_S: + case GGML_TYPE_IQ4_NL: + case GGML_TYPE_IQ4_XS: + return true; + default: + return false; + } + }; + auto make_compatible = [&](const ggml_tensor * t, const ggml_type typ) -> ggml_type { if (is_compatible(t, typ)) return typ; ggml_type fb = fallback_type(typ); @@ -995,8 +1012,6 @@ static std::unordered_map target_bpw_type( std::vector all; all.reserve(tensors.size()); for (const auto * tw : tensors) { - std::vector workers; - workers.reserve(std::max(1, nthread)); ggml_tensor * tensor = tw->tensor; const std::string name = ggml_get_name(tensor); if (!can_quantize(tensor)) { continue; }