Repository navigation
Fix offline training/export: avoid network calls in pre-flight checks and export - #6861
InfoSage05 wants to merge 2 commits into
Conversation
… and export Studio makes network calls during training/export even when offline or HF_HUB_OFFLINE=1 is set, causing hangs and crashes with DNS errors. Fixes: - Wrap export handler with offline window so save_pretrained_gguf etc. don't trigger Hub calls via transformers tokenizer init -> model_info - Skip RAG embedder warmup when HF_HUB_OFFLINE/TRANSFORMERS_OFFLINE is set - Guard SentenceTransformer load with HF_HUB_OFFLINE=1 when offline - is_embedding_model(): check _env_offline() before hf_model_info() - _get_model_size_bytes(): check offline before HfApi.repo_info() - detect_gguf_model_remote(): catch connection/DNS/timeout errors and fall back to local cache immediately instead of retrying 3 times Fixes unslothai#6817
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Thanks, this targets the right issue, but it needs an update before merge. The PR is currently conflicting with main, and the RAG changes are stale versus newer security code. Please rebase, preserve existing offline env vars instead of popping them, ensure explicit offline mode makes zero Hub metadata calls, and add focused tests for these offline short-circuits. |
Credit InfoSage05 for the original unslothai#6861 fix direction and affected call-site analysis. Co-authored-by: Ayushman <[email protected]>
Credit InfoSage05 for the original unslothai#6861 fix direction and affected call-site analysis. Co-authored-by: Ayushman <[email protected]>
|
Confirmed the gap is still real in studio/backend/core/export/worker.py:678 where the export handler runs outside any offline window, and in routes/models.py:2047 where the size lookup always hits the Hub. Main has since reworked the RAG embedder load and is_embedding_model to use the local cache, so could you rebase and narrow this to just those two call sites, keeping any offline env vars the user already set? |
|
The export path in studio/backend/core/export/worker.py and the size lookup in routes/models.py still reach the Hub offline on main, but the RAG embedder hunks are stale and pop offline env vars the user set. Could you rebase and narrow this to just those two call sites, as asked earlier? |
|
Thank you for the PR and for the detailed write-up of #6817! Closing this as superseded: every part of it has since landed on main through other PRs, and #6817 is closed.
The related tokenizer |
Description
Fixes #6817
Unsloth Studio makes several network calls during training pre-flight checks, export, and startup that ignore
HF_HUB_OFFLINE/TRANSFORMERS_OFFLINE, causing hangs and crashes when running without internet.What was broken
Export (GGUF/merged/lora) — the export handler had no offline protection.
save_pretrained_gguftriggers transformers'_patch_mistral_regex→is_base_mistral()→model_info()which makes a hidden network call and crashes withRuntimeError: Unsloth: The tokenizer is weirdly not loaded?RAG embedder warmup — the daemon thread loaded
unsloth/bge-small-en-v1.5viaSentenceTransformermaking HEAD requests even withHF_HUB_OFFLINE=1. Retried 5x per file causing massive startup delays.is_embedding_model()— calledhf_model_info()with no offline check, generatingCould not determine if X is embedding modelwarnings._get_model_size_bytes()— calledHfApi.repo_info()with no offline check, generatingCould not get model size for Xwarnings.detect_gguf_model_remote()— checked_env_offline()then fell back to cache (good), but when cache lookup returned None it fell into 3 network retries with 1s/2s/4s backoff instead of returning immediately.What was fixed
core/export/worker.py_offline_window_if_unreachable(setsHF_HUB_OFFLINE=1+ in-process flags + session reset)main.py_warm_rag_embedder()whenHF_HUB_OFFLINE/TRANSFORMERS_OFFLINEis setcore/rag/embeddings.pySentenceTransformerload withHF_HUB_OFFLINE=1/TRANSFORMERS_OFFLINE=1when offline env vars are setutils/models/model_config.pyis_embedding_model(): check_env_offline()beforehf_model_info()utils/models/model_config.pydetect_gguf_model_remote(): catch connection/DNS/timeout errors and break retry loop immediatelyroutes/models.py_get_model_size_bytes(): returnNoneimmediately when offlineAll fixes follow the pattern already established by
_env_offline()checks in sibling functions (e.g.detect_gguf_model_remote, GGUF variant listing) — it was just never applied to these call sites.