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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Import bitsandbytes before the hardware spoof rewrites torch (#7471)
Daniel Han0c1c9f71dbc5
diff --git a/tests/_zoo_aggressive_cuda_spoof.py b/tests/_zoo_aggressive_cuda_spoof.pyindex 05889d5df2e..5e485df72cf 100644--- a/tests/_zoo_aggressive_cuda_spoof.py+++ b/tests/_zoo_aggressive_cuda_spoof.py@@ -22,6 +22,20 @@ def apply() -> None:if getattr(torch.cuda, "_unsloth_consolidated_spoof", False):return+ # Settle bitsandbytes against the real torch first. Its __init__ does+ # `if torch.cuda.is_available(): from .backends.cuda import ops`, and that+ # module reads torch._C._cuda_getCurrentRawStream at import. On a CPU-only+ # wheel that attribute is absent, so a bitsandbytes imported AFTER this+ # spoof raises AttributeError (or OSError hunting libhipblas for the ROCm+ # spoof) rather than ImportError, which slips past the `except ImportError`+ # guards its importers use. Importing it here, while is_available() is+ # still False, caches the CPU path in sys.modules for everything that+ # follows.+ try:+ import bitsandbytes # noqa: F401+ except Exception:+ pass+# Device probes (cheap, value-returning)torch.cuda.is_available = lambda: Truetorch.cuda.device_count = lambda: 1