Skip to content

Commit 5cc3a71

Browse files
committed
Improve benchmark data collection
1 parent 3e63528 commit 5cc3a71

File tree

10 files changed

+87
-75
lines changed

10 files changed

+87
-75
lines changed

.github/workflows/Benchmark.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ jobs:
3131
julia --project=benchmark -e '
3232
using Pkg
3333
Pkg.develop(path=".")
34-
Pkg.instantiate()
35-
Pkg.add(["PkgBenchmark", "HTTP", "JSON"])'
34+
Pkg.instantiate()'
3635
- name: Run benchmarks and upload to server
37-
run: |
38-
julia --project=benchmark -e '
39-
using PkgBenchmark, TaylorDiff
40-
include("benchmark/utils.jl")
41-
res = benchmarkpkg(TaylorDiff)
42-
upload(res)'
36+
run: julia --project=benchmark benchmark/runbenchmarks.jl

.github/workflows/Documentation.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Documentation
2+
on:
3+
push:
4+
branches:
5+
- main
6+
tags: ['*']
7+
pull_request:
8+
concurrency:
9+
# Skip intermediate builds: always.
10+
# Cancel intermediate builds: only if it is a pull request build.
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
13+
jobs:
14+
docs:
15+
name: Documentation
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
steps:
20+
- uses: actions/checkout@v2
21+
- uses: julia-actions/setup-julia@v1
22+
with:
23+
version: '1'
24+
- uses: julia-actions/julia-buildpkg@v1
25+
- uses: julia-actions/julia-docdeploy@v1
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
- run: |
29+
julia --project=docs -e '
30+
using Documenter: DocMeta, doctest
31+
using TaylorDiff
32+
DocMeta.setdocmeta!(TaylorDiff, :DocTestSetup, :(using TaylorDiff); recursive=true)
33+
doctest(TaylorDiff)'

.github/workflows/CI.yml renamed to .github/workflows/Test.yml

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: Test
22
on:
33
push:
44
branches:
@@ -12,7 +12,7 @@ concurrency:
1212
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
1313
jobs:
1414
test:
15-
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
15+
name: Test on Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
1616
runs-on: ${{ matrix.os }}
1717
strategy:
1818
fail-fast: false
@@ -38,23 +38,3 @@ jobs:
3838
with:
3939
token: ${{ secrets.CODECOV_TOKEN }}
4040
files: lcov.info
41-
docs:
42-
name: Documentation
43-
runs-on: ubuntu-latest
44-
permissions:
45-
contents: write
46-
steps:
47-
- uses: actions/checkout@v2
48-
- uses: julia-actions/setup-julia@v1
49-
with:
50-
version: '1'
51-
- uses: julia-actions/julia-buildpkg@v1
52-
- uses: julia-actions/julia-docdeploy@v1
53-
env:
54-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55-
- run: |
56-
julia --project=docs -e '
57-
using Documenter: DocMeta, doctest
58-
using TaylorDiff
59-
DocMeta.setdocmeta!(TaylorDiff, :DocTestSetup, :(using TaylorDiff); recursive=true)
60-
doctest(TaylorDiff)'

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2"
88
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
99
ChainRulesOverloadGeneration = "f51149dc-2911-5acf-81fc-2076a2a81d4f"
1010
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
11-
ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444"
11+
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
1212

1313
[compat]
1414
ChainRules = "1"
1515
ChainRulesCore = "1"
1616
ChainRulesOverloadGeneration = "0.1"
17-
SymbolicUtils = "0.19, 0.20, 1"
18-
ZygoteRules = "0.2"
17+
SymbolicUtils = "1"
18+
Zygote = "0.6.55"
1919
julia = "1.6"

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
<p align=center>
44
<a href="https://www.repostatus.org/#active"><img src="https://www.repostatus.org/badges/latest/active.svg" alt="Project Status: Active – The project has reached a stable, usable state and is being actively developed." /></a>
5+
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License: MIT" /></a>
56
<a href="https://juliadiff.org/TaylorDiff.jl/stable/"><img src="https://img.shields.io/badge/docs-stable-blue.svg" alt="Stable" /></a>
67
<a href="https://juliadiff.org/TaylorDiff.jl/dev/"><img src="https://img.shields.io/badge/docs-dev-blue.svg" alt="Dev" /></a>
7-
<a href="https://github.com/JuliaDiff/TaylorDiff.jl/actions/workflows/CI.yml?query=branch%3Amain"><img src="https://github.com/JuliaDiff/TaylorDiff.jl/actions/workflows/CI.yml/badge.svg?branch=main" alt="Build Status" /></a>
8+
<br />
9+
<a href="https://github.com/JuliaDiff/TaylorDiff.jl/actions/workflows/Test.yml?query=branch%3Amain"><img src="https://github.com/JuliaDiff/TaylorDiff.jl/actions/workflows/Test.yml/badge.svg?branch=main" alt="Build Status" /></a>
810
<a href="https://codecov.io/gh/JuliaDiff/TaylorDiff.jl"><img src="https://codecov.io/gh/JuliaDiff/TaylorDiff.jl/branch/main/graph/badge.svg?token=5KYP7K71VQ"/></a>
911
<a href="https://benchmark.tansongchen.com/TaylorDiff.jl"><img src="https://github.com/JuliaDiff/TaylorDiff.jl/actions/workflows/Benchmark.yml/badge.svg?branch=main" alt="Benchmark Status" /></a>
1012
<br />
11-
<a href="https://github.com/SciML/ColPrac"><img src="https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet" alt="ColPrac: Contributor's Guide on Collaborative Practices for Community Packages" /></a>
12-
<a href="https://github.com/SciML/SciMLStyle"><img src="https://img.shields.io/static/v1?label=code%20style&message=SciML&color=9558b2&labelColor=389826" alt="SciML Code Style" /></a>
13+
<a href="https://github.com/SciML/ColPrac"><img src="https://img.shields.io/badge/contributor's%20guide-ColPrac-blueviolet" alt="ColPrac: Contributor's Guide on Collaborative Practices for Community Packages" /></a>
14+
<a href="https://github.com/SciML/SciMLStyle"><img src="https://img.shields.io/badge/code%20style-SciML-blueviolet" alt="SciML Code Style" /></a>
1315
</p>
1416

1517
<p align=center>

benchmark/Project.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@ BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
33
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
44
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
55
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
6+
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
7+
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
8+
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
69
Lux = "b2108857-7c20-44ae-9111-449ecde12c47"
10+
PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d"
711
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
812
TaylorDiff = "b36ab563-344f-407b-a36a-4f200bebf99c"
913
TaylorSeries = "6aa5eb33-94cf-58f4-a9d0-e4b2c4fc25ea"
1014
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
15+
16+
[compat]
17+
Zygote = "0.6.55"
18+
julia = "1.6"

benchmark/pinn.jl

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@ function loss_by_taylordiff(model, x)
2525
abs2(error)
2626
end
2727

28-
pinn = BenchmarkGroup("primal" => BenchmarkGroup("finitediff" => (@benchmarkable loss_by_finitediff($model,
29-
$x)),
30-
"taylordiff" => (@benchmarkable loss_by_taylordiff($model,
31-
$x))),
32-
"gradient" => BenchmarkGroup("finitediff" => (@benchmarkable gradient($loss_by_finitediff,
33-
$model,
34-
$x)),
35-
"taylordiff" => (@benchmarkable gradient($loss_by_taylordiff,
36-
$model,
37-
$x))))
28+
pinn_t = BenchmarkGroup("primal" => (@benchmarkable loss_by_taylordiff($model, $x)),
29+
"gradient" => (@benchmarkable gradient(loss_by_taylordiff, $model,
30+
$x)))
31+
pinn_f = BenchmarkGroup("primal" => (@benchmarkable loss_by_finitediff($model, $x)),
32+
"gradient" => (@benchmarkable gradient($loss_by_finitediff, $model,
33+
$x)))
34+
pinn = BenchmarkGroup("taylordiff" => pinn_t, "finitediff" => pinn_f)

benchmark/runbenchmarks.jl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using TaylorDiff
2+
using BenchmarkTools, PkgBenchmark
3+
using BenchmarkTools: Trial, TrialEstimate, Parameters
4+
import JSON: lower, json
5+
using HTTP: put
6+
using LibGit2: GitRepo, headname
7+
8+
dict(x) = Dict(name => lower(getfield(x, name)) for name in fieldnames(typeof(x)))
9+
10+
lower(results::BenchmarkResults) = dict(results)
11+
lower(group::BenchmarkGroup) = Dict(key => lower(value) for (key, value) in group.data)
12+
lower(trial::Trial) = lower(median(trial))
13+
lower(estimate::TrialEstimate) = dict(estimate)
14+
lower(parameters::Parameters) = dict(parameters)
15+
16+
function benchmark()
17+
repo = GitRepo(pwd())
18+
branch = headname(repo)
19+
config = BenchmarkConfig(id = branch)
20+
results = benchmarkpkg(TaylorDiff, config)
21+
results.name = "TaylorDiff.jl"
22+
endpoint = "https://benchmark.tansongchen.com"
23+
put(endpoint; body = json(results))
24+
end
25+
26+
benchmark()

benchmark/utils.jl

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/chainrules.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import ChainRulesCore: rrule, RuleConfig, ProjectTo, backing
2-
using ZygoteRules: @adjoint
2+
using Zygote: @adjoint
33

44
function contract(a::TaylorScalar{T, N}, b::TaylorScalar{S, N}) where {T, S, N}
55
mapreduce(*, +, value(a), value(b))

0 commit comments

Comments
 (0)