-
Notifications
You must be signed in to change notification settings - Fork 18
142 lines (126 loc) · 4.57 KB
/
run-on-runner.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
name: Run Benchmarks on EC2 Runner
on:
workflow_dispatch:
inputs:
runner_name:
required: true
type: string
instance_type:
required: true
type: string
enable_gpu:
required: true
type: string
provers:
required: false
type: string
default: 'sp1'
programs:
required: false
type: string
default: 'loop,fibonacci,tendermint,reth1,reth2'
filename:
required: false
type: string
default: 'benchmark'
trials:
required: false
type: string
default: '1'
sp1_ref:
required: false
type: string
additional_params:
required: false
type: string
default: '{"hashfns":"poseidon","shard_sizes":"22"}'
jobs:
run-benchmark:
runs-on: ${{ inputs.runner_name }}
steps:
- name: Echo Workflow Inputs
run: |
echo "Runner Name: ${{ inputs.runner_name }}"
echo "Instance Type: ${{ inputs.instance_type }}"
echo "Enable GPU: ${{ inputs.enable_gpu }}"
echo "Provers: ${{ inputs.provers }}"
echo "Programs: ${{ inputs.programs }}"
echo "Filename: ${{ inputs.filename }}"
echo "Trials: ${{ inputs.trials }}"
echo "SP1 Ref: ${{ inputs.sp1_ref }}"
echo "Additional Params: ${{ inputs.additional_params }}"
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Docker
uses: docker/setup-buildx-action@v2
- name: Parse additional parameters
id: parse-params
run: |
echo 'ADDITIONAL_PARAMS<<EOF' >> $GITHUB_ENV
echo '${{ inputs.additional_params }}' >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Update SP1 Pin
env:
SP1_REF: ${{ inputs.sp1_ref }}
RUN_BUILD: "false"
run: |
chmod +x update_sp1_and_build.sh
./update_sp1_and_build.sh
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build and cache Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.gpu
push: false
load: true
tags: zkvm-perf
build-args: |
SP1_REF=${{ inputs.sp1_ref }}
platforms: linux/amd64
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
# This step is necessary to prevent the cache from growing indefinitely
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
# - name: Build Docker image
# run: |
# docker build -t zkvm-perf --platform linux/amd64 -f Dockerfile.gpu --build-arg SP1_REF=${{ inputs.sp1_ref }} .
- name: Make benchmarks directory
run: mkdir -p ${{ github.workspace }}/benchmarks
- name: Run benchmark
run: |
docker run ${{ inputs.enable_gpu == 'true' && '--gpus all' || '' }} --platform linux/amd64 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ${{ github.workspace }}/benchmarks:/usr/src/app/benchmarks \
-e RUST_BACKTRACE=full \
-e INSTANCE_TYPE=${{ inputs.instance_type }} \
--network host \
zkvm-perf \
"python3 sweep.py --filename ${{ inputs.filename }} --trials ${{ inputs.trials }} --programs $(echo ${{ inputs.programs }} | sed 's/,/ /g') --provers ${{ inputs.provers }} --hashfns ${{ fromJson(env.ADDITIONAL_PARAMS).hashfns }} --shard-sizes ${{ fromJson(env.ADDITIONAL_PARAMS).shard_sizes }}"
- name: List benchmark results
run: ls -la ${{ github.workspace }}/benchmarks
- name: Add instance type to CSV
run: |
for file in ${{ github.workspace }}/benchmarks/*.csv; do
sed -i '1s/^/instance_type,/' "$file"
sed -i "2,\$s/^/${{ inputs.instance_type }},/" "$file"
done
- name: Upload benchmark results
uses: actions/upload-artifact@v3
with:
name: benchmark-results-${{ inputs.instance_type }}-${{ github.run_id }}
path: ${{ github.workspace }}/benchmarks/*.csv
- name: Print Results
run: |
cat ${{ github.workspace }}/benchmarks/*.csv