Expand description
The .kime packed format: one file holding a model’s tensors and config files, laid out so the
tensors can be mapped and used in place.
0 4 KiB header block
0..8 magic "KIME\x01\0\0\0"
8..12 format version, u32 LE, 1
12..16 zero
16..24 JSON length, u64 LE
24..32 data start, u64 LE, a multiple of 4 KiB
32..40 data length, u64 LE, running to the end of the file
40..72 blake3 of the JSON
72.. zero
4096 JSON: format, family, id, hash, tensors, files
data tensors, then files, each starting on a 4 KiB boundary, offsets relative to data starthash in the JSON is the blake3 of the whole data section and is the model hash kime reports.
The JSON’s own hash sits in the header block, so a reader can trust the index before touching
the data, and checking the model hash is a separate, optional pass at memory speed.
Every number is checked before use, as for safetensors: a header that points outside the file is an error and never a read.
Structs§
- Contents
- What to pack.
- File
Entry - A file carried inside a
.kime, such as a config or the tokenizer. - Index
- A parsed and checked
.kimeindex.
Constants§
- ALIGN
- Alignment of the header block, the data section and every tensor.
- MAGIC
- The first eight bytes of every
.kimefile. - VERSION
- The format version this build reads and writes.
Functions§
- is_kime
- Whether
bytesstarts like a.kimefile. - load
- Opens the tensors of a
.kimefile held inblob. - parse
- Parses and checks the index of a
.kimefile. The data section is not hashed here, seeverify. - verify
- Hashes the data section and compares it with the index. This reads every byte, on all cores, so it runs at memory or disk speed.
- write
- Writes a
.kimefile and returns its model hash.