Allow using -rtr and -muge together (#1444)

This commit is contained in:
Kawrakow 2026-03-16 18:26:26 +01:00 committed by GitHub
parent e3f5f3d823
commit 54bcafee16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 2 deletions

View File

@ -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<ggml_type, int> interleaved_properties(ggml_type type) {
std::pair<ggml_type, int> interleaved_properties(ggml_type type) {
static std::unordered_map<ggml_type, std::pair<ggml_type, int>> k_map = {
{ GGML_TYPE_Q4_0_4_4, { GGML_TYPE_Q4_0, 4} },
{ GGML_TYPE_Q4_0_4_8, { GGML_TYPE_Q4_0, 4} },

7
src/llama-quantize.h Normal file
View File

@ -0,0 +1,7 @@
#pragma once
#include "ggml.h"
#include <utility>
std::pair<ggml_type, int> interleaved_properties(ggml_type type);

View File

@ -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]);