Skip to content

Benchmarks

Benchmarks #25

Workflow file for this run

name: Benchmarks
on:
schedule:
# Runs at 00:00 UTC every Friday
- cron: '0 0 * * 5'
workflow_dispatch: # Enables manual trigger
permissions:
contents: write
concurrency:
# This causes it to cancel previous in-progress actions on the same PR / branch,
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
benchmarks:
runs-on: ubuntu-latest
env:
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
GITHUB_USERNAME: linkedin
REPO_NAME: Liger-Kernel
OUTPUT_DIR: benchmarks
OUTPUT_FILENAME: benchmark.csv
GENERATED_CSV: benchmark/data/all_benchmark_data.csv
steps:
- name: Checkout code
uses: actions/checkout@v3
# Get the latest commit hash from main branch
- name: Get commit hash
id: get_hash
run: echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
# Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install modal
pip install pandas
# Delete previous benchmark results.
- name: Remove previous benchmark data
run: |
rm -f benchmark/data/all_benchmark_data.csv
- name: Run benchmarks on GPU
run: |
modal run dev.modal.benchmarks
# Step 5: Checkout gh-pages branch in a subfolderAdd commentMore actions
- name: Checkout gh-pages
uses: actions/checkout@v3
with:
ref: gh-pages
path: gh-pages
# Step 6: Copy benchmark CSV to gh-pages directory
- name: Copy generated benchmark to gh-pages
run: |
mkdir -p gh-pages/${OUTPUT_DIR}/${{ steps.get_hash.outputs.hash }}
cp ${GENERATED_CSV} gh-pages/${OUTPUT_DIR}/${{ steps.get_hash.outputs.hash }}/${OUTPUT_FILENAME}
# Step 7: Append commit hash to commits.txt if not already present
- name: Update commits.txt
run: |
cd gh-pages
echo "commits.txt file path: ${OUTPUT_DIR}/commits.txt"
# Create file if it doesn't exist
mkdir -p ${OUTPUT_DIR}
touch ${OUTPUT_DIR}/commits.txt
# Append only if not already present
if ! grep -q "${{ steps.get_hash.outputs.hash }}" ${OUTPUT_DIR}/commits.txt; then
echo "${{ steps.get_hash.outputs.hash }}" >> ${OUTPUT_DIR}/commits.txt
fi
# Step 7: Commit and push
- name: Commit and push to gh-pages
run: |
cd gh-pages
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git add .
git commit -m "Add benchmark for commit ${{ steps.get_hash.outputs.hash }}" || echo "No changes to commit"
git push origin gh-pages