fix(studio): custom folder scan fails to find GGUF variants when pointing directly at a model directory#9
Closed
danielhanchen wants to merge 7 commits into
Closed
fix(studio): custom folder scan fails to find GGUF variants when pointing directly at a model directory#9danielhanchen wants to merge 7 commits into
danielhanchen wants to merge 7 commits into
Conversation
…ights
When a custom scan folder points directly at a model directory (e.g.
gemma-4-e2b-it-gguf/ containing config.json and .gguf files),
_scan_models_dir previously skipped the directory itself and listed
individual .gguf files as standalone models. The gguf-variants endpoint
then received file paths instead of directory paths, causing
list_local_gguf_variants to return an empty list ("No GGUF variants
found").
Three fixes:
1. _scan_models_dir: detect when the scanned directory itself is a model
(has BOTH a config file AND weight files) and return it as a single
entry. Both conditions are required to avoid false positives on bare
.gguf collections or config-only directories.
2. _scan_lmstudio_dir: early-return when the directory has config files
(not a publisher structure), and skip child directories that are
model directories rather than treating them as publisher folders.
3. list_local_gguf_variants: fall back to the parent directory when a
.gguf file path is passed instead of a directory.
for more information, see https://pre-commit.ci
…com/JYYYYYT/unsloth into fix/local-folder-scan-gguf-variants # Conflicts: # studio/backend/routes/models.py
for more information, see https://pre-commit.ci
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.
Staging mirror of unslothai#4860
Original PR: unslothai#4860
Author: JYYYYYT
This is a staging copy for review and editing. Once finalized, changes will be pushed back to the original PR.
Original description
Problem
When adding a custom scan folder that points directly at a model directory
(e.g.
/path/to/gemma-4-e2b-it-gguf/containingconfig.jsonandgemma-4-E2B-it-BF16.gguf), the model list shows individual.gguffilesas separate entries instead of recognizing the directory as a single model.
Clicking any of these entries shows "No GGUF variants found" because
list_local_gguf_variantsreceives a file path instead of a directory pathand
is_dir()returnsFalse.Additionally,
_scan_lmstudio_dirmisidentifies the model directory as anLM Studio publisher folder, creating duplicate broken entries.
Steps to reproduce
gemma-4-e2b-it-gguf/withconfig.json,gemma-4-E2B-it-BF16.gguf,mmproj-BF16.gguf)pointing directly at the model directory
gemma-4-E2B-it-BF16andmmproj-BF16) insteadof one (
gemma-4-e2b-it-gguf)produces duplicate broken entries from the LM Studio scanner
For example
/Users/shisheng/Documents/llm-workspace/models/gemma-4-E2B-it-gguf/
├── config.json
├── configuration.json
├── gemma-4-E2B-it-BF16.gguf (9.3 GB)
├── imatrix_unsloth.gguf_file
└── mmproj-BF16.gguf (987 MB)
When I add the directory above as a custom model folder, I see two entries:
And when I add the
/Users/shisheng/Documents/llm-workspace/models/directory as a custom model folder, I see these entries:Related Issues
After searching the issue tracker, I found no existing reports for this bug. This PR directly addresses the issue with a minimal fix.
Fix
1.
_scan_models_dir— detect self-as-model (routes/models.py)Before scanning subdirectories, check whether the directory itself is a
model: it must have both a config file (
config.jsonoradapter_config.json) and weight files (.gguf,.safetensors, or.bin). Both conditions are required to avoid false positives:.gguffiles (no config) may be a mixedcollection → should list files individually (existing behavior)
config.jsonalone (no weights) is not a model directory2.
_scan_lmstudio_dir— skip model directories (routes/models.py)model, not a publisher structure)