Skip to content

Commit e51a5e5

Browse files
committed
Claw back a few of the changes for less dramatic file size increase
1 parent b1a60aa commit e51a5e5

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/llama-quant.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,27 @@ static ggml_type llama_tensor_get_type(quantize_state_impl & qs, ggml_type new_t
192192
else new_type = ftype == LLAMA_FTYPE_MOSTLY_IQ2_S || ftype == LLAMA_FTYPE_MOSTLY_IQ2_M ? GGML_TYPE_IQ3_S : GGML_TYPE_Q2_K;
193193
++qs.i_attention_wv;
194194
}
195-
else if (qs.model.hparams.n_expert >= 8 && name.find("attn_k") != std::string::npos) {
195+
else if (qs.model.hparams.n_expert >= 8 && name.find("attn_k.weight") != std::string::npos) {
196196
new_type = GGML_TYPE_Q4_K;
197197
}
198-
else if (qs.model.hparams.n_expert >= 8 && name.find("attn_q") != std::string::npos) {
198+
else if (qs.model.hparams.n_expert >= 8 && name.find("attn_kv_a_mqa.weight") != std::string::npos) {
199199
new_type = GGML_TYPE_Q4_K;
200200
}
201+
else if (qs.model.hparams.n_expert >= 8 && name.find("attn_kv_b.weight") != std::string::npos) {
202+
if (qs.i_attention_wv < qs.n_attention_wv/16) {
203+
new_type = GGML_TYPE_Q4_K;
204+
}
205+
else if (use_more_bits(qs.i_attention_wv, qs.n_attention_wv)) {
206+
new_type = ftype == LLAMA_FTYPE_MOSTLY_IQ2_S || ftype == LLAMA_FTYPE_MOSTLY_IQ2_M ? GGML_TYPE_IQ3_S : GGML_TYPE_Q2_K;
207+
}
208+
++qs.i_attention_wv;
209+
}
210+
else if (qs.model.hparams.n_expert >= 8 && name.find("attn_q_a.weight") != std::string::npos) {
211+
new_type = GGML_TYPE_Q4_K;
212+
}
213+
else if (qs.model.hparams.n_expert >= 8 && name.find("attn_q_b.weight") != std::string::npos) {
214+
new_type = ftype == LLAMA_FTYPE_MOSTLY_IQ2_S || ftype == LLAMA_FTYPE_MOSTLY_IQ2_M ? GGML_TYPE_IQ3_S : GGML_TYPE_Q2_K;
215+
}
201216
else if (qs.model.hparams.n_expert >= 8 && name.find("ffn_down") != std::string::npos) {
202217
if (qs.i_ffn_down < qs.n_ffn_down/16) {
203218
new_type = GGML_TYPE_Q4_K;

0 commit comments

Comments
 (0)