Skip to content

Sekinal/hyperlearn

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

267 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HyperLearn Logo

2-2000x faster algorithms, 50% less memory usage, works on all hardware.

Python 3.10+ License Status: Revival in Progress


Project Status: Revival in Progress

HyperLearn was a promising but dormant project. It's now being actively revived and modernized.

What's New (v0.2.0)

  • 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

What's Needed

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!


Installation

Using uv (Recommended)

# 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 sync

Using pip

pip install hyperlearn

With GPU support (CUDA 12)

uv sync --extra cuda
# or
pip install hyperlearn[cuda]

With PyTorch support

uv sync --extra torch
# or
pip install hyperlearn[torch]

Quick Start

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)

Available Functions

Matrix Multiplication:

  • matmul(A, B) - Standard matrix multiply
  • matmul_T(A, B) - Compute A @ B.T efficiently
  • gram(A) - Compute A.T @ A or A @ A.T
  • batch_matmul(A, B) - Batched matrix multiply

Linear Systems:

  • solve(A, b) - Solve Ax = b
  • lstsq(A, b) - Least squares solution
  • pinv(A) - Moore-Penrose pseudo-inverse
  • solve_triangular(A, b) - Solve triangular system

Decompositions:

  • svd(A) - Singular value decomposition
  • truncated_svd(A, k) - Randomized truncated SVD
  • qr(A) - QR decomposition
  • cholesky(A) - Cholesky decomposition
  • eigh(A) - Eigendecomposition (symmetric)
  • lu(A) - LU decomposition

Vision

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.

Why JAX?

  • 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: vmap for batch operations

Development

# 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

Requirements

  • 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

History & Recognition

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

Contributing

This project is being revived and contributions are very welcome!

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests (uv run pytest)
  5. Commit (git commit -m 'Add amazing feature')
  6. Push (git push origin feature/amazing-feature)
  7. Open a Pull Request

License

Apache 2.0 License. See LICENSE for details.

About

2-2000x faster ML algos, 50% less memory usage, works on all hardware - new and old.

Resources

License

Code of conduct

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%