From dbc07b703ab490db6a994d54906cc4ac305343cd Mon Sep 17 00:00:00 2001 From: "William S. Moses" Date: Sat, 20 Sep 2025 22:48:11 -0500 Subject: [PATCH 1/3] Don't use closure for enzyme --- src/logdensityfunction.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/logdensityfunction.jl b/src/logdensityfunction.jl index 3b790576a..e5e6a6dae 100644 --- a/src/logdensityfunction.jl +++ b/src/logdensityfunction.jl @@ -350,6 +350,7 @@ closure approach will be used. By default, this function returns `false`, i.e. the constant approach will be used. """ use_closure(::ADTypes.AbstractADType) = true +use_closure(::ADTypes.AutoEnzyme) = false """ getmodel(f) From 91c87d1d749a87c9abd9f4adfd0b2d244474869d Mon Sep 17 00:00:00 2001 From: "William S. Moses" Date: Sat, 20 Sep 2025 22:49:59 -0500 Subject: [PATCH 2/3] no annotation --- test/integration/enzyme/main.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/enzyme/main.jl b/test/integration/enzyme/main.jl index ea4ec497d..5e8621c74 100644 --- a/test/integration/enzyme/main.jl +++ b/test/integration/enzyme/main.jl @@ -7,9 +7,9 @@ using ForwardDiff: ForwardDiff # run_ad uses FD for correctness test ADTYPES = Dict( "EnzymeForward" => - AutoEnzyme(; mode=set_runtime_activity(Forward), function_annotation=Const), + AutoEnzyme(; mode=set_runtime_activity(Forward)), "EnzymeReverse" => - AutoEnzyme(; mode=set_runtime_activity(Reverse), function_annotation=Const), + AutoEnzyme(; mode=set_runtime_activity(Reverse)), ) @testset "$ad_key" for (ad_key, ad_type) in ADTYPES From 13df62f69ebf6cb9de7e3adff548c246bd61f6e8 Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Wed, 24 Sep 2025 16:24:34 +0100 Subject: [PATCH 3/3] bump patch --- HISTORY.md | 4 ++++ Project.toml | 2 +- test/integration/enzyme/main.jl | 6 ++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 9c85674c3..d946a12d2 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,9 @@ # DynamicPPL Changelog +## 0.37.5 + +A minor optimisation for Enzyme AD on DynamicPPL models. + ## 0.37.4 An extension for MarginalLogDensities.jl has been added. diff --git a/Project.toml b/Project.toml index 51028b831..e636199a1 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "DynamicPPL" uuid = "366bfd00-2699-11ea-058f-f148b4cae6d8" -version = "0.37.4" +version = "0.37.5" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" diff --git a/test/integration/enzyme/main.jl b/test/integration/enzyme/main.jl index 5e8621c74..b40bbeb8f 100644 --- a/test/integration/enzyme/main.jl +++ b/test/integration/enzyme/main.jl @@ -6,10 +6,8 @@ import Enzyme: set_runtime_activity, Forward, Reverse, Const using ForwardDiff: ForwardDiff # run_ad uses FD for correctness test ADTYPES = Dict( - "EnzymeForward" => - AutoEnzyme(; mode=set_runtime_activity(Forward)), - "EnzymeReverse" => - AutoEnzyme(; mode=set_runtime_activity(Reverse)), + "EnzymeForward" => AutoEnzyme(; mode=set_runtime_activity(Forward)), + "EnzymeReverse" => AutoEnzyme(; mode=set_runtime_activity(Reverse)), ) @testset "$ad_key" for (ad_key, ad_type) in ADTYPES