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 small-host INT8: armed layers compile once (eager-only call counters, follow-up to #17167) (#17193)
Daniel Han4acaa6c99a40
diff --git a/studio/backend/core/inference/diffusion_small_host.py b/studio/backend/core/inference/diffusion_small_host.pyindex 25dc54b6baf..fc0a920cc16 100644--- a/studio/backend/core/inference/diffusion_small_host.py+++ b/studio/backend/core/inference/diffusion_small_host.py@@ -712,10 +712,13 @@ def _int8_linear_class():return y.reshape(*x.shape[:-1], self.out_features)def forward(self, x):+ # Eager-only: mutating a global int under Dynamo recompiles every call.+ count = not torch.compiler.is_compiling()if self._int8_act_ok(x):- _INT8_ACT_COUNTS["int8_act"] += 1+ if count:+ _INT8_ACT_COUNTS["int8_act"] += 1return self._forward_int8_act(x)- if self.act_int8:+ if self.act_int8 and count:_INT8_ACT_COUNTS["dequant"] += 1scale = self.scaleif scale.dtype == x.dtype:diff --git a/studio/backend/tests/test_diffusion_small_host_int8_act.py b/studio/backend/tests/test_diffusion_small_host_int8_act.pyindex afa3c200ff1..f4461eacfa6 100644--- a/studio/backend/tests/test_diffusion_small_host_int8_act.py+++ b/studio/backend/tests/test_diffusion_small_host_int8_act.py@@ -169,3 +169,27 @@ def test_forward_routes_by_dtype_rows_alignment_and_device(monkeypatch):off, _ = _layer(k = 256, n = 128, act_int8 = False)assert torch.equal(layer(x), off(x))assert calls == []+++def test_armed_layer_compiles_once_and_still_counts_eager_calls():+ """Counting under a trace used to recompile per call (recompile limit, then eager fallback or fullgraph failure)."""+ from torch._dynamo.testing import CompileCounter++ layer, _ = _layer(k = 64, n = 64)+ assert layer.act_int8+ x = torch.randn(17, 64, dtype = torch.float16)+ layer = layer.half()+ before = sh.int8_act_counts()["dequant"]+ with torch.no_grad():+ ref = layer(x)+ assert sh.int8_act_counts()["dequant"] == before + 1+ counter = CompileCounter()+ torch._dynamo.reset()+ try:+ fn = torch.compile(layer, backend = counter, fullgraph = True)+ with torch.no_grad():+ outs = [fn(x) for _ in range(12)]+ finally:+ torch._dynamo.reset()+ assert counter.frame_count == 1+ assert all(torch.equal(o, ref) for o in outs)