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
Gemma 3N (#2809)
Daniel Hane49e2e13f00d
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.pyindex 34a61e250d4..9bd0fc17ad0 100644--- a/unsloth/models/_utils.py+++ b/unsloth/models/_utils.py@@ -12,7 +12,7 @@# See the License for the specific language governing permissions and# limitations under the License.-__version__ = "2025.6.6"+__version__ = "2025.6.7"__all__ = ["SUPPORTS_BFLOAT16",diff --git a/unsloth/models/loader.py b/unsloth/models/loader.pyindex 8a490269849..184be835391 100644--- a/unsloth/models/loader.py+++ b/unsloth/models/loader.py@@ -48,14 +48,15 @@ import importlib.util# https://github.com/huggingface/transformers/pull/26037 allows 4 bit loading!from unsloth_zoo.utils import Version, _get_dtypetransformers_version = Version(transformers_version)-SUPPORTS_FOURBIT = transformers_version >= Version("4.37")-SUPPORTS_GEMMA = transformers_version >= Version("4.38")-SUPPORTS_GEMMA2 = transformers_version >= Version("4.42")-SUPPORTS_LLAMA31 = transformers_version >= Version("4.43.2")-SUPPORTS_LLAMA32 = transformers_version > Version("4.45.0")-SUPPORTS_GRANITE = transformers_version >= Version("4.46.0")-SUPPORTS_QWEN3 = transformers_version >= Version("4.50.3")+SUPPORTS_FOURBIT = transformers_version >= Version("4.37")+SUPPORTS_GEMMA = transformers_version >= Version("4.38")+SUPPORTS_GEMMA2 = transformers_version >= Version("4.42")+SUPPORTS_LLAMA31 = transformers_version >= Version("4.43.2")+SUPPORTS_LLAMA32 = transformers_version > Version("4.45.0")+SUPPORTS_GRANITE = transformers_version >= Version("4.46.0")+SUPPORTS_QWEN3 = transformers_version >= Version("4.50.3")SUPPORTS_QWEN3_MOE = transformers_version >= Version("4.50.3")+SUPPORTS_GEMMA3N = transformers_version >= Version("4.53.0")if SUPPORTS_GEMMA:from .gemma import FastGemmaModelif SUPPORTS_GEMMA2:@@ -543,6 +544,8 @@ class FastModel(FastBaseModel):os.environ["UNSLOTH_FORCE_CUSTOM_DTYPE"] = "torch.float16;if name.endswith(('_proj', 'fc1', 'fc2', 'codebook', 'head')): module.to(torch.float16)"elif "olmo-2" in lowered_model_name and transformers_version < Version("4.50.0.dev0"):raise RuntimeError("Unsloth: OLMo-2 only works on transformers >= 4.50.0." + NIGHTLY)+ elif "gemma-3n" in lowered_model_name and transformers_version < Version("4.53.0"):+ raise RuntimeError("Unsloth: Gemma 3N only works on transformers >= 4.53.0" + LATEST)else:for check_model_name in DISABLE_COMPILE_MODEL_NAMES:if check_model_name in lowered_model_name:@@ -727,6 +730,10 @@ class FastModel(FastBaseModel):unsloth_force_compile = unsloth_force_compile,)pass+ # Fix SDPA+ if "gemma-3n" in lowered_model_name:+ supports_sdpa = False+ pass# Check if this is local model since the tokenizer gets overwrittenif os.path.exists(os.path.join(old_model_name, "tokenizer_config.json")) and \diff --git a/unsloth/models/mapper.py b/unsloth/models/mapper.pyindex fdf95691a90..62259841c5c 100644--- a/unsloth/models/mapper.py+++ b/unsloth/models/mapper.py@@ -879,6 +879,26 @@ __INT_TO_FLOAT_MAPPER = \"mistralai/Mistral-Small-3.2-24B-Instruct-2506","unsloth/Mistral-Small-3.2-24B-Instruct-2506-bnb-4bit",),+ "unsloth/gemma-3n-E4B-it-unsloth-bnb-4bit" : (+ "unsloth/gemma-3n-E4B-it",+ "google/gemma-3n-E4B-it",+ "unsloth/gemma-3n-E4B-it-unsloth-bnb-4bit",+ ),+ "unsloth/gemma-3n-E2B-it-unsloth-bnb-4bit" : (+ "unsloth/gemma-3n-E2B-it",+ "google/gemma-3n-E2B-it",+ "unsloth/gemma-3n-E2B-it-unsloth-bnb-4bit",+ ),+ "unsloth/gemma-3n-E4B-unsloth-bnb-4bit" : (+ "unsloth/gemma-3n-E4B",+ "google/gemma-3n-E4B",+ "unsloth/gemma-3n-E4B-unsloth-bnb-4bit",+ ),+ "unsloth/gemma-3n-E2B-unsloth-bnb-4bit" : (+ "unsloth/gemma-3n-E2B",+ "google/gemma-3n-E2B",+ "unsloth/gemma-3n-E2B-unsloth-bnb-4bit",+ ),}INT_TO_FLOAT_MAPPER = {}