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

the easy way:

pip install --no-binary pytblis pytblis

The default compile options will give good performance. OpenMP is the default thread model when building from source. You can pass additional options to CMake via CMAKE_ARGS, change the thread model, compile for other CPU microarchitectures, etc.

the hard way:

  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.10.tar.gz (473.1 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.10-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.10-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.10-cp312-abi3-macosx_12_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.12+macOS 12.0+ ARM64

pytblis-0.0.10-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.10-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.10-cp311-cp311-macosx_12_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.11macOS 12.0+ ARM64

pytblis-0.0.10-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.10-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.10-cp310-cp310-macosx_12_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.10macOS 12.0+ ARM64

pytblis-0.0.10-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.10-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.10-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.10.tar.gz.

File metadata

  • Download URL: pytblis-0.0.10.tar.gz
  • Upload date:
  • Size: 473.1 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.10.tar.gz
Algorithm Hash digest
SHA256 20969aa5fadf53e9552fe0a9b1cd255b7a688c795bbbbd812e78171d1b5cecf1
MD5 a41d98af47cb13e5bdf320e0f58810c6
BLAKE2b-256 c64f20e34e535c9d11fb3f3f969c2c47a494c33776f3c687672a5551010f003e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.10.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.10-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.10-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b349348ec7bfe524842da70f53d0b601ac9e80e9350c4f4480b0ffc55a14edb7
MD5 1ca671ed17980c3fd1a13a3c5ef6583a
BLAKE2b-256 6faf3c02cc77358df374fc5eacb41ef1d47dbc995de3031be59afdf304d4249a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.10-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.10-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.10-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d0be3dc1f7d33d4ce7e55ab5bdb9fa1232de2cac7b3a5f320bfeb8f12ba7b78d
MD5 a8cc7d679ee62286712f41cd19aa53ee
BLAKE2b-256 d616ac3e82fe7d0ae13d8ca157c71d02579c90091a5ca5c191d30e87f8d0d185

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.10-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.10-cp312-abi3-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.10-cp312-abi3-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 a707da6cface1bfe5a3aed85d63076c8fba343b615c260ecfb8bbb87963821f0
MD5 867ad3ea3c957ae6876da631475b8402
BLAKE2b-256 ac16a53b731834a6c8a468427e11ae13dcb9d9adfa5338ada2337cdae4526ee8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.10-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.10-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.10-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cc9d8d6615c78bf21f8a94e601907e14b268c8a45f6439a290a8c6e2a4d9c422
MD5 cb512449515114ce7afa42e3f4f0366b
BLAKE2b-256 dbd21db2fbb7e1435da200ff4b4844da708f8c85dca0d188d23b37ef18e26607

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.10-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.10-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.10-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 115f252dcab64a4753b7ce7bfce47ef1e8cf25d1c09e62c6bf40aba61f7c11c4
MD5 5654cf8370727a07d00e46e3c5cc7a33
BLAKE2b-256 946da41dd9b96a9d9f3d3e41640d110e15e8da4ff214eb370d43662ace71bbca

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.10-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.10-cp311-cp311-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.10-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 104059b4884a3be3b96a6bb61233fb3f5f9d7e83f0f2ff890c90cd65f9264ae9
MD5 72134a50d9bd4b245054497780c281f5
BLAKE2b-256 9996a3bc209c45552c4c3b3861c3ea94d99d9ef75071fa04ce308bb627b11a64

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.10-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.10-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.10-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0678715801cf13b2d294ce6055a0d45063f60dd0d59d8f0cdd607a0f3b2af095
MD5 1ba1756e05e742c517d8af85b5bf1123
BLAKE2b-256 7429a3c10dce39ccf708c84c167e156db164693ab4078cad2c173cc8b98c39b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.10-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.10-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.10-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 885856eb78474bf8bd10baa50589e26530c06d8905ec3105fc8292a2779b5020
MD5 0394fa5caeea3779c9891ce237f326f8
BLAKE2b-256 900abd984424af57da133f7f395bc8ff9bec683c01fbb3da5e2294cabf684bbd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.10-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.10-cp310-cp310-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.10-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 055daedf58d32421049493883af882dd968adb0504eded4801911d78b482925b
MD5 cfd9de7936ac8989bba173bddf3a8adb
BLAKE2b-256 3b0ce1128fc7b4220818c529a92d9b2661679240644350447932ccb6bb9bc267

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.10-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.10-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.10-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 12bb75500d590d0535a30bf52cc3233f4c18d810ae3fc531dd242cf6512b3e0d
MD5 8e462fe0c7fe274911ef05d168913c43
BLAKE2b-256 bd90400006d8178081b3b37f851296246f24a44f68ff26de7748aeddaa50d291

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.10-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.10-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.10-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 23e9446b73ae28f8a1d19e001ae19d17d014761880968680c9861f480f9c0de9
MD5 23560488e5b2e35c8b11d311e67c6aa3
BLAKE2b-256 d7cfdf56eec6d42d28f4252c5f0947eac9c12eea3178bf3c087c54e1078025d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.10-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.10-cp39-cp39-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for pytblis-0.0.10-cp39-cp39-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 7c61a6aeaa117063c99153a11f5eb4a1f94252509bd07e51035171ff69011e36
MD5 47a088cfd24d41c42568e1dd560ee2ab
BLAKE2b-256 e3fd837cd3e5cec76b5fa2843621e4cebf17259d1fc5afd55d367db531353782

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytblis-0.0.10-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