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: avoid repeated Qwen-Image-2.1 VAE tile OOMs on ROCm (#13116)
oobabooga4399ef83bf88
diff --git a/studio/backend/core/inference/diffusion_vae_tiling.py b/studio/backend/core/inference/diffusion_vae_tiling.pyindex 0db54c04f8e..ce9b6d9f4b5 100644--- a/studio/backend/core/inference/diffusion_vae_tiling.py+++ b/studio/backend/core/inference/diffusion_vae_tiling.py@@ -277,6 +277,16 @@ def decode_tile_budget(vae: Any, z: Any) -> Optional[int]:raw = (os.environ.get(MAX_TILE_ENV) or "").strip()if raw.isdigit() and int(raw) > 0:return int(raw) ** 2+ # CUDA-calibrated coefficients under-predict Qwen-Image-2.1 decode on ROCm (40x40, 64x32 and 96x56 OOM at+ # 17/19 GiB limits): start at the tested 32x32 floor rather than retrying an oversized tile on every image.+ import torch++ if (+ z.device.type == "cuda"+ and getattr(torch.version, "hip", None)+ and type(vae).__name__ == "AutoencoderKLQwenImage21"+ ):+ return TILE_LATENTS**2try:_, tile, _ = _geometry(vae)# Stock tile == floor: grow only into device-free memory; decoding out of the allocator cache stalled ondiff --git a/studio/backend/tests/test_qwen21_rocm_vae_budget.py b/studio/backend/tests/test_qwen21_rocm_vae_budget.pynew file mode 100644index 00000000000..16ec6c84476--- /dev/null+++ b/studio/backend/tests/test_qwen21_rocm_vae_budget.py@@ -0,0 +1,57 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++from types import SimpleNamespace++import pytest++from core.inference import diffusion_vae_tiling as vt++torch = pytest.importorskip("torch")+++def decoder(monkeypatch):+ monkeypatch.delenv(vt.MAX_TILE_ENV, raising = False)+ monkeypatch.setattr(torch.version, "hip", "7.14")+ vae = type("AutoencoderKLQwenImage21", (), {})()+ vae._unsloth_wide_geometry = (16, 32, 16)+ vae._unsloth_wide_stock_tile = 16+ z = SimpleNamespace(device = SimpleNamespace(type = "cuda"), shape = (1, 64, 1, 96, 96))+ monkeypatch.setattr(vt, "_free_mib", lambda *a, **kw: (12000, 1))+ return vae, z++[email protected]("side", [64, 96, 128])+def test_rocm_keeps_qwen_tiles_at_the_measured_floor(decoder, side):+ vae, z = decoder+ for _ in range(2):+ budget = vt.decode_tile_budget(vae, z)+ assert vt.choose_tiles(side, side, budget) == (32, 32)++[email protected]("other_path", ["cuda", "cpu", "other_vae"])+def test_other_decoders_retain_their_adaptive_budget(monkeypatch, decoder, other_path):+ vae, z = decoder+ if other_path == "cuda":+ monkeypatch.setattr(torch.version, "hip", None)+ elif other_path == "cpu":+ z.device.type = "cpu"+ else:+ other = type("AutoencoderKLQwenImage", (), {})()+ other.__dict__.update(vae.__dict__)+ vae = other+ assert vt.decode_tile_budget(vae, z) > 32**2+++def test_explicit_tile_override_still_wins(monkeypatch, decoder):+ vae, z = decoder+ monkeypatch.setenv(vt.MAX_TILE_ENV, "64")+ assert vt.decode_tile_budget(vae, z) == 64**2+++def test_floor_memory_refusal_is_preserved(monkeypatch, decoder):+ vae, z = decoder+ monkeypatch.setattr(vt, "_free_mib", lambda *a, **kw: (512, 1))+ assert vt.floor_shortfall(vae, z) is not None+ assert vt.decode_tile_budget(vae, z) == 32**2