-
Notifications
You must be signed in to change notification settings - Fork 18
164 lines (149 loc) · 5.51 KB
/
adhoc.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Execute ZKVM-Perf
on:
workflow_dispatch:
inputs:
ami_id:
description: 'AMI ID'
required: true
type: string
default: 'ami-079a6a210557ef0e4'
provers:
description: 'Provers to use (comma-separated)'
required: true
type: string
default: 'sp1,risc0'
programs:
description: 'Programs to benchmark (comma-separated, leave empty for all)'
required: false
type: string
filename:
description: 'Filename for the benchmark'
required: true
default: 'benchmark'
type: string
trials:
description: 'Number of trials to run'
required: true
default: '1'
type: number
hashfns:
description: 'Hash functions to use (comma-separated)'
required: true
type: string
default: 'poseidon'
shard_sizes:
description: 'Shard sizes to use (comma-separated)'
required: true
default: '22'
type: string
sp1_ref:
description: 'SP1 reference (commit hash or branch name)'
required: false
type: string
default: '2e8b0a8'
jobs:
run-benchmarks:
name: Run ZKVM-Perf
runs-on: ubuntu-latest
strategy:
matrix:
instance_config:
- {type: "g6.16xlarge", gpu: true}
- {type: "r7i.16xlarge", gpu: false}
fail-fast: false
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Start EC2 runner
id: "start-ec2-runner"
uses: "xJonathanLEI/ec2-github-runner@main"
with:
mode: start
github-token: ${{ secrets.GH_PAT }}
ec2-image-id: ${{ inputs.ami_id }}
ec2-instance-type: ${{ matrix.instance_config.type }}
subnet-id: ${{ secrets.AWS_SUBNET_ID }}
security-group-id: ${{ secrets.AWS_SG_ID }}
- name: Run benchmarks
uses: actions/github-script@v6
env:
RUNNER_NAME: ${{ steps.start-ec2-runner.outputs.label }}
USE_GPU: ${{ matrix.instance_config.gpu }}
with:
script: |
const runnerName = process.env.RUNNER_NAME;
const useGpu = process.env.USE_GPU === 'true';
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'adhoc.yml',
ref: context.ref,
inputs: {
runner_name: runnerName,
sp1_ref: '${{ inputs.sp1_ref }}',
use_gpu: useGpu.toString(),
provers: '${{ inputs.provers }}',
programs: '${{ inputs.programs }}',
filename: '${{ inputs.filename }}',
trials: '${{ inputs.trials }}',
hashfns: '${{ inputs.hashfns }}',
shard_sizes: '${{ inputs.shard_sizes }}',
},
});
core.info('Triggered benchmark run on EC2 runner');
- name: Wait for benchmarks to complete
run: |
while true; do
status=$(gh run list --workflow=adhoc.yml --json conclusion -q '.[0].conclusion')
if [ "$status" = "success" ] || [ "$status" = "failure" ]; then
break
fi
sleep 60
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Stop EC2 runner
if: always()
uses: machulav/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.GH_PAT }}
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
run-on-ec2:
name: Run Benchmarks on EC2
runs-on: ${{ github.event.inputs.runner_name }}
if: github.event.inputs.runner_name != ''
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Update SP1 reference
run: |
chmod +x update_sp1_and_build.sh
SP1_REF=${{ github.event.inputs.sp1_ref }} RUN_BUILD=false ./update_sp1_and_build.sh
- name: Run docker build
run: |
docker build -t zkvm-perf --platform linux/amd64 -f Dockerfile.gpu --build-arg SP1_REF=${{ github.event.inputs.sp1_ref }} .
- name: Run Tests (docker)
run: |
docker run ${{ github.event.inputs.use_gpu == 'true' && '--gpus all' || '' }} --platform linux/amd64 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ./benchmarks:/usr/src/app/benchmarks \
-e RUST_BACKTRACE=full \
--network host \
zkvm-perf \
"python3 sweep.py --filename ${{ github.event.inputs.filename }} \
--trials ${{ github.event.inputs.trials }} \
${{ github.event.inputs.programs && format('--programs {0}', github.event.inputs.programs) || '' }} \
--provers ${{ github.event.inputs.provers }} \
--hashfns ${{ github.event.inputs.hashfns }} \
--shard-sizes ${{ github.event.inputs.shard_sizes }}"
- name: Print Results
run: |
cat benchmarks/*.csv