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.

Bug Fixes (#920)

Daniel Han1091f03d77a7
diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py
index 6a111c93446..6139115f679 100644
--- a/unsloth/models/llama.py
+++ b/unsloth/models/llama.py
@@ -1387,11 +1387,15 @@ class FastLlamaModel:
# RoPE Scaling's max_position_embeddings must be updated
max_position_embeddings = max(max_seq_length, model_max_seq_length)
kwargs.pop("attn_implementation", None); # No need since we auto call it
+
+ # Cannot be None, since HF now checks for the config
+ if load_in_4bit: kwargs["quantization_config"] = bnb_config
+
model = AutoModelForCausalLM.from_pretrained(
model_name,
device_map = device_map,
torch_dtype = dtype,
- quantization_config = bnb_config,
+ # quantization_config = bnb_config,
token = token,
max_position_embeddings = max_position_embeddings,
trust_remote_code = trust_remote_code,
diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py
index cce22aebf62..ad1098edac8 100644
--- a/unsloth/models/loader.py
+++ b/unsloth/models/loader.py
@@ -42,10 +42,11 @@ def __get_model_name(
INT_TO_FLOAT_MAPPER = None,
FLOAT_TO_INT_MAPPER = None,
):
-
model_name = str(model_name)
- if not SUPPORTS_FOURBIT and model_name.lower() in INT_TO_FLOAT_MAPPER:
- model_name = INT_TO_FLOAT_MAPPER[model_name.lower()]
+ lower_model_name = model_name.lower()
+
+ if not SUPPORTS_FOURBIT and lower_model_name in INT_TO_FLOAT_MAPPER:
+ model_name = INT_TO_FLOAT_MAPPER[lower_model_name]
logger.warning_once(
f"Unsloth: Your transformers version of {transformers_version} does not support native "\
f"4bit loading.\nThe minimum required version is 4.37.\n"\
@@ -55,16 +56,18 @@ def __get_model_name(
)
return model_name
- elif not load_in_4bit and model_name.lower() in INT_TO_FLOAT_MAPPER:
- new_model_name = INT_TO_FLOAT_MAPPER[model_name.lower()]
+ elif not load_in_4bit and lower_model_name in INT_TO_FLOAT_MAPPER:
+ new_model_name = INT_TO_FLOAT_MAPPER[lower_model_name]
# logger.warning_once(
# f"Unsloth: You passed in `{model_name}` which is a 4bit model, yet you set\n"\
# f"`load_in_4bit = False`. We shall load `{new_model_name}` instead."
# )
return new_model_name
-
- elif load_in_4bit and SUPPORTS_FOURBIT and model_name.lower() in FLOAT_TO_INT_MAPPER:
- new_model_name = FLOAT_TO_INT_MAPPER[model_name.lower()]
+ elif not load_in_4bit and lower_model_name in FLOAT_TO_INT_MAPPER:
+ new_model_name = FLOAT_TO_INT_MAPPER[lower_model_name]
+ return new_model_name
+ elif load_in_4bit and SUPPORTS_FOURBIT and lower_model_name in FLOAT_TO_INT_MAPPER:
+ new_model_name = FLOAT_TO_INT_MAPPER[lower_model_name]
# logger.warning_once(
# f"Unsloth: You passed in `{model_name}` and `load_in_4bit = True`.\n"\
# f"We shall load `{new_model_name}` for 4x faster loading."