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.py
Daniel Han10c359f231ab
diff --git a/unsloth/models/rl.py b/unsloth/models/rl.pyindex 1ac511e8334..128725a0a95 100644--- a/unsloth/models/rl.py+++ b/unsloth/models/rl.py@@ -86,7 +86,7 @@ pass# https://github.com/huggingface/trl/blob/main/trl/trainer/utils.py#L1674@torch.compile(dynamic = True, fullgraph = True, options = torch_compile_options,)-def _selective_log_softmax(logits, index):+def selective_log_softmax(logits, index):logits = logits.to(torch.float32)selected_logits = torch.gather(logits, dim=-1, index=index.unsqueeze(-1)).squeeze(-1)# loop to reduce peak mem consumption@@ -96,10 +96,6 @@ def _selective_log_softmax(logits, index):return per_token_logpspass-def selective_log_softmax(logits, index):- return _selective_log_softmax(logits, index)-pass-RLTrainer_replacement = '''import os@@ -423,10 +419,8 @@ def _patch_trl_rl_trainers(trainer_file = "grpo_trainer"):pass# Selective log softmax- selective_log_softmax_code = \- inspect.getsource(_selective_log_softmax) + "\n" + \- inspect.getsource(selective_log_softmax) + "\n"-+ selective_log_softmax_code = inspect.getsource(selective_log_softmax)+# Get final source codeRLTrainer_source = RLTrainer_replacement.format(RLTrainer_name = RLTrainer_name,