# E-means: A 10x Faster K-Means Clustering Optimization Algorithm

New optimization rule achieves superior clustering quality and speed using exponential moving averages.

- **Source:** [Hacker News: Front Page](https://brifing.si/source/b07aa772-b1a0-4a76-aa18-719c6f9e2dde)
- **Published:** 2026-11-09
- **Topic:** [technology](https://brifing.si/c/technology)
- **Original article:** <https://e-means.github.io/>
- **On Brifing:** https://brifing.si/s/febdbd3e-bee8-4343-a6a5-6fcf6cb35b84

## Revolutionizing K-Means Clustering

E-means introduces a novel optimization rule for the classic k-means problem, significantly outperforming the traditional Lloyd's algorithm. By utilizing exponential moving averages instead of full dataset passes, it achieves a 10x speedup on GPUs. This method provides both faster convergence and lower final loss across diverse, large-scale datasets.

## Scaling Laws Replace Tuning

A major advantage of e-means is the elimination of manual hyperparameter tuning. The algorithm automatically determines optimal batch and step sizes using derived scaling laws based on problem characteristics like n, k, and T. This ensures consistent performance across various scales without requiring the trial-and-error processes typical of previous methods.

## Exponential Moving Average Advantage

Unlike MacQueen's update or standard gradient descent, e-means employs exponential moving averages to track recent assignments. This approach ensures centroids remain within the convex hull of assigned points, preventing the instability often seen in gradient-based updates. It effectively balances the need for exploration with stable, efficient centroid convergence.

## Dead-Cluster Revival Strategy

To maintain codebook capacity, e-means implements a robust dead-cluster revival mechanism. When a cluster falls below a specific size threshold, the algorithm splits a large, active cluster into two. This method is significantly more effective than random reinitialization, ensuring that all k centroids remain active and contribute to the model.

## Performance Against State-of-the-Art

Benchmarking shows e-means achieves a 10x wall-clock reduction on GPUs compared to Flash-KMeans and an 8x reduction on CPUs against Faiss. By fusing nearest-centroid assignment with specialized kernels, the algorithm translates its algorithmic efficiency into tangible speedups. It consistently reaches lower test loss in just 1.2 to 3 epochs.

## Escaping Local Minima Effectively

Experimental results across 200 seeds indicate that e-means is less prone to pathological configurations than Lloyd's algorithm. The inherent noise in mini-batch updates allows the model to explore the optimization landscape more thoroughly. Consequently, it avoids the local minima traps that often limit the quality of traditional k-means clustering results.

## Algorithmic Flexibility and Finalization

The algorithm includes a cosine-scheduled decay rate and a finalization stage that further reduces training loss with negligible runtime impact. By setting the batch size to the full dataset and the decay rate to one, e-means can replicate Lloyd's behavior, proving it is a more generalized and powerful optimization framework.

## Broad Applicability and Impact

Validated on 24 different embedding and synthetic datasets, e-means demonstrates strong generalization across varying problem scales. Its ability to handle static datasets efficiently makes it a versatile tool for modern machine learning pipelines. Practitioners can now achieve higher quality clustering results with significantly less computational overhead and zero manual tuning.

## Sources covering this story

- https://e-means.github.io/ — 

---

_Summary written by Brifing from the original reporting. Copyright in the original article belongs to its publisher; read the full piece at the link above._
