Skip to content

Commit

Permalink
Continous Benchmarking Action (#1137)
Browse files Browse the repository at this point in the history
* ci: continous benchmarking action

* fix pytorch install command

* fixed action python version

* added github token to benchmark action

* test message worst performance

* ci: test gh-pages results from cb action

* ci: this should pass

* fix: typo

* remove cache action in favor of gh-pages

* extra /

* ci: action config should work now

* extra benchmarks from linalg module

* quicker linalg benchmarks

* cluster benchmarks, removed some code duplication

* corrected cb workflow command

* ci: split cb workflow into a main and pr. pr workflow triggers with a 'run bench' comment

* ci: bench pr runs after a review is requested

* ci: bench now only triggers on pull requests with 'PR talk' tag

* ci: reshape benchmark, removed cronjob from pytorch workflows, renamed 'old' benchmarking folder to '2020'

* mend

* fix: missing import in cb main

* ci: changed benchmark python version to 3.10, added shield in readme pointing to the benchmarks, changed trigger tag

* fix: incorrect python version param

---------

Co-authored-by: Claudia Comito <39374113+ClaudiaComito@users.noreply.github.com>
  • Loading branch information
JuanPedroGHM and ClaudiaComito authored Apr 27, 2023
1 parent 9f6b2eb commit 02d2492
Show file tree
Hide file tree
Showing 56 changed files with 322 additions and 171 deletions.
76 changes: 65 additions & 11 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,94 @@ categories:
- title: '🐛 Bug Fixes'
labels:
- 'bug :bug:'
- title: 'Google Summer of Code 2022'
label: 'GSoC22'
- title: '💯 Benchmarking'
label: 'benchmarking'
- title: '📜 Documentation'
label: 'documentation :book:'
- title: '🧹 Maintenance'
label: 'chore'
- title: '🧪 Testing'
label: 'testing'
- title: 'Arithmetic'
label: 'arithmetic'
- title: 'Array API'
label: 'array API'
- title: 'Classification'
label: 'classification'
- title: 'Cluster'
label: 'cluster'
- title: 'Communication'
labels:
- 'io'
- 'I/O'
- 'communication'
- title: 'Complex Math'
label: 'complex math'
- title: 'Constants'
label: 'constants'
- title: 'Datasets'
label: 'datasets'
- title: 'Devices'
label: 'devices'
- title: 'DNDarray'
label: 'dndarray'
- title: 'Exponential'
label: 'exponential'
- title: 'Factories'
label: 'factories'
- title: 'Graph'
label: 'graph'
- title: 'Indexing'
label: 'indexing'
- title: 'Linear Algebra'
label: 'linalg'
- title: 'Logical'
label: 'logical'
- title: 'Manipulations'
label: 'manipulation'
- title: 'Memory'
label: 'memory'
- title: 'Naive Bayes'
label: 'naive Bayes'
- title: 'Neural Networks'
labels:
- 'nn'
- 'neural net'
- title: 'Optimization'
label: 'optim'
- title: 'Printing'
label: 'printing'
- title: 'Random'
label: 'random'
- title: 'Regression'
label: 'regression'
- title: 'Relational'
label: 'relational'
- title: 'Rounding'
label: 'rounding'
- title: 'Sanitation'
label: 'sanitation'
- title: 'Signal'
label: 'signal'
- title: 'Sparse'
label: 'sparse'
- title: 'Google Summer of Code 2022'
label: 'GSoC22'
- title: '💯 Benchmarking'
label: 'benchmarking'
- title: '📜 Documentation'
label: 'documentation :book:'
- title: '🧹 Maintenance'
label: 'chore'
- title: '🧪 Testing'
label: 'testing'
- title: 'Spatial'
label: 'spatial'
- title: 'Statistics'
label: 'statistics'
- title: 'Stride Tricks'
label: 'stride tricks'
- title: 'Tiling'
label: 'tiling'
- title: 'Trigonometrics'
label: 'trigonometrics'
- title: 'Types'
label: 'types'

change-template: '- #$NUMBER $TITLE (by @$AUTHOR)'
categorie-template: '### $TITLE'
category-template: '### $TITLE'
exclude-labels:
- 'workflow'
template: |
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/benchmark_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Benchmark main and save
on:
push:
branches:
- main

jobs:
benchmark-main:
name: Benchmark main and save
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup MPI
uses: mpi4py/setup-mpi@v1
- name: Use Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.10.11 # Perun only supports 3.8 and ahead
architecture: x64
- name: Test
run: |
pip install torch==1.12.1+cpu torchvision==0.13.1+cpu torchaudio==0.12.1 -f https://download.pytorch.org/whl/torch_stable.html
pip install .[cb]
PERUN_RUN_ID=N4 mpirun -n 4 python benchmarks/cb/main.py
jq -s flatten bench_data/*.json > bench_data/all_benchmarks.json
- name: Save benchmark result and update gh-pages-chart
if: ${{github.ref == 'refs/heads/main'}}
uses: benchmark-action/github-action-benchmark@v1
with:
github-token: ${{secrets.GITHUB_TOKEN}}
# Benchmark action input and output
tool: 'customSmallerIsBetter'
output-file-path: bench_data/all_benchmarks.json
# external-data-json-path: ./cache/benchmark-data.json
# Alert configuration
fail-on-alert: false # Don't fail on main branch
comment-on-alert: true
# Save benchmarks from the main branch
save-data-file: true
# Pages configuration
auto-push: true
gh-pages-branch: gh-pages
benchmark-data-dir-path: dev/bench
# Upload the updated cache file for the next job by actions/cache
45 changes: 45 additions & 0 deletions .github/workflows/benchmark_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Benchmark PR
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
branches: [main]

jobs:
benchmark-pr:
name: Benchmark PR
if: contains(github.event.pull_request.labels.*.name, 'benchmark PR')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup MPI
uses: mpi4py/setup-mpi@v1
- name: Use Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.10.11 # Perun only supports 3.8 and ahead
architecture: x64
- name: Test
run: |
pip install torch==1.12.1+cpu torchvision==0.13.1+cpu torchaudio==0.12.1 -f https://download.pytorch.org/whl/torch_stable.html
pip install .[cb]
PERUN_RUN_ID=N4 mpirun -n 4 python benchmarks/cb/main.py
jq -s flatten bench_data/*.json > bench_data/all_benchmarks.json
- name: Compare benchmark result
if: ${{github.ref != 'refs/heads/main'}}
uses: benchmark-action/github-action-benchmark@v1
with:
github-token: ${{secrets.GITHUB_TOKEN}}
# Benchmark action input and output
tool: 'customSmallerIsBetter'
output-file-path: bench_data/all_benchmarks.json
# external-data-json-path: ./cache/benchmark-data.json
# Alert configuration
fail-on-alert: true
comment-on-alert: true
# Ignore results from non main branches.
save-data-file: false
# Pages configuration
auto-push: false
gh-pages-branch: gh-pages
benchmark-data-dir-path: dev/bench
2 changes: 0 additions & 2 deletions .github/workflows/pytorch-latest-main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Get latest PyTorch version main branch
on:
workflow_dispatch:
schedule:
- cron: '0 3 * * 1,4'
env:
working_branch: workflows/new-pytorch-main-branch
base_branch: main
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/pytorch-latest-release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Get latest PyTorch version release branch
on:
workflow_dispatch:
schedule:
- cron: '0 3 * * 1,4'
env:
working_branch: workflows/new-pytorch-release-branch
base_branch: release/1.2.x
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,5 @@ MANIFEST
travis_wait_*.log
testing.py
heat/datasets/MNISTDataset
perun_results/
bench_data/
8 changes: 8 additions & 0 deletions .perun.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[output]
format = bench
data_out = ./bench_data

[benchmarking]
bench_enable = True
bench_rounds = 10
bench_warmup_rounds = 1
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Heat is a distributed tensor framework for high performance data analytics.
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![license: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Downloads](https://pepy.tech/badge/heat)](https://pepy.tech/project/heat)
[![Github-Pages - Benchmarks](https://img.shields.io/badge/Github--Pages-Benchmarks-2ea44f)](https://helmholtz-analytics.github.io/heat/dev/bench)

# New
- **NO GSoC WITH US THIS YEAR**. On Feb 21st we learned that our Organisation has not been selected this year. Congratulations to the [GSoC 2023 Mentoring Orgs](https://summerofcode.withgoogle.com/programs/2023/organizations)!
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions benchmarks/cb/cluster.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import heat as ht
from perun.decorator import monitor


@monitor()
def kmeans_cpu(data):
kmeans = ht.cluster.KMeans(n_clusters=4, init="kmeans++")
kmeans.fit(data)


@monitor()
def kmedians_cpu(data):
kmeans = ht.cluster.KMedians(n_clusters=4, init="kmedians++")
kmeans.fit(data)


@monitor()
def kmedoids_cpu(data):
kmeans = ht.cluster.KMedoids(n_clusters=4, init="kmedoids++")
kmeans.fit(data)


n = 5000
seed = 1
data = ht.utils.data.spherical.create_spherical_dataset(
num_samples_cluster=n, radius=1.0, offset=4.0, dtype=ht.float32, random_state=seed
)
kmeans_cpu(data)
kmedians_cpu(data)
kmedoids_cpu(data)
38 changes: 38 additions & 0 deletions benchmarks/cb/linalg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# flake8: noqa
import heat as ht
from perun.decorator import monitor


@monitor()
def matmul_cpu_split_0(n: int = 3000):
a = ht.random.random((n, n), split=0, device="cpu")
b = ht.random.random((n, n), split=0, device="cpu")
a @ b


@monitor()
def matmul_cpu_split_1(n: int = 3000):
a = ht.random.random((n, n), split=1, device="cpu")
b = ht.random.random((n, n), split=1, device="cpu")
a @ b


@monitor()
def qr_cpu(n: int = 2000):
for t in range(1, 3):
for sp in range(2):
a = ht.random.random((n, n), split=sp)
qr = a.qr(tiles_per_proc=t)


@monitor()
def lanczos_cpu(n: int = 50):
A = ht.random.random((n, n), dtype=ht.float64, split=0)
B = A @ A.T
V, T = ht.lanczos(B, m=n)


matmul_cpu_split_0()
matmul_cpu_split_1()
qr_cpu()
lanczos_cpu()
4 changes: 4 additions & 0 deletions benchmarks/cb/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# flake8: noqa
import linalg
import cluster
import manipulations
14 changes: 14 additions & 0 deletions benchmarks/cb/manipulations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# flake8: noqa
import heat as ht
from perun.decorator import monitor


@monitor()
def reshape_cpu():
sizes = [10000, 20000, 40000]
for size in sizes:
st = ht.zeros((1000, size), split=1)
a = ht.reshape(st, (10000000, -1), new_split=1)


reshape_cpu()
Loading

0 comments on commit 02d2492

Please sign in to comment.