From 54bcafee1682847ea8884319e752803ea8ff17d7 Mon Sep 17 00:00:00 2001 From: Kawrakow Date: Mon, 16 Mar 2026 18:26:26 +0100 Subject: [PATCH] Allow using -rtr and -muge together (#1444) --- src/llama-quantize.cpp | 3 ++- src/llama-quantize.h | 7 +++++++ src/llama.cpp | 7 ++++++- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 src/llama-quantize.h diff --git a/src/llama-quantize.cpp b/src/llama-quantize.cpp index 2ed081d4..e0d5383b 100644 --- a/src/llama-quantize.cpp +++ b/src/llama-quantize.cpp @@ -1,6 +1,7 @@ #include "llama-impl.h" #include "llama-model.h" #include "llama-model-loader.h" +#include "llama-quantize.h" #include "ggml.h" #include "ggml-common.h" @@ -79,7 +80,7 @@ struct quantize_state_internal { {} }; -static std::pair interleaved_properties(ggml_type type) { +std::pair interleaved_properties(ggml_type type) { static std::unordered_map> k_map = { { GGML_TYPE_Q4_0_4_4, { GGML_TYPE_Q4_0, 4} }, { GGML_TYPE_Q4_0_4_8, { GGML_TYPE_Q4_0, 4} }, diff --git a/src/llama-quantize.h b/src/llama-quantize.h new file mode 100644 index 00000000..3f4f1966 --- /dev/null +++ b/src/llama-quantize.h @@ -0,0 +1,7 @@ +#pragma once + +#include "ggml.h" + +#include + +std::pair interleaved_properties(ggml_type type); diff --git a/src/llama.cpp b/src/llama.cpp index a342c2d7..75347f33 100644 --- a/src/llama.cpp +++ b/src/llama.cpp @@ -17,6 +17,7 @@ #include "llama-cparams.h" #include "llama-hparams.h" #include "llama-context.h" +#include "llama-quantize.h" #include "unicode.h" @@ -4696,7 +4697,11 @@ static void llama_repack_up_gate_exps(llama_context & lctx) { auto & l = model.layers[il]; if (l.ffn_up_gate_exps && l.ffn_up_exps && l.ffn_gate_exps && !l.ffn_up_gate_exps->extra) { - GGML_ASSERT(l.ffn_up_gate_exps->type == l.ffn_up_exps->type && l.ffn_up_gate_exps->type == l.ffn_gate_exps->type); + GGML_ASSERT(l.ffn_up_exps->type == l.ffn_gate_exps->type); + if (l.ffn_up_gate_exps->type != l.ffn_up_exps->type) { + auto [other_type, _] = interleaved_properties(l.ffn_up_gate_exps->type); + GGML_ASSERT(other_type == l.ffn_up_exps->type); + } GGML_ASSERT(l.ffn_up_gate_exps->ne[0] == l.ffn_up_exps->ne[0] && l.ffn_up_gate_exps->ne[0] == l.ffn_gate_exps->ne[0]); GGML_ASSERT(l.ffn_up_gate_exps->ne[2] == l.ffn_up_exps->ne[2] && l.ffn_up_gate_exps->ne[2] == l.ffn_gate_exps->ne[2]); GGML_ASSERT(l.ffn_up_gate_exps->ne[1] == l.ffn_up_exps->ne[1] + l.ffn_gate_exps->ne[1]);