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.
This commit is contained in:
Daniel Han 2026-04-15 07:33:48 -07:00 committed by GitHub
commit 156f3fc4b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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