|
1 | 1 | name: Self-hosted runner (benchmark) |
2 | 2 |
|
3 | 3 | on: |
4 | | - schedule: |
5 | | - - cron: "17 2 * * *" |
6 | | - workflow_call: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + types: [ opened, labeled, reopened, synchronize ] |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 11 | + cancel-in-progress: true |
7 | 12 |
|
8 | 13 | env: |
9 | 14 | HF_HOME: /mnt/cache |
10 | | - TF_FORCE_GPU_ALLOW_GROWTH: true |
11 | | - |
12 | 15 |
|
13 | 16 | jobs: |
14 | 17 | benchmark: |
15 | 18 | name: Benchmark |
16 | | - runs-on: |
| 19 | + runs-on: |
17 | 20 | group: aws-g5-4xlarge-cache |
18 | 21 | container: |
19 | | - image: huggingface/transformers-all-latest-gpu |
20 | | - options: --gpus all --privileged --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/ |
| 22 | + image: huggingface/transformers-pytorch-gpu |
| 23 | + options: --gpus all --privileged --ipc host |
21 | 24 | steps: |
22 | | - - name: Update clone |
23 | | - working-directory: /transformers |
| 25 | + - name: Get repo |
| 26 | + if: github.event_name == 'pull_request' |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + ref: ${{ github.event.pull_request.head.sha }} |
| 30 | + |
| 31 | + - name: Get repo |
| 32 | + if: github.event_name == 'push' |
| 33 | + uses: actions/checkout@v4 |
| 34 | + with: |
| 35 | + ref: ${{ github.sha }} |
| 36 | + |
| 37 | + - name: Install libpq-dev & psql |
24 | 38 | run: | |
25 | | - git fetch && git checkout ${{ github.sha }} |
| 39 | + apt update |
| 40 | + apt install -y libpq-dev postgresql-client |
| 41 | +
|
| 42 | + - name: Install benchmark script dependencies |
| 43 | + run: python3 -m pip install -r benchmark/requirements.txt |
26 | 44 |
|
27 | 45 | - name: Reinstall transformers in edit mode (remove the one installed during docker image build) |
28 | 46 | working-directory: /transformers |
29 | | - run: python3 -m pip uninstall -y transformers && python3 -m pip install -e . |
| 47 | + run: python3 -m pip uninstall -y transformers && python3 -m pip install -e ".[torch]" |
30 | 48 |
|
31 | | - - name: Benchmark (daily) |
32 | | - if: github.event_name == 'schedule' |
33 | | - working-directory: /transformers |
| 49 | + - name: Run database init script |
34 | 50 | run: | |
35 | | - python3 -m pip install optimum-benchmark>=0.3.0 |
36 | | - HF_TOKEN=${{ secrets.TRANSFORMERS_BENCHMARK_TOKEN }} python3 benchmark/benchmark.py --repo_id hf-internal-testing/benchmark_results --path_in_repo $(date +'%Y-%m-%d') --config-dir benchmark/config --config-name generation --commit=${{ github.sha }} backend.model=google/gemma-2b backend.cache_implementation=null,static backend.torch_compile=false,true --multirun |
| 51 | + psql -f benchmark/init_db.sql |
| 52 | + env: |
| 53 | + PGDATABASE: metrics |
| 54 | + PGHOST: ${{ secrets.TRANSFORMERS_BENCHMARKS_PGHOST }} |
| 55 | + PGUSER: transformers_benchmarks |
| 56 | + PGPASSWORD: ${{ secrets.TRANSFORMERS_BENCHMARKS_PGPASSWORD }} |
37 | 57 |
|
38 | | - - name: Benchmark (merged to main event) |
39 | | - if: github.event_name == 'push' && github.ref_name == 'main' |
40 | | - working-directory: /transformers |
| 58 | + - name: Run benchmark |
41 | 59 | run: | |
42 | | - python3 -m pip install optimum-benchmark>=0.3.0 |
43 | | - HF_TOKEN=${{ secrets.TRANSFORMERS_BENCHMARK_TOKEN }} python3 benchmark/benchmark.py --repo_id hf-internal-testing/benchmark_results_merge_event --path_in_repo $(date +'%Y-%m-%d') --config-dir benchmark/config --config-name generation --commit=${{ github.sha }} backend.model=google/gemma-2b backend.cache_implementation=null,static backend.torch_compile=false,true --multirun |
| 60 | + git config --global --add safe.directory /__w/transformers/transformers |
| 61 | + if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then |
| 62 | + commit_id=$(echo "${{ github.event.pull_request.head.sha }}") |
| 63 | + elif [ "$GITHUB_EVENT_NAME" = "push" ]; then |
| 64 | + commit_id=$GITHUB_SHA |
| 65 | + fi |
| 66 | + commit_msg=$(git show -s --format=%s | cut -c1-70) |
| 67 | + python3 benchmark/llama.py "${{ github.head_ref || github.ref_name }}" "$commit_id" "$commit_msg" |
| 68 | + env: |
| 69 | + HF_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }} |
| 70 | + PGHOST: ${{ secrets.TRANSFORMERS_BENCHMARKS_PGHOST }} |
| 71 | + PGUSER: transformers_benchmarks |
| 72 | + PGPASSWORD: ${{ secrets.TRANSFORMERS_BENCHMARKS_PGPASSWORD }} |
0 commit comments