Keep ffn down for HiDream

This commit is contained in:
City
2025-04-16 02:22:31 +02:00
parent 2ef5a66a9f
commit 3605bfbead
+8 -7
View File
@@ -39,7 +39,7 @@ index b16c462f..6d1568f1 100644
const int idx = gguf_find_tensor(ctx, name);
if (idx < 0) {
diff --git a/src/llama.cpp b/src/llama.cpp
index 24e1f1f0..6a0c0a0e 100644
index 24e1f1f0..5e944837 100644
--- a/src/llama.cpp
+++ b/src/llama.cpp
@@ -205,6 +205,15 @@ enum llm_arch {
@@ -114,7 +114,7 @@ index 24e1f1f0..6a0c0a0e 100644
// get hparams kv
ml.get_key(LLM_KV_VOCAB_SIZE, hparams.n_vocab, false) || ml.get_arr_n(LLM_KV_TOKENIZER_LIST, hparams.n_vocab);
@@ -18016,6 +18060,128 @@ static void llama_tensor_dequantize_internal(
@@ -18016,6 +18060,129 @@ static void llama_tensor_dequantize_internal(
workers.clear();
}
@@ -182,6 +182,7 @@ index 24e1f1f0..6a0c0a0e 100644
+ }
+ } else if ( // Rules for ffn
+ (name.find("ffn_down") != std::string::npos) ||
+ ((name.find("experts.") != std::string::npos) && (name.find(".w2.weight") != std::string::npos)) ||
+ (name.find(".ffn.2.weight") != std::string::npos) || // is this even the right way around?
+ (name.find(".ff.net.2.weight") != std::string::npos)
+ ) {
@@ -243,7 +244,7 @@ index 24e1f1f0..6a0c0a0e 100644
static ggml_type llama_tensor_get_type(quantize_state_internal & qs, ggml_type new_type, const ggml_tensor * tensor, llama_ftype ftype) {
const std::string name = ggml_get_name(tensor);
@@ -18513,7 +18679,9 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s
@@ -18513,7 +18680,9 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s
if (llama_model_has_encoder(&model)) {
n_attn_layer *= 3;
}
@@ -254,7 +255,7 @@ index 24e1f1f0..6a0c0a0e 100644
}
size_t total_size_org = 0;
@@ -18547,6 +18715,45 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s
@@ -18547,6 +18716,45 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s
ctx_outs[i_split] = gguf_init_empty();
}
gguf_add_tensor(ctx_outs[i_split], tensor);
@@ -300,7 +301,7 @@ index 24e1f1f0..6a0c0a0e 100644
}
// Set split info if needed
@@ -18647,6 +18854,92 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s
@@ -18647,6 +18855,92 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s
// do not quantize relative position bias (T5)
quantize &= name.find("attn_rel_b.weight") == std::string::npos;
@@ -393,7 +394,7 @@ index 24e1f1f0..6a0c0a0e 100644
enum ggml_type new_type;
void * new_data;
size_t new_size;
@@ -18655,6 +18948,9 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s
@@ -18655,6 +18949,9 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s
new_type = default_type;
// get more optimal quantization type based on the tensor shape, layer, etc.
@@ -403,7 +404,7 @@ index 24e1f1f0..6a0c0a0e 100644
if (!params->pure && ggml_is_quantized(default_type)) {
new_type = llama_tensor_get_type(qs, new_type, tensor, ftype);
}
@@ -18664,6 +18960,7 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s
@@ -18664,6 +18961,7 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s
if (params->output_tensor_type < GGML_TYPE_COUNT && strcmp(tensor->name, "output.weight") == 0) {
new_type = params->output_tensor_type;
}