From 7ed4d70a166ed6939125d34a6b7d95d5068c956c Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Fri, 11 Oct 2024 14:37:25 +0100 Subject: [PATCH 1/4] Default float type to float(Real), not Real (#685) * Default float type to float(Real), not Real Closes #684 * Trigger CI on backport branches/PRs * Add integration test for #684 * Bump Turing version to 0.34 in test subfolder --- .github/workflows/CI.yml | 2 ++ src/utils.jl | 6 +++--- test/turing/varinfo.jl | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f7d43470e..4015ab331 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -4,9 +4,11 @@ on: push: branches: - master + - backport-* pull_request: branches: - master + - backport-* merge_group: types: [checks_requested] diff --git a/src/utils.jl b/src/utils.jl index a809fda17..5fedd3039 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -941,10 +941,10 @@ end """ float_type_with_fallback(x) -Return type corresponding to `float(typeof(x))` if possible; otherwise return `Real`. +Return type corresponding to `float(typeof(x))` if possible; otherwise return `float(Real)`. """ -float_type_with_fallback(::Type) = Real -float_type_with_fallback(::Type{Union{}}) = Real +float_type_with_fallback(::Type) = float(Real) +float_type_with_fallback(::Type{Union{}}) = float(Real) float_type_with_fallback(::Type{T}) where {T<:Real} = float(T) """ diff --git a/test/turing/varinfo.jl b/test/turing/varinfo.jl index f1d805505..e5b8eb79f 100644 --- a/test/turing/varinfo.jl +++ b/test/turing/varinfo.jl @@ -342,4 +342,19 @@ model = state_space(y, length(t)) @test size(sample(model, NUTS(; adtype=AutoReverseDiff(true)), n), 1) == n end + + if Threads.nthreads() > 1 + @testset "DynamicPPL#684: OrderedDict with multiple types when multithreaded" begin + @model function f(x) + ns ~ filldist(Normal(0, 2.0), 3) + m ~ Uniform(0, 1) + return x ~ Normal(m, 1) + end + model = f(1) + chain = sample(model, NUTS(), MCMCThreads(), 10, 2) + loglikelihood(model, chain) + logprior(model, chain) + logjoint(model, chain) + end + end end From e7dc2e48483203edc70ad6877ef3fff30ccdb1b9 Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Thu, 31 Oct 2024 17:41:42 +0000 Subject: [PATCH 2/4] Bump minimum Julia version to 1.10 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 92fb67ddd..dabfc1c21 100644 --- a/Project.toml +++ b/Project.toml @@ -65,7 +65,7 @@ Requires = "1" ReverseDiff = "1" Test = "1.6" ZygoteRules = "0.2" -julia = "~1.6.6, 1.7.3" +julia = "1.10" [extras] ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" From 3ad1f1dedb79e0278e69902903bf82e30567944f Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Thu, 31 Oct 2024 19:53:20 +0000 Subject: [PATCH 3/4] Bump patch version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index dabfc1c21..f2527ccd4 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "DynamicPPL" uuid = "366bfd00-2699-11ea-058f-f148b4cae6d8" -version = "0.30.2" +version = "0.30.3" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" From 9f2cd3c51dbe01063b3495d6bcdd9a81cc5088df Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Tue, 5 Nov 2024 18:40:51 +0000 Subject: [PATCH 4/4] Bump patch again --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index f2527ccd4..1a523e21d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "DynamicPPL" uuid = "366bfd00-2699-11ea-058f-f148b4cae6d8" -version = "0.30.3" +version = "0.30.4" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"