From c84f8b700d7fe1bf797a7326210b197da435045f Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Thu, 6 Feb 2025 02:21:08 -0800 Subject: [PATCH] Update rl.py --- unsloth/models/rl.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/unsloth/models/rl.py b/unsloth/models/rl.py index d70a83f71d..fe1587f56b 100644 --- a/unsloth/models/rl.py +++ b/unsloth/models/rl.py @@ -388,6 +388,11 @@ def _patch_trl_rl_trainers(trainer_file = "grpo_trainer"): f"trl.trainer.{trainer_file}", imports, ) + + # Patch over modules + exec(f"trl.{RLTrainer_name} = module.Unsloth{RLTrainer_name}", locals(), globals()) + exec(f"trl.trainer.{RLTrainer_name} = module.Unsloth{RLTrainer_name}", locals(), globals()) + exec(f"trl.trainer.{trainer_file}.{RLTrainer_name} = module.Unsloth{RLTrainer_name}", locals(), globals()) return module pass