Skip to content

mlx-learn 0.1.5

Choose a tag to compare

@tabulai tabulai released this 19 Nov 12:48
· 87 commits to main since this release
0dec6e7

Version 0.1.5 adds mlxlearn.cluster.OMeans for clustering with many centroids on Apple silicon. O-means groups centroids into coarse cells and searches nearby cells during training. Final labels, predictions, and scores use a full centroid search. Training supports FP32 and BF16.

python -m pip install --upgrade mlx-learn==0.1.5
from mlxlearn.cluster import OMeans

model = OMeans(n_clusters=16_384, max_iter=2, random_state=10).fit(X_train)
labels = model.predict(X_test)

Across 18 datasets and three seeds, O-means reached EMeans' held-out mean squared error 4.44× as fast with FP32 on M5 Ultra and 4.13× as fast on M4 Max, using interpolated epoch budgets. The geometric-mean speedups at measured budgets were 3.96× and 3.67×, respectively. Inputs were already resident on the GPU for the timed calls. M5 Ultra benchmarks · M4 Max benchmarks

MNIST-family benchmarks

These benchmarks were added in PR #28 after the v0.1.5 tag. Each dataset has 60,000 training images with 784 features. The runs cover 1,024 to 8,192 centroids on M4 Max and M5 Ultra.

On M4 Max, OMeans.fit took 150–242 ms at 4,096 to 8,192 centroids, with held-out mean squared distance within 1% of scikit-learn's KMeans. The OMeans and EMeans timings include three epochs and final labeling and report medians across three seeds. The scikit-learn timings are single fits with default settings. Parentheses show the change in held-out mean squared distance relative to scikit-learn's KMeans.

Dataset Centroids OMeans EMeans scikit-learn MiniBatchKMeans scikit-learn KMeans
MNIST 4,096 150 ms (+0.25%) 190 ms (+0.35%) 23.9 s (+3.53%) 109.4 s
MNIST 8,192 228 ms (−0.06%) 381 ms (−0.02%) 90.0 s (+3.07%) 218.0 s
Fashion-MNIST 4,096 156 ms (−0.68%) 194 ms (−0.73%) 23.4 s (+3.88%) 107.2 s
Fashion-MNIST 8,192 242 ms (−0.82%) 420 ms (−0.83%) 89.4 s (+3.16%) 217.7 s
Kannada-MNIST 4,096 163 ms (−0.07%) 197 ms (+0.02%) 24.4 s (+2.74%) 113.3 s
Kannada-MNIST 8,192 230 ms (−0.93%) 392 ms (−0.84%) 93.1 s (+1.35%) 223.4 s

For training from GPU-resident inputs at two or three epochs, OMeans ran about 1.4× as fast as EMeans at 4,096 centroids and 2.0–2.3× as fast at 8,192 on M4 Max. On M5 Ultra, the corresponding speedups were 1.15–1.21× and 1.74–1.85×. At 1,024 and 2,048 centroids, assignment="auto" used the full search and training times were close to EMeans. At one epoch and 4,096 centroids, OMeans was 7–11% slower than EMeans on M5 Ultra. Full benchmark report and raw results · PR #28

The release provides Apple silicon wheels for Python 3.10–3.13 and a source distribution. O-means guide · Changelog · PyPI