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
requires grad
Daniel Han75ffad921fa1
diff --git a/unsloth/__init__.py b/unsloth/__init__.pyindex 90d2a63519b..bbeded9fc69 100644--- a/unsloth/__init__.py+++ b/unsloth/__init__.py@@ -17,16 +17,6 @@ from packaging.version import Versionimport os, re, subprocess, inspectimport numpy as np-# # Define a list of modules to check-# MODULES_TO_CHECK = ["bitsandbytes"]--# # Check if any of the modules in the list have been imported-# for module in MODULES_TO_CHECK:-# if module in sys.modules:-# raise ImportError(f"Unsloth: Please import Unsloth before {module}.")-# pass-# pass-# Unsloth currently does not work on multi GPU setups - sadly we are a 2 brother team so# enabling it will require much more work, so we have to prioritize. Please understand!# We do have a beta version, which you can contact us about!@@ -201,9 +191,18 @@ pass# Check for unsloth_zootry:+ unsloth_zoo_version = importlib_version("unsloth_zoo")+ if Version(unsloth_zoo_version) < Version("2025.1.1"):+ try:+ os.system("pip install --upgrade --no-cache-dir --no-deps unsloth_zoo")+ except:+ try:+ os.system("pip install --upgrade --no-cache-dir --no-deps --user unsloth_zoo")+ except:+ raise ImportError("Unsloth: Please update unsloth_zoo via `pip install --upgrade --no-cache-dir --no-deps unsloth_zoo`")import unsloth_zooexcept:- raise ImportError("Unsloth: Please install unsloth_zoo via `pip install unsloth-zoo`")+ raise ImportError("Unsloth: Please install unsloth_zoo via `pip install unsloth_zoo`")passfrom .models import *diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.pyindex 33fb36e8b60..098f5c3e475 100644--- a/unsloth/models/_utils.py+++ b/unsloth/models/_utils.py@@ -110,9 +110,6 @@ from unsloth_zoo.compiler import (get_transformers_model_type,unsloth_compile_transformers as _unsloth_compile_transformers,)-from unsloth_zoo.peft_utils import (- requires_grad_for_gradient_checkpointing,-)# =============================================# Disable some warnings which can get annoying@@ -559,9 +556,6 @@ def prepare_model_for_kbit_training(def make_inputs_require_grad(module, input, output):output.requires_grad_(True)model.get_input_embeddings().register_forward_hook(make_inputs_require_grad)-- # Enable grads on non language models as well- requires_grad_for_gradient_checkpointing(model)passreturn modeldiff --git a/unsloth/models/vision.py b/unsloth/models/vision.pyindex 2dc4b88dfab..51450aa0d93 100644--- a/unsloth/models/vision.py+++ b/unsloth/models/vision.py@@ -30,6 +30,7 @@ from transformers import set_seed as transformers_set_seedfrom unsloth_zoo.peft_utils import (get_peft_regex,SKIP_QUANTIZATION_MODULES,+ requires_grad_for_gradient_checkpointing,)from triton import __version__ as triton_version@@ -275,6 +276,8 @@ class FastBaseVisionModel:use_gradient_checkpointing = use_gradient_checkpointing,)model = get_peft_model(model, lora_config)+ # Enable gradients on modules which are trainable+ requires_grad_for_gradient_checkpointing(model)model = FastBaseVisionModel.patch_peft_model(model, use_gradient_checkpointing)