Skip to content

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.

Update rl.py

Daniel Handa966a4e1c22
diff --git a/unsloth/models/rl.py b/unsloth/models/rl.py
index c7d3ab2c208..e8d9c19a543 100644
--- a/unsloth/models/rl.py
+++ b/unsloth/models/rl.py
@@ -256,6 +256,7 @@ pass
def _patch_trl_rl_trainers(trainer_file = "grpo_trainer"):
# Patch for vLLM and Unsloth PEFT
+ import trl
import trl.trainer
trainer = eval(f"trl.trainer.{trainer_file}")
@@ -388,6 +389,7 @@ def _patch_trl_rl_trainers(trainer_file = "grpo_trainer"):
exec(RLTrainer_source, imported_functions, globals())
exec(f"trl.trainer.{trainer_file}.{RLTrainer_name} = Unsloth{RLTrainer_name}", locals(), globals())
exec(f"trl.trainer.{RLTrainer_name} = Unsloth{RLTrainer_name}", locals(), globals())
+ exec(f"trl.{RLTrainer_name} = Unsloth{RLTrainer_name}", locals(), globals())
pass