Documentation
¶
Overview ¶
Package gguf reads the metadata header of a GGUF model file: enough of it to size the KV cache exactly (flockd#46) and to learn the training context when the catalog does not say. Tensor data is never touched.
Format (v2/v3, little-endian): magic "GGUF", uint32 version, uint64 tensor count, uint64 kv count, then kv pairs of (string key, uint32 type, value). Arrays carry an element type and count. The tokenizer vocabulary lives in these pairs too, so a header can be several MB; values we do not need are skipped, not stored.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Meta ¶
type Meta struct {
Architecture string
BlockCount int // transformer layers
HeadCount int
HeadCountKV int // total across layers when the header lists per-layer counts
HeadCountKVList bool
EmbeddingLength int
KeyLength int // per head; defaults to EmbeddingLength/HeadCount
ValueLength int
ContextLength int // training window
}
Meta is the subset of the header that sizing needs. Zero means absent.
func ReadMeta ¶
ReadMeta reads the header of the GGUF at path. For a sharded model pass the first shard: that is where the metadata lives.
func (Meta) KVBytesPerToken ¶
KVBytesPerToken is the f16 KV-cache cost of one context token across all layers: 2 (K and V) × layers × kv heads × head size × 2 bytes. That is what llama-server allocates per --ctx-size token with its default cache type; models whose header lacks the geometry return 0 so callers fall back to their heuristic. Sliding-window and MLA architectures cost less than this figure, never more, so the estimate errs safe.