Repository navigation
124 lines (109 loc) · 5.21 KB
/
Copy pathbenchmark-pr-comment.yml
File metadata and controls
124 lines (109 loc) · 5.21 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
name: vs NumPy PR comment
env:
VJOBS: '2'
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
branches: [main]
paths:
- 'benchmarks/**/*.v'
- 'benchmarks/**/*.py'
- '*.v'
- 'nn/**/*.v'
- 'autograd/**/*.v'
- 'datasets/**/*.v'
- 'ml/**/*.v'
- 'la/**/*.v'
- 'stats/**/*.v'
- 'fft/**/*.v'
- 'storage/**/*.v'
- 'npy/**/*.v'
- 'npz/**/*.v'
- '.github/workflows/benchmark-pr-comment.yml'
permissions:
contents: read
pull-requests: write
jobs:
comment:
runs-on: ubuntu-24.04
env:
VJOBS: '2'
steps:
- uses: actions/checkout@v4
with:
path: vtl
- name: Checkout VSL
uses: actions/checkout@v4
with:
repository: vlang/vsl
path: vsl
- uses: vlang/setup-v@663cc08827d1fc0532ee755b4dedbb183c11d06a # v1.7
with:
version: ba41fa121b738a1a694e0050401a45d2376e09b9
- name: Install deps
run: |
sudo apt-get update -qq
sudo apt-get install -qq -y libopenblas-dev liblapacke-dev gfortran python3 python3-numpy
- name: Test benchmark report helpers
run: python3 -m unittest discover -s vtl/benchmarks/vs_numpy -p 'test_*.py'
- name: Install module
run: |
mkdir -p ~/.vmodules
cp -rf ./vsl ~/.vmodules/vsl
cp -rf ./vtl ~/.vmodules/vtl
- name: Run vs NumPy harness
run: |
set -euo pipefail
cd ~/.vmodules
report_file="$GITHUB_WORKSPACE/vs_numpy_pr.md"
run_v_benchmark() {
local name="$1"
local source="$2"
shift 2
local binary="/tmp/${name}"
env HOME="$HOME" PATH="$PATH" VJOBS=2 OPENBLAS_NUM_THREADS=2 v -no-parallel -cc gcc -prod \
-cflags "-march=native" "$@" -o "$binary" "$source"
env HOME="$HOME" PATH="$PATH" VJOBS=2 OPENBLAS_NUM_THREADS=2 "$binary"
}
{
echo '## VTL vs NumPy (CPU matmul via VSL CBLAS)'
run_v_benchmark vtl-matmul vtl/benchmarks/vs_numpy/matmul_bench.v -d vsl_blas_cblas
env HOME="$HOME" PATH="$PATH" VJOBS=2 OPENBLAS_NUM_THREADS=2 python3 vtl/benchmarks/vs_numpy/numpy_matmul_baseline.py
env HOME="$HOME" PATH="$PATH" VJOBS=2 OPENBLAS_NUM_THREADS=2 python3 vtl/benchmarks/vs_numpy/numpy_matmul_f32_end_to_end.py
echo '## Conv2D CPU vs NumPy'
run_v_benchmark vtl-conv2d vtl/benchmarks/vs_numpy/conv2d_bench.v
env HOME="$HOME" PATH="$PATH" VJOBS=2 OPENBLAS_NUM_THREADS=2 python3 vtl/benchmarks/vs_numpy/numpy_conv2d_baseline.py
echo '## Reduced SVD vs NumPy'
run_v_benchmark vtl-svd-purev vtl/benchmarks/vs_numpy/svd_bench.v
run_v_benchmark vtl-svd-lapacke vtl/benchmarks/vs_numpy/svd_bench.v -d vsl_lapack_lapacke
env HOME="$HOME" PATH="$PATH" VJOBS=2 OPENBLAS_NUM_THREADS=2 python3 vtl/benchmarks/vs_numpy/numpy_svd_baseline.py
echo '## Contiguous sum and mean'
run_v_benchmark vtl-stats vtl/benchmarks/vs_numpy/stats_bench.v
env HOME="$HOME" PATH="$PATH" VJOBS=2 OPENBLAS_NUM_THREADS=2 python3 vtl/benchmarks/vs_numpy/numpy_stats_baseline.py
echo '## Cumulative sum and product'
run_v_benchmark vtl-cumulative vtl/benchmarks/vs_numpy/cumulative_bench.v
env HOME="$HOME" PATH="$PATH" VJOBS=2 OPENBLAS_NUM_THREADS=2 python3 vtl/benchmarks/vs_numpy/numpy_cumulative_baseline.py
echo '## Mixed-dtype integer remainder'
run_v_benchmark vtl-promoted-remainder vtl/benchmarks/vs_numpy/promoted_remainder_bench.v
env HOME="$HOME" PATH="$PATH" VJOBS=2 OPENBLAS_NUM_THREADS=2 python3 vtl/benchmarks/vs_numpy/numpy_promoted_remainder_baseline.py
echo '## Linear bias gradient reduction'
run_v_benchmark vtl-linear-bias-purev vtl/benchmarks/linear_bias_reduction_bench.v
run_v_benchmark vtl-linear-bias-openblas vtl/benchmarks/linear_bias_reduction_bench.v -d vsl_blas_cblas
env HOME="$HOME" PATH="$PATH" VJOBS=2 OPENBLAS_NUM_THREADS=2 python3 vtl/benchmarks/vs_numpy/numpy_linear_bias_reduction_baseline.py
} 2>&1 | tee "$report_file"
- name: Add matmul ratios to benchmark report
run: python3 vtl/benchmarks/vs_numpy/check_matmul_perf.py --annotate vs_numpy_pr.md
- name: Prepare bounded benchmark comment
run: python3 vtl/benchmarks/vs_numpy/prepare_pr_comment.py vs_numpy_pr.md vs_numpy_pr_comment.md
- name: Post sticky PR comment
if: github.event.pull_request.head.repo.full_name == github.repository
uses: marocchino/sticky-pull-request-comment@v2
with:
header: vtl-vs-numpy
path: vs_numpy_pr_comment.md
- name: Enforce 3x CPU matmul slowdown budget
if: ${{ !contains(github.event.pull_request.labels.*.name, 'performance-exempt') }}
run: python3 vtl/benchmarks/vs_numpy/check_matmul_perf.py vs_numpy_pr.md
- name: Record performance exception
if: ${{ contains(github.event.pull_request.labels.*.name, 'performance-exempt') }}
run: echo 'Matmul slowdown budget bypassed by the performance-exempt label.' >> "$GITHUB_STEP_SUMMARY"