E-means: 10x faster k-means at equal loss e-means.github.io · 94 points · 3 comm...

@best

E-means: 10x faster k-means at equal loss e-means.github.io · 94 points · 3 comments · HN thread

TL;DR Meta FAIR has open-sourced e-means, a replacement for Lloyd's algorithm for k-means that uses mini-batch exponential-moving-average centroid updates, automatic scaling-law hyperparameters and a new dead-cluster revival scheme. The article reports about 10x faster end-to-end runs than Lloyd-based baselines (Flash-KMeans on GPU, Faiss on CPU) while reaching lower loss, with code in the faiss repo.

  • e-means replaces Lloyd's full-batch update with mini-batch updates using exponential moving averages, which the author found most efficient for static k-means.
  • Batch size and step size are set automatically by two fitted scaling laws in n, k and T, so no extra hyperparameter tuning is needed compared with Lloyd.
  • Dead clusters are revived by splitting large active clusters (sampled proportionally to size) rather than resampling points from the batch as in EnCodec; on DEEP and SIFT this cut dead clusters from thousands to 10-47.
  • Reported results: test loss below Lloyd's at 25 epochs reached in 1.2 to 3 epochs; end-to-end wall-clock 10-45x faster on GPU vs Flash-KMeans and 8-15x faster on CPU vs Faiss.
  • Lloyd's algorithm is described as a special case (batch equal to full dataset, alpha = 1, no cosine schedule), which the author says is a highly suboptimal setting.
  • The code lives in the faiss contrib package and the paper is arXiv:2611.09501.

Discussion The thread is short and positive. Commenters are impressed by the claimed speedups and found the explanation and visualizations clear, with one saying the idea looks obvious in hindsight. The main discussion is a request from a reader for intuition behind the automatic hyperparameter scaling laws, which have not yet been explained to their satisfaction.

  • Impressed by the speedup and clear presentation (most): Commenters praise the method and its visualizations, calling the approach obvious in hindsight. One reports a 146x GPU speedup after adapting it to their own IVF index.
  • Wants the method in scipy for wider availability (a few): One commenter hopes e-means gets added to scipy, since it is more available in common environments than Facebook's Faiss library.
  • Scaling laws for hyperparameters are not yet intuitive (a few): A reader finds the automatic batch and step size laws opaque and asks the authors for intuition behind them.

#kmeans #clustering #machineLearning #faiss #optimization