Skip to content

imatrix : use GGUF by default #14842

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 3, 2025
Merged

imatrix : use GGUF by default #14842

merged 2 commits into from
Aug 3, 2025

Conversation

compilade
Copy link
Collaborator

@compilade compilade commented Jul 24, 2025

The GGUF format for imatrix (added in #9400) is a saner default. The old imatrix.dat format 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 to imatrix.dat format from imatrix.gguf is the same as directly generating the imatrix.dat file (but the reverse is not necessarily true (e.g. for MoE models), due to evaluation counts shape not present in imatrix.dat).

llama-quantize already 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.dat format can be produced with --output-format dat.


Make sure to read the contributing guidelines before submitting a PR

Still uses the old format when the output filename ends with .dat
but this can be overridden with --output-format
// 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")) ||
Copy link
Collaborator Author

@compilade compilade Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator

@CISC CISC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, if you're still hesitant, add a warning if filename doesn't end with .gguf?

@CISC CISC merged commit d31192b into master Aug 3, 2025
47 checks passed
Nexesenex pushed a commit to Nexesenex/croco.cpp that referenced this pull request Aug 5, 2025
* imatrix : use GGUF by default

* imatrix : use GGUF regardless of the output filename

The legacy format can only be produced with --output-format dat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants