Skip to content

Studio: download the UD-Q4_K_XL FLUX.3 prompt upsampler by default - #14177

Merged
danielhanchen merged 1 commit into
mainfrom
studio-flux3-pup-ud-default
Oct 19, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
studio-flux3-pup-ud-default

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Enhance prompt (the FLUX.3 prompt upsampler) now downloads flux-3-image-klein-pup-UD-Q4_K_XL.gguf by default instead of flux-3-image-klein-pup-Q4_K_M.gguf, both from unsloth/flux-3-image-klein-pup-GGUF. The repo's Q4_K_M and Q6_K were also rebuilt with an importance matrix, so the expected Q4_K_M size is updated too.

File Size Mean KL divergence vs BF16 on the upsampler's own captions
Q4_K_M, previous (no imatrix) 5.63 GB 0.0500
Q4_K_M, imatrix 5.63 GB 0.0194
UD-Q4_K_XL, imatrix 5.97 GB 0.0119

That measurement uses 96 held-out requests with the t2i system prompt, scored on assistant tokens only. UD-Q4_K_XL is also better on wikitext-2 and on held-out code, Chinese, math and general chat. With greedy decoding its captions first diverge from BF16 at a median of word 49, against word 20 for both Q4_K_M files.

Speed (llama-bench, median t/s):

  • B200: prompt processing +3.9% and generation +0.9% against Q4_K_M.
  • CPU (16 pinned cores on a shared host): 142 vs 126 t/s prompt processing and 13.0 vs 13.7 t/s generation, both within the run-to-run spread.

Existing installs that already have the Q4_K_M file will see the download notice once for the new default; until it is downloaded, Enhance prompt falls back to the prompt as typed, as it does for any missing upsampler.

Testing

  • tests/test_flux3_prompt_upsampler.py, tests/test_training_vram_coexistence.py, tests/test_gpu_arbiter.py: 220 passed.
  • End to end on this branch, logged out, empty HF cache: Studio's own downloader fetched the UD-Q4_K_XL file and the projector from the Hub (45 s), and the preview route returned full English and Spanish captions from it.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 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-19T02:21:53.763598Z 915df55 Manual request
🔒 Security Review ⚠️ Failed 2026-10-19T02:20:21.993720Z 915df55 PR opened
ℹ️ 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

Copy link
Copy Markdown

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

Reviewed commit: 915df55fe8

ℹ️ 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 8675c63 into main Oct 19, 2026
@danielhanchen
danielhanchen deleted the studio-flux3-pup-ud-default branch October 19, 2026 03:04
danielhanchen added a commit that referenced this pull request Oct 23, 2026
…is missing (#14842)

## Problem

#14177 changed the FLUX.3 prompt upsampler default quant to
`UD-Q4_K_XL`. `_cached_pair()`, `_cached_download_paths()` and
`model_path()` only looked up `UPSAMPLER_MODEL_FILE`, the new default.
An install that had already downloaded the previous default
`flux-3-image-klein-pup-Q4_K_M.gguf` (or the `Q8_0` file) therefore
reported the upsampler as not downloaded, and Enhance prompt stopped
working until the new ~6 GB file was fetched. The cached older quant was
never used.

## Fix

- New `UPSAMPLER_MODEL_FILE_PREFERENCE`: the default `UD-Q4_K_XL` first,
then `Q8_0` (higher quality), then `Q4_K_M`.
- `_cached_pair()` walks that order and, for each file, the candidate
revisions (recorded one first). It still pairs a model with the
projector at the same revision, and still falls back to a model with no
projector only when no revision holds both. A complete pair of a
fallback quant wins over the default with no projector, as it did before
across revisions.
- `model_path()`, `mmproj_path()`, `status()` and the unpinned
`_cached_download_paths()` all go through `_cached_pair()`, so the
status route (`downloaded` / `mmproj_downloaded`), the frontend download
prompt and the Enhance gates in the generate route agree: a user with
the old file sees Enhance as ready.
- `status()` now reports the filename and on-disk size of the file in
use, not the default name beside an older file.
- Unchanged: the download spec still fetches `UD-Q4_K_XL` +
`mmproj-F16.gguf`, so a fresh install gets the new default. The
completion check for a pinned download still requires the default at
that revision. The `UNSLOTH_FLUX3_UPSAMPLER_GGUF` / `_MMPROJ` overrides
behave as before, including a missing override path never falling back
to the cache.

## Tests

New tests in `studio/backend/tests/test_flux3_prompt_upsampler.py` build
a real Hugging Face cache layout under `tmp_path` (no downloads):

- only `Q4_K_M` + projector cached: `model_path()` returns `Q4_K_M` and
`status()` reports ready
- default and fallbacks cached: the default wins
- `Q8_0` is preferred over `Q4_K_M`
- a fallback quant pairs with the projector at its own revision
- a pinned download's completion check still wants the default
- nothing cached: not ready, and the download targets `UD-Q4_K_XL`
- the env override still beats a cached quant

| | main | this branch |
|---|---|---|
| `tests/test_flux3_prompt_upsampler.py` | 3 failed, 205 passed | 208
passed |

The three failures on main are the `Q4_K_M` only, `Q8_0` preference and
fallback pairing tests. `test_diffusion_flux3.py`,
`test_orchestrator_unload_cancel.py` and `test_gpu_selection.py` also
pass.

## Not covered

- A user with only an older quant and no projector still downloads the
default plus the projector when they ask for the projector, and the
frontend size estimate for that case counts only the projector.
- No change to the frontend; no live Studio run with a real cached
quant.
danielhanchen added a commit to Imagineer99/unsloth that referenced this pull request Oct 25, 2026
…mpler quant (unslothai#14836)

## Summary

unslothai#14177 made `flux-3-image-klein-pup-UD-Q4_K_XL.gguf` the default prompt
upsampler file. unslothai#14842 (merged) lets an install that still holds the
earlier default, `flux-3-image-klein-pup-Q4_K_M.gguf`, keep enhancing
from it. But that install then reads as fully downloaded, so the Images
panel never offers the new default, which scores about 39% lower mean KL
divergence for 6% more bytes.

This change, on top of unslothai#14842:

- `status()` reports `current_filename`, `current_downloaded` (the
default pair at one revision) and `current_missing_bytes` (only blobs
not already cached at any revision), apart from `downloaded` /
`mmproj_downloaded`, which still mean "can run".
- The Enhance prompt panel keeps the Download control offered while an
earlier quant serves, says which file is in use, and sizes the button at
what the download actually fetches. A model-only earlier quant is sized
at the default model plus projector, not the projector alone.
- A complete `Q8_0` pair is not offered the smaller default: Q8_0 is
closer to BF16, so "for better captions" would be wrong there.
- An older backend without the new fields reads as before
(`current_downloaded` falls back to `downloaded && mmproj_downloaded`).
- Unchanged: what a run reads (`model_path()` / `mmproj_path()`), the
download spec (UD-Q4_K_XL + `mmproj-F16.gguf`), the env overrides, and a
fresh install.

## Testing

- `studio/backend/tests/test_flux3_prompt_upsampler.py`: 223 passed.
Base vs head differential: 5 tests fixed, 217 unchanged, 0 failing on
head. New tests cover: an install with only Q4_K_M keeps enhancing
offline and is still offered the default; the default wins once
downloaded; a complete earlier pair beats a default model with no
projector; a model-only earlier quant is priced at the whole default
download; a Q8_0 pair is not offered the download (fails without the
guard).
- `studio/frontend/tests/image-prompt-enhance.test.ts`: 12 passed.
- `status()` on an install serving Q4_K_M: about 2.0 ms per call vs 1.5
ms on main (the status route, not the generation path).

## Screenshots

Two isolated Studio installs (merge base vs this branch), both on one HF
cache holding only the Q4_K_M upsampler and projector. The upsampler
status comes from each backend; the image model status is set to a
loaded FLUX.3 klein model in the browser so the panel renders without
image weights.

![Enhance prompt panel before and
after](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/14836/pr14836_before_after-85a7e6646022.png)

Before: the Q4_K_M install shows no download, so it never gets the
better default. After: the panel names the earlier quant in use and
offers Download (6.0 GB).

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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