Skip to content
프로젝트

소개

Benchmark of Apple MLX operations on all Apple Silicon chips (GPU, CPU) + MPS and CUDA.

AI 및 머신러닝

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
+2
in 15 days
+2
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

⚡️ mlx-benchmark ⚡️

A comprehensive benchmark of MLX ops.

This repo aims to benchmark Apple's MLX operations and layers, on all Apple Silicon chips, along with some GPUs.

Contributions: Everyone can contribute to the benchmark! If you have a missing device or if you want to add a missing layer/operation, please read the contribution guidelines.

Current M chips: M1, M1 Pro, M1 Max, M1 Ultra, M2, M2 Pro, M2 Max, M2 Ultra, M3, M3 Pro, M3 Max, M3 Ultra, M4, M4 Pro, M4 Max, M5, M5 Max, M6.

Current CUDA GPUs: RTX4090, Tesla V100, A100.

Ladder 📊

How fast each chip runs MLX overall, and how MLX on the GPU compares to PyTorch MPS. One chart per operation is in the figure gallery.

Ranking of Apple Silicon chips by geometric-mean MLX GPU speedup over the M1 Heatmap of MLX GPU vs PyTorch MPS speedup for each Apple Silicon chip and operation

All figures are generated from average_benchmark.md by run_viz.py and are regenerated automatically when a PR is merged.

Benchmarks 🧪

Benchmarks are generated by measuring the runtime of every mlx operations on GPU and CPU, along with their equivalent in pytorch with mps, cpu and cuda backends. On MLX with GPU, the operations compiled with mx.compile are included in the benchmark by default. To not benchmark the compiled functions, set --compile=False.

For each operation, we measure the runtime of multiple experiments. We propose 2 benchmarks based on these experiments:

[!NOTE] You can submit your benchmark even for a device that is already listed, provided you use a newer version of MLX. Simply submit a PR by overriding the old benchmark table. Also, most of the existing benchmarks do not include the mx.compile feature, which has been recently added to mlx-benchmark.

Installation 💻

Installation on Mac devices

Running the benchmark locally is straightforward. Create a new env with osx-arm64 architecture and install the dependencies.

CONDA_SUBDIR=osx-arm64 conda create -n mlx_benchmark python=3.10 numpy pytorch torchvision scipy requests -c conda-forge

pip install -r requirements.txt

Installation on other devices

Other operating systems than macOS can only run the torch experiments, on CPU or with a CUDA device. Install a new env without the CONDA_SUBDIR=osx-arm64 prefix and install the torch package that matches your CUDA version. Then install all the requirements within requirements.txt, except mlx.

Finally, open the config.py file and set:

USE_MLX = False

to avoid importing the mlx package, which cannot be installed on non-Mac devices.

Run the benchmark 🧑‍💻

Run on Mac

To run the benchmark on mps, mlx and CPU:

python run_benchmark.py --include_mps=True --include_mlx_gpu=True --include_mlx_cpu=True --include_cpu=True

Run on other devices

To run the torch benchmark on CUDA and CPU:

python run_benchmark.py --include_mps=False --include_mlx_gpu=False --include_mlx_cpu=False --include_cuda=True --include_cpu=True

Run only compiled functions

If you're interested in benchmarking only operations against operations compiled with mx.compile, you can run:

python run_benchmark.py --include_mps=False --include_cpu=False --include_mlx_cpu=False

Contributing 🚀

Thanks all for keeping the project updated!

관련 프로젝트 살펴보기

불러오는 중…