Results

Experimental results

One machine (Apple M3 Ultra, PyTorch on the GPU through MPS and on 32 CPU cores), one exact evaluation for every method, five seeds for the mini-batch methods. "Best e-means" always means the better of e-means's two batch laws for that configuration. Loss is the exact train MSE on all training rows; held-out MSE is on 20,000 rows never seen in training.

Protocol

Main comparison at five passes

h-means train loss relative to the best e-means, all configurations

Negative is h-means better. Each point is one (dataset, k); bars are ± one seed standard deviation. Hover for seeds won.

datasetkn / kh-means T5 vs best e-means T5vs default lawh-means T3 vs best e-means T5held-out, vs bestseeds wontime e-means / h-means (s)
Fashion-MNIST-78451278 −0.35% ± 0.04 −0.52% +0.01% −0.19% 5 / 50.2 / 0.9
Fashion-MNIST-7842,04820 −2.19% ± 0.04 −2.53% −1.49% −0.40% 5 / 50.3 / 1.1
GloVe-10016,38471 −0.03% ± 0.01 −0.22% +0.37% +0.12% 5 / 52.8 / 4.5
GloVe-10065,53618 −2.02% ± 0.01 −2.57% −1.21% −0.09% 5 / 518.6 / 16.4
GloVe-100131,0729 −4.44% ± 0.02 −5.74% −3.65% +0.05% 5 / 536.5 / 31.8
GMM (d=96)8,19261 −0.18% ± 0.02 −0.18% −0.08% +0.01% 5 / 50.9 / 1.7
GMM (d=96)32,76815 −1.62% ± 0.00 −1.62% −1.29% +0.70% 5 / 52.1 / 3.8
GMM-Zipf (d=96)4,096122 −2.16% ± 0.17 −2.16% −1.92% −2.15% 5 / 50.6 / 1.7
GMM-Zipf (d=96)16,38431 −0.89% ± 0.00 −1.02% −0.57% −0.04% 5 / 51.2 / 2.5
NYTimes-2564,09656 −0.46% ± 0.02 −0.59% +0.04% −0.21% 5 / 50.6 / 1.4
NYTimes-25616,38414 −3.15% ± 0.08 −4.96% −2.43% −1.00% 5 / 51.0 / 2.7
NYTimes-25632,7687 −6.70% ± 0.34 −9.66% −5.94% −1.23% 5 / 51.7 / 4.9
SIFT-12816,38460 −0.24% ± 0.00 −0.43% +0.46% −0.03% 5 / 52.7 / 3.5
SIFT-12865,53615 −2.26% ± 0.01 −3.07% −0.97% −0.54% 5 / 516.1 / 14.4
SIFT-128131,0727 −5.97% ± 0.01 −7.26% −4.27% −1.12% 5 / 531.8 / 27.1

Per-configuration tables

Fashion-MNIST-784, n = 40,000, k = 512 (n/k = 78)
methodseedstrain MSEvs e-means T5held-out MSEpassestime (s)
Lloyd@25 (random init)31048168 ± 2.0e+2+0.95%108157725.000.1
Sculley mini-batch T531065670 ± 5.5e+2+2.63%10924165.000.3
e-means T351042219 ± 7.7e+2+0.37%10749693.000.3
e-means T551038353 ± 6.5e+2+0.00%10729715.000.2
e-means T5 quality51036569 ± 7.4e+2−0.17%10719335.001.3
h-means T351036695 ± 8.0e+2−0.16%10719083.200.9
h-means T551032910 ± 4.5e+2−0.52%10698715.200.9
h-means T5 quality51031827 ± 6.4e+2−0.63%10696145.204.4
h-means v1 T551034916 ± 4.5e+2−0.33%10714775.201.1
Fashion-MNIST-784, n = 40,000, k = 2,048 (n/k = 20)
methodseedstrain MSEvs e-means T5held-out MSEpassestime (s)
Lloyd@25 (random init)3857746 ± 9.7e+2+2.51%97208125.000.3
Sculley mini-batch T53881135 ± 4760+5.31%9801595.000.3
e-means T35843138 ± 1218+0.77%9608423.000.3
e-means T55836721 ± 8.7e+2+0.00%9592375.000.3
e-means T5 quality5833864 ± 6.5e+2−0.34%9583785.001.5
h-means T35821425 ± 6.1e+2−1.83%9567153.131.2
h-means T55815590 ± 3.0e+2−2.53%9545775.131.1
h-means T5 quality5815724 ± 3.0e+2−2.51%9546365.135.6
h-means v1 T55817225 ± 5.7e+2−2.33%9551915.131.0
GloVe-100, n = 1,163,514, k = 16,384 (n/k = 71)
methodseedstrain MSEvs e-means T5held-out MSEpassestime (s)
Lloyd@25 (random init)30.552558 ± 0.000059+0.93%0.57705925.0012.1
k-means++ (50k sample) Lloyd@2530.553374 ± 0.000038+1.08%0.57802925.13253.4
Sculley mini-batch T530.598753 ± 0.00056+9.37%0.6103505.0010.4
e-means T350.549935 ± 0.000087+0.45%0.5734573.001.9
e-means T550.547446 ± 0.000070+0.00%0.5718895.002.8
e-means T5 quality50.546400 ± 0.000049−0.19%0.5711685.004.3
h-means T350.548410 ± 0.000054+0.18%0.5732223.103.2
h-means T550.546249 ± 0.000038−0.22%0.5718675.104.5
h-means T5 quality50.545889 ± 0.000044−0.28%0.5717255.107.7
h-means v1 T550.546197 ± 0.000032−0.23%0.5725135.104.4
GloVe-100, n = 1,163,514, k = 65,536 (n/k = 18)
methodseedstrain MSEvs e-means T5held-out MSEpassestime (s)
Lloyd@25 (random init)30.490937 ± 0.000049+2.19%0.56016225.0089.7
Sculley mini-batch T530.538595 ± 0.00089+12.11%0.5822155.0025.6
e-means T350.484113 ± 0.00012+0.77%0.5541863.0011.3
e-means T550.480400 ± 0.000094+0.00%0.5528805.0018.6
e-means T5 quality50.477735 ± 0.000062−0.55%0.5528895.0020.3
h-means T350.471972 ± 0.000047−1.75%0.5539283.1011.2
h-means T550.468074 ± 0.000030−2.57%0.5523715.1016.4
h-means T5 quality50.467743 ± 0.000027−2.63%0.5521915.1021.6
h-means v1 T550.468810 ± 0.000023−2.41%0.5524815.1017.4
GloVe-100, n = 1,163,514, k = 131,072 (n/k = 9)
methodseedstrain MSEvs e-means T5held-out MSEpassestime (s)
Lloyd@25 (random init)30.439650 ± 0.0000082+2.11%0.55578625.00184.4
Sculley mini-batch T530.488218 ± 0.00024+13.39%0.5709075.0046.6
e-means T350.435698 ± 0.00041+1.19%0.5496443.0021.9
e-means T550.430573 ± 0.000040+0.00%0.5483735.0036.5
e-means T5 quality50.424687 ± 0.00032−1.37%0.5499755.0038.4
h-means T350.409203 ± 0.000015−4.96%0.5514523.0920.8
h-means T550.405842 ± 0.000069−5.74%0.5502265.0931.8
h-means T5 quality50.404415 ± 0.000027−6.08%0.5501175.1035.9
h-means v1 T550.406203 ± 0.000054−5.66%0.5505865.0932.1
GMM (d=96), n = 500,000, k = 8,192 (n/k = 61)
methodseedstrain MSEvs e-means T5held-out MSEpassestime (s)
Lloyd@25 (random init)331.2786 ± 0.023+0.78%32.407525.002.4
Sculley mini-batch T5331.4805 ± 0.011+1.43%32.30555.002.7
e-means T3531.0886 ± 0.0097+0.16%32.28863.000.5
e-means T5531.0378 ± 0.0070+0.00%32.28905.000.9
e-means T5 quality531.0371 ± 0.0056−0.00%32.29475.002.8
h-means T3531.0124 ± 0.0089−0.08%32.28923.101.5
h-means T5530.9815 ± 0.0072−0.18%32.29695.101.7
h-means T5 quality530.9813 ± 0.0058−0.18%32.29755.106.0
h-means v1 T5530.9656 ± 0.0077−0.23%32.30645.102.0
GMM (d=96), n = 500,000, k = 32,768 (n/k = 15)
methodseedstrain MSEvs e-means T5held-out MSEpassestime (s)
Lloyd@25 (random init)328.6554 ± 0.00062+1.75%32.328825.009.2
Sculley mini-batch T5330.1279 ± 0.0030+6.97%32.30045.004.2
e-means T3528.1678 ± 0.013+0.01%32.54363.001.4
e-means T5528.1636 ± 0.0038+0.00%32.54895.002.1
e-means T5 quality528.2222 ± 0.013+0.21%32.51925.003.3
h-means T3527.7997 ± 0.0014−1.29%32.72723.103.5
h-means T5527.7081 ± 0.00059−1.62%32.77775.103.8
h-means T5 quality527.6993 ± 0.0011−1.65%32.78625.108.5
h-means v1 T5527.7223 ± 0.00091−1.57%32.76875.103.6
GMM-Zipf (d=96), n = 500,000, k = 4,096 (n/k = 122)
methodseedstrain MSEvs e-means T5held-out MSEpassestime (s)
Lloyd@25 (random init)332.6293 ± 0.089+3.04%33.600325.001.2
Sculley mini-batch T5337.6070 ± 0.81+18.76%38.34965.002.5
e-means T3531.8544 ± 0.079+0.59%32.77693.000.4
e-means T5531.6666 ± 0.077+0.00%32.64195.000.6
e-means T5 quality532.1762 ± 0.13+1.61%33.22305.002.5
h-means T3531.0597 ± 0.065−1.92%31.94753.131.4
h-means T5530.9811 ± 0.054−2.16%31.93865.131.7
h-means T5 quality531.3056 ± 0.038−1.14%32.33225.136.2
h-means v1 T5531.0683 ± 0.074−1.89%32.04895.132.0
GMM-Zipf (d=96), n = 500,000, k = 16,384 (n/k = 31)
methodseedstrain MSEvs e-means T5held-out MSEpassestime (s)
Lloyd@25 (random init)328.5311 ± 0.0023+1.20%30.824725.004.6
Sculley mini-batch T5332.2836 ± 0.077+14.51%33.57215.003.3
e-means T3528.3164 ± 0.012+0.44%30.83693.000.8
e-means T5528.1932 ± 0.0035+0.00%30.80885.001.2
e-means T5 quality528.1582 ± 0.0059−0.12%30.82835.002.2
h-means T3527.9981 ± 0.0020−0.69%30.79393.112.2
h-means T5527.9066 ± 0.0012−1.02%30.81485.112.5
h-means T5 quality527.8856 ± 0.0011−1.09%30.81315.117.0
h-means v1 T5527.8853 ± 0.0011−1.09%30.83095.112.8
NYTimes-256, n = 228,969, k = 4,096 (n/k = 56)
methodseedstrain MSEvs e-means T5held-out MSEpassestime (s)
Lloyd@25 (random init)30.730985 ± 0.00025+0.74%0.76138525.001.0
k-means++ (50k sample) Lloyd@2530.729205 ± 0.00024+0.49%0.75926025.6653.9
Sculley mini-batch T530.823581 ± 0.0051+13.50%0.8399055.001.8
e-means T350.730591 ± 0.00014+0.69%0.7593113.000.4
e-means T550.725616 ± 0.00027+0.00%0.7553565.000.6
e-means T5 quality50.724670 ± 0.00027−0.13%0.7547865.002.4
h-means T350.724934 ± 0.00012−0.09%0.7559363.121.4
h-means T550.721325 ± 0.00017−0.59%0.7531695.121.4
h-means T5 quality50.721005 ± 0.00013−0.64%0.7524265.125.5
h-means v1 T550.723070 ± 0.00013−0.35%0.7548645.121.7
NYTimes-256, n = 228,969, k = 16,384 (n/k = 14)
methodseedstrain MSEvs e-means T5held-out MSEpassestime (s)
Lloyd@25 (random init)30.627850 ± 0.000060+0.31%0.72168825.003.5
Sculley mini-batch T530.716094 ± 0.00080+14.41%0.7754755.001.9
e-means T350.635280 ± 0.0059+1.50%0.7243593.000.7
e-means T550.625906 ± 0.0072+0.00%0.7189485.001.0
e-means T5 quality50.614229 ± 0.00087−1.87%0.7128105.001.9
h-means T350.599325 ± 0.000091−4.25%0.7087783.102.0
h-means T550.594855 ± 0.00051−4.96%0.7056945.102.7
h-means T5 quality50.594344 ± 0.00010−5.04%0.7056345.1110.2
h-means v1 T550.596103 ± 0.00013−4.76%0.7057795.102.4
NYTimes-256, n = 228,969, k = 32,768 (n/k = 7)
methodseedstrain MSEvs e-means T5held-out MSEpassestime (s)
Lloyd@25 (random init)30.543969 ± 0.000042−1.37%0.70956725.007.1
Sculley mini-batch T530.624395 ± 0.00095+13.21%0.7418095.002.7
e-means T350.565915 ± 0.0077+2.61%0.7138563.001.1
e-means T550.551540 ± 0.0080+0.00%0.7065755.001.7
e-means T5 quality50.534047 ± 0.0018−3.17%0.7008235.002.7
h-means T350.502311 ± 0.00091−8.93%0.6953653.103.0
h-means T550.498276 ± 0.0018−9.66%0.6922025.104.9
h-means T5 quality50.495315 ± 0.000087−10.19%0.6940105.108.6
h-means v1 T550.497698 ± 0.000072−9.76%0.6928735.103.2
SIFT-128, n = 980,000, k = 16,384 (n/k = 60)
methodseedstrain MSEvs e-means T5held-out MSEpassestime (s)
Lloyd@25 (random init)338233 ± 5.6+1.07%4102125.0010.4
k-means++ (50k sample) Lloyd@25338328 ± 3.3+1.31%4119025.15201.6
k-means++ (full data) Lloyd@25138107 ± 0.0+0.73%4086936.00429.5
Sculley mini-batch T5339808 ± 46+5.23%419785.007.7
e-means T3538119 ± 3.6+0.76%409263.001.6
e-means T5537830 ± 2.5+0.00%408385.002.7
e-means T5 quality537759 ± 2.7−0.19%407745.005.2
h-means T3537935 ± 1.7+0.28%408493.102.7
h-means T5537669 ± 1.3−0.43%407625.103.5
h-means T5 quality537631 ± 2.7−0.53%407565.107.8
h-means v1 T5537790 ± 3.3−0.11%408185.104.2
SIFT-128, n = 980,000, k = 65,536 (n/k = 15)
methodseedstrain MSEvs e-means T5held-out MSEpassestime (s)
Lloyd@25 (random init)330581 ± 6.9+2.89%3720025.0079.5
Sculley mini-batch T5331949 ± 1.3e+2+7.49%378505.0021.6
e-means T3530082 ± 24+1.21%369963.009.8
e-means T5529722 ± 14+0.00%368995.0016.1
e-means T5 quality529478 ± 2.7−0.82%367945.0017.6
h-means T3529193 ± 1.9−1.78%367233.099.8
h-means T5528811 ± 3.8−3.07%365975.0914.4
h-means T5 quality528757 ± 2.8−3.25%365845.0919.4
h-means v1 T5528917 ± 3.2−2.71%366465.0915.9
SIFT-128, n = 980,000, k = 131,072 (n/k = 7)
methodseedstrain MSEvs e-means T5held-out MSEpassestime (s)
Lloyd@25 (random init)325059 ± 4.6+4.39%3499625.00158.1
Sculley mini-batch T5326646 ± 82+11.00%356285.0037.5
e-means T3524326 ± 29+1.33%347953.0018.7
e-means T5524006 ± 40+0.00%347295.0031.8
e-means T5 quality523678 ± 5.8−1.37%346045.0033.9
h-means T3522666 ± 3.6−5.58%343263.0918.3
h-means T5522264 ± 1.8−7.26%342165.0927.1
h-means T5 quality522222 ± 5.8−7.43%342405.0931.4
h-means v1 T5522407 ± 3.8−6.66%342585.0929.7

Dependence on k (SIFT-128)

SIFT-128, n = 980,000, k from 2,048 to 262,144, three seeds, five passes.

h-means train loss relative to the best e-means, SIFT-128, 5 passes

Negative is h-means better. Bars show ± one seed standard deviation.

kn / ke-means T5e-means T5 qualityh-means T5h-means vs besttime e-means / h-means (s)
2,04847947239 ± 447200 ± 547213 ± 2+0.03%0.7 / 2.0
4,09623944192 ± 544148 ± 344157 ± 2+0.02%1.0 / 2.3
8,19212041113 ± 841051 ± 241040 ± 2−0.03%1.5 / 2.6
16,3846037831 ± 237757 ± 137668 ± 1−0.24%2.6 / 3.7
32,7683034185 ± 934024 ± 133705 ± 4−0.94%4.5 / 6.1
65,5361529718 ± 1629480 ± 228809 ± 4−2.28%15.1 / 15.5
131,072723996 ± 4923681 ± 522264 ± 1−5.98%30.4 / 29.1
262,144416714 ± 6816448 ± 1014026 ± 0−14.73%60.0 / 67.1

Above two hundred points per cluster h-means (EMA fraction 1.0 there) ties e-means with the quality law within ±0.03% and is 0.05 to 0.2% below its default law. From sixty points per cluster down the gap widens to 15% at four points per cluster, where Lloyd's algorithm is itself competitive with e-means. With a fixed 0.4 EMA fraction the large-k end was 0.25% worse than e-means and the small end 14.7% better; with a fixed 0.8 fraction, 0.07% worse and 7.4% better.

Held-out loss as a function of passes

Seed 0, held-out MSE after every pass. Dashed: three-pass runs; dotted: e-means quality law. The last point of each curve is the final centroids after e-means's last-pass finalisation, which is why the e-means curves can tick up at the end.

SIFT-128 k=65,536

NYTimes-256 k=32,768

GloVe-100 k=131,072

GMM-Zipf (d=96) k=4,096

Deep-96 at 10M rows

Deep-96, 9.97M training rows, k = 65,536 (152 points per cluster), two seeds. This is the regime of IVF training the e-means authors target: h-means is 0.2% below e-means in 10% less time (EMA fraction 1.0; the fixed 0.4 split was a tie).

methodseedstrain MSEvs e-means T5held-out MSEpassestime (s)
Lloyd@25 (random init)10.330926+0.50%0.34202625.00733
e-means T320.330463+0.36%0.3411673.0093
e-means T520.329273+0.00%0.3408035.00151
h-means T320.329802+0.16%0.3406433.0992
h-means T520.328614−0.20%0.3402955.09135

CPU wall-clock time

PyTorch CPU backend, 32 cores, three seeds. The official faiss implementation (NumpyEmeans) is included as a reference; its assignment runs through faiss.knn, which is about four times slower than a torch matmul on this machine, so compare the two torch rows.

datasetkmethodtrain MSEtime (s)passes
GloVe-10016,384e-means T5 (torch cpu)0.54743823.35.00
GloVe-10016,384e-means official (faiss cpu) T50.54746590.95.00
GloVe-10016,384lloyd@25 (torch cpu)0.552574118.825.00
GloVe-10065,536e-means T5 (torch cpu)0.48046398.85.00
GloVe-10065,536e-means official (faiss cpu) T50.480476324.55.00
GloVe-10065,536h-means T3 (torch cpu)0.47199959.03.10
GloVe-10065,536h-means T5 (torch cpu)0.46806892.45.10
SIFT-12816,384e-means T5 (torch cpu)3783019.65.00
SIFT-12816,384e-means official (faiss cpu) T53783076.85.00
SIFT-12816,384h-means T3 (torch cpu)3793112.13.10
SIFT-12816,384h-means T5 (torch cpu)3766819.05.10
SIFT-12816,384lloyd@25 (torch cpu)38234100.525.00
SIFT-12865,536e-means T5 (torch cpu)2971878.75.00
SIFT-12865,536e-means official (faiss cpu) T529719304.05.00
SIFT-12865,536h-means T3 (torch cpu)2919140.63.09
SIFT-12865,536h-means T5 (torch cpu)2880961.05.09

Ablations

Five passes, five seeds, each component switched off in turn, relative to the recipe with the fixed 0.4 EMA fraction (the final rule's choice at 15 and 18 points per cluster; at 60 and 122 the rule picks 0.8 and 1.0, which appear as rows). Sorted by train MSE.

SIFT-128 k=65,536

varianttrain MSEvs fulltime (s)
ema_frac 0.8 (v2 split)28788−0.08%14.4
h-means (full)28811+0.00%15.6
- SSE donors (mass donors)28811+0.00%14.3
- SSE allocation (uniform children)28844+0.11%14.1
- Hartigan in EMA phase28917+0.37%14.9
- warm start28986+0.61%13.8
- Hartigan tail (EMA only, same passes)29243+1.50%14.1
ema_frac 1.0 (no tail, Hartigan-EMA only)29243+1.50%14.3
e-means + Hartigan-EMA only29436+2.17%12.8
- Hartigan rule in tail (Lloyd-rule tail)29572+2.64%16.0
e-means (all off)29730+3.19%15.1

SIFT-128 k=16,384

varianttrain MSEvs fulltime (s)
ema_frac 0.8 (v2 split)37669−0.25%3.7
- Hartigan tail (EMA only, same passes)37672−0.24%3.7
ema_frac 1.0 (no tail, Hartigan-EMA only)37672−0.24%3.8
e-means + Hartigan-EMA only37711−0.14%2.7
h-means (full)37764+0.00%4.1
- SSE donors (mass donors)37764+0.00%4.0
- SSE allocation (uniform children)37767+0.01%4.0
- Hartigan in EMA phase37790+0.07%4.0
e-means (all off)37831+0.18%2.7
- warm start37841+0.20%3.1
- Hartigan rule in tail (Lloyd-rule tail)37973+0.55%4.2

GMM-Zipf (d=96) k=4,096

varianttrain MSEvs fulltime (s)
ema_frac 1.0 (no tail, Hartigan-EMA only)30.9568−0.31%1.7
ema_frac 0.8 (v2 split)30.9641−0.28%1.7
- Hartigan tail (EMA only, same passes)30.9784−0.24%1.7
- Hartigan in EMA phase31.0492−0.01%2.1
- SSE donors (mass donors)31.0495−0.01%2.1
h-means (full)31.0522+0.00%2.2
- Hartigan rule in tail (Lloyd-rule tail)31.1191+0.22%2.0
e-means + Hartigan-EMA only31.6389+1.89%0.8
e-means (all off)31.6988+2.08%0.7
- warm start31.9150+2.78%1.2
- SSE allocation (uniform children)33.9888+9.46%1.8

GloVe-100 k=65,536

varianttrain MSEvs fulltime (s)
- SSE donors (mass donors)0.468065−0.00%16.3
h-means (full)0.468067+0.00%16.4
- SSE allocation (uniform children)0.468465+0.08%15.7
- Hartigan in EMA phase0.468836+0.16%17.3
- warm start0.470682+0.56%14.8
ema_frac 0.8 (v2 split)0.471041+0.64%16.3
- Hartigan tail (EMA only, same passes)0.475586+1.61%16.2
ema_frac 1.0 (no tail, Hartigan-EMA only)0.475602+1.61%16.0
e-means + Hartigan-EMA only0.477000+1.91%14.3
- Hartigan rule in tail (Lloyd-rule tail)0.478863+2.31%18.9
e-means (all off)0.480423+2.64%17.8

Every component except the loss-proportional donors matters somewhere. The Hartigan rule in the tail is the largest single lever at small n/k; a Lloyd-rule tail with identical bookkeeping gains nothing. The warm start is worth 0.3 to 2.3% and its loss-proportional allocation is what makes it survive imbalance (uniform children: +9% on the Zipf mixture). "e-means (all off)" is the faithful reimplementation.

Limitations