Skip to content

Commit 99ee856

Browse files
authored
Create basic helion benchmark runner (#544)
1 parent eca6d83 commit 99ee856

File tree

3 files changed

+156
-2
lines changed

3 files changed

+156
-2
lines changed

.github/workflows/benchmark.yml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: Benchmark
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
gpu_type:
7+
description: 'GPU type to run benchmark on'
8+
required: true
9+
type: choice
10+
options:
11+
- 'h100'
12+
- 'b200'
13+
default: 'b200'
14+
15+
jobs:
16+
benchmark:
17+
strategy:
18+
matrix:
19+
include:
20+
- runner: "linux.aws.h100"
21+
python-version: "3.12"
22+
image: "nvidia/cuda:12.9.1-devel-ubuntu24.04"
23+
runtime-version: "cu129"
24+
container-options: "--gpus all"
25+
alias: "h100"
26+
condition: ${{ github.event.inputs.run_h100 == 'true' }}
27+
- runner: "linux.dgx.b200"
28+
python-version: "3.12"
29+
image: "nvidia/cuda:12.9.1-devel-ubuntu24.04"
30+
runtime-version: "cu129"
31+
container-options: "--gpus all"
32+
alias: "b200"
33+
condition: ${{ github.event.inputs.run_b200 == 'true' }}
34+
35+
name: benchmark-${{ matrix.runtime-version }}-py${{ matrix.python-version }}-${{ matrix.alias }}
36+
37+
if: ${{ matrix.condition }}
38+
39+
container:
40+
image: ${{ matrix.image }}
41+
options: ${{ matrix.container-options }}
42+
43+
runs-on: ${{ matrix.runner }}
44+
permissions:
45+
id-token: write
46+
contents: read
47+
48+
defaults:
49+
run:
50+
shell: bash -l {0}
51+
52+
steps:
53+
- name: Check out code
54+
uses: actions/checkout@v4
55+
56+
- name: Install uv
57+
uses: astral-sh/setup-uv@v6
58+
with:
59+
python-version: ${{ matrix.python-version }}
60+
enable-cache: true
61+
62+
- name: Create virtual environment
63+
run: |
64+
uv venv --python ${{ matrix.python-version }}
65+
66+
- name: Install PyTorch
67+
run: |
68+
source .venv/bin/activate
69+
uv pip install -U --pre torch --index-url https://download.pytorch.org/whl/nightly/${{ matrix.runtime-version }}
70+
71+
- name: Install Triton
72+
run: |
73+
set -x
74+
source .venv/bin/activate
75+
apt-get update
76+
apt-get install -y git
77+
apt-get install -y clang-14 clang++-14 zlib1g-dev
78+
export CC=clang-14
79+
export CXX=clang++-14
80+
mkdir -p /tmp/$USER
81+
cd /tmp/$USER
82+
uv pip uninstall triton pytorch-triton || true
83+
rm -rf triton/ || true
84+
git clone https://github.com/triton-lang/triton.git
85+
cd triton/
86+
uv pip install -r python/requirements.txt
87+
MAX_JOBS=$(nproc) TRITON_PARALLEL_LINK_JOBS=2 uv pip install .
88+
cd /tmp/$USER
89+
rm -rf triton/
90+
python -c "import triton; print(f'Triton version: {triton.__version__}')"
91+
92+
- name: Install Helion
93+
run: |
94+
source .venv/bin/activate
95+
uv pip install -r requirements.txt
96+
SETUPTOOLS_SCM_PRETEND_VERSION="0.0.0" uv pip install -e .'[dev]' --no-deps
97+
python -c "import helion; print(helion.__name__)"
98+
99+
- name: Install Benchmark Requirements
100+
run: |
101+
source .venv/bin/activate
102+
uv pip install quack-kernels
103+
mkdir -p benchmarks/ && pushd benchmarks/
104+
git clone https://github.com/pytorch-labs/tritonbench/
105+
pushd tritonbench/
106+
git submodule update --init --recursive
107+
uv pip install -r requirements.txt
108+
python install.py --liger
109+
uv pip install -e .
110+
popd
111+
popd
112+
uv pip install pip
113+
114+
- name: Run Benchmark
115+
run: |
116+
source .venv/bin/activate
117+
118+
TEST_REPORTS_DIR=${{ runner.temp }}/test/test-reports
119+
mkdir -p "$TEST_REPORTS_DIR"
120+
121+
python benchmarks/run.py \
122+
--kernel vector_add,vector_exp,sum \
123+
--num-inputs 3 \
124+
--metrics speedup,accuracy \
125+
--latency-measure-mode inductor_benchmarker \
126+
--output "$TEST_REPORTS_DIR/helionbench.json"
127+
128+
if [[ ! -s "$TEST_REPORTS_DIR/helionbench.json" ]]; then
129+
echo "❌ helionbench.json is missing or empty"
130+
exit 1
131+
fi
132+
cat "$TEST_REPORTS_DIR/helionbench.json"
133+
134+
- name: Authenticate with AWS
135+
if: matrix.alias == 'b200'
136+
uses: aws-actions/configure-aws-credentials@v4
137+
with:
138+
role-to-assume: arn:aws:iam::308535385114:role/gha_workflow_upload-benchmark-results
139+
# The max duration enforced by the server side
140+
role-duration-seconds: 18000
141+
aws-region: us-east-1
142+
143+
- name: Upload the benchmark results to OSS benchmark database for the dashboard
144+
uses: pytorch/test-infra/.github/actions/upload-benchmark-results@main
145+
with:
146+
benchmark-results-dir: ${{ runner.temp }}/test/test-reports
147+
dry-run: false
148+
schema-version: v3
149+
github-token: ${{ secrets.GITHUB_TOKEN }}
150+
venv: ".venv/bin/activate"

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run Tests
1+
name: Tests
22

33
on:
44
pull_request:

benchmarks/run.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,10 @@ def write_results_to_json(output: str, results: list[RunResult]) -> None:
598598
"helion_speedup",
599599
"helion_accuracy",
600600
]:
601+
values = getattr(result, metric_name)
602+
if len(values) == 0:
603+
continue
604+
601605
records.append(
602606
{
603607
"benchmark": {
@@ -611,7 +615,7 @@ def write_results_to_json(output: str, results: list[RunResult]) -> None:
611615
},
612616
"metric": {
613617
"name": metric_name,
614-
"benchmark_values": getattr(result, metric_name),
618+
"benchmark_values": values,
615619
},
616620
}
617621
)

0 commit comments

Comments
 (0)