From 7ceebe455470ffe5138e55b65af2f94b600b99d7 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Thu, 5 Feb 2026 05:32:52 -0800 Subject: [PATCH] Silence non-actionable TRL trainer import failures (#3980) _patch_trl_rl_trainers enumerates all trainer modules from dir(trl.trainer) and attempts to import each one. Modules like alignprop_trainer fail because they depend on optional packages (diffusers) that may not be installed. The failure is harmless but the print() call produces noise on every import. Change print() to logger.info() so these messages only appear when UNSLOTH_ENABLE_LOGGING=1. Co-authored-by: Daniel Han --- unsloth/models/rl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 unsloth/models/rl.py diff --git a/unsloth/models/rl.py b/unsloth/models/rl.py old mode 100644 new mode 100755 index 3776752f4b..eacfecc6c3 --- a/unsloth/models/rl.py +++ b/unsloth/models/rl.py @@ -420,7 +420,7 @@ def _patch_trl_rl_trainers(trainer_file = "grpo_trainer"): try: trainer = eval(f"trl.trainer.{trainer_file}") except Exception as error: - print(f"Unsloth: Could not import trl.trainer.{trainer_file}: {error}") + logger.info(f"Unsloth: Could not import trl.trainer.{trainer_file}: {error}") return # Get SFTTrainer and SFTConfig names