Execute ZKVM-Perf (Matrix) #1
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 (Matrix) | |
on: | |
workflow_dispatch: | |
inputs: | |
provers: | |
description: 'Provers to use (comma-separated)' | |
required: false | |
type: string | |
default: 'sp1' | |
programs: | |
description: 'Programs to benchmark (comma-separated)' | |
required: false | |
type: string | |
default: 'loop,fibonacci,tendermint,reth1,reth2' | |
filename: | |
description: 'Filename for the benchmark' | |
required: false | |
type: string | |
default: 'benchmark' | |
trials: | |
description: 'Number of trials to run' | |
required: false | |
type: string | |
default: '1' | |
sp1_ref: | |
description: 'SP1 reference (commit hash or branch name)' | |
required: false | |
type: string | |
default: '2e8b0a8' | |
additional_params: | |
description: 'Additional parameters as JSON' | |
required: false | |
type: string | |
default: '{"hashfns":"poseidon","shard_sizes":"22"}' | |
jobs: | |
run-benchmarks: | |
strategy: | |
matrix: | |
include: | |
- instance_type: g6.16xlarge | |
enable_gpu: true | |
ami_id: ami-079a6a210557ef0e4 | |
- instance_type: r7i.16xlarge | |
enable_gpu: false | |
ami_id: ami-079a6a210557ef0e4 | |
name: Run on ${{ matrix.instance_type }} | |
runs-on: ubuntu-latest | |
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: ${{ matrix.ami_id }} | |
ec2-instance-type: ${{ matrix.instance_type }} | |
subnet-id: ${{ secrets.AWS_SUBNET_ID }} | |
security-group-id: ${{ secrets.AWS_SG_ID }} | |
storage-size: 1024 | |
- name: Run benchmarks | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const runnerName = '${{ steps.start-ec2-runner.outputs.label }}'; | |
// Wait for the runner to be ready | |
while (true) { | |
const runners = await github.rest.actions.listSelfHostedRunnersForRepo({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
}); | |
const runner = runners.data.runners.find(r => r.name === runnerName); | |
if (runner && runner.status === 'online') { | |
console.log('Runner is ready'); | |
break; | |
} | |
console.log('Waiting for runner to be ready...'); | |
await new Promise(resolve => setTimeout(resolve, 10000)); | |
} | |
// Trigger the benchmark workflow on the new runner | |
await github.rest.actions.createWorkflowDispatch({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
workflow_id: 'run-on-runner.yml', | |
ref: context.ref, | |
inputs: { | |
runner_name: runnerName, | |
instance_type: '${{ matrix.instance_type }}', | |
enable_gpu: '${{ matrix.enable_gpu }}', | |
provers: '${{ inputs.provers }}', | |
programs: '${{ inputs.programs }}', | |
filename: '${{ inputs.filename }}_${{ matrix.instance_type }}', | |
trials: '${{ inputs.trials }}', | |
sp1_ref: '${{ inputs.sp1_ref }}', | |
additional_params: '${{ inputs.additional_params }}' | |
} | |
}); | |
- name: Wait for benchmark completion | |
run: | | |
while [[ $(gh run list --workflow=run-on-runner.yml --json status --jq '.[] | select(.status=="in_progress") | .status' | wc -l) -gt 0 ]]; do | |
echo "Waiting for benchmark to complete..." | |
sleep 60 | |
done | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Stop EC2 runner | |
if: always() | |
uses: xJonathanLEI/ec2-github-runner@main | |
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 }} |