1+ name : Benchmark v2 Framework
2+
3+ on :
4+ workflow_call :
5+ inputs :
6+ runner :
7+ description : ' GH Actions runner group to use'
8+ required : true
9+ type : string
10+ commit_sha :
11+ description : ' Commit SHA to benchmark'
12+ required : false
13+ type : string
14+ default : ' '
15+ upload_to_hub :
16+ description : ' Uploading results to a HuggingFace Dataset'
17+ required : false
18+ type : string
19+ default : ' false'
20+ run_id :
21+ description : ' Custom run ID for organizing results (auto-generated if not provided)'
22+ required : false
23+ type : string
24+ default : ' '
25+ benchmark_repo_id :
26+ description : ' HuggingFace Dataset to upload results to (e.g., "org/benchmark-results")'
27+ required : false
28+ type : string
29+ default : ' '
30+
31+ env :
32+ HF_HOME : /mnt/cache
33+ TRANSFORMERS_IS_CI : yes
34+ # For gated repositories, we still need to agree to share information on the Hub repo. page in order to get access.
35+ # This token is created under the bot `hf-transformers-bot`.
36+ HF_HUB_READ_TOKEN : ${{ secrets.HF_HUB_READ_TOKEN }}
37+
38+ jobs :
39+ benchmark-v2 :
40+ name : Benchmark v2
41+ runs-on : ${{ inputs.runner }}
42+ if : |
43+ (github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'run-benchmark')) ||
44+ (github.event_name == 'schedule')
45+ container :
46+ image : huggingface/transformers-pytorch-gpu
47+ options : --gpus all --privileged --ipc host --shm-size "16gb"
48+ steps :
49+ - name : Get repo
50+ uses : actions/checkout@v4
51+ with :
52+ ref : ${{ inputs.commit_sha || github.sha }}
53+
54+ - name : Install benchmark dependencies
55+ run : |
56+ python3 -m pip install -r benchmark_v2/requirements.txt
57+
58+ - name : Reinstall transformers in edit mode
59+ run : |
60+ python3 -m pip uninstall -y transformers
61+ python3 -m pip install -e ".[torch]"
62+
63+ - name : Show installed libraries and their versions
64+ run : |
65+ python3 -m pip list
66+ python3 -c "import torch; print(f'PyTorch version: {torch.__version__}')"
67+ python3 -c "import torch; print(f'CUDA available: {torch.cuda.is_available()}')"
68+ python3 -c "import torch; print(f'CUDA device count: {torch.cuda.device_count()}')" || true
69+ nvidia-smi || true
70+
71+ - name : Run benchmark v2
72+ working-directory : benchmark_v2
73+ run : |
74+ echo "Running benchmarks"
75+ python3 run_benchmarks.py \
76+ --commit-id '${{ inputs.commit_sha || github.sha }}' \
77+ --upload-to-hub '${{ inputs.upload_to_hub || false}}' \
78+ --run-id '${{ inputs.run_id }}' \
79+ --benchmark-repo-id '${{ inputs.benchmark_repo_id}}' \
80+ --log-level INFO
81+ env :
82+ HF_TOKEN : ${{ secrets.HF_HUB_READ_TOKEN }}
0 commit comments