Jabara and general-purpose archivers¶
tar and zip pack a checkpoint directory into one file, and zip, gzip, and zstd compress files as streams of bytes. Jabara reads the tensors in those files and codes each tensor with a codec chosen for its role and dtype. The table compares the two approaches on a checkpoint that holds model.safetensors and optimizer.pt.
Property |
|
Jabara |
|---|---|---|
Unit of work |
The bytes of each file |
Tensors, each with a name, a dtype, a shape, and a role |
What the compressor sees |
One byte stream per file or per archive |
One tensor at a time, so it can group the bytes of floats, code a tensor against the same tensor of an earlier checkpoint, or quantize it |
Integrity check |
|
A CRC-32 of every chunk, checked on every read, and a CRC-32 of the index. |
Reading one item |
|
The index at the end of the archive lists every tensor, and |
Delta against an earlier checkpoint |
|
Each tensor against the tensor of the same name in a base archive. The archive records the base, and a reader refuses a different one. |
Lossy coding |
None |
Only with |
Use from training code |
A script around the tool, and an unpack step before a resume |
The |
Comparing methods |
Run each tool on its own |
|
Sizes¶
On the 12 checkpoints of the four fine-tuning runs described in Who Jabara is for, tar piped to zstd -3 stored the two checkpoint files in 92.3% of their bytes. Jabara's per-tensor zstd/1 at the same level stored 92.1% of the tensor bytes, bytegroup-zstd/1 84.1%, and zipnn/1 82.9%. The denominators differ. The first counts the bytes of the files, which also hold a header and, in optimizer.pt, pickle data. The others count the bytes of the tensors. zip and gzip were not measured.
Where the general-purpose tools are the better choice¶
None of them needs a Python package, and
tarandgzipcome with most Unix-like systems. Jabara is not on PyPI yet.They take any file.
jabara compresstakes the files of the formats in Checkpoint file formats, and in a directory only the file names listed there. It leaves the other files of a checkpoint directory, such astrainer_state.json, as they are, so Jabara is not a backup tool.Their formats have published specifications: RFC 1952 for
gzip, RFC 8878 for Zstandard, and the APPNOTE of PKWARE forzip. Jabara's archive format is at version 1 (see Archive format).They run outside the training loop. A save with Jabara inside the loop takes longer than a plain save (see Who Jabara is for), and a framework cannot memory-map an archive.
To send a whole checkpoint directory as one file, run tar on the directory after Jabara has compressed it.