Vectorised kernels
Native backends for AVX2, AVX-512 and Apple silicon NEON.
Dense linear algebra and solver pipelines on CPU and CUDA, with a compact NumPy-first interface.
[01] OVERVIEW
Hyperfold is a modern high-performance computing library for dense and structured linear algebra. Its Python API works directly with the arrays you already use.
Native backends for AVX2, AVX-512 and Apple silicon NEON.
Accelerator-aware kernels and explicit device placement.
NumPy, CuPy and PyTorch arrays in; the same framework out.
02 / INSTALLATION
Python 3.11–3.14 · NumPy 1.26+
Hyperfold is not on PyPI yet. The command below is a placeholder for the forthcoming CPU package and will not install today.
The CPU and CUDA distributions use the same hyperfold import and are mutually exclusive.
03 / QUICKSTART
Existing arrays retain their dtype. Hyperfold supports float32 where registered and uses complex64 across the complete numerical API.
import numpy as np
import hyperfold
a = np.array([[1, 2], [3, 4]], dtype=np.float32)
b = np.array([[5, 6], [7, 8]], dtype=np.float32)
system = np.array([[4, 1-1j], [1+1j, 3]], dtype=np.complex64)
rhs = np.array([1+2j, 3-1j], dtype=np.complex64)
product = hyperfold.matmul(a, b)
solution = hyperfold.solve(system, rhs)
REUSE WORK
Reusable factorisations keep subsequent solve operations on the factor object.
factor = hyperfold.lu_factor(system)
first = factor.solve(rhs)
second = factor.solve(2 * rhs)
04 / GPU ARRAYS
CuPy and PyTorch use the same functions and preserve their framework through zero-copy DLPack interchange when arrays are contiguous and on one CUDA device.
import cupy as cp
import torch
import hyperfold
x_cp = cp.arange(8, dtype=cp.float32)
y_cp = hyperfold.add(x_cp, x_cp)
x_pt = torch.arange(8, dtype=torch.float32, device="cuda")
y_pt = hyperfold.scale(x_pt, 2.0)
Cross-device operands and hidden host/device copies are rejected.
CuPy arrays return CuPy arrays; PyTorch tensors return PyTorch tensors.
05 / CONTEXTS
Contexts make thread counts, scheduling and device scope explicit without changing numerical code.
cpu = hyperfold.Context(
cpu_threads=8,
parallel_work_threshold=65536,
numa_policy="auto",
pinning_policy="auto",
)
y = hyperfold.matmul(a, a, context=cpu)
gpu = hyperfold.Context(
cuda_devices=0,
stream_pool_size=32,
scheduling="auto",
cross_device="reject",
)
06 / API REFERENCE
The availability shown below reflects the currently registered CPU and CUDA backends.
| Group | Operations | Dtypes | Backends |
|---|---|---|---|
| Element-wise | add subtract multiply scale sum | float32, complex64 | CPU CUDA |
| Vector | inner norm vector_equal | complex64 | CPU CUDA |
| Matrix | matmul eye matrix_power is_unitary | float32*, complex64 | CPU CUDA |
| Solvers | solve lu_factor eigensolvers | complex64 | CPU CUDA |
| Quantum | partial_trace | complex64 | CPU CUDA |
* matmul supports float32 and complex64. Other matrix operations currently require complex64.