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 rl_replacements.py

Daniel Hanb526f8b09157
diff --git a/unsloth/models/rl_replacements.py b/unsloth/models/rl_replacements.py
index 7de04b06059..ebc3549273e 100644
--- a/unsloth/models/rl_replacements.py
+++ b/unsloth/models/rl_replacements.py
@@ -333,7 +333,8 @@ def grpo_trainer_compute_loss(function_name, function):
if self.beta != 0.0:
with torch.inference_mode(), model.disable_adapter():
ref_per_token_logps = self._get_per_token_logps(model, input_ids, attention_mask, logits_to_keep)
- print("ref_per_token_logps Unsloth 320", ref_per_token_logps.shape)
+ if ref_per_token_logps is not None:
+ print("ref_per_token_logps Unsloth 320", ref_per_token_logps.shape)
else:
ref_per_token_logps = None
# per_token_kl = torch.exp(ref_per_token_logps - per_token_logps) - (ref_per_token_logps - per_token_logps) - 1