diff --git a/.github/workflows/DocTest.yml b/.github/workflows/DocTest.yml new file mode 100644 index 000000000..73f337e13 --- /dev/null +++ b/.github/workflows/DocTest.yml @@ -0,0 +1,41 @@ +# 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 + + - uses: julia-actions/julia-runtest@v1 + env: + GROUP: Doctests diff --git a/.github/workflows/JuliaPre.yml b/.github/workflows/JuliaPre.yml index 0c053faf1..ca462289b 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,5 @@ jobs: - uses: julia-actions/cache@v2 - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 + env: + GROUP: ${{ matrix.test_group }} diff --git a/HISTORY.md b/HISTORY.md index 26eaa2d39..42613d08f 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,7 +2,9 @@ ## 0.36.4 -Added compatibility with DifferentiationInterface.jl 0.7. +Added compatibility with DifferentiationInterface.jl 0.7, and also with JET.jl 0.10. + +The JET compatibility entry should only affect you if you are using DynamicPPL on the Julia 1.12 pre-release. ## 0.36.3 diff --git a/Project.toml b/Project.toml index 128822367..6b3f445e3 100644 --- a/Project.toml +++ b/Project.toml @@ -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 92e81bb83..20ae16b44 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" @@ -41,14 +40,12 @@ Compat = "4.3.0" DifferentiationInterface = "0.6.41, 0.7" Distributions = "0.25" 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" -Mooncake = "0.4.95" OrderedCollections = "1" ReverseDiff = "1" StableRNGs = "1" 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..6c977084c 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 @@ -34,10 +33,18 @@ 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) +# 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 +end + +Random.seed!(100) include("test_util.jl") @testset verbose = true "DynamicPPL.jl" begin @@ -81,26 +88,27 @@ 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 @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) - 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