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.5.tar.gz (260.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

compintpy-0.0.5-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (218.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

compintpy-0.0.5-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (218.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

compintpy-0.0.5-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (218.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

compintpy-0.0.5-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (219.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file compintpy-0.0.5.tar.gz.

File metadata

  • Download URL: compintpy-0.0.5.tar.gz
  • Upload date:
  • Size: 260.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for compintpy-0.0.5.tar.gz
Algorithm Hash digest
SHA256 9663bc6eafeefd1aac8efeaa747cf88c64ed452b4f60c430f7447c73931bcc92
MD5 8ee2d59a392bb5d9aba9bfd82a9d2b27
BLAKE2b-256 14dc7841a33a076c3c837fe10a917af6d4ed77ec3a9a17c746f3aedd7c7df4e2

See more details on using hashes here.

File details

Details for the file compintpy-0.0.5-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for compintpy-0.0.5-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f929f413114a924fc0fcd4be097fa30a953336cc0982c63152fe21b9cde46557
MD5 7c4908354a6b76bd87f79cf5cf8265c0
BLAKE2b-256 9330ef3ccebcfd7ad856ed77ff7e8ac28f261dbd06752d4b7438dbe9f3b44919

See more details on using hashes here.

File details

Details for the file compintpy-0.0.5-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for compintpy-0.0.5-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 44de55e325d34900ceda25ff6ff46f363c560c6ba765a1b0e9f386e3e7790802
MD5 09ed1784c8c1a7177c8262341b51b839
BLAKE2b-256 6b57f80e05d85dc72ad779711c20aa306b2d2daaf38946b11fa936012c8e7605

See more details on using hashes here.

File details

Details for the file compintpy-0.0.5-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for compintpy-0.0.5-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4df8d1ba5e2ad30b0cac8082186126ef4515a4e267a98e56a95e7ab1c69dff5a
MD5 550ccf16f6aa9b8dd60b5b39fa632df9
BLAKE2b-256 74d8df40198fc4c26a5718a8e18899c2655026eb2e23e3fc26836787b5067f62

See more details on using hashes here.

File details

Details for the file compintpy-0.0.5-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for compintpy-0.0.5-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ec91d8432e532826e2df83fc5a27da633c86a0f29708282bda380d8b8957fb0f
MD5 967a076b71d8a3c676e7e296939e9d0a
BLAKE2b-256 3e37d983ca74f4d59bc53f5ef5b5b30689339509963eee846b023398962a6d51

See more details on using hashes here.

Supported by

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