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 MiniMax-H3: keep the conditioner read capture and tile decode traceable under torch.compile (#17095, #17097) (#17190)
Daniel Han0c946b49c56c
diff --git a/studio/backend/core/inference/video_minimax_h3_te.py b/studio/backend/core/inference/video_minimax_h3_te.pyindex ae3680139cf..a92b2c6057d 100644--- a/studio/backend/core/inference/video_minimax_h3_te.py+++ b/studio/backend/core/inference/video_minimax_h3_te.py@@ -1032,6 +1032,14 @@ def h3_te_read_capture_enabled() -> bool:)+def _is_compiling() -> bool:+ try:+ import torch+ return bool(torch.compiler.is_compiling())+ except Exception: # noqa: BLE001+ return False++def install_h3_te_read_capture(text_encoder: Any,*,@@ -1062,7 +1070,12 @@ def install_h3_te_read_capture(@functools.wraps(stock)def forward(*args: Any, **kwargs: Any) -> Any:- if not kwargs.get("output_hidden_states") or not h3_te_read_capture_enabled():+ # Hook registration is untraceable: a compiled caller takes the stock forward (same states, no graph break).+ if (+ not kwargs.get("output_hidden_states")+ or _is_compiling()+ or not h3_te_read_capture_enabled()+ ):return stock(*args, **kwargs)captured: list = []diff --git a/studio/backend/core/inference/video_minimax_h3_vae.py b/studio/backend/core/inference/video_minimax_h3_vae.pyindex cb3bec90063..8deffa27692 100644--- a/studio/backend/core/inference/video_minimax_h3_vae.py+++ b/studio/backend/core/inference/video_minimax_h3_vae.py@@ -1091,6 +1091,11 @@ def _stream_stitch(vae: Any) -> bool:cls = type(vae)known = _STITCH_KNOWN.get(cls)if known is None:+ import torch++ # inspect.getsource is untraceable; _install_tile_batch fills the verdict eagerly, so this is a fallback.+ if torch.compiler.is_compiling():+ return Falseimport hashlibimport inspect@@ -1178,6 +1183,7 @@ def _install_tile_batch(vae: Any) -> bool:):return Falsevae._decode_clip = types.MethodType(_batched_decode_clip, vae)+ _stream_stitch(vae)return Truediff --git a/studio/backend/tests/test_h3_te_read_capture.py b/studio/backend/tests/test_h3_te_read_capture.pyindex 7a97a3fb05e..57ff5a6d301 100644--- a/studio/backend/tests/test_h3_te_read_capture.py+++ b/studio/backend/tests/test_h3_te_read_capture.py@@ -129,3 +129,29 @@ def test_declines_deepstack_and_out_of_range_layers(layer):def test_declines_modules_without_a_decoder_stack():assert not install_h3_te_read_capture(torch.nn.Linear(2, 2))assert not install_h3_te_read_capture(None)+++def test_compiled_caller_traces_one_graph_with_the_capture_installed():+ model = _tiny()+ kw = _inputs(False)+ with torch.no_grad():+ stock = model.model(output_hidden_states = True, **kw).hidden_states+ assert install_h3_te_read_capture(model, layer = 4)+ from torch._dynamo.testing import CompileCounter++ counter = CompileCounter()+ torch._dynamo.reset()+ try:+ fn = torch.compile(+ lambda: model.model(output_hidden_states = True, **kw).hidden_states[4],+ backend = counter,+ fullgraph = True,+ )+ with torch.no_grad():+ got = fn()+ again = fn()+ finally:+ torch._dynamo.reset()+ assert counter.frame_count == 1+ assert torch.equal(got, stock[4]) and torch.equal(again, stock[4])+ assert not model.model.language_model.layers[4]._forward_pre_hooksdiff --git a/studio/backend/tests/test_video_minimax_h3_vae.py b/studio/backend/tests/test_video_minimax_h3_vae.pyindex 6a5dedffd1d..0bb9620e949 100644--- a/studio/backend/tests/test_video_minimax_h3_vae.py+++ b/studio/backend/tests/test_video_minimax_h3_vae.py@@ -1465,3 +1465,26 @@ def test_the_fused_int8_path_matches_the_unfused_int8_path_on_cuda(monkeypatch):rel = lambda a, b: float((a - b).norm() / b.norm()) # noqa: E731assert rel(unfused, dense) < 0.02 and rel(fused, dense) < 0.02assert rel(fused, unfused) < 0.01+++def test_cold_tile_decode_compiles_fullgraph_in_one_graph(monkeypatch):+ monkeypatch.setenv(H.H3_VAE_TILE_BATCH_ENV, "2")+ monkeypatch.setattr(H, "_STITCH_KNOWN", {})+ vae = _tiny_vae()+ assert H._install_tile_batch(vae)+ z = torch.randn(1, 8, 3, 6, 9, generator = torch.Generator().manual_seed(5))+ from torch._dynamo.testing import CompileCounter++ counter = CompileCounter()+ torch._dynamo.reset()+ try:+ fn = torch.compile(lambda z: vae._decode_clip(z), backend = counter, fullgraph = True)+ with torch.no_grad():+ got = fn(z)+ fn(z)+ finally:+ torch._dynamo.reset()+ with torch.no_grad():+ ref = vae._decode_clip(z)+ assert counter.frame_count == 1+ assert torch.equal(got, ref)