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

tar, zip, gzip, zstd

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

gzip stores a CRC-32 of the data, and zip a CRC-32 of each file. A zstd frame can carry a checksum, which the zstd command adds by default. tar has a checksum of each header, not of the data.

A CRC-32 of every chunk, checked on every read, and a CRC-32 of the index. jabara compress verifies each archive before it deletes the original.

Reading one item

zip lists its files in a central directory, so you can extract one file. tar has no index.

The index at the end of the archive lists every tensor, and Archive.read returns one tensor by name.

Delta against an earlier checkpoint

zstd --patch-from compresses a file against a reference file, at the level of bytes

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 allow_lossy=True. The archive stores the largest error of each tensor.

Use from training code

A script around the tool, and an unpack step before a resume

The Trainer adapter, the Lightning plugin, or save_state and load_state. A resume reads the archives.

Comparing methods

Run each tool on its own

jabara bench runs codecs on the same tensors with the same chunking and threads

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 tar and gzip come with most Unix-like systems. Jabara is not on PyPI yet.

  • They take any file. jabara compress takes 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 as trainer_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 for zip. 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.