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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio video: stream the Wan encode under model / sequential offload too (#15173)
Daniel Han43b83d515dd8
diff --git a/studio/backend/core/inference/video_stream_encode.py b/studio/backend/core/inference/video_stream_encode.pyindex 8352e580527..8f643adfae2 100644--- a/studio/backend/core/inference/video_stream_encode.py+++ b/studio/backend/core/inference/video_stream_encode.py@@ -561,6 +561,17 @@ def claim_stream(return session.take(video_frames, fps, audio, audio_sample_rate)+def _decodes_on_cuda(pipe: Any, decoder: Any, torch: Any) -> bool:+ """True if resident on CUDA, or offloaded to host while the pipeline executes on CUDA."""+ if next(decoder.parameters()).device.type == "cuda":+ return True+ try:+ device = torch.device(getattr(pipe, "_execution_device", None) or "cpu")+ except Exception: # noqa: BLE001 - no execution device: a CPU render+ return False+ return device.type == "cuda"++def open_stream_encode(pipe: Any,fps: int,@@ -568,7 +579,7 @@ def open_stream_encode(engage: bool,logger: Any = None,) -> Optional[StreamEncode]:- """A session for a resident CUDA ``AutoencoderKLWan`` with libx264 frame threads, or None."""+ """A session for an ``AutoencoderKLWan`` decoding on CUDA with libx264 frame threads, or None."""if not engage or not stream_encode_enabled():return Nonefrom .video_encode import frame_threads_enabled@@ -589,7 +600,9 @@ def open_stream_encode(import av # noqa: F401import torch- if not torch.cuda.is_available() or next(decoder.parameters()).device.type != "cuda":+ if not torch.cuda.is_available():+ return None+ if not _decodes_on_cuda(pipe, decoder, torch):return Nonereturn StreamEncode(vae, processor, fps, logger)except Exception: # noqa: BLE001 - no PyAV, no CUDA or no parameters: encode afterwardsdiff --git a/studio/backend/tests/test_video_stream_encode.py b/studio/backend/tests/test_video_stream_encode.pyindex 1c8a67b70ea..5b2373244f1 100644--- a/studio/backend/tests/test_video_stream_encode.py+++ b/studio/backend/tests/test_video_stream_encode.py@@ -199,6 +199,22 @@ def test_engagement_gates(monkeypatch):assert vse.open_stream_encode(pipe, 8, engage = True) is None+def test_an_offloaded_vae_engages_when_the_pipeline_executes_on_cuda(monkeypatch):+ monkeypatch.setattr(torch.cuda, "is_available", lambda: True)+ pipe = _Pipe(_vae())+ assert vse.open_stream_encode(pipe, 8, engage = True) is None+ pipe._execution_device = torch.device("cpu")+ assert vse.open_stream_encode(pipe, 8, engage = True) is None+ pipe._execution_device = torch.device("cuda", 0)+ session = vse.open_stream_encode(pipe, 8, engage = True)+ try:+ assert isinstance(session, vse.StreamEncode)+ finally:+ session.close()+ monkeypatch.setenv(vse.STREAM_ENCODE_ENV, "0")+ assert vse.open_stream_encode(pipe, 8, engage = True) is None++def test_a_streamed_file_that_does_not_hold_the_clip_is_never_used(monkeypatch):pipe = _Pipe(_vae())session = vse.StreamEncode(pipe.vae, pipe.video_processor, 8)