Skip to content

Commit 00ce868

Browse files
authored
Merge pull request #30 from SharpAI/feature/ci-benchmarks
feat: Add dedicated GitHub Actions Performance Benchmarking workflow
2 parents 6ad2d01 + 2801d68 commit 00ce868

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

.github/workflows/benchmark.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Performance Benchmark
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
model_id:
7+
description: 'HuggingFace Model ID (must be ungated and fit in 7GB RAM)'
8+
required: true
9+
default: 'mlx-community/gemma-4-e4b-it-4bit'
10+
contexts:
11+
description: 'Comma separated context lengths'
12+
required: true
13+
default: '512,1024,4096'
14+
use_ssd_stream:
15+
description: 'Enable SSD Expert Streaming'
16+
type: boolean
17+
required: false
18+
default: false
19+
20+
jobs:
21+
benchmark:
22+
runs-on: macos-15
23+
timeout-minutes: 60
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
submodules: recursive
28+
29+
- name: Install Metal Toolchain
30+
run: xcodebuild -downloadComponent MetalToolchain || true
31+
32+
- name: Cache Swift packages
33+
uses: actions/cache@v4
34+
with:
35+
path: .build
36+
key: ${{ runner.os }}-spm-SwiftLM-v2-${{ hashFiles('Package.resolved') }}
37+
restore-keys: |
38+
${{ runner.os }}-spm-SwiftLM-v2-
39+
40+
- name: Resolve dependencies
41+
run: swift package resolve
42+
43+
- name: Build (Release)
44+
run: swift build -c release
45+
46+
- name: Install MLX Metal library & Profiling Dependencies
47+
run: |
48+
python3 -m venv /tmp/mlx_venv
49+
/tmp/mlx_venv/bin/pip install --quiet mlx psutil requests
50+
cp /tmp/mlx_venv/lib/python*/site-packages/mlx/lib/mlx.metallib .build/release/
51+
52+
- name: Cache MLX models
53+
uses: actions/cache@v4
54+
with:
55+
path: ~/.cache/huggingface
56+
key: mlx-benchmark-model-${{ github.event.inputs.model_id }}
57+
58+
- name: Run Benchmark Script
59+
env:
60+
HF_HUB_DOWNLOAD_TIMEOUT: "900"
61+
run: |
62+
EXTRA_FLAGS=""
63+
if [ "${{ github.event.inputs.use_ssd_stream }}" = "true" ]; then
64+
EXTRA_FLAGS="--ssd-only"
65+
echo "Enabled SSD Streaming mode"
66+
fi
67+
68+
# Use the environment Python that has the pip dependencies
69+
source /tmp/mlx_venv/bin/activate
70+
71+
python3 -u scripts/profiling/profile_runner.py \
72+
--model "${{ github.event.inputs.model_id }}" \
73+
--contexts "${{ github.event.inputs.contexts }}" \
74+
$EXTRA_FLAGS \
75+
--out "./github-action-benchmark.md"
76+
77+
- name: Upload Benchmark Results
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: benchmark-results
81+
path: ./github-action-benchmark.md
82+
retention-days: 7

0 commit comments

Comments
 (0)