hyperfold

Dense linear algebra and solver pipelines on CPU and CUDA, with a compact NumPy-first interface.

[01] OVERVIEW

Native speed.
Familiar arrays.

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.

CPU

Vectorised kernels

Native backends for AVX2, AVX-512 and Apple silicon NEON.

GPU

CUDA execution

Accelerator-aware kernels and explicit device placement.

API

Framework preserving

NumPy, CuPy and PyTorch arrays in; the same framework out.

02 / INSTALLATION

Install Hyperfold

Python 3.11–3.14 · NumPy 1.26+

Package publishing in progress
Preview command

Hyperfold is not on PyPI yet. The command below is a placeholder for the forthcoming CPU package and will not install today.

CPUmacOS arm64 · Linux x86_64
python -m pip install hyperfold  # placeholder
CUDALinux x86_64 · CUDA 12
python -m pip install hyperfold-cuda  # placeholder

The CPU and CUDA distributions use the same hyperfold import and are mutually exclusive.

03 / QUICKSTART

Multiply and solve

Existing arrays retain their dtype. Hyperfold supports float32 where registered and uses complex64 across the complete numerical API.

NumPyquickstart.py
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

Factor once. Solve many times.

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

Stay in your framework

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.

CUDACuPy + PyTorch
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)
No implicit transfers

Cross-device operands and hidden host/device copies are rejected.

No framework switch

CuPy arrays return CuPy arrays; PyTorch tensors return PyTorch tensors.

05 / CONTEXTS

Control execution

Contexts make thread counts, scheduling and device scope explicit without changing numerical code.

ConfigurationCPU + CUDA
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

Core operations

The availability shown below reflects the currently registered CPU and CUDA backends.

GroupOperationsDtypesBackends
Element-wiseadd subtract multiply scale sumfloat32, complex64CPU CUDA
Vectorinner norm vector_equalcomplex64CPU CUDA
Matrixmatmul eye matrix_power is_unitaryfloat32*, complex64CPU CUDA
Solverssolve lu_factor eigensolverscomplex64CPU CUDA
Quantumpartial_tracecomplex64CPU CUDA

* matmul supports float32 and complex64. Other matrix operations currently require complex64.