Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

compintpy-0.0.4.tar.gz (260.0 kB view details)

Uploaded Source

Built Distributions

compintpy-0.0.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (190.2 kB view details)

Uploaded CPython 3.13 manylinux: glibc 2.17+ x86-64

compintpy-0.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (189.0 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

compintpy-0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (190.3 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

compintpy-0.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (188.0 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

compintpy-0.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (188.7 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

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

Hashes for compintpy-0.0.4.tar.gz
Algorithm Hash digest
SHA256 6c39bc4b01e381155bcc503c5f15d5077b2292504792ff7c1b1cfd3164cdc4ab
MD5 6fac1530f55979ce9b1ce6036c5b01a6
BLAKE2b-256 01debce1b781bdb1affdc28c8c5e6380f4ac9b4aae4ec258a121c7ff53fdce16

See more details on using hashes here.

File details

Details for the file compintpy-0.0.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for compintpy-0.0.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 26c987bfd52f3e4dbe90ba16b42c57271fdd3e93cd2b93cc9957671bdea9ec0b
MD5 78035e708682ef2bd1024f80fc83ca5a
BLAKE2b-256 dbc26cfb7e4db6419588825ae661477fcd21d858f4b0de10227389a07aad60a2

See more details on using hashes here.

File details

Details for the file compintpy-0.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for compintpy-0.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ed7a3e356ae8beaeac99f751df69229a0dc39c33743ba171e590cc1effe5b62c
MD5 eed84af685cbb126c177ac0192566842
BLAKE2b-256 235c21ec07a8516283b0caff8c8efbe1fbaaac7649ba2c611e08b3a801f0f7e0

See more details on using hashes here.

File details

Details for the file compintpy-0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for compintpy-0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 00de8c0e7a2cf6158debb8c5ed2d9246ccc3d816cc83db2b02c7c17a9cb7ece3
MD5 dbf8cc9cc1fe2a5602214b274cea1493
BLAKE2b-256 76141e42b73248f5eab8ad904f171379758eaaa34dc726b24c9fb1c7acc34a45

See more details on using hashes here.

File details

Details for the file compintpy-0.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for compintpy-0.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 721f326d247991134152d1ac2c2f9a817abb5948dca79e44165f04b85f2d6a5e
MD5 e207f57b6bf8ccd081472f83b71bf8b6
BLAKE2b-256 7c034bf43c3cdf20c37ef3fcca736524266258149d51b08019649ecbdf38dcbf

See more details on using hashes here.

File details

Details for the file compintpy-0.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for compintpy-0.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 88788b2f141faad3ced1abe53cfcfae71518c6beb25d97c629d0cf694e8073dc
MD5 b6e1030e186077d6e692e0b94c4aeb8c
BLAKE2b-256 b5db1acd336502e3e3ad173d807a4627343a93ee1b04161252617bd99e2204fa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page