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
Update llama.py
Daniel Han9852fdb642ad
diff --git a/unsloth/models/llama.py b/unsloth/models/llama.pyindex 5bc2983a228..bc434ecf192 100644--- a/unsloth/models/llama.py+++ b/unsloth/models/llama.py@@ -2063,9 +2063,9 @@ class FastLlamaModel:(getattr(gate_proj, "base_layer", gate_proj).bias is None) and \(getattr( up_proj, "base_layer", up_proj).bias is None) and \(getattr(down_proj, "base_layer", down_proj).bias is None) and \- (len(getattr(gate_proj, "lora_magnitude_vector", [])) == 0) and \- (len(getattr( up_proj, "lora_magnitude_vector", [])) == 0) and \- (len(getattr(down_proj, "lora_magnitude_vector", [])) == 0):+ (len(getattr(gate_proj, "lora_magnitude_vector", []) or []) == 0) and \+ (len(getattr( up_proj, "lora_magnitude_vector", []) or []) == 0) and \+ (len(getattr(down_proj, "lora_magnitude_vector", []) or []) == 0):# https://stackoverflow.com/questions/50599045/python-replacing-a-function-within-a-class-of-a-modulelayer.mlp.forward = types.MethodType(apply_lora_mlp, layer.mlp)@@ -2087,9 +2087,9 @@ class FastLlamaModel:(getattr(q_proj, "base_layer", q_proj).bias is None) and \(getattr(k_proj, "base_layer", k_proj).bias is None) and \(getattr(v_proj, "base_layer", v_proj).bias is None) and \- (len(getattr(q_proj, "lora_magnitude_vector", [])) == 0) and \- (len(getattr(k_proj, "lora_magnitude_vector", [])) == 0) and \- (len(getattr(v_proj, "lora_magnitude_vector", [])) == 0):+ (len(getattr(q_proj, "lora_magnitude_vector", []) or []) == 0) and \+ (len(getattr(k_proj, "lora_magnitude_vector", []) or []) == 0) and \+ (len(getattr(v_proj, "lora_magnitude_vector", []) or []) == 0):layer.self_attn.apply_qkv = apply_lora_qkvn_qkv += 1@@ -2106,7 +2106,7 @@ class FastLlamaModel:o_proj = layer.self_attn.o_projif hasattr(o_proj, "lora_A") and \(getattr(o_proj, "base_layer", o_proj).bias is None) and \- (len(getattr(o_proj, "lora_magnitude_vector", [])) == 0):+ (len(getattr(o_proj, "lora_magnitude_vector", []) or []) == 0):layer.self_attn.apply_o = apply_lora_on_o += 1