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.

Put back the unsloth_zoo modules the device map opt-in tests stub (#12038)

Daniel Han8c2ffee82e78
diff --git a/tests/test_unsloth_device_map_optin.py b/tests/test_unsloth_device_map_optin.py
index 7f0bdc53d4a..92480d1ba5b 100644
--- a/tests/test_unsloth_device_map_optin.py
+++ b/tests/test_unsloth_device_map_optin.py
@@ -28,6 +28,23 @@ _SRC = open(LOADER_UTILS, encoding = "utf-8").read()
_SKIP_MODULES = ["lm_head", "vision_tower", "audio_tower"]
+# _load plants stand-ins for these, and the rest of the suite shares the interpreter: a later
+# `import unsloth_zoo.compiler` in the same xdist worker would pick up a peft_utils with no
+# get_lora_layer_modules and fail with "cannot import name ... (unknown location)".
+_STUBBED_ZOO_MODULES = ("unsloth_zoo.peft_utils", "unsloth_zoo.device_map_planner")
+
+
[email protected](autouse = True)
+def _restore_stubbed_zoo_modules():
+ saved = {name: sys.modules.get(name) for name in _STUBBED_ZOO_MODULES}
+ yield
+ for name, module in saved.items():
+ if module is None:
+ sys.modules.pop(name, None)
+ else:
+ sys.modules[name] = module
+
+
class _FakeCuda:
def __init__(
self,