#!/usr/bin/env python3 """Pack several GGUF files (e.g. model + mmproj) into one GGUF "bundle", and unpack it again. The bundle is a valid GGUF v3 file. Each original file is stored verbatim as one raw int8 tensor, with its name, size and sha256 in the metadata, so unpacking gives back the exact original bytes. llama.cpp cannot run a bundle directly: unpack it first. Standard library only (Python 3.8+). python3 gguf_bundle.py unpack bundle.gguf [-o OUTDIR] python3 gguf_bundle.py list bundle.gguf python3 gguf_bundle.py pack out.gguf model.gguf mmproj.gguf [--name NAME] """ import argparse, hashlib, os, struct, sys MAGIC, VERSION, ALIGN = b"GGUF", 3, 32 T_U32, T_STRING, T_ARRAY, T_U64 = 4, 8, 9, 10 GGML_TYPE_I8 = 24 CHUNK = 16 << 20 # ---------- writing ---------- def _s(x): b = x.encode("utf-8") return struct.pack("