Repository navigation
Studio: load the retired FLUX.3 full copies through their base - #14173
Conversation
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e1b4a810d5
ℹ️ 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".
| const { filename: _filename, textEncoderFiles: _te, vaeFile: _vae, ...rest } = pick as T & { | ||
| textEncoderFiles?: unknown; | ||
| vaeFile?: unknown; | ||
| }; | ||
| return { ...rest, repoId: base, kind: "pipeline" } as T; |
There was a problem hiding this comment.
Preserve component overrides when redirecting the root file
When a user selects model.safetensors from either retired repo together with an Advanced text-encoder or VAE override, this branch unconditionally converts the pick to a pipeline and discards those component fields. The normal load path invokes this helper before reading the Advanced fields, after which componentFileFields() receives kind: "pipeline" and omits them from the request; recalled models lose the stored fields here as well. The backend deliberately redirects this root file only when both component overrides are absent, so the frontend should make the same check instead of silently loading the default components and producing results from a different configuration.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in debeff7. The frontend now applies the same rule as the backend: the root model.safetensors pick is redirected only when no text-encoder or VAE file is supplied. handleLoad runs the redirect after the Advanced component files are read, and a recalled model keeps its stored files, so a pick with its own components stays on the copy in both places.
| export function redirectRetiredImagePick< | ||
| T extends { repoId: string; kind: RememberedImageModel["kind"]; filename?: string }, | ||
| >(pick: T): T { | ||
| const base = RETIRED_FULL_COPIES[pick.repoId.trim().toLowerCase()]; |
There was a problem hiding this comment.
Redirect downloaded snapshots by their display repository
When either retired repository is already downloaded, the Hub picker supplies its validated snapshot path as repoId and the logical retired ID as displayRepoId. This lookup examines only repoId, so handleLoad sends the local snapshot path; the backend likewise only redirects exact repository IDs and therefore loads the retired 43 GB copy instead of the base/mirror. The preceding download plan uses displayRepoId and is redirected, so it can even stage the intended FP8 assets before the actual load ignores them. Account for displayRepoId when canonicalizing these cached picks.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in debeff7. A downloaded copy (snapshot path with the retired id as displayRepoId / display_repo_id) is now redirected on both sides: the frontend helper also reads the display id, and DiffusionLoadRequest maps display_repo_id the same way it maps model_path, so the load names the base and fetches from the -FP8 repo like the download plan does.
| if not single: | ||
| self.model_path = base |
There was a problem hiding this comment.
Canonicalize auto-switch locality and identity with the load
For API auto-switch requests naming a downloaded retired copy, locality is checked against the original local snapshot before this validator rewrites the eventual load to the BFL base. If the new FP8 mirror is not cached, auto-switch incorrectly approves the request and the cache-only load then fails; if it is cached and loads successfully, _await_loaded() still compares the base-valued status against the original retired MediaModelPick and reports that another load replaced it. Normalize the auto-switch pick before both locality checking and resident matching so these IDs do not produce a 503 after initiating a load.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in debeff7. The auto-switch now swaps a resolved retired copy for the base pick (_retired_copy_as_base) right after resolution, before the edit-only check, the locality check and the resident match. Locality is planned for the base load (refused with 409 when the -FP8 files are not cached), the load is started for the base, and the base-valued status satisfies the request afterwards. Covered by test_a_downloaded_retired_flux3_copy_switches_to_the_base_it_copies, which fails without the change.
… keep picks with their own components on the copy
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: debeff7f46
ℹ️ 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".
| return redirectRetiredImagePick({ | ||
| repoId: value.repoId, | ||
| kind: value.kind, |
There was a problem hiding this comment.
Migrate remembered snapshot paths for retired copies
When upgrading with a previously remembered downloaded retired pipeline, repoId is already the local snapshot path and no logical ID is available here, because withEngagedFamily() historically stripped displayRepoId before persistence. Consequently this lookup cannot recognize the record, and Generate-with-no-resident reloads the retired snapshot rather than the BFL base. The fresh evidence beyond the fixed live-picker case is that RememberedImageModel never stores displayRepoId, so records written by the parent version cannot take the new display-ID branch; migrate recognizable models--unsloth--flux-3-image-klein[-base]/snapshots/... paths or persist enough identity to canonicalize them.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 56bc3de. The redirect also recognises an HF-cache snapshot of either copy (.../models--unsloth--flux-3-image-klein[-base]/snapshots/<sha>) by its path alone, on both sides: the frontend helper (so a model remembered by an older build as that path is recalled as the base) and retired_full_copy_base on the backend (so an API caller naming the snapshot gets the same load). The -FP8 mirror's snapshots and any other path are left as they are. Covered in both test files.
| repoId = redirected.repoId; | ||
| opts = { kind: redirected.kind, filename: redirected.filename, displayRepoId: redirected.displayRepoId }; |
There was a problem hiding this comment.
Stage the canonical checkpoint for cached retired picks
When a downloaded retired repo is selected, its snapshot path and displayRepoId first pass through diffusionStagingEntries(), which removes every entry marked checkpoint because it assumes the pinned snapshot already contains the selected checkpoint. The redirected backend plan instead marks the canonical base's -FP8 mirror entry as the checkpoint, so that required entry is discarded before this line changes the actual load target to the base. If the mirror is not cached, the subsequent load therefore pulls its multi-GB checkpoint inline rather than through the staged-download progress, cancellation, and disk preflight path; canonicalize the staging identity too, or retain canonical checkpoint entries that differ from the pinned retired snapshot.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 56bc3de. The pick is now redirected at the start of loadOrStage, right after the Advanced component files are read and before the download plan is requested, so the plan, the staging entries (diffusionStagingEntries compares against the base, whose checkpoint entry is the -FP8 mirror's) and the load all name the same target. The per-repo Advanced values are re-read for the redirected id. handleLoad keeps its own redirect for the paths that reach it directly (Reapply, recall).
… base, and recall snapshot paths of them
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 56bc3de997
ℹ️ 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".
| if (redirected.repoId !== repoId) { | ||
| repoId = redirected.repoId; | ||
| opts = { kind: redirected.kind, filename: redirected.filename, displayRepoId: redirected.displayRepoId }; | ||
| advanced = downloadSnapshot ?? currentLoadAdvanced(repoId, familyOverrideRequired); |
There was a problem hiding this comment.
Stage redirected local snapshots before loading
When a user selects a retired repo's HF-cache snapshot through the local picker, redirectRetiredImagePick changes the local path into the remote BFL base here, but source remains "local"; the immediately following non-Hub return therefore skips requestDownloadPlan and loads the base directly. If the canonical -FP8 mirror assets are not cached, this pulls several gigabytes inside the backend load without the staged download's disk preflight, progress, or cancellation. The fresh case not covered by the earlier fixed Hub-picker finding is a direct local selection such as .../models--unsloth--flux-3-image-klein/snapshots/<sha>; a successful redirect should continue through planning rather than retaining local-source behavior.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b765d92. When loadOrStage redirects a pick (a local snapshot of either copy included), it now treats it as a Hub pick, so the base goes through the download plan and the staged download path (disk preflight, progress, cancel) instead of the direct local load.
| if owner == DIFFUSION: | ||
| pick = _retired_copy_as_base(pick) |
There was a problem hiding this comment.
Resolve retired IDs before querying the local index
When auto-switch receives a retired ID after Studio has staged only its canonical base/mirror, resolve_local_media_model(name) returns None and the request exits with model_not_found before this conversion can run. This is a newly reachable state because selecting a retired repo now downloads the base rather than the retired 43 GB copy, so a later /v1/images/generations request that still names unsloth/flux-3-image-klein[-base] cannot reload the very replacement this change installed. Canonicalize the requested name before resolution, or retry resolution with the mapped base, while retaining the original name for response matching.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b765d92. Auto-switch resolution (_resolve_pick) now falls back for a retired copy that is not downloaded itself: it tries the base, then the base's -FP8 mirror, which is what a pick of the copy stages now. The request name is kept for the resident match. Covered by test_a_retired_flux3_copy_name_reloads_the_mirror_that_replaced_it (fails without the change); names with no mapping still answer 404.
…find the mirror that replaced a copy
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b765d92988
ℹ️ 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".
| for candidate in (base, mirror_repo(base)): | ||
| if candidate: | ||
| pick = resolve_local_media_model(candidate, task = task) | ||
| if pick is not None: | ||
| return pick |
There was a problem hiding this comment.
Return a base-identity pick from the mirror fallback
When only the -FP8 mirror is cached—the normal result of staging a retired pick—this fallback returns the mirror's MediaModelPick unchanged. If the frontend has already loaded the redirected BFL base, its status reports the base ID, so satisfied_by(..., name, pick) cannot match either the retired request name or this mirror pick and unnecessarily drains and reloads the same model before changing the published identity to the mirror. Return a pick canonicalized to the mapped base while still letting locality planning use the cached mirror.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in c85ca9c. When the copy itself is not downloaded but its base or the base's -FP8 mirror is, _resolve_pick now returns a pick under the base's identity (black-forest-labs/flux-3-image-klein, pipeline). Locality is planned for the base, which reads the cached mirror, and a base the Images page already loaded answers the copy's name without a drain and reload. The test now checks both the base pick and the no-reload second request.
| elif ( | ||
| single == "model.safetensors" | ||
| and self.text_encoder_file is None | ||
| and self.vae_file is None | ||
| ): |
There was a problem hiding this comment.
Preserve an explicit companion base for root checkpoints
For API load or download-plan requests that select the retired root model.safetensors with an explicit base_repo, this condition still converts the request into a pipeline because it checks only text-encoder and VAE overrides. base_repo is the supported companion pipeline override for single-file loads, but after gguf_filename is cleared and model_kind becomes pipeline, planning and loading use the redirected BFL repo itself and silently ignore the caller's alternate or local companion base, producing a different build. Treat a nonempty explicit base_repo as a customization unless it resolves to the same mapped base.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in c85ca9c. The root model.safetensors redirect now also requires that no other companion base is named: a base_repo that is empty, the base the copy stands for, or the copy itself still redirects; any other base (including a local one) keeps the single-file build on the copy as requested. Covered in test_other_picks_are_left_as_named.
…lve a copy's name to its base identity
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…14835) ## Summary #14173 sends every load of `unsloth/flux-3-image-klein` and `unsloth/flux-3-image-klein-base` to the BFL base they copy, which Studio then fetches from the `-FP8` repo. That includes a snapshot of the copy that is already downloaded. The copies were retired for size (about 43 GB of the gated BFL repo, which the `-FP8` repo now hosts for Studio). Their files are fine: the bf16 transformer, text encoder and VAE are the base's own. So the redirect broke installs that already hold a complete copy: - **Offline**, the base's mirror is not in the cache. The load reads `modular_model_index.json` through `hf_hub_download(local_files_only=True)` and fails with `LocalEntryNotFoundError`, even though the model is on disk. - **Online**, the same bf16 weights are downloaded a second time under the mirror's repo key. This change keeps a copy that is complete on disk loading from disk, and redirects everything else as before: - `retired_copy_loads_from_disk` (`diffusion_families.py`): true for a snapshot path, or the copy's id with its `refs/main` snapshot in the live HF cache, when the folder passes the same FLUX.3 completeness check the load route applies (`local_pipeline_components_are_complete` with `FLUX3_COMPONENT_FOLDERS`). As the companion base of another single file, which supplies the transformer, the copy needs only the transformer config. Local stat only, no network. - `DiffusionLoadRequest` skips the redirect for such a copy (`model_path` and `base_repo`). Its root `model.safetensors` pick loads as the copy's own pipeline (the same weights): in the HF cache that file is a symlink into `blobs/`, which the single-file path check refuses. An incomplete or absent copy, a named id with nothing cached, and every other pick are redirected exactly as in #14173, and a pipeline redirected to the base also redirects a `base_repo` that names the incomplete copy. - Media auto-switch: `_retired_copy_as_base` leaves a complete downloaded copy as its own pick, so the switch neither plans nor waits for the mirror, and the load keeps its snapshot path (by id only the active cache is searched, so a copy in an earlier Models folder would be redirected). An incomplete one is still switched as the base. - Images page: a retired-copy pick (the On Device row's repo id, or a snapshot path) is no longer redirected before the backend sees it. It is planned like a Hub pick: a complete copy plans nothing and loads from disk; an incomplete one is redirected by the backend, so the plan stages the base's files first. Reapply and the remembered model take what the load reported (`retiredSnapshotAsLoaded`), including after a page reload mid-load. Offline, with the copy's real file layout in the cache (real JSON, placeholder weights), a load by its id reads everything from the snapshot; the only Hub call is a non-fatal size lookup. ## Testing - `tests/test_flux3_retired_copy_on_disk.py` (new): a complete snapshot, by path with or without the display id, stays on the snapshot. With `HF_HUB_OFFLINE=1` and every Hub lookup raising `LocalEntryNotFoundError`, the loader reads its manifest from disk with 0 Hub lookups. On main it is redirected and the lookup fails. The root `model.safetensors` pick stays on the snapshot. The copy named by id stays when its cached snapshot is complete. An incomplete snapshot, a root-transformer pick missing its file, and a copy that is not on disk at all are still redirected to the base. 4 of these fail on main and all 7 pass here. - Also in that file: the root pick of a snapshot laid out as the HF cache stores it (symlinks into `blobs/`) passes the route validator, the auto-switch keeps a copy in an earlier Models folder on its snapshot, and a pipeline redirected to the base does not keep an incomplete copy as its `base_repo`. These fail before the fix. - `tests/test_media_auto_switch.py::test_a_complete_downloaded_retired_flux3_copy_switches_to_itself` (new): the switch loads the snapshot without planning the base. On main it is refused with a 409 "not fully downloaded" for the base. The existing incomplete-copy switch test is unchanged and passes. - `studio/frontend/tests/image-retired-full-copies.test.ts`, `image-load-resume.test.ts`: retired-copy picks (id or snapshot) are planned and not redirected up front, and a load that went through the base, or loaded a root pick as the pipeline, is remembered as what it loaded as, also when recovered after a reload. - Existing suites: `test_flux3_retired_full_copies.py`, `test_media_auto_switch.py`, `test_diffusion_routes.py`, `test_diffusion_flux3.py`, `test_local_model_format.py` pass. Not covered: a real image generation from the copy. That needs the roughly 43 GB checkpoint and a GPU; routing was checked with the copy's real configs and placeholder weights. ## Before / after Offline Studio (`HF_HUB_OFFLINE=1`) with a downloaded `unsloth/flux-3-image-klein` in its cache, picked from the Images page On Device list. Before, the page sends `black-forest-labs/flux-3-image-klein`, whose mirror is not cached, so the load fails. After, it sends `unsloth/flux-3-image-klein` and the load reads the snapshot on disk; it stops here only because the test cache holds placeholder weights.  --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Summary
unsloth/flux-3-image-kleinandunsloth/flux-3-image-klein-baseare full copies of the gated BFL FLUX.3 Klein repos (about 43 GB each). Studio's copy of those files now lives inunsloth/flux-3-image-klein-FP8andunsloth/flux-3-image-klein-base-FP8, which the catalog already uses. The two full copies stay on the Hub for existing links, but a Studio load that names one of them used to treat it as its own base: it pulled the whole bf16 repo and missed the hosted text-encoder defaults, which are keyed on the BFL id.This change loads them through the base they copy:
DiffusionLoadRequestmaps either id to its BFL base (retired_full_copy_baseindiffusion_families.py), whether it arrives asmodel_pathor as thedisplay_repo_idof a downloaded snapshot, and the same forbase_repo. Every route that takes the request (load, download plan, API) then plans and loads exactly what the picker's own FLUX.3 row does, fetched from the-FP8repo.model.safetensorsis the base's bf16 transformer, so picking it becomes the pipeline load. Any other pick, or a single-file pick with its own text-encoder / VAE files, is left as named.The Hub tab's whole-repo Download of the copies is unchanged, since it is an explicit download of that repo.
Testing
tests/test_flux3_retired_full_copies.py: the mapping, the request redirect (pipeline, root transformer, downloaded snapshot, kept picks).tests/test_media_auto_switch.py::test_a_downloaded_retired_flux3_copy_switches_to_the_base_it_copies: the switch plans the base, refuses while it is not cached, loads the base pick, and treats it as resident afterwards (fails without the change).tests/test_diffusion_routes.py::test_a_retired_flux3_full_copy_reaches_the_backend_as_its_base: the download-plan and load routes hand the backend the BFL base as a pipeline pick (fails without the change).studio/frontend/tests/image-retired-full-copies.test.ts: the pick redirect and the remembered-model recall.tsc --noEmitclean.black-forest-labs/flux-3-image-klein, which a cold anonymous load already showed fetches only fromunsloth/flux-3-image-klein-FP8and renders with the int8 text encoder.