-
Notifications
You must be signed in to change notification settings - Fork 35
Improvements to DynamicPPLBenchmarks #346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 32 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
57b5d47
bigboy update to benchmarks
torfjelde e7c0a76
Merge branch 'master' into tor/benchmark-update
torfjelde 60ec2c8
Merge branch 'master' into tor/benchmark-update
torfjelde eb1b83c
Merge branch 'master' into tor/benchmark-update
torfjelde d8afa71
Merge branch 'master' into tor/benchmark-update
torfjelde 5bb48d2
make models return random variables as NamedTuple as it can be useful…
torfjelde 02484cf
add benchmarking of evaluation with SimpleVarInfo with NamedTuple
torfjelde 5c59769
added some information about the execution environment
torfjelde f1f1381
added judgementtable_single
torfjelde a48553a
added benchmarking of SimpleVarInfo, if present
torfjelde f2dc062
Merge branch 'master' into tor/benchmark-update
torfjelde fa675de
added ComponentArrays benchmarking for SimpleVarInfo
torfjelde 3962da2
Merge branch 'master' into tor/benchmark-update
yebai 53dc571
Merge branch 'master' into tor/benchmark-update
yebai f5705d5
Merge branch 'master' into tor/benchmark-update
torfjelde 7f569f7
formatting
torfjelde 4a06150
Merge branch 'master' into tor/benchmark-update
yebai a1cc6bf
Apply suggestions from code review
yebai 3e7e200
Update benchmarks/benchmarks.jmd
yebai c867ae8
Merge branch 'master' into tor/benchmark-update
yebai 96f120b
merged main into this one
shravanngoswamii 0460b64
Benchmarking CI
shravanngoswamii a8541b5
Julia script for benchmarking on top of current setup
shravanngoswamii 0291c2f
keep old results for reference
shravanngoswamii 6f255d1
Merge branch 'master' of https://github.com/TuringLang/DynamicPPL.jl …
shravanngoswamii 3b5e448
updated benchmarking setup
shravanngoswamii 1e61025
Merge branch 'master' of https://github.com/TuringLang/DynamicPPL.jl …
shravanngoswamii 640aa45
applied suggested changes
shravanngoswamii 3bdbe40
Merge branch 'master' of https://github.com/TuringLang/DynamicPPL.jl …
shravanngoswamii d8fd05c
updated benchmarks/README.md
shravanngoswamii c34e489
setup benchmarking CI
shravanngoswamii 1d1b11e
Merge remote-tracking branch 'origin/main' into tor/benchmark-update
mhauru ad4175a
Update benchmark models (#826)
mhauru d39a9d6
Merge branch 'main' into tor/benchmark-update
mhauru f765b40
Make benchmarks not depend on TuringBenchmarking.jl, and run `]dev ..…
mhauru 00296bd
Benchmarking.yml: now comments raw markdown table enclosed in triple …
shravanngoswamii 9a64f32
Benchmarking.yml: now includes the SHA of the DynamicPPL commit in Be…
shravanngoswamii 5c35238
Benchmark more with Mooncake
mhauru 923105e
Add model dimension to benchmark table
mhauru 2f15b72
Add info print
mhauru ee39e26
Fix type instability in benchmark model
mhauru 6ce0a4f
Remove done TODO note
mhauru c95d298
Merge branch 'main' into tor/benchmark-update
mhauru 2161352
Apply suggestions from code review
mhauru 70ff1a9
Fix table formatting bug
mhauru b847542
Simplify benchmark suite code
mhauru 4a15940
Use StableRNG
mhauru 5e6cab0
Merge branch 'main' into tor/benchmark-update
shravanngoswamii dae1be7
Merge branch 'main' of https://github.com/TuringLang/DynamicPPL.jl in…
shravanngoswamii File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Benchmarking | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
benchmarks: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Set up Julia | ||
uses: julia-actions/setup-julia@v2 | ||
with: | ||
version: '1' | ||
|
||
- name: Install Dependencies | ||
run: julia --project=benchmarks/ -e 'using Pkg; Pkg.instantiate()' | ||
|
||
- name: Run Benchmarks | ||
id: run_benchmarks | ||
run: | | ||
# Capture version info into a variable, print it, and set it as an env var for later steps | ||
version_info=$(julia -e 'using InteractiveUtils; versioninfo()') | ||
echo "$version_info" | ||
echo "VERSION_INFO<<EOF" >> $GITHUB_ENV | ||
echo "$version_info" >> $GITHUB_ENV | ||
echo "EOF" >> $GITHUB_ENV | ||
|
||
# Capture benchmark output into a variable | ||
echo "Running Benchmarks..." | ||
benchmark_output=$(julia --project=benchmarks benchmarks/benchmarks.jl) | ||
|
||
# Print benchmark results directly to the workflow log | ||
echo "Benchmark Results:" | ||
echo "$benchmark_output" | ||
|
||
# Set the benchmark output as an env var for later steps | ||
echo "BENCHMARK_OUTPUT<<EOF" >> $GITHUB_ENV | ||
echo "$benchmark_output" >> $GITHUB_ENV | ||
echo "EOF" >> $GITHUB_ENV | ||
|
||
- name: Find Existing Comment | ||
uses: peter-evans/find-comment@v3 | ||
id: find_comment | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
comment-author: github-actions[bot] | ||
|
||
- name: Post Benchmark Results as PR Comment | ||
uses: peter-evans/create-or-update-comment@v4 | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body: | | ||
## Computer Information | ||
``` | ||
${{ env.VERSION_INFO }} | ||
``` | ||
## Benchmark Report | ||
${{ env.BENCHMARK_OUTPUT }} | ||
comment-id: ${{ steps.find_comment.outputs.comment-id }} | ||
edit-mode: replace |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,5 @@ | ||
To run the benchmarks, simply do: | ||
To run the benchmarks, simply do this from the root directory of the repository: | ||
|
||
```sh | ||
julia --project -e 'using DynamicPPLBenchmarks; weave_benchmarks();' | ||
``` | ||
|
||
```julia | ||
julia> @doc weave_benchmarks | ||
weave_benchmarks(input="benchmarks.jmd"; kwargs...) | ||
|
||
Weave benchmarks present in benchmarks.jmd into a single file. | ||
|
||
Keyword arguments | ||
≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ | ||
|
||
• benchmarkbody: JMD-file to be rendered for each model. | ||
|
||
• include_commit_id=false: specify whether to include commit-id in the default name. | ||
|
||
• name: the name of directory in results/ to use as output directory. | ||
|
||
• name_old=nothing: if specified, comparisons of current run vs. the run pinted to by name_old will be included in the generated document. | ||
|
||
• include_typed_code=false: if true, output of code_typed for the evaluator of the model will be included in the weaved document. | ||
|
||
• Rest of the passed kwargs will be passed on to Weave.weave. | ||
``` | ||
julia --project=benchmarks benchmarks/benchmarks.jl | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using DynamicPPL: @model | ||
using DynamicPPLBenchmarks: make_suite | ||
using BenchmarkTools: median, run | ||
using Distributions: Normal, Beta, Bernoulli | ||
using PrettyTables: pretty_table, PrettyTables | ||
|
||
# Define models | ||
@model function demo1(x) | ||
m ~ Normal() | ||
x ~ Normal(m, 1) | ||
return (m=m, x=x) | ||
end | ||
|
||
@model function demo2(y) | ||
p ~ Beta(1, 1) | ||
N = length(y) | ||
for n in 1:N | ||
y[n] ~ Bernoulli(p) | ||
end | ||
return (; p) | ||
end | ||
|
||
demo1_data = randn() | ||
demo2_data = rand(Bool, 10) | ||
|
||
# Create model instances with the data | ||
demo1_instance = demo1(demo1_data) | ||
demo2_instance = demo2(demo2_data) | ||
|
||
# Specify the combinations to test: | ||
# (Model Name, model instance, VarInfo choice, AD backend) | ||
chosen_combinations = [ | ||
("Demo1", demo1_instance, :typed, :forwarddiff), | ||
("Demo1", demo1_instance, :simple_namedtuple, :zygote), | ||
("Demo2", demo2_instance, :untyped, :reversediff), | ||
("Demo2", demo2_instance, :simple_dict, :forwarddiff), | ||
] | ||
|
||
results_table = Tuple{String,String,String,Float64,Float64}[] | ||
|
||
for (model_name, model, varinfo_choice, adbackend) in chosen_combinations | ||
suite = make_suite(model, varinfo_choice, adbackend) | ||
results = run(suite) | ||
|
||
eval_time = median(results["AD_Benchmarking"]["evaluation"]["standard"]).time | ||
|
||
grad_group = results["AD_Benchmarking"]["gradient"] | ||
if isempty(grad_group) | ||
ad_eval_time = NaN | ||
else | ||
grad_backend_key = first(keys(grad_group)) | ||
ad_eval_time = median(grad_group[grad_backend_key]["standard"]).time | ||
end | ||
|
||
push!( | ||
results_table, | ||
(model_name, string(adbackend), string(varinfo_choice), eval_time, ad_eval_time), | ||
) | ||
end | ||
|
||
table_matrix = hcat(Iterators.map(collect, zip(results_table...))...) | ||
header = [ | ||
"Model", "AD Backend", "VarInfo Type", "Evaluation Time (ns)", "AD Eval Time (ns)" | ||
] | ||
pretty_table(table_matrix; header=header, tf=PrettyTables.tf_markdown) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.