Python bindings for compintc: A variable length compression algorithm.
Project description
CompIntPy
A Python library for compressing integers with variable-length Elias compression algorithms (universal codes). The library was designed for compressing indices of weight matrices in decentralised machine learning. Hence, it supports multithreading for faster encoding of indices to speed up the distribution of the data to neighbouring nodes.
Supported Algorithms
The library implements the Elias gamma, delta, and omega algorithms. An example for EliasGamma
is given below (Replace Gamma
with your respective choices):
arr = np.array([0, -1, 2, -5, 8], dtype=np.int64)
eg = EliasGamma(offset=1, map_negative_numbers=True)
comp = eg.compress(arr)
uncomp = eg.decompress(output, arr.size, output_dtype=np.int64)
Installation
git clone --recursive https://github.com/JeffWigger/compintpy.git
cd compintpy
pip install .
Documentation
All three algorithms are available as Python objects: comppy.elias.EliasGamma
, comppy.elias.EliasDelta
, and comppy.elias.EliasOmega
.
They are all subclasses of the follwing class:
class comppy.elias.Elias(offset: int = 0, map_negative_numbers: bool = False)
""" Abstract base class of all Elias compression implementations.""""
abstract compress(array: ndarray) → ndarray
""" Abstract method defining the compression method used by all Elias implementations.
Parameters:
array (np.ndarray) – Array to be compressed. The array must be of types Union[np.int64, np.uint64, np.int32, np.uint32].
"""
abstract decompress(array: ndarray, output_length: int, output_dtype: int64 | uint64 | int32 | uint32) → ndarray
"""Abstract method defining the decompression method used by all Elias implementations.
Parameters:
array (np.ndarray) – Numpy array containing data compressed with an Elias algorithm. The dtype must be np.uint8.
output_length (int) – Length of the decompressed output.
output_dtype (Union[np.int64, np.uint64, np.int32, np.uint32]) – Dtype of the output array.
""""
Multi-threading
The compress function is parallelized with OpenMP. You can set the number of threads by setting the OMP_NUM_THREADS environment variable, e.g.,
export OMP_NUM_THREADS=10
Bindings
This library binds the high-performance C++ code from our sister Project ComIntC.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file compintpy-0.0.3.tar.gz
.
File metadata
- Download URL: compintpy-0.0.3.tar.gz
- Upload date:
- Size: 259.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f97456b6ff63367fac929694ba7285d3f1e839b75329547c2599353eb6b06ff |
|
MD5 | e3a44a856c53a41a08221d598c3e43a3 |
|
BLAKE2b-256 | 87020481ce2c49a04b05bda65fe2783a57eddbc49f1df2d6187ca7384503b94d |
File details
Details for the file compintpy-0.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: compintpy-0.0.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 190.1 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca9366753b43b36585ccb7a512025fd84f2a2d91af13575004472039916d4159 |
|
MD5 | e26c3bb126734464a6b3816c2534b400 |
|
BLAKE2b-256 | 05d0cc66ce26581d523795ff804f1fe0fbf204321569d054fe7969d92492fba5 |
File details
Details for the file compintpy-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: compintpy-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 188.9 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58c3f39a7c07e1275b2d1052d8399ffc1fd301ae4151f1a7042d1fb5749987ba |
|
MD5 | 189ae0eb6d75fc98a62006b7bb275bcb |
|
BLAKE2b-256 | 2af95b9dc864df4bc8e08ea8263658f1882ad418943acf09a0d43f702ca487a3 |
File details
Details for the file compintpy-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: compintpy-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 190.3 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f636b84fa06982be7faaf42e9121f8c443ad3b630842549eaf1aec7ebf3b4a3f |
|
MD5 | 7e710825d1e4c2fd1a5b462934584c37 |
|
BLAKE2b-256 | 40d7537bd3319acacf00f628d852f239508ef76bb403be3e1c8ac65280efdd77 |
File details
Details for the file compintpy-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: compintpy-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 187.9 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a480deb0c54166eeec8a95ce3d4fd1f26ba6ee1d02ea580964d520b6ccadbe6e |
|
MD5 | d73b42c062b18ea6ffb88b0bfd2675c5 |
|
BLAKE2b-256 | c80d052c8f91faa82add8e809b7d94decd0c1abd6171fb3ab624ab05bc1af6d1 |
File details
Details for the file compintpy-0.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: compintpy-0.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 188.6 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b2e2b2efd20e42537685de3e5250928367af15f91a206574b50540b608857cb |
|
MD5 | 8ab81d4159a330fec92f4f61f0c4c372 |
|
BLAKE2b-256 | 4799e91be1573c4422db51c7eb57394a41e6c00a244de0cd60361b7cc0e596cc |