Skip to content

Studio: match hosted prequant files on the full base repo id, and stop retrying a failed portable VAE fold - #19012

Merged
danielhanchen merged 2 commits into
mainfrom
studio-recheck-nov23-prequant
Nov 23, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
studio-recheck-nov23-prequant

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Two small follow-ups on main for the diffusion stack.

1. A fine-tune named like the official repo no longer loads the official prequantised weights

_same_base_model (studio/backend/core/inference/diffusion_prequant.py) accepted any two ids whose last path segment matched. So someone/Qwen-Image-2.1 counted as Qwen/Qwen-Image-2.1, and every hosted prequant reader that runs this check (the torchao prequant loader, the text encoder prequant check, the converted single-file check and the fp8 training seed) could load the official prequantised DiT in place of the fine-tune's own weights.

Now:

  • Both sides are still normalised through canonical_base (the unsloth/* mirrors), and the retired full copies (unsloth/flux-3-image-klein[-base]) map to their upstream too.
  • The compare is case-insensitive on the full id.
  • Two Hub repo ids must name the same repo. A different owner with the same repo name is refused, so the loader falls back to quantising the fine-tune's own dense weights.
  • A local path (/models/Qwen-Image-2.1, C:\models\Qwen-Image-2.1, or a relative directory that exists) still uses the name compare as before. family_prequant_repo depends on that for a local copy of the base, and so does its test.

Every base_model_id value I could find in the hosted files was checked against its official id, every case spelling, its declared mirror and its retired copy. These are the ids in the unsloth_metadata header of each root .safetensors in every unsloth/* repo Studio names, read from the live Hub headers. All of them still match. The new test lists them, along with every pair in _ALL_MIRROR_PAIRS and _RETIRED_FULL_COPIES.

2. A failed upsample fold on the portable VAE path is not retried on every decode

On the portable whole-map decode (no fused kernels: ROCm, MPS, CPU, or CUDA when the kernels are not usable), a non-OOM failure with the upsample fold engaged was re-raised to the tiles without marking the decoder. Every later decode tried the fold again before it fell back.

Now full_map_decode marks the decoder (_unsloth_vae_fold_failed) when a portable run fails while the fold is engaged. It then retries that decode once with the fold off, and later decodes skip the fold. This is the same pattern the kernels path already uses with _unsloth_vae_strips_failed. Since #18995, that strips mark also turns the fold off. Now both marks feed the same fold switch and every retry runs with the fold off, so the decoder has one fold-off path, not two. Other behaviour does not change:

Tests

  • tests/test_diffusion_prequant_same_base.py (new, 85 cases): on main, 7 fail (the same-name fine-tune cases and the text encoder / fp8 training readers). With the fix, all 85 pass. The 78 positive cases pass on both.
  • tests/test_diffusion_vae_fold_failure.py (new, 3 cases): on main, the fold-failure case fails because the decode raises and the fold is tried on every call. With the fix, all 3 pass. The OOM case and the failure-outside-the-fold case pass on both.
  • tests/test_video_h3_te_quant.py::test_the_index_compare_has_no_tail_name_tolerance: its precondition asserted that te_base_equivalent accepts someone/MiniMax-H3, which was the hole being closed. It now asserts that the Hub fine-tune is refused and that a local path is still tolerated.
  • Wider runs on CPU:
    • The 146 test files that touch the prequant / TE prequant / converted single-file / fp8 training / prequant cache / native cache paths: 6834 passed, 268 skipped, 25 failed, 4 errors. Only the H3 test above differed from main. The other 24 failures and 4 errors also fail on main, with the same test IDs, so they predate this change on this host. The ones inspected are host environment issues: the installed huggingface_hub lacks get_cached_repo_tree, and diffusers 0.40 is older than some families need.
    • The 14 test files that touch the VAE strips / tiling / whole-map decode: 3245 passed, 49 skipped, 2 xfailed, 4 failed. All 4 fail the same way on main, for the same get_cached_repo_tree import reason.

Not covered here

  • No GPU run. The fold change was checked on CPU with a tiny AutoencoderKL and an injected failure. A real ROCm or MPS fold failure was not reproduced.
  • The prequant cache key (base_identity) still uses the repo name, so it is coarser than the new compare. Two bases share a key only when their dense source bytes are also identical, so the cached weights are the same either way. The key is left unchanged so existing local caches stay valid.

…quant checks

_same_base_model matched on the repo name alone, so someone/Qwen-Image-2.1
counted as Qwen/Qwen-Image-2.1 and every hosted prequant reader could load the
official prequantised weights instead of the fine-tune's own. Two Hub ids now
have to be the same repo (case-insensitive, after folding the unsloth mirrors
and the retired full copies onto their upstream). A local path keeps the name
compare, as family_prequant_repo expects for a local copy of the base.
…s not retried every decode

On the portable path (no fused kernels) a non-OOM failure with the fold
engaged was raised to the tiles without marking the decoder, so every later
decode tried the fold again first. Mark the decoder, retry this decode once
without the fold, and skip it from then on, as the kernels path already does
after a strip failure. OOM and failures outside the fold still go to the tiles.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T06:13:38.671940Z 454cdbb 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 454cdbbba8

ℹ️ 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 1763431 into main Nov 23, 2026
@danielhanchen
danielhanchen deleted the studio-recheck-nov23-prequant branch November 23, 2026 07:35
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