"""File size and effective bits per weight for each model, from file headers only (no GPU). MLX safetensors: logical params of a quantized weight = packed uint32 count * 32 / bits; scales/biases count as bytes but not params. GGUF: params and bytes from the tensor table. Usage: python model_stats.py --out raw/model_stats.json """ import argparse import glob import json import os import struct from math import prod HF = os.path.expanduser("~/.cache/huggingface/hub") MLX = {"A": "mlx-community/Qwen3.8-27B-4bit", "C": "mlx-community/Qwen3.6-35B-A3B-4bit", "D": "LiquidAI/LFM2.5-24B-A2B-MLX-4bit"} GGUF = {"B": ("unsloth/Qwen3.8-27B-GGUF", "Qwen3.8-27B-UD-Q4_K_XL.gguf")} DTYPE_BYTES = {"BF16": 2, "F16": 2, "F32": 4, "U32": 4, "I32": 4, "U8": 1, "I8": 1} def snapshot(repo): return sorted(glob.glob(os.path.join(HF, "models--" + repo.replace("/", "--"), "snapshots", "*")))[0] def safetensors_header(path): with open(path, "rb") as f: n = struct.unpack("