thinc-apple-ops
Make spaCy and Thinc up to 8 × faster on macOS by calling into Apple's native libraries.
⏳ Install
Make sure you have Xcode installed and
then install with pip:
pip install thinc-apple-ops
🏫 Motivation
Matrix multiplication is one of the primary operations in machine learning. Since matrix multiplication is computationally expensive, using a fast matrix multiplication implementation can speed up training and prediction significantly.
Most linear algebra libraries provide matrix multiplication in the form of the
standardized
BLAS gemm
functions. The work behind scences is done by a set of matrix multiplication
kernels that are meticulously tuned for specific architectures. Matrix
multiplication kernels use architecture-specific
SIMD instructions for data-level parallism
and can take factors such as cache sizes and intstruction latency into account.
Thinc uses the
BLIS linear algebra library, which provides
optimized matrix multiplication kernels for most x86_64 and some ARM CPUs.
Recent Apple Silicon CPUs, such as the M-series used in Macs, differ from traditional x86_64 and ARM CPUs in that they have a separate matrix co-processor(s) called AMX. Since AMX is not well-documented, it is unclear how many AMX units Apple M CPUs have. It is certain that the (single) performance cluster of the M1 has an AMX unit and there is empirical evidence that both performance clusters of the M1 Pro/Max have an AMX unit.
Even though AMX units use a set of undocumented
instructions,
the units can be used through Apple's
Accelerate linear
algebra library. Since Accelerate implements the BLAS interface, it can be used
as a replacement of the BLIS library that is used by Thinc. This is where the
thinc-apple-ops package comes in. thinc-apple-ops extends the default Thinc
ops, so that gemm matrix multiplication from Accelerate is used in place of
the BLIS implementation of gemm. As a result, matrix multiplication in Thinc
is performed on the fast AMX unit(s).
⏱ Benchmarks
Using thinc-apple-ops leads to large speedups in prediction and training on
Apple Silicon Macs, as shown by the benchmarks below.
Prediction
This first benchmark compares prediction speed of the de_core_news_lg spaCy
model between the M1 with and without thinc-apple-ops. Results for an Intel
Mac Mini and AMD Ryzen 5900X are also provided for comparison. Results are in
words per second. In this prediction benchmark, using thinc-apple-ops improves
performance by 4.3 times.
| CPU | BLIS | thinc-apple-ops | Package power (Watt) |
|---|---|---|---|
| Mac Mini (M1) | 6492 | 27676 | 5 |
| MacBook Air Core i5 2020 | 9790 | 10983 | 9 |
| Mac Mini Core i7 Late 2018 | 16364 | 14858 | 31 |
| AMD Ryzen 5900X | 22568 | N/A | 52 |
Training
In the second benchmark, we compare the training speed of the de_core_news_lg
spaCy model (without NER). The results are in training iterations per second.
Using thinc-apple-ops improves training time by 3.0 times.
| CPU | BLIS | thinc-apple-ops | Package power (Watt) |
|---|---|---|---|
| Mac Mini M1 2020 | 3.34 | 10.07 | 5 |
| MacBook Air Core i5 2020 | 3.10 | 3.27 | 10 |
| Mac Mini Core i7 Late 2018 | 4.71 | 4.93 | 32 |
| AMD Ryzen 5900X | 6.53 | N/A | 53 |
Metadata
Release files for thinc-apple-ops 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| thinc_apple_ops-1.0.0.tar.gz | 63.2 kB | Without provenance | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| thinc_apple_ops-1.0.0-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details |
| thinc_apple_ops-1.0.0-cp312-cp312-macosx_10_9_x86_64.whl | CPython 3.12 | CPython 3.12 | macOS 10.9+ x86-64 | Details |
| thinc_apple_ops-1.0.0-cp311-cp311-macosx_11_0_arm64.whl | CPython 3.11 | CPython 3.11 | macOS 11.0+ ARM64 | Details |
| thinc_apple_ops-1.0.0-cp311-cp311-macosx_10_9_x86_64.whl | CPython 3.11 | CPython 3.11 | macOS 10.9+ x86-64 | Details |
| thinc_apple_ops-1.0.0-cp310-cp310-macosx_11_0_arm64.whl | CPython 3.10 | CPython 3.10 | macOS 11.0+ ARM64 | Details |
| thinc_apple_ops-1.0.0-cp310-cp310-macosx_10_9_x86_64.whl | CPython 3.10 | CPython 3.10 | macOS 10.9+ x86-64 | Details |
| thinc_apple_ops-1.0.0-cp39-cp39-macosx_11_0_arm64.whl | CPython 3.9 | CPython 3.9 | macOS 11.0+ ARM64 | Details |
| thinc_apple_ops-1.0.0-cp39-cp39-macosx_10_9_x86_64.whl | CPython 3.9 | CPython 3.9 | macOS 10.9+ x86-64 | Details |
Total release size: 1.3 MB
Release files / thinc_apple_ops-1.0.0.tar.gz
| Download URL | thinc_apple_ops-1.0.0.tar.gz |
|---|---|
| Size | 63.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
97238eb6693e758bfdcf1ac8e92c064bbe893ab74a6a3a4237c5bdf17318e502
|
|
BLAKE2b-256 checksum How to use checksums |
0d4415fa7fd8c4f3011f29393a1aed7616b3991fb7562ef044a31a818c25558f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / thinc_apple_ops-1.0.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | thinc_apple_ops-1.0.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 157.7 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
1594f897f7dd03212d5b1ae1e4054be02526da530201a09c32d7bb557d274902
|
|
BLAKE2b-256 checksum How to use checksums |
c95dcacc702a8c7d6b5f19181819104b3d7d534598551d75a08d1c99ae96c869
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / thinc_apple_ops-1.0.0-cp312-cp312-macosx_10_9_x86_64.whl
| Download URL | thinc_apple_ops-1.0.0-cp312-cp312-macosx_10_9_x86_64.whl |
|---|---|
| Size | 163.0 kB |
| Tags | CPython 3.12 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
b2a9d2d3e8b86c9ce4750affc1b6c7350ef92fff3d33249302aeafee20f3e09e
|
|
BLAKE2b-256 checksum How to use checksums |
9c08c223217366308b794105b3269a5de183e898d0eb7d316143c33ca0d44d13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / thinc_apple_ops-1.0.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | thinc_apple_ops-1.0.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 156.6 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
257aa6fcaac764fc72285bf1fb93d1986ed9de17192c2c7090a785ee999188f8
|
|
BLAKE2b-256 checksum How to use checksums |
f3831717527eaebed4b71fd7e260deb7c8e2c33b35b9ac75a6bda6a1e7158e1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / thinc_apple_ops-1.0.0-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | thinc_apple_ops-1.0.0-cp311-cp311-macosx_10_9_x86_64.whl |
|---|---|
| Size | 161.5 kB |
| Tags | CPython 3.11 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
24083c6f74869a3b92bb398f610271687e269c290deda124075b3577a0873445
|
|
BLAKE2b-256 checksum How to use checksums |
a2c5fe79f5aff1731a80104c7366023b71b42948a6da3dad7383cbe779bdb6db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / thinc_apple_ops-1.0.0-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | thinc_apple_ops-1.0.0-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 156.9 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
2f641448bfcefc5c5204484a62baac7c040741fa8d8ecb86574a0357f390e373
|
|
BLAKE2b-256 checksum How to use checksums |
f41cb2727569fadd5299c11f3eecc8d2016cbb433b7b7d12da345295b2794693
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / thinc_apple_ops-1.0.0-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | thinc_apple_ops-1.0.0-cp310-cp310-macosx_10_9_x86_64.whl |
|---|---|
| Size | 161.9 kB |
| Tags | CPython 3.10 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
cef314b216ace57dddf403caabd12b8af9d5519b7c679b8a24871c28c7588845
|
|
BLAKE2b-256 checksum How to use checksums |
84b50e006fd7a0bf0a0a153ddf3134a47854e731af231bc865413188ec5c84a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / thinc_apple_ops-1.0.0-cp39-cp39-macosx_11_0_arm64.whl
| Download URL | thinc_apple_ops-1.0.0-cp39-cp39-macosx_11_0_arm64.whl |
|---|---|
| Size | 157.5 kB |
| Tags | CPython 3.9 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
25d16b4518642b394cc7c4cf6a6477720f35fb22e6d91dca633bff4102c59763
|
|
BLAKE2b-256 checksum How to use checksums |
e0a638816c30c865584ebd4ac80c21ae72d4f24518d726e755e3ff803ec47f89
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / thinc_apple_ops-1.0.0-cp39-cp39-macosx_10_9_x86_64.whl
| Download URL | thinc_apple_ops-1.0.0-cp39-cp39-macosx_10_9_x86_64.whl |
|---|---|
| Size | 162.5 kB |
| Tags | CPython 3.9 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
cd04a7cd379a629498f964f5c589150a885ce834228dc060967806ee32196fab
|
|
BLAKE2b-256 checksum How to use checksums |
93ec8f2aa7e1171343e456145fe47596d053b61d55cdadd3f04b46c99133d34b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Security for thinc-apple-ops 1.0.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.