From 45e74a97bd62627367b8540b789d399d039d36f7 Mon Sep 17 00:00:00 2001 From: Hitonabi Date: Sat, 27 Jun 2026 03:09:17 +0200 Subject: [PATCH] Fix: GGUF-Gesamtgroesse inkl. Split-Teile (heavy zeigte nur 10MB Header-Teil) _gguf_total_size summiert alle ...-NNNNN-of-NNNNN.gguf-Teile. size_bytes des ersten Teils war bei Split-Modellen wie Qwen3.5-122B (11M Header + 47G + 25G) irrefuehrend. Fix wirkt in UI-Anzeige UND Budget-Footprint. Co-Authored-By: Claude Opus 4.8 --- backend/services/llamaswap.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/backend/services/llamaswap.py b/backend/services/llamaswap.py index 98f1645..2205bdf 100644 --- a/backend/services/llamaswap.py +++ b/backend/services/llamaswap.py @@ -27,6 +27,24 @@ ROLE_IDS = {"fast", "heavy", "coder", "vision", "scout"} _CTX_RE = re.compile(r"-(?:c|-ctx-size)\s+(\d+)") _PATH_RE = re.compile(r"-(?:m|-model)\s+([^\s]+)") _QUANT_RE = re.compile(r"(Q\d_[A-Z0-9_]+|IQ\d_[A-Z0-9_]+|fp16|bf16)\.gguf", re.IGNORECASE) +_SPLIT_RE = re.compile(r"-(\d+)-of-(\d+)\.gguf$", re.IGNORECASE) + + +def _gguf_total_size(path: str) -> int | None: + """Gesamtgröße eines GGUF inkl. ALLER Split-Teile (…-00001-of-00003.gguf). + Die Größe nur des ersten Teils ist bei Splits irreführend (oft nur ein Header).""" + try: + base = os.path.basename(path) + m = _SPLIT_RE.search(base) + if not m: + return os.path.getsize(path) + prefix, dirn = base[:m.start()], os.path.dirname(path) + total = sum(os.path.getsize(os.path.join(dirn, f)) + for f in os.listdir(dirn) + if f.startswith(prefix) and _SPLIT_RE.search(f)) + return total or os.path.getsize(path) + except OSError: + return None # --- Lesen ------------------------------------------------------------------- @@ -54,7 +72,7 @@ def _parse_model(name: str, spec: dict) -> dict: path = m.group(1).replace("'", "").replace('"', "") filename = os.path.basename(path) if os.path.exists(path): - size_bytes = os.path.getsize(path) + size_bytes = _gguf_total_size(path) if (q := _QUANT_RE.search(path)): quant = q.group(1).upper()