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
Fix renaming on other model than Llama (#2762)
Edda398484d0ab1
diff --git a/unsloth/models/cohere.py b/unsloth/models/cohere.pyindex 0c36abf681e..25704301d1e 100644--- a/unsloth/models/cohere.py+++ b/unsloth/models/cohere.py@@ -466,7 +466,7 @@ class FastCohereModel(FastLlamaModel):CohereDecoderLayer .forward = CohereDecoderLayer_fast_forwardCohereModel .forward = LlamaModel_fast_forwardCohereForCausalLM .forward = CausalLM_fast_forward(CohereModel_fast_forward_inference)- PeftModelForCausalLM .forward = PeftModelForCausalLM_fast_forward+ PeftModelForCausalLM .forward = PeftModel_fast_forwardfix_prepare_inputs_for_generation(CohereForCausalLM)import transformers.models.cohere.modeling_coherediff --git a/unsloth/models/gemma.py b/unsloth/models/gemma.pyindex 873bdcf2eb8..8ad1c7e62d1 100644--- a/unsloth/models/gemma.py+++ b/unsloth/models/gemma.py@@ -332,7 +332,7 @@ class FastGemmaModel(FastLlamaModel):GemmaDecoderLayer .forward = GemmaDecoderLayer_fast_forwardGemmaModel .forward = LlamaModel_fast_forwardGemmaForCausalLM .forward = CausalLM_fast_forward(GemmaModel_fast_forward_inference)- PeftModelForCausalLM.forward = PeftModelForCausalLM_fast_forward+ PeftModelForCausalLM.forward = PeftModel_fast_forwardfix_prepare_inputs_for_generation(GemmaForCausalLM)# Solves https://github.com/unslothai/unsloth/issues/168diff --git a/unsloth/models/gemma2.py b/unsloth/models/gemma2.pyindex 316b4e8f0ee..23b91ff6f33 100644--- a/unsloth/models/gemma2.py+++ b/unsloth/models/gemma2.py@@ -477,7 +477,7 @@ class FastGemma2Model(FastLlamaModel):Gemma2DecoderLayer .forward = Gemma2DecoderLayer_fast_forwardGemma2Model .forward = LlamaModel_fast_forwardGemma2ForCausalLM .forward = CausalLM_fast_forward(Gemma2Model_fast_forward_inference)- PeftModelForCausalLM .forward = PeftModelForCausalLM_fast_forward+ PeftModelForCausalLM .forward = PeftModel_fast_forwardfix_prepare_inputs_for_generation(Gemma2ForCausalLM)# Solves https://github.com/unslothai/unsloth/issues/168diff --git a/unsloth/models/granite.py b/unsloth/models/granite.pyindex df498d18bad..0f88bbc55ea 100644--- a/unsloth/models/granite.py+++ b/unsloth/models/granite.py@@ -468,7 +468,7 @@ class FastGraniteModel(FastLlamaModel):GraniteModel .forward = LlamaModel_fast_forwardGraniteForCausalLM .forward = CausalLM_fast_forward(GraniteModel_fast_forward_inference)GraniteForCausalLM .__init__ = patched_init(GraniteForCausalLM.__init__)- PeftModelForCausalLM .forward = PeftModelForCausalLM_fast_forward+ PeftModelForCausalLM .forward = PeftModel_fast_forwardfix_prepare_inputs_for_generation(GraniteForCausalLM)import transformers.models.granite.modeling_granitediff --git a/unsloth/models/mistral.py b/unsloth/models/mistral.pyindex 303c3d95898..ef71c89c4a3 100644--- a/unsloth/models/mistral.py+++ b/unsloth/models/mistral.py@@ -368,7 +368,7 @@ class FastMistralModel(FastLlamaModel):MistralDecoderLayer .forward = LlamaDecoderLayer_fast_forwardMistralModel .forward = LlamaModel_fast_forwardMistralForCausalLM .forward = MistralForCausalLM_fast_forward- PeftModelForCausalLM .forward = PeftModelForCausalLM_fast_forward+ PeftModelForCausalLM .forward = PeftModel_fast_forwardfix_prepare_inputs_for_generation(MistralForCausalLM)# Solves https://github.com/unslothai/unsloth/issues/168diff --git a/unsloth/models/qwen2.py b/unsloth/models/qwen2.pyindex 82de1951b89..b073913651a 100644--- a/unsloth/models/qwen2.py+++ b/unsloth/models/qwen2.py@@ -55,7 +55,7 @@ class FastQwen2Model(FastLlamaModel):Qwen2DecoderLayer .forward = LlamaDecoderLayer_fast_forwardQwen2Model .forward = LlamaModel_fast_forwardQwen2ForCausalLM .forward = CausalLM_fast_forward(LlamaModel_fast_forward_inference)- PeftModelForCausalLM.forward = PeftModelForCausalLM_fast_forward+ PeftModelForCausalLM.forward = PeftModel_fast_forwardfix_prepare_inputs_for_generation(Qwen2ForCausalLM)# Solves https://github.com/unslothai/unsloth/issues/168diff --git a/unsloth/models/qwen3.py b/unsloth/models/qwen3.pyindex ac3ac108fbf..83c9dbea0ac 100644--- a/unsloth/models/qwen3.py+++ b/unsloth/models/qwen3.py@@ -387,7 +387,7 @@ class FastQwen3Model(FastLlamaModel):Qwen3DecoderLayer .forward = LlamaDecoderLayer_fast_forwardQwen3Model .forward = LlamaModel_fast_forwardQwen3ForCausalLM .forward = CausalLM_fast_forward(_LlamaModel_fast_forward_inference(Qwen3Attention_fast_forward_inference))- PeftModelForCausalLM.forward = PeftModelForCausalLM_fast_forward+ PeftModelForCausalLM.forward = PeftModel_fast_forwardfix_prepare_inputs_for_generation(Qwen3ForCausalLM)# Solves https://github.com/unslothai/unsloth/issues/168diff --git a/unsloth/models/qwen3_moe.py b/unsloth/models/qwen3_moe.pyindex 319e3bffe3c..b62a742d98d 100644--- a/unsloth/models/qwen3_moe.py+++ b/unsloth/models/qwen3_moe.py@@ -177,7 +177,7 @@ class FastQwen3MoeModel(FastQwen3Model):Qwen3MoeDecoderLayer .forward = Qwen3MoeDecoderLayer_fast_forwardQwen3MoeModel .forward = LlamaModel_fast_forwardQwen3MoeForCausalLM .forward = CausalLM_fast_forward(LlamaModel_fast_forward_inference)- PeftModelForCausalLM.forward = PeftModelForCausalLM_fast_forward+ PeftModelForCausalLM.forward = PeftModel_fast_forwardfix_prepare_inputs_for_generation(Qwen3MoeForCausalLM)# Solves https://github.com/unslothai/unsloth/issues/168