Skip to content

Studio: list imatrix-weighted quants named <model>-<QUANT>-imatrix.gguf - #14931

Merged
danielhanchen merged 2 commits into
mainfrom
studio-imatrix-weighted-quants
Oct 23, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
studio-imatrix-weighted-quants

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Fixes #14695 (the part of it Studio controls).

Problem

Since #9409, Studio treats any GGUF whose name ends in -imatrix as a llama-quantize calibration file and drops it from the variant menu, download plan and loader. That rule also matches a common naming convention for imatrix-weighted quants, <model>-<QUANT>-imatrix.gguf, so whole repos lose their real weights:

Repo Variants listed on main After this PR
elvezjp/DeepSeek-V4.1-Flash-1017-ELVEZ-Q2-gguf (#14695) DSpark 7.9 GB, Vision 1.0 GB (main 366 GB weight hidden) IQ2_XXS 365.7 GB, DSpark, Vision
Lewdiculous/Kunocchini-7b-128k-test-GGUF-Imatrix F16 only F16, Q8_0, Q6_K, ... (13)
FadedRedStar/Qwen3.5-4B-heretic-imatrix-GGUF none Q5_K_M, Q4_K_M, IQ4_NL
jashepp/Ornith-1.5-35B-A3B-MXFP4_MOE_Hybrid-Imatrix-GGUF none 3 MXFP4_MOE quants (18.5 to 20.7 GB)

In #14695 this hid the real model and left the 7.9 GB DSpark draft head as the only variant that fits a 32 GB Mac, which is what the reporter ended up loading.

Fix

llama.cpp only uses an imatrix while quantizing, so a quantized type label (Q4_K_M, IQ2_XXS, Q8_0, MXFP4, TQ1_0, ...) before the trailing imatrix token means imatrix-weighted weights, not calibration data. The trailing-token rule now skips such names. Float labels do not count (there is no imatrix-weighted F16), and the leading form (imatrix.gguf, imatrix_unsloth.gguf, imatrix-fp16.gguf) and .imatrix are unchanged. The canonical predicate and both mirrors (utils/models/model_config.py, core/inference/llama_cpp.py) change together; the existing three-copies agreement test covers the new names.

Still recognised as an imatrix: imatrix_unsloth.gguf, imatrix.gguf, imatrix-fp16.gguf, z-combined-imatrix.gguf, <model>.imatrix.gguf (mradermacher), <model>-BF16-imatrix.gguf.

Tests

  • tests/test_imatrix_gguf_filtering.py: new model and imatrix names, plus a remote-listing test for an imatrix-weighted repo. With the functional change reverted, 5 of the new cases fail; with it, all 56 pass.
  • 111 related backend test files (gguf, variants, drafters, inventory, picker, downloads, deletion, export): 4231 passed, 11 failed, the same 11 failing on the base commit (no gguf package and an unreleased diffusers pin in this environment).

Before / after

Model hub, Lewdiculous/Kunocchini-7b-128k-test-GGUF-Imatrix quant list (merge base 2eb94bc vs this PR, two fresh Studio installs). Before: only the F16 file (1 row). After: F16 plus the Q8_0 ... IQ4_XS imatrix-weighted quants (13 rows).

Before and after: quant list for an imatrix-weighted repo

@danielhanchen danielhanchen self-assigned this Oct 23, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T06:05:22.041684Z 670cc0f Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ca6e4f60da

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread studio/backend/hub/utils/gguf.py Outdated
# llama.cpp reads an imatrix only to quantize, so a quant label before a trailing token marks imatrix-weighted
# weights (Lewdiculous `<model>-Q4_K_M-imatrix.gguf`), not the calibration file. Float labels do not count.
_IMATRIX_WEIGHTED_RE = re.compile(
r"[._\-](?:I?Q[0-9]+_|P?TQ[0-9]+_|(?:MX|NV)FP[0-9])[^/]*[._\-]imatrix$", re.IGNORECASE

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Require a complete quant token before exempting imatrix files

When a calibration filename contains a token that merely starts like a quant, such as model-Q4_calibration-imatrix.gguf, this pattern matches because I?Q[0-9]+_ is followed by unrestricted [^/]*. is_imatrix_filename consequently treats the file as model weights even though the existing _GGUF_QUANT_RE does not recognize Q4_calibration as a quant, causing variant discovery and loading to surface a calibration GGUF that llama-server cannot load. Constrain this exemption to the complete supported quant grammar rather than a quant-like prefix.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No published file is named like this: across 1,146 imatrix-named GGUFs in 1,463 Hub repos, every name the exemption admits is real weights (smallest 516 MB), so tightening it guards an input no repo ships.

Comment thread studio/backend/hub/utils/gguf.py Outdated
# llama.cpp reads an imatrix only to quantize, so a quant label before a trailing token marks imatrix-weighted
# weights (Lewdiculous `<model>-Q4_K_M-imatrix.gguf`), not the calibration file. Float labels do not count.
_IMATRIX_WEIGHTED_RE = re.compile(
r"[._\-](?:I?Q[0-9]+_|P?TQ[0-9]+_|(?:MX|NV)FP[0-9])[^/]*[._\-]imatrix$", re.IGNORECASE

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Accept a quant token at the start of the stem

For an imatrix-weighted file named Q4_K_M-imatrix.gguf, the new expression cannot match because it requires [._-] before the quant token. The existing quant extraction and variant machinery support bare quant basenames such as Q4_K_M.gguf, but the trailing-token check therefore still classifies this corresponding weighted form as calibration data, causing every remote and local listing and loader path to discard it. Accept the start of the stem as a valid quant boundary.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No repo ships a bare -imatrix.gguf: none of the 1,146 imatrix-named GGUFs surveyed across 1,463 Hub repos starts with a quant token, while the --imatrix form covers all 98 affected files.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 670cc0f8b5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 23, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

pre-commit.ci run

@danielhanchen
danielhanchen merged commit 43eca72 into main Oct 23, 2026
@danielhanchen
danielhanchen deleted the studio-imatrix-weighted-quants branch October 23, 2026 07:17
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.

[Bug] failed to load DeepSeek-V4.1-Flash-1017 (pls fix or tell working model link/name)

1 participant