Meta FAIR has open-sourced e-means, a clustering algorithm designed to replace Lloyd’s algorithm, the standard approach in k-means clustering. According to the project documentation, e-means delivers approximately 10× speedup in both epochs and wall-clock time while simultaneously achieving lower loss across a range of scales and datasets.

The core innovation of e-means involves using mini-batch updates with exponential moving averages instead of Lloyd’s approach, which requires full passes over the entire dataset. This mini-batch strategy enables the algorithm to forget older assignments at a configurable rate, allowing centroids to track recent assignments rather than the full history. Measured end-to-end on GPU, e-means achieves a 10–45× wall-clock reduction against Flash-KMeans, the state-of-the-art Lloyd implementation, and 8–15× speedup on CPU against Faiss.
A key distinguishing feature is that e-means requires no hyperparameter tuning. The algorithm automatically sets batch size and step size using scaling laws derived from problem characteristics. The developers fitted two scaling laws to determine optimal batch size and step size from dataset size (n), number of clusters (k), and training epochs (T), finding strong generalization across unseen datasets and problem scales.
The algorithm also improves upon mini-batch k-means approaches in handling dead clusters—centroids that accumulate zero assigned points during optimization. Instead of randomly reinitializing dead clusters, e-means revives them by splitting large, existing clusters, a strategy adapted from Faiss k-means that more effectively preserves codebook capacity.
Compared to Lloyd’s algorithm, e-means reaches test loss below Lloyd’s target within 1.2 to 3 epochs, whereas Lloyd typically requires 25 epochs to achieve comparable loss. The developers attributed this advantage partly to mini-batch updates providing noisier gradients that better explore the optimization landscape and escape local minima, while Lloyd’s monotonically decreasing loss makes it more prone to getting stuck in suboptimal configurations. The algorithm includes additional refinements such as cosine-scheduled decay rates and a finalization stage that reduces training loss with negligible runtime overhead.
Key facts
- e-means achieves approximately 10× speedup compared to Lloyd’s algorithm in epochs and wall-clock time
- The algorithm reaches Lloyd’s target loss in 1.2–3 epochs versus Lloyd’s typical 25 epochs
- GPU benchmarks show 10–45× wall-clock speedup over Flash-KMeans and 8–15× on CPU versus Faiss
- e-means uses exponential moving averages on mini-batches instead of full-dataset updates
- The method automatically sets hyperparameters using scaling laws, requiring no manual tuning
- Dead cluster revival is performed by splitting large existing clusters rather than random reinitialization
