Repository navigation
167 lines (160 loc) · 6.61 KB
/
Copy pathBenchmark.yml
File metadata and controls
167 lines (160 loc) · 6.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: GPU Benchmarks
on:
# Pushes to main and to branches of open PRs from this repository are benchmarked.
# Fork PRs never trigger this workflow, so untrusted code cannot reach the GPU runner.
push:
branches:
- "**"
workflow_dispatch:
inputs:
pull_request:
description: PR number of the selected branch (leave empty on main)
required: false
type: string
permissions:
contents: read
pull-requests: read
jobs:
prepare:
name: Prepare benchmarks
runs-on: ubuntu-latest
outputs:
head: ${{ steps.select.outputs.head }}
pr: ${{ steps.select.outputs.pr }}
base: ${{ steps.select.outputs.base }}
steps:
- name: Select the commit to benchmark
id: select
uses: actions/github-script@v9
env:
INPUT_PR: ${{ inputs.pull_request }}
with:
script: |
const repo = context.repo;
const {full_name: fullName, default_branch: defaultBranch} = context.payload.repository;
const branch = context.ref.replace('refs/heads/', '');
const input = process.env.INPUT_PR;
let pr;
if (context.eventName === 'workflow_dispatch') {
// Manual runs benchmark main without a PR number, or a PR from its head branch.
if (branch === defaultBranch) {
if (input) throw new Error('Leave the PR number empty when running on the default branch');
} else {
if (!/^[1-9][0-9]*$/.test(input)) throw new Error('Enter the PR number of the selected branch');
({data: pr} = await github.rest.pulls.get({...repo, pull_number: Number(input)}));
if (pr.head.ref !== branch || pr.head.sha !== context.sha) {
throw new Error(`The selected branch must be the current head of PR #${input}`);
}
}
} else if (branch !== defaultBranch) {
// Pushes to other branches benchmark their open same-repository PR.
const prs = await github.paginate(github.rest.pulls.list, {
...repo,
state: 'open',
head: `${repo.owner}:${branch}`,
per_page: 100
});
pr = prs.find(pr => pr.head.repo?.full_name === fullName);
if (!pr) return;
}
if (pr && (pr.state !== 'open' || pr.draft || pr.head.repo?.full_name !== fullName)) return;
// Respect a skip marker in the commit's title (not its description).
const {data: commit} = await github.rest.repos.getCommit({...repo, ref: context.sha});
if (commit.commit.message.split('\n', 1)[0].includes('[skip benchmarks]')) return;
core.setOutput('head', context.sha);
core.setOutput('pr', pr?.number ?? '');
core.setOutput('base', pr?.base.ref ?? defaultBranch);
benchmark:
name: Run benchmarks
needs: prepare
if: needs.prepare.outputs.head != ''
runs-on: [self-hosted, linux, x64, gpu]
concurrency:
group: gpu-rhs-${{ github.repository }}
queue: max
timeout-minutes: 60
continue-on-error: true
outputs:
complete: ${{ steps.environment.outcome == 'success' }}
baseline: ${{ steps.measure.outputs.baseline }}
env:
BENCHMARK_PR: ${{ needs.prepare.outputs.pr }}
BENCHMARK_BASE_BRANCH: ${{ needs.prepare.outputs.base }}
BENCHMARK_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
BENCHMARK_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
steps:
- name: Check out the measured commit
uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false
- name: Measure the baseline and target performance
id: measure
run: |
nvidia-smi
julia +1.10 --project=benchmark -e 'using Pkg; Pkg.develop(path=pwd()); Pkg.instantiate()'
julia +1.10 --project=benchmark benchmark/runbenchmarks.jl
- name: Upload report and raw measurements
id: results
uses: actions/upload-artifact@v7
with:
name: gpu-rhs-results-${{ needs.prepare.outputs.head }}
path: |
benchmark/results/baseline.json
benchmark/results/target.json
benchmark/results/report.md
if-no-files-found: error
retention-days: 90
overwrite: true
- name: Upload resolved Julia environments
id: environment
uses: actions/upload-artifact@v7
with:
name: gpu-rhs-environment-${{ needs.prepare.outputs.head }}
path: benchmark/results/environments/
if-no-files-found: error
retention-days: 90
overwrite: true
- name: Link artifacts from the report
env:
RESULTS_URL: ${{ steps.results.outputs.artifact-url }}
ENVIRONMENT_URL: ${{ steps.environment.outputs.artifact-url }}
run: |
{
printf '\n[Download report and measurements](%s): ' "$RESULTS_URL"
printf '%s' '`report.md` (full report), `baseline.json` and `target.json` '
printf '%s\n' '(raw timing samples, parameters, and environment details). '
printf '[Download target and baseline environments](%s): ' "$ENVIRONMENT_URL"
printf '%s' '`target/Project.toml`, `target/Manifest.toml`, '
printf '%s' '`baseline/Project.toml`, and `baseline/Manifest.toml` '
printf '%s\n\n' '(the exact resolved Julia environments).'
} >> "$GITHUB_STEP_SUMMARY"
comment:
name: Publish comment
needs: [prepare, benchmark]
if: needs.prepare.outputs.pr != '' && needs.benchmark.outputs.complete == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Check out the comment publisher
uses: actions/checkout@v7
with:
sparse-checkout: .github/scripts
persist-credentials: false
- name: Download benchmark results
uses: actions/download-artifact@v8
with:
name: gpu-rhs-results-${{ needs.prepare.outputs.head }}
path: results
- name: Publish or update bot comment
uses: actions/github-script@v9
env:
PR_NUMBER: ${{ needs.prepare.outputs.pr }}
HEAD_SHA: ${{ needs.prepare.outputs.head }}
BASELINE_SHA: ${{ needs.benchmark.outputs.baseline }}
BASE_BRANCH: ${{ needs.prepare.outputs.base }}
with:
script: |
await require('./.github/scripts/benchmark-comment.js')({github, context});