Skip to content

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.

Update _utils.py

Daniel Han163ef4318145
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py
index 386d71354d4..9bd3598b19a 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__ = "2024.12.12"
+__version__ = "2025.1.1"
__all__ = [
"prepare_model_for_kbit_training",
@@ -110,6 +110,9 @@ 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
@@ -557,6 +560,10 @@ def prepare_model_for_kbit_training(
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()
+ pass
+
return model
pass