Update rl.py

This commit is contained in:
Daniel Han 2025-07-29 01:32:39 -07:00
commit 121785dd23

View file

@ -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: