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: report CUDA graphs as on once the deferred speed profile arms them (#12301)

Daniel Han5efd2d8b0814
diff --git a/studio/backend/core/inference/diffusion.py b/studio/backend/core/inference/diffusion.py
index 64234db3461..bb1f3e8afd4 100644
--- a/studio/backend/core/inference/diffusion.py
+++ b/studio/backend/core/inference/diffusion.py
@@ -8354,6 +8354,19 @@ class DiffusionBackend:
att["reason"] = (
"cuDNN fused attention upgrade" if attention_engaged else "diffusers default"
)
+ # The load recorded "speed tier does not capture" for the deferred tier; the profile that just engaged may
+ # have armed graphs, so re-derive the entry the same way the load does or the badge keeps saying "off".
+ graph = (state.resolved or {}).get("cuda_graph")
+ if isinstance(graph, dict):
+ graph["value"] = "on" if speed_applied.get("cuda_graph") else "off"
+ graph["reason"] = (
+ "denoiser step captured per input shape, replayed bit-identically"
+ if speed_applied.get("cuda_graph")
+ else str(
+ getattr(state.pipe, "_unsloth_cuda_graph_reason", None)
+ or "speed tier does not capture"
+ )
+ )
logger.info(
"diffusion.speed: deferred profile engaged on generation 3 (optims=%s, attention=%s)",
",".join(state.speed_optims) or "none",
diff --git a/studio/backend/tests/test_diffusion_backend.py b/studio/backend/tests/test_diffusion_backend.py
index 1d6510b5284..4f5c40477b2 100644
--- a/studio/backend/tests/test_diffusion_backend.py
+++ b/studio/backend/tests/test_diffusion_backend.py
@@ -1290,6 +1290,46 @@ def test_deferred_speed_skips_while_adapter_attached(fake_runtime, tmp_path, mon
assert len(engaged) == 1
+def test_deferred_speed_refreshes_the_cuda_graph_entry(fake_runtime, tmp_path, monkeypatch):
+ # The load records "speed tier does not capture" for the deferred tier; once the 3rd generation arms graphs the
+ # resolved entry must say so too, or the badge contradicts speed_optims.
+ from core.inference import diffusion as dmod
+
+ graphs_on = {"value": True}
+ monkeypatch.setattr(dmod, "compile_eligible", lambda *a, **k: True)
+ monkeypatch.setattr(
+ dmod,
+ "apply_speed_optims",
+ lambda pipe, target, **k: {
+ "compiled": k.get("speed_mode") == "default",
+ "cuda_graph": k.get("speed_mode") == "default" and graphs_on["value"],
+ },
+ )
+ monkeypatch.setattr(dmod.compile_cache, "begin", lambda **k: None)
+
+ (tmp_path / "model.safetensors").write_bytes(b"weights")
+ backend = DiffusionBackend()
+ _load_into(backend, tmp_path, gguf_filename = "model.safetensors", family_override = "qwen-image")
+ assert backend.status()["resolved"]["cuda_graph"]["value"] == "off"
+ for p in ("one", "two", "three"):
+ backend.generate(prompt = p)
+ status = backend.status()
+ assert "cuda_graph" in status["speed_optims"]
+ assert status["resolved"]["cuda_graph"]["value"] == "on"
+ assert "captured" in status["resolved"]["cuda_graph"]["reason"]
+
+ # Control: a deferred profile that arms no graphs keeps the entry off with the recorded reason.
+ backend.unload()
+ graphs_on["value"] = False
+ _load_into(backend, tmp_path, gguf_filename = "model.safetensors", family_override = "qwen-image")
+ for p in ("a", "b", "c"):
+ backend.generate(prompt = p)
+ status = backend.status()
+ assert "cuda_graph" not in status["speed_optims"]
+ assert status["resolved"]["cuda_graph"]["value"] == "off"
+ backend.unload()
+
+
def test_deferred_speed_preserves_explicit_attention(fake_runtime, tmp_path, monkeypatch):
# Speed=Auto with Attention pinned must keep that choice when the 3rd generation engages.
from core.inference import diffusion as dmod