#!/usr/bin/env python3 """GGUF header differential: strata-next (`model inspect`, `model inspect-metadata`, `model index`) vs the unmodified tools/gguf_reader.py on randomized synthetic GGUF v3 files, plus geometry-table parity and the "Rust is stricter by design" rejection list. python scripts/offline/diff_gguf_header.py [--cases N] [--seed S] Random files cover all 13 metadata value types, arrays of every element type, unicode strings, `general.alignment`, split keys and 1-4 dimensional tensors of every block geometry both sides know. Pure stdlib + the oracle. """ import json import random import struct import subprocess import sys import tempfile from pathlib import Path REPO = Path(__file__).resolve().parents[2] sys.path.insert(0, str(REPO / 'engine/strata/tools')) sys.path.insert(0, str(Path(__file__).resolve().parent)) import gguf_reader as G # noqa: E402 (the oracle, unchanged) from ggufgen import write_gguf, string # noqa: E402 SCALAR_KINDS = ['u8', 'i8', 'u16', 'i16', 'u32', 'i32', 'f32', 'bool', 'u64', 'i64', 'f64'] RANGES = {'u8': (0, 255), 'i8': (-128, 127), 'u16': (0, 65535), 'i16': (-32768, 32767), 'u32': (0, 2**32 - 1), 'i32': (-2**31, 2**31 - 1), 'u64': (0, 2**64 - 1), 'i64': (-2**63, 2**63 - 1)} GEOM = {name: g for name, g in G.BLOCK_GEOMETRY.items()} TYPE_IDS = {name: i for i, name in G.GGML_TYPES.items() if name in GEOM} def rand_string(rng): alphabet = 'abcXYZ019 _-./äöüéßçñΩλπЖ中文日本語한국어😀🧪‍́' return ''.join(rng.choice(alphabet) for _ in range(rng.randint(0, 24))) def rand_scalar(rng, kind): if kind == 'bool': return rng.random() < 0.5 if kind == 'f32': return struct.unpack('