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 diffusion: keep the VRAM Budget reserve free in the decode-time residency release (#15048)
Daniel Han6792704cf094
diff --git a/studio/backend/core/inference/diffusion_memory.py b/studio/backend/core/inference/diffusion_memory.pyindex a137937f884..030461b4bf3 100644--- a/studio/backend/core/inference/diffusion_memory.py+++ b/studio/backend/core/inference/diffusion_memory.py@@ -4534,7 +4534,9 @@ def release_for_decode(if dev.index is None:dev = torch.device("cuda", torch.cuda.current_device())need = decode_need_mib(lend, width = width, height = height, batch_size = batch_size)- free = int(torch.cuda.mem_get_info(dev)[0])+ free, total = (int(x) for x in torch.cuda.mem_get_info(dev))+ # keep the VRAM Budget reserve free, like every other decode-time check+ free -= user_budget_reserve_bytes(dev, total)# only the cache an ordinary decode allocation can reuse: a CUDA graph pool's free blocks are notcached = max(0,diff --git a/studio/backend/tests/test_diffusion_phase_peaks.py b/studio/backend/tests/test_diffusion_phase_peaks.pyindex cfedc564ee5..6eed61d6f2b 100644--- a/studio/backend/tests/test_diffusion_phase_peaks.py+++ b/studio/backend/tests/test_diffusion_phase_peaks.py@@ -410,6 +410,23 @@ class _GuardTorch:self.cuda = cuda+def test_decode_release_keeps_the_vram_budget_reserve_free(monkeypatch):+ calls = []+ monkeypatch.setattr(+ dm,+ "release_resident_groups",+ lambda pipe, need, logger = None, reason = "", device = None, **kw: calls.append(need)+ or (lambda: None),+ )+ pipe = types.SimpleNamespace()+ pipe._unsloth_decode_lend = (4040, 5900, 1024 * 1024, False)+ # 7500 MiB covers the decode, but not plus a 2 GiB reserve+ monkeypatch.setattr(dm, "user_budget_reserve_bytes", lambda device, total: 2048 << 20)+ monkeypatch.setitem(sys.modules, "torch", _GuardTorch(free_mib = 7500))+ assert dm.release_for_decode(pipe, width = 1024, height = 1024, device = "cuda:0") is not None+ assert calls == [6785 + dm._DECODE_SLACK_MIB - (7500 - 2048)]++def test_decode_streams_lent_encoders_only_when_free_memory_is_short(monkeypatch):calls = []monkeypatch.setattr(