Skip to content

Studio: resolve a repo-id load to the local scan-folder copy instead of downloading it - #12254

Closed
VTplus wants to merge 1 commit into
unslothai:mainfrom
VTplus:studio-scan-folder-local-load
Closed

VTplus wants to merge 1 commit into
unslothai:mainfrom
VTplus:studio-scan-folder-local-load

Conversation

@VTplus

@VTplus VTplus commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Fixes #12253.

What

POST /api/inference/load with a repo-shaped id now asks the local model resolver first — the same index the OpenAI auto-switch path uses (./models, hub caches, LM Studio, Hermes, Ollama, registered scan folders). A hit rewrites the request to the local path and the load opens the weights already on disk; a miss is untouched and keeps the existing remote path (including pinned-quant misses).

Why

Today a repo id that only exists in a scan folder is classified as remote and downloaded into the hub cache even though complete weights sit on disk (details in the issue).

Scope / guards

  • Only org/name-shaped ids; bare names keep the unsloth/<name> remote meaning.
  • Managed accounts and native path leases keep the requested id (same boundary as the neighboring _as_ollama_manifest_request rewrite).
  • Ollama manifest ref results are left to that rewrite's lease handling; any resolver failure falls through to the remote path.

Tests

studio/backend/tests/test_load_scan_folder_resolution.py, 9 cases: hit with/without pinned variant, legacy-alias replacement, miss, bare name, paths/manifest refs, resolver failure, managed account, native lease.

Known limitations (deliberate)

  • A model already resident under its repo id reloads fresh once the id starts resolving locally (path vs repo-id identity) — never different weights.
  • The first load after the resolver's 5 s TTL pays the index scan (worker thread, user-initiated slow action).

Related: #6989 (grows what the resolver can hit), #11246 (orthogonal download targeting).

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed that /load in routes/inference.py still treats a repo id held only in a scan folder as remote and downloads it again, and this routes it through the local resolver with a clean fallback. Will get this reviewed.

@VTplus
VTplus force-pushed the studio-scan-folder-local-load branch from d4774dd to 5b56870 Compare September 29, 2026 22:57
@danielhanchen danielhanchen self-assigned this Oct 8, 2026
danielhanchen added a commit that referenced this pull request Oct 8, 2026
…ading it (#13034)

A repo id whose complete GGUF copy lives only in a registered scan folder (or another local root outside the active hub cache) now loads that copy instead of downloading a duplicate into the hub cache. /validate uses the same rewrite so the chat flow also works without Hub access.

The rewrite only applies to the owner's own Studio session, only to a GGUF snapshot of the requested repo, and never to a repo the active hub cache already serves. Responses keep the requested repo id, and bundled chat templates plus DeepSeek-V4 reasoning detection read an HF snapshot path as its repo id.

Fixes #12253. Takes over #12254.

Co-authored-by: Mathias Müller <[email protected]>
@VTplus

VTplus commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of #13034. The API-key-session variant still remote-downloads; I'll propose a PR as soon as it's tested.

@VTplus VTplus closed this Oct 9, 2026
@VTplus
VTplus deleted the studio-scan-folder-local-load branch October 9, 2026 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Unsloth Loading a repo id that exists in a registered scan folder downloads it into the hub cache instead of using the local copy

2 participants