diff --git a/README.md b/README.md
index f8944c5a77..2b8e79f021 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@
-### Finetune Llama 3.1, Mistral, Phi-3.5 & Gemma 2-5x faster with 80% less memory!
+### Finetune Llama 3.2, Mistral, Phi-3.5 & Gemma 2-5x faster with 80% less memory!

@@ -32,15 +32,17 @@ All notebooks are **beginner friendly**! Add your dataset, click "Run All", and
| **DPO Zephyr** | [▶️ Start for free](https://colab.research.google.com/drive/15vttTpzzVXv_tJwEk-hIcQ0S9FcEWvwP?usp=sharing) | 1.9x faster | 43% less |
- **Kaggle Notebooks** for [Llama 3.1 (8B)](https://www.kaggle.com/danielhanchen/kaggle-llama-3-1-8b-unsloth-notebook), [Gemma 2 (9B)](https://www.kaggle.com/code/danielhanchen/kaggle-gemma-7b-unsloth-notebook/), [Mistral (7B)](https://www.kaggle.com/code/danielhanchen/kaggle-mistral-7b-unsloth-notebook)
+- Run [Llama 3.2 1B 3B notebook](https://colab.research.google.com/drive/1hoHFpf7ROqk_oZHzxQdfPW9yvTxnvItq?usp=sharing) and [Llama 3.2 conversational notebook](https://colab.research.google.com/drive/1T5-zKWM_5OD21QHwXHiV9ixTRR7k3iB9?usp=sharing)
- Run [Llama 3.1 conversational notebook](https://colab.research.google.com/drive/15OyFkGoCImV9dSsewU1wa2JuKB4-mDE_?usp=sharing) and [Mistral v0.3 ChatML](https://colab.research.google.com/drive/15F1xyn8497_dUbxZP4zWmPZ3PJx1Oymv?usp=sharing)
- This [text completion notebook](https://colab.research.google.com/drive/1ef-tab5bhkvWmBOObepl1WgJvfvSzn5Q?usp=sharing) is for continued pretraining / raw text
- This [continued pretraining notebook](https://colab.research.google.com/drive/1tEd1FrOXWMnCU9UIvdYhs61tkxdMuKZu?usp=sharing) is for learning another language
- Click [here](https://github.com/unslothai/unsloth/wiki) for detailed documentation for Unsloth.
## 🦥 Unsloth.ai News
+- 📣 NEW! [Llama 3.2 Conversational notebook](https://colab.research.google.com/drive/1T5-zKWM_5OD21QHwXHiV9ixTRR7k3iB9?usp=sharing) includes training only on completions / outputs (increase accuracy), ShareGPT standardization and more!
+- 📣 NEW! [Llama 3.2 Kaggle notebook](https://www.kaggle.com/danielhanchen/kaggle-llama-3-2-1b-3b-unsloth-notebook) and [Llama 3.2 Kaggle conversational notebook](https://www.kaggle.com/code/danielhanchen/kaggle-llama-3-2-1b-3b-conversational-unsloth/notebook)
- 📣 NEW! [Qwen 2.5 7b notebook](https://colab.research.google.com/drive/1Kose-ucXO1IBaZq5BvbwWieuubP7hxvQ?usp=sharing) finetuning is supported! Qwen 2.5 comes in multiple sizes - check our [4bit uploads](https://huggingface.co/unsloth) for 4x faster downloads!. 14b fits in a Colab GPU! [Qwen 2.5 conversational notebook](https://colab.research.google.com/drive/1qN1CEalC70EO1wGKhNxs1go1W9So61R5?usp=sharing)
- 📣 NEW! [Mistral Small 22b notebook](https://colab.research.google.com/drive/1oCEHcED15DzL8xXGU1VTx5ZfOJM8WY01?usp=sharing) finetuning fits in under 16GB of VRAM!
-- 📣 NEW! [Llama 3.1 Conversational notebook](https://colab.research.google.com/drive/15OyFkGoCImV9dSsewU1wa2JuKB4-mDE_?usp=sharing) includes training only on completions / outputs (increase accuracy), ShareGPT standardization and more!
- 📣 NEW! [Phi-3.5 (mini)](https://colab.research.google.com/drive/1lN6hPQveB_mHSnTOYifygFcrO8C1bxq4?usp=sharing) now supported
- 📣 NEW! [Gemma-2-2b](https://colab.research.google.com/drive/1weTpKOjBZxZJ5PQ-Ql8i6ptAY2x-FWVA?usp=sharing) now supported! Try out [Chat interface](https://colab.research.google.com/drive/1i-8ESvtLRGNkkUQQr_-z_rcSAIo9c3lM?usp=sharing)!
- 📣 NEW! [Llama 3.1 8b, 70b](https://colab.research.google.com/drive/1Ys44kVvmeZtnICzWz0xgpRnrIOjZAuxp?usp=sharing) & [Mistral Nemo-12b](https://colab.research.google.com/drive/17d3U-CAIwzmbDRqbZ9NnpHxCkmXB6LZ0?usp=sharing) both Base and Instruct are now supported
diff --git a/pyproject.toml b/pyproject.toml
index b61908a690..59ef1b8aab 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -35,7 +35,7 @@ exclude = ["images*"]
huggingface = [
"packaging",
"tyro",
- "transformers>=4.43.2",
+ "transformers>=4.45.1",
"datasets>=2.16.0",
"sentencepiece>=0.2.0",
"tqdm",
@@ -212,7 +212,7 @@ colab-ampere-torch220 = [
colab-new = [
"packaging",
"tyro",
- "transformers>=4.43.2",
+ "transformers>=4.45.1",
"datasets>=2.16.0",
"sentencepiece>=0.2.0",
"tqdm",
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py
index af7e1eb293..309c0d913e 100644
--- a/unsloth/models/_utils.py
+++ b/unsloth/models/_utils.py
@@ -306,6 +306,14 @@ if Version(xformers_version) >= Version("0.0.27"):
accelerate_new_send_to_device = _fixed_send_to_device
pass
pass
+
+# Transformers 4.46 breaks dynamic caching. This is a hack
+import transformers.generation.configuration_utils
+if hasattr(transformers.generation.configuration_utils, "ALL_CACHE_IMPLEMENTATIONS"):
+ if type(transformers.generation.configuration_utils.ALL_CACHE_IMPLEMENTATIONS) is list:
+ transformers.generation.configuration_utils.ALL_CACHE_IMPLEMENTATIONS.append("dynamic")
+ pass
+pass
# =============================================
# =============================================
diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py
index f5dc02704e..a245330108 100644
--- a/unsloth/models/llama.py
+++ b/unsloth/models/llama.py
@@ -62,10 +62,7 @@ from peft.tuners.lora import Linear4bit as Peft_Linear4bit
from ..save import patch_saving_functions
import re, os, inspect, math, sys
from huggingface_hub.utils._token import get_token
-from transformers import __version__ as transformers_version
-from packaging.version import Version
-transformers_version = Version(transformers_version)
-SUPPORTS_LLAMA32 = transformers_version > Version("4.45.0")
+
def original_apply_qkv(self, X):
Q = self.q_proj(X)
@@ -1386,10 +1383,7 @@ def _wrap_fast_inference(generate, device_type, dtype, model):
pass
# For newer HF
- if SUPPORTS_LLAMA32:
- kwargs["cache_implementation"] = "hybrid"
- else:
- kwargs["cache_implementation"] = "dynamic"
+ kwargs["cache_implementation"] = "dynamic"
# For num_logits_to_keep
kwargs["num_logits_to_keep"] = 1
diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py
index ee1f680ace..0ac9b02743 100644
--- a/unsloth/models/loader.py
+++ b/unsloth/models/loader.py
@@ -138,17 +138,6 @@ def get_model_name(model_name, load_in_4bit = True):
pass
-LLAMA32_MODEL_NAMES = set((
- "unsloth/Llama-3.2-1B-bnb-4bit",
- "unsloth/Llama-3.2-3B-bnb-4bit",
- "unsloth/Llama-3.2-1B",
- "unsloth/Llama-3.2-3B",
- "unsloth/Llama-3.2-1B-Instruct-bnb-4bit",
- "unsloth/Llama-3.2-3B-Instruct-bnb-4bit",
- "unsloth/Llama-3.2-1B-Instruct",
- "unsloth/Llama-3.2-3B-Instruct",
-))
-
class FastLanguageModel(FastLlamaModel):
@staticmethod
def from_pretrained(
@@ -203,7 +192,7 @@ class FastLanguageModel(FastLlamaModel):
pass
# Cannot be both!
- if is_model and is_peft:
+ if (is_model and is_peft) and not SUPPORTS_LLAMA32:
raise RuntimeError(
"Unsloth: Your repo has a LoRA adapter and a base model.\n"\
"You have 2 files `config.json` and `adapter_config.json`.\n"\
@@ -255,14 +244,6 @@ class FastLanguageModel(FastLlamaModel):
f"to obtain the latest transformers build, then restart this session."\
)
- elif model_name.lower() in LLAMA32_MODEL_NAMES and not SUPPORTS_LLAMA32:
- raise ImportError(
- f"Unsloth: Your transformers version of {transformers_version} does not support Llama 3.2.\n"\
- f"The minimum required version is 4.46\n"\
- f'Try `pip install --upgrade "transformers>=4.46"`\n'\
- f"to obtain the latest transformers build, then restart this session."\
- )
-
dispatch_model = FastLlamaModel
elif model_type == "mistral": dispatch_model = FastMistralModel
diff --git a/unsloth/tokenizer_utils.py b/unsloth/tokenizer_utils.py
index 477d993e69..04690d3566 100644
--- a/unsloth/tokenizer_utils.py
+++ b/unsloth/tokenizer_utils.py
@@ -1180,11 +1180,6 @@ def patch_sft_trainer_tokenizer():
check_text = \
"\n"\
- "if self._inner_training_loop.__name__ != '_fast_inner_training_loop':\n"\
- " raise RuntimeError(\n"\
- " 'Please do not edit specific areas of the Unsloth codebase or you will get CUDA segfaults.'\n"\
- " )\n"\
- "pass\n"\
"import subprocess, re, gc, numpy as np\n"\
"a = np.array([0,])\n"\
"try:\n"\