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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Update rl.py
Daniel Hanbe18ce5db950
diff --git a/unsloth/models/rl.py b/unsloth/models/rl.pyindex 50f97955881..c4122f7aaea 100644--- a/unsloth/models/rl.py+++ b/unsloth/models/rl.py@@ -107,18 +107,21 @@ passdef _patch_trl_rl_trainers(trainer_file = "grpo_trainer"):# Patch for vLLM and Unsloth PEFT+ print(1)import trlimport trl.trainertry:trainer = eval(f"trl.trainer.{trainer_file}")except Exception as error:return+ print(2)# Get SFTTrainer and SFTConfig namesname = [x for x in dir(trainer) if x.endswith("Trainer") and x != "Trainer" and trainer_file.split("_")[0] in x.lower()]config = [x for x in dir(trainer) if x.endswith("Config") and x != "Config" and trainer_file.split("_")[0] in x.lower()]if len(name) != 1: returnif len(config) != 1: return+ print(3)# Get SFTTrainer, SFTConfigRLTrainer_name = name[0]@@ -127,6 +130,7 @@ def _patch_trl_rl_trainers(trainer_file = "grpo_trainer"):except: returntry: RLConfig = eval(f"trl.trainer.{trainer_file}.{RLConfig_name}" )except: return+ print(4)# Check nameif RLTrainer.__name__.startswith("Unsloth"): return@@ -134,6 +138,7 @@ def _patch_trl_rl_trainers(trainer_file = "grpo_trainer"):all_imports = dir(trainer)imports = [x for x in all_imports if not x.startswith("_")]+ print(5)# Get default argumentsEMPTY = inspect.Parameter.empty@@ -157,6 +162,7 @@ def _patch_trl_rl_trainers(trainer_file = "grpo_trainer"):call_args = f"\n{' '*12}" + f",\n{' '*12}".join(call_args)processed.append((arguments, call_args,))pass+ print(6)# Process RLTrainer firstarguments, call_args = processed[0]@@ -274,11 +280,13 @@ def _patch_trl_rl_trainers(trainer_file = "grpo_trainer"):RLTrainer_extras = patch_vllm(trainer_file, RLTrainer_name, all_imports, imports)if RLTrainer_extras is None:RLTrainer_extras = f"_Unsloth{RLTrainer_name} = {RLTrainer_name}"+ print(7)# Create full moduleexec(f"from trl.trainer import ({RLTrainer_name}, {RLConfig_name},)")__RLTrainer_doc__ = eval(f"trl.trainer.{RLTrainer_name}").__doc____RLConfig_doc__ = eval(f"trl.trainer.{RLConfig_name}") .__doc__+ print(8)RLTrainer_source = RLTrainer_replacement.format(RLTrainer_name = RLTrainer_name,@@ -295,7 +303,6 @@ def _patch_trl_rl_trainers(trainer_file = "grpo_trainer"):RLTrainer_extras = RLTrainer_extras,)- print(RLTrainer_source)# Create new functioncreated_module = create_new_function(@@ -304,6 +311,7 @@ def _patch_trl_rl_trainers(trainer_file = "grpo_trainer"):f"trl.trainer.{trainer_file}",imports,)+ print(9)# Patch Trainerexec(f"trl.{RLTrainer_name} = created_module.Unsloth{RLTrainer_name}", locals(), globals())