Skip to content

Studio: fetch the sd.cpp companion assets from unsloth mirrors, not community repacks - #7995

Merged
danielhanchen merged 15 commits into
mainfrom
diffusion-thirdparty-mirrors
Aug 6, 2026
Merged

danielhanchen merged 15 commits into
mainfrom
diffusion-thirdparty-mirrors

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

#7952 moved the twelve gated vendor bases behind ungated unsloth/* mirrors. It left the other half untouched: the files the no-GPU path actually opens do not come from the vendor at all, they come from community repacks.

comfyanonymous/flux_text_encoders               CLIP-L + T5-XXL fp16   FLUX.1
Comfy-Org/Qwen-Image_ComfyUI                    VAE                    Qwen-Image
Comfy-Org/flux2-dev                             VAE + Mistral encoder  FLUX.2 dev, FLUX.2 klein
Comfy-Org/z_image_turbo                         VAE + Qwen3-4B         Z-Image, klein 4B
Comfy-Org/vae-text-encorder-for-flux-klein-9b   Qwen3-8B               klein 9B
QuantStack/Wan2.2-TI2V-5B-GGUF                  13 GGUF quants         Wan2.2 TI2V 5B

None of these owes anyone availability. A rename, a reshuffle of split_files/, or a takedown turns every CPU FLUX / Qwen-Image / Z-Image / klein load into a 404, and the Wan pick into a dead one-click download. Two of the six carry no licence metadata at all, one of those has no model card at all, and a third names the wrong licence.

All six now have byte-identical unsloth/* mirrors, and this change points the family tables at them.

What moved

Was Now Files Size
comfyanonymous/flux_text_encoders unsloth/flux-text-encoders clip_l.safetensors, t5xxl_fp16.safetensors 9.34 GiB
Comfy-Org/Qwen-Image_ComfyUI unsloth/Qwen-Image-ComfyUI split_files/vae/qwen_image_vae.safetensors 0.24 GiB
Comfy-Org/flux2-dev unsloth/FLUX.2-VAE split_files/vae/flux2-vae.safetensors 0.31 GiB
Comfy-Org/flux2-dev unsloth/FLUX.2-dev-ComfyUI split_files/text_encoders/mistral_3_small_flux2_bf16.safetensors 33.14 GiB
Comfy-Org/z_image_turbo unsloth/Z-Image-Turbo-ComfyUI split_files/vae/ae.safetensors, split_files/text_encoders/qwen_3_4b.safetensors 7.80 GiB
Comfy-Org/vae-text-encorder-for-flux-klein-9b unsloth/FLUX.2-klein-9B-ComfyUI split_files/text_encoders/qwen_3_8b.safetensors 15.26 GiB
QuantStack/Wan2.2-TI2V-5B-GGUF unsloth/Wan2.2-TI2V-5B-GGUF all 13 quants + the companion VAE 42.31 GiB

Only what Studio opens is mirrored, not whole repos, except the Wan GGUF: that one is a gguf_repo, so the picker offers the precision and every quant has to be there. The relative paths are unchanged on purpose, so the diff is an id swap.

Comfy-Org/flux2-dev becomes two repos rather than one, because its two files are not under the same licence. See below.

Licences carried, not assumed

These are repacks of vendor models, so the obligation flows from the original licence, and the repacker's own card is not a reliable guide to it. Every mirror ships the upstream LICENSE plus a NOTICE, and declares the terms on its card.

Three of the labels are not the obvious ones, so here is the reasoning and the evidence.

The FLUX.2 autoencoder is Apache-2.0, so it does not live with the non-commercial conditioner. Black Forest Labs released it separately and say so themselves: "The autoencoder is released under Apache 2.0" (github.com/black-forest-labs/flux2). That matters concretely, because FLUX.2 klein 4B is itself Apache-2.0 and needs this VAE. Bundling it beside the Mistral conditioner would have put a permissive file behind a non-commercial label, so it is unsloth/FLUX.2-VAE on its own and the conditioner keeps the FLUX terms in unsloth/FLUX.2-dev-ComfyUI.

The klein 9B conditioner is stock Qwen3-8B, so it is Apache-2.0 too. It ships inside the non-commercial black-forest-labs/FLUX.2-klein-9B, so non-commercial looks like the safe call. It is not the accurate one: all 399 tensors were compared against Qwen/Qwen3-8B by byte hash of the raw tensor buffer, key for key, and came back BIT-IDENTICAL 399, DIFFERENT 0, with no key present in one file and absent in the other. There is nothing of Black Forest Labs's in the file, and the FLUX licence itself provides at section 9 that third-party components stay subject to their own licensors' terms. Mislabelling Alibaba's Apache-2.0 weights as non-commercial would not have been cautious, just wrong. The card says plainly that klein 9B the model remains non-commercial regardless.

z_image_turbo's ae.safetensors is the FLUX.1 autoencoder, not a Tongyi VAE. The file's own safetensors metadata says modelspec.author = "Black Forest Labs", modelspec.license = "Apache License 2.0". Apache-2.0 section 4(c) says to retain attribution notices, so the NOTICE credits Black Forest Labs rather than the repo it happens to ship in. A byte-identical mirror keeps the metadata block itself intact.

The rest: Apache-2.0 with attribution and a statement of changes for Qwen-Image (VAE), Z-Image's Qwen3-4B conditioner, and Wan2.2 (quantised and .pth converted to .safetensors, so a Derivative Work, stated as such under 4(b)). MIT for CLIP-L and Apache-2.0 for T5-XXL, one per file, both reproduced in full; the NOTICE records that openai/clip-vit-large-patch14 declares no licence at all and that MIT comes from github.com/openai/CLIP, since that is an inference rather than a declaration on the weights.

For the one mirror that stays non-commercial, all three of the FLUX licence's distribution conditions are met, not just the obvious one: the verbatim licence (3(a)), the statement that rights come directly from Black Forest Labs rather than from Unsloth (also 3(a), and easy to miss), the prescribed Attribution Notice verbatim (3(b)), and the statement of modification, since these are Comfy-Org repacks (3(c)(i)). No extra_gated_* key was copied into any mirror.

The one behaviour change

_cached_repo_task tags a cached repo as a pickable image model when it is trusted and its id resolves to a family. Trust means unsloth/*, which a community org never was, so a companion repo could never reach that branch. After the swap they can: unsloth/Z-Image-Turbo-ComfyUI reads as z-image, unsloth/FLUX.2-klein-9B-ComfyUI as flux.2-klein. Left alone that would put five rows in the On Device list for repos holding no denoiser, each one a pick that cannot load.

So sd_cpp_companion_only_repo_ids() computes, from the tables themselves, which ids exist only to hand sd.cpp a VAE or a text encoder, and the listing skips them. Derived rather than hand-listed so a future table edit cannot desync it, and it subtracts every id that is also a base, prequant or training repo: black-forest-labs/FLUX.1-schnell serves the FLUX.1 VAE and is still perfectly loadable.

Everything else is unchanged. Detection still resolves the old ids, so a QuantStack/Wan2.2-TI2V-5B-GGUF already sitting in someone's cache keeps working, and there is a test for it.

Verification

  • Byte identity, per file, both directions: local sha256 of all 22 downloaded files against the source repos' lfs.sha256, then the published mirrors' lfs.sha256 and byte size against the sources'. 22/22 exact, 0 mismatches. Sizes alone would not have caught a re-serialised safetensors.
  • Anonymous reads, in a process with HF_TOKEN and HUGGING_FACE_HUB_TOKEN stripped, implicit token disabled and trust_env off: a raw GET with no Authorization header, an hf_hub_download(token = False), a HEAD on the largest file in each repo, and model_info reporting gated=False, private=False. 28/28 probes clean.
  • Every (repo, path) pair the edited tables will ask the Hub for, resolved anonymously off the tables themselves rather than a transcribed list. All twelve answer 200. The one exception is black-forest-labs/FLUX.1-schnell/ae.safetensors, still 401 for the FLUX.1 VAE: that is the gated vendor base and Studio: fetch the gated diffusion bases from ungated unsloth mirrors #7952's mirror is what fixes it.
  • 1760 diffusion, sd.cpp, video, cached-route, consent-gate and local-format tests pass.

The no-GPU path opens a single-file VAE and text encoder alongside the
transformer, and six of those files came from community repacks rather than
from the vendor: comfyanonymous/flux_text_encoders, three Comfy-Org repos and
QuantStack's Wan2.2 TI2V 5B quants. A rename, a reshuffle of split_files/ or a
takedown there turns every CPU FLUX, Qwen-Image, Z-Image or klein load into a
404 no client can work around, and two of the six publish no licence metadata
at all.

Each now has a byte-identical unsloth mirror, published under the terms the
upstream model sets for redistribution (LICENSE plus the prescribed NOTICE in
every one), so point the family tables at them. Relative paths are unchanged,
so this is an id swap.

One consequence needs handling. The cached-model listing tags a repo as a
pickable image model when it is trusted and its id resolves to a family; trust
means unsloth/*, which a community org never was. After the swap four
companion repos clear that gate and would each add an On Device row for a repo
with no denoiser in it. sd_cpp_companion_only_repo_ids() derives the
companion-only set from the tables and the listing skips it, minus any id that
is also a base: FLUX.1-schnell serves the FLUX.1 VAE and stays loadable.

Detection still resolves the old ids, so a QuantStack copy already in someone's
cache keeps working.
Comfy-Org/flux2-dev holds two files under two licences. The Mistral
conditioner travels under the FLUX Non-Commercial License, but Black Forest
Labs released the FLUX.2 autoencoder separately under Apache-2.0 and say so in
their own repository. Mirroring both into one repo would have labelled the
permissive file non-commercial, which matters because FLUX.2 klein 4B is itself
Apache-2.0 and this is the VAE it loads.

So the VAE gets its own mirror and both FLUX.2 families point at it. The
conditioner stays where it is, still non-commercial.
@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: 0eca8df510

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

vae_force_fp32 = True,
gguf_repo = "QuantStack/Wan2.2-TI2V-5B-GGUF",
# Byte-identical mirror of QuantStack/Wan2.2-TI2V-5B-GGUF (13 quants + companion VAE).
gguf_repo = "unsloth/Wan2.2-TI2V-5B-GGUF",

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 the Wan mirror to the actual video catalog

Changing this field does not move the advertised one-click Wan download: VideoFamily.gguf_repo has no production readers, while studio/frontend/src/features/model-picker/components/model-selector/model-catalog.ts still defines Wan 2.2 TI2V 5B with only the Wan-AI/Wan2.2-TI2V-5B-Diffusers bf16 artifact. Consequently, users selecting Wan from the Video catalog can never be offered or download unsloth/Wan2.2-TI2V-5B-GGUF; the new value is currently exercised only by tests.

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.

Both facts check out, but neither is a defect of this change.

VideoFamily.gguf_repo has no production reader: grepping gguf_repo across studio/backend outside tests returns the dataclass field, the two assignments, and otherwise only unrelated RAG embedding config (core/rag/config.py) and is_gguf_repo_partial. And model-catalog.ts:350 does define Wan 2.2 TI2V 5B with bf16Pipeline("Wan-AI/Wan2.2-TI2V-5B-Diffusers") only.

But that is the state of the field on main, not something introduced here. LTX-2.3 carries gguf_repo = "unsloth/LTX-2.3-GGUF" and is equally unread today. This PR only changed the Wan value from a community repack to the unsloth mirror; it never claimed to wire up a download path.

Wiring the video catalog to offer GGUF artifacts is a real gap and worth its own PR, including verifying the video GGUF load path end to end for Wan. Folding it into a PR about where companion assets are fetched from would mix a sourcing change with a new feature. Leaving this one as noted, not fixed here.

Comment thread studio/backend/routes/models.py Outdated
Comment on lines +3970 to +3971
if repo_id.strip().lower() in sd_cpp_companion_only_repo_ids():
return None

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 Exclude companion repos instead of classifying them as chat

When one of these mirrors is present in the cache, returning None does not skip its row: /api/models/cached-models still appends the repo with task: null, and the model picker treats an absent task as chat-loadable. Thus an sd.cpp companion such as unsloth/Z-Image-Turbo-ComfyUI can move from the Images list into the Chat On Device list, where selecting it attempts to load a VAE/text-encoder-only repository as a chat model. The inventory needs an explicit hidden/unsupported classification or must omit companion rows entirely.

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.

Correct on the mechanism, fixed in 7f5defd. Wrong on the direction, and that matters for what the fix has to be.

task: null is exactly what every unclassified CHAT repo carries, so returning None never dropped the row: it put the companion in the chat On Device list, not the Images one. The move is the other way round from your description. Before this PR Comfy-Org/z_image_turbo failed _is_trusted_diffusion_repo, so it was already a task: null chat row; the guard I had put these mirrors back where they already were rather than newly promoting them to Images.

It is still a bug, and a worse one now that the id reads unsloth/* and looks legitimate to a user.

Omitting the rows outright is the one thing I did not do. These are 0.24 to 42 GiB each, and the cached-models row is how a user sees and deletes them, so hiding them makes tens of GB unreachable. Instead the row stays and carries a flag:

  • CachedModelRepo.companion on both schemas (declared, or response_model drops it before the picker sees it)
  • set in list_cached_models from _is_sd_cpp_companion_repo
  • use-chat-picker-inventory.ts filters !row.companion on cachedModels only

Scoped to the non-GGUF listing deliberately. The companion set contains unsloth/Qwen2.5-VL-7B-Instruct-GGUF, which is a real chat model sd.cpp merely borrows as a text encoder; filtering the GGUF list on this set would take a downloaded model away from someone who fetched it to chat with. That is now stated on the helper's docstring and pinned by test_the_companion_set_never_hides_a_repo_that_is_a_real_chat_model.

test_a_companion_mirror_is_listed_but_flagged_so_no_picker_offers_it fails without the flag.

Comment on lines +117 to +118
("unsloth/flux-text-encoders", "clip_l.safetensors", "clip_l"),
("unsloth/flux-text-encoders", "t5xxl_fp16.safetensors", "t5xxl"),

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 Reuse cached legacy assets before fetching their mirrors

For an existing installation whose transformer and old community companion files are already cached, changing the repo ID makes SdCppDiffusionBackend._fetch_assets look only under the new mirror's HF cache namespace. Because HF cache entries are keyed by repository, an offline load now fails despite having the byte-identical asset locally, while an online load may re-download up to tens of gigabytes. Keep the mirror as the preferred source, but fall back to the corresponding legacy repo when its exact file is already cached so upgrades do not invalidate previously working no-GPU setups.

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, and the sharpest item of the three. Fixed in 75a44a6.

The HF cache is keyed by repo id, so an install that already pulled the repack has the byte-identical file filed under the OLD key. Repointing the table alone leaves the mirror namespace empty: an online upgrade re-downloads up to 42 GiB (the Wan quants) and an offline load fails outright over bytes sitting on disk.

Implemented as you suggested, mirror preferred and repack as the fallback:

  • _SD_CPP_LEGACY_SOURCES maps each mirror to the repack it came from
  • prefer_cached_legacy_source(repo_id, files) returns the repack only when it already satisfies THIS load's exact file list, reusing _upstream_is_cached so an interrupted or partial repack does not win (.incomplete files have no snapshot symlink, and only the revision refs/main names counts)
  • chained after the gated swap inside _fetch_repo_map, so the staging plan and the fetch take the same decision. Both swaps are pure, no network

Also extended _with_mirrors, which the delete-cached guard uses: which of the pair holds the bytes is re-decided per load, so a guard naming only the mirror could delete the copy the next load needs.

test_a_cached_community_repack_is_reused_instead_of_re_downloading_the_mirror covers both directions (cached repack wins, fresh install still gets the mirror), plus test_the_delete_guard_names_the_repack_as_well_as_the_mirror.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 0eca8df510

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

_cached_repo_task returning None does not omit the row: task null is exactly
what an unclassified chat repo carries, so a denoiser-less companion mirror
landed in the chat On Device list as a load that cannot succeed. Dropping the
row instead would hide tens of GB the user could then never find or delete, so
the row stays and carries a companion flag the chat picker filters on.

The set includes unsloth/Qwen2.5-VL-7B-Instruct-GGUF, which is a real chat model
sd.cpp only borrows as a text encoder. It is safe today only because this
listing never sees a GGUF-only repo; documented and pinned with a test.
The HF cache is keyed by repo id, so an install that already holds the byte
identical repack has it filed under the OLD id. Repointing the tables alone
would leave the mirror namespace empty, re-download up to tens of GB on upgrade,
and fail an offline load over bytes already on disk. The mirror stays preferred
for a fresh install; the swap only fires when the repack already satisfies the
exact files this load wants, using the same probe the gated swap uses.

The delete-cached guard names the repack too, since which of the pair holds the
bytes is re-decided per load.
@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: df531412c6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

// An sd.cpp companion mirror holds a VAE / text encoders and no denoiser. It has no
// task, and a task of null is what every unclassified CHAT repo carries, so without
// this it lands in the chat On Device list as a load that cannot succeed.
!row.companion &&

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 Propagate companion rows through the Hub inventory

When the picker is backed by useHubInventory, this filter only works if /api/hub/cached-models supplies companion, but that path calls listCachedModels() in hub/inventory/api.ts and the backend hub inventory row in hub/services/models/cache_inventory.py still emits task, partial, and single_file without the new flag. Fresh evidence versus the earlier thread is that the legacy /api/models/cached-models route was updated, while the primary Hub inventory endpoint used here was not, so a cached unsloth/Z-Image-Turbo-ComfyUI-style companion still arrives with row.companion === false and remains chat-loadable.

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 about the endpoint, and my fix was on the wrong one. Fixed in 924f3be. Wrong about the consequence, and the reason is worth recording.

The endpoint half is correct. Nothing in the frontend calls /api/models/cached-models at all: grep for it across studio/frontend/src returns zero hits, while /api/hub/cached-models has two. So the flag was on a route with no consumer. cache_inventory.py now sets companion on the row it builds, next to single_file -- whose own comment three lines above says the identical thing happened to it ("the picker's single_file gate sees undefined on every hub-sourced row").

The consequence half does not hold today. The published mirrors are ComfyUI-style: weights under split_files/ and no config.json or model_index.json. _repo_non_gguf_model_payload classifies that as unknown:

vae only (real mirror shape)   format=unknown      runnable=False
chat-model shape               format=safetensors  runnable=True

has_runnable_weights=False makes _scan_cached_models continue before any row is built, so there is no row to be chat-loadable. The flag is a latch against that classifier learning to admit these, not a live fix, and test_the_real_companion_shape_never_reaches_a_row_at_all pins the current behaviour so the day it changes is visible.

One thing I found while fixing it: importing the classifier from routes.models returned False under pytest, so the first attempt failed its own test. It now imports sd_cpp_companion_only_repo_ids from diffusion_families directly, which is the right direction anyway. Worth noting _cached_row_task still has the routes.models import and is monkeypatched in every test, so its fail-open path is untested.

175 hub tests and 287 backend tests pass.

The chat picker is backed by /api/hub/cached-models, not the legacy
/api/models one, so the flag set only on the legacy route arrived as undefined
where the filter reads it. Same trap single_file fell into, and the comment
recording that is three lines above where this now sits.

The classifier is imported from diffusion_families rather than routes.models: a
hub service reaching into a route is backwards, and that import is exactly what
made the first attempt return False under pytest.
@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: 3be7261320

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

),
# Listed so tens of GB of companion weights stay visible and deletable, but
# flagged so no picker offers a denoiser-less repo as a load.
"companion": _cached_row_companion(repo_id),

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 Mark companion rows non-chattable

When this endpoint emits a companion row, setting only companion hides it from the picker filter added in useChatPickerInventory, but it does not protect other chat load paths: startup auto-load calls listCachedModels() and isChattableCachedRepo() accepts any non-partial row unless capabilities.can_chat is false. Since _cache_inventory_fields() still derives can_chat=true for runnable safetensors/checkpoint rows, the config.json companion shape added in the new hub test can be auto-loaded as a chat model even though it contains only VAE/text-encoder weights; mark companion rows non-chattable in capabilities or teach auto-load to skip the flag too.

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.

Correct, and the better of the two fixes you offered. Done in 44652cb.

Verified the path: autoLoadSmallestModel calls listCachedModels() and filters with

function isChattableCachedRepo(repo) {
  return repo.partial !== true && repo.capabilities?.can_chat !== false;
}

which reads capabilities.can_chat and nothing else. The row flag never reaches it, so a companion that got as far as the listing was auto-loadable.

Went with clearing can_chat rather than teaching auto-load about the flag, for two reasons: a VAE / text-encoder mirror genuinely cannot chat whatever its weight format says, so this is the true statement rather than a filter; and it protects every consumer that reads capabilities, not just the one path we happened to find. Set inside _cache_inventory_fields, whose own docstring calls it "the SOLE producer of a row's capabilities: add new flags here rather than patching them on afterwards", beside the existing hidden_infra rule.

The hub test now asserts capabilities.can_chat is False on the companion row and is True on the ordinary one, and fails without the change.

Still true that the published mirrors never reach a row at all (model_format == unknown, pinned in test_the_real_companion_shape_never_reaches_a_row_at_all), so this closes the same latent gap one layer deeper rather than a live bug. 175 hub tests and 129 route tests pass.

The row flag only reaches the picker filter. Startup auto-load goes through
isChattableCachedRepo, which reads capabilities.can_chat and nothing else, so a
companion that reached the listing was still auto-loadable as a chat model.

Set in _cache_inventory_fields, which its own docstring calls the sole producer
of a row's capabilities, rather than patched on afterwards. A VAE / text-encoder
mirror holds no language model, so this is true regardless of weight format.
@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. What shall we delve into next?

Reviewed commit: 44652cb884

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

#7870 landed a plan-entry assertion naming Comfy-Org/z_image_turbo. This PR
repoints that table at unsloth/Z-Image-Turbo-ComfyUI, and no legacy copy is
cached in the test, so prefer_cached_legacy_source keeps the mirror.

@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: 079c977f62

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

legacy = _SD_CPP_LEGACY_SOURCES.get((repo_id or "").strip().lower())
if not legacy:
return repo_id
return legacy if _upstream_is_cached(legacy, files) else repo_id

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 Search the fallback cache before selecting the mirror

When a user changes Studio's cache folder after downloading a legacy community repack, _upstream_is_cached() searches only the current live root, so this returns the mirror even though the required legacy files remain in huggingface_hub's import-time cache root. _fetch_assets() deliberately supports that second root via reuse_other_cache_root=True, but it cannot reuse those bytes after the repository ID has been changed to the mirror; an online load therefore re-downloads several GB and an offline load fails. Check both cache roots before deciding that the legacy source is unavailable.

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.

Correct, fixed in e55c0d6. _upstream_is_cached now takes an opt-in other_root and prefer_cached_legacy_source passes it, so the probe also reads huggingface_hub.constants.HF_HUB_CACHE (exactly what cache_dir = None resolves to in file_download, which is the root reuse_other_cache_root falls back to). It stays OFF for prefer_ungated_mirror: from_pretrained is pinned to the live root and cannot see the other one, so counting those bytes there would hand a gated base back the 401 the mirror exists to remove. Regression test test_a_repack_left_in_the_pre_change_cache_root_still_wins_over_the_mirror in tests/test_sd_cpp_backend.py, confirmed failing without the change.

// An sd.cpp companion mirror holds a VAE / text encoders and no denoiser. It has no
// task, and a task of null is what every unclassified CHAT repo carries, so without
// this it lands in the chat On Device list as a load that cannot succeed.
!row.companion &&

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 Exclude companion mirrors from Hub search results

When one of these file-only mirrors is returned without an unsupported pipeline or library tag, this guard protects only cached inventory rows; the same picker separately searches all unsloth/* repositories through useHubModelSearch, where classifyUnslothSupport() treats a taskless companion as chat-supported and no companion flag exists. The newly created mirrors can therefore still be selected from the Unsloth Hub results and handed to the chat loader despite containing only a VAE or text encoder. Because this filter also removes them from cachedModels, downloadedSet does not suppress an already-cached companion from those search results either; exclude the companion IDs from the Hub-result path as well.

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.

The gap is real: the picker's Unsloth Hub search is a separate path, and the mirrors carry no pipeline tag, so classifyUnslothSupport read them as chat-supported. Fixed in e55c0d6, but not by excluding the companion ids. That set deliberately contains unsloth/Qwen2.5-VL-7B-Instruct-GGUF, which sd.cpp borrows as Qwen-Image's text encoder and which is a perfectly good chat model; filtering the Hub results on it would take a real model away from someone who downloaded it to chat with (the set's own docstring says so). Instead diffusion-single-file joins UNSUPPORTED_LIBRARY_TAGS. Every mirror publishes library_name: diffusion-single-file with no pipeline tag, and the library check runs after the pipeline check, so a real single-file checkpoint (FLUX.2-klein-9B-GGUF, image-to-image) keeps its Images routing while a taskless companion becomes unsupported. Covers future mirrors too, and needs no id list on the frontend. Tests in studio/frontend/tests/unsloth-support-companion-mirror.test.ts, confirmed failing without the change. On the second point: downloadedSet only exempts a row from the fit filter and drives the downloaded badge, so dropping companions from it hides them further rather than surfacing them.

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.

One precision on the above, after re-checking the live metadata for all six companion-only mirrors: four of them (unsloth/flux-text-encoders, unsloth/FLUX.2-VAE, unsloth/FLUX.2-dev-ComfyUI, unsloth/FLUX.2-klein-9B-ComfyUI) already classified as unsupported at head, because they carry the flux tag and flux is in UNSUPPORTED_LIBRARY_TAGS. Only unsloth/Qwen-Image-ComfyUI and unsloth/Z-Image-Turbo-ComfyUI actually leaked into the picker: no pipeline tag and no flux tag. The library rule now covers all six on the same footing, so a future mirror is not left depending on a name coincidence.

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

ℹ️ 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 abe009b into main Aug 6, 2026
50 checks passed
@danielhanchen
danielhanchen deleted the diffusion-thirdparty-mirrors branch August 6, 2026 10:30
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