Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fht_cpu-1.0.1.tar.gz (170.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fht_cpu-1.0.1-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (175.8 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

fht_cpu-1.0.1-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (177.4 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

fht_cpu-1.0.1-cp314-cp314-macosx_14_0_arm64.whl (58.5 kB view details)

Uploaded CPython 3.14macOS 14.0+ ARM64

fht_cpu-1.0.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (175.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

fht_cpu-1.0.1-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (177.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

fht_cpu-1.0.1-cp313-cp313-macosx_14_0_arm64.whl (58.2 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

fht_cpu-1.0.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (175.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

fht_cpu-1.0.1-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (177.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

fht_cpu-1.0.1-cp312-cp312-macosx_14_0_arm64.whl (58.2 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

fht_cpu-1.0.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (176.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

fht_cpu-1.0.1-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (177.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

fht_cpu-1.0.1-cp311-cp311-macosx_14_0_arm64.whl (58.8 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

fht_cpu-1.0.1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (176.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

fht_cpu-1.0.1-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (178.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

fht_cpu-1.0.1-cp310-cp310-macosx_14_0_arm64.whl (58.9 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

Details for the file fht_cpu-1.0.1.tar.gz.

File metadata

  • Download URL: fht_cpu-1.0.1.tar.gz
  • Upload date:
  • Size: 170.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fht_cpu-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e94c8803609efbdf1e0f58d5774bcbedc8727b4194b1fd6750a2b68b1d40142f
MD5 34046909d768a0526753243e8bb9cc29
BLAKE2b-256 2bb1b1670f80062cfab90609fad47c634052f849cb443995ebbce6f0d33c2616

See more details on using hashes here.

Provenance

The following attestation bundles were made for fht_cpu-1.0.1.tar.gz:

Publisher: wheels.yml on grigori-hpnalgs-lab/fht

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fht_cpu-1.0.1-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fht_cpu-1.0.1-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fdf83359586ca5e23d49ac362b9edaf090f6bb7c0e779f7f795779c27c569af2
MD5 c5fce1585239c15dc3d5d1378a57cc41
BLAKE2b-256 d8748066c14ef2b0dbee4b4ef5475017872dd354d20e10b522062dbc350e1aed

See more details on using hashes here.

Provenance

The following attestation bundles were made for fht_cpu-1.0.1-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on grigori-hpnalgs-lab/fht

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fht_cpu-1.0.1-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for fht_cpu-1.0.1-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 45cc5dab1f435971958019c06452fbf138ce3b771c3b1a78b904c8b3be532f39
MD5 25e011b1f3698fc904ba8fab99eef58f
BLAKE2b-256 3c906c34b5ded3c49e7b5a4dbf00a283ae807da593d307a2ebef5cee6fa02623

See more details on using hashes here.

Provenance

The following attestation bundles were made for fht_cpu-1.0.1-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl:

Publisher: wheels.yml on grigori-hpnalgs-lab/fht

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fht_cpu-1.0.1-cp314-cp314-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for fht_cpu-1.0.1-cp314-cp314-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 06535e623c1367b922bee8dc0e8b08458f04e41f680b168a9b41c2a095de65f6
MD5 63773a7f838758214b3dc7dd1a65e620
BLAKE2b-256 ffb5d64a2bc720ebbde0d0ca8679c0221ae40063d3daa60d5ab1ed2bf0ce04f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for fht_cpu-1.0.1-cp314-cp314-macosx_14_0_arm64.whl:

Publisher: wheels.yml on grigori-hpnalgs-lab/fht

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fht_cpu-1.0.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fht_cpu-1.0.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 239e2b563229f75e0e179bd4cd3b4bf4e1afcb383c4b8522062977f8a9cddb84
MD5 a43663b49796af88270ef685834d2d11
BLAKE2b-256 efb4b01dcecddeb7f63731c964d43593168bf1891e2083f4ec889d5f1648e831

See more details on using hashes here.

Provenance

The following attestation bundles were made for fht_cpu-1.0.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on grigori-hpnalgs-lab/fht

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fht_cpu-1.0.1-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for fht_cpu-1.0.1-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 393ee246f848cd26f11aea9cebb433d5ef1bc8885cde5525d4c2a20b6cf8a3b0
MD5 bb0fb121b8b465c40bc59b11437196d1
BLAKE2b-256 d709b55db8447e5ea6fb8c840873062a9f651ece146cbf6e5dcc32648f403a3c

See more details on using hashes here.

Provenance

The following attestation bundles were made for fht_cpu-1.0.1-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl:

Publisher: wheels.yml on grigori-hpnalgs-lab/fht

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fht_cpu-1.0.1-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for fht_cpu-1.0.1-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 b45f087beb9863df980e41460d15e8277de1f6033c932dd87a9b4795af8aff6f
MD5 f1db2b09a815ada67e3f323a995d6e53
BLAKE2b-256 6e6e1b9954fb77d9ab720fa0a5330e2431dce382f32c6371eb1dea26f37af328

See more details on using hashes here.

Provenance

The following attestation bundles were made for fht_cpu-1.0.1-cp313-cp313-macosx_14_0_arm64.whl:

Publisher: wheels.yml on grigori-hpnalgs-lab/fht

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fht_cpu-1.0.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fht_cpu-1.0.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 570d743d3a27be6921d99cdcd2bbddf0924acb56dd942308b47ac6bdcb283405
MD5 cb4575e78ac236a211c54d8e94896eb5
BLAKE2b-256 600f9b1ac92f634893222f0e9be4b1a866f20527ffe157c7e1ea3509eb64bcdc

See more details on using hashes here.

Provenance

The following attestation bundles were made for fht_cpu-1.0.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on grigori-hpnalgs-lab/fht

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fht_cpu-1.0.1-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for fht_cpu-1.0.1-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8dec865e5277d18cdab6a2d65843321cfedf7b87b6284c54ffa3bff33ea16e3c
MD5 14c1bc627f1d032f34c58fbf3d158b1e
BLAKE2b-256 0d4492703fb13a65431fd04a659e55f382840aba1a16da2ced4e56e0509d7174

See more details on using hashes here.

Provenance

The following attestation bundles were made for fht_cpu-1.0.1-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl:

Publisher: wheels.yml on grigori-hpnalgs-lab/fht

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fht_cpu-1.0.1-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for fht_cpu-1.0.1-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 371f205d483c3fc65df115b3b4d076b94ef9a3dc30ce997e8c5d5845cf08850f
MD5 9e27cbcc596e12ade0f26b321fb49392
BLAKE2b-256 9d4bcc1a1f81a7d6cb1094f2957e9e11cafc1899e3ff1f20cd82d942de14440f

See more details on using hashes here.

Provenance

The following attestation bundles were made for fht_cpu-1.0.1-cp312-cp312-macosx_14_0_arm64.whl:

Publisher: wheels.yml on grigori-hpnalgs-lab/fht

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fht_cpu-1.0.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fht_cpu-1.0.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 00571078a80c2b5fe2c1f97a24555039ed796f6b65db82c8b375e480313de560
MD5 a6024148b2fb10e6ef39508aa5d0e32e
BLAKE2b-256 ef33094e8af197b69a8d2f7a52afdda06b39327a4f6c0cc34d15a6eccbe10832

See more details on using hashes here.

Provenance

The following attestation bundles were made for fht_cpu-1.0.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on grigori-hpnalgs-lab/fht

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fht_cpu-1.0.1-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for fht_cpu-1.0.1-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f2cbfa03b8f117e7a82e64b791400f8a6d32aeb69fe812da84980ca9468468a7
MD5 00a1a705eeb645b5da2b0f90fdf6b70a
BLAKE2b-256 d478915df3ca5a1ab06c9d02ecba66c8a574367c6c3328a0720a2c0b66aa8299

See more details on using hashes here.

Provenance

The following attestation bundles were made for fht_cpu-1.0.1-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl:

Publisher: wheels.yml on grigori-hpnalgs-lab/fht

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fht_cpu-1.0.1-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for fht_cpu-1.0.1-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 37e8757d4dbcce14bf80b10bd6eb461e5ae059a13c12929364f0aa7d4649a056
MD5 735ea1c9090ab55d6b4b19396afc0b79
BLAKE2b-256 1b0e762b3e4d17cc340ef9b8f78c911010a60529296b0c3f6c13b0b3f6195f7c

See more details on using hashes here.

Provenance

The following attestation bundles were made for fht_cpu-1.0.1-cp311-cp311-macosx_14_0_arm64.whl:

Publisher: wheels.yml on grigori-hpnalgs-lab/fht

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fht_cpu-1.0.1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fht_cpu-1.0.1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7bb46b19f391849812ee5fad0c8c66400538275b72c0860bde53f9f0870000d3
MD5 5178e8adde4f73ac64f1ad7febf50a62
BLAKE2b-256 c74319287650458a96fc8d5f7c42f4b6848f3a74934e8e2ba31dc58de8fe5ef1

See more details on using hashes here.

Provenance

The following attestation bundles were made for fht_cpu-1.0.1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on grigori-hpnalgs-lab/fht

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fht_cpu-1.0.1-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for fht_cpu-1.0.1-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bad6bdfe3f2a6bbf9f6d00d7b33dc7b6f5c4adde0bb5754a4097a98f9b27e3cf
MD5 3cfbeed1fd90469d3d111f29d6472b52
BLAKE2b-256 12009713a95ce7ff83aef1bb9a46c0fb6c202c70363db5d02bc5e65f3585fe0c

See more details on using hashes here.

Provenance

The following attestation bundles were made for fht_cpu-1.0.1-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl:

Publisher: wheels.yml on grigori-hpnalgs-lab/fht

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fht_cpu-1.0.1-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for fht_cpu-1.0.1-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 2f2ff2dadb226429d6fbba749f88c7327c6948979093258e3e5859a811b107a3
MD5 cbd51882569f3587ae5963ab69d1a3e3
BLAKE2b-256 d4e494d582554637fc96219e57f7ae52f87477fad8f348aaba836bdeec809702

See more details on using hashes here.

Provenance

The following attestation bundles were made for fht_cpu-1.0.1-cp310-cp310-macosx_14_0_arm64.whl:

Publisher: wheels.yml on grigori-hpnalgs-lab/fht

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