Merged
Conversation
Still uses the old format when the output filename ends with .dat but this can be overridden with --output-format
compilade
commented
Jul 24, 2025
tools/imatrix/imatrix.cpp
Outdated
| // TODO: use the new format in more cases | ||
| if (!string_ends_with(fname, ".gguf")) { | ||
| LOG_WRN("\n%s: saving to legacy imatrix format because output suffix is not .gguf\n", __func__); | ||
| if ((imat_type == COMMON_IMATRIX_FORMAT_AUTO && string_ends_with(fname, ".dat")) || |
Collaborator
Author
There was a problem hiding this comment.
It might be better to instead simply use GGUF regardless of the file name by default.
I don't know why I'm hesitating.
Generating new imatrix.dat has limited uses (however, reading has many uses). The main user who would benefit doesn't really use mainline llama.cpp for this anymore (see ikawrakow/ik_llama.cpp#15 (reply in thread)).
This simplification could also remove the need for the common_imatrix_format_type enum, which could be a bool instead.
EDIT: I've changed this in 1ef3cc1, the format is no longer decided with the output filename.
The legacy format can only be produced with --output-format dat
CISC
approved these changes
Jul 24, 2025
Collaborator
CISC
left a comment
There was a problem hiding this comment.
LGTM, if you're still hesitant, add a warning if filename doesn't end with .gguf?
This was referenced Aug 4, 2025
blime4
referenced
this pull request
in blime4/llama.cpp
Feb 5, 2026
* imatrix : use GGUF by default * imatrix : use GGUF regardless of the output filename The legacy format can only be produced with --output-format dat
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.
The GGUF format for imatrix (added in #9400) is a saner default. The old
imatrix.datformat doesn't store the per-expert evaluation counts for MoE models, which would make future improvements like #9400 (comment) less accurate.Previously, the behavior was to only use GGUF when the output filename ended with
.gguf. That is too strict in some cases (e.g. when using an additional~suffix to mark temporary files), and can also lead to people using the legacy format accidentally.Since the GGUF-based imatrix format is very close to the internal state of
llama-imatrix, converting toimatrix.datformat fromimatrix.ggufis the same as directly generating theimatrix.datfile (but the reverse is not necessarily true (e.g. for MoE models), due to evaluation counts shape not present inimatrix.dat).llama-quantizealready doesn't use the imatrix filename to guess its type; it attempts to load as GGUF and fallbacks to the other format when it fails, so the name of the imatrix file doesn't technically matter.The new default imatrix output format is GGUF regardless of the output filename. The legacy
imatrix.datformat can be produced with--output-format dat.Make sure to read the contributing guidelines before submitting a PR