hyperfold

Dense and structured linear algebra on CPU and CUDA, with a flat Python API for NumPy, CuPy and PyTorch arrays.

OVERVIEW

Native speed.
Familiar arrays.

Hyperfold is a C++23 high-performance computing library for dense and structured linear algebra. Its Python API supports NumPy host arrays and CUDA arrays from CuPy and PyTorch, with explicit dtype, device and output ownership.

CPU

Native CPU execution

x86_64 wheels support runtime selection between AVX2 and AVX-512. Linux ARM64 uses NEON; Apple Silicon uses NEON and Accelerate.

GPU

CUDA 13 execution

The CUDA distribution combines CPU and CUDA backends with explicit device placement. Install Linux x86_64 wheels or build locally for Windows AMD64.

ARRAYS

Framework preserving

Results stay in NumPy, CuPy or PyTorch and remain on the originating device.

INSTALLATION

Install Hyperfold

CPython 3.11–3.14 · NumPy 1.26+ · ml_dtypes 0.5.3+

0.1.1 available on PyPI
Choose CPU or CUDA

Install hyperfold or hyperfold-cuda from PyPI for CPU execution on Linux, Windows and Apple Silicon, or CPU + CUDA on Linux x86_64. Windows CUDA is available through a local source build. This reference covers Hyperfold 0.1.1.

CPULinux · Windows · macOS arm64
python -m pip install hyperfold
CUDALinux x86_64 · CUDA 13
python -m pip install hyperfold-cuda

The CPU and CUDA distributions use the same hyperfold import and are mutually exclusive. See the full platform matrix and Windows CUDA build instructions.

API REFERENCE

Core operations

All 32 built-in operations support float16, bfloat16, float32, float64, complex32, complex64 and complex128 on CPU and CUDA.

Group Operations Dtypes Backends
Vector arithmetic All supported floating dtypes AVX2 · AVX-512 · ARM NEON · Apple Silicon CUDA
Reductions / matmul All supported floating dtypes AVX2 · AVX-512 · ARM NEON · Apple Silicon CUDA
Vector transforms All supported floating dtypes AVX2 · AVX-512 · ARM NEON · Apple Silicon CUDA
Matrix operations All supported floating dtypes AVX2 · AVX-512 · ARM NEON · Apple Silicon CUDA
Solvers / quantum All supported floating dtypes AVX2 · AVX-512 · ARM NEON · Apple Silicon CUDA

Precision rules

Input storage Compute, reductions and solve Ordinary array results General eig / LU logdet results
float16, bfloat16 float32 Input dtype complex64
float32 float32 float32 complex64
float64 float64 float64 complex128
complex32 complex64 complex32 complex64
complex64 complex64 complex64 complex64
complex128 complex128 complex128 complex128

Low-precision LU factors, solve results and structured-solver arrays use compute precision. Norms and Hermitian eigenvalues use the real component dtype; predicates return booleans. Inputs to multi-array operations must have matching dtypes.

NumPy bfloat16 support is supplied by the required ml_dtypes>=0.5.3 dependency; CUDA dtype availability also depends on the installed framework.

Select an operation for its full signature, shapes, output, examples and errors.

EXTENSIBLE BY DESIGN

Bring your own kernels

Hyperfold can load externally compiled CPU and CUDA kernels through its development C ABI, with explicit stream and device handling from Python.

Read the compiled-kernel documentation