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.

Diffusion tests: pin the NVIDIA-host spoof and assert ROCm keeps the stock path (#16609)

Daniel Hanc15ac9bdef5e
diff --git a/studio/backend/tests/test_diffusion_int8_gemm.py b/studio/backend/tests/test_diffusion_int8_gemm.py
index b025db78743..ac33a406ab4 100644
--- a/studio/backend/tests/test_diffusion_int8_gemm.py
+++ b/studio/backend/tests/test_diffusion_int8_gemm.py
@@ -1315,11 +1315,29 @@ def test_swap_passes_streamed_only_for_the_onload_device_install(monkeypatch):
import core.inference.diffusion_int8_fused as fused
monkeypatch.setattr(fused, "resident_cuda_device", lambda t: torch.device("cuda", 0))
+ # An NVIDIA host; ROCm torch refuses the explicit-device install (next test).
+ monkeypatch.setattr(g8, "is_rocm_torch", lambda _torch: False)
g8._swap(torch.nn.Linear(2, 2), device = "cuda:0")
g8._swap(torch.nn.Linear(2, 2))
assert seen == [(0, True), (0, False)]
+def test_rocm_torch_swaps_nothing_for_an_onload_device(monkeypatch):
+ seen = []
+ monkeypatch.setattr(torch.cuda, "is_available", lambda: True)
+ monkeypatch.setattr(
+ g8, "_swap_on", lambda t, lg, i, streamed = False: seen.append((i, streamed)) or 0
+ )
+ import core.inference.diffusion_int8_fused as fused
+
+ monkeypatch.setattr(g8, "is_rocm_torch", lambda _torch: True)
+ monkeypatch.setattr(fused, "is_rocm_torch", lambda _torch: True)
+ assert g8._swap(torch.nn.Linear(2, 2), device = "cuda:0") == 0
+ assert fused.resident_cuda_device(torch.nn.Linear(2, 2)) is None
+ assert g8._split_cards(torch.nn.Linear(2, 2)) == ()
+ assert seen == []
+
+
@needs_cuda
def test_block_streamed_swiglu_mlp_runs_fused_after_the_onload(h16_rotq, monkeypatch):
"""Streamed host MLP runs fused, bit-identical to resident; the kill switch keeps it stock."""
diff --git a/studio/backend/tests/test_diffusion_qwenimage21_eager.py b/studio/backend/tests/test_diffusion_qwenimage21_eager.py
index 248b9c5f4f1..3678bf5f32c 100644
--- a/studio/backend/tests/test_diffusion_qwenimage21_eager.py
+++ b/studio/backend/tests/test_diffusion_qwenimage21_eager.py
@@ -23,7 +23,9 @@ from test_diffusion_qwenimage21 import _inputs, _model, _render # noqa: E402
def _clean(monkeypatch):
monkeypatch.delenv(e.EAGER_FAST_ENV, raising = False)
monkeypatch.delenv(q.FAST_STEP_ENV, raising = False)
+ # Wiring tests on CPU tensors posing as an NVIDIA host: ROCm torch keeps the stock step (test below).
monkeypatch.setattr(torch.cuda, "is_available", lambda: True)
+ monkeypatch.setattr(e, "is_rocm_torch", lambda _torch: False)
q.uninstall()
e.uninstall()
yield
@@ -129,6 +131,16 @@ def test_install_is_idempotent_and_uninstall_restores():
assert qmod._qwenimage21_prepare_qkv is stock
+def test_rocm_torch_keeps_the_stock_step(monkeypatch):
+ monkeypatch.setattr(e, "is_rocm_torch", lambda _torch: True)
+ stock = qmod._qwenimage21_prepare_qkv
+ m = _model()
+ assert not e.install()
+ assert not e.install_for_pipe(types.SimpleNamespace(transformer = m))
+ assert qmod._qwenimage21_prepare_qkv is stock
+ assert e._ATTR not in m.__dict__
+
+
def test_installed_diffusers_matches_the_fingerprints():
assert e.why_unsupported(qmod) is None