-
Notifications
You must be signed in to change notification settings - Fork 18
147 lines (132 loc) · 4.88 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
143
144
145
146
147
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:
name: Run Benchmark on ${{ inputs.runner_name }}
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@v3
- 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: 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: rust-cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
~/.rustup/
key: rust-1.79.0-${{ hashFiles('**/Cargo.toml') }}
restore-keys: rust-1.79.0-
- 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 \
-v ~/.cargo/registry:/root/.cargo/registry \
-v ~/.cargo/git:/root/.cargo/git \
-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 and SP1 ref to CSV
run: |
for file in ${{ github.workspace }}/benchmarks/*.csv; do
sed -i '1s/^/instance_type,sp1_ref,/' "$file"
sed -i "2,\$s|^|${{ inputs.instance_type }},${{ inputs.sp1_ref }},|" "$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