Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

fix: use exact variant matching and shard-prefix discovery for split GGUFs

Roland Tannousd635846b8da4
diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.py
index b394284532b..934062f56b7 100644
--- a/studio/backend/core/inference/llama_cpp.py
+++ b/studio/backend/core/inference/llama_cpp.py
@@ -255,16 +255,32 @@ class LlamaCppBackend:
if hf_variant:
# Try common naming patterns
try:
+ import re
from huggingface_hub import list_repo_files
files = list_repo_files(hf_repo, token=hf_token)
variant_lower = hf_variant.lower()
- matching = sorted(
+ # Use word-boundary matching so "Q8_0" doesn't also
+ # match "IQ8_0" or other superset variant names.
+ boundary = re.compile(
+ r'(?<![a-zA-Z0-9])' + re.escape(variant_lower) + r'(?![a-zA-Z0-9])'
+ )
+ gguf_files = sorted(
f for f in files
- if f.endswith(".gguf") and variant_lower in f.lower()
+ if f.endswith(".gguf") and boundary.search(f.lower())
)
- if matching:
- gguf_filename = matching[0] # first shard (or single file)
- gguf_extra_shards = matching[1:] # remaining shards if split
+ if gguf_files:
+ gguf_filename = gguf_files[0]
+ # For split GGUFs (e.g. model-Q8_0-00001-of-00003.gguf)
+ # discover siblings by shared prefix instead of
+ # trusting all variant matches to be shards.
+ shard_pat = re.compile(r'^(.*)-\d{5}-of-\d{5}\.gguf$')
+ m = shard_pat.match(gguf_filename)
+ if m:
+ prefix = m.group(1)
+ gguf_extra_shards = [
+ f for f in gguf_files[1:]
+ if f.startswith(prefix + "-") and shard_pat.match(f)
+ ]
except Exception as e:
logger.warning(f"Could not list repo files: {e}")