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.

Fix main's red Backend CI, repo and picker contract tests after #13724, #13749 and #13828 (#13846)

Daniel Hand303bac37492
diff --git a/studio/backend/core/inference/diffusion_measured_peaks.py b/studio/backend/core/inference/diffusion_measured_peaks.py
index 20486e6232b..ed5d49b097e 100644
--- a/studio/backend/core/inference/diffusion_measured_peaks.py
+++ b/studio/backend/core/inference/diffusion_measured_peaks.py
@@ -150,7 +150,7 @@ def _read(path: Path, fresh: bool = False) -> dict:
):
return _cache["data"]
try:
- data = json.loads(path.read_text())
+ data = json.loads(path.read_text(encoding = "utf-8"))
if (
not isinstance(data, dict)
or data.get("version") != _VERSION
@@ -187,7 +187,7 @@ def _write(path: Path, data: dict) -> None:
path.parent.mkdir(parents = True, exist_ok = True)
fd, tmp = tempfile.mkstemp(prefix = ".peaks.", dir = str(path.parent))
try:
- with os.fdopen(fd, "w") as handle:
+ with os.fdopen(fd, "w", encoding = "utf-8") as handle:
json.dump(data, handle, indent = 1) # insertion order is the eviction order
os.replace(tmp, path)
except BaseException:
diff --git a/studio/backend/tests/test_diffusion_component_sizes.py b/studio/backend/tests/test_diffusion_component_sizes.py
index 14f6cedd05c..24aed11a5c7 100644
--- a/studio/backend/tests/test_diffusion_component_sizes.py
+++ b/studio/backend/tests/test_diffusion_component_sizes.py
@@ -398,10 +398,17 @@ class _Pipe:
self.transformer = _Module()
+def _on_card_placement(monkeypatch):
+ # A peak is recorded only under a known placement; the fake pipe's denoiser stays on the card.
+ from core.inference import diffusion_memory
+ monkeypatch.setattr(diffusion_memory, "stream_window_pad_mib", lambda pipe: 0)
+
+
def test_calibration_records_and_reuses_for_any_family(monkeypatch):
import torch
monkeypatch.setattr(vsr, "_PEAKS", {})
+ _on_card_placement(monkeypatch)
allocated = {"now": 1000 << 20, "peak": 0}
monkeypatch.setattr(torch.cuda, "reset_peak_memory_stats", lambda dev = None: None)
monkeypatch.setattr(torch.cuda, "memory_allocated", lambda dev = None: allocated["now"])
@@ -1638,6 +1645,7 @@ def test_retagged_peak_is_recorded_under_the_mode_that_ran(monkeypatch):
import torch
monkeypatch.setattr(vsr, "_PEAKS", {})
+ _on_card_placement(monkeypatch)
alloc = {"now": 0, "peak": 0}
monkeypatch.setattr(torch.cuda, "reset_peak_memory_stats", lambda dev = None: None)
monkeypatch.setattr(torch.cuda, "memory_allocated", lambda dev = None: alloc["now"])
@@ -1727,9 +1735,9 @@ def test_calibration_revision_includes_the_companion_base(monkeypatch):
)
return video._calibration_revision(state)
- assert rev("pipeline", "Lightricks/LTX-2") == "g" * 40
+ assert rev("pipeline", "Lightricks/LTX-2") == f"u/ltx-gguf/x.gguf@{'g' * 40}"
gguf_default = rev("gguf", "Lightricks/LTX-2")
- assert gguf_default == f"{'g' * 40}|base=Lightricks/LTX-2@{'b' * 40}"
+ assert gguf_default == f"u/ltx-gguf/x.gguf@{'g' * 40}+Lightricks/LTX-2@{'b' * 40}"
assert rev("gguf", "someone/ltx2-base") != gguf_default
diff --git a/studio/backend/tests/test_diffusion_learned_peaks.py b/studio/backend/tests/test_diffusion_learned_peaks.py
index 8e27bc2d792..a8c0308a702 100644
--- a/studio/backend/tests/test_diffusion_learned_peaks.py
+++ b/studio/backend/tests/test_diffusion_learned_peaks.py
@@ -1225,7 +1225,7 @@ def test_phase_table_seed_needs_its_measured_configuration(klein_pipe):
def test_oom_inside_the_first_offload_apply_unwinds_its_hooks(monkeypatch):
torch = pytest.importorskip("torch")
- import diffusers.hooks as hooks
+ hooks = pytest.importorskip("diffusers.hooks")
def fake_apply(module, **kwargs):
module._fake_hooked = True # hooked part of the module, then ran out of memory
diff --git a/tests/studio/test_model_picker_contracts.py b/tests/studio/test_model_picker_contracts.py
index cb9e6fe5761..486f5e71dad 100644
--- a/tests/studio/test_model_picker_contracts.py
+++ b/tests/studio/test_model_picker_contracts.py
@@ -425,9 +425,14 @@ def test_diffusion_capability_labeled_image_video_gen():
"features/hub/lib/model-type-filter.ts",
"features/hub/lib/view-models.ts",
):
- src = _read(rel)
- assert "Image to text" not in src, rel
- assert "Image/video gen" in src, rel
+ assert "Image to text" not in _read(rel), rel
+ assert '{ value: "diffusion", label: "Image/video gen" }' in _read(
+ "features/hub/lib/model-type-filter.ts"
+ )
+ # The Hub filter splits the capability into its two generator kinds (#13749).
+ hub = _read("features/hub/lib/view-models.ts")
+ assert '{ value: "image-gen", label: "Image gen" }' in hub
+ assert '{ value: "video-gen", label: "Video gen" }' in hub
def test_active_model_config_round_trips_gpu_fields():
diff --git a/tests/test_triton_fp_fusion.py b/tests/test_triton_fp_fusion.py
index dbca7905bac..16c9fcd625a 100644
--- a/tests/test_triton_fp_fusion.py
+++ b/tests/test_triton_fp_fusion.py
@@ -37,7 +37,7 @@ def _launch_sites():
rel = path.relative_to(KERNELS)
if rel.parts[0] == "moe" and rel.parts[1] in ("tests", "benchmark"):
continue
- src = path.read_text()
+ src = path.read_text(encoding = "utf-8")
if "triton" not in src:
continue
for node in ast.walk(ast.parse(src)):
@@ -61,11 +61,11 @@ def test_every_launch_requests_fp_fusion():
def test_nf4_options_and_warmup_carry_fp_fusion():
- nf4 = (KERNELS / "nf4.py").read_text()
+ nf4 = (KERNELS / "nf4.py").read_text(encoding = "utf-8")
assert '"enable_fp_fusion": bool(fp_fusion)' in nf4
- gemv = (KERNELS / "nf4_gemv.py").read_text()
+ gemv = (KERNELS / "nf4_gemv.py").read_text(encoding = "utf-8")
assert gemv.count("enable_fp_fusion = True") == 2
- int4 = ast.parse((KERNELS / "int4_packed.py").read_text())
+ int4 = ast.parse((KERNELS / "int4_packed.py").read_text(encoding = "utf-8"))
warmups = [
node
for node in ast.walk(int4)