Skip to content

Commit 93d2a90

Browse files
committed
WIP benchmark v2 workflow
1 parent 5c40e7a commit 93d2a90

File tree

2 files changed

+175
-0
lines changed

2 files changed

+175
-0
lines changed

.github/workflows/benchmark_v2.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Benchmark v2 Framework
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
model_id:
7+
description: 'Model ID to benchmark (e.g., meta-llama/Llama-2-7b-hf)'
8+
required: false
9+
type: string
10+
default: ''
11+
warmup_iterations:
12+
description: 'Number of warmup iterations'
13+
required: false
14+
type: number
15+
default: 3
16+
measurement_iterations:
17+
description: 'Number of measurement iterations'
18+
required: false
19+
type: number
20+
default: 5
21+
num_tokens_to_generate:
22+
description: 'Number of tokens to generate'
23+
required: false
24+
type: number
25+
default: 100
26+
commit_sha:
27+
description: 'Commit SHA to benchmark'
28+
required: false
29+
type: string
30+
default: ''
31+
32+
env:
33+
HF_HOME: /mnt/cache
34+
TRANSFORMERS_IS_CI: yes
35+
# For gated repositories, we still need to agree to share information on the Hub repo. page in order to get access.
36+
# This token is created under the bot `hf-transformers-bot`.
37+
HF_HUB_READ_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }}
38+
39+
jobs:
40+
benchmark-v2:
41+
name: Benchmark v2
42+
strategy:
43+
matrix:
44+
# Use GPU-enabled runners for accurate benchmarking
45+
group: [aws-g5-4xlarge-cache]
46+
runs-on:
47+
group: ${{ matrix.group }}
48+
container:
49+
image: huggingface/transformers-pytorch-gpu
50+
options: --gpus all --privileged --ipc host --shm-size "16gb"
51+
steps:
52+
- name: Get repo
53+
uses: actions/checkout@v4
54+
with:
55+
ref: ${{ inputs.commit_sha || github.sha }}
56+
57+
- name: Update clone
58+
if: inputs.commit_sha
59+
run: |
60+
git fetch && git checkout ${{ inputs.commit_sha }}
61+
62+
- name: Install benchmark dependencies
63+
working-directory: benchmark_v2
64+
run: |
65+
python3 -m pip install -r requirements.txt
66+
67+
- name: Reinstall transformers in edit mode
68+
run: |
69+
python3 -m pip uninstall -y transformers
70+
python3 -m pip install -e ".[torch]"
71+
72+
- name: Show installed libraries and their versions
73+
run: |
74+
python3 -m pip list
75+
python3 -c "import torch; print(f'PyTorch version: {torch.__version__}')"
76+
python3 -c "import torch; print(f'CUDA available: {torch.cuda.is_available()}')"
77+
python3 -c "import torch; print(f'CUDA device count: {torch.cuda.device_count()}')" || true
78+
nvidia-smi || true
79+
80+
- name: Prepare benchmark arguments
81+
id: prepare-args
82+
run: |
83+
args="--log-level INFO"
84+
85+
# Add model ID if specified
86+
if [ -n "${{ inputs.model_id }}" ]; then
87+
args="$args --model-id '${{ inputs.model_id }}'"
88+
fi
89+
90+
# Add iterations
91+
args="$args --warmup-iterations ${{ inputs.warmup_iterations }}"
92+
args="$args --measurement-iterations ${{ inputs.measurement_iterations }}"
93+
args="$args --num-tokens-to-generate ${{ inputs.num_tokens_to_generate }}"
94+
95+
# Add commit ID if available
96+
if [ -n "${{ inputs.commit_sha }}" ]; then
97+
args="$args --commit-id '${{ inputs.commit_sha }}'"
98+
elif [ -n "${{ github.sha }}" ]; then
99+
args="$args --commit-id '${{ github.sha }}'"
100+
fi
101+
102+
echo "benchmark_args=$args" >> $GITHUB_OUTPUT
103+
echo "Benchmark arguments: $args"
104+
105+
- name: Run benchmark v2
106+
working-directory: benchmark_v2
107+
run: |
108+
echo "Running benchmark with args: ${{ steps.prepare-args.outputs.benchmark_args }}"
109+
python3 run_benchmarks.py ${{ steps.prepare-args.outputs.benchmark_args }}
110+
env:
111+
HF_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Benchmark v2 Scheduled Runner
2+
3+
on:
4+
schedule:
5+
# Run daily at 2:30 AM UTC
6+
- cron: "30 2 * * *"
7+
push:
8+
branches:
9+
- run_nvidia_benchmark*
10+
workflow_dispatch:
11+
inputs:
12+
model_id:
13+
description: 'Model ID to benchmark (leave empty for default models)'
14+
required: false
15+
type: string
16+
default: ''
17+
warmup_iterations:
18+
description: 'Number of warmup iterations'
19+
required: false
20+
type: number
21+
default: 3
22+
measurement_iterations:
23+
description: 'Number of measurement iterations'
24+
required: false
25+
type: number
26+
default: 5
27+
num_tokens_to_generate:
28+
description: 'Number of tokens to generate'
29+
required: false
30+
type: number
31+
default: 100
32+
include_benchmarks:
33+
description: 'Benchmarks to include (comma-separated, e.g., "llama")'
34+
required: false
35+
type: string
36+
default: ''
37+
exclude_benchmarks:
38+
description: 'Benchmarks to exclude (comma-separated)'
39+
required: false
40+
type: string
41+
default: ''
42+
enable_file_logging:
43+
description: 'Enable file logging'
44+
required: false
45+
type: boolean
46+
default: false
47+
repository_dispatch:
48+
types: [benchmark_v2_trigger]
49+
50+
jobs:
51+
benchmark-v2-default:
52+
name: Benchmark v2 - Default Models
53+
uses: ./.github/workflows/benchmark_v2.yml
54+
with:
55+
model_id: ${{ inputs.model_id || '' }}
56+
warmup_iterations: ${{ inputs.warmup_iterations || 3 }}
57+
measurement_iterations: ${{ inputs.measurement_iterations || 5 }}
58+
num_tokens_to_generate: ${{ inputs.num_tokens_to_generate || 100 }}
59+
include_benchmarks: ${{ inputs.include_benchmarks || '' }}
60+
exclude_benchmarks: ${{ inputs.exclude_benchmarks || '' }}
61+
enable_file_logging: ${{ inputs.enable_file_logging || false }}
62+
slack_report_channel: '#transformers-ci-benchmark-v2'
63+
commit_sha: ${{ github.sha }}
64+
secrets: inherit

0 commit comments

Comments
 (0)