Skip to content

Commit daf2dd7

Browse files
authored
quantize : skip tensor override when in fallback mode (#14995)
1 parent a06ed5f commit daf2dd7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/llama-quant.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -875,9 +875,10 @@ static void llama_model_quantize_impl(const std::string & fname_inp, const std::
875875

876876
// get more optimal quantization type based on the tensor shape, layer, etc.
877877
if (!params->pure && ggml_is_quantized(default_type)) {
878+
int fallback = qs.n_fallback;
878879
new_type = llama_tensor_get_type(qs, new_type, tensor, ftype);
879-
// unless the user specifies a type
880-
if (params->tensor_types) {
880+
// unless the user specifies a type, and the tensor geometry will not require fallback quantisation
881+
if (params->tensor_types && qs.n_fallback - fallback == 0) {
881882
const std::vector<tensor_quantization> & tensor_types = *static_cast<const std::vector<tensor_quantization> *>(params->tensor_types);
882883
const std::string tensor_name(tensor->name);
883884
for (const auto & [tname, qtype] : tensor_types) {
@@ -890,7 +891,6 @@ static void llama_model_quantize_impl(const std::string & fname_inp, const std::
890891
}
891892
}
892893
}
893-
894894
if (params->token_embedding_type < GGML_TYPE_COUNT && strcmp(tensor->name, "token_embd.weight") == 0) {
895895
new_type = params->token_embedding_type;
896896
}

0 commit comments

Comments
 (0)