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.

Tests: stop a GPU-selection route test leaking a CHAT owner into the upsampler tests (#14169)

Daniel Han2f8b62cd970f
diff --git a/studio/backend/tests/test_flux3_prompt_upsampler.py b/studio/backend/tests/test_flux3_prompt_upsampler.py
index c139c5be465..ade9525cf5c 100644
--- a/studio/backend/tests/test_flux3_prompt_upsampler.py
+++ b/studio/backend/tests/test_flux3_prompt_upsampler.py
@@ -19,6 +19,12 @@ from core.inference import flux3_prompt_upsampler as pup
@pytest.fixture(autouse = True)
def _clean(monkeypatch):
+ # The sidecar only starts while the image model holds the GPU, or nobody does yet. The arbiter is
+ # process-wide, so pin that fresh-start owner here rather than inherit one an earlier test left behind.
+ # Tests about a different owner set it themselves.
+ from core.inference import gpu_arbiter
+
+ monkeypatch.setattr(gpu_arbiter, "_owner", None)
pup.clear_cache()
monkeypatch.delenv(pup.ENV_MODEL_OVERRIDE, raising = False)
monkeypatch.delenv(pup.ENV_MMPROJ_OVERRIDE, raising = False)
diff --git a/studio/backend/tests/test_gpu_selection.py b/studio/backend/tests/test_gpu_selection.py
index be44e90c03e..95758ad2bb6 100644
--- a/studio/backend/tests/test_gpu_selection.py
+++ b/studio/backend/tests/test_gpu_selection.py
@@ -1312,7 +1312,19 @@ class TestPreSpawnGpuResolution(_GpuCacheResetMixin, unittest.TestCase):
self.assertEqual(sub_config["gpu_selection"]["selection_mode"], "auto")
+# The arbiter's module-level state, restored by TestRouteErrors.
+_ARBITER_STATE = ("_owner", "_owner_epoch", "_owner_account", "_prior_account")
+
+
class TestRouteErrors(unittest.TestCase):
+ def setUp(self):
+ # These tests drive the real load routes, which claim the GPU in the process-wide arbiter before the
+ # stubbed backend refuses the load. Put the arbiter back, or the next test on this worker inherits a
+ # CHAT owner that nothing holds (it made the FLUX.3 prompt upsampler tests refuse to start).
+ import core.inference.gpu_arbiter as arb
+ saved = {name: getattr(arb, name) for name in _ARBITER_STATE}
+ self.addCleanup(lambda: [setattr(arb, name, value) for name, value in saved.items()])
+
def test_prepare_gpu_selection_rejects_gpu_ids_on_non_accelerator_backend(self):
with patch("utils.hardware.hardware.get_device", return_value = DeviceType.CPU):
with self.assertRaises(ValueError) as exc_info: