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
More bug fixes (#133)
Daniel Han7da0c50f757b
diff --git a/unsloth/kernels/utils.py b/unsloth/kernels/utils.pyindex 7c693a6c4ec..e22e3a11b90 100644--- a/unsloth/kernels/utils.py+++ b/unsloth/kernels/utils.py@@ -179,7 +179,10 @@ passdef fast_linear_forward(proj, X, temp_lora = None, out = None):W, W_quant, lora_A, lora_B, lora_S = get_lora_parameters(proj)- out = fast_gemv(X, W, W_quant, out = out)+ if W_quant is None:+ out = torch.matmul(X, W.t())+ else:+ out = fast_gemv(X, W, W_quant, out = out)if lora_A is not None:# Save LoRAs for inference to stop data movement costsdiff --git a/unsloth/models/llama.py b/unsloth/models/llama.pyindex da99ea4b68c..bc7dc69261d 100644--- a/unsloth/models/llama.py+++ b/unsloth/models/llama.py@@ -489,7 +489,7 @@ def LlamaModel_fast_forward(# Ignore attention_maskif attention_mask is None:padding_mask = None- elif True:#self.training:+ elif self.training:attention_mask = Nonepadding_mask = Noneelse:diff --git a/unsloth/save.py b/unsloth/save.pyindex b4e17966fac..6c44d23cb00 100644--- a/unsloth/save.py+++ b/unsloth/save.py@@ -258,11 +258,19 @@ def unsloth_save_model("private" : save_pretrained_settings["private"],"token" : save_pretrained_settings["token"],}-++ # Check if PEFT Model or not - if yes, 3 levels. If not 2 levels.+ from peft import PeftModelForCausalLM+ if isinstance(model, PeftModelForCausalLM):+ internal_model = model.model+ else:+ internal_model = model+ pass++ # Cannot be converted properly!if (save_method == "merged_4bit") or (save_method == "lora") or (not hasattr(model, "model") or \- not hasattr(model.model, "model") or \- not hasattr(model.model.model, "layers")+ not hasattr(internal_model.model, "layers")):# Do general saving@@ -343,12 +351,12 @@ def unsloth_save_model(# HF also uses a OrderedDictfrom collections import OrderedDictstate_dict = OrderedDict()- state_dict["model.embed_tokens.weight"] = model.model.model.embed_tokens.weight.data+ state_dict["model.embed_tokens.weight"] = internal_model.model.embed_tokens.weight.datamax_vram = int(torch.cuda.get_device_properties(0).total_memory * maximum_memory_usage)from tqdm import tqdm as ProgressBar- for j, layer in enumerate(ProgressBar(model.model.model.layers)):+ for j, layer in enumerate(ProgressBar(internal_model.model.layers)):for item in LLAMA_WEIGHTS:proj = eval(f"layer.{item}")name = f"model.layers.{j}.{item}.weight"@@ -375,8 +383,8 @@ def unsloth_save_model(passpass- state_dict["model.norm.weight"] = model.model.model.norm.weight.data- state_dict["lm_head.weight"] = model.model.lm_head.weight.data+ state_dict["model.norm.weight"] = internal_model.model.norm.weight.data+ state_dict["lm_head.weight"] = internal_model.lm_head.weight.data# All tensors MUST be type torch.Tensor and not torch.nn.parameter.Parameterfor key, value in state_dict.items():@@ -418,7 +426,7 @@ def unsloth_save_model(model.config = new_config# Save!- model.model.save_pretrained(**save_pretrained_settings)+ internal_model.save_pretrained(**save_pretrained_settings)# Revert config backoriginal_model = model