From 6a8ebbac92e815c35febb81d283a82e02f506a98 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Wed, 25 Jun 2025 20:13:17 -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 7de04b0605..ebc3549273 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