Skip to content

Fix Studio hydrating synced GGUF files before selection - #9539

Merged
oobabooga merged 15 commits into
unslothai:mainfrom
milewski:fix/studio-synced-drive-hydration
Aug 27, 2026
Merged

oobabooga merged 15 commits into
unslothai:mainfrom
milewski:fix/studio-synced-drive-hydration

Conversation

@milewski

Copy link
Copy Markdown
Contributor

Summary

  • classify local GGUF models from filename and path hints without opening weight files during Studio startup
  • make local GGUF variant discovery metadata-only by deferring context and projector header reads until an explicit variant load
  • retain filename-based media and audio-only classification while leaving load-time GGUF inspection unchanged
  • add regressions covering startup discovery and variant-menu expansion against content reads

Fixes #9537

Verification

  • 252 passed, 1 skipped, 6 deselected across the focused model scan and GGUF variant suites (the deselected cases require Windows symlink privileges)
  • Ruff checks passed for all changed Python files

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed the startup path in studio/backend/hub/utils/gguf.py does open projector and GGUF headers during discovery, which is what hydrates online-only files. The direction is right, but this also drops context_length to None for everyone and replaces architecture-based task and vision detection with filename guesses, so an audio-only projector now reports has_vision true; could you narrow it to skipping content reads for placeholder or unhydrated files and keep the real header reads for local files that are already present?

@milewski

Copy link
Copy Markdown
Contributor Author

Hi @danielhanchen I updated it again, take a look, PS: I only tested it on windows

@oobabooga

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 762a652f7d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +314 to +317
if not file_contents_available_locally(model_path):
# Preserve the established H3 name-only exception; every architecture-backed
# task remains unknown until the placeholder is hydrated.
return _arch_to_task(None, name_hints = hints)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Skip placeholders in the audio-type fallback

When a Windows-synced GGUF has a recall attribute, this new branch returns None, but the primary local inventory path calls _local_model_classification, which responds to a None task by invoking _local_model_audio_type; that reaches _gguf_path_audio_type and _gguf_architecture without the new availability check, opening and hydrating the same potentially multi-gigabyte placeholder during startup. Apply the local-content guard to the audio-type probe as well (including directory candidates), otherwise the change does not prevent the reported recall behavior for /api/models/local.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed and fixed in 48980e4. _local_model_classification falls through to _local_model_audio_type whenever the task comes back None, and _gguf_path_audio_type reads an architecture of its own, so /api/models/local opened the placeholder anyway. A folder row was worse than a single file: that probe walks _iter_gguf_paths with no cap and no read deadline, unlike _gguf_folder_task with its 64 file cap and 1.5 s budget, so it read every sibling.

The guard now lives in _gguf_architecture, the one wrapper all three classification probes read through, so the audio-type probe is covered without a fourth copy of the check. Load-time inspection calls read_gguf_architecture directly and still hydrates on purpose. test_local_classification_never_opens_an_online_only_gguf covers the single-file and folder rows and spies read_gguf_architecture itself rather than the probe above it, which is why the earlier _local_model_task test did not catch this.

Comment on lines +314 to +317
if not file_contents_available_locally(model_path):
# Preserve the established H3 name-only exception; every architecture-backed
# task remains unknown until the placeholder is hydrated.
return _arch_to_task(None, name_hints = hints)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve task routing for unhydrated media GGUFs

For an online-only Flux, Z-Image, Wan, ASR, or other media GGUF, passing arch=None discards the architecture-backed task and only retains the special H3 filename case. The frontend's task-scoped On Device pickers require an exact non-null task, so these models disappear from Images, Video, or Audio before the user can select them; in the unfiltered picker they instead look chat-routable. Preserve a media task from trustworthy filename/path metadata or otherwise represent an unhydrated task without opening the weights.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed and fixed in 48980e4. taskMatchesFilter in pickers.tsx requires repoTask != null, so an unclassified row cannot reach Images, Video or Audio, while the unfiltered gate lists it in Chat and isAutoLoadableLocalRow in chat-adapter.ts admits it to the startup background auto-load, which recalls the placeholder into llama.cpp. That is the recall this PR set out to remove, moved from discovery to startup.

_unhydrated_gguf_task now routes an unhydrated GGUF from the same name and path hints _arch_to_task already trusts for a placeholder architecture, factored into _name_hint_media_task so both callers share one rule. flux1-dev, z-image and the buildable Wan and HunyuanVideo tiers keep the picker whose pick is what hydrates them, an MoE tier still answers image-diffusion-unsupported exactly as its architecture would, and a name that says nothing stays unknown and keeps its Chat row.

Speech is left out deliberately. filesystemRowsSupportedForTask drops any automatic-speech-recognition row from every filesystem list, and audioPickIsRoutable fails a text-to-speech GGUF row closed when its codec is unknown, so claiming either from a filename would hide the model outright instead of routing it. test_an_unhydrated_denoiser_keeps_the_picker_that_would_hydrate_it covers the routing.

@oobabooga

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@oobabooga

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 48980e4801

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +350 to +352
hints = id_hints + (model_path.name,)
if not file_contents_available_locally(model_path):
return _unhydrated_gguf_task(hints)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict placeholder family hints to the model leaf

When an online-only GGUF comes from ./models or a custom folder, model.id is the full local path and is included in id_hints; _unhydrated_gguf_task passes every hint to family detection, which matches tokens in any path segment. Thus a generic chat model such as /models/flux/random-Q4_K_M.gguf is classified as text-to-image solely because of its parent directory, and passesTaskGate/mediaPageForTask in pickers.tsx then expose and route it as an image model rather than loading it through chat. Use only the leaf component for filesystem-path hints while retaining genuine repository IDs.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed and fixed in c18bd09, though not on the literal example: bare flux is not a family alias, so /models/flux/random-Q4_K_M.gguf already answered None. The mechanism is real one segment up. A filesystem row's model.id is its whole path, detect_family_for_pick matches a keyword in any segment of it, and a real alias in an ancestor did decide the row:

  • .../FLUX.1-dev-GGUF/extra/qwen3-4b/qwen3-Q4_K_M.gguf classified text-to-image
  • .../ltx-2/qwen3-4b/qwen3-Q4_K_M.gguf classified text-to-video
  • .../wan2.2-ti2v-5b/qwen3-4b/qwen3-Q4_K_M.gguf classified text-to-video

That is mine, not the original change. With an architecture in hand a family mismatch only picks the wrong denoiser family; with the name as the entire case it relabels a chat GGUF, which is worse than the unknown it replaced.

_unhydrated_gguf_task now reduces every hint to its last path segment before family detection, so a repo id and a scanned folder row still match on their own leaf (unsloth/FLUX.1-dev-GGUF, a directory named FLUX.1-dev-GGUF) while an ancestor directory cannot decide anything. The H3 bundle check keeps the full hint, since is_h3_bundle_repo is an exact repo-id membership test. One consequence worth naming: a generically named denoiser file such as FLUX.1-dev-GGUF/diffusion_model-Q4_K_M.gguf, listed as a single-file row rather than a folder row, now stays unknown until it is hydrated. That is the conservative direction, since the immediate parent is exactly the segment this item is about. test_an_ancestor_directory_does_not_name_an_unhydrated_gguf covers both directions.

@oobabooga

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: c18bd09b0b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@oobabooga

Copy link
Copy Markdown
Member

Thanks @milewski. I verified that discovery now leaves Synology online-only GGUF weights and projectors unopened, while hydrated files retain their metadata reads and explicit loads still inspect the files normally.

The filename fallback is deliberately conservative: an online-only media model with an unrecognizable name stays in Chat's On Device list until hydrated instead of appearing in the wrong media tab. That is a reasonable tradeoff for preventing Studio startup from recalling an entire synced model library.

@oobabooga
oobabooga merged commit 8a68128 into unslothai:main Aug 27, 2026
40 of 46 checks passed
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.

[Studio Bug] Opening the app reads and downloads all model files from synced drives

3 participants