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.

fix_huggingface_hub

Daniel Han8d44bd35d389
diff --git a/unsloth/__init__.py b/unsloth/__init__.py
index d10a0f80303..c74b248a830 100644
--- a/unsloth/__init__.py
+++ b/unsloth/__init__.py
@@ -30,16 +30,19 @@ from .import_fixes import (
check_fbgemm_gpu_version,
torchvision_compatibility_check,
fix_diffusers_warnings,
+ fix_huggingface_hub,
)
fix_message_factory_issue()
check_fbgemm_gpu_version()
torchvision_compatibility_check()
fix_diffusers_warnings()
+fix_huggingface_hub()
del fix_message_factory_issue
del check_fbgemm_gpu_version
del torchvision_compatibility_check
del fix_diffusers_warnings
+del fix_huggingface_hub
# This check is critical because Unsloth optimizes these libraries by modifying
# their code at import time. If they're imported first, the original (slower,
diff --git a/unsloth/import_fixes.py b/unsloth/import_fixes.py
index efc7a7f4cd7..f388f4ea8df 100644
--- a/unsloth/import_fixes.py
+++ b/unsloth/import_fixes.py
@@ -539,3 +539,10 @@ def fix_executorch():
def fix_diffusers_warnings():
# Silence Flax classes are deprecated and will be removed in Diffusers v1.0.0.
os.environ["DIFFUSERS_VERBOSITY"] = "error"
+
+
+def fix_huggingface_hub():
+ # huggingface_hub.is_offline_mode got removed, so add it back
+ import huggingface_hub
+ if not hasattr(huggingface_hub, "is_offline_mode"):
+ huggingface_hub.is_offline_mode = lambda: huggingface_hub.constants.HF_HUB_OFFLINE