Skip to content

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.

Gate trl disable_gradient_checkpointing patch warning on UNSLOTH_ENABLE_LOGGING (#5038)

Daniel Han156f3fc4b07c
diff --git a/unsloth/models/rl.py b/unsloth/models/rl.py
index f444f6bd373..ac9b35a8221 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