From b84202e8db2f0f2e91ab28e2c0ed5a5d0d1e15a0 Mon Sep 17 00:00:00 2001 From: Roland Tannous Date: Tue, 10 Mar 2026 19:28:26 +0000 Subject: [PATCH] fix: restrict shard siblings to exact basename and total count startswith(prefix) could match unrelated split variants whose names extend the selected file's prefix (e.g. model-Q8_0-v2-00001-of-...). Now builds an exact regex from the chosen file's base prefix and shard total so only true siblings are downloaded. --- studio/backend/core/inference/llama_cpp.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.py index 934062f56b..dac8d380c3 100644 --- a/studio/backend/core/inference/llama_cpp.py +++ b/studio/backend/core/inference/llama_cpp.py @@ -271,15 +271,19 @@ class LlamaCppBackend: 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$') + # discover siblings by exact basename + total match + # so "model-Q8_0-v2-*" isn't pulled in as a sibling. + shard_pat = re.compile(r'^(.*)-\d{5}-of-(\d{5})\.gguf$') m = shard_pat.match(gguf_filename) if m: prefix = m.group(1) + total = m.group(2) + sibling_pat = re.compile( + r'^' + re.escape(prefix) + r'-\d{5}-of-' + re.escape(total) + r'\.gguf$' + ) gguf_extra_shards = [ f for f in gguf_files[1:] - if f.startswith(prefix + "-") and shard_pat.match(f) + if sibling_pat.match(f) ] except Exception as e: logger.warning(f"Could not list repo files: {e}")