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 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
+ ]
lmz/__main__.py ADDED
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from .cli import main
4
+
5
+ sys.exit(main())