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 Han74463e92d947
diff --git a/unsloth/models/rl_replacements.py b/unsloth/models/rl_replacements.pyindex 53ec6e6cde9..77d7e6a5302 100644--- a/unsloth/models/rl_replacements.py+++ b/unsloth/models/rl_replacements.py@@ -216,7 +216,8 @@ def grpo_trainer_compute_loss(function_name, function):# attention_mask = torch.cat([prompt_mask, completion_mask], dim=1)attention_mask = Nonelogits_to_keep = completion_ids.size(1) # we only need to compute the logits for the completion tokens-+ _input_ids = input_ids+ _logits_to_keep = logits_to_keepper_token_logps = self._get_per_token_logps(model, input_ids, attention_mask, logits_to_keep)# Compute the KL divergence between the model and the reference model@@ -238,8 +239,8 @@ def grpo_trainer_compute_loss(function_name, function):if RL_REPLACEMENTS["count"] == 10: raiseelse: RL_REPLACEMENTS["count"] = 1RL_REPLACEMENTS["data"] = (- ref_per_token_logps, per_token_logps, input_ids, completion_mask, self.beta, advantages,- loss, completion_length, mean_kl, completion_ids,+ ref_per_token_logps, per_token_logps, _input_ids, completion_mask, self.beta, advantages,+ loss, completion_length, mean_kl, completion_ids, _logits_to_keep,)# Log the metrics# completion_length = self.accelerator.gather_for_metrics(completion_mask.sum(1)).float().mean().item()