Skip to content

mlx-learn 0.1.4

Choose a tag to compare

@tabulai tabulai released this 18 Nov 13:30
· 94 commits to main since this release
f8bb076

Install on Apple silicon with python -m pip install --upgrade mlx-learn==0.1.4. This release provides wheels for Python 3.10–3.13 and a source distribution.

E-means benchmarked against Lloyd at 25 iterations

The 0.1.3 benchmark gave e-means and Lloyd the same two or three passes over the data. The new benchmark adds the paper's 25-iteration Lloyd reference for held-out mean squared error. On each dataset, both Metal implementations start from identical centers and share FP32 assignment and statistics kernels. Lloyd runs for 25 iterations, e-means runs for two or three epochs, and both timers include fresh final labels and inertia. 0.1.3 equal-pass benchmark · 0.1.4 Lloyd-25 benchmark

Dataset, 10M vectors and 65,536 centers Lloyd at 25 iterations E-means E-means speedup E-means test MSE vs. Lloyd
DEEP 545.60 s 63.33 s (2 epochs) 8.62× +0.196%
SPACEV 672.73 s 70.87 s (2 epochs) 9.49× +0.096%
SimSearchNet++ 1,421.44 s 159.60 s (2 epochs) 8.91× −0.189%
SIFT 718.55 s 109.22 s (3 epochs) 6.58× −0.280%

The paper's GPU comparison searches e-means budgets in 0.2-epoch increments for the first run that reaches Flash-KMeans at 25 iterations, then reports medians across ten seeds at the 10M scale on H100. The Metal benchmark uses preset whole epochs and one timed fit per method with one seed on M4 Max. E-means reached lower test MSE on two of the four datasets and came within 0.20% on the other two. The 10M DINO prefix had no completed Lloyd-25 pair. E-means paper, §4.3 and Table 4 · Benchmark results and limits

Faster clustering and SVC fits

  • Metal clustering. The shared FP32 assignment kernel on M4 Max emits only the winning score and center index per tile. In a matched 10M-vector DEEP run, fixed-center assignment fell from 22.88 to 14.77 s with identical labels and squared-distance bits. A separate two-update Lloyd fit including final labeling fell from 115.56 to 55.67 s, with identical labels and inertia. Peak active GPU memory fell from 5.82 to 4.04 GiB. The four-dataset same-session comparison against the earlier kernel measured 1.06–1.53× faster e-means fits. Assignment and fit benchmarks · Same-session control
  • Exact Lloyd pruning. Lloyd can reuse a label when center separation proves it is still correct. Mixed tiles use a limited set of batch sizes to reduce shader compilation. On a separated-cluster workload, pruning alone cut fit time from 68.83 to 46.08 ms. The four 10M-vector Lloyd runs reused zero labels, so their gains came from the streaming assignment kernel. Lloyd pruning benchmark
  • SVC kernel-row caching. The native solver reuses rows across working sets when the full Gram matrix exceeds cache_size. At 200 MiB on M4 Max, standard MNIST fit time fell from 9.09 to 3.59 s (2.53×) and Fashion-MNIST from 10.29 to 4.59 s (2.24×) against the pre-cache build. On standard MNIST, all 450,000 decision scores matched the pre-cache build bit for bit, accuracy was 97.92%, and warm prediction on 10,000 images took 88.2 ms, down from 88.7 ms. SVC benchmarks

Exact nearest neighbors and numerical fixes

  • Exact kNN. Both APIs share a memory-aware planner, with filtered candidate selection, parallel exact fallback, and a guard against incorrect ordering in very wide MLX sorts. At a 128 MiB workspace budget on M4 Max, the tighter planner cut a million-reference query batch from 112.57 to 43.63 ms and additional peak GPU memory from 134.6 to 33.4 MiB, with identical indices and distance bits. Integration benchmark · Memory-budget benchmark
  • M5 and wide PCA. A shared binary32 matrix-multiplication kernel avoids TF32 operand rounding in affected paths across kNN, clustering, PCA, multinomial logistic regression, SVC, and Hessian sketches. Wide GPU full-SVD PCA now reorthogonalizes components, retains computed tail directions, and handles negative-stride inputs. Reorthogonalization added 11–22% to measured wide full-SVD fits without a tail. Changelog

Full change set