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 LTX-2.5: keep a fixed negative prompt in the encoder cache (refresh entries on a hit) (#17138)
Daniel Han33a1f1bd4014
diff --git a/studio/backend/core/inference/video_ltx25.py b/studio/backend/core/inference/video_ltx25.pyindex cdf1e16573d..080f9e0bbe2 100644--- a/studio/backend/core/inference/video_ltx25.py+++ b/studio/backend/core/inference/video_ltx25.py@@ -1310,8 +1310,10 @@ class Ltx25TextEncoderClient:clone per call is ~40 ms on a B200 host."""key = (tuple(prompts), int(max_sequence_length))with self._lock:- for cached_key, value in self._cache:+ for i, (cached_key, value) in enumerate(self._cache):if cached_key == key:+ # LRU: a negative prompt hit every render is never the one evicted.+ self._cache.append(self._cache.pop(i))return (value[0].clone(), value[1].clone()) if copy else valueif not self.alive():logger.warning("video.ltx25_te: encoder worker not running; restarting it")diff --git a/studio/backend/tests/test_video_ltx25.py b/studio/backend/tests/test_video_ltx25.pyindex 7547b5c9d19..90ef0de8fc0 100644--- a/studio/backend/tests/test_video_ltx25.py+++ b/studio/backend/tests/test_video_ltx25.py@@ -999,6 +999,42 @@ def test_client_caches_recent_encodes_and_reports_a_dead_worker(monkeypatch):client._get(None, "encoding")+def test_a_fixed_negative_prompt_stays_cached_across_alternating_prompts():+ import torch++ client = v25.Ltx25TextEncoderClient(+ repo = "r",+ hf_token = None,+ cache_dir = None,+ local_files_only = True,+ device = "cpu",+ dtype = "bfloat16",+ resident = False,+ venv_dir = "/x",+ )+ client._cmd, client._resp = queue.Queue(), queue.Queue()+ client._proc = SimpleNamespace(is_alive = lambda: True, exitcode = None)+ client._ready = True+ sent = []++ def fake_put(msg):+ sent.append(msg["prompts"][0])+ client._resp.put(+ {+ "type": "embeds",+ "id": msg["id"],+ "embeds": torch.zeros(1, 2, 3),+ "mask": torch.ones(1, 2),+ }+ )++ client._cmd.put = fake_put+ for positive in ("p1", "p2", "p1", "p2"):+ client.encode([positive], 2)+ client.encode(["neg"], 2)+ assert sent == ["p1", "neg", "p2", "p1", "p2"]++def test_an_abandoned_encodes_error_does_not_fail_the_next_one():import torch