Repository navigation
fix(models): reliable model downloads and storage location on Windows - #1247
Open
procdeveloper wants to merge 5 commits into
Open
procdeveloper wants to merge 5 commits into
procdeveloper wants to merge 5 commits into
Conversation
…cate HF links on migration Picking a models folder before any model was downloaded called /models/migrate, which returned moved=0; the UI then showed "no models to migrate" and returned without saving the folder or restarting the server. The choice was silently discarded and every download kept going to the default HuggingFace cache (C:\Users\<user>\.cache\huggingface\hub on Windows). Now the new location is adopted even when there is nothing to move. The cross-filesystem migration path (e.g. C: -> D: on Windows) followed the snapshots/<rev>/* -> blobs/<hash> symlinks, so every model was written twice at the destination and the progress total double-counted. Symlinks inside the cache are now recreated (relative symlink, then NTFS hard link when symlinks are not permitted, then a plain copy as a last resort), and the size calculation skips links. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t each other Starting a second download while another model was loading (e.g. Whisper while Qwen TTS was downloading) made the first load fail with "Cannot copy out of meta tensor; no data!" and made progress bars jump between models. Every model download in voicebox is a load, and loads run on worker threads. transformers/accelerate build models inside init_empty_weights(), which replaces torch.nn.Module.register_parameter for the whole process, so layers another backend built at the same moment landed on the meta device. no_init_weights() and from_pretrained's default-dtype switch are global too. HFProgressTracker also patches the shared tqdm classes, so two concurrent downloads reported each other's bytes (jamiepine#708), and whichever finished first restored tqdm underneath the other. All backends load through model_load_progress, so serialize there with a process-wide re-entrant lock. A load that has to wait reports "Waiting for another model to finish loading..." instead of looking stuck. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ter each Download toasts opened one Server-Sent Events stream per active model. The webview allows only six HTTP connections per server, so with six or more downloads active (queued ones included) every other request stalled behind them: the model list stopped refreshing, the Download button appeared to do nothing, and dropped streams surfaced as "Failed to track download progress". The toasts now read the shared, polled ['activeTasks'] query instead, which costs one short request per second however many downloads are tracked. A download is no longer reported complete when its first file reaches 100%; it completes when the server drops the task and the model is downloaded. /models/download works by loading the model, which left it resident on the GPU. A few queued downloads filled VRAM until later ones failed with "CUDA out of memory" although their files were fine. The route now unloads a model it loaded only to fetch its weights, unless a generation is running. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tada-1b and tada-3b-ml share one backend, but the generic download path called load_model() without a size, so "downloading" TADA 3B loaded the cached 1B model and reported success without fetching anything. The loaded check and unload likewise ignored the size. The download task also never closed its initial "Connecting to HuggingFace..." progress entry when the load reported under a different name, so TADA 3B stayed in /tasks/active as a download that never ends. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…harded TADA 3B huggingface_hub 0.x caches one requests.Session per thread, and a session created while HF_HUB_OFFLINE is forced mounts an adapter that refuses every request for the rest of the thread's life. Model loads run on reused worker threads, so after a cached model had loaded on a thread, a later download landing there failed with "outgoing traffic has been disabled" (seen with TADA 3B) even though the offline window was long closed. Reset the session cache whenever the window opens or closes. TADA 3B ships sharded weights, but the cache check required a single model.safetensors, so the backend always treated 3B as not downloaded and generation would refuse it. Require config.json plus any weight file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Model downloads were unreliable on Windows, and some of the problems affect every platform. This PR fixes them one commit each:
C:cache. The folder is now saved and the server restarted even when there's nothing to move.snapshots/<rev>/file -> ../../blobs/<hash>links. Migration copied every link target in full (so each file was copied twice) and the folder size counted them twice. Links that stay inside the cache are now recreated. Where Windows refuses the symlink (no Developer Mode, network shares), it falls back to a hard link to the copied blob, then to a plain copy.init_empty_weights,no_init_weights, the default dtype). Two loads running at once producedCannot copy out of meta tensorerrors. Both downloads also patched the same tqdm classes, so progress bars jumped between models ([BUG] Download progress bars display incorrect values when downloading multiple models concurrently (Windows) #708). Loads are now serialized inmodel_load_progress, and a queued download shows "Waiting for another model to finish loading..."./tasks/activequery. They also finish only when the server reports the model downloaded, not when the first file reaches 100%.load_model()without a size, so downloading TADA 3B loaded the cached 1B and reported success. The loaded check and unload ignored the size too. A stale "Connecting to HuggingFace..." entry was also left in/tasks/activefor good.requests.Sessionper thread, and a session created whileHF_HUB_OFFLINEis forced refuses every request for the rest of that thread's life. Model loads run on reused worker threads, so after a cached model loaded, a later download (or a Kokoro generation fetching a voice file) on the same thread failed with "outgoing traffic has been disabled". The session cache is now reset whenever the offline window opens or closes. TADA 3B's sharded weights were also never recognised as cached, which would have blocked generating with it.Testing
test_models_migrate_symlinks.py,test_model_load_serialization.py,test_download_unloads_model.py,test_offline_session_reset.py. They pass together with the existing offline, progress and model tests.test_progress.py::test_hf_progress_trackerandtest_offline_guard.py::test_nesting_opposite_mode_on_same_thread_raises_instead_of_deadlocking.tsc --noEmitis clean.C:, moved the cache toD:through the UI with links intact, then downloaded the rest toD:🤖 Generated with Claude Code