# Flash-KMeans: Fast and Memory-Efficient Exact K-Means

*Shuo Yang, Haocheng Xi, Yilong Zhao, Muyang Li, Xiaoze Fan, Jintao Zhang, Han Cai, Yujun Lin, Xiuyu Li, Kurt Keutzer, Song Han, Chenfeng Xu, Ion Stoica*

[NeurIPS page](https://neurips.cc/virtual/2026/poster/151963) · [OpenReview](https://openreview.net/forum?id=WVswOFOoe5) · [Open on the map](../papers.html#p151963)

Category: [Time Series, PDEs & Probabilistic ML](../pcat/9.md) › [Clustering and Matching under Uncertainty](../pgroup/614.md) · Type: new method · Keywords: GPU clustering, memory-efficient k-means, IO-aware algorithms, segmented reductions, GPU acceleration

Areas: [Memory](../areas/memory.md) › Model Memory Optimization › Efficient Attention for LLMs

## Summary
Flash-KMeans is an IO-aware, contention-free GPU implementation of exact clustering that achieves up to 17.9× end-to-end speedup by fusing distance computation with assignment and using segment-level reductions.

## Explained to a 5-year-old
We want to group lots of data points into clusters quickly on a computer. The old way uses a lot of memory and is slow. This paper finds a way to do it faster by not storing all the numbers at once. It also uses a clever trick to update the clusters without waiting for slow parts. This makes the grouping process much quicker, so the computer can do more things in less time.

## Explained to a 5-year-old, longer
Imagine you have a huge pile of toys and you want to sort them into groups by color. Doing this on a computer can be slow because the computer has to remember a lot of numbers about each toy. The new idea is like a shortcut: instead of writing down every number for every toy, the computer calculates the group on the fly while looking at each toy. Then, when the groups need to be updated, the computer uses a special method that gathers updates in batches, avoiding the slowdown caused by many tiny updates at the same time. This makes the whole sorting process much faster, so the computer can handle more toys in a shorter amount of time. The method works for any kind of data, not just toys, and it keeps the grouping exactly correct. It also fits nicely into existing computer systems, so other programs can use it without big changes. This improvement helps real-time applications like video analysis, recommendation systems, and large-scale data processing run smoother and quicker.

## For a technical reader
The approach eliminates the N×K distance matrix materialization by fusing distance computation with argmin, reducing memory traffic. It replaces irregular atomic centroid updates with a segment-level reduction scheme derived from an inverse mapping, mitigating write contention. Additional optimizations include overlapped streaming and cache-aware compilation, resulting in up to 17.9× overall speedup on modern GPUs.

## Problem
Running exact clustering algorithms efficiently on GPUs as an online primitive is limited by memory bottlenecks and contention during updates, which hinder scalability in real-time AI systems.

## Method
The approach fuses distance computation with assignment to avoid materializing the full distance matrix and replaces high-contention atomic updates with segment-level reductions, complemented by chunked streaming and cache-aware compilation for practical deployment.

## Results
The approach achieves up to 17.9× end-to-end speedup over best baselines, with kernel-level speedups of 21.2× for the assignment kernel and 6.3× for the update kernel.

## Contributions
The paper identifies IO and contention bottlenecks in GPU clustering and proposes algorithmic-system co-designs that eliminate intermediate memory materialization and replace atomic scatters with localized reductions, enabling exact clustering at scale.

## Practical relevance
It enables exact clustering to be integrated as a high-performance, first-class component in online AI systems and other GPU-intensive workloads.

## Research questions this paper is counted under

- [How can clustering algorithms be made efficient for large datasets?](../q/274.md)

This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. [Suggest a correction](../feedback/?on=p/151963)
