lmz
Smaller checkpoints. Byte for byte.
Lossless compression built for model weights. zstd -1 takes 22.7% off a
Llama-3.1-8B BF16 checkpoint. lmz takes 34.7% — and 64.6% off the
directory as Hugging Face actually ships it, which is 13 GB more than zstd
on one 8B model.
Nothing is approximated. Every byte comes back.
pip install lmzip
lmz compress ./Llama-3.1-8B-Instruct/
What it saves
Real checkpoints, every round-trip verified byte-identical.
| size | after | saved | zstd -1 | |
|---|---|---|---|---|
| Llama-3.1-8B, whole HF directory | 32.13 GB | 11.38 GB | 64.6% | 22.7% |
| Llama-3.1-8B, 4 BF16 shards | 16.06 GB | 10.49 GB | 34.7% | 22.7% |
| Ministral-8B, whole directory | 32.11 GB | 11.55 GB | 64.0% | 22.7% |
| Pythia-160m, 3 training checkpoints | 1.81 GiB | 644 MiB | 65.3% | 22.7% |
| bge-m3 directory (FP32 container) | 4.59 GB | 2.45 GB | 46.5% | — |
| 8-bit AdamW optimizer state ×2 | 161 MiB | 119 MiB | 26.1% | — |
On BF16 weights lmz beats the published state of the art, and sits 0.3 points off the bound no lossless coder of any kind can pass:
| on real Llama BF16 | saved |
|---|---|
| lmz | 34.7% |
| ZipNN (published, same model) | 33.6% |
| DFloat11 (published) | ~30% |
| bzip2 -9 | 30.7% |
| xz -6 | 29.9% |
| zstd -19 | 23.6% |
| theoretical joint-entropy bound | 35.0% |
Three things a general compressor structurally cannot do, which is where most of the margin comes from: store a tensor once when a directory ships it twice, code a checkpoint as the difference from the one before it, and split on a float's own bit-fields instead of byte boundaries.
Where it is not worth it
Stated plainly, because a compressor that only advertises its wins should not be believed:
| lmz | best alternative | verdict | |
|---|---|---|---|
| Quantised GGUF (Q8_0 / Q4_K_M) | 6.7% / 5.1% | 5.5% / 2.5% | the quantiser already took it |
| FP8 safetensors | 17.14% | zstd -3, 17.11% | just use zstd, the gap is 0.03 points |
| Text, code, JSON, binaries | = zstd | zstd | lmz is zstd here, by design |
| Read speed | slower | a plain file | see below |
Reading a compressed file transparently can never beat a plain one by more
than 1/(1−saved) — you still have to read the archive. That is 1.5× on BF16
and 1.05× on Q4_K, so on a fast SSD the mount is slower. It buys disk, not
speed.
Also included
lmz add ./my-model/ && lmz mount ~/models # read a compressed model as ordinary
# files; llama.cpp needs no patch
lmz fs ~/.lmz/data ~/data # a read-write compressed filesystem;
# 32.1% where btrfs+zstd gets 18.9%
Buy me a coffee
lmz is free, MIT-licensed and unfunded. If it saved you disk or bandwidth —
☕ Buy me a coffee
or Alipay (打开支付宝,扫一扫). Thank you.
Documentation
- How it works — why a float array defeats a general-purpose compressor, and the bit-level choices that close the gap
- Measured results — every number, with its conditions
- Using lmz — command line, Python API, the mount and the filesystem
- Limitations — where it does not pay, and what the 81 tests check
Python 3.10+, no runtime dependencies. zstd comes from the standard library on
3.14+; a C compiler, if present, is used once to build the SIMD kernel into the
package directory — nothing is installed system-wide. Runs straight from a
checkout with ./lmz-cli if you would rather not install it at all.
Check what is active with lmz doctor.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lmzip-1.0.0.tar.gz.
File metadata
- Download URL: lmzip-1.0.0.tar.gz
- Upload date:
- Size: 121.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c521612293c24e5b7a464c1e670b74ad41c91d44042b54c22d1c5b1d3a80d428
|
|
| MD5 |
e81bae8fac4d84b0b683c4120db41907
|
|
| BLAKE2b-256 |
16c17bff2c2c6d5dba40db2fb43159d93ecf69c8f768c1d711f4977c09ff751d
|
File details
Details for the file lmzip-1.0.0-py3-none-any.whl.
File metadata
- Download URL: lmzip-1.0.0-py3-none-any.whl
- Upload date:
- Size: 101.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c8923c2481c6ff48ba67422393f2d281d4d56876fdedac157d35c5be9906f26
|
|
| MD5 |
a1fedb3e5f7cc386c3f469b0da6227b5
|
|
| BLAKE2b-256 |
5d2f69ed5fdfe31e774792e68f483d78d0a525fb86a080a0277d63ebd277fd2b
|