Skip to content

isaaccorley/torchid

Repository files navigation

torchid — intrinsic dimension estimation

GPU-accelerated intrinsic dimension estimators in PyTorch. A port of scikit-dimension with batched/vectorized implementations and CUDA support.

Why

scikit-dimension is the reference library for intrinsic dimension (ID) estimation but is CPU-only and relies heavily on per-point Python loops. torchid re-implements every estimator using batched torch ops so the same methods run 100–2700× faster on GPU (measured on an NVIDIA H100, see BENCHMARKS.md) while producing outputs that match the reference library within documented tolerances.

Install

pip install "torchid[cpu]"   # CPU-only (faiss-cpu)
pip install "torchid[cuda]"  # GPU-enabled (faiss-cuda-cu128, manylinux_2_28+)

For a CUDA-capable install, also pick the PyTorch wheel that matches your driver, e.g.:

pip install torch --index-url https://download.pytorch.org/whl/cu128
pip install "torchid[cuda]"

For running parity tests against scikit-dimension from a clone:

uv sync --group validation

Usage

import torch
from torchid.estimators import lPCA

X = torch.randn(10_000, 50, device="cuda")
est = lPCA().fit(X)
print(est.dimension_)

About

GPU-accelerated intrinsic dimension estimation with PyTorch

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors