Skip to content

Studio: classify qwen_image21 GGUFs as text-to-image - #13333

Merged
danielhanchen merged 6 commits into
unslothai:mainfrom
abhishekacharya200:fix/qwen-image21-gguf-arch
Oct 12, 2026
Merged

danielhanchen merged 6 commits into
unslothai:mainfrom
abhishekacharya200:fix/qwen-image21-gguf-arch

Conversation

@abhishekacharya200

@abhishekacharya200 abhishekacharya200 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #13328

Qwen-Image-2.1 GGUFs that carry a GGUF header (e.g. abenzerps/Qwen-Image-2.1-Uncensored-GGUF) declare general.architecture = qwen_image21. That arch was missing from _DIFFUSION_GGUF_ARCHS, so _arch_to_task() fell through to text-generation: the model showed up under Chat (where it cannot run) and never on the Images page. The official unsloth/Qwen-Image-2.1* repos were unaffected only because their headers have no architecture key and go through the name-based fallback.

Changes:

  • Add qwen_image21 / qwenimage21 to _DIFFUSION_GGUF_ARCHS in catalog_classification.py (same pattern as the existing qwen_image / qwenimage pair). The text-to-image branch still goes through _gguf_family_buildable(), so unbuildable families stay hidden.
  • Add qwen_image21 to LlamaCppBackend._IMAGE_ARCHES, so loading such a file as a chat model gives the "open it from the Images page" message instead of an unknown-architecture failure.
  • Regression test in test_arch_to_task_hides_unsupported_diffusion_from_chat.

Testing:

  • The new assertion fails on main ('text-generation' == 'text-to-image') and passes with this change.
  • tests/test_cached_gguf_routes.py, tests/test_llama_cpp_non_chat_gguf_preflight.py and tests/test_local_model_format.py: 370 passed, 1 skipped.

Before / after (Studio, merge base vs this PR, same seeded cache with the real qwen-image-2.1-UC-Q4_K_M.gguf)

Images page model picker, On Device tab: the model is missing before and listed after.

Images picker before and after

Picking the model from the Chat picker: before, Studio tries to load it as a chat model; after, it opens the Images page.

Chat pick before and after

Qwen-Image-2.1 GGUFs that carry a header declare
`general.architecture = qwen_image21`, which was missing from the diffusion
arch allowlist, so they were listed under Chat instead of the Images page.
Add it to the catalog allowlist and to the llama.cpp image-arch gate.

Fixes unslothai#13328
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 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 ⚠️ Failed 2026-10-12T01:48:49.719792Z d00c014 New commits
ℹ️ 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.

@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: bcbd12a73c

ℹ️ 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".


_DIFFUSION_GGUF_ARCHS = frozenset({"flux", "flux2", "qwen_image", "qwenimage", "z_image", "zimage"})
_DIFFUSION_GGUF_ARCHS = frozenset(
{"flux", "flux2", "qwen_image", "qwenimage", "qwen_image21", "qwenimage21", "z_image", "zimage"}

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 Resolve cached Qwen 2.1 families before advertising them

For a cached Hub GGUF whose repo id and filename are opaque or renamed, this new architecture entry makes _repo_gguf_task() return text-to-image from the header because _gguf_family_buildable() fails open when its name hints resolve no family. The actual image load calls DiffusionBackend.validate_load_request() with only that repo id and filename; detect_family_for_pick() has no cached-header fallback, so it returns None and the picker-advertised load fails with a 400. Resolve qwen_image21 from the cached header on the image load path (as video's _detect_load_family() does), or avoid advertising it when the names do not resolve.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not a regression: _gguf_family_buildable already fails open for every arch in this set (an opaque-named flux or qwen_image GGUF behaves the same), and before this PR such a file was listed in Chat, where it cannot load at all. Every public qwen_image21 upload checked (abenzerps, realrebelai, Gohans, KasugaiSakura, Nylonek, basileleuwa, 0xSojalSec) resolves to qwen-image-2.1 via detect_family_for_pick from its repo id or filename.

_IMAGE_ARCHES = frozenset(
(
"qwen_image",
"qwen_image21",

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 Gate the Qwen 2.1 redirect on Images availability

On a CUDA host with diffusers older than 0.41.0 and the default engine policy, family_buildable_here() is false for Qwen-Image-2.1, so the catalog tags a named GGUF unsupported and the Images picker omits it. This unconditional membership nevertheless makes both _non_chat_gguf_refusal() and _classify_llama_start_failure() tell users to open that missing Images entry; apply the same family/buildability verdict used by the catalog before promising this destination.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Studio pins diffusers==0.41.0 (requirements/diffusers-pin.txt) and requires Python >= 3.11, so Qwen-Image-2.1 is buildable on every supported install; the other _IMAGE_ARCHES entries are unconditional for the same reason. Before this PR the same load died with llama-server's unknown-architecture error, so the redirect is strictly better.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Correction to my earlier reply: diffusers-pin.txt still gives Python 3.9 hosts diffusers 0.36, so this was reachable there. Fixed in 224dc49.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@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: bcbd12a73c

ℹ️ 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".

_IMAGE_ARCHES = frozenset(
(
"qwen_image",
"qwen_image21",

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 Gate the Qwen 2.1 redirect by host buildability

On a supported Python 3.9 CUDA installation using the default engine policy, the Images entry this new unconditional membership promises does not exist: pyproject.toml:15 supports Python 3.9, studio/backend/requirements/diffusers-pin.txt:12-16 pins that interpreter to diffusers 0.36.0, and diffusion_families.py:1596-1599 records that QwenImage21Pipeline requires 0.41.0, so _gguf_family_buildable() makes the catalog classify a named Qwen-Image-2.1 GGUF as image-diffusion-unsupported. Nevertheless, both _non_chat_gguf_refusal() and _classify_llama_start_failure() now use _IMAGE_ARCHES to direct the user to the absent Images row; use the same family/buildability check before naming that destination. This version-marker evidence directly contradicts the earlier thread's assumption that Studio requires Python >=3.11.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed in 224dc49: the refusal now asks the same buildability check the catalog uses before naming the Images page (diffusers-pin.txt keeps Python 3.9 hosts on diffusers 0.36, which has no Qwen-Image-2.1 pipeline).

…mages redirect on buildability

The image loader now falls back to a cached GGUF's arch when the repo id and
filename name no family, for archs that pin down a single family, so a renamed
qwen_image21 file the picker lists no longer fails to load with a 400. The
catalog judges that file by the same family instead of failing open, and the
llama.cpp refusals only point at the Images page when that family can be
built on this host.
@abhishekacharya200

Copy link
Copy Markdown
Contributor Author

Thanks for taking a look, and for the comment fix! I went through both Codex points and they were right, so I pushed a1a55ff to cover them.

Renamed cached GGUFs. detect_family_for_pick now falls back to the cached GGUF's general.architecture when the repo id and filename name no family, reusing the video loader's _picked_gguf_arch helper, so it reads a local dir or the cached Hub blob without touching the network. I limited this to archs that point to exactly one family (qwen_image21 / qwenimage21 for now). qwen_image and flux stay name based, since guessing there would hand an Edit or Kontext file the wrong pipeline. _gguf_family_buildable takes the arch too and judges an opaque file by that same family instead of failing open, so the listing and the loader agree.

Images redirect on hosts that can't build it. The llama.cpp preflight refusal and _classify_llama_start_failure now ask _gguf_family_buildable before sending users to the Images page, the same check the catalog uses. When the family can't be built (for example Qwen-Image-2.1 with diffusers older than 0.41), the message says the Images page doesn't list it either. On an unresolved family it still fails open, like the catalog does.

Tests: 4 new regression tests (loader header fallback, catalog verdict, both refusal paths) fail on the previous head and pass now. The cached GGUF routes, llama.cpp preflight and start failure suites pass (551 passed). Five test_delete_variant_* tests in hub/tests/test_model_services.py fail for me locally, but they fail the same way on main, so they're unrelated.

If you'd rather keep this PR to the one line allowlist change and handle the rest separately, I'm happy to split it out.

The renamed file case is not a regression, so the loader and catalog go back
to how they were. The llama.cpp refusals still check buildability before naming
the Images page, since Python 3.9 hosts get diffusers 0.36, which cannot build
Qwen-Image-2.1.
@abhishekacharya200

Copy link
Copy Markdown
Contributor Author

Sorry, I missed your replies on the threads before posting, my bad. You're right that the renamed file case isn't a regression, so I've dropped the loader fallback and kept this PR small.

On the redirect, I think Codex's second note holds: pyproject.toml still allows Python 3.9 (>=3.9,<3.15), and diffusers-pin.txt gives 3.9 hosts diffusers 0.36.0, which can't build Qwen-Image-2.1. So the latest commit keeps only the buildability check before the refusal names the Images page, with its two tests. Happy to drop that too if you'd rather handle 3.9 separately.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 224dc4923b

ℹ️ 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 12, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 12, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 12, 2026
@danielhanchen
danielhanchen merged commit a4b9c62 into unslothai:main Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Diffusion GGUF with general.architecture=qwen_image21 is filed as text-generation and hidden from the Images page

2 participants