Skip to content

Commit 00fa58a

Browse files
authored
Adding a test to run one benchmark when anything is pushed to the main branch (#744)
## Summary <!--- This is a required section; please describe the main purpose of this proposed code change. ---> Trying to run just the KTO loss for now for testing purposes. It will run after any thing is pushed to the main branch <!--- ## 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
1 parent 4a2da99 commit 00fa58a

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

.github/workflows/benchmark.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Benchmarks
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
# This causes it to cancel previous in-progress actions on the same PR / branch,
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
benchmarks:
15+
runs-on: ubuntu-latest
16+
env:
17+
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
18+
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v3
23+
24+
- name: Set up Python
25+
uses: actions/setup-python@v3
26+
with:
27+
python-version: '3.10'
28+
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install modal
33+
34+
- name: Run benchmarks on GPU
35+
run: |
36+
modal run dev.modal.benchmarks

dev/modal/benchmarks.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from pathlib import Path
2+
3+
import modal
4+
5+
ROOT_PATH = Path(__file__).parent.parent.parent
6+
REMOTE_ROOT_PATH = "/root/liger-kernel"
7+
PYTHON_VERSION = "3.12"
8+
9+
image = modal.Image.debian_slim(python_version=PYTHON_VERSION).pip_install("uv")
10+
11+
app = modal.App("liger_benchmarks", image=image)
12+
13+
# mount: add local files to the remote container
14+
repo = image.add_local_dir(ROOT_PATH, remote_path=REMOTE_ROOT_PATH)
15+
16+
17+
@app.function(gpu="A10G", image=repo, timeout=60 * 45)
18+
def liger_benchmarks():
19+
import subprocess
20+
21+
subprocess.run(
22+
["uv pip install -e '.[dev]' --system"],
23+
check=True,
24+
shell=True,
25+
cwd=REMOTE_ROOT_PATH,
26+
)
27+
subprocess.run(["python benchmark/scripts/benchmark_kto_loss.py"], check=True, shell=True, cwd=REMOTE_ROOT_PATH)

0 commit comments

Comments
 (0)