Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio Images: say why LoRAs vanish after Speed=Auto compiles, offer a reload (#14359)

Daniel Hand18a0a8a0415
diff --git a/studio/backend/core/inference/diffusion.py b/studio/backend/core/inference/diffusion.py
index 07a7ef40dde..bb622cbfd55 100644
--- a/studio/backend/core/inference/diffusion.py
+++ b/studio/backend/core/inference/diffusion.py
@@ -1385,6 +1385,8 @@ class _LoadState:
eager_patched: bool = False
# Deferred speed auto: the load stays eager, generate() engages `default` at the 3rd generation
speed_deferred: bool = False
+ # That deferred engagement compiled the denoiser: LoRAs are off until a reload, which defers again.
+ speed_auto_compiled: bool = False
# Auto static skip plan for that deferred `default` tier, installed when it engages.
deferred_static_plan: Optional[dict] = None
# Successful generations on this load; drives the deferred engagement above.
@@ -11966,6 +11968,7 @@ class DiffusionBackend:
speed_applied["vae_fp16_decode"] = True
object.__setattr__(state, "speed_mode", SPEED_DEFAULT)
object.__setattr__(state, "speed_optims", tuple(k for k, v in speed_applied.items() if v))
+ object.__setattr__(state, "speed_auto_compiled", bool(speed_applied.get("compiled")))
object.__setattr__(
state, "cuda_graphs", tuple(getattr(state.pipe, "_unsloth_cuda_graphs", ()) or ())
)
@@ -13254,6 +13257,7 @@ class DiffusionBackend:
"workflows": [],
"conditioning": None,
"supports_lora": False,
+ "lora_after_reload": False,
"supports_controlnet": False,
"resolved": None,
"generation_defaults": None,
@@ -13265,6 +13269,16 @@ class DiffusionBackend:
state.resolved, state.speed_optims, getattr(state, "cuda_graphs", ())
)
speed_optims = int8_gemm_live(state.pipe, speed_optims)
+ lora_gate = dict(
+ engine = "diffusers",
+ family = state.family.name,
+ model_kind = state.kind,
+ transformer_quant = state.transformer_quant,
+ )
+ compiled = "compiled" in (getattr(state, "speed_optims", ()) or ())
+ lora_load_ok = not _small_host_int8(state.pipe) and not comfy_block_runtime_layers(
+ getattr(state.pipe, "transformer", None)
+ )
return {
"loaded": True,
"repo_id": state.repo_id,
@@ -13315,15 +13329,13 @@ class DiffusionBackend:
"conditioning": conditioning_capabilities(
state.family, _family_workflows(state.family)
),
- "supports_lora": diffusion_lora.supports_lora(
- engine = "diffusers",
- family = state.family.name,
- model_kind = state.kind,
- transformer_quant = state.transformer_quant,
- compiled = "compiled" in (getattr(state, "speed_optims", ()) or ()),
- )
- and not _small_host_int8(state.pipe)
- and not comfy_block_runtime_layers(getattr(state.pipe, "transformer", None)),
+ "supports_lora": lora_load_ok
+ and diffusion_lora.supports_lora(compiled = compiled, **lora_gate),
+ # Only Speed=Auto's 3rd-image compile blocks LoRA: a reload stays eager until then.
+ "lora_after_reload": lora_load_ok
+ and compiled
+ and getattr(state, "speed_auto_compiled", False)
+ and diffusion_lora.supports_lora(compiled = False, **lora_gate),
"small_host": small_host_engaged_on(state.pipe),
"supports_controlnet": diffusion_controlnet.supports_controlnet(
engine = "diffusers",
diff --git a/studio/backend/models/inference.py b/studio/backend/models/inference.py
index 407a9b70d1d..71f8b507ba7 100644
--- a/studio/backend/models/inference.py
+++ b/studio/backend/models/inference.py
@@ -5674,6 +5674,11 @@ class DiffusionStatusResponse(BaseModel):
description = "LoRA is unavailable on the current engine for this GGUF, but reloading it on the "
"native sd.cpp engine would apply LoRAs.",
)
+ lora_after_reload: bool = Field(
+ False,
+ description = "LoRA is off only because Speed=Auto compiled the model on its 3rd image; "
+ "reloading it (still Speed=Auto) brings LoRAs back until then.",
+ )
supports_lora: bool = Field(
False,
description = "Whether the loaded model + quantisation can apply LoRA adapters (drives the "
diff --git a/studio/backend/tests/test_diffusion_backend.py b/studio/backend/tests/test_diffusion_backend.py
index 7938def0894..c360f43ca22 100644
--- a/studio/backend/tests/test_diffusion_backend.py
+++ b/studio/backend/tests/test_diffusion_backend.py
@@ -1248,6 +1248,47 @@ def test_dense_speed_auto_defers_compile_to_third_generation(fake_runtime, tmp_p
backend.unload()
+def test_speed_auto_compile_reports_that_a_reload_brings_lora_back(
+ fake_runtime, tmp_path, monkeypatch
+):
+ # #14114: the 3rd-image compile turns LoRA off. Status must say a reload restores it, or the picker just vanishes.
+ from core.inference import diffusion as dmod
+ from models.inference import DiffusionStatusResponse
+
+ monkeypatch.setattr(dmod, "compile_eligible", lambda *a, **k: True)
+ monkeypatch.setattr(
+ dmod,
+ "apply_speed_optims",
+ lambda pipe, target, **k: {"compiled": k.get("speed_mode") in ("default", "max")},
+ )
+ monkeypatch.setattr(dmod.compile_cache, "begin", lambda **k: None)
+ (tmp_path / "model.safetensors").write_bytes(b"weights")
+ load = dict(gguf_filename = "model.safetensors", family_override = "qwen-image")
+
+ backend = DiffusionBackend()
+ status = _load_into(backend, tmp_path, **load)
+ assert (status["supports_lora"], status["lora_after_reload"]) == (True, False)
+ for p in ("one", "two", "three"):
+ backend.generate(prompt = p)
+ status = backend.status()
+ assert "compiled" in status["speed_optims"]
+ assert (status["supports_lora"], status["lora_after_reload"]) == (False, True)
+ assert DiffusionStatusResponse(**status).lora_after_reload is True
+
+ # The reload defers again, so LoRA is back.
+ backend.unload()
+ status = _load_into(backend, tmp_path, **load)
+ assert (status["supports_lora"], status["lora_after_reload"]) == (True, False)
+
+ # An explicit compiled tier compiles at load: a reload would not help, so no hint.
+ backend.unload()
+ status = _load_into(backend, tmp_path, speed_mode = "default", **load)
+ assert "compiled" in status["speed_optims"]
+ assert (status["supports_lora"], status["lora_after_reload"]) == (False, False)
+ backend.unload()
+ assert backend.status()["lora_after_reload"] is False
+
+
def test_deferred_speed_stays_off_when_only_an_explicit_tier_may_compile(
fake_runtime, tmp_path, monkeypatch
):
diff --git a/studio/frontend/src/features/images/api.ts b/studio/frontend/src/features/images/api.ts
index d8aa1e7bfbf..ab32b97f0f2 100644
--- a/studio/frontend/src/features/images/api.ts
+++ b/studio/frontend/src/features/images/api.ts
@@ -83,6 +83,8 @@ export interface DiffusionStatus {
native_engine_eligible?: boolean;
// LoRA is unavailable on this engine, but a reload on the native engine would apply LoRAs.
lora_via_native?: boolean;
+ // LoRA is off only because Speed=Auto compiled the model on its 3rd image; a reload brings it back.
+ lora_after_reload?: boolean;
// Whether the loaded model + quantisation can apply LoRA adapters (drives the LoRA picker enabled state).
supports_lora?: boolean;
// Whether the loaded model can apply a ControlNet. Diffusers only, for families with a ControlNet pipeline.
diff --git a/studio/frontend/src/features/images/images-page.tsx b/studio/frontend/src/features/images/images-page.tsx
index 16278ec43aa..90a5d7be5d0 100644
--- a/studio/frontend/src/features/images/images-page.tsx
+++ b/studio/frontend/src/features/images/images-page.tsx
@@ -356,6 +356,7 @@ import {
loadedEngineChoice,
nativeLoadAdvanced,
nativeReloadTarget,
+ offersCompiledLoraReload,
offersNativeLoraReload,
reapplyChangesEngine,
reapplyTarget,
@@ -6203,6 +6204,16 @@ export function ImagesPage({
</Button>
</div>
)}
+ {!external && !loraCapable && offersCompiledLoraReload(status) && (
+ <div className="flex items-center justify-between gap-2 rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground">
+ <span>Speed compiled this model after a few images, so LoRAs are off. Reload it to add LoRAs.</span>
+ {(canReapply || residentReloadTarget(status) !== null) && (
+ <Button size="sm" variant="secondary" className="h-7 shrink-0 text-xs" disabled={busy !== null} onClick={handleReapply}>
+ Reload model
+ </Button>
+ )}
+ </div>
+ )}
{/* LoRA adapters: shown whenever the loaded model + quant can apply them. Each carries a 0-2 weight. */}
{loraCapable && (
<Field
diff --git a/studio/frontend/src/features/images/lib/engine-choice.ts b/studio/frontend/src/features/images/lib/engine-choice.ts
index 14ccc085c3a..91fba3f7b3f 100644
--- a/studio/frontend/src/features/images/lib/engine-choice.ts
+++ b/studio/frontend/src/features/images/lib/engine-choice.ts
@@ -73,6 +73,7 @@ interface EngineStatus {
engine_forced?: string | null;
native_engine_eligible?: boolean;
lora_via_native?: boolean;
+ lora_after_reload?: boolean;
supports_lora?: boolean;
resolved?: Record<string, { source: string; requested?: string | boolean | null }> | null;
}
@@ -97,6 +98,11 @@ export function offersNativeLoraReload(status: EngineStatus | null | undefined):
);
}
+/** The note under the LoRA slot after Speed=Auto compiled the model on its 3rd image: a reload defers again. */
+export function offersCompiledLoraReload(status: EngineStatus | null | undefined): boolean {
+ return Boolean(status?.loaded && status.lora_after_reload && !status.supports_lora);
+}
+
interface ReloadStatus {
loaded: boolean;
repo_id?: string | null;
diff --git a/studio/frontend/tests/image-engine-choice.test.ts b/studio/frontend/tests/image-engine-choice.test.ts
index 741bf6fd658..a7dfbe3459e 100644
--- a/studio/frontend/tests/image-engine-choice.test.ts
+++ b/studio/frontend/tests/image-engine-choice.test.ts
@@ -11,6 +11,7 @@ import {
loadedEngineChoice,
nativeLoadAdvanced,
nativeReloadTarget,
+ offersCompiledLoraReload,
offersNativeLoraReload,
reapplyChangesEngine,
reapplyTarget,
@@ -91,6 +92,16 @@ test("the loaded build's select value follows the backend's engine provenance",
assert.equal(loadedEngineChoice({ loaded: false, resolved: { engine: { source: "explicit", requested: "sd_cpp" } } }), "auto");
});
+test("the LoRA note offers a plain reload once Speed=Auto compiled LoRA off", () => {
+ const compiled = { loaded: true, engine: "diffusers", supports_lora: false, lora_after_reload: true };
+ assert.equal(offersCompiledLoraReload(compiled), true);
+ assert.equal(offersCompiledLoraReload({ ...compiled, lora_after_reload: false }), false);
+ assert.equal(offersCompiledLoraReload({ ...compiled, supports_lora: true }), false);
+ // An older backend sends no field.
+ assert.equal(offersCompiledLoraReload({ loaded: true, supports_lora: false }), false);
+ assert.equal(offersCompiledLoraReload({ loaded: false, lora_after_reload: true }), false);
+});
+
test("the LoRA note offers a native reload only where it would turn LoRA on", () => {
assert.equal(offersNativeLoraReload(ggufOnDiffusers), true);
assert.equal(offersNativeLoraReload({ ...ggufOnDiffusers, lora_via_native: false }), false);