Skip to content

Commit 3f8d7a2

Browse files
committed
Claw back a few of the changes for less dramatic file size increase
1 parent cb496c4 commit 3f8d7a2

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
@@ -259,12 +259,27 @@ static ggml_type llama_tensor_get_type(quantize_state_impl & qs, ggml_type new_t
259259
else new_type = ftype == LLAMA_FTYPE_MOSTLY_IQ2_S || ftype == LLAMA_FTYPE_MOSTLY_IQ2_M ? GGML_TYPE_IQ3_S : GGML_TYPE_Q2_K;
260260
++qs.i_attention_wv;
261261
}
262-
else if (qs.model.hparams.n_expert >= 8 && name.find("attn_k") != std::string::npos) {
262+
else if (qs.model.hparams.n_expert >= 8 && name.find("attn_k.weight") != std::string::npos) {
263263
new_type = GGML_TYPE_Q4_K;
264264
}
265-
else if (qs.model.hparams.n_expert >= 8 && name.find("attn_q") != std::string::npos) {
265+
else if (qs.model.hparams.n_expert >= 8 && name.find("attn_kv_a_mqa.weight") != std::string::npos) {
266266
new_type = GGML_TYPE_Q4_K;
267267
}
268+
else if (qs.model.hparams.n_expert >= 8 && name.find("attn_kv_b.weight") != std::string::npos) {
269+
if (qs.i_attention_wv < qs.n_attention_wv/16) {
270+
new_type = GGML_TYPE_Q4_K;
271+
}
272+
else if (use_more_bits(qs.i_attention_wv, qs.n_attention_wv)) {
273+
new_type = ftype == LLAMA_FTYPE_MOSTLY_IQ2_S || ftype == LLAMA_FTYPE_MOSTLY_IQ2_M ? GGML_TYPE_IQ3_S : GGML_TYPE_Q2_K;
274+
}
275+
++qs.i_attention_wv;
276+
}
277+
else if (qs.model.hparams.n_expert >= 8 && name.find("attn_q_a.weight") != std::string::npos) {
278+
new_type = GGML_TYPE_Q4_K;
279+
}
280+
else if (qs.model.hparams.n_expert >= 8 && name.find("attn_q_b.weight") != std::string::npos) {
281+
new_type = ftype == LLAMA_FTYPE_MOSTLY_IQ2_S || ftype == LLAMA_FTYPE_MOSTLY_IQ2_M ? GGML_TYPE_IQ3_S : GGML_TYPE_Q2_K;
282+
}
268283
else if (qs.model.hparams.n_expert >= 8 && name.find("ffn_down") != std::string::npos) {
269284
if (qs.i_ffn_down < qs.n_ffn_down/16) {
270285
new_type = GGML_TYPE_Q4_K;

0 commit comments

Comments
 (0)