From 5cab7dd0ec02ba8dcb055b16ae0268e8070940f3 Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Fri, 16 May 2025 12:30:01 +0100 Subject: [PATCH 01/13] Don't test Mooncake on 1.12 --- test/Project.toml | 4 +++- test/ad.jl | 17 +++++++++++------ test/runtests.jl | 14 ++++++++++++-- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/test/Project.toml b/test/Project.toml index 79e6d129b..95958d033 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -19,7 +19,6 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" LogDensityProblems = "6fdf6af0-433a-55f7-b3ed-c6c6e0b8df7c" MCMCChains = "c7f686f2-ff18-58e9-bc7b-31028e88f75d" MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" -Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6" OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" @@ -29,6 +28,9 @@ StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" +[weakdeps] +Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6" + [compat] ADTypes = "1" AbstractMCMC = "5" diff --git a/test/ad.jl b/test/ad.jl index 69ab99e19..c34624f5b 100644 --- a/test/ad.jl +++ b/test/ad.jl @@ -3,11 +3,16 @@ using DynamicPPL: LogDensityFunction @testset "Automatic differentiation" begin # Used as the ground truth that others are compared against. ref_adtype = AutoForwardDiff() - test_adtypes = [ - AutoReverseDiff(; compile=false), - AutoReverseDiff(; compile=true), - AutoMooncake(; config=nothing), - ] + + test_adtypes = if IS_PRERELEASE + [AutoReverseDiff(; compile=false), AutoReverseDiff(; compile=true)] + else + [ + AutoReverseDiff(; compile=false), + AutoReverseDiff(; compile=true), + AutoMooncake(; config=nothing), + ] + end @testset "Unsupported backends" begin @model demo() = x ~ Normal() @@ -16,7 +21,7 @@ using DynamicPPL: LogDensityFunction ) end - @testset "Correctness: ForwardDiff, ReverseDiff, and Mooncake" begin + @testset "Correctness" begin @testset "$(m.f)" for m in DynamicPPL.TestUtils.DEMO_MODELS rand_param_values = DynamicPPL.TestUtils.rand_prior_true(m) vns = DynamicPPL.TestUtils.varnames(m) diff --git a/test/runtests.jl b/test/runtests.jl index 06e58738d..626387319 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -12,7 +12,6 @@ using ForwardDiff using LogDensityProblems using MacroTools using MCMCChains -using Mooncake: Mooncake using StableRNGs using ReverseDiff using Zygote @@ -40,6 +39,15 @@ Random.seed!(100) include("test_util.jl") +# Don't attempt to import Mooncake on 1.12 +# https://github.com/chalk-lab/Mooncake.jl/pull/545 +IS_PRERELEASE = VERSION >= v"1.12" + +if !IS_PRERELEASE + Pkg.add("Mooncake") + using Mooncake: Mooncake +end + @testset verbose = true "DynamicPPL.jl" begin # The tests are split into two groups so that CI can run in parallel. The # groups are chosen to make both groups take roughly the same amount of @@ -81,7 +89,9 @@ include("test_util.jl") end @testset "ad" begin include("ext/DynamicPPLForwardDiffExt.jl") - include("ext/DynamicPPLMooncakeExt.jl") + if !IS_PRERELEASE + include("ext/DynamicPPLMooncakeExt.jl") + end include("ad.jl") end @testset "prob and logprob macro" begin From 32f90541642ea8d0a79788e97a20592821e6da6a Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Fri, 16 May 2025 12:50:20 +0100 Subject: [PATCH 02/13] Bump JET.jl compatibility to include 0.10 --- HISTORY.md | 5 +++++ Project.toml | 4 ++-- docs/Project.toml | 2 +- test/Project.toml | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 4e9bc2d42..1bda23e86 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,10 @@ # DynamicPPL Changelog +## 0.36.4 + +Added a compatibility entry for JET.jl 0.10. +This should only affect you if you are using DynamicPPL on the Julia 1.12 pre-release. + ## 0.36.3 Moved the `bijector(model)`, where `model` is a `DynamicPPL.Model`, function from the Turing main repo. diff --git a/Project.toml b/Project.toml index 5bef5bcb1..20e0fa03c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "DynamicPPL" uuid = "366bfd00-2699-11ea-058f-f148b4cae6d8" -version = "0.36.3" +version = "0.36.4" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" @@ -60,7 +60,7 @@ DocStringExtensions = "0.9" EnzymeCore = "0.6 - 0.8" ForwardDiff = "0.10.12" InteractiveUtils = "1" -JET = "0.9" +JET = "0.9, 0.10" KernelAbstractions = "0.9.33" LinearAlgebra = "1.6" LogDensityProblems = "2" diff --git a/docs/Project.toml b/docs/Project.toml index fdf8ae1d3..e362361bf 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -23,7 +23,7 @@ DocumenterMermaid = "0.1, 0.2" DynamicPPL = "0.36" FillArrays = "0.13, 1" ForwardDiff = "0.10" -JET = "0.9" +JET = "0.9, 0.10" LogDensityProblems = "2" MCMCChains = "5, 6" StableRNGs = "1" diff --git a/test/Project.toml b/test/Project.toml index 95958d033..accaf7625 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -46,7 +46,7 @@ DistributionsAD = "0.6.3" Documenter = "1" EnzymeCore = "0.6 - 0.8" ForwardDiff = "0.10.12" -JET = "0.9" +JET = "0.9, 0.10" LogDensityProblems = "2" MCMCChains = "6.0.4" MacroTools = "0.5.6" From 57bd1116d2afaab9e1f099a93e8919f04bd91d7d Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Fri, 16 May 2025 13:45:58 +0100 Subject: [PATCH 03/13] Disable doctests on prerelease --- test/runtests.jl | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 626387319..2873a3901 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -98,19 +98,22 @@ end @test_throws ErrorException prob"..." @test_throws ErrorException logprob"..." end - @testset "doctests" begin - DocMeta.setdocmeta!( - DynamicPPL, - :DocTestSetup, - :(using DynamicPPL, Distributions); - recursive=true, - ) - doctestfilters = [ - # Ignore the source of a warning in the doctest output, since this is dependent on host. - # This is a line that starts with "└ @ " and ends with the line number. - r"└ @ .+:[0-9]+", - ] - doctest(DynamicPPL; manual=false, doctestfilters=doctestfilters) + if !IS_PRERELEASE + # Don't run doctests on prerelease as error messages etc. may vary + @testset "doctests" begin + DocMeta.setdocmeta!( + DynamicPPL, + :DocTestSetup, + :(using DynamicPPL, Distributions); + recursive=true, + ) + doctestfilters = [ + # Ignore the source of a warning in the doctest output, since this is dependent on host. + # This is a line that starts with "└ @ " and ends with the line number. + r"└ @ .+:[0-9]+", + ] + doctest(DynamicPPL; manual=false, doctestfilters=doctestfilters) + end end end end From fa479f39f7200586253706c8cc737c32ca78f987 Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Fri, 16 May 2025 14:31:50 +0100 Subject: [PATCH 04/13] Fix version check --- test/runtests.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 2873a3901..174e06b58 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -41,7 +41,9 @@ include("test_util.jl") # Don't attempt to import Mooncake on 1.12 # https://github.com/chalk-lab/Mooncake.jl/pull/545 -IS_PRERELEASE = VERSION >= v"1.12" +# the check against v"1.12-" includes prerelease versions, +# whereas >=v"1.12" would only catch 1.12.0 onwards +IS_PRERELEASE = VERSION >= v"1.12-" if !IS_PRERELEASE Pkg.add("Mooncake") From 16ca002a6fecf7ccdff3ca70df7286acbf14be1c Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Fri, 16 May 2025 15:40:30 +0100 Subject: [PATCH 05/13] Split prerelease CI into two groups like the rest --- .github/workflows/JuliaPre.yml | 11 +++++++++++ test/runtests.jl | 14 +++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/JuliaPre.yml b/.github/workflows/JuliaPre.yml index 0c053faf1..c2442bf5c 100644 --- a/.github/workflows/JuliaPre.yml +++ b/.github/workflows/JuliaPre.yml @@ -14,6 +14,14 @@ permissions: jobs: test: runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + test_group: + - Group1 + - Group2 + steps: - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@v2 @@ -22,3 +30,6 @@ jobs: - uses: julia-actions/cache@v2 - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 + env: + GROUP: ${{ matrix.test_group }} + IS_PRERELEASE: "true" diff --git a/test/runtests.jl b/test/runtests.jl index 174e06b58..5a6a751cd 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -33,23 +33,19 @@ using OrderedCollections: OrderedSet using DynamicPPL: getargs_dottilde, getargs_tilde +# These flags are set in CI const GROUP = get(ENV, "GROUP", "All") const AQUA = get(ENV, "AQUA", "true") == "true" -Random.seed!(100) - -include("test_util.jl") - -# Don't attempt to import Mooncake on 1.12 -# https://github.com/chalk-lab/Mooncake.jl/pull/545 -# the check against v"1.12-" includes prerelease versions, -# whereas >=v"1.12" would only catch 1.12.0 onwards -IS_PRERELEASE = VERSION >= v"1.12-" +const IS_PRERELEASE = get(ENV, "IS_PRERELEASE", "false") == "true" if !IS_PRERELEASE Pkg.add("Mooncake") using Mooncake: Mooncake end +Random.seed!(100) +include("test_util.jl") + @testset verbose = true "DynamicPPL.jl" begin # The tests are split into two groups so that CI can run in parallel. The # groups are chosen to make both groups take roughly the same amount of From 7363432f89ab8d3a9432c850ea199de05a3e37bb Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Sun, 18 May 2025 12:54:13 +0100 Subject: [PATCH 06/13] Use VERSION.prerelease --- .github/workflows/JuliaPre.yml | 1 - test/runtests.jl | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/JuliaPre.yml b/.github/workflows/JuliaPre.yml index c2442bf5c..ca462289b 100644 --- a/.github/workflows/JuliaPre.yml +++ b/.github/workflows/JuliaPre.yml @@ -32,4 +32,3 @@ jobs: - uses: julia-actions/julia-runtest@v1 env: GROUP: ${{ matrix.test_group }} - IS_PRERELEASE: "true" diff --git a/test/runtests.jl b/test/runtests.jl index 5a6a751cd..462a827bb 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -36,8 +36,9 @@ using DynamicPPL: getargs_dottilde, getargs_tilde # These flags are set in CI const GROUP = get(ENV, "GROUP", "All") const AQUA = get(ENV, "AQUA", "true") == "true" -const IS_PRERELEASE = get(ENV, "IS_PRERELEASE", "false") == "true" +# Detect if prerelease version, if so, we skip some tests +const IS_PRERELEASE = !isempty(VERSION.prerelease) if !IS_PRERELEASE Pkg.add("Mooncake") using Mooncake: Mooncake From e0ec6014a750898c7811e89fa55616c2d4d25d3f Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Tue, 20 May 2025 14:36:54 +0100 Subject: [PATCH 07/13] Remove Mooncake test dep (use DPPL compat) --- test/Project.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/Project.toml b/test/Project.toml index accaf7625..a6fc71fcc 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -28,9 +28,6 @@ StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" -[weakdeps] -Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6" - [compat] ADTypes = "1" AbstractMCMC = "5" @@ -50,7 +47,6 @@ JET = "0.9, 0.10" LogDensityProblems = "2" MCMCChains = "6.0.4" MacroTools = "0.5.6" -Mooncake = "0.4.95" OrderedCollections = "1" ReverseDiff = "1" StableRNGs = "1" From 6974ab28f0f4085fa0d5dc773ca034b0636f5aff Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Tue, 20 May 2025 14:52:32 +0100 Subject: [PATCH 08/13] Move doctests into separate workflow --- .github/workflows/DocTest.yml | 59 +++++++++++++++++++++++++++++++++++ test/Project.toml | 2 -- test/runtests.jl | 18 ----------- 3 files changed, 59 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/DocTest.yml diff --git a/.github/workflows/DocTest.yml b/.github/workflows/DocTest.yml new file mode 100644 index 000000000..ebc5cbc1f --- /dev/null +++ b/.github/workflows/DocTest.yml @@ -0,0 +1,59 @@ +# We want to only run doctests on a single version of Julia, because +# things like error messages / output can change between versions and +# is fragile to test against. +name: Doctests + +on: + push: + branches: + - main + pull_request: + merge_group: + types: [checks_requested] + +# needed to allow julia-actions/cache to delete old caches that it has created +permissions: + actions: write + contents: read + +# Cancel existing tests on the same PR if a new commit is added to a pull request +concurrency: + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: julia-actions/setup-julia@v2 + with: + version: '1' + + - uses: julia-actions/cache@v2 + + - uses: julia-actions/julia-buildpkg@v1 + + - name: Run doctests + shell: julia --color=yes --project=docs {0} + run: | + # Develop currently checked out version of DynamicPPL + using Pkg + Pkg.develop(path=pwd()) + + using Documenter + DocMeta.setdocmeta!( + DynamicPPL, + :DocTestSetup, + :(using DynamicPPL, Distributions); + recursive=true, + ) + doctestfilters = [ + # Ignore the source of a warning in the doctest output, since this is dependent on host. + # This is a line that starts with "└ @ " and ends with the line number. + r"└ @ .+:[0-9]+", + ] + + doctest(DynamicPPL; manual=false, doctestfilters=doctestfilters) diff --git a/test/Project.toml b/test/Project.toml index a6fc71fcc..fdea8f506 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -11,7 +11,6 @@ DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63" Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" DistributionsAD = "ced4e74d-a319-5a8a-b0ac-84af2272839c" -Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" @@ -40,7 +39,6 @@ Compat = "4.3.0" DifferentiationInterface = "0.6.41" Distributions = "0.25" DistributionsAD = "0.6.3" -Documenter = "1" EnzymeCore = "0.6 - 0.8" ForwardDiff = "0.10.12" JET = "0.9, 0.10" diff --git a/test/runtests.jl b/test/runtests.jl index 462a827bb..ec5b66153 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -7,7 +7,6 @@ using Bijectors using DifferentiationInterface using Distributions using DistributionsAD -using Documenter using ForwardDiff using LogDensityProblems using MacroTools @@ -97,22 +96,5 @@ include("test_util.jl") @test_throws ErrorException prob"..." @test_throws ErrorException logprob"..." end - if !IS_PRERELEASE - # Don't run doctests on prerelease as error messages etc. may vary - @testset "doctests" begin - DocMeta.setdocmeta!( - DynamicPPL, - :DocTestSetup, - :(using DynamicPPL, Distributions); - recursive=true, - ) - doctestfilters = [ - # Ignore the source of a warning in the doctest output, since this is dependent on host. - # This is a line that starts with "└ @ " and ends with the line number. - r"└ @ .+:[0-9]+", - ] - doctest(DynamicPPL; manual=false, doctestfilters=doctestfilters) - end - end end end From f9d16c747bc487501fdd1183f2ee75f7375d7cd2 Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Tue, 20 May 2025 15:02:38 +0100 Subject: [PATCH 09/13] Fix dependencies needed for doctests --- .github/workflows/DocTest.yml | 4 +++- docs/Project.toml | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/DocTest.yml b/.github/workflows/DocTest.yml index ebc5cbc1f..bbadafb58 100644 --- a/.github/workflows/DocTest.yml +++ b/.github/workflows/DocTest.yml @@ -42,8 +42,10 @@ jobs: # Develop currently checked out version of DynamicPPL using Pkg Pkg.develop(path=pwd()) + Pkg.instantiate() + + using Documenter, DynamicPPL, Distributions - using Documenter DocMeta.setdocmeta!( DynamicPPL, :DocTestSetup, diff --git a/docs/Project.toml b/docs/Project.toml index e362361bf..571f42a80 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,4 +1,5 @@ [deps] +ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" AbstractPPL = "7a57a42e-76ec-4ea3-a279-07e840d6d9cf" Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" From cac8f9c41125dc5d64bbda5a16471b319a0182b0 Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Tue, 20 May 2025 15:15:14 +0100 Subject: [PATCH 10/13] Enable depwarns for doctests --- .github/workflows/DocTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/DocTest.yml b/.github/workflows/DocTest.yml index bbadafb58..524177b5f 100644 --- a/.github/workflows/DocTest.yml +++ b/.github/workflows/DocTest.yml @@ -37,7 +37,7 @@ jobs: - uses: julia-actions/julia-buildpkg@v1 - name: Run doctests - shell: julia --color=yes --project=docs {0} + shell: julia --color=yes --depwarn=yes --project=docs {0} run: | # Develop currently checked out version of DynamicPPL using Pkg From 027ccdc42c734c16cdb1a59819b65321e0bc63d9 Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Tue, 20 May 2025 15:52:30 +0100 Subject: [PATCH 11/13] Change length of ThreadSafeVarInfo logps to maxthreadid() --- HISTORY.md | 2 ++ src/threadsafe.jl | 2 +- test/threadsafe.jl | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 42613d08f..09f280073 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,6 +6,8 @@ Added compatibility with DifferentiationInterface.jl 0.7, and also with JET.jl 0 The JET compatibility entry should only affect you if you are using DynamicPPL on the Julia 1.12 pre-release. +The array of log probabilities stored in `ThreadSafeVarInfo` is now of length `Threads.maxthreadid()`, rather than `Threads.nthreads()`. + ## 0.36.3 Moved the `bijector(model)`, where `model` is a `DynamicPPL.Model`, function from the Turing main repo. diff --git a/src/threadsafe.jl b/src/threadsafe.jl index 2dc2645de..363e4dffb 100644 --- a/src/threadsafe.jl +++ b/src/threadsafe.jl @@ -9,7 +9,7 @@ struct ThreadSafeVarInfo{V<:AbstractVarInfo,L} <: AbstractVarInfo logps::L end function ThreadSafeVarInfo(vi::AbstractVarInfo) - return ThreadSafeVarInfo(vi, [Ref(zero(getlogp(vi))) for _ in 1:Threads.nthreads()]) + return ThreadSafeVarInfo(vi, [Ref(zero(getlogp(vi))) for _ in 1:Threads.maxthreadid()]) end ThreadSafeVarInfo(vi::ThreadSafeVarInfo) = vi diff --git a/test/threadsafe.jl b/test/threadsafe.jl index 72c439db8..2e5b3aa2f 100644 --- a/test/threadsafe.jl +++ b/test/threadsafe.jl @@ -5,7 +5,7 @@ @test threadsafe_vi.varinfo === vi @test threadsafe_vi.logps isa Vector{typeof(Ref(getlogp(vi)))} - @test length(threadsafe_vi.logps) == Threads.nthreads() + @test length(threadsafe_vi.logps) == Threads.maxthreadid() @test all(iszero(x[]) for x in threadsafe_vi.logps) end From af76f81ee25570caa92174f35b5a4cdf7fe6ceb0 Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Tue, 20 May 2025 16:48:29 +0100 Subject: [PATCH 12/13] Revert "Change length of ThreadSafeVarInfo logps to maxthreadid()" This reverts commit 027ccdc42c734c16cdb1a59819b65321e0bc63d9. maxthreadid() causes failures with Mooncake, even on 1.11, so this is not safe to change --- HISTORY.md | 2 -- src/threadsafe.jl | 2 +- test/threadsafe.jl | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 09f280073..42613d08f 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,8 +6,6 @@ Added compatibility with DifferentiationInterface.jl 0.7, and also with JET.jl 0 The JET compatibility entry should only affect you if you are using DynamicPPL on the Julia 1.12 pre-release. -The array of log probabilities stored in `ThreadSafeVarInfo` is now of length `Threads.maxthreadid()`, rather than `Threads.nthreads()`. - ## 0.36.3 Moved the `bijector(model)`, where `model` is a `DynamicPPL.Model`, function from the Turing main repo. diff --git a/src/threadsafe.jl b/src/threadsafe.jl index 363e4dffb..2dc2645de 100644 --- a/src/threadsafe.jl +++ b/src/threadsafe.jl @@ -9,7 +9,7 @@ struct ThreadSafeVarInfo{V<:AbstractVarInfo,L} <: AbstractVarInfo logps::L end function ThreadSafeVarInfo(vi::AbstractVarInfo) - return ThreadSafeVarInfo(vi, [Ref(zero(getlogp(vi))) for _ in 1:Threads.maxthreadid()]) + return ThreadSafeVarInfo(vi, [Ref(zero(getlogp(vi))) for _ in 1:Threads.nthreads()]) end ThreadSafeVarInfo(vi::ThreadSafeVarInfo) = vi diff --git a/test/threadsafe.jl b/test/threadsafe.jl index 2e5b3aa2f..72c439db8 100644 --- a/test/threadsafe.jl +++ b/test/threadsafe.jl @@ -5,7 +5,7 @@ @test threadsafe_vi.varinfo === vi @test threadsafe_vi.logps isa Vector{typeof(Ref(getlogp(vi)))} - @test length(threadsafe_vi.logps) == Threads.maxthreadid() + @test length(threadsafe_vi.logps) == Threads.nthreads() @test all(iszero(x[]) for x in threadsafe_vi.logps) end From 86be8b1615bfaccbc0bf4e1b83860cc36803dede Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Wed, 21 May 2025 11:13:48 +0100 Subject: [PATCH 13/13] Move doctest invocation back to test/runtests.jl --- .github/workflows/DocTest.yml | 26 +++----------------------- docs/Project.toml | 1 - test/Project.toml | 1 + test/runtests.jl | 14 ++++++++++++++ 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/.github/workflows/DocTest.yml b/.github/workflows/DocTest.yml index 524177b5f..73f337e13 100644 --- a/.github/workflows/DocTest.yml +++ b/.github/workflows/DocTest.yml @@ -36,26 +36,6 @@ jobs: - uses: julia-actions/julia-buildpkg@v1 - - name: Run doctests - shell: julia --color=yes --depwarn=yes --project=docs {0} - run: | - # Develop currently checked out version of DynamicPPL - using Pkg - Pkg.develop(path=pwd()) - Pkg.instantiate() - - using Documenter, DynamicPPL, Distributions - - DocMeta.setdocmeta!( - DynamicPPL, - :DocTestSetup, - :(using DynamicPPL, Distributions); - recursive=true, - ) - doctestfilters = [ - # Ignore the source of a warning in the doctest output, since this is dependent on host. - # This is a line that starts with "└ @ " and ends with the line number. - r"└ @ .+:[0-9]+", - ] - - doctest(DynamicPPL; manual=false, doctestfilters=doctestfilters) + - uses: julia-actions/julia-runtest@v1 + env: + GROUP: Doctests diff --git a/docs/Project.toml b/docs/Project.toml index 571f42a80..e362361bf 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,5 +1,4 @@ [deps] -ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" AbstractPPL = "7a57a42e-76ec-4ea3-a279-07e840d6d9cf" Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" diff --git a/test/Project.toml b/test/Project.toml index 59e9550a7..20ae16b44 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -11,6 +11,7 @@ DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63" Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" DistributionsAD = "ced4e74d-a319-5a8a-b0ac-84af2272839c" +Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" diff --git a/test/runtests.jl b/test/runtests.jl index ec5b66153..6c977084c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -7,6 +7,7 @@ using Bijectors using DifferentiationInterface using Distributions using DistributionsAD +using Documenter using ForwardDiff using LogDensityProblems using MacroTools @@ -97,4 +98,17 @@ include("test_util.jl") @test_throws ErrorException logprob"..." end end + + if GROUP == "All" || GROUP == "Doctests" + DocMeta.setdocmeta!( + DynamicPPL, :DocTestSetup, :(using DynamicPPL, Distributions); recursive=true + ) + doctestfilters = [ + # Ignore the source of a warning in the doctest output, since this is dependent on host. + # This is a line that starts with "└ @ " and ends with the line number. + r"└ @ .+:[0-9]+", + ] + + doctest(DynamicPPL; manual=false, doctestfilters=doctestfilters) + end end