max_norm_perturbation kwarg#1173
Conversation
|
thanks, I'll take a look today |
| ε_list = filter( | ||
| ε -> isnothing(max_norm_perturbation) || ε <= max_norm_perturbation, | ||
| [1e-2, 1e-3, 1e-4, 1e-5, 1e-6, 1e-7, 1e-8], | ||
| ) |
There was a problem hiding this comment.
worth add a check here for the filtered ε_list: if too few left or empty
| x = map(primal, x_ẋ) | ||
| ẋ = map(tangent, x_ẋ) | ||
| x = map(primal, x_ẋ) | ||
| ẋ = map(x -> normalize_tangent(tangent(x)), x_ẋ) |
There was a problem hiding this comment.
a nit on style, maybe do something like normalize_tangent ∘ tangent instead of the anonymous function?
| """ | ||
| test_rule( | ||
| rng::AbstractRNG, | ||
| x...; | ||
| interface_only::Bool=false, | ||
| is_primitive::Bool=true, | ||
| perf_flag::Symbol=:none, | ||
| mode::Union{Nothing,Type{ForwardMode},Type{ReverseMode}}=nothing, | ||
| debug_mode::Bool=false, | ||
| unsafe_perturb::Bool=false, | ||
| print_results=true, | ||
| output_tangent=nothing, | ||
| atol=1e-3, | ||
| rtol=1e-3 | ||
| ) |
There was a problem hiding this comment.
update this too? it was outdated before this PR but worth fixing with it
| print_results=false, | ||
| max_norm_perturbation=1.0e-3, | ||
| ) | ||
| @test !ts.anynonpass |
There was a problem hiding this comment.
will fix this, its actually a field in Test.DefaultTestSet i was using it as @test !ts.anynonpass to assert that all internal tests passed.
| @test TestUtils.count_allocs(Mooncake.fdata_type, Tuple{Vector{Float64}}) == 0 | ||
| end | ||
| @testset "max_norm_perturbation kwarg for testing rules" begin | ||
| rng = Xoshiro(1) |
There was a problem hiding this comment.
this feels inconsistent coding style
| StableRNG(123), sqrt, 0.005; is_primitive=true, max_norm_perturbation=1e-3 | ||
| ) | ||
| end | ||
| end |
There was a problem hiding this comment.
does this overlap with the one in test_utils.jl?
| ε_list = filter( | ||
| ε -> isnothing(max_norm_perturbation) || ε <= max_norm_perturbation, | ||
| [1e-2, 1e-3, 1e-4, 1e-5, 1e-6, 1e-7, 1e-8], | ||
| ) |
|
thanks for the reviews @sunxd3! I have tried addressing all of them. |
| function _check_ε_list(ε_list, max_norm_perturbation) | ||
| isempty(ε_list) && throw( | ||
| ArgumentError( | ||
| "max_norm_perturbation=$max_norm_perturbation filters out all finite-difference " * | ||
| "step sizes; the smallest available is 1e-8, below which floating-point rounding " * | ||
| "errors dominate the estimate.", | ||
| ), | ||
| ) | ||
| end |
There was a problem hiding this comment.
this is a style nit: we can just check the value of max_norm_perturbation directly before
ε_list = filter(
ε -> isnothing(max_norm_perturbation) || ε <= max_norm_perturbation,
[1e-2, 1e-3, 1e-4, 1e-5, 1e-6, 1e-7, 1e-8],
)
and error if too small, try to keep it a oneliner?
closes #765
CI Summary — GitHub Actions
Documentation Preview
Mooncake.jl documentation for PR #1173 is available at:
https://chalk-lab.github.io/Mooncake.jl/previews/PR1173/
Performance
Performance Ratio:
Ratio of time to compute gradient and time to compute function.
Warning: results are very approximate! See here for more context.