Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

Coprocessor CPU benchmarks #7

Coprocessor CPU benchmarks

Coprocessor CPU benchmarks #7

# Run fhevm coprocessor benchmarks on a CPU instance and return parsed results to Slab.
name: Coprocessor CPU benchmarks
on:
workflow_dispatch:
inputs:
benchmarks:
description: "Benchmark set"
required: true
type: choice
options:
- "erc20"
- "synthetics"
- "all"
batch_size:
description: "Batch sizes (# FHE operations executed per batch)"
required: true
type: string
default: "5000"
env:
CARGO_TERM_COLOR: always
RESULTS_FILENAME: parsed_benchmark_results_${{ github.sha }}.json
ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
RUST_BACKTRACE: "full"
RUST_MIN_STACK: "8388608"
CHECKOUT_TOKEN: ${{ secrets.REPO_CHECKOUT_TOKEN || secrets.GITHUB_TOKEN }}
jobs:
setup-instance:
name: Setup instance (fhevm-coprocessor-benchmarks-cpu)
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
runner-name: ${{ steps.start-remote-instance.outputs.label }}
steps:
- name: Start remote instance
id: start-remote-instance
uses: zama-ai/slab-github-runner@79939325c3c429837c10d6041e4fd8589d328bac
with:
mode: start
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
slab-url: ${{ secrets.SLAB_BASE_URL }}
job-secret: ${{ secrets.JOB_SECRET }}
backend: aws
profile: bench
fhevm-coprocessor-benchmarks-cpu:
name: Coprocessor CPU benchmarks (hpc7a.96xlarge)
needs: setup-instance
runs-on: ${{ needs.setup-instance.outputs.runner-name }}
concurrency:
group: ${{ github.workflow_ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
continue-on-error: true
timeout-minutes: 720 # 12 hours
permissions:
contents: read
strategy:
fail-fast: false
# explicit include-based build matrix, of known valid options
matrix:
include:
- os: ubuntu-22.04
cuda: "12.2"
gcc: 11
steps:
- name: Install git LFS
run: |
sudo systemctl stop unattended-upgrades
sudo apt-get update
sudo apt-get install -y git-lfs
git lfs install
- name: Checkout fhevm-backend
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
persist-credentials: 'false'
fetch-depth: 0
lfs: true
- name: Checkout LFS objects
run: git lfs checkout
- name: Get benchmark details
run: |
{
echo "BENCH_DATE=$(date --iso-8601=seconds)";
echo "COMMIT_DATE=$(git --no-pager show -s --format=%cd --date=iso8601-strict ${{ github.sha }})";
echo "COMMIT_HASH=$(git describe --tags --dirty)";
} >> "${GITHUB_ENV}"
- name: Install rust
uses: dtolnay/rust-toolchain@888c2e1ea69ab0d4330cbf0af1ecc7b68f368cc1
with:
toolchain: nightly
- name: Install cargo dependencies
run: |
sudo systemctl stop docker
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y protobuf-compiler cmake \
pkg-config libssl-dev \
libclang-dev docker-compose-v2 \
docker.io acl
sudo systemctl start docker
cargo install sqlx-cli
- name: Install foundry
uses: foundry-rs/foundry-toolchain@de808b1eea699e761c404bda44ba8f21aba30b2c
- name: Cache cargo
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Init database
run: make init_db
working-directory: fhevm-engine/coprocessor
- name: Run benchmarks on CPU
run: |
BENCHMARK_BATCH_SIZE="${{ inputs.batch_size }}" make "benchmark_${{ inputs.benchmarks }}_cpu"
working-directory: fhevm-engine/coprocessor
- name: Parse results
run: |
python3 ./ci/benchmark_parser.py fhevm-engine/target/criterion ${{ env.RESULTS_FILENAME }} \
--database coprocessor \
--hardware "hpc7a.96xlarge" \
--backend cpu \
--project-version "${{ env.COMMIT_HASH }}" \
--branch ${{ github.ref_name }} \
--commit-date "${{ env.COMMIT_DATE }}" \
--bench-date "${{ env.BENCH_DATE }}" \
--walk-subdirs \
--name-suffix "operation_batch_size_${{ inputs.batch_size }}"
- name: Upload parsed results artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: ${{ github.sha }}_${{ inputs.benchmarks }}_cpu
path: ${{ env.RESULTS_FILENAME }}
- name: Checkout Slab repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
repository: zama-ai/slab
path: slab
persist-credentials: 'false'
token: ${{ secrets.REPO_CHECKOUT_TOKEN }}
- name: Send data to Slab
shell: bash
run: |
python3 slab/scripts/data_sender.py ${{ env.RESULTS_FILENAME }} "${{ secrets.JOB_SECRET }}" \
--slab-url "${{ secrets.SLAB_URL }}"
teardown-instance:
name: Teardown instance (fhevm-coprocessor-benchmarks-cpu)
if: ${{ always() && needs.setup-instance.result == 'success' }}
needs: [ setup-instance, fhevm-coprocessor-benchmarks-cpu ]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Stop remote instance
id: stop-instance
uses: zama-ai/slab-github-runner@79939325c3c429837c10d6041e4fd8589d328bac
with:
mode: stop
github-token: ${{ secrets.SLAB_ACTION_TOKEN }}
slab-url: ${{ secrets.SLAB_BASE_URL }}
job-secret: ${{ secrets.JOB_SECRET }}
label: ${{ needs.setup-instance.outputs.runner-name }}