-
Notifications
You must be signed in to change notification settings - Fork 18
207 lines (191 loc) · 6.49 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
name: PR
on:
workflow_dispatch:
inputs:
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
programs:
description: 'Programs to benchmark'
required: true
type: choice
options:
- loop
- fibonacci
- tendermint
- reth1
- reth2
provers:
description: 'Provers to use'
required: true
type: choice
options:
- sp1
- risc0
hashfns:
description: 'Hash functions to use'
required: true
type: choice
options:
- poseidon
shard_sizes:
description: 'Shard sizes to use'
required: true
default: '22'
type: string
block_1:
description: 'Block number for reth1'
required: true
default: '17106222'
type: string
block_2:
description: 'Block number for reth2'
required: true
default: '19409768'
type: string
instance_type:
description: 'Instance type'
required: true
type: choice
default: 'g6.4xlarge'
options:
- g6.16xlarge
- g6.8xlarge
- g6.4xlarge
- g6.2xlarge
ami_id:
description: 'AMI ID'
required: true
type: string
default: 'ami-079a6a210557ef0e4'
pull_request:
branches: [main]
jobs:
start-runner:
name: Start Self-Hosted EC2 Runner
runs-on: "ubuntu-latest"
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
# Use an access key for an IAM user with these permissions:
# - ec2:RunInstances
# - ec2:TerminateInstances
# - ec2:DescribeInstances
# - ec2:DescribeInstanceStatus
- 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"
# Must use personal access token here as `GITHUB_TOKEN` does not have access to runners.
# Use a fine-grained token with these permissions to at least this repository:
# - Administration: Read and write
# - Contents: Read and write
# - Metadata: Read-only
# - Workflows: Read and write
github-token: "${{ secrets.GH_PAT }}"
ec2-image-id: "${{ inputs.ami_id }}"
ec2-instance-type: "${{ inputs.instance_type || 'g6.4xlarge' }}"
# Use a subnet in the default VPC
subnet-id: "${{ secrets.AWS_SUBNET_ID }}"
# Use a security group attached to the default VPC
security-group-id: "${{ secrets.AWS_SG_ID }}"
storage-size: 1024
perf:
name: Run ZKVM-Perf
runs-on: "${{ needs.start-runner.outputs.label }}"
needs:
- "start-runner"
env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
steps:
- name: Checkout sources
uses: actions/checkout@v4
# - name: Setup Self-Hosted Runner
# uses: ./.github/actions/self-hosted
- 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-
# Commented out because the latency of the docker buildx cache is high enough
# with the EC2 builder that it's a wash. Can be added back in if the toolchain gets complex.
# - 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.toolchain
# push: false
# load: true
# tags: moongate-toolchain:latest
# 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: Run docker build
run: |
docker build -t zkvm-perf --platform linux/amd64 -f Dockerfile.gpu .
# we need to run cargo test --release in the docker container
- name: Run Tests (docker)
run: |
docker run --gpus all -it --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 ${{ inputs.filename }} --trials ${{ inputs.trials }} --programs ${{ inputs.programs }} --provers ${{ inputs.provers }} --hashfns ${{ inputs.hashfns }} --shard-sizes ${{ inputs.shard_sizes }} --block-1 ${{ inputs.block_1 }} --block-2 ${{ inputs.block_2 }}"
stop-runner:
name: Stop Self-Hosted EC2 Runner
runs-on: "ubuntu-latest"
needs:
- "start-runner"
- "perf"
if: ${{ always() }}
steps:
- 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: Stop EC2 runner
uses: "xJonathanLEI/ec2-github-runner@main"
with:
mode: "stop"
github-token: ${{ secrets.GH_PAT }}
label: "${{ needs.start-runner.outputs.label }}"
ec2-instance-id: "${{ needs.start-runner.outputs.ec2-instance-id }}"