jabara 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jabara-0.2.1/.gitignore +27 -0
- jabara-0.2.1/CHANGELOG.md +84 -0
- jabara-0.2.1/LICENSE +21 -0
- jabara-0.2.1/PKG-INFO +166 -0
- jabara-0.2.1/README.md +117 -0
- jabara-0.2.1/docs/man/man1/jabara-bench.1 +84 -0
- jabara-0.2.1/docs/man/man1/jabara-codecs.1 +84 -0
- jabara-0.2.1/docs/man/man1/jabara-compress.1 +120 -0
- jabara-0.2.1/docs/man/man1/jabara-decompress.1 +94 -0
- jabara-0.2.1/docs/man/man1/jabara-export-weights.1 +57 -0
- jabara-0.2.1/docs/man/man1/jabara-help.1 +35 -0
- jabara-0.2.1/docs/man/man1/jabara-join.1 +60 -0
- jabara-0.2.1/docs/man/man1/jabara-ls.1 +87 -0
- jabara-0.2.1/docs/man/man1/jabara-man.1 +37 -0
- jabara-0.2.1/docs/man/man1/jabara-split.1 +76 -0
- jabara-0.2.1/docs/man/man1/jabara-verify.1 +72 -0
- jabara-0.2.1/docs/man/man1/jabara.1 +120 -0
- jabara-0.2.1/pyproject.toml +280 -0
- jabara-0.2.1/src/jabara/__init__.py +3 -0
- jabara-0.2.1/src/jabara/_codec_list.py +153 -0
- jabara-0.2.1/src/jabara/_config.py +184 -0
- jabara-0.2.1/src/jabara/_durable.py +64 -0
- jabara-0.2.1/src/jabara/_help.py +527 -0
- jabara-0.2.1/src/jabara/_man.py +131 -0
- jabara-0.2.1/src/jabara/assign.py +64 -0
- jabara-0.2.1/src/jabara/bench.py +561 -0
- jabara-0.2.1/src/jabara/cli.py +965 -0
- jabara-0.2.1/src/jabara/codecs/__init__.py +25 -0
- jabara-0.2.1/src/jabara/codecs/_references.py +85 -0
- jabara-0.2.1/src/jabara/codecs/base.py +93 -0
- jabara-0.2.1/src/jabara/codecs/builtin.py +143 -0
- jabara-0.2.1/src/jabara/codecs/delta.py +106 -0
- jabara-0.2.1/src/jabara/codecs/quant.py +215 -0
- jabara-0.2.1/src/jabara/codecs/registry.py +40 -0
- jabara-0.2.1/src/jabara/codecs/zipnn.py +117 -0
- jabara-0.2.1/src/jabara/container.py +1024 -0
- jabara-0.2.1/src/jabara/errors.py +49 -0
- jabara-0.2.1/src/jabara/files.py +783 -0
- jabara-0.2.1/src/jabara/formats/__init__.py +98 -0
- jabara-0.2.1/src/jabara/formats/_protobuf.py +108 -0
- jabara-0.2.1/src/jabara/formats/_zip.py +102 -0
- jabara-0.2.1/src/jabara/formats/base.py +71 -0
- jabara-0.2.1/src/jabara/formats/coreml.py +86 -0
- jabara-0.2.1/src/jabara/formats/flax_msgpack.py +204 -0
- jabara-0.2.1/src/jabara/formats/gguf.py +164 -0
- jabara-0.2.1/src/jabara/formats/hdf5.py +160 -0
- jabara-0.2.1/src/jabara/formats/mindspore.py +121 -0
- jabara-0.2.1/src/jabara/formats/npy.py +118 -0
- jabara-0.2.1/src/jabara/formats/onnx.py +167 -0
- jabara-0.2.1/src/jabara/formats/registry.py +82 -0
- jabara-0.2.1/src/jabara/formats/safetensors.py +158 -0
- jabara-0.2.1/src/jabara/formats/splice.py +168 -0
- jabara-0.2.1/src/jabara/formats/tensorflow.py +192 -0
- jabara-0.2.1/src/jabara/formats/torch_zip.py +290 -0
- jabara-0.2.1/src/jabara/hf.py +289 -0
- jabara-0.2.1/src/jabara/lightning.py +99 -0
- jabara-0.2.1/src/jabara/parts.py +387 -0
- jabara-0.2.1/src/jabara/py.typed +0 -0
- jabara-0.2.1/src/jabara/schemas.py +50 -0
- jabara-0.2.1/src/jabara/skeleton.py +178 -0
- jabara-0.2.1/src/jabara/torch.py +197 -0
- jabara-0.2.1/src/jabara/types.py +94 -0
jabara-0.2.1/.gitignore
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
.venv/
|
|
5
|
+
.ruff_cache/
|
|
6
|
+
.pytest_cache/
|
|
7
|
+
*.egg-info/
|
|
8
|
+
build/
|
|
9
|
+
dist/
|
|
10
|
+
.tox/
|
|
11
|
+
.mypy_cache/
|
|
12
|
+
|
|
13
|
+
# Data: keep the directory skeleton, ignore the contents
|
|
14
|
+
data/**
|
|
15
|
+
!data/*/
|
|
16
|
+
!data/*/.gitkeep
|
|
17
|
+
|
|
18
|
+
# OS / editor
|
|
19
|
+
.DS_Store
|
|
20
|
+
|
|
21
|
+
# local scratch: decision trail, logs
|
|
22
|
+
.audit/
|
|
23
|
+
*.log
|
|
24
|
+
|
|
25
|
+
# Documentation build output
|
|
26
|
+
docs/_build/
|
|
27
|
+
docs/ja/locale/**/*.mo
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Notable changes to the `jabara` package, the `jabara` command, the site, and the docs.
|
|
4
|
+
Each version is a [GitHub release](https://github.com/iamtatsuki05/jabara/releases). From 0.2.1, each version is also on [PyPI](https://pypi.org/project/jabara/).
|
|
5
|
+
|
|
6
|
+
## [Unreleased]
|
|
7
|
+
|
|
8
|
+
## [0.2.1] - 2026-12-01
|
|
9
|
+
|
|
10
|
+
The first version on PyPI.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `jabara --version` prints `jabara <version>`, such as `jabara 0.2.1`, and exits 0. It stands alone: with any other argument, or after a command, it is a usage error.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Jabara is published on PyPI. Install it with `pip install jabara`, an extra with `pip install "jabara[torch]"`, or in a uv project with `uv add jabara`. The README files, the installation pages in English and Japanese, the project and About pages, and `llms.txt` say so; installing from a clone is for working on Jabara itself.
|
|
19
|
+
- The message for a missing `zipnn` package says `pip install "jabara[zipnn]"`, like the other missing extras.
|
|
20
|
+
|
|
21
|
+
## [0.2.0] - 2026-12-01
|
|
22
|
+
|
|
23
|
+
Archives that 0.1.0 wrote still decompress. Some archives that 0.2.0 writes need 0.2.0 to decompress; "Changed" lists them, with the other changes that a user of 0.1.0 can notice.
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
- Checkpoint file formats are a registry, `jabara.formats`: a format is one `CheckpointFormat` subclass with `@register_format`, and the formats reference page is generated from the registry. A format may share a name pattern with another when it overrides `CheckpointFormat.claims`. `jabara.formats.splice` holds what the formats share, and the extend how-to shows the built-in `.npy` format as a whole entry. The formats reference page also lists the formats Jabara does not take, with the reason for each.
|
|
28
|
+
- New checkpoint file formats, each restored byte for byte from a lossless archive:
|
|
29
|
+
- `torch-zip`: any file that `torch.save` wrote in its zip layout, read without unpickling it: `pytorch_model*.bin`, Accelerate's `optimizer.bin`, PyTorch Lightning's `*.ckpt`, DeepSpeed's `mp_rank_*_model_states.pt` and `*_optim_states.pt`, and Megatron-LM's `model_optim_rng.pt`, besides `optimizer.pt`. Tensor names and roles come from `torch.load(weights_only=True)`; when torch is not installed or refuses a file, the tensors get the role `other`, and a refusal prints one line on stderr.
|
|
30
|
+
- NumPy `.npy` and `.npz` (from `np.savez`, or MLX's `mx.savez`), GGUF, and HDF5 files such as Keras 3's `.weights.h5` and `.keras` (with the new `hdf5` extra, which installs `h5py`). They are taken when named on their own, not from a checkpoint directory.
|
|
31
|
+
- TensorFlow, MindSpore, ONNX, and Core ML, each read with the standard library alone, so no new extra: a TensorFlow data shard (`*.data-00000-of-00001`, its tensors located by the `.index` next to it, which stays), a MindSpore `.ckpt` (told apart from a Lightning `.ckpt` by its first bytes), an ONNX model (`*.onnx`) and its external data file (`<model>.onnx.data` or `<model>.onnx_data`), and the `weight.bin` of a Core ML ML program (told apart from a `torch.save` `weight.bin` the same way). `compress` on a directory also takes TensorFlow shards and MindSpore checkpoints. A TensorFlow shard, and a MindSpore checkpoint saved with `crc_check=True`, keep checksums that Jabara cannot rewrite, so they are compressed only losslessly: a lossy codec raises `LossyNotAllowedError` that says why.
|
|
32
|
+
- Flax msgpack files, the JAX checkpoint that fits a byte-for-byte restore: a file that `flax.serialization.to_bytes` wrote (`*.msgpack` named on its own, and a Hugging Face Flax model's `flax_model*.msgpack` in a directory), read without msgpack or Flax, each array a tensor named by its path, Optax state under `opt_state` with the role `other`.
|
|
33
|
+
- An archive can be written as several files and joined back. `jabara compress --part-size SIZE` (`2GB`, `500MiB`; `KB`, `MB`, `GB`, `TB` count 1000s, `KiB`, `MiB`, `GiB`, `TiB` count 1024s) and `--parts N` cut each archive into parts of at most that size or into that many parts, and the new `jabara split` and `jabara join` change an archive that exists without encoding it again; `compress_file`, `compress_dir`, `jabara.files.split_archive`, `jabara.files.join_archive`, and `jabara.parts.parse_size` are the Python side. The first part keeps the name of the archive and the others are `<name>.002`, `<name>.003`, and so on. Cuts fall between chunks, so every chunk keeps its CRC-32; every command that takes an archive takes the first part and reads the parts as one; `join` restores the archive byte for byte; a part that is missing, out of order, truncated, or from another archive is an `ArchiveFormatError` before any chunk is read. Delta archives can be split and can be bases. The archive format version is unchanged, and single-file archives are read and written as before. A how-to page, "Split an archive into parts and join it back", and the archive format reference describe it.
|
|
34
|
+
- `jabara compress`, `decompress`, `verify`, and `ls` take `--recursive` for a directory of checkpoint directories (`checkpoint-100`, `checkpoint-200`, ...), and `jabara.files.checkpoint_dirs` lists them. Each checkpoint stays all or nothing, a failure stops the run with one line that says how far it got, and a second run skips what is done. `compress --dry-run` lists what would be compressed. `compress --recursive --delta first` codes every checkpoint but the first against the first, and `--delta previous` codes each against the one before it, a chain (a restore of the checkpoint at position k decodes k archives per tensor, and one lost archive loses every checkpoint after it; the how-to guide has measurements and the setup). `Archive.open` and `open_bases` take a delta archive as a base when it is opened with its own base, and `jabara.files` finds the base of a delta archive among the archives beside it. A missing link is reported with the archive that lacks its base; `decompress` and `verify` find the base archives among the other checkpoints, and `decompress` refuses to delete archives that a sibling directory needs unless that sibling is restored first or you pass `--keep`. `compress_file` refuses to replace an archive that a sibling checkpoint needs as its base.
|
|
35
|
+
- `jabara compress`, `decompress`, and `verify` take `--base` as the directory of an earlier compressed checkpoint, for a single file or for a checkpoint directory, and so do `compress_file`, `decompress_file`, `compress_dir`, and `decompress_dir` in Python. Each tensor is coded against the tensor of the same name in any archive of that directory, so the two checkpoints may split their weights over files differently.
|
|
36
|
+
- `jabara.hf.attach(trainer, delta="first")` saves each checkpoint as a delta against the oldest earlier checkpoint that is fully compressed, and resumes from delta checkpoints, `load_best_model_at_end` included. The adapter rotates checkpoints itself in this mode: a checkpoint that a kept one needs as its base is kept and counts toward `save_total_limit`, so no delta archive loses its base. `save_total_limit=1` is refused, because the `Trainer` would delete the base at the end of training. `jabara.lightning.JabaraCheckpointIO` writes full archives only; `delta` raises `ValueError` and says why.
|
|
37
|
+
- `jabara decompress --jobs N` restores `N` archives of a directory at the same time, and `decompress_dir(path, jobs=N)` is the Python side. The default 1 restores them one after another, as before. It is faster for a directory of many files and holds about `N` files in memory at once; `--threads` stays the total, shared among the archives, though each archive uses at least one thread. The restored bytes, the messages, and the all-or-nothing behavior do not change, and a failure reports the error of the first failing archive in name order, as one at a time does. A how-to page, "Restore many files at once", has an illustrative measurement of the time and the memory.
|
|
38
|
+
- Every command but `help` and `man` takes `--config FILE`, a JSON, YAML, or TOML file whose keys are the options and arguments of the command. The command line wins over the file, and the file wins over the defaults. A key that the command lacks, a value of the wrong type, and a suffix that is not `.json`, `.yaml`, `.yml`, or `.toml` are usage errors with one `jabara:` line. `--show-config` prints the settings that would be used, as JSON, and runs nothing. YAML needs the new `yaml` extra (PyYAML). A how-to page, "Run from a config file", shows it.
|
|
39
|
+
- `jabara -h` and `jabara COMMAND -h` print a short help: the usage, one line per option, and an example. `--help`, `-H`, and `jabara help COMMAND` print the full help: what the command reads, writes, and prints, every option with the values it takes and its default, the exit status, examples, and related commands. `jabara` with no argument prints the short help and still exits 2.
|
|
40
|
+
- Manual pages: the package installs `jabara(1)` and one page per command, such as `jabara-compress(1)`, so `man jabara` works in a virtual environment or after `pipx install`. `jabara man COMMAND` opens the same page with man(1) on a terminal, and prints its roff source when the output is not a terminal.
|
|
41
|
+
- `jabara codecs --long`, `jabara codecs ID`, and `jabara codecs --json` show each codec's properties (lossless or lossy, base, dtypes, parameters, optional package and whether it is installed) and the works it builds on: the library it wraps, the paper or specification behind that library, and related work for the codecs that are Jabara's own. The codec reference and the project page list the same works. `jabara codecs` alone still prints one id per line.
|
|
42
|
+
- An agent skill for the `jabara` command in `skills/jabara/`, installable in Claude Code as the `jabara` plugin (`/plugin marketplace add iamtatsuki05/jabara`), in Codex and GitHub Copilot CLI from the same marketplace, in Gemini CLI with `gemini skills install`, and in Cursor through `.cursor-plugin/marketplace.json`; other agents read it once it is copied into their `.agents/skills/` folder. A how-to page, "Use Jabara from an AI agent", gives the command's guarantees to a program that runs it. `AGENTS.md` gives the rules for agents that change the code base.
|
|
43
|
+
- The package marks itself as typed (`py.typed`), so type checkers read its annotations.
|
|
44
|
+
- Documentation for readers who are deciding whether Jabara fits: "Who Jabara is for", one section per use case with the measured sizes and times and what Jabara is not for, and "Jabara and general-purpose archivers", a comparison with `tar`, `zip`, `gzip`, and `zstd` that says where the general tools are the better choice, both in English and Japanese. The how-to guide "Compress the checkpoints of many runs" compresses the checkpoint directories of several runs and measures a delta against another run with `jabara bench --base`. The README files and the About page have a "Who it is for" section.
|
|
45
|
+
- The live demo lets a visitor write a codec in the page and run it beside the built-in ones, with the library's own check of the round trip, and it says which device computed the result, naming Chromium browsers by brand. The results viewer shows the machine and software of each report, and the reports carry keys for them and positional large errors.
|
|
46
|
+
|
|
47
|
+
### Changed
|
|
48
|
+
|
|
49
|
+
- Torch files come back byte for byte: `optimizer.pt` and other `torch.save` files are restored as the same bytes, where 0.1.0 restored the same state with `torch.save`. A torch file that `weights_only=True` refuses is now compressed instead of refused, and `compress` and `bench` on torch files no longer need torch installed.
|
|
50
|
+
- `compress` on a checkpoint directory replaces more files with archives: besides `*.safetensors` and `optimizer.pt`, every file that a format takes in a directory (`optimizer.bin`, `pytorch_model*.bin`, `*.ckpt`, the DeepSpeed and Megatron-LM files, TensorFlow shards, `flax_model*.msgpack`). Without `--keep` the originals are deleted, as before. `jabara.hf.attach` compresses the same files, so a `pytorch_model*.bin` in a checkpoint is compressed too, and resume restores it.
|
|
51
|
+
- Archives that 0.1.0 cannot decompress: an archive written from a file in a new format, including the `torch-zip` archives of torch files, which 0.1.0 still lists and verifies; the parts of a split archive; a delta archive whose tensors refer to more than one base archive (archive format 2, which 0.1.0 refuses with `ArchiveFormatError`; every other archive stays format 1); and a delta archive whose base is itself a delta archive.
|
|
52
|
+
- On Python 3.10 the package depends on `tomli`, to read TOML config files.
|
|
53
|
+
- `jabara -h` prints the short help instead of argparse's full help; `--help` prints the full one.
|
|
54
|
+
- The site moved from `https://iamtatsuki05.github.io/jabara/` to `https://jabara.iamtatsuki05.com/`. The canonical and social URLs, `robots.txt`, `sitemap.xml`, `rss.xml`, `llms.txt`, the command help, the manual pages, the README files, the documentation, and the plugin metadata name the new address. The old address redirects to it. The site is built and tested at the root `/`, and the end-to-end tests run in Chromium, Firefox, and WebKit against that build.
|
|
55
|
+
- One term for each concept in the documentation, the READMEs, the site, `llms.txt`, and the docstrings behind the generated reference: the lossless or lossy column of the codec tables is "Type" (it was "Kind") on the project page, in the README files, and in the codec reference, and the Japanese exit-status table is headed 終了ステータス. "Base" replaces "ref" for what a delta codes against, and the spelling is American (-ize), with serial commas. `docs/ja/README.md` lists the Japanese terms, and `tests/docs/test_terms.py` keeps the replaced variants out.
|
|
56
|
+
- The README files, the documentation index, "Who Jabara is for", the scope and archiver pages, the About page, the project page, and `llms.txt` list what Jabara can do together: the format registry, split and join, whole runs, deltas, config files, help, and the agent skill. The site's Updates page has entries for the features of this release.
|
|
57
|
+
- The documentation is set in the fonts of the project page, and the front page, guides, reference, explanation pages, READMEs, and the project, About, demo, and results pages are tighter. The README files link the deployed documentation site. The demo screenshot in the README is retaken, on a white background like the social preview.
|
|
58
|
+
- Package metadata for PyPI: the license is the SPDX expression `MIT`, the long description links and shows its image from GitHub, the project links include the changelog, and the sdist holds only the library, its manual pages, and the package files. A manual workflow, `publish.yml`, can upload a released tag to PyPI or TestPyPI; Jabara is not on PyPI yet.
|
|
59
|
+
- Tests cover a checkpoint whose weights are split over several safetensors files.
|
|
60
|
+
|
|
61
|
+
### Fixed
|
|
62
|
+
|
|
63
|
+
- `jabara bench` printed `encode encode time 0` for a codec whose encode time measured 0; it prints `encode time 0`.
|
|
64
|
+
- The documentation narrows the claims about the Lightning plugin, delta archives in a directory, and the resume test to what the code and the measurements support.
|
|
65
|
+
- The formats reference gives a more precise reason for Core ML neural network `.mlmodel` files and TensorRT engines, which stay refused. Orbax checkpoints stay refused, now with the reason: Orbax compresses every chunk with zstd.
|
|
66
|
+
|
|
67
|
+
## [0.1.0] - 2026-11-30
|
|
68
|
+
|
|
69
|
+
First release.
|
|
70
|
+
|
|
71
|
+
- Compresses the weights and optimizer state of a training checkpoint into `.jbr` archives. By default every tensor comes back bit for bit, and every read checks a CRC-32 per chunk.
|
|
72
|
+
- Eight codecs behind one `Codec` interface: `raw/1`, `zstd/1`, `bytegroup-zstd/1`, and `zipnn/1` (lossless); `xor-delta/1` and `sub-delta/1` (lossless, as a difference from the same tensor in an earlier archive); `quant8-linear/1` and `quant8-log/1` (lossy, used only when the caller opts in, with the largest error of each tensor recorded in the archive).
|
|
73
|
+
- `jabara.torch.save_state` and `load_state` store a nested PyTorch state, such as an optimizer's `state_dict()`, in an archive that is read without unpickling.
|
|
74
|
+
- The `jabara` command: `compress`, `decompress`, `verify`, `ls`, `export-weights`, `bench`, and `codecs`. `compress` works on one file or on a checkpoint directory, where it replaces each `*.safetensors` file and `optimizer.pt` with a verified archive.
|
|
75
|
+
- Adapters: `jabara.hf.attach` compresses each checkpoint a Hugging Face `Trainer` saves and restores it on resume, and `jabara.lightning.JabaraCheckpointIO` writes PyTorch Lightning checkpoints as archives.
|
|
76
|
+
- `jabara.bench.compare` runs a set of codecs on the same tensors and reports the stored size, the encode and decode throughput, and whether each round trip is exact.
|
|
77
|
+
- Extension points: a new codec, a rule that picks the codec of each tensor, or the tensor roles of another optimizer is one subclass of `Codec`, `Assigner`, or `StateSchema`.
|
|
78
|
+
- A live demo that runs the library in the browser with Pyodide, on a small preset checkpoint or a `.safetensors` file of your own, without uploading it; a results viewer for `jabara.bench` reports; and a project page.
|
|
79
|
+
- Documentation in English and Japanese: installation, a tutorial, how-to guides (Hugging Face `Trainer`, PyTorch Lightning, a plain PyTorch loop, choosing codecs, delta checkpoints, lossy codecs, exporting weights, comparing codecs, extending Jabara), explanations, and a reference for the command, the codecs, the archive format, the JSON schemas, and the Python API.
|
|
80
|
+
- The official transformers `run_clm.py`, PyTorch ImageNet, and Lightning ImageNet examples with Jabara added in fenced blocks. CI checks that the rest of each file is identical to upstream.
|
|
81
|
+
|
|
82
|
+
[0.2.1]: https://github.com/iamtatsuki05/jabara/compare/v0.2.0...v0.2.1
|
|
83
|
+
[0.2.0]: https://github.com/iamtatsuki05/jabara/compare/v0.1.0...v0.2.0
|
|
84
|
+
[0.1.0]: https://github.com/iamtatsuki05/jabara/releases/tag/v0.1.0
|
jabara-0.2.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tatsuki Okada
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
jabara-0.2.1/PKG-INFO
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: jabara
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: A unified library for compressing LLM training checkpoints: weights and optimizer state
|
|
5
|
+
Project-URL: Homepage, https://jabara.iamtatsuki05.com/
|
|
6
|
+
Project-URL: Documentation, https://jabara.iamtatsuki05.com/docs/
|
|
7
|
+
Project-URL: Repository, https://github.com/iamtatsuki05/jabara
|
|
8
|
+
Project-URL: Changelog, https://github.com/iamtatsuki05/jabara/blob/main/CHANGELOG.md
|
|
9
|
+
Project-URL: Issues, https://github.com/iamtatsuki05/jabara/issues
|
|
10
|
+
Author: Tatsuki Okada
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: checkpoint,compression,llm,lossless,optimizer-state,pytorch,safetensors,training
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
25
|
+
Classifier: Topic :: System :: Archiving :: Compression
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: >=3.10
|
|
28
|
+
Requires-Dist: numpy>=1.26
|
|
29
|
+
Requires-Dist: pydantic>=2.8
|
|
30
|
+
Requires-Dist: tomli>=2.0; python_version < '3.11'
|
|
31
|
+
Requires-Dist: typed-argument-parser>=1.12.0
|
|
32
|
+
Requires-Dist: zstandard>=0.23
|
|
33
|
+
Provides-Extra: hdf5
|
|
34
|
+
Requires-Dist: h5py>=3.10; extra == 'hdf5'
|
|
35
|
+
Provides-Extra: hf
|
|
36
|
+
Requires-Dist: accelerate>=1.0; extra == 'hf'
|
|
37
|
+
Requires-Dist: torch>=2.4; extra == 'hf'
|
|
38
|
+
Requires-Dist: transformers>=5.0; extra == 'hf'
|
|
39
|
+
Provides-Extra: lightning
|
|
40
|
+
Requires-Dist: lightning>=2.4; extra == 'lightning'
|
|
41
|
+
Requires-Dist: torch>=2.4; extra == 'lightning'
|
|
42
|
+
Provides-Extra: torch
|
|
43
|
+
Requires-Dist: torch>=2.4; extra == 'torch'
|
|
44
|
+
Provides-Extra: yaml
|
|
45
|
+
Requires-Dist: pyyaml>=6.0; extra == 'yaml'
|
|
46
|
+
Provides-Extra: zipnn
|
|
47
|
+
Requires-Dist: zipnn<0.6,>=0.5; extra == 'zipnn'
|
|
48
|
+
Description-Content-Type: text/markdown
|
|
49
|
+
|
|
50
|
+
# Jabara
|
|
51
|
+
|
|
52
|
+
English / [日本語](https://github.com/iamtatsuki05/jabara/blob/v0.2.1/README_JA.md)
|
|
53
|
+
|
|
54
|
+
Jabara compresses training checkpoints: model weights and optimizer state. Lossless compression, deltas against an earlier checkpoint, and quantization all sit behind one codec interface. By default Jabara restores every tensor bit for bit, every read checks a CRC-32, and an archive gets a lossy codec only when you opt in.
|
|
55
|
+
|
|
56
|
+

|
|
57
|
+
|
|
58
|
+
- **Live demo:** https://jabara.iamtatsuki05.com/demo/ (runs in your browser and uploads nothing)
|
|
59
|
+
- **Project page:** https://jabara.iamtatsuki05.com/
|
|
60
|
+
- **Results viewer:** https://jabara.iamtatsuki05.com/results/
|
|
61
|
+
- **Documentation:** [English](https://jabara.iamtatsuki05.com/docs/) / [日本語](https://jabara.iamtatsuki05.com/docs/ja/)
|
|
62
|
+
|
|
63
|
+
## Who it is for
|
|
64
|
+
|
|
65
|
+
Jabara is for checkpoints that you keep and read back later: the checkpoints of seed and hyperparameter sweeps, intermediate checkpoints kept for analysis, and runs that resume after an interruption or that someone else resumes. Saves and loads take longer than without Jabara, and a framework cannot memory-map an archive, so it is not a format to serve a model from. [Who Jabara is for](https://jabara.iamtatsuki05.com/docs/explanation/use-cases.html) gives the measured sizes and costs, and [Compress the checkpoints of many runs](https://jabara.iamtatsuki05.com/docs/how-to/compress-many-runs.html) shows the commands for a finished sweep. [Jabara and general-purpose archivers](https://jabara.iamtatsuki05.com/docs/explanation/archivers.html) compares it with `tar`, `zip`, `gzip`, and `zstd`.
|
|
66
|
+
|
|
67
|
+
## What you can do
|
|
68
|
+
|
|
69
|
+
- **Take many file formats through one registry.** `jabara compress` reads safetensors, `torch.save` files (without unpickling them), NumPy, GGUF, Keras and HDF5, ONNX, TensorFlow and MindSpore checkpoints, Core ML weight files, and Flax msgpack files, and a lossless archive restores each file byte for byte. A new format is one `CheckpointFormat` subclass plus the code that finds the tensor bytes in the file, and the built-in format modules are 86 to 290 lines each ([Checkpoint file formats](https://jabara.iamtatsuki05.com/docs/reference/formats.html)).
|
|
70
|
+
- **Split an archive by size or by count, and join it back.** `--part-size 2GB` or `--parts 4` cuts each archive, and `jabara split` and `jabara join` change an archive that exists without encoding it again ([Split an archive into parts and join it back](https://jabara.iamtatsuki05.com/docs/how-to/split-archives.html)).
|
|
71
|
+
- **Handle a whole run.** `--recursive` takes every checkpoint directory of a run, and `compress --dry-run` lists what it would do before it changes anything ([Compress the checkpoints of many runs](https://jabara.iamtatsuki05.com/docs/how-to/compress-many-runs.html)).
|
|
72
|
+
- **Store deltas.** `--delta first` codes each later checkpoint against the first one and `--delta previous` against the one before it, which saves only a few points more and restores slower. `--base` takes a directory too, and `jabara.hf.attach(trainer, delta="first")` saves deltas from a `Trainer` ([Delta checkpoints](https://jabara.iamtatsuki05.com/docs/how-to/delta-checkpoints.html)).
|
|
73
|
+
- **Read options from a file.** `--config FILE` takes JSON, YAML, or TOML, and `--show-config` prints the settings without running the command ([Run from a config file](https://jabara.iamtatsuki05.com/docs/how-to/run-from-a-config-file.html)).
|
|
74
|
+
- **Find your way in the command.** `-h` and `-H` print the short and the full help, `jabara man COMMAND` shows the manual page, and `jabara codecs --long` lists each codec with the works it builds on ([Command-line reference](https://jabara.iamtatsuki05.com/docs/reference/cli.html)).
|
|
75
|
+
- **Hand it to an agent.** The repository ships an agent skill for Claude Code, Codex CLI, GitHub Copilot CLI, Cursor, and Gemini CLI, an `AGENTS.md`, and a test of the command's contract ([Use Jabara from an AI agent](https://jabara.iamtatsuki05.com/docs/how-to/use-from-an-agent.html)).
|
|
76
|
+
|
|
77
|
+
## Install
|
|
78
|
+
|
|
79
|
+
Jabara needs Python 3.10 or newer. Install it from PyPI into a virtual environment:
|
|
80
|
+
|
|
81
|
+
```console
|
|
82
|
+
$ python -m venv .venv
|
|
83
|
+
$ source .venv/bin/activate
|
|
84
|
+
$ pip install "jabara[torch]"
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
In a uv project, run `uv add "jabara[torch]"` instead.
|
|
88
|
+
|
|
89
|
+
The extras are `torch` (PyTorch state, and the tensor names and roles of `.pt` files), `hf` (the Hugging Face `Trainer` adapter), `lightning` (the PyTorch Lightning plugin), `zipnn` (the `zipnn/1` codec), `yaml` (YAML config files), and `hdf5` (HDF5 and Keras files). See [Installation](https://jabara.iamtatsuki05.com/docs/getting-started/installation.html).
|
|
90
|
+
|
|
91
|
+
## Quickstart
|
|
92
|
+
|
|
93
|
+
Compress a checkpoint directory, check it, and restore it. `compress` replaces each `*.safetensors` file and `optimizer.pt` with a verified `.jbr` archive and leaves the other files alone. It also takes the files that Accelerate, PyTorch Lightning, DeepSpeed, and Megatron-LM write with `torch.save`, without unpickling them, TensorFlow data shards, MindSpore `.ckpt` files, and a Flax model's `flax_model.msgpack`, and, when you name the file, NumPy `.npy` and `.npz`, GGUF, Keras `.keras` and HDF5 files, ONNX models and their external data, Core ML `weight.bin` files, and any Flax `.msgpack` file. Each format is one class in a registry, and a lossless archive restores the file byte for byte (see [Checkpoint file formats](https://jabara.iamtatsuki05.com/docs/reference/formats.html)).
|
|
94
|
+
|
|
95
|
+
```console
|
|
96
|
+
$ jabara compress checkpoint-1000
|
|
97
|
+
checkpoint-1000/model.safetensors.jbr: ... -> ... bytes (...% of original)
|
|
98
|
+
checkpoint-1000/optimizer.pt.jbr: ... -> ... bytes (...% of original)
|
|
99
|
+
$ jabara verify checkpoint-1000
|
|
100
|
+
ok checkpoint-1000/model.safetensors.jbr
|
|
101
|
+
ok checkpoint-1000/optimizer.pt.jbr
|
|
102
|
+
$ jabara decompress checkpoint-1000
|
|
103
|
+
checkpoint-1000/model.safetensors
|
|
104
|
+
checkpoint-1000/optimizer.pt
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Save and load a PyTorch state from Python:
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
import torch
|
|
111
|
+
from jabara.torch import load_state, save_state
|
|
112
|
+
|
|
113
|
+
model = torch.nn.Linear(16, 16)
|
|
114
|
+
optimizer = torch.optim.AdamW(model.parameters())
|
|
115
|
+
model(torch.randn(4, 16)).sum().backward()
|
|
116
|
+
optimizer.step()
|
|
117
|
+
|
|
118
|
+
save_state(optimizer.state_dict(), "optimizer.jbr")
|
|
119
|
+
optimizer.load_state_dict(load_state("optimizer.jbr"))
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The [tutorial](https://jabara.iamtatsuki05.com/docs/getting-started/tutorial.html) explains both examples. Every command that has options also reads them from a JSON, YAML, or TOML file with `--config FILE`; see [Run from a config file](https://jabara.iamtatsuki05.com/docs/how-to/run-from-a-config-file.html).
|
|
123
|
+
|
|
124
|
+
An archive can also be written as several files, parts of at most a given size (`jabara compress --part-size 2GiB`) or a given number of parts (`--parts 4`). Every command reads the parts as one archive, and `jabara join` gives back the archive byte for byte; see [Split an archive into parts and join it back](https://jabara.iamtatsuki05.com/docs/how-to/split-archives.html).
|
|
125
|
+
|
|
126
|
+
## Codecs
|
|
127
|
+
|
|
128
|
+
| Codec | Type | Needs a base |
|
|
129
|
+
| --- | --- | --- |
|
|
130
|
+
| `bytegroup-zstd/1` | lossless | no |
|
|
131
|
+
| `quant8-linear/1` | lossy | no |
|
|
132
|
+
| `quant8-log/1` | lossy | no |
|
|
133
|
+
| `raw/1` | lossless | no |
|
|
134
|
+
| `sub-delta/1` | lossless | yes |
|
|
135
|
+
| `xor-delta/1` | lossless | yes |
|
|
136
|
+
| `zipnn/1` | lossless | no |
|
|
137
|
+
| `zstd/1` | lossless | no |
|
|
138
|
+
|
|
139
|
+
A codec that needs a base stores each tensor as its difference from the same tensor in an earlier archive. The [codec reference](https://jabara.iamtatsuki05.com/docs/reference/codecs.html) gives the dtypes, the parameters, and the error bounds of the lossy codecs.
|
|
140
|
+
|
|
141
|
+
## Extend Jabara
|
|
142
|
+
|
|
143
|
+
To extend Jabara, subclass one of these abstract base classes. You change no other code. Each example is a complete script, and a test runs all of them.
|
|
144
|
+
|
|
145
|
+
- `Codec` turns one chunk of one tensor into bytes and back: [examples/extend/custom_codec.py](https://github.com/iamtatsuki05/jabara/blob/v0.2.1/examples/extend/custom_codec.py), and with a validated parameter, [examples/extend/codec_with_params.py](https://github.com/iamtatsuki05/jabara/blob/v0.2.1/examples/extend/codec_with_params.py).
|
|
146
|
+
- `Assigner` chooses the codec for each tensor: [examples/extend/custom_assigner.py](https://github.com/iamtatsuki05/jabara/blob/v0.2.1/examples/extend/custom_assigner.py).
|
|
147
|
+
- `StateSchema` names the role of each tensor from its path in the nested state: [examples/extend/custom_schema.py](https://github.com/iamtatsuki05/jabara/blob/v0.2.1/examples/extend/custom_schema.py).
|
|
148
|
+
|
|
149
|
+
## Documentation
|
|
150
|
+
|
|
151
|
+
Read the documentation on the [published site](https://jabara.iamtatsuki05.com/docs/). GitHub shows its MyST sources as raw text.
|
|
152
|
+
|
|
153
|
+
- [Installation](https://jabara.iamtatsuki05.com/docs/getting-started/installation.html) and the [tutorial](https://jabara.iamtatsuki05.com/docs/getting-started/tutorial.html)
|
|
154
|
+
- [Command-line reference](https://jabara.iamtatsuki05.com/docs/reference/cli.html), and [Use Jabara from an AI agent](https://jabara.iamtatsuki05.com/docs/how-to/use-from-an-agent.html) with the agent skill in [skills/jabara/](https://github.com/iamtatsuki05/jabara/blob/v0.2.1/skills/jabara/SKILL.md) for Claude Code, Codex, GitHub Copilot, Gemini CLI, Cursor, and other agents
|
|
155
|
+
- [Built-in codecs](https://jabara.iamtatsuki05.com/docs/reference/codecs.html)
|
|
156
|
+
- [Archive format](https://jabara.iamtatsuki05.com/docs/reference/archive-format.html) and [JSON schemas](https://jabara.iamtatsuki05.com/docs/reference/schemas.html)
|
|
157
|
+
- [Python API](https://jabara.iamtatsuki05.com/docs/reference/api.html)
|
|
158
|
+
- [DESIGN.md](https://github.com/iamtatsuki05/jabara/blob/v0.2.1/DESIGN.md) sets the data shapes and module boundaries.
|
|
159
|
+
|
|
160
|
+
To build the site from the clone, run `uv run --group docs sphinx-build -W --keep-going -b html docs docs/_build/html` and open `docs/_build/html/index.html`. [docs/README.md](https://github.com/iamtatsuki05/jabara/blob/v0.2.1/docs/README.md) gives the Japanese build and explains how the sources are tested.
|
|
161
|
+
|
|
162
|
+
To work on Jabara, run `uv sync` in the clone to install the locked `dev` group, then `uv run tox` to run the tests, ruff, and mypy.
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
MIT. See [LICENSE](https://github.com/iamtatsuki05/jabara/blob/v0.2.1/LICENSE).
|
jabara-0.2.1/README.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Jabara
|
|
2
|
+
|
|
3
|
+
English / [日本語](README_JA.md)
|
|
4
|
+
|
|
5
|
+
Jabara compresses training checkpoints: model weights and optimizer state. Lossless compression, deltas against an earlier checkpoint, and quantization all sit behind one codec interface. By default Jabara restores every tensor bit for bit, every read checks a CRC-32, and an archive gets a lossy codec only when you opt in.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
- **Live demo:** https://jabara.iamtatsuki05.com/demo/ (runs in your browser and uploads nothing)
|
|
10
|
+
- **Project page:** https://jabara.iamtatsuki05.com/
|
|
11
|
+
- **Results viewer:** https://jabara.iamtatsuki05.com/results/
|
|
12
|
+
- **Documentation:** [English](https://jabara.iamtatsuki05.com/docs/) / [日本語](https://jabara.iamtatsuki05.com/docs/ja/)
|
|
13
|
+
|
|
14
|
+
## Who it is for
|
|
15
|
+
|
|
16
|
+
Jabara is for checkpoints that you keep and read back later: the checkpoints of seed and hyperparameter sweeps, intermediate checkpoints kept for analysis, and runs that resume after an interruption or that someone else resumes. Saves and loads take longer than without Jabara, and a framework cannot memory-map an archive, so it is not a format to serve a model from. [Who Jabara is for](https://jabara.iamtatsuki05.com/docs/explanation/use-cases.html) gives the measured sizes and costs, and [Compress the checkpoints of many runs](https://jabara.iamtatsuki05.com/docs/how-to/compress-many-runs.html) shows the commands for a finished sweep. [Jabara and general-purpose archivers](https://jabara.iamtatsuki05.com/docs/explanation/archivers.html) compares it with `tar`, `zip`, `gzip`, and `zstd`.
|
|
17
|
+
|
|
18
|
+
## What you can do
|
|
19
|
+
|
|
20
|
+
- **Take many file formats through one registry.** `jabara compress` reads safetensors, `torch.save` files (without unpickling them), NumPy, GGUF, Keras and HDF5, ONNX, TensorFlow and MindSpore checkpoints, Core ML weight files, and Flax msgpack files, and a lossless archive restores each file byte for byte. A new format is one `CheckpointFormat` subclass plus the code that finds the tensor bytes in the file, and the built-in format modules are 86 to 290 lines each ([Checkpoint file formats](https://jabara.iamtatsuki05.com/docs/reference/formats.html)).
|
|
21
|
+
- **Split an archive by size or by count, and join it back.** `--part-size 2GB` or `--parts 4` cuts each archive, and `jabara split` and `jabara join` change an archive that exists without encoding it again ([Split an archive into parts and join it back](https://jabara.iamtatsuki05.com/docs/how-to/split-archives.html)).
|
|
22
|
+
- **Handle a whole run.** `--recursive` takes every checkpoint directory of a run, and `compress --dry-run` lists what it would do before it changes anything ([Compress the checkpoints of many runs](https://jabara.iamtatsuki05.com/docs/how-to/compress-many-runs.html)).
|
|
23
|
+
- **Store deltas.** `--delta first` codes each later checkpoint against the first one and `--delta previous` against the one before it, which saves only a few points more and restores slower. `--base` takes a directory too, and `jabara.hf.attach(trainer, delta="first")` saves deltas from a `Trainer` ([Delta checkpoints](https://jabara.iamtatsuki05.com/docs/how-to/delta-checkpoints.html)).
|
|
24
|
+
- **Read options from a file.** `--config FILE` takes JSON, YAML, or TOML, and `--show-config` prints the settings without running the command ([Run from a config file](https://jabara.iamtatsuki05.com/docs/how-to/run-from-a-config-file.html)).
|
|
25
|
+
- **Find your way in the command.** `-h` and `-H` print the short and the full help, `jabara man COMMAND` shows the manual page, and `jabara codecs --long` lists each codec with the works it builds on ([Command-line reference](https://jabara.iamtatsuki05.com/docs/reference/cli.html)).
|
|
26
|
+
- **Hand it to an agent.** The repository ships an agent skill for Claude Code, Codex CLI, GitHub Copilot CLI, Cursor, and Gemini CLI, an `AGENTS.md`, and a test of the command's contract ([Use Jabara from an AI agent](https://jabara.iamtatsuki05.com/docs/how-to/use-from-an-agent.html)).
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
Jabara needs Python 3.10 or newer. Install it from PyPI into a virtual environment:
|
|
31
|
+
|
|
32
|
+
```console
|
|
33
|
+
$ python -m venv .venv
|
|
34
|
+
$ source .venv/bin/activate
|
|
35
|
+
$ pip install "jabara[torch]"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
In a uv project, run `uv add "jabara[torch]"` instead.
|
|
39
|
+
|
|
40
|
+
The extras are `torch` (PyTorch state, and the tensor names and roles of `.pt` files), `hf` (the Hugging Face `Trainer` adapter), `lightning` (the PyTorch Lightning plugin), `zipnn` (the `zipnn/1` codec), `yaml` (YAML config files), and `hdf5` (HDF5 and Keras files). See [Installation](https://jabara.iamtatsuki05.com/docs/getting-started/installation.html).
|
|
41
|
+
|
|
42
|
+
## Quickstart
|
|
43
|
+
|
|
44
|
+
Compress a checkpoint directory, check it, and restore it. `compress` replaces each `*.safetensors` file and `optimizer.pt` with a verified `.jbr` archive and leaves the other files alone. It also takes the files that Accelerate, PyTorch Lightning, DeepSpeed, and Megatron-LM write with `torch.save`, without unpickling them, TensorFlow data shards, MindSpore `.ckpt` files, and a Flax model's `flax_model.msgpack`, and, when you name the file, NumPy `.npy` and `.npz`, GGUF, Keras `.keras` and HDF5 files, ONNX models and their external data, Core ML `weight.bin` files, and any Flax `.msgpack` file. Each format is one class in a registry, and a lossless archive restores the file byte for byte (see [Checkpoint file formats](https://jabara.iamtatsuki05.com/docs/reference/formats.html)).
|
|
45
|
+
|
|
46
|
+
```console
|
|
47
|
+
$ jabara compress checkpoint-1000
|
|
48
|
+
checkpoint-1000/model.safetensors.jbr: ... -> ... bytes (...% of original)
|
|
49
|
+
checkpoint-1000/optimizer.pt.jbr: ... -> ... bytes (...% of original)
|
|
50
|
+
$ jabara verify checkpoint-1000
|
|
51
|
+
ok checkpoint-1000/model.safetensors.jbr
|
|
52
|
+
ok checkpoint-1000/optimizer.pt.jbr
|
|
53
|
+
$ jabara decompress checkpoint-1000
|
|
54
|
+
checkpoint-1000/model.safetensors
|
|
55
|
+
checkpoint-1000/optimizer.pt
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Save and load a PyTorch state from Python:
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
import torch
|
|
62
|
+
from jabara.torch import load_state, save_state
|
|
63
|
+
|
|
64
|
+
model = torch.nn.Linear(16, 16)
|
|
65
|
+
optimizer = torch.optim.AdamW(model.parameters())
|
|
66
|
+
model(torch.randn(4, 16)).sum().backward()
|
|
67
|
+
optimizer.step()
|
|
68
|
+
|
|
69
|
+
save_state(optimizer.state_dict(), "optimizer.jbr")
|
|
70
|
+
optimizer.load_state_dict(load_state("optimizer.jbr"))
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The [tutorial](https://jabara.iamtatsuki05.com/docs/getting-started/tutorial.html) explains both examples. Every command that has options also reads them from a JSON, YAML, or TOML file with `--config FILE`; see [Run from a config file](https://jabara.iamtatsuki05.com/docs/how-to/run-from-a-config-file.html).
|
|
74
|
+
|
|
75
|
+
An archive can also be written as several files, parts of at most a given size (`jabara compress --part-size 2GiB`) or a given number of parts (`--parts 4`). Every command reads the parts as one archive, and `jabara join` gives back the archive byte for byte; see [Split an archive into parts and join it back](https://jabara.iamtatsuki05.com/docs/how-to/split-archives.html).
|
|
76
|
+
|
|
77
|
+
## Codecs
|
|
78
|
+
|
|
79
|
+
| Codec | Type | Needs a base |
|
|
80
|
+
| --- | --- | --- |
|
|
81
|
+
| `bytegroup-zstd/1` | lossless | no |
|
|
82
|
+
| `quant8-linear/1` | lossy | no |
|
|
83
|
+
| `quant8-log/1` | lossy | no |
|
|
84
|
+
| `raw/1` | lossless | no |
|
|
85
|
+
| `sub-delta/1` | lossless | yes |
|
|
86
|
+
| `xor-delta/1` | lossless | yes |
|
|
87
|
+
| `zipnn/1` | lossless | no |
|
|
88
|
+
| `zstd/1` | lossless | no |
|
|
89
|
+
|
|
90
|
+
A codec that needs a base stores each tensor as its difference from the same tensor in an earlier archive. The [codec reference](https://jabara.iamtatsuki05.com/docs/reference/codecs.html) gives the dtypes, the parameters, and the error bounds of the lossy codecs.
|
|
91
|
+
|
|
92
|
+
## Extend Jabara
|
|
93
|
+
|
|
94
|
+
To extend Jabara, subclass one of these abstract base classes. You change no other code. Each example is a complete script, and a test runs all of them.
|
|
95
|
+
|
|
96
|
+
- `Codec` turns one chunk of one tensor into bytes and back: [examples/extend/custom_codec.py](examples/extend/custom_codec.py), and with a validated parameter, [examples/extend/codec_with_params.py](examples/extend/codec_with_params.py).
|
|
97
|
+
- `Assigner` chooses the codec for each tensor: [examples/extend/custom_assigner.py](examples/extend/custom_assigner.py).
|
|
98
|
+
- `StateSchema` names the role of each tensor from its path in the nested state: [examples/extend/custom_schema.py](examples/extend/custom_schema.py).
|
|
99
|
+
|
|
100
|
+
## Documentation
|
|
101
|
+
|
|
102
|
+
Read the documentation on the [published site](https://jabara.iamtatsuki05.com/docs/). GitHub shows its MyST sources as raw text.
|
|
103
|
+
|
|
104
|
+
- [Installation](https://jabara.iamtatsuki05.com/docs/getting-started/installation.html) and the [tutorial](https://jabara.iamtatsuki05.com/docs/getting-started/tutorial.html)
|
|
105
|
+
- [Command-line reference](https://jabara.iamtatsuki05.com/docs/reference/cli.html), and [Use Jabara from an AI agent](https://jabara.iamtatsuki05.com/docs/how-to/use-from-an-agent.html) with the agent skill in [skills/jabara/](skills/jabara/SKILL.md) for Claude Code, Codex, GitHub Copilot, Gemini CLI, Cursor, and other agents
|
|
106
|
+
- [Built-in codecs](https://jabara.iamtatsuki05.com/docs/reference/codecs.html)
|
|
107
|
+
- [Archive format](https://jabara.iamtatsuki05.com/docs/reference/archive-format.html) and [JSON schemas](https://jabara.iamtatsuki05.com/docs/reference/schemas.html)
|
|
108
|
+
- [Python API](https://jabara.iamtatsuki05.com/docs/reference/api.html)
|
|
109
|
+
- [DESIGN.md](DESIGN.md) sets the data shapes and module boundaries.
|
|
110
|
+
|
|
111
|
+
To build the site from the clone, run `uv run --group docs sphinx-build -W --keep-going -b html docs docs/_build/html` and open `docs/_build/html/index.html`. [docs/README.md](docs/README.md) gives the Japanese build and explains how the sources are tested.
|
|
112
|
+
|
|
113
|
+
To work on Jabara, run `uv sync` in the clone to install the locked `dev` group, then `uv run tox` to run the tests, ruff, and mypy.
|
|
114
|
+
|
|
115
|
+
## License
|
|
116
|
+
|
|
117
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
.TH JABARA-BENCH 1 2026-12-01 "jabara 0.2.1" "Jabara Manual"
|
|
2
|
+
.nh
|
|
3
|
+
.SH NAME
|
|
4
|
+
jabara\-bench \- Compare codecs in memory on the tensors of PATH: an archive, a
|
|
5
|
+
safetensors or torch file, or a directory.
|
|
6
|
+
.SH SYNOPSIS
|
|
7
|
+
.B jabara bench
|
|
8
|
+
[\-h] [\-\-json] [\-\-base BASE] [\-\-repeats N] [\-\-threads N] [\-\-candidates a,b,c]
|
|
9
|
+
[\-\-config FILE] [\-\-show\-config] PATH
|
|
10
|
+
.SH DESCRIPTION
|
|
11
|
+
Default candidates are the lossless codecs that need no base; with \-\-base (a
|
|
12
|
+
path of the same kinds as PATH), the delta codecs are added. \-\-candidates
|
|
13
|
+
a,b,c names codecs instead, lossy ones included. It takes no \-\-recursive: it
|
|
14
|
+
holds every tensor in memory, and a parent of several checkpoints would
|
|
15
|
+
multiply that.
|
|
16
|
+
.PP
|
|
17
|
+
It runs each candidate codec in memory on the same tensors and writes no file.
|
|
18
|
+
Without \-\-candidates it runs every lossless codec that needs no base, plus the
|
|
19
|
+
delta codecs when \-\-base is given. It skips a codec whose optional package is
|
|
20
|
+
missing and says so in a 'jabara: skipped ID: REASON' line on standard error.
|
|
21
|
+
.PP
|
|
22
|
+
It prints a header line, 'N threads, best of REPEATS, W warm\-up, chunk SIZE
|
|
23
|
+
bytes', then one line per candidate and role: sizes, encode and decode
|
|
24
|
+
throughput in MB/s (10^6 bytes per second), and 'exact' or 'NOT EXACT'. A row
|
|
25
|
+
that is NOT EXACT still exits with status 0. With \-\-json it prints the report
|
|
26
|
+
as one line of JSON.
|
|
27
|
+
.SH ARGUMENTS
|
|
28
|
+
.TP
|
|
29
|
+
\fIPATH\fR
|
|
30
|
+
an archive, a safetensors or torch file, or a directory. Takes a path.
|
|
31
|
+
.SH OPTIONS
|
|
32
|
+
.TP
|
|
33
|
+
\fB\-h\fR, \fB\-H\fR, \fB\-\-help\fR
|
|
34
|
+
print the short (\-h) or the full help and exit.
|
|
35
|
+
.TP
|
|
36
|
+
\fB\-\-json\fR
|
|
37
|
+
print the report as JSON (also \-\-json=true or \-\-json=false).
|
|
38
|
+
.TP
|
|
39
|
+
\fB\-\-base\fR \fIBASE\fR
|
|
40
|
+
the base tensors, a path of the same kinds as PATH. Takes a path.
|
|
41
|
+
.TP
|
|
42
|
+
\fB\-\-repeats\fR \fIN\fR
|
|
43
|
+
timed runs per codec. Takes a positive integer. Default: 3.
|
|
44
|
+
.TP
|
|
45
|
+
\fB\-\-threads\fR \fIN\fR
|
|
46
|
+
worker threads (default: up to 8). Takes a positive integer.
|
|
47
|
+
.TP
|
|
48
|
+
\fB\-\-candidates\fR \fIa,b,c\fR
|
|
49
|
+
the codecs to compare instead of the default ones. Takes a codec ids,
|
|
50
|
+
comma\-separated.
|
|
51
|
+
.TP
|
|
52
|
+
\fB\-\-config\fR \fIFILE\fR
|
|
53
|
+
read options from a .json, .yaml, .yml, or .toml file. Takes a path.
|
|
54
|
+
.TP
|
|
55
|
+
\fB\-\-show\-config\fR
|
|
56
|
+
print the settings to be used, as JSON, and exit.
|
|
57
|
+
.SH EXIT STATUS
|
|
58
|
+
.TP
|
|
59
|
+
.B 0
|
|
60
|
+
The command succeeded, or help or the version was printed.
|
|
61
|
+
.TP
|
|
62
|
+
.B 1
|
|
63
|
+
The command failed. It prints one line, 'jabara: MESSAGE', on standard error.
|
|
64
|
+
.TP
|
|
65
|
+
.B 2
|
|
66
|
+
Usage error. It prints the usage and an error line on standard error, and runs
|
|
67
|
+
nothing.
|
|
68
|
+
.SH EXAMPLES
|
|
69
|
+
.RS 4
|
|
70
|
+
.nf
|
|
71
|
+
$ jabara bench checkpoint\-1000/model.safetensors \-\-candidates raw/1,zstd/1,bytegroup\-zstd/1 \-\-repeats 3
|
|
72
|
+
\&... threads, best of 3, 1 warm\-up, chunk ... bytes
|
|
73
|
+
raw/1 weight: ... bytes (...% of original), encode ... MB/s, decode ... MB/s, exact
|
|
74
|
+
zstd/1 weight: ... bytes (...% of original), encode ... MB/s, decode ... MB/s, exact
|
|
75
|
+
bytegroup\-zstd/1 weight: ... bytes (...% of original), encode ... MB/s, decode ... MB/s, exact
|
|
76
|
+
.fi
|
|
77
|
+
.RE
|
|
78
|
+
.SH SEE ALSO
|
|
79
|
+
\fBjabara\fR(1),
|
|
80
|
+
\fBjabara\-codecs\fR(1),
|
|
81
|
+
\fBjabara\-compress\fR(1)
|
|
82
|
+
.PP
|
|
83
|
+
The documentation:
|
|
84
|
+
\fIhttps://jabara.iamtatsuki05.com/docs/reference/cli.html#jabara\-bench\fR
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
.TH JABARA-CODECS 1 2026-12-01 "jabara 0.2.1" "Jabara Manual"
|
|
2
|
+
.nh
|
|
3
|
+
.SH NAME
|
|
4
|
+
jabara\-codecs \- List the registered codecs: their ids, or with \-\-long, \-\-json
|
|
5
|
+
or an ID what each is and builds on.
|
|
6
|
+
.SH SYNOPSIS
|
|
7
|
+
.B jabara codecs
|
|
8
|
+
[\-h] [\-\-long] [\-\-json] [\-\-config FILE] [\-\-show\-config] [ID]
|
|
9
|
+
.SH DESCRIPTION
|
|
10
|
+
Without an argument it prints the id of every registered codec, one per line,
|
|
11
|
+
in name order.
|
|
12
|
+
.PP
|
|
13
|
+
With \-\-long it prints a block per codec: what it does, its type (lossless or
|
|
14
|
+
lossy), whether it needs a base, the dtypes it encodes, its parameters and
|
|
15
|
+
their defaults, the jabara extra it needs and whether that is installed here,
|
|
16
|
+
and the works it builds on. With ID it prints all of that for one codec, with
|
|
17
|
+
the codec's full description. \-\-json prints the same as JSON.
|
|
18
|
+
.PP
|
|
19
|
+
Each work is marked with how the codec relates to it. 'wraps': the codec calls
|
|
20
|
+
this library. 'describes': the work describes the method or the format of a
|
|
21
|
+
library the codec wraps. 'related': the work has the same idea; the codec is
|
|
22
|
+
this project's own and does not reproduce its method.
|
|
23
|
+
.SH ARGUMENTS
|
|
24
|
+
.TP
|
|
25
|
+
\fIID\fR
|
|
26
|
+
show everything about this codec.
|
|
27
|
+
.SH OPTIONS
|
|
28
|
+
.TP
|
|
29
|
+
\fB\-h\fR, \fB\-H\fR, \fB\-\-help\fR
|
|
30
|
+
print the short (\-h) or the full help and exit.
|
|
31
|
+
.TP
|
|
32
|
+
\fB\-\-long\fR
|
|
33
|
+
show each codec's properties and references (also \-\-long=true or
|
|
34
|
+
\-\-long=false).
|
|
35
|
+
.TP
|
|
36
|
+
\fB\-\-json\fR
|
|
37
|
+
print JSON: a list of codecs, or one codec for an ID (also \-\-json=true or
|
|
38
|
+
\-\-json=false).
|
|
39
|
+
.TP
|
|
40
|
+
\fB\-\-config\fR \fIFILE\fR
|
|
41
|
+
read options from a .json, .yaml, .yml, or .toml file. Takes a path.
|
|
42
|
+
.TP
|
|
43
|
+
\fB\-\-show\-config\fR
|
|
44
|
+
print the settings to be used, as JSON, and exit.
|
|
45
|
+
.SH EXIT STATUS
|
|
46
|
+
.TP
|
|
47
|
+
.B 0
|
|
48
|
+
The command succeeded, or help or the version was printed.
|
|
49
|
+
.TP
|
|
50
|
+
.B 1
|
|
51
|
+
The command failed. It prints one line, 'jabara: MESSAGE', on standard error.
|
|
52
|
+
.TP
|
|
53
|
+
.B 2
|
|
54
|
+
Usage error. It prints the usage and an error line on standard error, and runs
|
|
55
|
+
nothing.
|
|
56
|
+
.SH EXAMPLES
|
|
57
|
+
.RS 4
|
|
58
|
+
.nf
|
|
59
|
+
$ jabara codecs
|
|
60
|
+
bytegroup\-zstd/1
|
|
61
|
+
quant8\-linear/1
|
|
62
|
+
quant8\-log/1
|
|
63
|
+
raw/1
|
|
64
|
+
sub\-delta/1
|
|
65
|
+
xor\-delta/1
|
|
66
|
+
zipnn/1
|
|
67
|
+
zstd/1
|
|
68
|
+
.fi
|
|
69
|
+
.RE
|
|
70
|
+
.PP
|
|
71
|
+
.RS 4
|
|
72
|
+
.nf
|
|
73
|
+
$ jabara codecs raw/1
|
|
74
|
+
raw/1: Stores the bytes unchanged.
|
|
75
|
+
|
|
76
|
+
type: lossless; needs no base; dtypes: every dtype; parameters: none
|
|
77
|
+
.fi
|
|
78
|
+
.RE
|
|
79
|
+
.SH SEE ALSO
|
|
80
|
+
\fBjabara\fR(1),
|
|
81
|
+
\fBjabara\-bench\fR(1)
|
|
82
|
+
.PP
|
|
83
|
+
The documentation:
|
|
84
|
+
\fIhttps://jabara.iamtatsuki05.com/docs/reference/cli.html#jabara\-codecs\fR
|