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
For Linux the project is available via pip:
pip install compintpy
Or, install it from the GitHub repository:
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.4.tar.gz
.
File metadata
- Download URL: compintpy-0.0.4.tar.gz
- Upload date:
- Size: 260.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c39bc4b01e381155bcc503c5f15d5077b2292504792ff7c1b1cfd3164cdc4ab |
|
MD5 | 6fac1530f55979ce9b1ce6036c5b01a6 |
|
BLAKE2b-256 | 01debce1b781bdb1affdc28c8c5e6380f4ac9b4aae4ec258a121c7ff53fdce16 |
File details
Details for the file compintpy-0.0.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: compintpy-0.0.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 190.2 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 | 26c987bfd52f3e4dbe90ba16b42c57271fdd3e93cd2b93cc9957671bdea9ec0b |
|
MD5 | 78035e708682ef2bd1024f80fc83ca5a |
|
BLAKE2b-256 | dbc26cfb7e4db6419588825ae661477fcd21d858f4b0de10227389a07aad60a2 |
File details
Details for the file compintpy-0.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: compintpy-0.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 189.0 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 | ed7a3e356ae8beaeac99f751df69229a0dc39c33743ba171e590cc1effe5b62c |
|
MD5 | eed84af685cbb126c177ac0192566842 |
|
BLAKE2b-256 | 235c21ec07a8516283b0caff8c8efbe1fbaaac7649ba2c611e08b3a801f0f7e0 |
File details
Details for the file compintpy-0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: compintpy-0.0.4-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 | 00de8c0e7a2cf6158debb8c5ed2d9246ccc3d816cc83db2b02c7c17a9cb7ece3 |
|
MD5 | dbf8cc9cc1fe2a5602214b274cea1493 |
|
BLAKE2b-256 | 76141e42b73248f5eab8ad904f171379758eaaa34dc726b24c9fb1c7acc34a45 |
File details
Details for the file compintpy-0.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: compintpy-0.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 188.0 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 | 721f326d247991134152d1ac2c2f9a817abb5948dca79e44165f04b85f2d6a5e |
|
MD5 | e207f57b6bf8ccd081472f83b71bf8b6 |
|
BLAKE2b-256 | 7c034bf43c3cdf20c37ef3fcca736524266258149d51b08019649ecbdf38dcbf |
File details
Details for the file compintpy-0.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: compintpy-0.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 188.7 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 | 88788b2f141faad3ced1abe53cfcfae71518c6beb25d97c629d0cf694e8073dc |
|
MD5 | b6e1030e186077d6e692e0b94c4aeb8c |
|
BLAKE2b-256 | b5db1acd336502e3e3ad173d807a4627343a93ee1b04161252617bd99e2204fa |