Skip to content

Commit

Permalink
More formatting improvements to benchmarking (#71)
Browse files Browse the repository at this point in the history
* Fix up benchmarking

* Stabilise benchmarking and tidy up script

* Tighten some bounds

* Improve readme and docstring

* Do not restrict benchmarking time

* Loosen some tolerances

* Improve style

* Remove redundant code

* Remove redundant imports

* Loosen some bounds
  • Loading branch information
willtebbutt authored Feb 5, 2024
1 parent f2106fc commit f6b960c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
17 changes: 3 additions & 14 deletions bench/run_benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using Taped:
TestUtils,
TInterp

using Taped.TestUtils: _deepcopy, to_benchmark
using Taped.TestUtils: _deepcopy, to_benchmark, set_up_gradient_problem

function benchmark_rules!!(test_case_data, default_ratios)
test_cases = reduce(vcat, map(first, test_case_data))
Expand All @@ -30,7 +30,7 @@ function benchmark_rules!!(test_case_data, default_ratios)
)

# Benchmark pullback.
rule, in_f = TestUtils.set_up_gradient_problem(args...)
rule, in_f = set_up_gradient_problem(args...)
coduals = map(x -> x isa CoDual ? x : zero_codual(x), args)
suite["value_and_pb"] = @benchmarkable(
to_benchmark($rule, zero_codual($in_f), $coduals...);
Expand Down Expand Up @@ -75,18 +75,7 @@ function benchmark_hand_written_rrules!!(rng_ctor)
end

function benchmark_derived_rrules!!(rng_ctor)
# Only testing a subset of the cases because there are still problems in the subset of
# the cases.
test_case_data = map([
# :avoiding_non_differentiable_code,
# :blas,
# :builtins,
# :foreigncall,
# :iddict,
# :lapack,
# :low_level_maths,
# :misc,
# :new,
:test_utils
]) do s
test_cases, memory = generate_derived_rrule!!_test_cases(rng_ctor, Val(s))
Expand All @@ -100,7 +89,7 @@ function flag_concerning_performance(ratios)
between(x, (lb, ub)) = lb < x && x < ub
@testset "detect concerning performance" begin
@testset for ratio in ratios
@test between(ratio.value_and_pb_ratio, ratio.range)
@test ratio.range.lb < ratio.value_and_pb_ratio < ratio.range.ub
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/rrules/builtins.jl
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ function generate_hand_written_rrule!!_test_cases(rng_ctor, ::Val{:builtins})
_a[1] = [5.4, 4.23, -0.1, 2.1]

# Slightly wider range for builtins whose performance is known not to be great.
_range = (lb=0.1, ub=100.0)
_range = (lb=0.1, ub=200.0)

test_cases = Any[

Expand Down

0 comments on commit f6b960c

Please sign in to comment.