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 diffusion: store request peaks for Wan pipelines with an empty transformer_2 slot so measured residency runs (#14864)

Daniel Hanca7b167160c0
diff --git a/studio/backend/core/inference/diffusion_memory.py b/studio/backend/core/inference/diffusion_memory.py
index e1cefbfe711..1649df23558 100644
--- a/studio/backend/core/inference/diffusion_memory.py
+++ b/studio/backend/core/inference/diffusion_memory.py
@@ -3127,6 +3127,8 @@ def stream_window_pad_mib(pipe: Any) -> Optional[int]:
for name, module in (getattr(pipe, "components", {}) or {}).items():
if str(name) not in ("transformer", "transformer_2", "unconditional_transformer"):
continue
+ if module is None:
+ continue # an empty slot (Wan2.2-TI2V-5B and Wan2.1 register transformer_2 = None)
state = _streaming_state(module)
if state is None:
return None
@@ -3159,6 +3161,8 @@ def _streamed_group_window_mib(pipe: Any) -> int:
for name, module in (getattr(pipe, "components", {}) or {}).items():
if str(name) not in ("transformer", "transformer_2", "unconditional_transformer"):
continue
+ if module is None:
+ continue
for group in _offload_groups(module):
if getattr(group, "_unsloth_resident", False):
continue
diff --git a/studio/backend/tests/test_diffusion_peak_pad_empty_slot.py b/studio/backend/tests/test_diffusion_peak_pad_empty_slot.py
new file mode 100644
index 00000000000..7f6d0ec7270
--- /dev/null
+++ b/studio/backend/tests/test_diffusion_peak_pad_empty_slot.py
@@ -0,0 +1,56 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+"""A ``transformer_2 = None`` slot (Wan2.1, Wan2.2-TI2V-5B) must not make the stream pad None. CPU only."""
+
+from __future__ import annotations
+
+import types
+
+import pytest
+
+import core.inference.diffusion_memory as dm
+
+torch = pytest.importorskip("torch")
+
+
+class _Group:
+ def __init__(self, module, nbytes):
+ self.modules = [module]
+ self.parameters = []
+ self.buffers = []
+ self._nbytes = nbytes
+
+
+def streamed(monkeypatch):
+ dit = torch.nn.Linear(64, 64)
+ groups = {id(dit): [_Group(dit, 64 * 64 * 4)]}
+ real = dm._offload_groups # raises on None, as for any non-module
+
+ monkeypatch.setattr(
+ dm,
+ "_offload_groups",
+ lambda module: list(groups[id(module)]) if id(module) in groups else real(module),
+ )
+ return dit
+
+
+def test_pad_skips_an_empty_denoiser_slot(streamed):
+ pipe = types.SimpleNamespace(components = {"transformer": streamed, "transformer_2": None})
+ assert dm.stream_window_pad_mib(pipe) == 0
+ assert (
+ dm.stream_window_pad_mib(types.SimpleNamespace(components = {"transformer": streamed})) == 0
+ )
+
+
+def test_streamed_group_window_skips_an_empty_denoiser_slot(streamed):
+ pipe = types.SimpleNamespace(components = {"transformer": streamed, "transformer_2": None})
+ assert dm._streamed_group_window_mib(pipe) > 0
+
+
+def test_an_unhooked_off_card_denoiser_still_reads_unknown(streamed):
+ # unhooked off-card weights stay unknown
+ other = torch.nn.Linear(8, 8)
+ pipe = types.SimpleNamespace(components = {"transformer": streamed, "transformer_2": other})
+ assert dm.stream_window_pad_mib(pipe) is None