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 video: keep a streamed LTX-2 denoiser partly resident per request (21% faster per step) (#16787)

Daniel Hanc6f4f78913ad
diff --git a/studio/backend/core/inference/video_stream_residency.py b/studio/backend/core/inference/video_stream_residency.py
index aba2815fd7f..ea549e8fdd2 100644
--- a/studio/backend/core/inference/video_stream_residency.py
+++ b/studio/backend/core/inference/video_stream_residency.py
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-"""Keeps top group and block prefix of a Wan or HunyuanVideo-1.5 denoiser resident, re-fitted per
+"""Keeps top group and block prefix of a Wan, HunyuanVideo-1.5 or LTX-2 denoiser resident, re-fitted per
request; need estimate stays the lower bound; kill switches UNSLOTH_VIDEO_DIT_RESIDENT=0,
UNSLOTH_VIDEO_DIT_RESIDENT_BLOCKS=0 (top group only), UNSLOTH_VIDEO_DIT_RESIDENT_MEASURED=0
(estimate only)."""
@@ -17,6 +17,8 @@ VIDEO_DIT_RESIDENT_MEASURED_ENV = "UNSLOTH_VIDEO_DIT_RESIDENT_MEASURED"
RESIDENT_POLICIES = ("group", "streaming")
# Single-DiT families measured under the fit (MiniMax-H3 has its own controller, video_minimax_h3_residency).
RESIDENT_FAMILY_PREFIXES = ("wan", "hunyuanvideo-1.5")
+# Matched by name only: "ltx-2" covers LTX-2.0 to 2.3; "ltx-2.5" (another decoder stack) is not measured.
+RESIDENT_FAMILIES = ("ltx-2",)
# A measured peak is scaled by this and a fixed slack is kept on top (allocator fragmentation, cuDNN workspaces).
MEASURED_PEAK_MARGIN = 1.15
MEASURED_SLACK_MIB = 1024
@@ -64,7 +66,10 @@ def applies(
residency_enabled()
and not modular
and not is_moe
- and str(family_name or "").startswith(RESIDENT_FAMILY_PREFIXES)
+ and (
+ str(family_name or "").startswith(RESIDENT_FAMILY_PREFIXES)
+ or str(family_name or "") in RESIDENT_FAMILIES
+ )
and offload_policy in RESIDENT_POLICIES
and str(device or "").startswith("cuda")
)
diff --git a/studio/backend/tests/test_video_stream_residency.py b/studio/backend/tests/test_video_stream_residency.py
index 44d0e3533db..3d2b105b351 100644
--- a/studio/backend/tests/test_video_stream_residency.py
+++ b/studio/backend/tests/test_video_stream_residency.py
@@ -30,12 +30,16 @@ def _applies(**kw):
return vr.applies(family, **args)
-def test_applies_only_to_block_streamed_single_dit_wan_and_hunyuanvideo_on_cuda(monkeypatch):
+def test_applies_only_to_block_streamed_single_dit_wan_hunyuanvideo_and_ltx2_on_cuda(monkeypatch):
assert _applies()
assert _applies(offload_policy = "streaming")
assert _applies(device = "cuda")
assert not _applies(family = "wan2.2-t2v-a14b", is_moe = True)
- assert not _applies(family = "ltx-2")
+ assert _applies(family = "ltx-2")
+ assert _applies(family = "ltx-2", offload_policy = "streaming")
+ assert not _applies(family = "ltx-2.5")
+ assert not _applies(family = "ltx-2-custom")
+ assert not _applies(family = "ltx-2", is_moe = True)
assert _applies(family = "hunyuanvideo-1.5")
assert _applies(family = "hunyuanvideo-1.5-720p", offload_policy = "streaming")
assert not _applies(family = "minimax-h3")