When does Apple Silicon GPU acceleration pay off?

Classical machine learning and XGBoost benchmarks on an M5 Pro

Machine Learning
Apple Silicon
Benchmarking
A reproducible look at where Metal helps classical machine learning and XGBoost, from operation-level traces to training and prediction crossovers.
Author

Atila Madai

Published

November 17, 2026

I wanted to know how much of my tabular machine-learning work could run faster on the GPU already in my MacBook. XGBoost made the difference between training and serving easy to measure. An analyst might score a whole table at once. An application might score one row while someone waits. Those two calls can go through the same model and still favor different hardware.

On my M5 Pro, xgboost-metal trained both baseline models about twice as fast as four-thread CPU XGBoost. It also scored the full 25,000-row batch about three and a half times as fast. At one row, the CPU was much faster. The measurements in between are what I wanted from the project. They show where the answer changes and how wide the margin is.

Training speedup across a logarithmic row-count axis. Regression crosses parity earlier than classification. Training speedup across a logarithmic row-count axis. Regression crosses parity earlier than classification. Zoom near parity. First wins in both passes were at 208 rows for regression and 464 for classification. Zoom near parity. First wins in both passes were at 208 rows for regression and 464 for classification.
Where Metal starts winning on trainingRatios above the dashed 1× line favor Metal. Points show the median across passes. Whiskers span the observed pass ratios. Each pass used three steady fits per engine. Inputs have 32 features. Data and method.

What I wanted the benchmark to prove

I built mlx-m5-bench in two stages. The first compared scikit-learn with mlx-learn on logistic regression, nearest neighbors, SVC, and PCA. The second added CPU XGBoost and xgboost-metal as independent adapters. Keeping the stages separate gave me a chance to establish the timing boundaries and verification method before adding a new engine.

I wanted each number to answer a specific question. How long did it take to ingest comparison-ready arrays? How long did the fitting call take? How long did a warmed prediction take on an already fitted model? For XGBoost I measured training-matrix ingestion separately from histogram training. Prediction starts with a NumPy array and ends with materialized output. The warmed prediction measurements use the same fitted booster within each measurement block.

Both sides receive the same data for a given comparison. The XGBoost workers live in separate Python environments because both distributions export the same xgboost module. The benchmark records input hashes, environment versions, and operation-level timings. I alternated which engine ran first and inspected the paired passes near the crossover. The held-out checks compare log loss and ROC AUC for classification and RMSE for regression.

The traces answer a different question from the stopwatch. I ran the Metal observer separately and recorded completed command buffers and direct compute dispatches. That gave me evidence of GPU work inside the operation being timed, while keeping instrumentation out of the latency runs. Benchmark methodology and raw results

What mlx-learn taught me about routing

The classical estimators gave me a good reason to keep separate records for fitting and prediction. In the selected logistic regression replay, requesting MLX produced GPU work during fit, and prediction stayed on the host. KNN showed the reverse pattern in its selected replay. Fit submitted zero Metal command buffers, and the first prediction submitted one. An estimator-level backend label would have hidden both distinctions.

Automatic routing made the picture more interesting. On the shapes shown below, KNN kept GPU work in its first query. The selected logistic regression, SVC, and PCA operations stayed on the host in auto mode even where a forced replay had submitted Metal work. These are observations about the specified shapes and operations. Other workloads can select different paths.

Selected replay Fit Predict / transform Auto fit Auto predict
mlx-learn logistic regression100,000 × 256 Mixed18 Host0 Host0 Host0
mlx-learn KNN8,000 × 128 Host0 GPU1 Host0 GPU1
mlx-learn SVC4,000 × 256 Mixed4 Mixed1 Host0 Host0
mlx-learn PCA12,000 × 256 Mixed3 GPU2 Host0 Host0
xgboost-metal classifier75,000 × 32 training GPU206 GPU2 — —
Where the work ranNumbers count completed Metal command buffers. GPU and mixed cells record GPU work. Host cells record zero Metal submissions in these replays. The first two operation columns use forced MLX or xgboost-metal. The auto columns apply to mlx-learn.

Routing and speed also asked different questions. In the 2,000-row, 32-feature logistic regression case, forced fit emitted Metal work and took about 5.02 ms versus 1.16 ms for scikit-learn. At 100,000 rows and 256 features, forced fit took about 17.09 ms versus 42.45 ms. The larger workload could amortize costs that dominated the smaller one. That result is why I went into XGBoost looking for crossovers as well as headline speedups. Classical benchmark results and routing traces

XGBoost on the same machine

For the second experiment I compared XGBoost 3.4.1 with xgboost-metal 0.1.1. The baseline used synthetic dense binary classification and regression. Both tasks used 75,000 training rows, 32 features, and 25,000 held-out prediction rows. I fixed 100 boosting rounds, depth six, and 256 histogram bins. CPU XGBoost used four threads.

Classification training took 243.1 ms on CPU and 124.0 ms on Metal. Regression took 243.6 and 118.8 ms. Classification training took 243.1 ms on CPU and 124.0 ms on Metal. Regression took 243.6 and 118.8 ms. Classification prediction took 3.38 ms on CPU and 0.96 ms on Metal. Regression took 3.29 and 0.97 ms. Classification prediction took 3.38 ms on CPU and 0.96 ms on Metal. Regression took 3.29 and 0.97 ms.
The 32-feature baselineMedian latencies for 75,000 training rows and a 25,000-row prediction batch. Each engine contributed six steady fits and 20 warmed predictions per task. Data and method.

The baseline put classification training at about 243 ms on CPU and 124 ms on Metal. Regression was 244 ms and 119 ms. Warmed prediction took 3.38 ms on CPU and 0.96 ms on Metal for classification, and 3.29 ms and 0.97 ms for regression. All 12 paired fits passed the held-out quality checks. The instrumented replays captured GPU work during both training and warmed prediction, and the CPU controls submitted zero Metal work. Baseline evidence and reproduction commands

Training scale and prediction scale

The lead chart varies the training set and keeps the prediction batch at 25,000 rows. With classification, the CPU won every tested pass at 448 training rows. Metal won both at 464 rows, with median training time changing from 66.177 ms on CPU to 65.749 ms on Metal. For regression the corresponding bracket was 192 to 208 rows, with 80.135 ms on CPU and 78.682 ms on Metal at 208 rows. Both margins were small. Metal won every measured training pass at larger tested training sizes.

Prediction with the full held-out batch favored Metal even at three training rows, the smallest size tested. A large prediction batch can keep the GPU busy even when the model was trained on very little data. That result made it worth varying prediction batch size on its own while fixing the training set at 75,000 rows. Training-size sweep

Prediction speedup from one to 25,000 rows. The dotted line at 512 rows marks a Metal kernel switch. Prediction speedup from one to 25,000 rows. The dotted line at 512 rows marks a Metal kernel switch. Zoom near parity. Both workloads first won all passes at 3,360 rows. At some larger batches, pass ranges cross one. Zoom near parity. Both workloads first won all passes at 3,360 rows. At some larger batches, pass ranges cross one.
Prediction needs a larger batch to pull aheadThe 39 batch sizes use prefixes of the same held-out array. Each pass includes 30 warmed predictions per engine and size. Whiskers show the range of observed pass ratios. Data and method.

At a single prediction row, classification took 59 µs on CPU and 804 µs on Metal. The Metal traces already showed GPU work at that size. At 512 rows, they showed a switch from ordinary prediction to a kernel that caches tree nodes during traversal. Metal latency fell from roughly 737 µs at 511 classification rows to 507 µs at 512, while CPU latency at 512 was about 145 µs.

For both tasks, 3,360 rows was the first tested batch where Metal won every measured pass. Some larger batches split the passes. Classification stayed ahead across every larger tested size from 3,648 rows, and regression did so from 3,424 rows. Around 3,360, the median advantage was about 2%. I treat those sizes as landmarks for this experiment. A different tree ensemble, CPU thread setting, or way of preparing input could move them. Prediction-batch timings and dispatch traces

What happens when the table gets wider?

I fixed the training and prediction row counts again and expanded the inputs from 32 to 512 features. The original 32 columns remained byte-for-byte identical. Wider inputs appended the same seeded noise columns to both engines. That let me test the cost of additional columns without deliberately introducing more predictive signal.

Classification training scales from 246 to 3,883 milliseconds on CPU and 125 to 844 on Metal. Classification training scales from 246 to 3,883 milliseconds on CPU and 125 to 844 on Metal. Classification prediction scales from 3.35 to 6.22 milliseconds on CPU and 0.99 to 2.87 on Metal. Classification prediction scales from 3.35 to 6.22 milliseconds on CPU and 0.99 to 2.87 on Metal. Regression training scales from 240 to 4,233 milliseconds on CPU and 118 to 833 on Metal. Regression training scales from 240 to 4,233 milliseconds on CPU and 118 to 833 on Metal. Regression prediction scales from 3.61 to 6.27 milliseconds on CPU and 0.94 to 2.91 on Metal. Regression prediction scales from 3.61 to 6.27 milliseconds on CPU and 0.94 to 2.91 on Metal.
Wider inputs shift the training and prediction gainsTraining uses a logarithmic latency axis. Each width keeps the original 75,000 training and 25,000 prediction rows. Additional columns contain seeded noise. Data and method.

At 512 features, Metal trained classification 4.60× faster and regression 5.08× faster. Warmed prediction was 2.17× and 2.16× faster, respectively. The prediction advantage had narrowed from the 32-feature cases as both engines took longer on wider inputs. The observed prediction kernel stayed the same across these widths. Metal won every paired timing pass for both operations at all ten widths, and all 120 timed model pairs passed the held-out checks. Feature-count sweep and Metal traces

How I’d use these results

For a batch scoring job on this machine, I would include Metal in the first benchmark. For interactive scoring at one row per call, I would start with the CPU. I would also measure training separately from inference. An experiment can show a substantial training gain while leaving a serving job on a different backend.

The limits of the experiment matter for that decision. These are dense synthetic datasets on one M5 Pro and against a four-thread CPU baseline. The results cover pinned versions, a fixed boosting configuration, and observed timing passes. Real workloads can change the balance through tree shape, missing values, feature types, batch size, or how much time is spent getting data to the model. The sweep tells me which variables I would test first on my own data.

The release includes the worker setup, raw measurements, quality checks, plotting data, and Metal traces. If you reproduce the comparison, record your chip, package versions, CPU threads, and actual prediction batch sizes alongside the speedup. Those details make differing results useful. Get mlx-m5-bench v0.2.0

Acknowledgments

Thank you to Bojan Tunguz and the contributors behind TabulAI’s mlx-learn and xgboost-metal for bringing these workloads to Apple Silicon GPUs. Bojan published the xgboost-metal release tested here. The project credits INT21’s swarm with the initial prototype. Their work made this comparison possible. Bojan Tunguz on GitHub · xgboost-metal project and credits · Tested xgboost-metal release · mlx-learn project