Skip to main content

Python bindings for TBLIS, a high performance library for tensor operations

Project description

pytblis: Python bindings for TBLIS

Actions Status GitHub Discussion

Are your einsums too slow?

Need FP64 tensor contractions and can't buy a datacenter GPU because you already maxed out your home equity line of credit?

Set your CPU on fire with TBLIS!

Installation

pip install pytblis

The pre-built wheels on PyPI use pthreads for multithreading. To reduce the overhead due to creating and joining threads, compile pytblis yourself and configure it to use OpenMP.

Building

  1. Install TBLIS.
  2. Run CMAKE_ARGS="-DTBLIS_ROOT=wherever_tblis_is_installed" pip install .

See dev_install.sh for an example. This script installs TBLIS in ./local_tblis_prefix and then links pytblis against it.

Usage

pytblis.einsum and pytblis.tensordot are drop-in replacements for numpy.einsum and numpy.tensordot.

In addition, low level wrappers are provided for tblis_tensor_add, tblis_tensor_mult, tblis_tensor_reduce, tblis_tensor_shift, and tblis_tensor_dot. These are named pytblis.add, pytblis.mult, et cetera.

Finally, there are mid-level convenience wrappers for tblis_tensor_mult and tblis_tensor_add:

def contract(
    subscripts: str,
    a: ArrayLike,
    b: ArrayLike,
    alpha: scalar = 1.0,
    beta: scalar = 0.0,
    out: Optional[npt.ArrayLike] = None,
    conja: bool = False,
    conjb: bool = False,
) -> ArrayLike

and

def transpose_add(
    subscripts: str,
    a: ArrayLike,
    alpha: scalar = 1.0,
    beta: scalar = 0.0,
    out: Optional[ArrayLike] = None,
    conja: bool = False,
    conjout: bool = False,
) -> ArrayLike

These are used as follows:

C = pytblis.contract("ij,jk->ik", A, B, alpha=1.0, beta=0.5, out=C, conja=True, conjb=False)

does

$$C \gets \overline{A} B + \frac{1}{2} C.$$

B = pytblis.tensor_add("iklj->ijkl", A, alpha=-1.0, beta=1.0, out=B)

does

$$B_{ijkl} \gets B_{ijkl} - A_{iklj}.$$

Some additional documentation (work in progress) is available at pytblis.readthedocs.io.

Limitations

Supported datatypes: np.float32, np.float64, np.complex64, np.complex128. Mixing arrays of different types isn't yet supported. I may add a workaround for real-complex tensor contraction.

Arrays with negative or zero stride are not supported and will cause pytblis to fall back to NumPy (for einsum and contract) or raise an error (all other functions).

Research

If you use TBLIS in your academic work, it's a good idea to cite:

TBLIS is not my work, and its developers are not responsible for flaws in these Python bindings.

Acknowledgements

The implementation of einsum and the tests are modified versions of those from opt_einsum.

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

pytblis-0.0.9.tar.gz (27.5 kB view details)

Uploaded Source

Built Distributions

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

pytblis-0.0.9-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (5.9 MB view details)

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

pytblis-0.0.9-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (2.6 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

pytblis-0.0.9-cp312-abi3-macosx_12_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.12+macOS 12.0+ ARM64

pytblis-0.0.9-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (5.9 MB view details)

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

pytblis-0.0.9-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (2.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

pytblis-0.0.9-cp311-cp311-macosx_12_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.11macOS 12.0+ ARM64

pytblis-0.0.9-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (5.9 MB view details)

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

pytblis-0.0.9-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (2.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

pytblis-0.0.9-cp310-cp310-macosx_12_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.10macOS 12.0+ ARM64

pytblis-0.0.9-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (5.9 MB view details)

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

pytblis-0.0.9-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (2.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

pytblis-0.0.9-cp39-cp39-macosx_12_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.9macOS 12.0+ ARM64

File details

Details for the file pytblis-0.0.9.tar.gz.

File metadata

  • Download URL: pytblis-0.0.9.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytblis-0.0.9.tar.gz
Algorithm Hash digest
SHA256 77b25e00a1c54d135e057e2a63f223f11b1ec1cc33d4d959bf2a1cf9b71f792b
MD5 33801c78e7451a5b92ba3b21f5904a63
BLAKE2b-256 86f3c4aa81c194c80273dd4d0cb2beecb27b9557a8f222785358f2f410b9df96

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.9.tar.gz:

Publisher: release.yml on chillenb/pytblis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytblis-0.0.9-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.9-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8d30f3dffe8e969a8e74f29d180a1c2d0467dbf6302e921642acd03e42f4afdf
MD5 1c4568fba6ffda8b9012e9219ede6eaa
BLAKE2b-256 4f2077a2a0e5035fdc23090bb028fabf533f88faf878df3d45a36241a0f9f516

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.9-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on chillenb/pytblis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytblis-0.0.9-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.9-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 163a4c710a3878147d4345bfc9a5fdb5219f593e574d371e542a5e9d2fc1a2ed
MD5 5e7c44044cef645996b0b9a226706491
BLAKE2b-256 6726876f5c31ede595d31de414162af23485a5701fbe8d7e05b13162c9c3ae7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.9-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yml on chillenb/pytblis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytblis-0.0.9-cp312-abi3-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.9-cp312-abi3-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 ca597b97f240564bb10f75754ba64bbc907920d8bd437cfec5309457b37f2304
MD5 8a473e15b0819817b500932837c57981
BLAKE2b-256 f64a0f05d274e01d7b0db6b0533102985c63de028a5cb7a335483acb23ec9ace

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.9-cp312-abi3-macosx_12_0_arm64.whl:

Publisher: release.yml on chillenb/pytblis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytblis-0.0.9-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.9-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 03ee45eaa651b4090d4762a374be77abff15f0aa86991bd2e8c167bb80f1da00
MD5 c696df51a4e59bca89b7e59ed84f90a0
BLAKE2b-256 acfdc772ae199b49c18a6d340a21782564f44b5046fbb2ad4e214b3f5976c8be

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.9-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on chillenb/pytblis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytblis-0.0.9-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.9-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 59e270e9ded7d333dc491d1ffdab32a5c3b2683cdbc30c2efc421314fd75e03f
MD5 7750e566f901fa29f56c738a8b953953
BLAKE2b-256 b4feaa6d71e7a414e06600e2d5988db217cc3fdb4310eb3498a9152e424f8544

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.9-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yml on chillenb/pytblis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytblis-0.0.9-cp311-cp311-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.9-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 3d6e300559e4310bd3ea15de3c2db9c04cff986b2c721966e3223f74fca47070
MD5 583cf564be8eeeb878ada7fd8d10e325
BLAKE2b-256 3dca54567a9eba77c0031b58b5f7000f8bf7f7c188f56785482e895d950a3cba

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.9-cp311-cp311-macosx_12_0_arm64.whl:

Publisher: release.yml on chillenb/pytblis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytblis-0.0.9-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.9-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4c661ae3ef270910e71fecd1fdcf77ed2329cccc7fa21c221ef15807a1913a7f
MD5 d59c30d41236244ef67935f9d09feac4
BLAKE2b-256 52aa4296e8b5801a8cd858b2434b81e26374ae9a78672e386ecd0bfe5bb0d52b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.9-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on chillenb/pytblis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytblis-0.0.9-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.9-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 74a64723559f6952317678f260bf395ac9619fd8e5a8f19f7aec0662ada8d158
MD5 e667f9465ab32f8322b68803a7befc70
BLAKE2b-256 a91b3b56e3e5c71a4da58a2d77124d60fa2d6da1476afb308f079879f9bdfa3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.9-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yml on chillenb/pytblis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytblis-0.0.9-cp310-cp310-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.9-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 a5d59d35f834b0147ec48bd78b69b8166140fe8bb36fc83429f824051a2f7d14
MD5 8fb09027551060873664a1aebc404117
BLAKE2b-256 d941332fb2138f6301e8383cea8cad22871bc489c0803d19197abb07f13abb1e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.9-cp310-cp310-macosx_12_0_arm64.whl:

Publisher: release.yml on chillenb/pytblis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytblis-0.0.9-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.9-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ea86519690e83360f41f841c4a03f328de7e90079b155aba9aa6e50b0879450d
MD5 2e2bcdbd2a38a05be03d537b6233e7b1
BLAKE2b-256 0c37d59cf0cbdaf0abbea6c1e24d26d7661959cf8db69ba9aecf9082ce8e8fcb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.9-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on chillenb/pytblis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytblis-0.0.9-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.9-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 41bb3289d4413145153ee2db94d5491cfaec960d89e95598fa54c90a665c2161
MD5 861302f5bcf7ea2d2b7fe3494ee2ebce
BLAKE2b-256 98d01419222242454014dd10d45fc84dfad565545def20cb5cdf6a27b5d0bddb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.9-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yml on chillenb/pytblis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytblis-0.0.9-cp39-cp39-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.9-cp39-cp39-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 de1ca6e4994857d6cc5993862d17d71e5fc0be2975906efdbd273477e05656a6
MD5 dd8408277f7518a56722f0f38fe5e79a
BLAKE2b-256 7cfb24a56cfbaba0cea8634cb2958a2f33c9c29b73f52dd1d2d4aabc3afdf199

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.9-cp39-cp39-macosx_12_0_arm64.whl:

Publisher: release.yml on chillenb/pytblis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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