#!/usr/bin/env python3 """Exact GGUF size budget from the vendor header, per quantization policy. No weights needed: the 148 KB safetensors header gives every tensor's dtype/shape. GGUF sizes: Q4_0 = 18 B / 32 weights (4.5 bpw), Q8_0 = 34 B / 32 (8.5 bpw), F16 = 2 B/weight, F32 = 4 B/weight, BF16 = 2 B/weight. """ import json import struct from pathlib import Path V = Path(__file__).resolve().parent.parent / "vendor" b = (V / "inkling-header.bin").read_bytes() n = struct.unpack("= 2 def classify(k): if is_expert(k): return "expert" if is_embed(k): return "embed" if is_linear(k): if any(s in k for s in ("wq_du", "wk_dv", "wv_dv", "wo_ud", "gate_attn", "wr_du", "attn_sink")): return "attn" return "other_linear" return "small" POLICIES = { # name: (expert, attn, other_linear, embed, small) "Q4_0 floor (all linears 4.5bpw)": dict(expert=4.5, attn=4.5, other_linear=4.5, embed=4.5, small=32.0), "Q4_0 realistic (attn F16, embed Q8)": dict(expert=4.5, attn=16.0, other_linear=16.0, embed=8.5, small=32.0), "Q4_K_M-like (4.85bpw, attn F16, embed Q8)": dict(expert=4.85, attn=16.0, other_linear=16.0, embed=8.5, small=32.0), "Q4_0 + attn Q8 + embed Q8": dict(expert=4.5, attn=8.5, other_linear=8.5, embed=8.5, small=32.0), "Q8_0 text-only": dict(expert=8.5, attn=8.5, other_linear=8.5, embed=8.5, small=32.0), } counts = {c: 0 for c in ("expert", "attn", "other_linear", "embed", "small")} for k in h: if not is_text(k) or is_quant_aux(k): continue counts[classify(k)] += 1 print("tensor classes (text-only):", counts) print() for name, pol in POLICIES.items(): tot = 0.0 parts = {} for k, meta in h.items(): if not is_text(k) or is_quant_aux(k): continue c = classify(k) shp = logical_last(meta["shape"], meta["dtype"]) v = nbytes(shp, pol[c]) tot += v parts[c] = parts.get(c, 0) + v print(f"{name:52s} {tot/1e9:6.2f} GB") print(" " + " ".join(f"{c}={parts[c]/1e9:.2f}" for c in parts)) print() print("vision (for reference, if ever included):") vis = sum(nbytes(logical_last(m["shape"], m["dtype"]), 4.5) for k, m in h.items() if k.startswith("model.visual.")) print(f" at 4.5 bpw = {vis/1e9:.2f} GB")