Fast Hadamard Transform with SIMD acceleration
Project description
FHT - Fast Hadamard Transform
High-performance Fast Hadamard Transform library with SIMD-optimized implementations for x86 (SSE/AVX) and ARM (NEON), and Python bindings via nanobind.
Install
pip install fht_cpu
From source:
git clone https://github.com/grigori-hpnalgs-lab/fht_cpu.git
cd fht
pip install .
Python Usage
import numpy as np
from fht import fht
# 1D transform (in-place)
x = np.random.randn(1024).astype(np.float32)
fht(x)
# Allocating mode (returns new array, original unchanged)
y = fht(x, inplace=False)
# Preallocated output
out = np.empty_like(x)
fht(x, out=out)
# 2D — each row transformed in parallel via OpenMP
X = np.random.randn(1000, 2**16).astype(np.float32)
fht(X, axis=-1)
# Complex arrays (decomposes into real/imag, transforms separately)
z = np.random.randn(512).astype(np.complex128)
fht(z)
Supported dtypes: float32, float64, complex64, complex128.
The transform axis must have a power-of-2 length. For 2D arrays, rows (or columns) are processed in parallel with OpenMP — set thread count via OMP_NUM_THREADS=N.
C/C++ Usage
Header-only. Just include and compile:
#include <fht/fht.h>
float buf[1024];
fht_float(buf, 10); // log2(1024) = 10
C API
int fht_float(float *buf, int log_n);
int fht_double(double *buf, int log_n);
int fht_float_oop(float *in, float *out, int log_n);
int fht_double_oop(double *in, double *out, int log_n);
Returns 0 on success, 1 on invalid log_n (valid range: 0-30).
CMake Integration
# Via CPM (recommended)
CPMAddPackage("gh:grigori-hpnalgs-lab/fht@1.0.0")
target_link_libraries(myapp PRIVATE fht::fht)
# Or as subdirectory
add_subdirectory(fht)
target_link_libraries(myapp PRIVATE fht::fht)
Compile with -mavx on x86 for best performance.
Platform Support
| Platform | Float | Double |
|---|---|---|
| x86_64 + AVX | yes | yes |
| x86_64 + SSE | yes | yes |
| ARM64 (NEON) | yes | yes |
Re-optimizing the code for your CPU
cmake -B build -DFHT_OPTIMIZE_FOR_HOST=ON
cmake --build build
Limitations
Known issues:
-
inplace=False/out=does copy + in-place — we will add an out of place version soon, it just requires some changes to the codegen files. - Complex number support is not optimal — we will provide separate kernels for complex, currently we deinterleave into real and imaginary parts, apply the transform and then recombine.
Acknowledgments
The x86 AVX/SSE implementation is based on FFHT from the FALCONN project by Alexandr Andoni, Piotr Indyk, Thijs Laarhoven, Ilya Razenshteyn, and Ludwig Schmidt. The original code was copied and integrated with minor modifications.
The ARM NEON implementation was written from scratch with auto-tuned code generation.
License
See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fht_cpu-1.0.0.tar.gz.
File metadata
- Download URL: fht_cpu-1.0.0.tar.gz
- Upload date:
- Size: 170.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1d7baf50aedb0f06fcfda2114d34389e60049ac2a3b163667a16c7e42d13264
|
|
| MD5 |
275233e86be22a82bd46386ced21e848
|
|
| BLAKE2b-256 |
5c50478e82e61c1afe596b765e05734ec63a7fd6728ad6c2c04d6832cbeb6ed5
|
File details
Details for the file fht_cpu-1.0.0-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: fht_cpu-1.0.0-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 175.8 kB
- Tags: CPython 3.14, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19812d58da19565631fc894763da80d5573ddc0349ad8a53f6467c9e2dd3cba1
|
|
| MD5 |
891036a43f2b64111169366fcb7fe753
|
|
| BLAKE2b-256 |
1c44b97d0e85b1f4368c50baeecdff9461e0aeb61aab701f950211f0d24825bf
|
File details
Details for the file fht_cpu-1.0.0-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: fht_cpu-1.0.0-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 177.4 kB
- Tags: CPython 3.14, manylinux: glibc 2.24+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
398751352ceaef586c7c389defde62f9c43e7674e03cfb14c638542ff1da5b74
|
|
| MD5 |
6496d207312fb49bf38e1ed47447f03f
|
|
| BLAKE2b-256 |
3d2ba040c78e82de2e411f652f1314e3b2328b216e757db796dbf78e7b7118d6
|
File details
Details for the file fht_cpu-1.0.0-cp314-cp314-macosx_14_0_arm64.whl.
File metadata
- Download URL: fht_cpu-1.0.0-cp314-cp314-macosx_14_0_arm64.whl
- Upload date:
- Size: 58.5 kB
- Tags: CPython 3.14, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27ed0590d4fd0d2386d28fb55d084fb285c9e6bd8a5b82dec5560ea639e7ae67
|
|
| MD5 |
b5bf5ead1e55df35ed814dc99269b2ba
|
|
| BLAKE2b-256 |
f8224afcc1af67bb58ed61a1f2ef59ed8ebdd79cc5f32335cc46605ffc1f8b90
|
File details
Details for the file fht_cpu-1.0.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: fht_cpu-1.0.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 175.7 kB
- Tags: CPython 3.13, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3260d37bd6e2e180603cf30a120a632589364666f302b78bcceecf72506d8c81
|
|
| MD5 |
4351a6cf3194428633ae0e5d6ff40164
|
|
| BLAKE2b-256 |
94749c53ccfc3c1be5e2d78348bfcae683006ba3115c2607433386ec07df1c30
|
File details
Details for the file fht_cpu-1.0.0-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: fht_cpu-1.0.0-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 177.2 kB
- Tags: CPython 3.13, manylinux: glibc 2.24+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6569340a542288f64a0d211a17ca601755676dba8cde4030f92235059dfd5a9c
|
|
| MD5 |
38a3d84384aab75bf76f273308643abf
|
|
| BLAKE2b-256 |
f92668f70e06708ef9d78751c0936dd9254eb6d6d7dd64a30a444076c0028605
|
File details
Details for the file fht_cpu-1.0.0-cp313-cp313-macosx_14_0_arm64.whl.
File metadata
- Download URL: fht_cpu-1.0.0-cp313-cp313-macosx_14_0_arm64.whl
- Upload date:
- Size: 58.2 kB
- Tags: CPython 3.13, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c818f88a6250cd82a6b526b96081d4a04ab5d01e69dacf049a3bad3cdefe7b0f
|
|
| MD5 |
c6690f4d230cbcbca70b737a66a0a07b
|
|
| BLAKE2b-256 |
c4c4d7daa199e9e32c6b2ecbe8aaa77fd615ad3fa92924a6f87fa854350bcff5
|
File details
Details for the file fht_cpu-1.0.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: fht_cpu-1.0.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 175.7 kB
- Tags: CPython 3.12, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c047e39281d4106f4981870ec96f6761040f971f467e4d168e146f2cdd77fbdc
|
|
| MD5 |
0e15e3a54e24f467bad092ebf1cfedf8
|
|
| BLAKE2b-256 |
4b0878f4b0611c0e1837555b621d56fee05135e5bb2289748e235473b3fa2082
|
File details
Details for the file fht_cpu-1.0.0-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: fht_cpu-1.0.0-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 177.3 kB
- Tags: CPython 3.12, manylinux: glibc 2.24+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83e95ab07459c2ded2dc44964ab7ae9ca2d0af5583fdf852e99b7625aabdad0f
|
|
| MD5 |
29f46c1769199750f50867a588e398ff
|
|
| BLAKE2b-256 |
0b4684f9f5c80316ce0ab7066bb7b46b3590ffb464d655a39c7c3db3b08a1d3e
|
File details
Details for the file fht_cpu-1.0.0-cp312-cp312-macosx_14_0_arm64.whl.
File metadata
- Download URL: fht_cpu-1.0.0-cp312-cp312-macosx_14_0_arm64.whl
- Upload date:
- Size: 58.2 kB
- Tags: CPython 3.12, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78fdeaeab579810fc6a7066ea89c8a1563233fc3346b949f762dbc4d6cfa5d7c
|
|
| MD5 |
769a7dc9f24824b4a24defcff24b23a8
|
|
| BLAKE2b-256 |
2d1a71331c41bfa9b74817edc6da4cdf5ea3b67af6b08445483b41b77e1ba7e0
|
File details
Details for the file fht_cpu-1.0.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: fht_cpu-1.0.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 176.0 kB
- Tags: CPython 3.11, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7028dcdf4cbe6e3159c911aa0c4cb372e83f24d5ed70247a1f0ca549e6bd42a3
|
|
| MD5 |
cd590882512a82659203f2d210ada786
|
|
| BLAKE2b-256 |
5284a9c97024e2ad18fad84c2a1ca7022d1d4347e4f278a78904383df6fa45a5
|
File details
Details for the file fht_cpu-1.0.0-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: fht_cpu-1.0.0-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 177.8 kB
- Tags: CPython 3.11, manylinux: glibc 2.24+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f01aea73566a677f9f09673199297184457766a8e13f1ca6b9d627545d2724d
|
|
| MD5 |
3ad4154786f6c7e97416259fe3d0a88b
|
|
| BLAKE2b-256 |
6523ade80484916d96e9b1d082523ace0ea093a295922665d561e025357fed63
|
File details
Details for the file fht_cpu-1.0.0-cp311-cp311-macosx_14_0_arm64.whl.
File metadata
- Download URL: fht_cpu-1.0.0-cp311-cp311-macosx_14_0_arm64.whl
- Upload date:
- Size: 58.8 kB
- Tags: CPython 3.11, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65a4b156d11a7df6c0e5fadb92f67f60a3ccee76ed7ec6ebf2f66aeadad25167
|
|
| MD5 |
40e7970f99e35c3f83fc7d778f997829
|
|
| BLAKE2b-256 |
6862b09407f1a0d221fd9e581d02f9e7d874b694fb50a6f439c560a4b0a69ec1
|
File details
Details for the file fht_cpu-1.0.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: fht_cpu-1.0.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 176.2 kB
- Tags: CPython 3.10, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07b7cf9c3f15e1731f214275d35ba9a0ba1d0180f3479ab5806199b4963d6e3b
|
|
| MD5 |
65c9d3675abb561a9b096c985abed7fc
|
|
| BLAKE2b-256 |
2b5be5e7f2c4595ac7790da399f9510535b8a2caab60af6978def8ec7dbf58d2
|
File details
Details for the file fht_cpu-1.0.0-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: fht_cpu-1.0.0-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 178.0 kB
- Tags: CPython 3.10, manylinux: glibc 2.24+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e881a2d0f616059d26089d575bf27cd3326c6caaec27110cfc1f26ba68e23fe
|
|
| MD5 |
2c48e1442346e7541a85f25d5a0dbf08
|
|
| BLAKE2b-256 |
cb4b0aa67fe83eb2223cd0eb5ad33762bd491abc7997cad6f7a5dc4ed2a1150b
|
File details
Details for the file fht_cpu-1.0.0-cp310-cp310-macosx_14_0_arm64.whl.
File metadata
- Download URL: fht_cpu-1.0.0-cp310-cp310-macosx_14_0_arm64.whl
- Upload date:
- Size: 58.9 kB
- Tags: CPython 3.10, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99042da7d26bcc889a77fbeae874a37c5b635347690ec396b039e382c1f7fd7f
|
|
| MD5 |
fc47cb3336c0f76b0b917d2e9d2bcc8e
|
|
| BLAKE2b-256 |
ee6664daaa05f3e348240f81451df70c19e83f7db30fb7a513013338f6fd90e7
|