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

New optimization method achieves superior clustering quality with significantly reduced computational overhead.

- **Source:** [Hacker News](https://news.ycombinator.com)
- **Published:** 2026-11-09
- **Topic:** [technology](https://brifing.si/c/technology)
- **Original article:** <https://e-means.github.io/>
- **On Brifing:** https://brifing.si/s/deb25ab9-199e-41b8-8d62-770e74df1012

## Revolutionizing K-Means Clustering

The e-means algorithm introduces a modern optimization rule for the classic k-means problem, achieving 10x faster performance than traditional Lloyd's algorithm. By utilizing exponential moving averages instead of full-dataset passes, it significantly reduces wall-clock time. This approach maintains high clustering quality while drastically lowering the computational cost for large-scale datasets.

## Scaling Laws for Optimization

Unlike previous methods, e-means eliminates the need for manual hyperparameter tuning by deriving batch and step sizes from scaling laws. These laws automatically adjust based on the dataset size, cluster count, and training duration. This automation ensures optimal performance across diverse scales without requiring extensive trial-and-error configuration by the user.

## EMA vs. Gradient Descent

The core innovation lies in using exponential moving average updates, which provide superior stability compared to gradient-descent-based approaches. While gradient descent can overshoot the convex hull of assigned points, EMA updates guarantee centroids remain within these bounds. This stability allows for larger learning rates and faster convergence on static datasets.

## Dead-Cluster Revival Strategy

A common failure in mini-batch k-means is the emergence of dead clusters, which reduce codebook capacity. E-means addresses this by splitting large, active clusters to revive those with zero assigned points. This method, adapted from Faiss, proves more effective than random reinitialization, ensuring all clusters remain active and useful throughout training.

## Performance Benchmarks and Speed

Measured end-to-end, e-means achieves a 10x wall-clock reduction on GPUs compared to Flash-KMeans and 8x on CPUs against Faiss. These gains are realized through specialized kernels that fuse nearest-centroid assignments. By effectively parallelizing the update process, the algorithm transforms algorithmic efficiency into tangible speedups for high-dimensional data processing tasks.

## Escaping Local Minima

Experimental results across 200 seeds indicate that e-means is significantly less likely to fall into pathological configurations than Lloyd's algorithm. The inherent noise in mini-batch updates allows the model to explore the optimization landscape more effectively. Consequently, e-means avoids the local minima traps that often plague traditional, strictly decreasing loss methods.

## Integration and Finalization

The algorithm includes a cosine-scheduled decay rate and a finalization stage that further reduces training loss. These components add only a negligible runtime penalty while ensuring the final centroids are highly accurate. By ending the run on the exact last-epoch mean, e-means provides a refined, high-quality result for complex clustering applications.

## Practical Implications for Practitioners

E-means offers a robust alternative for researchers working with large-scale embeddings or synthetic datasets. By providing a drop-in replacement for Lloyd's algorithm that requires no extra hyperparameter tuning, it simplifies the workflow. Practitioners can now achieve better clustering results in significantly less time, improving efficiency for modern machine learning pipelines.

## 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._
