Execute ZKVM-Perf #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Execute ZKVM-Perf | |
on: | |
workflow_dispatch: | |
inputs: | |
instance_type: | |
description: 'Instance type' | |
required: true | |
type: choice | |
default: 'g6.16xlarge' | |
options: | |
- g6.16xlarge | |
- r7i.16xlarge | |
enable_gpu: | |
description: 'Enable GPU usage' | |
required: true | |
type: boolean | |
default: true | |
ami_id: | |
description: 'AMI ID' | |
required: true | |
type: string | |
default: 'ami-079a6a210557ef0e4' | |
provers: | |
description: 'Provers to use' | |
required: true | |
type: choice | |
options: | |
- sp1 | |
- risc0 | |
programs: | |
description: 'Programs to benchmark' | |
required: true | |
type: choice | |
options: | |
- loop | |
- fibonacci | |
- tendermint | |
- reth1 | |
- reth2 | |
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' | |
required: true | |
type: choice | |
options: | |
- poseidon | |
shard_sizes: | |
description: 'Shard sizes to use' | |
required: true | |
default: '22' | |
type: string | |
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: | |
- 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 || 'ami-079a6a210557ef0e4' }}" | |
ec2-instance-type: "${{ inputs.instance_type || 'g6.4xlarge' }}" | |
subnet-id: "${{ secrets.AWS_SUBNET_ID }}" | |
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: 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 docker build | |
run: | | |
docker build -t zkvm-perf --platform linux/amd64 -f Dockerfile.gpu . | |
- name: Run Tests (docker) | |
run: | | |
docker run ${{ inputs.enable_gpu && '--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 ${{ inputs.filename || 'benchmark' }} --trials ${{ inputs.trials || '1' }} --programs ${{ inputs.programs || 'loop' }} --provers ${{ inputs.provers || 'sp1' }} --hashfns ${{ inputs.hashfns || 'poseidon' }} --shard-sizes ${{ inputs.shard_sizes || '22' }}" | |
- name: Print Results | |
run: | | |
cat benchmarks/*.csv | |
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 }}" |