Skip to main content

Module pack

Module pack 

Source
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 start

hash 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.
FileEntry
A file carried inside a .kime, such as a config or the tokenizer.
Index
A parsed and checked .kime index.

Constants§

ALIGN
Alignment of the header block, the data section and every tensor.
MAGIC
The first eight bytes of every .kime file.
VERSION
The format version this build reads and writes.

Functions§

is_kime
Whether bytes starts like a .kime file.
load
Opens the tensors of a .kime file held in blob.
parse
Parses and checks the index of a .kime file. The data section is not hashed here, see verify.
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 .kime file and returns its model hash.