From 02237cd1461b475687567050bef3eadf3c05fca2 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Tue, 29 Jul 2025 01:32:39 -0700 Subject: [PATCH] Update rl.py --- unsloth/models/rl.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unsloth/models/rl.py b/unsloth/models/rl.py index 664fe10c4f..deb779588c 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: