Skip to content

Studio Images: reload for new LoRAs on quantized loads, hold Generate during a model switch, show the loaded precision - #18420

Merged
danielhanchen merged 12 commits into
mainfrom
studio-images-page-fixes
Nov 19, 2026
Merged

danielhanchen merged 12 commits into
mainfrom
studio-images-page-fixes

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Studio Images page: LoRAs on INT8 / FP8 builds, Generate during a model switch, loaded precision label, default steps / CFG

Four fixes on the Images page, found while writing the MOSS-Image docs.

1. LoRAs on INT8 / FP8 builds

An INT8, FP8, NVFP4 or MXFP8 build takes LoRA adapters only when it loads. If you picked a LoRA the build was not loaded with, Generate failed with a 400 ("This quantized (int8/fp8) load was built without LoRA adapters"). To fix it, you had to know to click Reapply.

Rebuilding the model silently on the backend is not safe here. A load with LoRAs skips the prequantized checkpoint, so it builds the dense bf16 transformer, which may mean downloading it, and then quantizes it. The Colab L4 numbers below show the cost. The API's media auto switch is bounded to about 100 s and never downloads, so a generate request must not start this rebuild. Instead:

  • Images page: when the selection needs a reload, the button reads Reload and generate and a line above it says why. Clicking it reloads the model with the selection baked in, through the existing Reapply path with its load progress toast, and then runs the generate. Queue, Compare and Vary stop with the same offer. If a lora-reload refusal still arrives (for example a weight change on a streamed load), the error toast has a Reload with LoRAs action.
  • Backend: the refusal is now LoraReloadRequiredError, a LoraSelectionError subclass.
    • The message names the remedy: Reapply on the Images page, or loras in POST /api/inference/images/load.
    • /images/generate tags it with X-Unsloth-Refusal: lora-reload.
    • /v1/images/generations returns error.code = "lora_reload_required" (still a 400 with param = "loras").
    • The MiniMax-H3-Image refusal and the refusals for streamed or offloaded merged weights use the same type.

A selection that is the baked set or part of it still renders without a reload, as before.

2. Generate during a model switch

While a model pick was planning or downloading, the page's busy state was not set, so Generate stayed enabled. The form already had the new model's steps and guidance, so a click rendered the old model with the new model's settings.

  • Images page: Generate is now off while a pick is in flight, with the notice "Switching models. Generate turns back on once the new model has loaded." Compare, Vary and Queue check the same state.
  • Backend: /images/generate now returns a 409 (problem code loading) while an image load is in preflight, saving the chat context, downloading or finalizing. Before, it accepted the run.

3. Loaded precision in the picker header

The picker header showed the catalog row's stored precision ("BF16", and the "(Fast FP8)" tier on dense-quant hosts) while an INT8 build was loaded. The header now shows the precision the backend reports, using the same vocabulary as the Loaded build row and the loaded models list:

  • the engaged quant, such as INT8;
  • otherwise the GGUF as stored;
  • otherwise the dense dtype.

4. Default steps and guidance

The Images page defaults table was missing several backend rows: Chroma, Anima, the generic Krea key, flux1-* file names and MiniMax-H3-Image file names. Picking one of those models showed the 9 step fallback until the model loaded. The table now matches the backend row for row, and a new test parses the backend table to check this.

The MOSS-Image Hugging Face cards said Studio uses 50 steps and CFG 3, but Studio renders MOSS-Image at 25 steps and CFG 2.5. Corrected cards are prepared separately; their measurements at 50 / 3 are unchanged.

Tests

Test file Tests merge base this branch
Backend tests/test_lora_reload_refusal.py 7 fails (no reload error type) 7 pass
Backend tests/test_images_generate_during_load.py 6 3 fail (generate runs during a load) 6 pass
Frontend tests/images-lora-reload.test.ts 7 fails 7 pass
Frontend tests/images-generate-during-switch.test.ts 6 fails 6 pass
Frontend tests/images-loaded-precision-header.test.ts 5 fails 5 pass
Frontend tests/image-generation-defaults-parity.test.ts 4 2 fail (8 backend keys fall back to 9 / 0) 4 pass

Wider runs:

  • Backend, the image route, LoRA, OpenAI images and queue suites (1416 tests): the only failures were 4 tests that matched the old refusal wording. They are updated, and the LoRA suites now pass (704 tests).
  • Frontend, full suite (16747 tests): failures match the merge base. One build-config test fails on both sides. The 4 tests that read the reworked Generate button and Reapply code are updated.

GPU check (Colab L4)

One Colab L4 (23 GB, 52 GB host RAM) ran a cold prefetch, then base, head, base in fresh processes for each model. Each model got a random r=4 LoRA. Both models were loaded INT8 with no LoRA, generated once, generated again with the LoRA (refused), reloaded with the LoRA baked in, and generated with it.

model INT8 load, no LoRA (median, base range) reload with LoRA (median, base range) dense transformer download on the first reload card peak, reload / generate with LoRA LoRA engaged (mean abs pixel diff)
MOSS-Image 27.1 s (26.0 to 49.8) 41.3 s (41.3 to 66.7) 10.17 GB 14.8 / 15.9 GB 14.6 in all 4 runs
Qwen-Image-2.1 58.7 s (58.7 to 65.6) 84.8 s (81.3 to 84.8) 14.23 GB 16.0 / 16.8 GB 3.3 in all 4 runs
  • Base: raises LoraSelectionError with the old message.
  • Head: raises LoraReloadRequiredError, with refusal = "lora-reload" and openai_code = "lora_reload_required".
  • Same load path: load and bake behave the same in both arms: same status fields, peak VRAM within a few MiB, identical pixel diffs.
  • Why it is not silent: the reload builds from the dense transformer, so the first time it downloads it, and host RSS peaks at 25 to 34 GB. That is why the reload is an explicit, labelled step with load progress, not a silent part of a generate request.

Not covered

  • HTTP mapping on a GPU: the L4 run drove the backend in process, so the HTTP refusal header and OpenAI error code were checked only by CPU route tests.
  • Screenshots: the before and after shots of the header, the disabled Generate and the Reload and generate label come from two real Studio installs (CPU). The image status and host class were mocked in the browser, and the switch was photographed only while its download plan was pending. No shot shows the Reload and generate button being clicked through a real reload.
  • Backend 409 during a load: only /images/generate refuses runs during a load. The server image queue and the chat image tool still go through the engine's own load fences.
  • Reapply button: it stays enabled while a model pick is in flight.

Update: baked LoRA set reaches the page, and a hidden pick no longer holds Generate

  • Baked LoRAs: the page decides whether a LoRA needs a reload from baked_lora_specs, which the engine reports but DiffusionStatusResponse did not declare, so pydantic dropped it from /images/status and the load response. Every LoRA then read as not baked on a quantized build. The field is now declared (additive; the video status already has it), and the page treats a missing baked set as unknown and leaves the decision to the backend, whose refusal still offers the reload.
  • Pick hidden mid-plan: a pick whose page was hidden while its download plan was pending left the pick in flight, so Generate stayed off with the switching notice until the next pick. The page now takes such a pick back.
  • Staged engine reload: Reload and generate waits for the next load to start, so a reload that first plans or downloads companion files for another engine still generates once loaded.

The 409 during a load fires exactly when /images/load-progress reports a chat-context save, downloading or finalizing (16 load states, 0 mismatches); idle, ready, failed, cancelled, video and LLM loads are served as before. The frontend defaults table now matches the backend resolver in all 400 checked ids; 43 cells moved, all from the 9 / 0 fallback under the 8 missing keys.

Screenshots

Images page, main on the left, this PR on the right. The loaded INT8 status is served from a stub, since the screenshot host has no GPU.

Picker header after an INT8 load: main shows the catalog row's "(Fast FP8)" tier and "BF16"; this PR shows the precision the backend reports.

Picker header, loaded precision

During a model switch: Generate stays enabled on main and would render the old model with the new model's settings; this PR disables it with a notice until the new model has loaded. The notice sits in the sticky footer, so the form scrolls under it.

Generate held during a model switch

A LoRA selected that the INT8 build did not bake: main offers Generate, which the backend then refuses; this PR offers "Reload and generate" and says why it can take minutes.

Reload and generate for an unbaked LoRA

An INT8 / FP8 / NVFP4 / MXFP8 image load takes LoRA adapters only when it loads, so a
generate with a new selection is refused. The refusal now names the exact remedy (the
Images page Generate or Reapply, or the loras field of POST /api/inference/images/load)
and carries a machine readable code: the X-Unsloth-Refusal: lora-reload header on
/images/generate and code lora_reload_required on /v1/images/generations.
/images/generate admitted a run during a model load or switch, so it rendered the
outgoing model with the incoming pick's settings or was cancelled by the swap. It now
answers 409 (problem code loading) until the load finishes.
The frontend defaults table missed several backend rows (Chroma, Anima, the generic
Krea key, flux1-* and MiniMax-H3-Image file names), so a pick of those models showed
the 9 step fallback until the model loaded. The table now mirrors the backend row for
row, and a test pins the parity.
… Generate during a switch

A LoRA picked on an INT8 or FP8 image build that did not bake it made Generate fail
with a 400. Generate now reads Reload and generate, says why, reloads the model with
the selection baked in (the Reapply path, with its load progress) and then runs. Queue,
Compare and Vary stop with the same offer, and a lora-reload refusal that still arrives
offers the reload instead of a bare error.

Generate also stayed enabled while a model pick was planning or downloading, so it
rendered the outgoing model with the incoming model's steps and guidance. It is now
off with a notice until the new model has loaded.
The header showed the catalog row's stored precision (BF16) and the row's Fast FP8
tier while an INT8 build was resident. It now names the precision the backend reports,
the same value as the Loaded build row and the loaded models list.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T03:39:15.168669Z af5e53f 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.

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 19, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 19, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 19, 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 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: bbc87c7cf8

ℹ️ 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 +4866 to +4869
pendingRecalledGeneration.current = {
model,
load: loadSeq.current + 1,
workflow,

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 Preserve pending generation through staged engine reloads

When a quantized GGUF needs a LoRA reload and the selected engine differs from the resident engine, reapplyLoad goes through loadOrStage, which can download companion files before calling handleLoad. During that interval, loadSeq.current still has its old value, so the pending-generation effect clears this request because pending.load !== loadSeq.current. Staging updates trigger the render that runs that effect. The model eventually loads, but “Reload and generate” never generates despite its confirmation toast. Keep the pending request valid through planning/staging and bind it to the load sequence when the load actually starts.

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.

Fixed in the latest push: Reload and generate now records the request as waiting for the next load (load: "next"), the pending effect keeps it through planning and companion downloads, and handleLoad binds it to the load sequence it starts. A stage that never loads drops it, and a new pick clears it as before. Test added; it fails without the change.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@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: e71afa5fc8

ℹ️ 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".

): string | null {
if (!status?.loaded || status.supports_lora === false || !bakesLorasAtLoad(status)) return null;
const picks = activePicks(loras);
const baked = (status.baked_lora_specs ?? []).filter((s) => s && s.id && s.weight !== 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.

P1 Badge Expose baked LoRA specs in the image status response

For an INT8/FP8/NVFP4/MXFP8 or MiniMax-H3-Image load with selected LoRAs, this always treats the baked set as empty: although DiffusionBackend.status() supplies baked_lora_specs, DiffusionStatusResponse in studio/backend/models/inference.py does not declare it, and /images/status constructs that Pydantic model, discarding the field. Consequently, even after a successful reload with the requested adapters, loraReloadReason still requires another reload; the pending generation reaches handleGenerate, hits its LoRA-reload guard, and never generates. Declare and preserve the specs in the HTTP response so the frontend can recognize a successfully baked selection.

Useful? React with 👍 / 👎.

… run it

/images/status and the load response dropped baked_lora_specs because
DiffusionStatusResponse did not declare it. The Images page read every
LoRA on an INT8 / FP8 build as unbaked, so Generate always offered
Reload and generate, and the generate after the reload was stopped by
the same check. Declare the field, and treat a status without it as
unknown so the backend decides.
A pick that loses its owner to a page switch while its download plan
is pending stages and loads nothing, and nothing cleared its pending
revert. With Generate now held while a pick is in flight, the button
stayed off with the switching notice until another pick. Revert such
a pick when the plan answers, as a cancel would.

[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. Swish!

Reviewed commit: af5e53ff9f

ℹ️ 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 8bf14d0 into main Nov 19, 2026
@danielhanchen
danielhanchen deleted the studio-images-page-fixes branch November 19, 2026 18:23
danielhanchen added a commit that referenced this pull request Nov 19, 2026
…route effect from #18420 (#18534)

## Summary

Two tests in `studio/frontend/tests/image-generation-defaults.test.ts`
fail on `main` (seen in `Frontend unit tests (Windows)` on #18504, which
only touches engine installs; they fail the same way on Linux):

```
not ok - routed image picks apply and transactionally roll back model defaults
    assert.ok(routeStart >= 0 && routeEnd > routeStart)
not ok - a base file in a Turbo / Flash folder or repo keeps the backend's recipe, not the distilled one
    /models/chroma1-flash Chroma1-HD.safetensors
    + { guidance: 3.5, steps: 26 }   - { guidance: 0, steps: 9 }
```

## Root cause

Both come from #18420, and in both the product change is intended:

- **Route test.** It located the routed-pick block between `const pick =
diffusionRoutePick(` and the comment `// Reload the current model with
the current advanced options.`. #18420 removed that comment, so the end
anchor was not found. The route effect itself still applies defaults
through `applyImageModelDefaults(wanted, "auto", ...)` and rolls back
with `revertPick(revert)` when the load does not start.
- **Base file in a Flash folder.** #18420 filled in the frontend
defaults table to match the backend row for row (Chroma, Anima, Krea,
`flux1-*`, MiniMax-H3-Image). The test pinned `{ steps: 9, guidance: 0
}`, which was the fallback a base Chroma1-HD file got while the table
had no Chroma row. It now gets Chroma's own recipe (26 / 3.5), which is
exactly what the test's name promises: the base file's recipe, not the
Flash one (16 / 1).

## Changes

- Route test: the block ends at the effect's own dependency list
(`]);`), so it no longer depends on a comment. The four assertions
inside it are unchanged.
- Base-file test: each case now asserts the key resolves to the base
file's own recipe (`defaultsFor(file)`) and is not the distilled recipe
(Anima-Turbo 10 / 1, Chroma1-Flash 16 / 1), instead of pinning whatever
number the table held at the time.

Test-only change.

## Testing

- `node --test tests/image-generation-defaults.test.ts`: 26 passed (2
fail on `main`).
- Sabotage, each against this branch:
- `defaultsKeyFor` returning a Flash / Turbo folder's own key before the
file's: the base-file test fails (along with two neighbours that guard
the same rule).
- Dropping the route effect's `revertPick(revert)`: the route test
fails.
danielhanchen added a commit that referenced this pull request Nov 19, 2026
…treaming without diffusers (#18535)

## Summary

`(Python 3.13, diffusion)` fails on `main` for every PR (seen on #18526
and #18348, neither of which touches diffusion). Four tests, from two
recent merges:

```
FAILED tests/test_diffusion_backend.py::test_apply_loras_quant_unbaked_requires_reload
FAILED tests/test_diffusion_backend.py::test_apply_loras_quant_baked_matrix
    Expected regex: 'Reload the model with the adapter selection'
    Actual message: 'This INT8 build was loaded without LoRA adapters, ... Reload the model with the LoRA selection: on the Images page click Reapply ...'
FAILED tests/test_diffusion_te_residency.py::test_release_streams_and_restore_unhooks_with_identical_outputs
    assert 0 == 4   (release('test') == r.mib)
FAILED tests/test_diffusion_te_residency.py::test_a_restore_that_runs_out_of_memory_keeps_streaming
    assert True is False
```

## Root causes

**LoRA reload refusal (#18420).** #18420 turned this refusal into
`LoraReloadRequiredError` and rewrote its message to name the remedy
(Reapply on the Images page, or `loras` in `/images/load`). The routes
key on the type (`X-Unsloth-Refusal: lora-reload`, `error.code =
"lora_reload_required"`). The two tests still matched the old wording.
The behaviour is intended; the tests pinned prose.

**Encoder residency streaming (#18424).** `EncoderResidency.release()`
streams the text encoders through diffusers' group offloading. The
`(Python 3.13, diffusion)` lane does not install diffusers (the same log
shows `No module named 'diffusers'` skips), so the stream fails,
`release()` correctly keeps the encoders resident and returns 0, and the
two tests that need a real stream fail. The module is right to refuse;
the tests needed diffusers and did not say so.

## Changes

- `test_diffusion_backend.py`: both tests assert
`pytest.raises(LoraReloadRequiredError, match = "Reload the model with
the LoRA selection")`, the typed refusal plus the remedy phrase both
messages share.
- `test_diffusion_te_residency.py`: the two streaming tests are marked
to skip when `importlib.util.find_spec("diffusers") is None`. Only the
absence of diffusers skips: with diffusers installed, a regression in
Unsloth's streaming still fails them. The tests that do not stream (host
RAM refusal, a failed stream putting the encoders back) keep running
everywhere.

Test-only change.

## Testing

- With diffusers 0.43.0 (current release) on a CPU host: `pytest
tests/test_diffusion_te_residency.py tests/test_diffusion_backend.py`:
733 passed, the two streaming tests included.
- Sabotage: raising a plain `LoraSelectionError` instead of
`LoraReloadRequiredError` fails both LoRA tests.
- The no-diffusers lane is the `(Python 3.13, diffusion)` job on this
PR.
danielhanchen added a commit that referenced this pull request Nov 19, 2026
#18420 (#18536)

## Summary

`Repo tests (CPU, studio)` fails on `main` (seen on #18444):

```
FAILED tests/studio/test_model_picker_contracts.py::test_a_plan_that_lands_after_a_newer_pick_is_dropped
E   AssertionError: features/images/images-page.tsx: a superseded plan is not dropped
```

## Root cause

#18420 added `dropReleasedPick(ownRevert);` to both superseded-plan
guards in `images-page.tsx`'s `loadOrStage`, between
`pickToast.dismiss(pickToastId);` and `return true;`, so a pick released
while it was the newest is cleaned up. The behaviour this test protects
is unchanged: a plan that lands after a newer pick still returns `true`
(started), so its rollback does not fire at the newer pick's label. The
test's regex allowed only the toast dismiss before the `return`, so it
no longer found either guard.

## Changes

- Both regexes in the test now allow plain call statements
(`name(...);`) between the toast dismiss and the `return`, and still
require the guard's condition and `return true` / the fallback-load
ordering exactly as before. One line says why.

Test-only change.

## Testing

- `pytest tests/studio/test_model_picker_contracts.py`: 205 passed (the
test fails on `main`).
- Sabotage: turning the first guard's `return true;` into `return
false;` fails the test ("a superseded pick reports failure").
danielhanchen added a commit that referenced this pull request Nov 20, 2026
…ok, H3-Image LoRA reload message) (#18583)

`test_attention_hook_installs_on_cudnn_pins` (#18083) read the source of
`_apply_attention_backend` and looked for the literal `if backend ==
"_native_cudnn" and target is not None and _is_cuda_nvidia(target):`
line. #18418 moved that branch into `_apply_attention_backend_impl`, so
on main the test fails with `ValueError: substring not found` before it
checks anything. The production hook is still installed; only the test
broke, and a test that greps source text would break again on the next
refactor.

## Change

Test only (`tests/test_diffusion_qwenimage21_strided_attn.py`). The test
now runs the real `_apply_attention_backend` on a fake DiT, with the
card checks stubbed (`_is_cuda_nvidia`, `_cudnn_serves_pipe`, kernel
install, ROCm guards) and the Qwen-Image-2.1 and FLUX.3 strided installs
replaced by recorders. No production code changes.

## Tests

- `test_attention_hook_installs_on_cudnn_pins`: a `_native_cudnn` pin on
an NVIDIA target engages, pins the DiT, and calls the Qwen-Image-2.1
strided install with `(pipe, "_native_cudnn", target, logger)`. The old
version fails on main (`ValueError`), the new one passes here. With the
`install_q21_strided(...)` call removed from
`_apply_attention_backend_impl`, the new test fails, so it still guards
the hook.
- `test_attention_hook_skips_other_pins` (2 cases): a cuDNN pin on a
non-NVIDIA target and a `_native_math` pin on NVIDIA engage without
calling either strided install.

Suite (`test_diffusion_qwenimage21_strided_attn.py`,
`test_diffusion_flux3_strided_attn.py`,
`test_diffusion_int8_attention_auto.py`,
`test_diffusion_int8_attention_dispatch.py`,
`test_diffusion_int8_attention_persisted.py`,
`test_diffusion_attention.py`,
`test_diffusion_attention_honest_status.py`,
`test_diffusion_attention_cudnn_head_dim.py`): main 272 passed, 1
skipped, 1 failed (`test_attention_hook_installs_on_cudnn_pins`); this
branch 275 passed, 1 skipped, 0 failed.

## Not proven here

No GPU run; none is needed for a test-only change. The new test fakes
the card and the installs, so it shows the apply calls the hook, not
that the strided processors run on a real NVIDIA card (the existing
`gpu`-marked tests in the same file cover that).

## Second stale test: MiniMax-H3-Image LoRA reload message


`tests/test_diffusion_h3_image_trainer.py::test_backend_runs_only_the_load_time_lora_set_for_h3_image`
also fails on main: #18420 reworded the reload error to the shared
`LORA_RELOAD_REMEDY` ("Reload the model with the LoRA selection: ..."),
but the test still matched the old "Load the model again". The behaviour
it checks is unchanged (a different LoRA set or weight on an H3-Image
load is refused), so the test now matches the current message. The file
goes from 1 failed, 20 passed on main to 21 passed here.
danielhanchen added a commit that referenced this pull request Nov 20, 2026
…18657)

## Summary

`Frontend unit tests` fail on `main` (seen on #18522, reproduced on
current `main`):

```
not ok - the backend refuses an image generate while a load is in flight
  location: studio/frontend/tests/images-generate-during-switch.test.ts:77
  The input did not match the regular expression /if await asyncio\.to_thread\(_image_load_in_flight\):\s*raise HTTPException\(\s*status_code = 409/
```

## Cause

#18420 added this source check: a generate that arrives while a model
load is in flight was refused straight away with 409. Then #18626
deliberately changed that branch in `routes/inference.py`:

- a generate during a load whose pipeline is already published now waits
out the load's tail (encoder pins);
- a generate that cannot wait (pipeline not published yet, or the tail
outlasts the cap) is still refused with the in-flight 409.

#18626 covered the new behaviour with backend tests
(`test_images_generate_load_tail.py`), but this frontend check still
expected the 409 on the line right after the `if`. The product change is
right; the check is out of date.

## Change

`images-generate-during-switch.test.ts` now asserts the invariant both
PRs share, that no image run starts while a load is in flight. It finds
the in-flight branch before a run is admitted and requires both:

- that it waits out the tail (`await _wait_image_load_tail(`);
- that it still raises `HTTPException(status_code = 409, detail =
IMAGE_LOAD_IN_FLIGHT_MSG)` when it cannot.

## Testing

- On `main` the file fails 1 of 7. With this change: 7 passed.
- Sabotage on `routes/inference.py`, each of which fails the new check:
  - removing the in-flight 409;
  - replacing the tail wait.
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