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
Restore UNSLOTH_RETURN_LOGITS after prediction_step instead of forcing 0 (#6239)
Daniel Hanb1cc76d1e131
diff --git a/unsloth/models/rl.py b/unsloth/models/rl.pyindex c5a7f1c881a..b44eaa31b2b 100644--- a/unsloth/models/rl.py+++ b/unsloth/models/rl.py@@ -278,6 +278,9 @@ def PatchRL(FastLanguageModel):else:labels = None+ # Force logits during eval, but restore the user's prior setting after+ # so an explicit UNSLOTH_RETURN_LOGITS="1" is not silently turned off.+ _old_return_logits = os.environ.get("UNSLOTH_RETURN_LOGITS", "0")os.environ["UNSLOTH_RETURN_LOGITS"] = "1"with torch.no_grad():if has_labels or loss_without_labels:@@ -317,7 +320,7 @@ def PatchRL(FastLanguageModel):# TODO: this needs to be fixed and made cleaner later.if self.args.past_index >= 0:self._past = outputs[self.args.past_index - 1]- os.environ["UNSLOTH_RETURN_LOGITS"] = "0"+ os.environ["UNSLOTH_RETURN_LOGITS"] = _old_return_logitsif prediction_loss_only:return (loss, None, None)