From 580842de0bd2da2129df4033c8ce8ccc1d2f0d95 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Wed, 25 Jun 2025 19:51:43 -0700 Subject: [PATCH] Update rl_replacements.py --- unsloth/models/rl_replacements.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/unsloth/models/rl_replacements.py b/unsloth/models/rl_replacements.py index 585545be15..7de04b0605 100644 --- a/unsloth/models/rl_replacements.py +++ b/unsloth/models/rl_replacements.py @@ -324,7 +324,8 @@ def grpo_trainer_compute_loss(function_name, function): print("logits_to_keep Unsloth 320", logits_to_keep) per_token_logps = self._get_per_token_logps(model, input_ids, attention_mask, logits_to_keep) - print("per_token_logps Unsloth 320", per_token_logps.shape) + if per_token_logps is not None: + print("per_token_logps Unsloth 320", per_token_logps.shape) # Compute the KL divergence between the model and the reference model # _prepare_inputs doesn't return reference log probs anymore. We need to calculate it ourselves.