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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
fix: prevent offline freeze by fixing stats retry and forwarding local_files_only (#5016)
David Solanas Sanz1fcb2502cf5c
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.pyindex 71f7db915c6..d0cd4ba028a 100644--- a/unsloth/models/_utils.py+++ b/unsloth/models/_utils.py@@ -1350,6 +1350,11 @@ import socketdef has_internet(host = "8.8.8.8", port = 53, timeout = 3):if os.environ.get("TRANSFORMERS_OFFLINE", "0") == "1":return False++ OFFLINE_TRUE = {"1", "true", "yes", "on"}++ if os.environ.get("HF_HUB_OFFLINE", "").strip().lower() in OFFLINE_TRUE:+ return Falsetry:socket.setdefaulttimeout(timeout)sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)@@ -1468,8 +1473,8 @@ def _get_statistics(statistics = None, force_download = True):"```")except Exception:- # Try no time limit check- stats_check()+ logger.debug("Unsloth: stats_check failed with an exception.")+ # Don't retry without a time limit — would freeze offlinedef get_statistics(local_files_only = False):diff --git a/unsloth/models/loader.py b/unsloth/models/loader.pyindex df97c5c7df1..a66a7c6abcd 100644--- a/unsloth/models/loader.py+++ b/unsloth/models/loader.py@@ -439,12 +439,15 @@ class FastLanguageModel(FastLlamaModel):peft_error = Nonemodel_config = Nonepeft_config = None+ local_files_only = kwargs.get("local_files_only", False)+try:model_config = AutoConfig.from_pretrained(model_name,token = token,revision = revision,trust_remote_code = trust_remote_code,+ local_files_only = local_files_only,)is_model = Trueexcept ImportError:@@ -470,6 +473,7 @@ class FastLanguageModel(FastLlamaModel):token = token,revision = revision,trust_remote_code = trust_remote_code,+ local_files_only = local_files_only,)is_peft = Trueexcept ImportError:@@ -566,6 +570,7 @@ class FastLanguageModel(FastLlamaModel):model_name,token = token,trust_remote_code = trust_remote_code,+ local_files_only = local_files_only,)if not was_disabled:@@ -1049,12 +1054,15 @@ class FastModel(FastBaseModel):peft_error = Nonemodel_config = Nonepeft_config = None+ local_files_only = kwargs.get("local_files_only", False)+try:model_config = AutoConfig.from_pretrained(model_name,token = token,revision = revision,trust_remote_code = trust_remote_code,+ local_files_only = local_files_only,)is_model = Trueexcept ImportError:@@ -1080,6 +1088,7 @@ class FastModel(FastBaseModel):token = token,revision = revision,trust_remote_code = trust_remote_code,+ local_files_only = local_files_only,)is_peft = Trueexcept ImportError:@@ -1330,6 +1339,7 @@ class FastModel(FastBaseModel):model_name,token = token,trust_remote_code = trust_remote_code,+ local_files_only = local_files_only,)if not was_disabled: