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.

Call patch_compiling_bitsandbytes on the FastLanguageModel path (#6144)

Daniel Han812999406137
diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py
index 67d1ce9b8d4..0ee9e49ba1c 100644
--- a/unsloth/models/loader.py
+++ b/unsloth/models/loader.py
@@ -722,6 +722,14 @@ class FastLanguageModel(FastLlamaModel):
load_in_4bit_kwargs = False
load_in_8bit_kwargs = False
+ # Mirror FastModel: bitsandbytes < 0.46.0 needs dynamo disabled.
+ # Best effort: never crash the load (old unsloth_zoo without the
+ # zoo #710 fix raises NameError here on Python 3.13).
+ try:
+ patch_compiling_bitsandbytes()
+ except Exception as e:
+ print(f"Unsloth: Could not patch bitsandbytes for torch.compile - {e}")
+
model, tokenizer = dispatch_model.from_pretrained(
model_name = model_name,
max_seq_length = max_seq_length,