MA-Means: Bounded-Memory $k$-Means via Elastic Multi-Candidate Contraction, Coordinate-Wise Over-Relaxation, and Zero-Error Out-of-Core Bypass

Meng ZhuarXiv 2026

TL;DR

Clustering massive datasets with $k$-means usually forces an uncomfortable choice between slow full-batch runs, memory-exploding lookup tables, or fast mini-batch methods that accidentally erase rare, important data modes. MA-Means breaks this deadlock by keeping a tiny, strictly bounded memory footprint (under 9 MB, even for 10 billion vectors) that enables smart cluster "surgery," adaptive learning rates, and zero-error data skipping when streaming from CPU to GPU. It acts as a faster, more accurate drop-in upgrade for modern AI workloads—from messy real-world telemetry to heavy-tailed LLM caches.

What Problem Does This Paper Address?

$k$-means clustering is the quiet workhorse behind modern AI infrastructure: it powers vector search indices, deduplicates web-scale pretraining data, and quantizes LLM KV-caches. Yet at massive scale, existing solvers are stuck in a three-way bind:

  1. Full-batch Lloyd’s algorithm scans every vector against every centroid at each step—prohibitively slow at tens of millions of points—and easily gets trapped in bad local minima.
  2. Sample-memory methods (which track per-point bounds to skip redundant math) require $\Theta(n)$ memory, ballooning to tens of gigabytes at web scale and crashing GPUs.
  3. Mini-batch Exponential Moving Average (EMA) solvers (like Meta FAIR’s e-means) are blazingly fast on clean, uniform data because they only store a simple point-count per cluster. However, they suffer from topological blindness: if a cluster has very few points, e-means assumes it is "dead" and resets it—repeatedly destroying rare but critical outlier clusters. Furthermore, when datasets don't fit in GPU memory (out-of-core), stateless mini-batch solvers must haul every single byte across the slow CPU-to-GPU link on every pass.

Methods

MA-Means builds on e-means by replacing simple scalar counts with a bounded $O(1)$-in-$n$ memory architecture—three compact tables totaling just 0.8 to 8.6 MB regardless of dataset size $n$.

Figure 1: Empirical and asymptotic auxiliary memory scaling (𝐷= 128, 𝐾= 1024, 𝑃max = 4096). Unlike SR-MBKM (4𝑛bytes, reaching 37.3 GB at 𝑛= 1010), MA-Means remains strictly flat at 0.79–1.46 MB independent of 𝑛.

Inside a fused Triton BF16 GPU + async C++17 CPU pipeline, this compact state powers three mechanisms:

  • Certified Huygens–Ward Surgery: Instead of resetting clusters based solely on point count, MA-Means pairs a distortion-aware gate (mass $\times$ error) with non-local merge–split "teleports": it merges two close centroids and teleports the freed centroid to split a high-error cluster. To avoid slicing through single elongated ("cigar-shaped") clusters, it uses a parameter-free mathematical threshold ($2/(\pi - 2) \approx 1.752$) that distinguishes true bimodal traps from stretched unimodal Gaussians in any dimension.
  • Anchor-Aligned Kalman Gains: Mini-batch updates are noisy. Using low-dimensional Johnson–Lindenstrauss sketches, MA-Means separates true centroid drift from batch noise to compute per-cluster Kalman step sizes—speeding up newly teleported centroids without shaking settled ones.
  • Zero-Error Out-of-Core Bypass: For datasets living in host RAM, data is grouped into micro-tiles with 80-byte fingerprints. Comparing these against int8-quantized centroid checkpoints—guarded by "monotonic jump latches" that catch centroids that move and bounce back—lets the CPU deterministically skip sending unchanged tiles over PCIe with zero assignment errors.

Datasets

Without any per-dataset hyperparameter tuning, the author evaluates MA-Means against 14 baselines across:

  • Five public benchmarks: SIFT1M ($980\text{k} \times 128$), Deep10M (up to $9.97\text{M} \times 96$), ImageNet-CLIP ($1\text{M} \times 768$ multimodal embeddings), Cohere-10M ($980\text{k} \times 768$ text embeddings), and NYC-Taxi-20M ($19.98\text{M} \times 4$ heavy-tailed telemetry).
  • Four synthetic stress-test suites (up to $n = 10^7$): gaussian_balanced, gaussian_zipf, stretched_embedding (100:1 aspect ratio), and multiscale_trap.

Key Insights and Ideas

  • Why uniform schedules work—until they don't: A standout theoretical insight (Theorem 4) proves why e-means' simple uniform learning-rate schedule works so well on smooth data: inside a stationary basin, uniform annealing is already optimal up to $O(1/T^2)$, making adaptive per-cluster rates redundant. However, immediately after surgery teleports a subset of centroids, a uniform schedule either starves the newcomers or destabilizes settled clusters—creating the exact window where Kalman gains shine.
  • Mass-only revival is toxic to heavy tails: On NYC-Taxi-20M, turning on e-means' standard count-based cluster revival actually worsens clustering error (MSE) by +87.0% because it keeps deleting rare, high-variance outlier modes. Weighting revival by both mass and distortion solves this dilemma cleanly.
  • Universal bimodality check: Projected onto any 1D line, no unimodal Gaussian—no matter how stretched or high-dimensional—can have a between-group to within-group variance ratio above $2/(\pi - 2)$ when split at its mean. That gives a zero-FLOP safety lock against false cluster splits.

Key Results

  • Multimodal & Heavy-Tailed Wins: On ImageNet-CLIP ($K=4096$), MA-Core wins 10/10 seeds and hits equal error 1.24$\times$–1.76$\times$ faster than e-means. On heavy-tailed NYC-Taxi-20M, it slashes MSE by 58%–62% (running 1.41$\times$–3.20$\times$ faster than e-means and 25$\times$–133$\times$ faster than exact Ball/Hamerly pruning).
  • Scale Crossover: While MA-Means has a small 7–55 ms startup overhead at 1M rows, its per-row cost stays flat as $n$ grows while e-means' rises +20%. By $n = 10\text{M}$, MA-Means beats e-means in both wall-clock time (0.68$\times$–0.85$\times$ on Deep10M; 0.76$\times$–0.81$\times$ on synthetics) and MSE (up to -86.0% on multiscale_trap).
  • Out-of-Core Streaming: Over PCIe on a 1 GB dataset, host-side filtering eliminates 14.4%–26.4% of host-to-device data transfers with 0 false positives and 19.8% lower MSE.
Figure 2: Steady-state 10-seed epoch frontiers ({1,2,3,4,5,7} epochs) of MA-L2 (red squares) and Official Meta e-means (blue circles) on smooth-uniform (SIFT1M, Cohere-10M) and multimodal (ImageNet-CLIP) benchmarks, with 25-epoch Lloyd-k- means++, 5-epoch Sculley MBKM and 25-epoch exact Hamerly overlaid as hollow reference markers (5-seed medians, Table 6C).

Limitations and Future Work

  • Small-$n$ startup cost: Fixed initialization overhead (7–55 ms) means standard e-means finishes 5–25 ms faster on smooth, uniform datasets smaller than ~2M–4M vectors.
  • Strictly downhill moves: Cluster surgery only executes splits and merges that decrease error; it cannot make temporary "uphill" moves to cross complex energy barriers, and relies on finite-sample batch estimates rather than exact global counts.
  • Tile coarsening & single-GPU scope: Keeping the tile count capped means each tile covers more points as $n \gg 10^7$, which can dilute out-of-core bypass rates on unclustered data. Finally, experiments are limited to a single workstation ($n \le 2 \times 10^7$; $10^{10}$ memory scaling is analytical), leaving multi-node sharding for future work.

Summary updated

BibTeX
@misc{zhu2026ma,
  author = {Meng Zhu},
  title = {{MA-Means: Bounded-Memory $k$-Means via Elastic Multi-Candidate Contraction, Coordinate-Wise Over-Relaxation, and Zero-Error Out-of-Core Bypass}},
  year = {2026},
  eprint = {2611.39057},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.39057},
}
Figure