Built-in codecs¶
A codec turns one chunk of one tensor into bytes and back. Its id has the form <name>/<version>, and an archive records the id and the full parameters of the codec of every tensor. The table and the sections below are generated from the codec registry. The dtypes column lists the dtypes that a codec encodes, and any other dtype raises UnsupportedDtypeError.
With no assigner, Jabara uses
DefaultAssigner:bytegroup-zstd/1forfloat16,bfloat16,float32, andfloat64, andzstd/1for every other dtype.A lossless codec decodes every chunk to the exact bytes it encoded.
An archive can use a lossy codec only when the caller passes
allow_lossy=True. Otherwisewrite_archiveraisesLossyNotAllowedError. The archive records the largest absolute error of each lossy tensor inmax_abs_err.A codec that needs a base codes a tensor as its difference from the tensor with the same name, dtype, and shape in an earlier archive, the base. When the base has no such tensor, the writer uses the
fallbackof theCodecChoice, or raisesMissingBaseErrorif there is none. Reading a delta tensor without its base raisesMissingBaseError.get_codec(codec_id, params)checksparamsagainst the codec'sParamsmodel and raisespydantic.ValidationErrorfor an unknown or invalid parameter. A delta codec also builds its inner codec, so an unknowninnerraisesUnknownCodecError, and an inner codec that is lossy or needs a base raisesValueError.
Each codec section names the works the codec builds on, and how it relates to each. "wraps" means that the codec calls this library. "describes" means that the work describes the method or the format of a library that the codec wraps. "related" means that the work has the same idea, and the codec is this project's own and does not reproduce the work's method.
jabara codecs prints the codec ids. jabara codecs --long adds what this page gives for each codec and whether its extra is installed, jabara codecs ID shows one codec, and --json prints the same as JSON:
$ jabara codecs raw/1
raw/1: Stores the bytes unchanged.
type: lossless; needs no base; dtypes: every dtype; parameters: none
Codec |
Type |
Needs a base |
Dtypes |
Parameters and defaults |
|---|---|---|---|---|
lossless |
no |
all |
|
|
lossy |
no |
|
|
|
lossy |
no |
|
|
|
lossless |
no |
all |
none |
|
lossless |
yes |
all except |
|
|
lossless |
yes |
all |
|
|
lossless |
no |
|
none |
|
lossless |
no |
all |
|
Dtype names: bool, uint8, int8, uint16, int16, float16, bfloat16, uint32, int32, float32, uint64, int64, float64, complex64, complex128.
bytegroup-zstd/1¶
Class: jabara.codecs.builtin.ByteGroupZstdCodec.
Splits the chunk into one byte plane per item byte and compresses each plane with Zstandard. For one-byte
items it is the same as zstd/1.
Parameters: level is the Zstandard compression level of every plane.
References:
related: ZipNN: Lossless Compression for AI Models. Hershcovitch et al., 2025 (paper).
related: Lossless Compression for LLM Tensor Incremental Snapshots. Waddington and Constantinescu, 2025 (paper).
wraps: python-zstandard. Gregory Szorc, 2025 (implementation).
quant8-linear/1¶
Class: jabara.codecs.quant.Quant8LinearCodec.
8-bit codes for 255 equal steps from the chunk minimum to its maximum.
Code c stands for lo + c * scale.
Per chunk, scale = (max - min) / 255 (the exact quotient). With tiny the smallest positive subnormal of
the dtype, abs(x - x_hat) <= m * scale / 2 + 2**-48 * max(abs(x)) + tiny, where m is 1 for float64 and
2 for float16, bfloat16, and float32. No decoded value leaves [min, max]. A chunk whose items all have the
same bits decodes exactly, -0.0 included.
Zeros keep no sign of their own. Entry 0 is lo, the chunk minimum, and no other entry is -0.0. When the
minimum is zero, every zero gets code 0 and decodes to -0.0 if the chunk holds a -0.0, else to +0.0,
so a chunk that mixes 0.0 and -0.0 decodes all its zeros to -0.0. When the minimum is negative, a zero
decodes to +0.0 or to a nonzero value within the bound, so no zero decodes to -0.0.
Payload: the table size in bytes (uint16), the table (entry c is lo + c * scale kept inside
[min, max] and rounded to the dtype, for c up to the largest code used), then the
Zstandard-compressed codes.
Parameters: level is the Zstandard compression level of the 8-bit codes.
References:
related: BitSnap: Checkpoint Sparsification and Quantization in LLM Training. Peng et al., 2025 (paper).
wraps: python-zstandard. Gregory Szorc, 2025 (implementation).
quant8-log/1¶
Class: jabara.codecs.quant.Quant8LogCodec.
Logarithmic steps on the magnitude; the sign of every item is a separate packed bit plane.
Code 0 is the zero code: the item decodes to a signed zero. Codes 1 to 255 are 255 levels of ln(abs(x))
from the chunk's smallest to its largest nonzero magnitude, with step = (ln(max) - ln(min)) / 254;
code c stands for exp(ln_min + (c - 1) * step). With step the exact quotient and m and tiny
as for the linear codec, abs(x - x_hat) <= m * abs(x) * (exp(step / 2) - 1) + 2**-40 * abs(x) + tiny.
No decoded magnitude leaves [min, max] of the nonzero magnitudes. Exact zeros, including -0.0, and every sign are kept
exactly. Payload: the table size in bytes (uint16), the table of magnitudes in the dtype (entry 0 is zero),
the packed sign plane (ceil(n / 8) bytes), then the Zstandard-compressed codes.
Parameters: level is the Zstandard compression level of the 8-bit codes.
References:
related: 8-bit Optimizers via Block-wise Quantization. Dettmers et al., 2021 (paper).
wraps: python-zstandard. Gregory Szorc, 2025 (implementation).
raw/1¶
Class: jabara.codecs.builtin.RawCodec.
Stores the bytes unchanged.
sub-delta/1¶
Class: jabara.codecs.delta.SubDeltaCodec.
Codes the wrap-around difference of the chunk and the base chunk, read as unsigned integers of the item size,
with the inner codec. complex128 raises UnsupportedDtypeError.
Parameters: inner is the id of the lossless codec that codes the difference, and inner_params are its parameters. The
inner codec must not need a base.
References:
related: ULPack: Reference-Conditioned Lossless Compression of Checkpoint Trajectories. Ashok, 2026 (paper).
xor-delta/1¶
Class: jabara.codecs.delta.XorDeltaCodec.
Codes the bitwise XOR of the chunk and the same chunk of the base, with the inner codec. Accepts every dtype.
Parameters: inner is the id of the lossless codec that codes the difference, and inner_params are its parameters. The
inner codec must not need a base.
References:
related: ZipNN: Lossless Compression for AI Models. Hershcovitch et al., 2025 (paper).
related: Lossless Compression for LLM Tensor Incremental Snapshots. Waddington and Constantinescu, 2025 (paper).
zipnn/1¶
Class: jabara.codecs.zipnn.ZipNNCodec.
The zipnn package, with Zstandard as its entropy coder.
Lossless. Handles float16, bfloat16, and float32. Any other dtype raises UnsupportedDtypeError.
The third-party zipnn package is imported on first use. It imports torch, so the first call loads torch into
the process. This import hides the FutureWarning about torch.jit.script that torch issues.
zipnn holds the GIL for a whole call and runs the call on threads of its own, so the container's thread pool
cannot run two chunks at once. with_threads hands it the caller's thread budget instead; the bytes it writes
are the same for every thread count. An instance from get_codec uses one thread.
It needs the zipnn extra.
References:
wraps: ZipNN: A Lossless Compression Library for AI pipelines. ZipNN Contributors, 2026 (implementation).
describes: ZipNN: Lossless Compression for AI Models. Hershcovitch et al., 2025 (paper).
zstd/1¶
Class: jabara.codecs.builtin.ZstdCodec.
Compresses the whole chunk with Zstandard.
Parameters: level is the Zstandard compression level.
References:
wraps: python-zstandard. Gregory Szorc, 2025 (implementation).
wraps: Zstandard - Fast real-time compression algorithm. Meta Platforms, Inc. and affiliates, 2025 (implementation).
describes: Zstandard Compression and the 'application/zstd' Media Type. Collet and Kucherawy, 2021 (specification).