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 Han1f7001b5c3e6
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py
index 0f531dbadc4..c01e0ccc823 100644
--- a/unsloth/models/_utils.py
+++ b/unsloth/models/_utils.py
@@ -1050,7 +1050,10 @@ def _unsloth_pre_compute_loss(self, model, inputs, *args, **kwargs):
pass
pass
- if num_items_in_batch is None:
+ # Get gradient accumulation steps if possible
+ if num_items_in_batch is None and \
+ getattr(self, "args", {}).get("gradient_accumulation_steps", 1) != 1:
+
name = (model.base_model.model if hasattr(model, "base_model") else model).__class__.__name__
logger.warning_once(
f"Unsloth: Not an error, but {name} does not accept `num_items_in_batch`.\n"\