Allow quantize to only copy tensors, other improvements #2931
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.
You can now specify
copy
as the type to thequantize
tool to only copy tensors, never quantize. I forget where I saw it, but it was recently mentioned that something like could be used to convert/repackage from stuff like GGUF V1 to GGUF V2.This also improves the logic in the actual quantize function (mainly for k-quants) to be a bit smarter when requantizing to the same format. The current logic skips quantizing when
quantize_type == tensor->type
. However, this means the k-quants logic for stuff like counting numbers of tensors to decide whether to use more bits doesn't run. The result is if you quantize toq4_k_m
and then requantize toq4_k_m
stuff like requantizingq6_k
tensors toq4_k
will occur. Not super likely, but I recall reading a pull recently where someone was confused by behavior like that and making it work a little more intuitively is pretty easy. (Of course, if the k-quants strategy changes then you're still going to have a bad time but this change is at least as good as the status quo.)