From d635846b8da4809159b1f5f2a591b97bc162df6d Mon Sep 17 00:00:00 2001 From: Roland Tannous Date: Tue, 10 Mar 2026 19:13:03 +0000 Subject: [PATCH] fix: use exact variant matching and shard-prefix discovery for split GGUFs Substring matching (e.g. "Q8_0" in filename) could match superset variants like "IQ8_0", causing wrong quantizations to be downloaded. Now uses word-boundary regex for variant matching and discovers split shards by shared filename prefix rather than treating all variant matches as shards. --- studio/backend/core/inference/llama_cpp.py | 28 +++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.py index b394284532..934062f56b 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( - f for f in files - if f.endswith(".gguf") and variant_lower in f.lower() + # Use word-boundary matching so "Q8_0" doesn't also + # match "IQ8_0" or other superset variant names. + boundary = re.compile( + r'(?