Skip to content

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
mainfrom
pr-4860-head
Closed

fix(studio): custom folder scan fails to find GGUF variants when pointing directly at a model directory#9
danielhanchen wants to merge 7 commits into
mainfrom
pr-4860-head

Conversation

@danielhanchen

Copy link
Copy Markdown
Owner

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/ containing config.json and
gemma-4-E2B-it-BF16.gguf), the model list shows individual .gguf files
as 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_variants receives a file path instead of a directory path
and is_dir() returns False.

Additionally, _scan_lmstudio_dir misidentifies the model directory as an
LM Studio publisher folder, creating duplicate broken entries.

Steps to reproduce

  1. Download a GGUF model repo locally (e.g. gemma-4-e2b-it-gguf/ with
    config.json, gemma-4-E2B-it-BF16.gguf, mmproj-BF16.gguf)
  2. In Studio, click Select Model → Custom Folders and add the path
    pointing directly at the model directory
  3. Two entries appear (gemma-4-E2B-it-BF16 and mmproj-BF16) instead
    of one (gemma-4-e2b-it-gguf)
  4. Clicking either entry shows "No GGUF variants found"
  5. Scanning the parent directory works for the top-level entry but still
    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:

image

And when I add the /Users/shisheng/Documents/llm-workspace/models/ directory as a custom model folder, I see these entries:

image

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.json or
adapter_config.json) and weight files (.gguf, .safetensors, or
.bin). Both conditions are required to avoid false positives:

  • A bare directory with loose .gguf files (no config) may be a mixed
    collection → should list files individually (existing behavior)
  • A config.json alone (no weights) is not a model directory

2. _scan_lmstudio_dir — skip model directories (routes/models.py)

  • Early-return when the scanned directory itself has config files (it's a
    model, not a publisher structure)
  • Skip child direct

JYYYYYT and others added 7 commits April 5, 2026 15:06
…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.
…com/JYYYYYT/unsloth into fix/local-folder-scan-gguf-variants

# Conflicts:
#	studio/backend/routes/models.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants