Skip to content

Commit fc8fd33

Browse files
Manan17Manan Shahvaibhavjindal
authored
Giving an option to update benchmark results for previous commits. (#791)
## Summary <!--- This is a required section; please describe the main purpose of this proposed code change. ---> This pr does two things: 1) Making H100 a strict requirement 2) It gives an option to run benchmarks for any commit manually but with the current (latest ie from main branch) benchmark scripts. This will help us get accurate benchmarks results for previous commits after the benchmark scripts are updated (merge this after the new benchmark scripts are merged). <!--- ## Details This is an optional section; is there anything specific that reviewers should be aware of? ---> ## Testing Done <!--- This is a required section; please describe how this change was tested. ---> <!-- Replace BLANK with your device type. For example, A100-80G-PCIe Complete the following tasks before sending your PR, and replace `[ ]` with `[x]` to indicate you have done them. --> - Hardware Type: <BLANK> - [ ] run `make test` to ensure correctness - [ ] run `make checkstyle` to ensure code style - [ ] run `make test-convergence` to ensure convergence --------- Co-authored-by: Manan Shah <[email protected]> Co-authored-by: Vaibhav Jindal <[email protected]>
1 parent 804f0d5 commit fc8fd33

File tree

2 files changed

+79
-14
lines changed

2 files changed

+79
-14
lines changed

.github/workflows/benchmark.yml

Lines changed: 78 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ on:
55
# Runs at 00:00 UTC every Friday
66
- cron: '0 0 * * 5'
77
workflow_dispatch: # Enables manual trigger
8+
inputs:
9+
commit_hash:
10+
description: 'Commit hash to benchmark'
11+
default: 'main'
12+
overwrite:
13+
description: 'Overwrite existing benchmark data if it exists'
14+
type: boolean
15+
default: false
816

917
permissions:
1018
contents: write
@@ -28,13 +36,64 @@ jobs:
2836

2937

3038
steps:
31-
- name: Checkout code
39+
# Step: Decide the commit hash to use
40+
- name: Determine commit hash to checkout
41+
id: choose_commit
42+
run: |
43+
if [ "${{ github.event.inputs.commit_hash }}" != "" ]; then
44+
echo "Using manual input commit: ${{ github.event.inputs.commit_hash }}"
45+
echo "hash=${{ github.event.inputs.commit_hash }}" >> $GITHUB_OUTPUT
46+
else
47+
echo "Using latest commit from main"
48+
git fetch origin main
49+
echo "hash=$(git rev-parse origin/main)" >> $GITHUB_OUTPUT
50+
fi
51+
52+
# Step: Checkout full history so we can check out any commit
53+
- name: Checkout full repo history
3254
uses: actions/checkout@v3
55+
with:
56+
fetch-depth: 0 # Important: so we can checkout arbitrary commit
57+
# Step: Conditionally replace benchmark folder from main
58+
- name: Replace benchmark folder from main (manual only, commit ≠ main)
59+
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.commit_hash != 'main' }}
60+
run: |
61+
echo "Detected manual trigger with commit_hash = ${{ github.event.inputs.commit_hash }}"
62+
63+
# Save current branch (detached HEAD at old commit)
64+
ORIG_COMMIT=${{ github.event.inputs.commit_hash }}
65+
66+
# Fetch and checkout main
67+
git fetch origin main
68+
git checkout origin/main -- benchmark/
69+
70+
# Save benchmark folder from main
71+
cp -r benchmark /tmp/benchmark_main
72+
73+
# Checkout back to target commit
74+
git checkout $ORIG_COMMIT
3375
34-
# Get the latest commit hash from main branch
35-
- name: Get commit hash
36-
id: get_hash
37-
run: echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
76+
# Replace old benchmark with one from main
77+
rm -rf benchmark
78+
cp -r /tmp/benchmark_main benchmark
79+
80+
# Step: Check if benchmark exists and exit if overwrite is false
81+
- name: Check existing benchmark
82+
run: |
83+
COMMIT_HASH="${{ steps.choose_commit.outputs.hash }}"
84+
BENCHMARK_URL="https://raw.githubusercontent.com/linkedin/Liger-Kernel/refs/heads/gh-pages/benchmarks/${COMMIT_HASH}/benchmark.csv"
85+
86+
if curl --output /dev/null --silent --head --fail "$BENCHMARK_URL"; then
87+
echo "Benchmark already exists for commit $COMMIT_HASH"
88+
if [ "${{ github.event.inputs.overwrite }}" != "true" ]; then
89+
echo "Overwrite is false - exiting"
90+
exit 1
91+
else
92+
echo "Overwrite is true - proceeding"
93+
fi
94+
else
95+
echo "No existing benchmark found - proceeding"
96+
fi
3897
3998
- name: Set up Python
4099
uses: actions/setup-python@v3
@@ -46,7 +105,6 @@ jobs:
46105
run: |
47106
python -m pip install --upgrade pip
48107
pip install modal
49-
pip install pandas
50108
51109
# Delete previous benchmark results.
52110
- name: Remove previous benchmark data
@@ -67,8 +125,16 @@ jobs:
67125
# Step 6: Copy benchmark CSV to gh-pages directory
68126
- name: Copy generated benchmark to gh-pages
69127
run: |
70-
mkdir -p gh-pages/${OUTPUT_DIR}/${{ steps.get_hash.outputs.hash }}
71-
cp ${GENERATED_CSV} gh-pages/${OUTPUT_DIR}/${{ steps.get_hash.outputs.hash }}/${OUTPUT_FILENAME}
128+
COMMIT_DIR="gh-pages/${OUTPUT_DIR}/${{ steps.choose_commit.outputs.hash }}"
129+
mkdir -p "$COMMIT_DIR"
130+
131+
if [ -f "$COMMIT_DIR/${OUTPUT_FILENAME}" ]; then
132+
echo "Removing existing benchmark.csv for this commit"
133+
rm "$COMMIT_DIR/${OUTPUT_FILENAME}"
134+
fi
135+
136+
cp "${GENERATED_CSV}" "$COMMIT_DIR/${OUTPUT_FILENAME}"
137+
72138
# Step 7: Append commit hash to commits.txt if not already present
73139
- name: Update commits.txt
74140
run: |
@@ -77,17 +143,16 @@ jobs:
77143
# Create file if it doesn't exist
78144
mkdir -p ${OUTPUT_DIR}
79145
touch ${OUTPUT_DIR}/commits.txt
80-
# Append only if not already present
81-
if ! grep -q "${{ steps.get_hash.outputs.hash }}" ${OUTPUT_DIR}/commits.txt; then
82-
echo "${{ steps.get_hash.outputs.hash }}" >> ${OUTPUT_DIR}/commits.txt
83-
fi
146+
147+
echo "${{ steps.choose_commit.outputs.hash }}" >> ${OUTPUT_DIR}/commits.txt
148+
echo "Added commit hash to commits.txt"
84149
# Step 7: Commit and push
85150
- name: Commit and push to gh-pages
86151
run: |
87152
cd gh-pages
88153
git config user.name github-actions[bot]
89154
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
90155
git add .
91-
git commit -m "Add benchmark for commit ${{ steps.get_hash.outputs.hash }}" || echo "No changes to commit"
156+
git commit -m "Add benchmark for commit ${{ steps.choose_commit.outputs.hash }}" || echo "No changes to commit"
92157
git push origin gh-pages
93158

dev/modal/benchmarks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
repo = image.add_local_dir(ROOT_PATH, remote_path=REMOTE_ROOT_PATH)
1515

1616

17-
@app.function(gpu=["H100"], image=repo, timeout=60 * 90)
17+
@app.function(gpu="H100!", image=repo, timeout=60 * 90)
1818
def liger_benchmarks():
1919
import os
2020
import subprocess

0 commit comments

Comments
 (0)