quantize: fix F16/F32 downcast to q6_K#5980
Closed
JohannesGaessler wants to merge 1 commit intoggml-org:masterfrom
Closed
quantize: fix F16/F32 downcast to q6_K#5980JohannesGaessler wants to merge 1 commit intoggml-org:masterfrom
JohannesGaessler wants to merge 1 commit intoggml-org:masterfrom
Conversation
Member
|
Wouldn't it make more sense to not quantize at all if the requested type is F16 or F32: diff --git a/llama.cpp b/llama.cpp
index 24944216..a08d3874 100644
--- a/llama.cpp
+++ b/llama.cpp
@@ -12106,8 +12106,10 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s
llama_format_tensor_shape(tensor).c_str(),
ggml_type_name(tensor->type));
+ bool quantize = ggml_is_quantized(quantized_type);
+
// This used to be a regex, but <regex> has an extreme cost to compile times.
- bool quantize = name.rfind("weight") == name.size() - 6; // ends with 'weight'?
+ quantize &= name.rfind("weight") == name.size() - 6; // ends with 'weight'?
// quantize only 2D tensors
quantize &= (ggml_n_dims(tensor) == 2);note: I haven't tested this |
Contributor
Author
|
With the proposed code change it would not be possible to do f16 <-> f32 conversions because the tensors would simply be copied. |
ggerganov
added a commit
that referenced
this pull request
Mar 11, 2024
Member
|
I pushed an alternative fix + some minor code cleanup |
NeoZhangJianyu
pushed a commit
to NeoZhangJianyu/llama.cpp
that referenced
this pull request
Mar 12, 2024
jordankanter
pushed a commit
to jordankanter/llama.cpp
that referenced
this pull request
Mar 13, 2024
Seunghhon
pushed a commit
to Seunghhon/llama.cpp
that referenced
this pull request
Apr 26, 2026
phuongncn
pushed a commit
to phuongncn/llama.cpp-gx10-dgx-sparks-deepseekv4
that referenced
this pull request
Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While converting the official Gemma FP32 GGUF to FP16 with
quantizeI noticed thattoken_embd.weightwas being converted to q6_k. This seems to be a simple oversight in the code where the only data type checked against is q8_0 but not f16/f32. This PR adds the missing checks.