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: start every diffusion_segment test with no GPU arbiter resident (#14271)

Daniel Hane680e303ea53
diff --git a/studio/backend/tests/test_diffusion_segment.py b/studio/backend/tests/test_diffusion_segment.py
index ba7090bba8c..006f78c6951 100644
--- a/studio/backend/tests/test_diffusion_segment.py
+++ b/studio/backend/tests/test_diffusion_segment.py
@@ -18,6 +18,33 @@ import pytest
from core.inference import diffusion_segment as seg
[email protected](autouse = True)
+def _no_other_gpu_owner(monkeypatch):
+ """Start every test with no GPU arbiter resident.
+
+ choose_device() runs on the CPU when another owner holds the card (_other_owner_on), and
+ the arbiter's state is module-global. A test elsewhere in the same xdist worker that leaves
+ a CHAT owner behind turns the card tests here into ('cpu', torch.float32). Tests that need
+ an owner set one themselves.
+ """
+ from core.inference import gpu_arbiter
+
+ # Every correlated global together: acquire_for() in later tests moves the account and epoch
+ # fields with the owner, so restoring only some of them would pair one claim's owner with
+ # another's account in the next test on this worker.
+ for name, empty in (
+ ("_owner", None),
+ ("_owner_account", None),
+ ("_prior_account", None),
+ ("_residents", {}),
+ ("_accounts", {}),
+ ("_media_needs", {}),
+ ):
+ monkeypatch.setattr(gpu_arbiter, name, empty)
+ for counter in ("_owner_epoch", "_handovers"):
+ monkeypatch.setattr(gpu_arbiter, counter, getattr(gpu_arbiter, counter))
+
+
def _png_b64(
width: int = 64,
height: int = 48,