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 compile cache: torch 2.7 keeps reused graphs in saved bundles (follow-up to #17110) (#17196)

Daniel Han50c236cc8599
diff --git a/studio/backend/core/inference/diffusion_compile_cache.py b/studio/backend/core/inference/diffusion_compile_cache.py
index af60fb6b96f..98a70615cb3 100644
--- a/studio/backend/core/inference/diffusion_compile_cache.py
+++ b/studio/backend/core/inference/diffusion_compile_cache.py
@@ -942,7 +942,13 @@ def _fresh_collector(logger: Any, forwards: frozenset = frozenset()) -> bool:
return False
try:
import torch # noqa: PLC0415
- from torch.compiler._cache import CacheArtifactManager # noqa: PLC0415
+
+ # _merge_groups needs these (torch 2.8+), not just AppendingByteSerializer
+ from torch.compiler._cache import ( # noqa: F401, PLC0415
+ CacheArtifactManager,
+ _deserialize_single_cache,
+ _serialize_single_cache,
+ )
from torch.utils._appending_byte_serializer import AppendingByteSerializer # noqa: F401, PLC0415
except ImportError:
# torch 2.7 bundles are a flat list that cannot be merged
diff --git a/studio/backend/tests/test_diffusion_compile_cache_collector.py b/studio/backend/tests/test_diffusion_compile_cache_collector.py
index 1e878004abb..2f2b82900a2 100644
--- a/studio/backend/tests/test_diffusion_compile_cache_collector.py
+++ b/studio/backend/tests/test_diffusion_compile_cache_collector.py
@@ -111,6 +111,15 @@ def test_a_running_compile_is_never_waited_for(collector, monkeypatch):
assert not _cache.CacheArtifactManager.need_serialize()
+def test_a_torch_without_the_grouped_bundle_helpers_keeps_the_collector(collector, monkeypatch):
+ # clearing without the per-group (de)serializers dropped reused graphs from the next bundle
+ monkeypatch.delattr(_cache, "_serialize_single_cache")
+ monkeypatch.delattr(_cache, "_deserialize_single_cache")
+ _record("pending")
+ assert cc._fresh_collector(None) is False
+ assert _cache.CacheArtifactManager.need_serialize()
+
+
# Real CPU Inductor: a later model of the same classes runs earlier graphs from memory and records nothing.