lmzip 1.0.0__py3-none-any.whl
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.
- lmz/__init__.py +40 -0
- lmz/__main__.py +5 -0
- lmz/api.py +1489 -0
- lmz/cli.py +678 -0
- lmz/codec.py +1002 -0
- lmz/entropy.py +111 -0
- lmz/format.py +269 -0
- lmz/fuse.py +664 -0
- lmz/kernels.py +832 -0
- lmz/lmzfs.py +651 -0
- lmz/native/__init__.py +0 -0
- lmz/native/build.py +112 -0
- lmz/native/lmzcore.c +1047 -0
- lmz/parallel.py +117 -0
- lmz/planner.py +652 -0
- lmz/store.py +516 -0
- lmzip-1.0.0.dist-info/METADATA +135 -0
- lmzip-1.0.0.dist-info/RECORD +22 -0
- lmzip-1.0.0.dist-info/WHEEL +5 -0
- lmzip-1.0.0.dist-info/entry_points.txt +2 -0
- lmzip-1.0.0.dist-info/licenses/LICENSE +21 -0
- lmzip-1.0.0.dist-info/top_level.txt +1 -0
lmz/__init__.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""lmz - fast lossless compression for large model weights.
|
|
2
|
+
|
|
3
|
+
Model weights compress poorly with general-purpose tools because a float
|
|
4
|
+
array looks like noise byte for byte. It is not: in a BF16 tensor the
|
|
5
|
+
sign-and-exponent byte of every element takes only a few dozen distinct
|
|
6
|
+
values, while the mantissa byte really is close to random. Separating those
|
|
7
|
+
into distinct planes lets the exponents be entropy coded properly and the
|
|
8
|
+
mantissas be passed through untouched, which is both smaller and faster than
|
|
9
|
+
compressing the interleaved bytes.
|
|
10
|
+
|
|
11
|
+
import lmz
|
|
12
|
+
lmz.compress("model.safetensors", "model.lmz")
|
|
13
|
+
lmz.decompress("model.lmz", "restored.safetensors")
|
|
14
|
+
|
|
15
|
+
Output is byte-for-byte identical to the input.
|
|
16
|
+
|
|
17
|
+
A model can also be kept in the store and read in place, so nothing is ever
|
|
18
|
+
expanded onto disk:
|
|
19
|
+
|
|
20
|
+
import lmz
|
|
21
|
+
lmz.Store().add("./my-model", "my-model") # compressed, once
|
|
22
|
+
|
|
23
|
+
lmz mount ~/models # every runtime reads it as
|
|
24
|
+
# ordinary model files
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
__version__ = "1.0.0"
|
|
28
|
+
|
|
29
|
+
from .api import (DEFAULT_CHUNK_SIZE, DEFAULT_LEVEL, Stats, backends, compress,
|
|
30
|
+
decompress, info, read_tensor, verify)
|
|
31
|
+
from .api import MappedArchive, append, extract # noqa: F401
|
|
32
|
+
from .format import FormatError
|
|
33
|
+
from .lmzfs import LmzFS # noqa: F401
|
|
34
|
+
from .store import Store, mount # noqa: F401
|
|
35
|
+
|
|
36
|
+
__all__ = [
|
|
37
|
+
"compress", "decompress", "verify", "info", "read_tensor", "backends",
|
|
38
|
+
"MappedArchive", "append", "extract", "Store", "mount", "LmzFS",
|
|
39
|
+
"Stats", "FormatError", "DEFAULT_LEVEL", "DEFAULT_CHUNK_SIZE", "__version__",
|
|
40
|
+
]
|