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
Fix missing num_items_in_batch in unsloth_prediction_step (#4616)
Daniel Han6b5da2ea0f96
diff --git a/unsloth/models/rl.py b/unsloth/models/rl.pyindex 581244e4d33..5651a7da413 100755--- a/unsloth/models/rl.py+++ b/unsloth/models/rl.py@@ -273,8 +273,17 @@ def PatchRL(FastLanguageModel):with torch.no_grad():if has_labels or loss_without_labels:with self.compute_loss_context_manager():+ try:+ num_items_in_batch = self._get_num_items_in_batch(+ [inputs], self.args.device+ )+ except (AttributeError, TypeError):+ num_items_in_batch = Noneloss, outputs = self.compute_loss(- model, inputs, return_outputs = True+ model,+ inputs,+ return_outputs = True,+ num_items_in_batch = num_items_in_batch,)loss = loss.mean().detach()