diff --git a/src/llama-quant.cpp b/src/llama-quant.cpp index 6e7f1ba3ba..eb94c8a212 100644 --- a/src/llama-quant.cpp +++ b/src/llama-quant.cpp @@ -690,7 +690,23 @@ static ggml_type llama_tensor_get_type(quantize_state_impl & qs, const llama_mod return tensor->type; } if (params->token_embedding_type < GGML_TYPE_COUNT && tm.category == tensor_category::TOKEN_EMBD) { - return params->token_embedding_type; + // per_layer_token_embd shares this category with token_embd.weight and follows + // --token-embedding-type by default. But it is a separate table and far from a + // rounding error: qwen4exp's is ~46% of a 4-bit file. Let an explicit --tensor-type + // name it; nothing changes unless such a pattern is passed. + bool named = false; + if (std::strcmp(tensor->name, "per_layer_token_embd.weight") == 0) { + const std::string tensor_name(tensor->name); + for (const auto & [pattern, qtype] : qs.tensor_type_patterns) { + if (std::regex_search(tensor_name, pattern)) { + named = true; + break; + } + } + } + if (!named) { + return params->token_embedding_type; + } } if (params->output_tensor_type < GGML_TYPE_COUNT && tm.category == tensor_category::OUTPUT) { return params->output_tensor_type;