Jabara
Theme

Compress a training checkpoint in your browser

Jabara is a Python library that compresses training checkpoints: the model weights and the optimizer state. Each kind of tensor can get its own codec. Press the button to run the real library on a small checkpoint on your device, and see how many bytes each codec stores and whether it decodes to the same bytes.

    Your own file or codec, the other checkpoint, or other codecs
    Checkpoint

    Your own codec

    Write a codec in Python: subclass Codec, set id to name/version and lossless to True or False, implement encode and decode, and register the class with @register_codec. Every codec the code registers joins the comparison beside the built-in ones, and the library checks its round trip the same way. The code runs only in this browser, in the worker that runs the library, and is not uploaded. The editor keeps it in this browser. What the code changes in the library stays until the page is reloaded.

    Tab indents and Shift+Tab outdents. To leave the editor with the keyboard, press Esc, then Tab.

    Checked to import in the worker with no extra download: numpy, zlib, bz2, lzma, struct, zstandard. Most of Python's standard library comes with the runtime; of other packages, only those the library needs are installed, and the page installs nothing for your code.

    Use the file with the installed library

    The jabara command knows only the built-in codecs. In Python, importing the file registers yours, and then every function that takes a codec id accepts it:

    Python
    import my_codec  # registers the codecs in my_codec.py
    from jabara.bench import candidates_for, compare
    from jabara.files import load_records
    
    report = compare(load_records("model.safetensors"), candidates_for(["bytegroup-lzma/1", "zstd/1"]))
    What a training checkpoint holds
    Weights
    The model's parameters: what you need to run the model.
    First moment
    Adam's running average of each weight's gradient. One value per weight.
    Second moment
    Adam's running average of each weight's squared gradient. One value per weight, never negative.
    Step counter
    How many updates the optimizer has made. A few bytes: the thin bar is wider than its true share.

    Adam keeps two values for every weight, so the optimizer state is twice the size of the weights when they share a dtype. The parts hold different kinds of numbers, so Jabara records the role of each tensor and can give each role its own codec.

    Result

    Computed on this device

    Each result above is computed by Jabara in this browser, on this device. Nothing is uploaded: the checkpoint, the file you choose, your own codec and the results stay here. This is what the browser tells a page about the device.

    Browser
    …
    Operating system, as the browser reports it
    …
    Logical processors, as the browser reports them
    …
    Memory, as the browser reports it
    …
    Processor model
    …
    Pyodide
    …
    Python
    …
    Jabara, the wheel that ran
    …
    Threads
    …

    Results measured on full-size checkpoints, and the machine each was measured on, are on the results page.

    Every role in a table, with encode and decode times and the environment

    Stored is the sum of the chunk payloads over the raw tensor bytes; smaller is better. A role under 1 KiB is listed in a note and not charted. A lossy row shows the largest error it introduced.

    About this demo

    What runs here

    Limits
      Units and the clock