Command line

The jabara command compresses, restores, lists, verifies, and compares checkpoints. PATH is a checkpoint file or directory. The command sections below are generated from the argument parser.

Commands

jabara compress

jabara compress [-h] [--threads N] [--base BASE] [--recursive] [--keep] [--dry-run] [--delta MODE] [--config FILE] [--show-config] PATH

Compress a checkpoint file, or the files it recognises in a checkpoint directory.

With --base BASE (an archive of an earlier checkpoint, or the directory of one), float tensors are stored as differences from the tensors of the same name in it. With --recursive, PATH holds several checkpoint directories (checkpoint-100, checkpoint-200, ...): each is compressed in turn as a directory is, the first failure stops the run, --delta first codes every checkpoint but the first against the first, and --delta previous codes each against the one before it, a chain that restores in order. --dry-run lists what would be compressed and changes nothing.

Argument

Description

-h, -H, --help

print the short (-h) or the full help and exit

PATH

a file, a checkpoint directory, or with --recursive their parent [path]

--threads N

worker threads (default: up to 8) [positive integer]

--base BASE

an archive of an earlier checkpoint, or its directory [path]

--recursive

take every checkpoint directory in PATH, one level down (also --recursive=true or --recursive=false)

--keep

keep the input files (also --keep=true or --keep=false)

--dry-run

print what would be compressed, with its size on disk, and change nothing (also --dry-run=true or --dry-run=false)

--delta MODE

with --recursive: first or previous, the checkpoint each one is coded against

--config FILE

read options from a .json, .yaml, .yml, or .toml file [path]

--show-config

print the settings to be used, as JSON, and exit

jabara decompress

jabara decompress [-h] [--threads N] [--base BASE] [--recursive] [--keep] [--config FILE] [--show-config] PATH

Restore the original file from an archive, or every archive in a directory.

An archive written with --base needs the same --base BASE here. With --recursive, PATH holds several checkpoint directories: each is restored in turn as a directory is, dependants of another checkpoint's archives first, and the first failure stops the run. Without --keep, a checkpoint whose archives a sibling checkpoint still needs as its base is not restored before that sibling.

Argument

Description

-h, -H, --help

print the short (-h) or the full help and exit

PATH

an archive, a checkpoint directory, or with --recursive their parent [path]

--threads N

worker threads (default: up to 8) [positive integer]

--base BASE

an archive of an earlier checkpoint, or its directory [path]

--recursive

take every checkpoint directory in PATH, one level down (also --recursive=true or --recursive=false)

--keep

keep the input files (also --keep=true or --keep=false)

--config FILE

read options from a .json, .yaml, .yml, or .toml file [path]

--show-config

print the settings to be used, as JSON, and exit

jabara ls

jabara ls [-h] [--json] [--recursive] [--config FILE] [--show-config] PATH

List the tensors of an archive, or of every archive in a directory. A directory without one is an error.

With --recursive, PATH holds several checkpoint directories, and the archives of each are listed.

Argument

Description

-h, -H, --help

print the short (-h) or the full help and exit

PATH

an archive or a directory, or with --recursive their parent [path]

--json

print JSON (also --json=true or --json=false)

--recursive

take every checkpoint directory in PATH, one level down (also --recursive=true or --recursive=false)

--config FILE

read options from a .json, .yaml, .yml, or .toml file [path]

--show-config

print the settings to be used, as JSON, and exit

jabara verify

jabara verify [-h] [--threads N] [--base BASE] [--recursive] [--config FILE] [--show-config] PATH

Decode every chunk of an archive, or of every archive in a directory, and check its checksum.

A directory without an archive is an error. A delta archive needs --base BASE, as for decompress. With --recursive, PATH holds several checkpoint directories: every archive of each is checked, a delta archive against the archives of the other checkpoints that it names, and a failure does not stop the others.

Argument

Description

-h, -H, --help

print the short (-h) or the full help and exit

PATH

an archive or a directory, or with --recursive their parent [path]

--threads N

worker threads (default: up to 8) [positive integer]

--base BASE

the base archive of a delta archive, or its directory [path]

--recursive

take every checkpoint directory in PATH, one level down (also --recursive=true or --recursive=false)

--config FILE

read options from a .json, .yaml, .yml, or .toml file [path]

--show-config

print the settings to be used, as JSON, and exit

jabara export-weights

jabara export-weights [-h] [--config FILE] [--show-config] ARCHIVE OUT

Write the weight tensors of ARCHIVE as a safetensors file.

Argument

Description

-h, -H, --help

print the short (-h) or the full help and exit

ARCHIVE

[path]

OUT

the safetensors file to write; must not exist [path]

--config FILE

read options from a .json, .yaml, .yml, or .toml file [path]

--show-config

print the settings to be used, as JSON, and exit

jabara bench

jabara bench [-h] [--json] [--base BASE] [--repeats N] [--threads N] [--candidates a,b,c] [--config FILE] [--show-config] PATH

Compare codecs in memory on the tensors of PATH: an archive, a safetensors or torch file, or a directory.

Default candidates are the lossless codecs that need no base; with --base (a path of the same kinds) the delta codecs join them. --candidates a,b,c names codecs instead, lossy ones included. It takes no --recursive: it holds every tensor in memory, and a parent of several checkpoints would multiply that.

Argument

Description

-h, -H, --help

print the short (-h) or the full help and exit

PATH

an archive, a safetensors or torch file, or a directory [path]

--json

print the report as JSON (also --json=true or --json=false)

--base BASE

the base tensors, a path of the same kinds [path]

--repeats N

timed runs per codec [positive integer, default 3]

--threads N

worker threads (default: up to 8) [positive integer]

--candidates a,b,c

the codecs to compare instead of the default ones [codec ids, comma-separated]

--config FILE

read options from a .json, .yaml, .yml, or .toml file [path]

--show-config

print the settings to be used, as JSON, and exit

jabara codecs

jabara codecs [-h] [--long] [--json] [--config FILE] [--show-config] [ID]

List the registered codecs: their ids, or with --long, --json or an ID what each is and builds on.

Argument

Description

-h, -H, --help

print the short (-h) or the full help and exit

ID

show everything about this codec

--long

show each codec's properties and references (also --long=true or --long=false)

--json

print JSON: a list of codecs, or one codec for an ID (also --json=true or --json=false)

--config FILE

read options from a .json, .yaml, .yml, or .toml file [path]

--show-config

print the settings to be used, as JSON, and exit

jabara help

jabara help [-h] [COMMAND]

Print the full help of jabara or of a command.

Argument

Description

-h, -H, --help

print the short (-h) or the full help and exit

COMMAND

a command; jabara itself without it [command name]

jabara man

jabara man [-h] [COMMAND]

Show the manual page of jabara or of a command.

Argument

Description

-h, -H, --help

print the short (-h) or the full help and exit

COMMAND

a command; jabara itself without it [command name]

Files and directories

  • compress on a file takes *.safetensors, *.pt, *.pth, *.bin, *.ckpt, *.npy, *.npz, *.gguf, *.h5, *.hdf5, and *.keras, and writes <name>.jbr next to it. On a directory it takes the regular files named *.safetensors, optimizer.pt, optimizer.bin, pytorch_model*.bin, *.ckpt, mp_rank_*_model_states.pt, *_optim_states.pt, or model_optim_rng.pt, not recursively, and leaves every other file alone. Checkpoint file formats lists the frameworks that write these files. decompress writes each file back byte for byte when its archive is lossless. The files of a sharded model, such as model-00001-of-00002.safetensors, get one archive each, and model.safetensors.index.json stays. A directory with none of them is an error.

  • decompress on a file takes *.jbr and writes the name without the suffix. It refuses to write over a file that exists. On a directory it restores every *.jbr file.

  • Before they change anything, compress and decompress refuse a file that sits next to its own archive (model.safetensors beside model.safetensors.jbr). Remove one of the two first.

  • On a directory, compress and decompress are all or nothing. They write and verify every output first, then delete the inputs unless you pass --keep. If one file fails, they delete the outputs that they wrote, and every input stays in place.

  • ls and verify take an archive or a directory. On a directory they read its *.jbr files, and a directory with no archive is an error.

  • For compress, decompress, and verify, --base names an archive of an earlier checkpoint, or the directory of that checkpoint, for a file and for a directory alike. With a directory, each tensor is coded against the tensor of the same name in any of its archives, and the directory must hold no checkpoint file without its archive. An archive written with compress --base needs a --base that holds its base archives for decompress and verify. For bench, --base is a path of any kind that bench reads.

  • export-weights writes the tensors with the role weight to a safetensors file.

    • For an archive of a safetensors file, every tensor has that role, and the output is the original file, byte for byte.

    • For any other archive, the output holds the tensors with the role weight and leaves the rest out. An archive made with save_state and WeightsSchema has only such tensors.

    • compress gives the tensors of a torch file the optimizer roles by their path, so the tensors of a model state_dict get the role other. export-weights refuses that archive, prints jabara: model.pt.jbr: no tensors with role 'weight' and exits with status 1. The same holds for an archive of optimizer.pt.

    • OUT must not exist.

    • export-weights takes no base, so it cannot read a delta archive.

  • bench reads an archive, a file that compress takes, or a directory. In a directory it reads the files that compress takes and the *.jbr files, and prefixes each tensor name with the file name and /. An archive counts under the name of the file that it restores, so a compressed and an uncompressed directory give the same tensor names. A directory that holds a file and its archive is an error. bench cannot read a delta archive.

A parent directory of checkpoints

compress, decompress, verify, and ls take --recursive. PATH is then a parent, such as the output_dir of a Hugging Face Trainer, and the command works on its checkpoints one after the other.

  • A checkpoint directory directly holds a regular file that compress takes in a directory, or a *.jbr archive. The checkpoints are the immediate subdirectories that are checkpoint directories, in natural order of name (checkpoint-200 before checkpoint-1000), then PATH itself last if it is one. A directory such as best sorts before checkpoint-*, and with --delta it becomes the first checkpoint, so check the order with --dry-run. The walk goes one level down, never deeper, and skips hidden directories and symbolic links to directories. Files that are not checkpoint files are never touched. jabara.files.checkpoint_dirs(path) returns the same list in Python.

  • Without --recursive, a PATH that holds no file of its own to work on is still an error. The message names the checkpoint directories that it found and suggests --recursive.

  • compress and decompress take one checkpoint at a time, each all or nothing, and stop at the first failure. The checkpoints before it stay done, so disk space is freed as the run goes. The one that failed and the later ones stay as they were. The command exits with status 1 and prints one line, jabara: <checkpoint>: <error>; stopped there: <k> checkpoints done or skipped before it, this one and <n> after it left as they were. Before it changes anything, the command refuses a file beside its own archive in any checkpoint.

  • A checkpoint with nothing to do prints <dir>: skipped, already compressed (already decompressed for decompress) and is not an error. After a stop, run the same command again.

  • compress --dry-run works with any PATH. It prints what would be compressed and its size on disk, after the same refusals, without reading a tensor and without changing anything.

  • compress --recursive --delta first compresses the first checkpoint, in the order above, as full archives, or uses it as it is if it holds only full archives. It codes every other checkpoint, PATH itself included, against that first one, as --base does for a directory. A first checkpoint that holds a delta archive is refused. compress --recursive --delta previous codes every checkpoint but the first against the checkpoint before it in that order, so the archives form a chain, and a checkpoint compressed earlier stays as it is: a later run codes a new checkpoint against the last one. A restore follows the chain: the checkpoint at position k decodes k archives per tensor, and one lost archive loses every checkpoint after it. Use first when any checkpoint may be needed at any time, and previous when most are rarely read and disk is the constraint (the how-to guide has measurements). --delta needs --recursive and cannot be combined with --base, and --recursive cannot be combined with --base: each is a usage error.

  • decompress --recursive and verify --recursive find the base archives of a delta archive among the archives of the other checkpoints, by the recorded file name and index CRC-32. decompress --recursive restores the checkpoints that hold delta archives before the ones they need, so in a chain the last checkpoint goes first. It checks every base first, down each chain, so a base that no checkpoint holds stops it before it restores anything. For a link behind an archive's own base, the message names both archives: <archive>: <owner>: base <name> (index crc <c>) is missing or changed.

  • decompress of a checkpoint directory or of one archive, without --keep, is refused before it changes anything when a sibling checkpoint holds a delta archive written against an archive that it would delete, and no copy of that archive (the same index CRC-32) remains in a sibling. Decompress those first, or pass --keep. decompress --recursive makes the same check for PATH itself, whose siblings are not checkpoints of the parent. A delta archive whose base lies outside the parent stops decompress --recursive: restore that checkpoint on its own with --base.

  • Do not delete or move a checkpoint of a parent compressed with --delta while a later one is compressed. jabara.hf.attach(trainer, delta="first") writes the first layout and keeps the first checkpoint when the Trainer rotates old ones.

  • bench takes no --recursive. It holds every tensor in memory, and a parent would multiply that.

Output

Sizes are tensor bytes, not file sizes: <raw> counts the bytes of the tensors, and <stored> counts their encoded chunks. The percentage is 100 * stored / raw with one decimal, or empty when raw is 0.

  • compress prints one line per archive: <path>: <raw> -> <stored> bytes (<p>% of original).

  • decompress prints the path of each restored file.

  • With --recursive, compress and decompress print their usual lines for each checkpoint, then <dir>: <n> archives, <raw> -> <stored> bytes (<p>% of original), and at the end total: <k> checkpoints, <s> skipped, <raw> -> <stored> bytes (<p>% of original). <k> counts every checkpoint found, and <s> the skipped ones. decompress takes the sizes from the archives before it restores them.

  • compress --dry-run prints <path>: would compress, <n> bytes on disk per file and a last line total: <n> files, <size> bytes on disk. With --recursive it also prints <dir>: <n> files, <size> bytes on disk per checkpoint (followed by , delta against <base> with --delta), and the last line is total: <k> checkpoints, <s> skipped, <n> files, <size> bytes on disk.

  • ls prints one line per archive, <path>: <n> tensors, <raw> -> <stored> bytes (<p>% of original), then one line per tensor with its name, dtype, shape, role, codec, and sizes. ls --json prints a JSON list of objects with the keys path and tensors, also with --recursive.

  • verify prints ok <path> for each archive. verify --recursive checks every archive and does not stop at the first failure. It prints FAILED <path>: <reason> for an archive that fails, such as base <name> (index crc <c>) is missing or changed, and exits with status 1 after jabara: <m> of <n> archives failed.

  • export-weights prints nothing.

  • codecs prints one codec id per line. Built-in codecs describes codecs --long, codecs ID, and codecs --json.

  • bench prints a header line, <n> threads, best of <repeats>, <w> warm-up, chunk <size> bytes, then one line per candidate and role: sizes, encode and decode throughput in MB/s (10^6 bytes per second), and exact or NOT EXACT. Throughput is the raw bytes divided by the smallest of the timed runs. A run times only the codec's encode or decode of the chunks in memory, not file access. <w> untimed rounds run first. In every round, each candidate in turn encodes and decodes once, and the candidate order reverses on every other timed round. Right before each timed encode and decode, the pool's threads and the calling thread run a busy loop for 0.1 s, untimed. A lossy row that decoded adds max_abs_err=<value>. When a decode failed, the line says decode failed (<message>) in place of the decode throughput. When a delta candidate fell back for some tensors, the line ends with , 1 tensor used the fallback for one tensor and , <n> tensors used the fallback for more. The command exits 0 even with a NOT EXACT row. bench --json prints the report described in JSON schemas.

Parsing rules

jabara parses and checks the whole argument list before it runs a command, so an argument list that it refuses, or that asks for help, changes no file. The first of these rules that matches decides:

  1. -h, -H, or --help, spelled exactly that way and placed anywhere, prints the help of the command named first, or the overview if the first argument is not a command. -h prints the short help, and -H and --help print the full help. It exits 0 and runs nothing. Another spelling, such as -hx, -hh, or --help=x, is a usage error. No other short flag exists.

  2. -- is a usage error wherever it stands.

  3. Every other argument that starts with - must be a flag of the command. It is never a path or a value. Write a path that starts with - as ./-name. An unknown flag, a misspelled flag, a prefix of a flag (--kee), and a flag of another command are usage errors.

  4. Every other argument is a string. Nothing is read as a Python literal, so run#2, 123, a,b, and True are paths. An empty path, such as the one an unset "$CKPT" gives, is a usage error. A missing positional argument or a surplus one is a usage error.

  5. --keep, --json, --recursive, and --dry-run are switches. --keep, --keep=true, and --keep=false are accepted, and any other value, such as --keep=0, is a usage error. A switch takes no separate value, so in --keep false the word false is a surplus argument.

  6. --threads and --repeats take a positive integer in ASCII digits, as --threads 2 or --threads=2. --candidates takes one codec id, or several separated by commas. A flag given twice takes the last value.

Configuration files

compress, decompress, ls, verify, export-weights, bench, and codecs take --config FILE, a .json, .yaml, .yml, or .toml file that holds a mapping. Run from a config file shows one of each.

  • The keys are the destinations of the command's own options and arguments: the long option names with underscores (base, keep, threads, candidates) and the names of the positional arguments (path, archive, out). The generated sections above list them. An option that a later version adds is a key without another change.

  • The precedence is the command line, then the file, then the defaults. A positional argument on the command line replaces the same one of the file, and the command line fills them from the left.

  • The values have the types of the command line: a string for a path, an integer for a count, true or false for a switch, and a list of strings for candidates. Each value goes through the checks of its option, so threads = 0 fails as --threads 0 does. A key that the command lacks, a value of another type, null, a suffix that is not listed, text that does not parse, and a top level that is not a mapping are usage errors. config and show_config are not keys.

  • A usage error from a file prints one line, jabara: <file>: key '<key>': <reason> or jabara: <file>: <reason>, and exits with status 2. A file that cannot be read exits with status 1. A YAML file without PyYAML exits with status 1 and says to install jabara[yaml].

  • --show-config prints {"command": ..., "config": ..., "settings": {...}} as JSON, with every key of the command, and exits with status 0. It runs nothing.

  • YAML is read with PyYAML's safe_load. TOML is read with tomllib, or with tomli on Python 3.10.

Help and manual pages

jabara help COMMAND prints the same text as jabara COMMAND --help. jabara with no argument prints the short overview on standard error and exits 2, as a usage error.

The package installs a manual page for jabara and for each command, such as jabara-compress(1), under share/man/man1 of its environment. man jabara finds them when the environment's bin directory is on PATH, as in an activated virtual environment or after pipx install. uv tool install does not link them. jabara man COMMAND shows the same page anywhere. When standard output is not a terminal, it prints the page's roff source.

Exit status

Status

When

0

The command succeeded, or help was printed.

1

The command raised a JabaraError, an OSError, or a ValueError. jabara prints one line, jabara: <message>, to standard error.

2

Usage error. jabara prints the usage line and one error line to standard error, and runs no command. A bad configuration file gives one line, jabara: <file>: <message>, and no usage line.

Any other exception is not caught and ends the command with a Python traceback.