gitmyhub

flashlib

Python ★ 543 updated 7d ago

Fast and memory-efficient classical machine learning operators

FlashLib is a Python library offering GPU-accelerated classical machine learning operations like clustering, dimensionality reduction, and regression with a scikit-learn-style API.

PythonTritonCuteDSLscikit-learnsetup: moderatecomplexity 4/5

FlashLib is a Python library that provides GPU-accelerated implementations of classical machine learning operations. It targets researchers and engineers who need standard algorithms to run faster on graphics hardware without switching to deep learning frameworks.

The library ships 15 high-level operations across clustering, dimensionality reduction, nearest-neighbor search, regression, and classification. Clustering includes k-means, DBSCAN, HDBSCAN, and spectral clustering. Dimensionality reduction covers PCA, truncated SVD, UMAP, and t-SNE. Regression covers linear, ridge, and logistic variants. Classification includes a multinomial naive Bayes and a random forest. A standard scaler is included for preprocessing. Each operation is available both as a top-level function with a flash_ prefix and as a scikit-learn-style class.

The underlying implementation uses Triton, a language for writing GPU kernels, and CuteDSL. The library supports multiple floating-point precisions and includes a family of matrix multiplication variants covering TF32, BFloat16, FP16, INT8, and mixed-precision combinations.

A lightweight submodule called flashlib.info is included for cost estimation. It predicts the runtime, FLOPs, and memory bandwidth for any primitive given a data shape and target hardware, and runs on CPU without importing the GPU dependencies. The README describes this as useful for budgeting a data pipeline before running it, and notes it is small enough for an LLM agent to call in an environment without a GPU.

Installation is through pip or from source. The API follows the scikit-learn pattern, so existing code using numpy-backed implementations can be adapted to use GPU-backed equivalents with minimal changes. The library is released under the Apache 2.0 license.

Where it fits