fastumap¶
A UMAP and clustering library for environments where a JIT compiler at import time is not acceptable: serverless functions, small or CPU-limited containers, and autoscaled workers that pay a cold start on every new process.
umap-learn compiles its kernels with numba and LLVM the first time the package is imported. That costs seconds on a workstation and minutes on a CPU-throttled container, and it recurs on every cold start rather than once per machine. NumPy and SciPy are equally compiled code, but they ship their machine code prebuilt in the wheel, so they load immediately. fastumap reimplements the UMAP algorithm on top of them, with precompiled Rust kernels (also shipped in the wheel) for the parts that need to be fast. Nothing is left to compile at import.
| cold import | added to image | |
|---|---|---|
import umap (umap-learn) |
~21 s | ~172 MB |
import fastumap |
~12 ms | 0 MB |
Projection quality stays within 0.01 neighbour overlap of umap-learn; the measurements are below.
Install¶
pip install fastumap # one wheel, native kernels included
pip install fastumap[ann] # adds an approximate kNN backend for large inputs (see below)
Where to go next¶
- Projection:
umap_project, metrics, supervised layouts, densMAP. - Clustering: k-means, spectral, DBSCAN and HDBSCAN, with no layout step.
- In a server: fit once, place new points per request, persist the model.
- Speed and quality: the per-call trade-off, with measurements.
- Guarantees: what is enforced by a test, and what changes output.
- API: every public function, generated from the source.
fastumap is an independent reimplementation of the UMAP algorithm (McInnes, Healy & Melville, arXiv:1802.03426). It is not affiliated with or endorsed by the UMAP authors, and it is not a drop-in replacement; the public API is deliberately small. MIT licensed.