Skip to main content

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!

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 precisions isn't yet supported.

New features

Mixed-complex/real contractions

New in version v0.0.11: pytblis.contract fully supports contractions between complex and/or real tensors of the same floating point precision, provided that alpha and beta are both real. This just contracts the real and imaginary parts separately with TBLIS. As of v0.0.14, this feature is enabled by default. It can be turned off in pytblis.contract and pytblis.einsum by passing complex_real_contractions=False.

Installation

I will try to get this package added to conda-forge. In the meantime, conda packages may be downloaded from my personal channel.

conda install pytblis -c conda-forge -c chillenb

The pre-built Mac OS wheels on PyPI use pthreads for multithreading. The Linux wheels now use OpenMP, which is much more efficient. Mac users who want OpenMP should install from source or use the conda packages.

pip install pytblis (not as performant)

About OpenBLAS

Don't use OpenBLAS configured with pthreads. It causes oversubscription when used with other multithreaded libraries, in particular anything that uses OpenMP. Instead, use MKL (libblas=*=*mkl) or the OpenMP variant of OpenBLAS (libopenblas=*=*openmp*).

Installation from source

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.

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.

pytblis was developed in the Zhu Group, Department of Chemistry, Yale University.

Metadata

Release files for pytblis 0.0.16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytblis 0.0.16
File Size Uploaded
pytblis-0.0.16.tar.gz 486.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pytblis 0.0.16
File
pytblis-0.0.16-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
pytblis-0.0.16-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl CPython 3.12 abi3 Linux glibc 2.24+ ARM64, Linux glibc 2.28+ ARM64 Details
pytblis-0.0.16-cp312-abi3-macosx_12_0_arm64.whl CPython 3.12 abi3 macOS 12.0+ ARM64 Details
pytblis-0.0.16-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
pytblis-0.0.16-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.24+ ARM64, Linux glibc 2.28+ ARM64 Details
pytblis-0.0.16-cp311-cp311-macosx_12_0_arm64.whl CPython 3.11 CPython 3.11 macOS 12.0+ ARM64 Details
pytblis-0.0.16-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
pytblis-0.0.16-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.24+ ARM64, Linux glibc 2.28+ ARM64 Details
pytblis-0.0.16-cp310-cp310-macosx_12_0_arm64.whl CPython 3.10 CPython 3.10 macOS 12.0+ ARM64 Details
pytblis-0.0.16-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
pytblis-0.0.16-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl CPython 3.9 CPython 3.9 Linux glibc 2.28+ ARM64, Linux glibc 2.24+ ARM64 Details
pytblis-0.0.16-cp39-cp39-macosx_12_0_arm64.whl CPython 3.9 CPython 3.9 macOS 12.0+ ARM64 Details

Total release size: 44.3 MB

Release files / pytblis-0.0.16.tar.gz

Download URL pytblis-0.0.16.tar.gz
Size 486.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0b1e09f13f407057b29ef18efc61508fff23dfa61a6b6167e7df3209d235cc8f
BLAKE2b-256 checksum
How to use checksums
c709036d061bad5b405a457a6f65ca6b625d02c7e0eccbb9d0f07ff9c2c866e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / pytblis-0.0.16-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL pytblis-0.0.16-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 6.0 MB
Tags CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
b913214c908ca72a5060aed163d14b327e92ce45575d123cdd6233882073c74b
BLAKE2b-256 checksum
How to use checksums
81be94589ac86195b6c03a629097491908f06a82b6b27b225127e4998c5e6804
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / pytblis-0.0.16-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL pytblis-0.0.16-cp312-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 2.7 MB
Tags CPython 3.12 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
ab8167e8aec31da6b357f7498bb8807e3629fda63386aa0e82986906882ba954
BLAKE2b-256 checksum
How to use checksums
8bc93b61f4f9d3a6bab54cdd60f4e518c503a66fcc1744b5bef857cc07020fd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / pytblis-0.0.16-cp312-abi3-macosx_12_0_arm64.whl

Download URL pytblis-0.0.16-cp312-abi3-macosx_12_0_arm64.whl
Size 2.1 MB
Tags CPython 3.12 abi3 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
249fd0f178f8d3714fbbc2751007727597e81be7b76398ba0a3091208821587d
BLAKE2b-256 checksum
How to use checksums
cf9bd3b42084de4d15d43f88af32603ffe5437f7af5f32ebed387a51de3b0ce6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / pytblis-0.0.16-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL pytblis-0.0.16-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 6.1 MB
Tags CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
43aa9e6d900c2f9c8b6f39cfbf2c47bcacea942da3beb2911a99ced5ba12045b
BLAKE2b-256 checksum
How to use checksums
4ebdef2790b77f6f3c1fea7e18c783398f46e8b363213fac2fc4faa33cfe8f72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / pytblis-0.0.16-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL pytblis-0.0.16-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 2.7 MB
Tags CPython 3.11 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
69c6147489e6b85336b323aac36339db654e5c87c457b50d4e69af6446399fc1
BLAKE2b-256 checksum
How to use checksums
1543656581dfbf70487df1863c591785f71b591d5bd243ad3e349da0b1643fa3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / pytblis-0.0.16-cp311-cp311-macosx_12_0_arm64.whl

Download URL pytblis-0.0.16-cp311-cp311-macosx_12_0_arm64.whl
Size 2.2 MB
Tags CPython 3.11 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
dac7d293dc60f8b19d4c6f373bcfc037c3ea3116280ffff0845058e8362193b1
BLAKE2b-256 checksum
How to use checksums
54437e1b16b268817b0e393374e98712bd6b0d05c1ca7d3daa9a1e5e8d98c618
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / pytblis-0.0.16-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL pytblis-0.0.16-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 6.1 MB
Tags CPython 3.10 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
fb2381282bfcfc5ee75badad5255b840e7618dfdb5332d9f71d72f08e517a7fe
BLAKE2b-256 checksum
How to use checksums
ab1ba415f9193fc088206539fab1fc7ded4483375ac2a22a369839d59b7ed330
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / pytblis-0.0.16-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL pytblis-0.0.16-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 2.7 MB
Tags CPython 3.10 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
5aa155e855701179553f52a4b72871a381b33b5c4d5cfa1ff9e68dbffca44e2e
BLAKE2b-256 checksum
How to use checksums
7ff94ff8ce4e4aa37adc8972713193f96670d914ba4bb4f23fd89c9bc62630b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / pytblis-0.0.16-cp310-cp310-macosx_12_0_arm64.whl

Download URL pytblis-0.0.16-cp310-cp310-macosx_12_0_arm64.whl
Size 2.2 MB
Tags CPython 3.10 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
dbbba9c0148a1ed66283b5bd0307169ead343d2f17cbfe02dff9b4cdacb9a80a
BLAKE2b-256 checksum
How to use checksums
771fd5151b4aebb03cfb3104e4b50a125494526fab8d2d27cf7a06502ac5e4f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / pytblis-0.0.16-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL pytblis-0.0.16-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 6.1 MB
Tags CPython 3.9 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
ae16c0cacd3ad6c73f6da6f0a5e81c1ce10755953a073d5328a70626b4d43ebf
BLAKE2b-256 checksum
How to use checksums
2e7b6a68856664a114c0ea6f0492d959a97ae04de4f0eaa77f6cc54126e4868a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / pytblis-0.0.16-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL pytblis-0.0.16-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 2.7 MB
Tags CPython 3.9 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
3922c02bcd197d4e714b08dd586d7018c6f0878cb16bf443d3bdc8c1bd2a3c39
BLAKE2b-256 checksum
How to use checksums
de65ee25e5d117551c9e0cab22dcbd597df4fb989c4c05f15cbd7fc00e8040a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release files / pytblis-0.0.16-cp39-cp39-macosx_12_0_arm64.whl

Download URL pytblis-0.0.16-cp39-cp39-macosx_12_0_arm64.whl
Size 2.2 MB
Tags CPython 3.9 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
76a4534b29bd849383c74d60cec82e113f6e88abae649accd31bc4e372d704b8
BLAKE2b-256 checksum
How to use checksums
ae15b67f72afd65a4094a3ad56ede4cfcaa4d6eb0260b81508234753482827a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.16 This release

13 release files

0.0.9

13 release files

0.0.8

16 release files

0.0.5

16 release files

0.0.2

16 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page