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.

Update loader.py

Daniel Han87c643cb4267
diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py
index b4639f27b14..de25ec0b519 100644
--- a/unsloth/models/loader.py
+++ b/unsloth/models/loader.py
@@ -518,9 +518,12 @@ class FastModel(FastBaseModel):
if not was_disabled: enable_progress_bars()
do_logging = os.environ.get("UNSLOTH_ENABLE_LOGGING", "0") == "1"
- redirector = sys.stdout if do_logging else open(os.devnull, "w")
+ if do_logging:
+ redirector = contextlib.redirect_stdout(open(os.devnull, "w"))
+ else:
+ redirector = contextlib.nullcontext()
- with contextlib.redirect_stdout(redirector):
+ with redirector:
patch_loss_functions(torch_compile = False)
model_types = unsloth_compile_transformers(
model_name = model_name,