From d0bb1fb18dc6ad63b42d2277b22c29bc88c70250 Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Thu, 29 May 2025 11:43:01 +0100 Subject: [PATCH 1/4] Bump ForwardDiff=1 --- HISTORY.md | 4 ++++ Project.toml | 4 ++-- docs/Project.toml | 2 +- test/Project.toml | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index b8c9d30e0..e4fca51e7 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,9 @@ # DynamicPPL Changelog +## 0.36.10 + +Added compatibility with ForwardDiff 1.0. + ## 0.36.9 Fixed a failure when sampling from `ProductNamedTupleDistribution` due to diff --git a/Project.toml b/Project.toml index fd5d20c9b..fe4d69ef5 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "DynamicPPL" uuid = "366bfd00-2699-11ea-058f-f148b4cae6d8" -version = "0.36.9" +version = "0.36.10" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" @@ -58,7 +58,7 @@ DifferentiationInterface = "0.6.41, 0.7" Distributions = "0.25" DocStringExtensions = "0.9" EnzymeCore = "0.6 - 0.8" -ForwardDiff = "0.10.12" +ForwardDiff = "0.10.12, 1" InteractiveUtils = "1" JET = "0.9, 0.10" KernelAbstractions = "0.9.33" diff --git a/docs/Project.toml b/docs/Project.toml index 336c55c88..c00c29c96 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -22,7 +22,7 @@ Documenter = "1" DocumenterMermaid = "0.1, 0.2" DynamicPPL = "0.36" FillArrays = "0.13, 1" -ForwardDiff = "0.10" +ForwardDiff = "0.10, 1" JET = "0.9, 0.10" LogDensityProblems = "2" MCMCChains = "5, 6, 7" diff --git a/test/Project.toml b/test/Project.toml index 923a48ea2..271cf4f19 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -42,7 +42,7 @@ Distributions = "0.25" DistributionsAD = "0.6.3" Documenter = "1" EnzymeCore = "0.6 - 0.8" -ForwardDiff = "0.10.12" +ForwardDiff = "0.10.12, 1" JET = "0.9, 0.10" LogDensityProblems = "2" MCMCChains = "6.0.4, 7" From c371dcf9198d4205eb48e7ca1a704df527099b3b Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Thu, 29 May 2025 12:34:35 +0100 Subject: [PATCH 2/4] Remove compat/ad.jl --- test/Project.toml | 2 -- test/compat/ad.jl | 29 ----------------------------- test/runtests.jl | 4 ---- test/test_util.jl | 20 -------------------- 4 files changed, 55 deletions(-) delete mode 100644 test/compat/ad.jl diff --git a/test/Project.toml b/test/Project.toml index 271cf4f19..4f9ff4220 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -6,7 +6,6 @@ Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" Bijectors = "76274a88-744f-5084-9051-94815aaf08c4" Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa" -Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63" Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" @@ -36,7 +35,6 @@ Accessors = "0.1" Aqua = "0.8" Bijectors = "0.15.1" Combinatorics = "1" -Compat = "4.3.0" DifferentiationInterface = "0.6.41, 0.7" Distributions = "0.25" DistributionsAD = "0.6.3" diff --git a/test/compat/ad.jl b/test/compat/ad.jl deleted file mode 100644 index e6b23f379..000000000 --- a/test/compat/ad.jl +++ /dev/null @@ -1,29 +0,0 @@ -@testset "ad.jl" begin - @testset "logp" begin - # Hand-written log probabilities for vector `x = [s, m]`. - function logp_gdemo_default(x) - s = x[1] - m = x[2] - dist = Normal(m, sqrt(s)) - - return logpdf(InverseGamma(2, 3), s) + - logpdf(Normal(0, sqrt(s)), m) + - logpdf(dist, 1.5) + - logpdf(dist, 2.0) - end - - test_model_ad(gdemo_default, logp_gdemo_default) - - @model function wishart_ad() - return v ~ Wishart(7, [1 0.5; 0.5 1]) - end - - # Hand-written log probabilities for `x = [v]`. - function logp_wishart_ad(x) - dist = Wishart(7, [1 0.5; 0.5 1]) - return logpdf(dist, reshape(x, 2, 2)) - end - - test_model_ad(wishart_ad(), logp_wishart_ad) - end -end diff --git a/test/runtests.jl b/test/runtests.jl index 6c977084c..997a41641 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -15,7 +15,6 @@ using MCMCChains using StableRNGs using ReverseDiff using Zygote -using Compat using Distributed using LinearAlgebra @@ -79,9 +78,6 @@ include("test_util.jl") end if GROUP == "All" || GROUP == "Group2" - @testset "compat" begin - include(joinpath("compat", "ad.jl")) - end @testset "extensions" begin include("ext/DynamicPPLMCMCChainsExt.jl") include("ext/DynamicPPLJETExt.jl") diff --git a/test/test_util.jl b/test/test_util.jl index 902dd7230..d5335249d 100644 --- a/test/test_util.jl +++ b/test/test_util.jl @@ -8,26 +8,6 @@ end const gdemo_default = gdemo_d() -# TODO(penelopeysm): Remove this (and also test/compat/ad.jl) -function test_model_ad(model, logp_manual) - vi = VarInfo(model) - x = vi[:] - - # Log probabilities using the model. - ℓ = DynamicPPL.LogDensityFunction(model, vi) - logp_model = Base.Fix1(LogDensityProblems.logdensity, ℓ) - - # Check that both functions return the same values. - lp = logp_manual(x) - @test logp_model(x) ≈ lp - - # Gradients based on the manual implementation. - grad = ForwardDiff.gradient(logp_manual, x) - - # Gradients based on the model. - @test ForwardDiff.gradient(logp_model, x) ≈ grad -end - """ short_varinfo_name(vi::AbstractVarInfo) From 7f7ff6bf8bcb8f48568a05497c15e7392912c3e9 Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Thu, 29 May 2025 14:23:03 +0100 Subject: [PATCH 3/4] Bump benchmarks compat too --- benchmarks/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/Project.toml b/benchmarks/Project.toml index 88386f243..134508b83 100644 --- a/benchmarks/Project.toml +++ b/benchmarks/Project.toml @@ -19,7 +19,7 @@ StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" ADTypes = "1.14.0" BenchmarkTools = "1.6.0" Distributions = "0.25.117" -ForwardDiff = "0.10.38" +ForwardDiff = "0.10.38, 1" LogDensityProblems = "2.1.2" PrettyTables = "2.4.0" ReverseDiff = "1.15.3" From ac22eb8e96b8b955a65182f051008e4222b5646a Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Thu, 29 May 2025 14:23:21 +0100 Subject: [PATCH 4/4] Add CompatHelper to benchmarks folder --- .github/workflows/CompatHelper.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml index 36bf4939c..0c1c69aca 100644 --- a/.github/workflows/CompatHelper.yml +++ b/.github/workflows/CompatHelper.yml @@ -14,4 +14,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} - run: julia -e 'using CompatHelper; CompatHelper.main(; subdirs = ["", "docs", "test"])' + run: julia -e 'using CompatHelper; CompatHelper.main(; subdirs = ["", "docs", "test", "benchmarks"])'