Skip to content

Studio: keep enhancing prompts from an already downloaded FLUX.3 upsampler quant - #14836

Merged
danielhanchen merged 8 commits into
mainfrom
studio-flux3-upsampler-cached-quant
Oct 25, 2026
Merged

danielhanchen merged 8 commits into
mainfrom
studio-flux3-upsampler-cached-quant

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Summary

#14177 made flux-3-image-klein-pup-UD-Q4_K_XL.gguf the default prompt upsampler file. #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 #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

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).

…uant

After the UD-Q4_K_XL default, an install holding only the earlier Q4_K_M
file had no upsampler until another 5.97 GB downloaded (never, offline).
A run now reads the default when cached, else another listed quant already
downloaded; the download still fetches the default.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 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-25T05:27:34.027415Z 4b71a3f 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 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: 381091172a

ℹ️ 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 +751 to +752
if model_only is not None:
return model_only, 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.

P1 Badge Prefer a complete fallback pair over a model-only default

When the preferred GGUF is cached without its projector—for example, after an interrupted default-quant download—but an older quant and its projector are both cached, this early return prevents checking that complete fallback pair. mmproj_path() then returns None, and upsample() silently enhances image-edit requests without their reference images despite having a usable model/projector pair; defer the model-only return until all candidate model files have been searched for a complete pair.

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.

Valid, fixed in 081ded92. _cached_pair now looks for a complete model + projector pair across every listed quant first, and only falls back to a model on its own (still in preference order) when no quant has its projector. So an interrupted default download no longer hides an earlier quant that is cached with its projector, and edits keep their reference images. When no complete pair exists anywhere, the default model alone still wins over an earlier model alone, so text-only enhancing still uses the better quant. Both cases are tested.

# An override that does not exist is a typo, not a reason to read the cache instead.
return _env_path(ENV_MODEL_OVERRIDE)
return _cached_pair()[0]
return _cached_pair(model_files = UPSAMPLER_RUN_FILES)[0]

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 Keep fallback readiness separate from download completion

On an upgraded install containing the former Q4_K_M model and projector, this makes model_path() non-null, so status() reports both downloaded and mmproj_downloaded as true. The frontend predicate in studio/frontend/src/features/images/lib/prompt-enhance.ts:101-102 therefore hides the only download control, leaving users no UI path to fetch the new UD-Q4_K_XL default even though _cached_download_paths() correctly considers it absent; report fallback run availability separately from whether the current default is downloaded.

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.

Valid, fixed in 081ded92. downloaded / mmproj_downloaded still describe what a run can use, so Preview and enhancing keep working from the earlier quant. The status body now also reports current_downloaded (the same check the download state uses for completion) and current_missing_bytes. The frontend keeps the Download control offered while current_downloaded is false, sizes it from current_missing_bytes, and the notice says an earlier quant is in use. An older backend without the field reads as fully downloaded, so nothing changes there.

danielhanchen added a commit that referenced this pull request Oct 23, 2026
… in #14822 (#14852)

pre-commit.ci fails `ruff-format-with-kwargs` again on PRs queued after
00:36 UTC (#14834, #14835, #14836, #14842, #14845):
`studio/backend/tests/test_video_stream_encode.py` was merged in #14822
without the formatter, so every PR's all-files run rewrites it.

Same class as #14817. `python scripts/run_ruff_format.py` (the hook's
entry point, `ruff==0.6.9`) applied to that one file. The AST is
identical before and after, `ruff check` passes, and a full run of the
hook over every tracked Python file on this branch changes nothing else.
…efault

A default GGUF cached without its projector (interrupted download) no
longer hides an earlier quant cached with its projector: a complete pair of
any listed quant now beats a model alone, so edits keep their reference
images.

The status body now reports the current default's download state apart
from what can run (current_downloaded, current_missing_bytes), so an
install still serving the earlier Q4_K_M keeps the Download control and
sees why, instead of the control vanishing with no path to the new default.

[skip ci]
@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: 081ded914a

ℹ️ 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 +121 to +122
export function upsamplerServesEarlierQuant(status: PromptUpsamplerStatus): boolean {
return status.downloaded && status.mmproj_downloaded && !status.current_downloaded;

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 Treat a model-only fallback as an earlier quant

When an upgraded cache contains an older quant but no projector, enhancement still uses that older model for text-only prompts, yet this predicate returns false because mmproj_downloaded is false. The notice consequently claims that only the projector is missing and upsamplerDownloadBytes() reports roughly 918 MB, although the download route fetches the missing current-default model as well (roughly another 5.97 GB); use the backend's current_missing_bytes whenever a non-current fallback model is serving, even if its projector is absent.

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.

Valid. With an earlier quant cached and no projector, the download route still fetches the current default model plus the projector, but the predicate required mmproj_downloaded, so the panel called it a projector-only download and sized it at the projector. upsamplerServesEarlierQuant now also returns true when the serving model is not the current default file (filename differs from the status' current_filename, now parsed), so upsamplerDownloadBytes uses current_missing_bytes. The current default with only its projector missing stays the projector-only case, and so does a status without current_filename. The notice also says edits run from the text alone in that state. Frontend tests cover the model-only fallback, and a backend test pins the status it reads (earlier filename, current_missing_bytes = default model + projector).

main landed #14842, which also runs from a cached earlier upsampler quant
(UPSAMPLER_MODEL_FILE_PREFERENCE: UD-Q4_K_XL, then Q8_0, then Q4_K_M) and
lets the unpinned _cached_download_paths count any cached quant.

Conflicts in studio/backend/core/inference/flux3_prompt_upsampler.py:
- Run order: took main's UPSAMPLER_CACHED_FALLBACK_QUANTS /
  UPSAMPLER_MODEL_FILE_PREFERENCE (Q8_0 before Q4_K_M) and dropped this
  branch's UPSAMPLER_RUN_FILES (dict order, Q4_K_M before Q8_0).
- _cached_pair: kept this branch's model_files parameter, now defaulting
  to UPSAMPLER_MODEL_FILE_PREFERENCE, so model_path / mmproj_path /
  unpinned _cached_download_paths behave as on main.
- status(): kept main's size_bytes fallback chain and this branch's
  current_filename / current_downloaded / current_missing_bytes. Since
  main's unpinned _cached_download_paths is now satisfied by an earlier
  quant, current_downloaded reads _cached_pair(model_files=(default,))
  instead, so the Download control stays offered while an earlier quant
  serves.

Conflicts in studio/backend/tests/test_flux3_prompt_upsampler.py: kept
both test sets. This branch's "only Q4_K_M cached" test now asserts
current_downloaded is False and a pinned check at that revision is None,
instead of an unpinned _cached_download_paths None (main asserts it
returns the earlier pair). Main's matching test also asserts
current_downloaded is False, replacing its "UI offers no download"
comment.

[skip ci]
@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. Nice work!

Reviewed commit: 5e7b711909

ℹ️ 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. Keep them coming!

Reviewed commit: 9d8c794b31

ℹ️ 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 self-assigned this Oct 25, 2026
@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. 👍

Reviewed commit: 4b71a3f5d2

ℹ️ 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 25, 2026
@danielhanchen
danielhanchen merged commit 3af50bd into main Oct 25, 2026
46 of 55 checks passed
@danielhanchen
danielhanchen deleted the studio-flux3-upsampler-cached-quant branch October 25, 2026 07:24
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.

1 participant