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.

Update loader.py

Daniel Hana33ff972c16a
diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py
index 96e71075e6d..8d42ffe0561 100644
--- a/unsloth/models/loader.py
+++ b/unsloth/models/loader.py
@@ -437,10 +437,12 @@ class FastLanguageModel(FastLlamaModel):
if load_in_4bit:
# Fix up bitsandbytes config
+ config = model.config.to_dict()
+ torch_dtype = config.get("dtype") or config.get("torch_dtype")
quantization_config = \
{
# Sometimes torch_dtype is not a string!!
- "bnb_4bit_compute_dtype" : model.config.to_dict()["torch_dtype"],
+ "bnb_4bit_compute_dtype" : torch_dtype,
"bnb_4bit_quant_type" : "nf4",
"bnb_4bit_use_double_quant" : True,
"llm_int8_enable_fp32_cpu_offload" : False,
@@ -887,10 +889,12 @@ class FastModel(FastBaseModel):
if load_in_4bit:
# Fix up bitsandbytes config
+ config = model.config.to_dict()
+ torch_dtype = config.get("dtype") or config.get("torch_dtype")
quantization_config = \
{
# Sometimes torch_dtype is not a string!!
- "bnb_4bit_compute_dtype" : model.config.to_dict()["torch_dtype"],
+ "bnb_4bit_compute_dtype" : torch_dtype,
"bnb_4bit_quant_type" : "nf4",
"bnb_4bit_use_double_quant" : True,
"llm_int8_enable_fp32_cpu_offload" : False,