From 156f3fc4b07c7a306822d6ef82208dc9d127463f Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Wed, 15 Apr 2026 07:33:48 -0700 Subject: [PATCH] Gate trl disable_gradient_checkpointing patch warning on UNSLOTH_ENABLE_LOGGING (#5038) The "Patched trl.models.utils.disable_gradient_checkpointing with a no-op" warning fires once on every Unsloth import, including from notebooks where the user did not opt into verbose logging. It is a routine integration patch, not an anomaly the user needs to know about. Gate it on UNSLOTH_ENABLE_LOGGING=1 like other diagnostic notices. --- unsloth/models/rl.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/unsloth/models/rl.py b/unsloth/models/rl.py index f444f6bd37..ac9b35a822 100755 --- a/unsloth/models/rl.py +++ b/unsloth/models/rl.py @@ -2018,11 +2018,12 @@ def patch_trl_disable_gradient_checkpointing(): except (AttributeError, TypeError): pass - logger.warning_once( - "Unsloth: Patched trl.models.utils.disable_gradient_checkpointing with " - "a no-op to preserve Unsloth gradient checkpointing across TRL " - "generation passes." - ) + if os.environ.get("UNSLOTH_ENABLE_LOGGING", "0") == "1": + logger.warning_once( + "Unsloth: Patched trl.models.utils.disable_gradient_checkpointing with " + "a no-op to preserve Unsloth gradient checkpointing across TRL " + "generation passes." + ) return