Skip to content

quant : do not require imatrix when the tensor keeps its type - #26255

Open
TrevorS wants to merge 1 commit into
ggml-org:masterfrom
TrevorS:fix-quant-imatrix-same-type
Open

quant : do not require imatrix when the tensor keeps its type#26255
TrevorS wants to merge 1 commit into
ggml-org:masterfrom
TrevorS:fix-quant-imatrix-same-type

Conversation

@TrevorS

@TrevorS TrevorS commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Overview

While claude was requantizing the deepseek iq3xxs model while pinning the experts in place, it came across a regression. Minimal repro on any model that already contains an imatrix-requiring type, pinning that type in place:

llama-quantize --allow-requantize --tensor-type ffn_up=iq2_xxs \
    model-iq2_xxs.gguf model-q8_0.gguf Q8_0

aborts in the pre-quantization validation with ERROR: this quantization requires an importance matrix! even though the pinned tensors are byte-copied rather than quantized (regression introduced with the early validation pass in #19770).

To fix the regression you can avoid setting requires_imatrix when target_type and tensor->type are the same.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES - the bug was found and the patch written with Claude Code; reviewed and repro-tested by me (CPU build, fix-side repro, --dry-run, and a still-aborts control on a genuinely converting pin).

A tensor whose target type equals its current type is copied verbatim by
the quantize loop (cur_type != new_type short-circuit), so the imatrix
data is unused by construction. Only set requires_imatrix when the type
actually changes, so that --tensor-type pins holding IQ-class tensors at
their source type no longer abort a partial requantization with
"this quantization requires an importance matrix!" (and no longer
trigger the spurious --dry-run imatrix warning).
@TrevorS
TrevorS requested a review from ggerganov as a code owner July 28, 2026 23:25
@ggml-gh-bot

ggml-gh-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

Hi @TrevorS, thanks for your contribution!

Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:

  • PR Template not respected: Please respect the template when creating a new pull request. Make sure to fill out all required sections.

Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant