"""Synthetic GGUF v3 writer for the offline differential harnesses (small fixtures only, no model data). Metadata values are written from (key, type, value) triples; `type` is one of the 13 GGUF value types spelled u8 i8 u16 i16 u32 i32 f32 bool str u64 i64 f64, or ('array', element_type). Tensors are (name, dims, ggml_type, raw_bytes) with dims fastest-first, laid out sequentially at the file's alignment, as llama.cpp writes them. """ import struct SCALARS = {'u8': 'B', 'i8': 'b', 'u16': 'H', 'i16': 'h', 'u32': 'I', 'i32': 'i', 'f32': 'f', 'bool': '?', 'u64': 'Q', 'i64': 'q', 'f64': 'd'} TYPE_ID = {'u8': 0, 'i8': 1, 'u16': 2, 'i16': 3, 'u32': 4, 'i32': 5, 'f32': 6, 'bool': 7, 'str': 8, 'array': 9, 'u64': 10, 'i64': 11, 'f64': 12} def string(s): b = s.encode() if isinstance(s, str) else s return struct.pack(' (type id word, payload)""" if isinstance(kind, tuple): assert kind[0] == 'array' element = kind[1] payload = struct.pack('