From 92670a90ddefc6077afecca3c57ea46e35626694 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Sun, 15 Mar 2026 07:31:31 +0000 Subject: [PATCH] studio: fix case-insensitive HF cache lookup for downloaded GGUF variants HF cache dirs use the exact case from the repo_id at download time (e.g. models--unsloth--kimi-k2.5-gguf) which may differ from the canonical HF repo_id (unsloth/Kimi-K2.5-GGUF). Use case-insensitive matching to find the cache directory. --- studio/backend/routes/models.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/studio/backend/routes/models.py b/studio/backend/routes/models.py index 8be847976f..4633bd26fe 100644 --- a/studio/backend/routes/models.py +++ b/studio/backend/routes/models.py @@ -556,17 +556,23 @@ async def get_gguf_variants( default_variant = _extract_quant_label(best) if best else None # Check which variants are already downloaded in the HF cache + # HF cache dir uses the exact case from the repo_id at download time, + # which may differ from the canonical HF repo_id, so do a + # case-insensitive match. cached_files: set = set() try: from huggingface_hub import constants as hf_constants cache_dir = Path(hf_constants.HF_HUB_CACHE) - repo_dir = cache_dir / f"models--{repo_id.replace('/', '--')}" - snapshots = repo_dir / "snapshots" - if snapshots.is_dir(): - for snap in snapshots.iterdir(): - for f in snap.rglob("*.gguf"): - cached_files.add(f.name) + target = f"models--{repo_id.replace('/', '--')}".lower() + for entry in cache_dir.iterdir(): + if entry.name.lower() == target: + snapshots = entry / "snapshots" + if snapshots.is_dir(): + for snap in snapshots.iterdir(): + for f in snap.rglob("*.gguf"): + cached_files.add(f.name) + break except Exception: pass