Skip to content

Diffusion: source every image family's companions from unsloth mirrors - #8030

Merged
danielhanchen merged 15 commits into
mainfrom
qwen-2512-mirror
Aug 9, 2026
Merged

danielhanchen merged 15 commits into
mainfrom
qwen-2512-mirror

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Aug 6, 2026 •

Copy link
Copy Markdown
Member

Second half of #8001, and the last third-party fetch on the Qwen-Image-2512 load path.

The gap

unsloth/Qwen-Image-2512-GGUF, -FP8 and -unsloth-bnb-4bit ship only the denoiser. The VAE,
text encoder, tokenizer and scheduler come from the base repo, which for these artifacts is named
by the base_model card tag:

$ hf api model_info unsloth/Qwen-Image-2512-GGUF
tags: ['base_model:Qwen/Qwen-Image-2512', ...]

_resolve_base_repo trusts that tag (qwen/qwen-image-2512 is on the non-GGUF allowlist), so the
fetch lands on the vendor repo no matter what the family table says. The family default is the
older Qwen/Qwen-Image, so the mirror redirect added in #7952 never covered this route, and every
2512 pick pulled 16.8 GB of companions from a third-party repo whose transformer directory it does
not want.

The mirror

unsloth/Qwen-Image-2512 is a complete copy, verified against upstream:

  • 32 files vs upstream's 30; the two extra are LICENSE and NOTICE
  • no upstream file missing
  • all 14 LFS weight files identical by sha256
  • DiffusionPipeline.load_config returns QwenImagePipeline with all five components

Upstream is Apache-2.0 and ships no licence file, so section 4(a) is satisfied by writing the
Apache 2.0 text as LICENSE plus a NOTICE recording provenance and disclaiming endorsement. The
card gets a provenance banner.

Unlike the twelve repos in that script this upstream is not gated, so the table's comments no
longer describe only gating. They now say what it is for: a mirror removes a 401 for the gated
vendors and removes a third-party fetch for the ungated ones.

What does not change

The swap is fetch-only, as before. status()["base_repo"], saved configs and a trained adapter's
base_model tag all still read Qwen/Qwen-Image-2512, because _resolve_base_repo maps a mirror
id back through canonical_base. Every existing decline still applies: UNSLOTH_DIFFUSION_NO_MIRROR,
a local path, and an upstream snapshot already cached.

Tests

  • test_the_qwen_2512_mirror_covers_the_card_tag_route: the pair resolves, prefer_ungated_mirror
    swaps it, the family default is confirmed to have no mirror of its own so the redirect cannot be
    mistaken for the fallback doing the work, and canonical_base maps back to the vendor id.
  • test_no_mirror_is_a_companion_only_repo: a mirror stands in for the whole base, including a
    plain bf16 pipeline pick where the transformer is read from it. A companions-only repo in this
    table would turn a working load into a missing-weights error, so assert no mirror appears in
    sd_cpp_companion_only_repo_ids().
  • The round-trip test's count moves 12 to 13.
tests/test_diffusion_*.py tests/test_video_*.py   1431 passed, 1 skipped
hub/tests/                                         210 passed
ruff check studio/backend/                         All checks passed

Update: the rest of the third-party bases

Extended to cover every remaining vendor base an image family loads companions from. Eight more
complete mirrors, all verified against upstream (every LFS weight file matches by sha256, no
upstream file missing):

Upstream Mirror Licence
Qwen/Qwen-Image unsloth/Qwen-Image Apache-2.0
Qwen/Qwen-Image-Edit-2511 unsloth/Qwen-Image-Edit-2511 Apache-2.0
black-forest-labs/FLUX.2-klein-4B unsloth/FLUX.2-klein-4B Apache-2.0
Tongyi-MAI/Z-Image-Turbo unsloth/Z-Image-Turbo Apache-2.0
Alpha-VLLM/Lumina-Image-2.0 unsloth/Lumina-Image-2.0 Apache-2.0
HiDream-ai/HiDream-I1-Full unsloth/HiDream-I1-Full MIT
stabilityai/stable-diffusion-xl-base-1.0 unsloth/stable-diffusion-xl-base-1.0 OpenRAIL++
stabilityai/sdxl-turbo unsloth/sdxl-turbo Stability AI Community

Redistribution terms differ per repo, so each mirror carries the upstream licence text plus the
notice its own licence prescribes: Apache-2.0 section 4(a) for the five above, MIT's copyright and
permission notice for HiDream, OpenRAIL++ with Attachment A's use restrictions flowed down for
SDXL base, and for sdxl-turbo the section IV(a) attribution sentence verbatim.

One base deliberately not mirrored

hunyuanvideo-community/HunyuanImage-2.1-Diffusers stays third-party. The Tencent Hunyuan
Community License permits distribution "exclusively in the Territory", and the Territory is
defined to exclude the EU, the UK and South Korea. A public Hub repo distributes worldwide, so
that mirror cannot be made compliant. The table says so where the next person will look.

Test churn

Three existing tests asserted a vendor id at a point where the fetch now reads the mirror. Updated
to the mirror, and two of them now also assert status()["base_repo"] still reports the vendor id,
which is the property the fetch-only swap exists to preserve.

A Qwen-Image-2512 GGUF, FP8 or bnb-4bit pick ships only the denoiser and reads
its VAE, text encoder, tokenizer and scheduler from the base. That base is named
by the base_model card tag on the artifact repo (Qwen/Qwen-Image-2512), not by
the family table, whose default is the older Qwen/Qwen-Image, so nothing in the
existing redirect touched it and every 2512 pick pulled 16.8 GB from the vendor.

unsloth/Qwen-Image-2512 is a complete mirror: all 14 weight files match upstream
by sha256, no file is missing, and it loads as QwenImagePipeline with all five
components. Apache-2.0 upstream, so the copy carries LICENSE and NOTICE.

The mirror table is no longer only about gating, so its comments say what it is
now for. The swap stays fetch-only: status(), saved configs and a trained
adapter's base_model tag still read the vendor id through canonical_base.

Two new tests: the 2512 pair specifically, since it is the one entry the family
table cannot reach; and a guard that no mirror is ever a companion-only repo,
because prefer_ungated_mirror also fires on a plain bf16 pipeline pick and a
mirror without a transformer would break it.
Eight more complete mirrors, so that every image family Studio can load takes
its companions from unsloth/* rather than a vendor repo: Qwen-Image,
Qwen-Image-Edit-2511, FLUX.2-klein-4B, Z-Image-Turbo, Lumina-Image-2.0,
HiDream-I1-Full, stable-diffusion-xl-base-1.0 and sdxl-turbo.

All eight verified against upstream: every LFS weight file matches by sha256,
no upstream file is missing. Redistribution terms differ, so each mirror
carries the upstream licence text plus the notice its own licence prescribes:
Apache-2.0 for the five Qwen/BFL/Tongyi/Alpha-VLLM repos, MIT with its
copyright and permission notice for HiDream, OpenRAIL++ with Attachment A's
use restrictions flowed down for SDXL base, and for sdxl-turbo the Stability
AI Community License with the section IV(a) attribution sentence verbatim.

HunyuanImage-2.1 is deliberately NOT mirrored, and the table says so. The
Tencent Hunyuan Community License permits distribution only inside a Territory
that excludes the EU, the UK and South Korea, and a public Hub repo
distributes worldwide.

Three existing tests asserted a vendor id where the fetch now reads the
mirror. Updated to the mirror, and two of them now also assert that status
still reports the vendor id, which is the property the fetch-only swap is
supposed to preserve.
@danielhanchen danielhanchen changed the title Diffusion: source the Qwen-Image-2512 companions from unsloth Diffusion: source every image family's companions from unsloth mirrors Aug 6, 2026
Both build a Z-Image cache fixture and then let prefer_ungated_mirror read the
REAL cache to decide whether the swap fires. On a machine that happens to hold
the upstream they pass, on a clean runner they fail, which is how they passed
locally for me and failed in CI.

The cross-root test pins UNSLOTH_DIFFUSION_NO_MIRROR, since its subject is
shard discovery across cache roots and not mirroring at all. The dense-builder
test pins _no_cache and asserts the mirror id, which is what the load reads now
that Z-Image is mirrored; which hub id it is was always incidental there, the
point being a hub id rather than the staged snapshot path.

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

ℹ️ 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 on lines +508 to +511
("black-forest-labs/FLUX.2-klein-4B", "unsloth/FLUX.2-klein-4B"),
("Tongyi-MAI/Z-Image-Turbo", "unsloth/Z-Image-Turbo"),
("Alpha-VLLM/Lumina-Image-2.0", "unsloth/Lumina-Image-2.0"),
("HiDream-ai/HiDream-I1-Full", "unsloth/HiDream-I1-Full"),

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 Add mirrors for every supported variant base

The table only covers the standard Klein 4B and HiDream Full repos, but exact lookup means supported variants still bypass the mirrors: unsloth/FLUX.2-klein-base-4B-GGUF can resolve its trusted card tag to black-forest-labs/FLUX.2-klein-base-4B, while the model catalog directly offers HiDream-ai/HiDream-I1-Dev and HiDream-ai/HiDream-I1-Fast. Because none of those IDs is present here, prefer_ungated_mirror returns the vendor ID and these advertised loads continue fetching up to roughly 63 GB from third parties, contrary to the change's stated coverage and its claim that Hunyuan is the sole deliberate exception.

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.

Right on all three, fixed in 2032643. Confirmed each: unsloth/FLUX.2-klein-base-4B-GGUF resolves its card tag to black-forest-labs/FLUX.2-klein-base-4B (exercised in test_diffusion_more_families.py), and HiDream-ai/HiDream-I1-Dev / -Fast are both bf16Pipeline entries at 63 GB in the catalog. None was in the table, so all three kept fetching from the vendor.

All three upstreams are ungated and permissively licensed (apache-2.0 for klein-base-4B, MIT for both HiDream), so redistribution rests on the same basis as the other ungated mirrors. I published complete copies and verified them file-by-file against upstream: 25/25, 36/36 and 36/36, no missing entries and no size mismatches.

Rather than just add three rows, the new test reads the catalog instead of restating the table, so a newly offered vendor bf16 pipeline fails there instead of quietly bypassing the mirrors. It caught Lightricks/LTX-2 and the two Wan-AI bases as well; those are video and out of this change's scope, so the test is sliced to IMAGE_CATALOG and mirroring them is a separate call. Verified load-bearing: dropping the two HiDream rows fails it and names them.

danielhanchen and others added 2 commits August 7, 2026 06:13
The table named FLUX.2-klein-4B and HiDream-I1-Full but not the variants a
supported pick can actually resolve to, and lookup is by exact id:

  black-forest-labs/FLUX.2-klein-base-4B  <- what unsloth/FLUX.2-klein-base-4B-GGUF
                                             resolves to from its card tag
  HiDream-ai/HiDream-I1-Dev               <- offered directly, 63 GB bf16 pipeline
  HiDream-ai/HiDream-I1-Fast              <- offered directly, 63 GB bf16 pipeline

So those picks kept fetching from the vendor while the change claimed to have
stopped that, and claimed Hunyuan was the only deliberate exception.

All three upstreams are ungated and permissively licensed (apache-2.0 and MIT),
so redistribution rests on the same basis as the existing ungated mirrors. Each
new mirror is a complete copy, verified file-by-file against upstream: 25/25,
36/36 and 36/36 files with no missing entries and no size mismatches.

The new test reads the catalog rather than restating the table, so a newly
offered vendor bf16 pipeline fails here instead of quietly bypassing the
mirrors. It is scoped to IMAGE_CATALOG, matching this change's scope; the video
bases are ungated and a separate call. Verified load-bearing: dropping the two
HiDream rows fails it and names them.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 10260e8f9f

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

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 53da53d564

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

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. Hooray!

Reviewed commit: 8f874f70c8

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

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 80be20e577

ℹ️ 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
danielhanchen merged commit b8f09bc into main Aug 9, 2026
38 of 45 checks passed
@danielhanchen
danielhanchen deleted the qwen-2512-mirror branch August 9, 2026 11:33
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