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 Hane20efe32a3c4
diff --git a/unsloth/models/rl.py b/unsloth/models/rl.py
index 071818a7ae0..b48f9eeee08 100644
--- a/unsloth/models/rl.py
+++ b/unsloth/models/rl.py
@@ -271,6 +271,7 @@ def _patch_trl_rl_trainers(trainer_file = "grpo_trainer"):
return
all_imports = dir(trainer)
imports = [x for x in all_imports if not x.startswith("_") and x in __init__]
+ imports += ["Trainer"]
spaces = __init__.find("def")
__init__ = __init__.split("\n")
@@ -316,6 +317,9 @@ def _patch_trl_rl_trainers(trainer_file = "grpo_trainer"):
__init__ = __init__.replace("if peft_config is not None:", "if False:")
__init__ = __init__.replace("get_peft_model(model, peft_config)", "model")
+ # Change super() to Trainer
+ __init__ = __init__.replace("super()", "super(Trainer, self)")
+
# Search for vLLM calling in all child functions
functions = dir(RLTrainer)
RLTrainer_source = inspect.getsource(RLTrainer)