mihasK/phi2-llm-on-MLX-vs-Pytorch-MPS

19

stars

17

commits

Jupyter Notebook

primary language

Dec 29, 2023

updated

README

Benchmark of running Phi-2 LLM on MLX and PyTorch on MPS device

Code for the article about speed comparison of MLX and PyTorch on Apple's M1 MAX GPU: https://medium.com/@koypish/mps-or-mlx-for-domestic-ai-the-answer-will-surprise-you-df4b111de8a0

Installation

  • pyenv install 3.11
  • pyenv local 3.11

1st option:

  • poetry shell

2nd option:

  • python -m venv .venv; source .venv/bin/activate
  • pip install -r requirements.txt

Run Phi-2 benchmarks

  • make mlx
  • make mps - for PyTorch on Metal GPU
  • make cpu - for PyTorch on CPU

In order to track CPU/GPU usage, keep make track running while performing operation of interest.

Results on M1 Max (MacOS Sonoma 14.1.1)

Speed Benchmark

MLX resources usage

PyTorch on MPS resources usage

PyTorch on MPS convnet training

Structure

Contributors

mihasK

17 commits

mihasK/phi2-llm-on-MLX-vs-Pytorch-MPS

19

stars

17

commits

Jupyter Notebook

primary language

Dec 29, 2023

updated

README

Benchmark of running Phi-2 LLM on MLX and PyTorch on MPS device

Code for the article about speed comparison of MLX and PyTorch on Apple's M1 MAX GPU: https://medium.com/@koypish/mps-or-mlx-for-domestic-ai-the-answer-will-surprise-you-df4b111de8a0

Installation

  • pyenv install 3.11
  • pyenv local 3.11

1st option:

  • poetry shell

2nd option:

  • python -m venv .venv; source .venv/bin/activate
  • pip install -r requirements.txt

Run Phi-2 benchmarks

  • make mlx
  • make mps - for PyTorch on Metal GPU
  • make cpu - for PyTorch on CPU

In order to track CPU/GPU usage, keep make track running while performing operation of interest.

Results on M1 Max (MacOS Sonoma 14.1.1)

Speed Benchmark

MLX resources usage

PyTorch on MPS resources usage

PyTorch on MPS convnet training

Structure

Contributors

mihasK

17 commits

Languages

Jupyter Notebook

89.7%

Python

9.6%