HyperLearn was a promising but dormant project. It's now being actively revived and modernized.
- JAX backend - XLA-compiled operations for CPU/GPU/TPU portability
- Modernized build system using uv and
pyproject.toml - Updated to Python 3.10+ with modern dependencies
- Removed legacy Cython and Numba in favor of pure JAX
- Added comprehensive pytest test suite
- Core linear algebra:
matmul,svd,qr,cholesky,lstsq,pinv, and more
This project needs contributors! Areas where help is wanted:
- Algorithms: Porting optimized implementations from the original codebase
- Testing: Expanding test coverage and benchmarks
- Documentation: API docs, tutorials, examples
- Benchmarks: Performance comparisons vs NumPy/SciPy/sklearn
If you're interested in fast numerical computing and want to help revive this project, please open an issue or submit a PR!
# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone and install
git clone https://github.com/danielhanchen/hyperlearn.git
cd hyperlearn
uv syncpip install hyperlearnuv sync --extra cuda
# or
pip install hyperlearn[cuda]uv sync --extra torch
# or
pip install hyperlearn[torch]import numpy as np
from hyperlearn.linalg import matmul, svd, lstsq, qr
# Create some matrices (float32 for best performance)
A = np.random.randn(1000, 500).astype(np.float32)
B = np.random.randn(500, 800).astype(np.float32)
# Fast matrix multiplication (JIT-compiled via XLA)
C = matmul(A, B)
# SVD decomposition
U, s, Vt = svd(A)
# Least squares solution
b = np.random.randn(1000).astype(np.float32)
x = lstsq(A, b)
# QR decomposition
Q, R = qr(A)Matrix Multiplication:
matmul(A, B)- Standard matrix multiplymatmul_T(A, B)- Compute A @ B.T efficientlygram(A)- Compute A.T @ A or A @ A.Tbatch_matmul(A, B)- Batched matrix multiply
Linear Systems:
solve(A, b)- Solve Ax = blstsq(A, b)- Least squares solutionpinv(A)- Moore-Penrose pseudo-inversesolve_triangular(A, b)- Solve triangular system
Decompositions:
svd(A)- Singular value decompositiontruncated_svd(A, k)- Randomized truncated SVDqr(A)- QR decompositioncholesky(A)- Cholesky decompositioneigh(A)- Eigendecomposition (symmetric)lu(A)- LU decomposition
HyperLearn aims to be a drop-in replacement for Scikit-Learn, designed for speed and memory efficiency:
- 70% faster Least Squares / Linear Regression + 50% less memory
- 50% faster Non-Negative Matrix Factorization with parallelized algorithms
- 40% faster Euclidean / Cosine distance computations
- 50% faster LSMR iterative least squares
- 20-30% faster RandomizedSVD
- Parallelized sparse matrix operations
Built with: JAX (XLA compiler), NumPy, Pandas, SciPy.
- XLA Backend: Automatically optimized linear algebra kernels
- GPU/TPU Portable: Same code runs on CPU, GPU, or TPU
- Lightweight: ~80MB vs 185MB for Numba+LLVM
- JIT Compilation: First call compiles, subsequent calls are fast
- Auto-vectorization:
vmapfor batch operations
# Clone the repository
git clone https://github.com/danielhanchen/hyperlearn.git
cd hyperlearn
# Install with dev dependencies
uv sync --extra dev
# Run tests
uv run pytest
# Run tests with coverage
uv run pytest --cov=hyperlearn- Python 3.10+
- NumPy >= 1.24.0
- SciPy >= 1.10.0
- Scikit-learn >= 1.2.0
- Pandas >= 2.0.0
- JAX >= 0.4.20
- jaxlib >= 0.4.20
Optional:
jax[cuda12]for GPU support- PyTorch >= 2.0.0
- Torchvision >= 0.15.0
HyperLearn's algorithms have been featured in research from:
- Microsoft: Yu et al. Making Classical Machine Learning Pipelines Differentiable
- UC Berkeley: Rokem & Kay. Fractional ridge regression: a fast, interpretable reparameterization
- NVIDIA: Raschka et al. RAPIDS: Machine Learning in Python
- University of Washington: GPU Accelerated T-SNE
HyperLearn methods have been incorporated into:
- Facebook's PyTorch
- SciPy
- CuPy
- NVIDIA RAPIDS
This project is being revived and contributions are very welcome!
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
uv run pytest) - Commit (
git commit -m 'Add amazing feature') - Push (
git push origin feature/amazing-feature) - Open a Pull Request
Apache 2.0 License. See LICENSE for details.
