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 Han121785dd239c
diff --git a/unsloth/models/rl.py b/unsloth/models/rl.py
index 664fe10c4fc..deb779588cc 100644
--- a/unsloth/models/rl.py
+++ b/unsloth/models/rl.py
@@ -702,13 +702,16 @@ def patch_functions(RLTrainer, trainer_file, RLTrainer_name, all_imports, import
)
pass
-
# Remove peft_config
init = init.replace("elif peft_config is None:", "elif False:")
init = init.replace("elif peft_config is not None:", "elif False:")
init = init.replace("if peft_config is None:", "if False:")
init = init.replace("if peft_config is not None:", "if False:")
init = init.replace("get_peft_model(model, peft_config)", "model")
+ # New TRL 0.20.0
+ init = init.replace("if peft_config is not None or (is_peft_available() and isinstance(model, PeftModel)):", "if False:")
+ # New TRL 0.20.0
+ init = init.replace("model = self._prepare_peft_model(model, peft_config, args)\n", "pass\n")
# Set use_vllm if not set
if "args.use_vllm" in init and "model" in init and "args" in init: