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.

Native quant tests: make peft see torchao as absent when the test blocks it (#16704)

Daniel Hana1e340be0f78
diff --git a/studio/backend/tests/test_diffusion_native_quant.py b/studio/backend/tests/test_diffusion_native_quant.py
index 3a22f93db8c..c06aa0609fe 100644
--- a/studio/backend/tests/test_diffusion_native_quant.py
+++ b/studio/backend/tests/test_diffusion_native_quant.py
@@ -409,6 +409,12 @@ def _block_torchao(monkeypatch):
# A None sys.modules entry makes any torchao import raise, proving the branch never reaches it.
monkeypatch.setitem(sys.modules, "torchao", None)
monkeypatch.setitem(sys.modules, "torchao.quantization", None)
+ # peft caches is_torchao_available() per process: an earlier True in this worker would send its
+ # LoRA dispatcher into the blocked import, so peft must see torchao as absent too.
+ for name in ("peft.import_utils", "peft.tuners.lora.torchao"):
+ module = sys.modules.get(name)
+ if module is not None and hasattr(module, "is_torchao_available"):
+ monkeypatch.setattr(module, "is_torchao_available", lambda: False)
@pytest.mark.parametrize("scheme", ["int8", "fp8"])