From 5f22141a052b95bb354f70b6ee79413f7d57fab2 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Thu, 6 Feb 2025 01:16:43 -0800 Subject: [PATCH] Update rl.py --- unsloth/models/rl.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/unsloth/models/rl.py b/unsloth/models/rl.py index 071818a7ae..b48f9eeee0 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)