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 Han-Chen66874d99183a
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py
index 77509cd8dad..69e570dc9a5 100644
--- a/unsloth/models/_utils.py
+++ b/unsloth/models/_utils.py
@@ -96,7 +96,7 @@ def prepare_model_for_kbit_training(
# Freeze all parameters except LoRA
import re
- with torch.inference_mode():
+ with torch.no_grad():
for name, param in model.named_parameters():
if ".lora_A." in name or ".lora_B." in name or ".lora_magnitude_vector" in name:
param.requires_grad_(True)