Repository navigation
Studio Images: an omitted loras keeps the load's LoRAs (Deploy to Create no longer drops it), HunyuanImage-2.1 LoRA gated off - #17993
Conversation
The engine reads a missing LoRA selection as none, which on an int8 / fp8 load that baked its adapters sets every baked adapter's weight to 0. The native /images/generate route passed None for an omitted list, so API calls and internal callers that build a request without loras (the chat generate_image tool, the queue and XY cells built from such a request) rendered a Deploy-to-Create load without its LoRA, silently. Omitted now means the load's adapters at their load weights, as on /v1/images/generations; an empty list renders without any. The Create page sends [] instead of omitting the field when no adapter is active, so turning a LoRA off there still turns it off.
…ad of omitting loras /images/generate now reads an omitted loras list as the adapters the model was loaded with, so a Compare grid cell that sets every LoRA weight to 0 must say none explicitly; otherwise it would render with the load's adapters.
…pter-free The cell used to drop its loras to None, which /images/generate now reads as the adapters the model was loaded with; keep it as an explicit empty list instead.
… has no LoRA loader The family passed the LoRA gate, so a selected adapter failed every generation with "'HunyuanImagePipeline' object has no attribute 'load_lora_weights'" (and a LoRA load failed the same way). List it as unsupported so the load and the picker refuse it up front, and add a guard that every diffusers pipeline family either has a loader or is listed.
|
@codex review |
Codex Review Summary: ✅ CompletedThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 113c8385f5
ℹ️ 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 expected_load is None: | ||
| expected_load = load_identity( | ||
| status.get("repo_id"), status.get("base_repo"), status.get("family") | ||
| ) |
There was a problem hiding this comment.
Pin the load even when its default adapter list is empty
For an unmanaged API request that supplies steps, guidance, width, and height but omits loras, an empty adapter list leaves expected_load unset. If a different model with load-time LoRAs finishes loading between this status read and acquisition of the generation slot, the backend accepts that replacement and receives loras=None, disabling its adapters instead of applying the newly documented defaults. Pin the status identity whenever resolving omitted LoRAs, including when no adapters or no loaded model were observed, so the existing replacement retry can resolve the new load's adapters.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed: an omitted loras now pins the load identity whenever it is resolved (nothing loaded pins the empty identity), as the steps / guidance defaults do, so a replacement load is retried and gets its own adapters. Fix and a fails-before test coming in the next push.
…r-free Speed Auto compiles a dense load once a run goes adapter-free, after which the load reports supports_lora false. The Images page then hides LoRA and omits the field, and the chat tool always omits it, so resolving the load's named set made every later generation fail with the compiled-LoRA refusal. The baked set still resolves.
…o none With no adapters resolved (or nothing loaded) the run stayed unpinned, so a load with LoRAs finishing before the generation slot was admitted with loras=None and its adapters were dropped. Pin it like the omitted steps / guidance do, so the replacement retry re-resolves against the new load.
A pipeline class missing from the installed diffusers was skipped silently. Only FLUX.3 (diffusers 0.42+, loader asserted when it imports), in-tree MOSS-Image (its loader methods asserted) and MiniMax-H3-Image (adapters merged at load) may be absent; any other missing class fails. [skip ci]
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7dcce22e2f
ℹ️ 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".
| load_identity( | ||
| status.get("repo_id"), status.get("base_repo"), status.get("family") | ||
| ) |
There was a problem hiding this comment.
Include adapter defaults in the omitted-LoRA load pin
If the same checkpoint is reloaded with different load-time LoRAs between this status read and acquisition of the generation slot, this pin still matches: load_identity() contains only repo, base repo, and family, and DiffusionBackend.generate() compares only those fields. The request therefore runs with the previous load's adapter selection instead of retrying with the replacement's defaults. For example, replacing an adapter-free load with the same model plus a baked LoRA still admits loras=None and disables that LoRA. Include a load revision or the adapter-default identity in the generation-slot check so same-model replacements also trigger resolution again.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed. The route now also records the adapter set it resolved an omitted loras from (load_lora_signature of the status's load_lora_specs), and DiffusionBackend.generate compares it inside the generation slot next to the load identity; a same-model reload with other adapters raises DiffusionModelReplacedError and the existing retry re-resolves. New test test_a_same_model_reload_with_other_adapters_retries_with_its_own_set fails without it (renders [None]).
…a same-model reload with other LoRAs retries [skip ci]
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! 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". |
[skip ci]
…failing one (diffusion / g-l red since #17993) (#18000) ## Summary #17993 (an omitted `loras` keeps the load's LoRAs) merged with three backend tests red, and they are red on main now (`(Python 3.13, diffusion)` and `(Python 3.13, g-l)` on every PR based on `01d166c63c` or later): ``` test_diffusion_minimax_h3_image_default_size.py::test_an_omitted_text_to_image_size_survives_a_failing_status_read RuntimeError: status read failed test_image_generate_model_defaults.py::test_explicit_values_equal_to_the_schema_defaults_stay_and_skip_the_status_read assert 2 == 1 (backend.status_calls) test_diffusion_lora.py::test_lora_loader_check_exceptions_hold ModuleNotFoundError: No module named 'diffusers' ``` ## Cause and fix **A failing status read now fails the run (route).** The new `request.loras is None` block in `_generate_diffusion_image_run` calls `backend.status()` unguarded. The omitted-size path right below it already treats a failed status read as "no status", and the test pins that a run with named steps and guidance survives one. A status read that raises now fails `/images/generate` before the engine is called. The fix gives the omitted-loras block the same handling as the size block: - reuse the FLUX.3 upsampler probe's status read on the first attempt (no second read, as the size path does); - if a read is still needed and it raises, log it and leave `loras` omitted, which is what the engine received before #17993. **An extra status read on every run with explicit steps and guidance (test).** The defaults test sends `steps` and `guidance` and asserts the defaults add no status read. Since #17993 an omitted `loras` stands for the load's adapters, which needs the status, so that request is no longer fully explicit. The test now also names `loras: []`, which keeps its claim (explicit values skip the read and do not pin the load). With the probe reuse above, an omitted `loras` costs no extra read either, and a new test pins that: one status read in total, and the run is pinned to the load. **The MOSS import runs before the diffusers skip (test).** `test_lora_loader_check_exceptions_hold` imports `core.inference.diffusion_moss_image` before `pytest.importorskip("diffusers")`, but that module subclasses diffusers' mixins at import time, so the diffusion shard (no diffusers installed) errors instead of skipping. The import now comes after the skip. The family-name check still runs everywhere. ## Verification - On main: the first two fail, as in CI. The third needs diffusers absent; with `sys.modules["diffusers"] = None` it skips with this change instead of erroring. - With this change: `test_image_generate_model_defaults.py`, `test_diffusion_minimax_h3_image_default_size.py`, `test_diffusion_lora.py` and `test_images_generate_load_loras.py`: 725 passed. The 32 backend test files that drive `/images/generate` or the LoRA defaults: 2070 passed; the 5 failures there (`test_diffusion_backend.py` MiniMax H3 download plan) fail the same way on main in this environment (a local diffusers import error), so they are not from this change. - Restoring main's `routes/inference.py` fails the size test (`status read failed`) and the new omitted-loras test (two status reads).
… mid-request (unslothai#18135) ## Summary `/v1/images/generations` can render with a stale adapter set when the model is reloaded mid-request. With `loras` omitted, the route resolves the request to the load's adapters, but it pins only repo, base and family. Reloading the same model with other adapters keeps that identity, so a reload that lands between the status read and the generation slot is let through. There are two outcomes: - **Plain load rebaked with a LoRA:** the engine reads "no selection" as no LoRA, so the new bake renders at weight 0. - **One baked LoRA swapped for another:** the request gets a 400 for an adapter it never named. unslothai#17993 fixed the same race on the native route. `/v1` now passes the same `expected_load_loras` pin, on both single and batched calls. It does so only when `loras` is omitted and the engine reports its load's adapters. Batches are keyed on it. ## Testing - **New:** `tests/test_openai_images_load_swap.py`, 6 tests in which a load thread commits a rebake between the status read and the slot. On main 4 fail and 2 pass; on this branch all 6 pass. - One test drives the real `DiffusionBackend.generate` slot check. On main it reaches the render with `loras=None`, which would zero the new bake. - **Updated:** the fake engine in `test_openai_images_baked_loras.py` takes `expected_load_loras`, as the real diffusers engine does. - **Suites:** `/v1` and native route suites pass. Across 14 wider route files, main and this branch fail the same test IDs; they need zstd, sqlite_vec and the MiniMax download plan. ## Not covered No GPU run drove a real reload into a live `/v1` request. The race is route-level, and the test exercises the real engine's slot check.
Summary
A LoRA deployed with "Deploy to Create" on an int8 / fp8 image load was silently dropped by any
/images/generatecall that leftlorasout. That includes direct API calls and every internal caller built from such a request: the chatgenerate_imagetool, the queue and XY cells./v1/images/generationsalready resolves an omitted list to the load's adapters (Studio: keep a load's baked LoRAs on /v1/images/generations #17899, Studio: /v1/images/generations keeps a deployed LoRA on MiniMax-H3-Image and dense builds #17961); the native route did not.Three smaller gaps found by the same LoRA matrix are fixed too.
Change
/images/generate: an omittedlorasnow means the adapters the model was loaded with (the baked set, or the set a dense load named), at their load weights. A load that named none still renders with none. An empty list[]renders without any adapter.[].models/inference.pydocuments the new meaning.supports_lora: false) resolves an omitted list to none, so turning a LoRA off and letting Speed compile never brings it back as a refused request. The baked set of an int8 / fp8 load still resolves.[]instead of omitting the field when no adapter is active, so turning a LoRA off in the UI still turns it off.[]instead of omittingloras, so it stays adapter-free under the new meaning.load_lora_weights, so every LoRA generation and every int8 / fp8 LoRA load on it failed with an AttributeError. A new test checks that every diffusers image family either has a LoRA loader or is listed as gated off.Results
Real GPU, Colab G4, Z-Image int8 through the REST API, compiled, same seed:
lorasomitted after a Deploy-to-Create LoRA load[]; LoRA vs none LPIPS 0.147)loras: []HunyuanImage-2.1 on main, same G4: the bf16, INT8-attention and fp16 LoRA cells fail to render, and the int8 / fp8 LoRA loads fail at load. With this PR the family no longer offers LoRA.
The same G4 matrix checked LoRA application across 18 bf16 families plus GGUF, sd.cpp, nf4, fp16, INT8 attention and baked int8 / fp8 loads.
Tests
tests/test_images_generate_load_loras.py: omittedlorasrenders with the baked set; a dense load keeps the adapters it named; the chatgenerate_imagetool keeps the baked set;[]renders with none. 3 fail on main.tests/test_diffusion_lora.py: HunyuanImage-2.1 is gated off, and every diffusers pipeline family has a LoRA loader or is gated off. Both fail on main.tests/test_images_generate_load_loras.py: a compiled dense load that omitslorasrenders without its named set, and a load swapped in before the slot retries with its own set. Both fail without their fix.tests/test_diffusion_xy.py: an all-zero LoRA cell drops the adapter. Fails on main.studio/frontend/tests/images-compare-grid.test.ts: the all-zero cell assertion fails on main; the file passes (47)./v1baked LoRA suites: 914 passed.Not covered
[]instead of a missing field).