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
Update rl_replacements.py
Daniel Han0815525b152c
diff --git a/unsloth/models/rl_replacements.py b/unsloth/models/rl_replacements.pyindex df95f73fc5f..e343a2ec70f 100644--- a/unsloth/models/rl_replacements.py+++ b/unsloth/models/rl_replacements.py@@ -320,12 +320,16 @@ def grpo_trainer_compute_loss(function_name, function):# _prepare_inputs doesn't return reference log probs anymore. We need to calculate it ourselves.# https://github.com/huggingface/trl/blob/05bc43e960396581e458195b8388efe6b82cae1f/trl/trainer/grpo_trainer.py#L1328if self.beta != 0.0:+ print("!!!!!!!!!!")+ print("!!!!!!!!!!")with torch.inference_mode(), model.disable_adapter():ref_per_token_logps = self._get_per_token_logps(model, input_ids, attention_mask, logits_to_keep)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-+ print("!!!!!!!!!!")+ print("!!!!!!!!!!")+ print(ref_per_token_logps)# x - x.detach() allows for preserving gradients from xadvantages = inputs["advantages"]# per_token_loss = torch.exp(per_token_logps - per_token_logps.detach()) * advantages.unsqueeze(1)