Repository navigation
Unsloth Studio / Desktop: remember the text encoder and VAE files per image model - #14845
Conversation
A successful load stores the encoder / VAE paths it was asked for, keyed by repo, kind and file. Picking that model again refills the Advanced fields, a model with nothing saved clears them, and paths the user edited since are left alone. A load with empty fields forgets the entry. Capped at the 50 most recent models.
… 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.
…iles After a restart the Advanced fields start on the remembered model's files. Reapply of a different resident model read those fields directly and sent another model's text encoder / VAE with it. Route Reapply through the same per-model rule a pick uses: untouched fields are replaced by the target's saved files (or cleared), typed paths are still sent as typed. [skip ci]
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. |
…files The picker's download footprint planned a GGUF with the live Advanced fields, which may still hold another model's encoder / VAE files, while the Load it fires sends the model's own saved files (or none). Share the per-model rule as componentFilesForModel and apply it, without touching the fields, when resolving Load-mode footprints. Download-only picks keep sending the fields as they are. [skip ci]
…ied and direct loads - A recalled generation pinned the last-model slot's files, which a native (sd_cpp) load leaves empty, so its success erased the per-model entry. Recall now reads the entry first (recalledComponentFiles), slot as fallback. - A Load anyway retry re-sent the request a native load had stripped, so the retry's success forgot the files. Retry the same pick instead; the native engine strips the same fields again. - A finished load took ownership of the fields even when it never touched them (an adapter deploy loads a pipeline), so the next pick sent the old model's paths on as a user edit. A load owns the fields only while they show its files. [skip ci]
…m when the resident build differs - First run after an upgrade: the fields start on the last-model slot's paths while the map is empty, so re-picking that model cleared them and its load could overwrite the only copy. Page open now copies the slot into the map when the model has no entry (seedImageComponents). - A resident build of the same model with other components (another client reloaded it without the overrides) rewrote the slot but left the map, so the next recall brought the stale paths back. Generate now forgets an entry the resident diffusers build does not use (forgetStaleImageComponents); a native build never takes supplied files, so its entry stays.
…engages Re-entering the page mid-reload seeds lastLoad from the resident descriptor, which carries no requested files, so the finished load stored that as the request and erased the model's entry. Only a load the page started (one with fieldFiles) stores its request now; a resumed one keeps the entry when the build engages it (or runs native) and forgets it otherwise (rememberLoadedImageComponents). [skip ci]
…aved files on the first status - Editing only the VAE (or only the encoder) made both fields count as the user's, so the untouched one rode along to the next model and could be saved under it. componentFilesForModel and componentFieldsOwnerAfterLoad now decide each field on its own; an edited field keeps its old owner, so it stays an edit until a load takes it. - The fields start on the remembered model's saved files before status is known. On the first loaded status, a resident build of that same model that does not use them (another client reloaded it) now forgets the entry and clears the untouched fields (reconcileRememberedComponents), so Reapply or a re-pick does not load stale files. Native builds keep it. [skip ci]
… slot too; a pipeline load keeps a cleared field an edit [skip ci]
…esident cleanup runs once per status A local component file's status name is the basename the caller supplied rather than its resolved target, so an HF cache snapshot symlink no longer reports its blob hash and gets its saved paths erased. The resident cleanup now runs once per status response, so a field edit against a cached status cannot erase another tab's newer saved files. [skip ci]
…ontext save, and persist a pending load's paths A reload that changed only one override now keeps the other's saved path instead of dropping both. The page open probe treats saving_chat_context as an in-flight load. The requested encoder / VAE paths are kept in localStorage while a load runs, so a load resumed after a page reload records them; any failed, cancelled or refused load clears it. [skip ci]
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ 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". |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ 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". |
… and keep the saving phase through the GPU acquire On page open a load-progress of ready now reconciles the pending load descriptor with the resident build before it is cleared, so typed encoder and VAE paths are remembered. The chat context save marker is now held by the SwapSave handle until the acquire thread is done, so a page resumed during saving_chat_context does not read the eviction and VRAM wait before begin_load as a cancelled load.
The first status read on mount can be the build a reload replaced. The ready branch recorded the new component paths but left that old status on the page, so releasing the probe gate reconciled the saved paths against it and deleted them. Publish the fresh status under a status ticket before releasing the gate. [skip ci]
…s not use A pending descriptor left by a closed page matched the resident model by repo, kind and filename only, so a reload of the same checkpoint on other component files by another client replaced the saved entry with the stale request. Require its files to match the status component_files (basenames, sd_cpp exempt) before resuming it. [skip ci]
…ill untouched fields from a recovered load The load POST holds a preparing marker until it returns, so load-progress reads as starting while evidence, checks and the acquire run instead of the previous model's ready or null, and a page reopened then keeps the pending descriptor and polls. A pending load recovered on reopen fills each Advanced field the user has not touched since with its paths and owns it. [skip ci]
The preflight marker is now a token that /images/unload cancels, within the same account scope as the engine unload. The load POST checks it before the engine switch, after the chat KV save, before the acquire, and under the token lock around begin_load, so a Cancel from a reopened page stops the load with the engine's 409 instead of evicting chat and loading anyway.
…e video model [skip ci]
…ore anything is evicted [skip ci]
Reported in the Discord help thread. Related to #10695.
On the Images page, the Advanced "Text encoder file(s)" and "VAE file" fields start empty on every page load, and a model pick never clears or refills them, so anyone using separate ComfyUI-style files has to retype the paths each time (and one model's files ride along to the next). The fields were plain
useState("")inimages-page.tsx, and the only saved copy of the paths was the single last-model slot, which never fills them back in.Fix
Follow-ups in this PR keep the saved paths honest when the resident build changes underneath the page:
Frontend only.
Tested
Colab T4 high-RAM (Tesla T4, 15 GB), Linux, unsloth/Z-Image-Turbo-GGUF with the Comfy-Org Z-Image-Turbo
qwen_3_4b.safetensorsencoder andae.safetensorsVAE typed as absolute paths. Before = main at505bbc2(this PR's base), after =8212984(current head). Same VM, frontend rebuilt and server restarted between the two, fresh browser profile each.505bbc28212984505bbc28212984Server log for the same three loads (
serve.log, UTC). Adiffusion.comfy_componentsline means the load used the supplied files:A render with the recalled files works (default test prompt, 1024x1024, 8 steps, 73 s):
Apple M5 Mac, at
8212984:tests/image-component-recall.test.tsandtests/image-model-recall.test.ts(storage, the 50 cap, forgetting, fill / clear / keep-edits on a pick, per-field ownership, the stale-entry reconcile) 24 passed, typecheck clean.Not tested