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
Detach logits before returning from function (#3554)
pluesclues91db85048897
diff --git a/unsloth/models/rl_replacements.py b/unsloth/models/rl_replacements.pyindex 281e3a71df2..6584e2a426a 100644--- a/unsloth/models/rl_replacements.py+++ b/unsloth/models/rl_replacements.py@@ -510,7 +510,7 @@ def grpo_trainer__get_per_token_logps_and_entropies(function_name, function):os.environ["UNSLOTH_RETURN_HIDDEN_STATES"] = "0"# logits = logits[:, :-1, :] # (B, L-1, V), exclude the last logit: it corresponds to the next token pred- return logits, entropies # logps, entropies+ return logits.detach(), entropies # logps, entropies# input_ids = input_ids[:, -logits_to_keep:]# For transformers<=4.48, logits_to_keep argument isn't supported, so here we drop logits ourselves.# See https://github.com/huggingface/trl/issues/2770