Skip to content

Commit

Permalink
Safe mode warning with LogDensityProblemsAD and GP testing (#167)
Browse files Browse the repository at this point in the history
* Run GP integration tests properly

* Print warning when running Tapir in safe mode

* Bump patch version

* Revert interface only change
  • Loading branch information
willtebbutt authored May 24, 2024
1 parent 1ddee6a commit 7411e01
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Tapir"
uuid = "07d77754-e150-4737-8c94-cd238a1fb45b"
authors = ["Will Tebbutt, Hong Ge, and contributors"]
version = "0.2.19"
version = "0.2.20"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
9 changes: 8 additions & 1 deletion ext/TapirLogDensityProblemsADExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ function logdensity_and_gradient(∇l::TapirGradientLogDensity, x::Vector{Float6
end

# Interop with ADTypes.
ADgradient(x::ADTypes.AutoTapir, ℓ) = ADgradient(Val(:Tapir), ℓ; safety_on=x.safe_mode)
function ADgradient(x::ADTypes.AutoTapir, ℓ)
if x.safe_mode
msg = "Running Tapir in safe mode. Disable for best performance. Do this by " *
"using AutoTapir(safe_mode=false)."
@info msg
end
return ADgradient(Val(:Tapir), ℓ; safety_on=x.safe_mode)
end

end
10 changes: 5 additions & 5 deletions test/integration_testing/gp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ using AbstractGPs, KernelFunctions
RowVecs(randn(9, 4)),
]
d_2_xs = Any[ColVecs(randn(2, 11)), RowVecs(randn(9, 2))]
@testset "kernelmatrix_diag $k, $(typeof(x1))" for (k, x1) in vcat(
@testset "$k, $(typeof(x1))" for (k, x1) in vcat(
Any[(k, x) for k in base_kernels for x in simple_xs],
Any[(with_lengthscale(k, 1.1), x) for k in base_kernels for x in simple_xs],
Any[(with_lengthscale(k, rand(2)), x) for k in base_kernels for x in d_2_xs],
Expand All @@ -30,18 +30,18 @@ using AbstractGPs, KernelFunctions
k in base_kernels for x in d_2_xs
],
)
@info typeof(k), typeof(x1)
fx = GP(k)(x1, 1.1)
@testset "$(_typeof(x))" for x in Any[
(kernelmatrix, k, x1, x1),
(kernelmatrix_diag, k, x1, x1),
(kernelmatrix, x1),
(kernelmatrix_diag, x1),
(kernelmatrix, k, x1),
(kernelmatrix_diag, k, x1),
(rand, Xoshiro(123456), fx),
(logpdf, fx, rand(fx)),
]
@info typeof(x)
TestUtils.test_derived_rule(
sr(123456), rand, Xoshiro(123456), GP(k)(x1, 1.1);
sr(123456), x...;
interp, perf_flag=:none, interface_only=true, is_primitive=false,
)
end
Expand Down

2 comments on commit 7411e01

@willtebbutt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/107582

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.20 -m "<description of version>" 7411e016ebac84da282c91fcaf7829fe65d3f98f
git push origin v0.2.20

Please sign in to comment.