Skip to main content

Cython BLIS: Fast BLAS-like operations from Python and Cython, without the tears

This repository provides the Blis linear algebra routines as a self-contained Python C-extension.

Currently, we only supports single-threaded execution, as this is actually best for our workloads (ML inference).

Azure Pipelines pypi Version conda Python wheels

Installation

You can install the package via pip, first making sure that pip, setuptools, and wheel are up-to-date:

pip install -U pip setuptools wheel
pip install blis

Wheels should be available, so installation should be fast. If you want to install from source and you're on Windows, you'll need to install LLVM.

Building BLIS for alternative architectures

The provided wheels should work on x86_86 architectures. Unfortunately we do not currently know a way to provide different wheels for alternative architectures, and we cannot provide a single binary that works everywhere. So if the wheel doesn't work for your CPU, you'll need to specify source distribution, and tell Blis your CPU architecture using the BLIS_ARCH environment variable.

a) Installing with generic arch support

BLIS_ARCH="generic" pip install spacy --no-binary blis

b) Building specific support

In order to compile Blis, cython-blis bundles makefile scripts for specific architectures, that are compiled by running the Blis build system and logging the commands. We do not yet have logs for every architecture, as there are some architectures we have not had access to.

See here for list of architectures. For example, here's how to build support for the ARM architecture cortexa57:

git clone https://github.com/explosion/cython-blis && cd cython-blis
git pull && git submodule init && git submodule update && git submodule status
python3 -m venv env3.6
source env3.6/bin/activate
pip install -r requirements.txt
./bin/generate-make-jsonl linux cortexa57
BLIS_ARCH="cortexa57" python setup.py build_ext --inplace
BLIS_ARCH="cortexa57" python setup.py bdist_wheel

Fingers crossed, this will build you a wheel that supports your platform. You could then submit a PR with the blis/_src/make/linux-cortexa57.jsonl and blis/_src/include/linux-cortexa57/blis.h files so that you can run:

BLIS_ARCH=cortexa57 pip install --no-binary=blis

Usage

Two APIs are provided: a high-level Python API, and direct Cython access, which provides fused-type, nogil Cython bindings to the underlying Blis linear algebra library. Fused types are a simple template mechanism, allowing just a touch of compile-time generic programming:

cimport blis.cy
A = <float*>calloc(nN * nI, sizeof(float))
B = <float*>calloc(nO * nI, sizeof(float))
C = <float*>calloc(nr_b0 * nr_b1, sizeof(float))
blis.cy.gemm(blis.cy.NO_TRANSPOSE, blis.cy.NO_TRANSPOSE,
             nO, nI, nN,
             1.0, A, nI, 1, B, nO, 1,
             1.0, C, nO, 1)

Bindings have been added as we've needed them. Please submit pull requests if the library is missing some functions you require.

Development

To build the source package, you should run the following command:

./bin/copy-source-files.sh

This populates the blis/_src folder for the various architectures, using the flame-blis submodule.

Updating the build files

In order to compile the Blis sources, we use jsonl files that provide the explicit compiler flags. We build these jsonl files by running Blis's build system, and then converting the log. This avoids us having to replicate the build system within Python: we just use the jsonl to make a bunch of subprocess calls. To support a new OS/architecture combination, we have to provide the jsonl file and the header.

Linux

The Linux build files need to be produced from within the manylinux1 docker container, so that they will be compatible with the wheel building process.

First, install docker. Then do the following to start the container:

sudo docker run -it quay.io/pypa/manylinux1_x86_64:latest

Once within the container, the following commands should check out the repo and build the jsonl files for the generic arch:

mkdir /usr/local/repos
cd /usr/local/repos
git clone https://github.com/explosion/cython-blis && cd cython-blis
git pull && git submodule init && git submodule update && git submodule
status
/opt/python/cp36-cp36m/bin/python -m venv env3.6
source env3.6/bin/activate
pip install -r requirements.txt
./bin/generate-make-jsonl linux generic --export
BLIS_ARCH=generic python setup.py build_ext --inplace
# N.B.: don't copy to /tmp, docker cp doesn't work from there.
cp blis/_src/include/linux-generic/blis.h /linux-generic-blis.h
cp blis/_src/make/linux-generic.jsonl /

Then from a new terminal, retrieve the two files we need out of the container:

sudo docker ps -l # Get the container ID
# When I'm in Vagrant, I need to go via cat -- but then I end up with dummy
# lines at the top and bottom. Sigh. If you don't have that problem and
# sudo docker cp just works, just copy the file.
sudo docker cp aa9d42588791:/linux-generic-blis.h - | cat > linux-generic-blis.h
sudo docker cp aa9d42588791:/linux-generic.jsonl - | cat > linux-generic.jsonl

Release files for blis 0.7.4

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

Source distribution (sdist)

Source distribution for blis 0.7.4
File Size Uploaded
blis-0.7.4.tar.gz 2.8 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for blis 0.7.4
File
blis-0.7.4-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
blis-0.7.4-cp39-cp39-manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
blis-0.7.4-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details
blis-0.7.4-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
blis-0.7.4-cp38-cp38-manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details
blis-0.7.4-cp38-cp38-macosx_10_9_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.9+ x86-64 Details
blis-0.7.4-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
blis-0.7.4-cp37-cp37m-manylinux2014_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 Details
blis-0.7.4-cp37-cp37m-macosx_10_9_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 Details
blis-0.7.4-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
blis-0.7.4-cp36-cp36m-manylinux2014_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.17+ x86-64 Details
blis-0.7.4-cp36-cp36m-macosx_10_9_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64 Details

Total release size: 90.7 MB

Release files / blis-0.7.4.tar.gz

Download URL blis-0.7.4.tar.gz
Size 2.8 MB
Tags Source
SHA-256 checksum
How to use checksums
7daa615a97d4f28db0f332b710bfe1900b15d0c25841c6d727965e4fd91e09cf
BLAKE2b-256 checksum
How to use checksums
b154b0de9905ee80aebd64c333bc112cacfe06849a9b5a7230a02dfde73e7aad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Release files / blis-0.7.4-cp39-cp39-win_amd64.whl

Download URL blis-0.7.4-cp39-cp39-win_amd64.whl
Size 6.5 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
78a8e0ee72a42c3b2f5b9114500a781119995f76fa6c21d4b02c6fb9c21df2cc
BLAKE2b-256 checksum
How to use checksums
521c3bbb7c382d728f94b9a9b911f54200da16bed3ef2d9adf3c81d2781ca652
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Release files / blis-0.7.4-cp39-cp39-manylinux2014_x86_64.whl

Download URL blis-0.7.4-cp39-cp39-manylinux2014_x86_64.whl
Size 9.8 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
5c1a2023f7d8431daa8d87d32f539bb23e1a009500c37f9eba0ac7b3f20f73eb
BLAKE2b-256 checksum
How to use checksums
c086937a97e4db05fda4b333f9267573316e0e7ce409ed48832773cc31cc53db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Release files / blis-0.7.4-cp39-cp39-macosx_10_9_x86_64.whl

Download URL blis-0.7.4-cp39-cp39-macosx_10_9_x86_64.whl
Size 5.8 MB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
168fd7bd763ebe529aa25a066d3a6b89f4c3f492f6297f881df6942741b95787
BLAKE2b-256 checksum
How to use checksums
3519c2d83aac652e904f1103721f13451b0f8b1f86e0cb5143e09715370c4a2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Release files / blis-0.7.4-cp38-cp38-win_amd64.whl

Download URL blis-0.7.4-cp38-cp38-win_amd64.whl
Size 6.5 MB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
94890b2296f1449baa56aede46627ea7fc8de11c788f9c261ee38c2eb4a2cc7d
BLAKE2b-256 checksum
How to use checksums
efde4f0c01070a21633665f2ac5a0f608a8c6e78525167750c3c2cb698d47d87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Release files / blis-0.7.4-cp38-cp38-manylinux2014_x86_64.whl

Download URL blis-0.7.4-cp38-cp38-manylinux2014_x86_64.whl
Size 9.8 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
445e4838b809e99677f5c0982fb9af320f0d91328fb28c8097e5f1173c4df9d6
BLAKE2b-256 checksum
How to use checksums
0634e896b84f7d2e3d61e9b5718670025988eae81ac10deb5c33979cd633e1de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Release files / blis-0.7.4-cp38-cp38-macosx_10_9_x86_64.whl

Download URL blis-0.7.4-cp38-cp38-macosx_10_9_x86_64.whl
Size 5.8 MB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
4222bbc7b9c47bc3cf6f36f2241862c1512ca7ebac3828267a2e05ef6c47fc54
BLAKE2b-256 checksum
How to use checksums
4c8a520ce842368186de26a9f93a53832122fddb5b234dbf9256c59a2c6c2f94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Release files / blis-0.7.4-cp37-cp37m-win_amd64.whl

Download URL blis-0.7.4-cp37-cp37m-win_amd64.whl
Size 6.5 MB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
6814991b3e3193db4f9b2417174c6f24b9c0197409d864fa7628583bd2df1f0f
BLAKE2b-256 checksum
How to use checksums
7cf32c18510d125d6af493120ca50fc8f2e3c21c9f58fb38d34c032f813dadcb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Release files / blis-0.7.4-cp37-cp37m-manylinux2014_x86_64.whl

Download URL blis-0.7.4-cp37-cp37m-manylinux2014_x86_64.whl
Size 9.8 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
5ecddc4c6daf80558154b091db0a9839bb15dbe65d2906a543a73b93fbce4f73
BLAKE2b-256 checksum
How to use checksums
0ec1f364687078298233696eff17305f9a54c4a27d9da03c07c0062909d550f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Release files / blis-0.7.4-cp37-cp37m-macosx_10_9_x86_64.whl

Download URL blis-0.7.4-cp37-cp37m-macosx_10_9_x86_64.whl
Size 5.8 MB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
d717b5dea407aac89a646908e7d9849105abab9c88a539c120518c200f899f4e
BLAKE2b-256 checksum
How to use checksums
5cf2c0bd2de42c442fe1e0826aa525f9a8037b37eda465dbe09e9d7edbfb2f15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Release files / blis-0.7.4-cp36-cp36m-win_amd64.whl

Download URL blis-0.7.4-cp36-cp36m-win_amd64.whl
Size 6.5 MB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
c2d8064217c326dd9a0dcbae294ffe8557263e2a00d76101ffa222b9c9d9c62d
BLAKE2b-256 checksum
How to use checksums
d54e013b495c02ed555b56efe7c84b254a5e27f18aac34aac49d2ae1ea66b48e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Release files / blis-0.7.4-cp36-cp36m-manylinux2014_x86_64.whl

Download URL blis-0.7.4-cp36-cp36m-manylinux2014_x86_64.whl
Size 9.8 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
9f9b829480c12fc834549306821e5c51cb28b216ca5f88c5b2cfedbeb9daf67d
BLAKE2b-256 checksum
How to use checksums
bb9fe526cd764e2a2cf6958a1389a59c42acda7a65f24949256100cc94c2ff6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Release files / blis-0.7.4-cp36-cp36m-macosx_10_9_x86_64.whl

Download URL blis-0.7.4-cp36-cp36m-macosx_10_9_x86_64.whl
Size 5.8 MB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
5b403deb2ad5515e1edb3c0867bccb5b974b461f24283d9219a3a761fd6dacc6
BLAKE2b-256 checksum
How to use checksums
cc664390cb4842477f6a518875c5d04706279c730552472888fbddb944938290
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Release history Release notifications | RSS feed

1.3.3

36 release files

1.3.2

36 release files

1.3.1

29 release files

1.2.0

29 release files

1.1.0

36 release files

1.0.2

36 release files

1.0.1

29 release files

1.0.0

17 release files

0.9.0

19 release files

0.8.0

10 release files

0.7.9

28 release files

0.7.8

24 release files

0.7.7

19 release files

0.7.6

16 release files

0.7.5

16 release files

This release

0.7.4 This release

13 release files

0.7.3

13 release files

0.7.1

10 release files

0.7.0

10 release files

0.4.1

16 release files

0.4.0

12 release files

0.3.1

13 release files

0.2.3

1 release file

0.2.2

13 release files

0.2.1

10 release files

0.2.0

1 release file

0.1.0

8 release files

0.0.16

7 release files

0.0.13

1 release file

0.0.12

1 release file

0.0.10

1 release file

0.0.8

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

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