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 Han734c5338dc00
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py
index 4f1b40884ab..e508c96b0ef 100644
--- a/unsloth/models/_utils.py
+++ b/unsloth/models/_utils.py
@@ -1104,7 +1104,7 @@ def patch_gradient_accumulation_fix(Trainer):
"else:\n"\
"\2if num_items_in_batch is None:\n"\
- "\3loss /= self.args.gradient_accumulation_steps\n"\
+ "\3loss = loss / self.args.gradient_accumulation_steps\n"\
"\1self.accelerator.backward(loss, **kwargs)",
function,