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 the two backend guards that #9292 turned red on the 3.13 leg (#9348)

Daniel Han149d29752fd0
diff --git a/studio/backend/tests/test_metal_paravirtual_guard.py b/studio/backend/tests/test_metal_paravirtual_guard.py
index eab6ce2787f..73554937dcb 100644
--- a/studio/backend/tests/test_metal_paravirtual_guard.py
+++ b/studio/backend/tests/test_metal_paravirtual_guard.py
@@ -227,7 +227,17 @@ def test_repeat_auto_load_does_not_reload_a_healthy_cpu_server(monkeypatch, tmp_
def _never(*args, **kwargs): # pragma: no cover - must never run
raise AssertionError("tore down a healthy server on a duplicate /load")
- monkeypatch.setattr(backend, "_find_llama_server_binary", _never)
+ # _kill_process is the teardown this test is about, so it stays forbidden.
+ # _find_llama_server_binary is NOT teardown and is now legitimately on the fast
+ # path: adopt_load_intent_if_matched() asks _binary_changed_since_launch()
+ # whether a different llama-server is installed than the live one was launched
+ # from, which is the point of a custom build -- an identical request must still
+ # reload when the binary underneath it changed. Forbidding the READ made a
+ # duplicate load look like a teardown. Return a fixed path so the revision
+ # comparison sees no change and the fast path is still what is exercised.
+ monkeypatch.setattr(
+ backend, "_find_llama_server_binary", lambda *a, **k: "/nonexistent/llama-server"
+ )
monkeypatch.setattr(backend, "_kill_process", _never)
assert (
@@ -1394,7 +1404,17 @@ def test_a_suppressed_drafter_does_not_reload_the_server_it_left_healthy(monkeyp
def _never(*args, **kwargs): # pragma: no cover - must never run
raise AssertionError("tore down a healthy server on a duplicate /load")
- monkeypatch.setattr(backend, "_find_llama_server_binary", _never)
+ # _kill_process is the teardown this test is about, so it stays forbidden.
+ # _find_llama_server_binary is NOT teardown and is now legitimately on the fast
+ # path: adopt_load_intent_if_matched() asks _binary_changed_since_launch()
+ # whether a different llama-server is installed than the live one was launched
+ # from, which is the point of a custom build -- an identical request must still
+ # reload when the binary underneath it changed. Forbidding the READ made a
+ # duplicate load look like a teardown. Return a fixed path so the revision
+ # comparison sees no change and the fast path is still what is exercised.
+ monkeypatch.setattr(
+ backend, "_find_llama_server_binary", lambda *a, **k: "/nonexistent/llama-server"
+ )
monkeypatch.setattr(backend, "_kill_process", _never)
assert (
diff --git a/studio/backend/tests/test_vram_budget_settings.py b/studio/backend/tests/test_vram_budget_settings.py
index 42a653b1ef5..e8ddaca31b8 100644
--- a/studio/backend/tests/test_vram_budget_settings.py
+++ b/studio/backend/tests/test_vram_budget_settings.py
@@ -470,7 +470,13 @@ class TestPendingOwnership:
]
compact = "".join("".join(code).split())
assert "withself._serial_load_lock:try:yieldfinally:" in compact
- assert compact.endswith("self._vram_fraction_pending=None")
+ # In the finally, not necessarily last in it. The scope releases more than
+ # one pending marker now -- #9292 added _binary_revision_pending -- and
+ # pinning this to the END of the source made adding a sibling clear read as
+ # "the pending value is no longer released with the load lock", which is a
+ # different and much more alarming claim than the one that was true.
+ released = compact.split("finally:", 1)[1]
+ assert "self._vram_fraction_pending=None" in released
# And the load has to go through it, or the scope guards nothing.
load = "".join(inspect.getsource(lc.LlamaCppBackend.load_model).split())
assert "withself._serial_load_scope():" in load