Skip to content

Commit 3acd0a2

Browse files
authored
JET + Mooncake fixes for 1.12 (#921)
* Don't test Mooncake on 1.12 * Bump JET.jl compatibility to include 0.10 * Disable doctests on prerelease * Fix version check * Split prerelease CI into two groups like the rest * Use VERSION.prerelease * Remove Mooncake test dep (use DPPL compat) * Move doctests into separate workflow * Fix dependencies needed for doctests * Enable depwarns for doctests * Change length of ThreadSafeVarInfo logps to maxthreadid() * Revert "Change length of ThreadSafeVarInfo logps to maxthreadid()" This reverts commit 027ccdc. maxthreadid() causes failures with Mooncake, even on 1.11, so this is not safe to change * Move doctest invocation back to test/runtests.jl
1 parent 072234d commit 3acd0a2

File tree

8 files changed

+93
-30
lines changed

8 files changed

+93
-30
lines changed

.github/workflows/DocTest.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# We want to only run doctests on a single version of Julia, because
2+
# things like error messages / output can change between versions and
3+
# is fragile to test against.
4+
name: Doctests
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
merge_group:
12+
types: [checks_requested]
13+
14+
# needed to allow julia-actions/cache to delete old caches that it has created
15+
permissions:
16+
actions: write
17+
contents: read
18+
19+
# Cancel existing tests on the same PR if a new commit is added to a pull request
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
22+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
23+
24+
jobs:
25+
test:
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- uses: julia-actions/setup-julia@v2
32+
with:
33+
version: '1'
34+
35+
- uses: julia-actions/cache@v2
36+
37+
- uses: julia-actions/julia-buildpkg@v1
38+
39+
- uses: julia-actions/julia-runtest@v1
40+
env:
41+
GROUP: Doctests

.github/workflows/JuliaPre.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ permissions:
1414
jobs:
1515
test:
1616
runs-on: ubuntu-latest
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
test_group:
22+
- Group1
23+
- Group2
24+
1725
steps:
1826
- uses: actions/checkout@v4
1927
- uses: julia-actions/setup-julia@v2
@@ -22,3 +30,5 @@ jobs:
2230
- uses: julia-actions/cache@v2
2331
- uses: julia-actions/julia-buildpkg@v1
2432
- uses: julia-actions/julia-runtest@v1
33+
env:
34+
GROUP: ${{ matrix.test_group }}

HISTORY.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
## 0.36.4
44

5-
Added compatibility with DifferentiationInterface.jl 0.7.
5+
Added compatibility with DifferentiationInterface.jl 0.7, and also with JET.jl 0.10.
6+
7+
The JET compatibility entry should only affect you if you are using DynamicPPL on the Julia 1.12 pre-release.
68

79
## 0.36.3
810

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ DocStringExtensions = "0.9"
6060
EnzymeCore = "0.6 - 0.8"
6161
ForwardDiff = "0.10.12"
6262
InteractiveUtils = "1"
63-
JET = "0.9"
63+
JET = "0.9, 0.10"
6464
KernelAbstractions = "0.9.33"
6565
LinearAlgebra = "1.6"
6666
LogDensityProblems = "2"

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ DocumenterMermaid = "0.1, 0.2"
2323
DynamicPPL = "0.36"
2424
FillArrays = "0.13, 1"
2525
ForwardDiff = "0.10"
26-
JET = "0.9"
26+
JET = "0.9, 0.10"
2727
LogDensityProblems = "2"
2828
MCMCChains = "5, 6"
2929
StableRNGs = "1"

test/Project.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1919
LogDensityProblems = "6fdf6af0-433a-55f7-b3ed-c6c6e0b8df7c"
2020
MCMCChains = "c7f686f2-ff18-58e9-bc7b-31028e88f75d"
2121
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
22-
Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"
2322
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
2423
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
2524
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
@@ -41,14 +40,12 @@ Compat = "4.3.0"
4140
DifferentiationInterface = "0.6.41, 0.7"
4241
Distributions = "0.25"
4342
DistributionsAD = "0.6.3"
44-
Documenter = "1"
4543
EnzymeCore = "0.6 - 0.8"
4644
ForwardDiff = "0.10.12"
47-
JET = "0.9"
45+
JET = "0.9, 0.10"
4846
LogDensityProblems = "2"
4947
MCMCChains = "6.0.4"
5048
MacroTools = "0.5.6"
51-
Mooncake = "0.4.95"
5249
OrderedCollections = "1"
5350
ReverseDiff = "1"
5451
StableRNGs = "1"

test/ad.jl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ using DynamicPPL: LogDensityFunction
33
@testset "Automatic differentiation" begin
44
# Used as the ground truth that others are compared against.
55
ref_adtype = AutoForwardDiff()
6-
test_adtypes = [
7-
AutoReverseDiff(; compile=false),
8-
AutoReverseDiff(; compile=true),
9-
AutoMooncake(; config=nothing),
10-
]
6+
7+
test_adtypes = if IS_PRERELEASE
8+
[AutoReverseDiff(; compile=false), AutoReverseDiff(; compile=true)]
9+
else
10+
[
11+
AutoReverseDiff(; compile=false),
12+
AutoReverseDiff(; compile=true),
13+
AutoMooncake(; config=nothing),
14+
]
15+
end
1116

1217
@testset "Unsupported backends" begin
1318
@model demo() = x ~ Normal()
@@ -16,7 +21,7 @@ using DynamicPPL: LogDensityFunction
1621
)
1722
end
1823

19-
@testset "Correctness: ForwardDiff, ReverseDiff, and Mooncake" begin
24+
@testset "Correctness" begin
2025
@testset "$(m.f)" for m in DynamicPPL.TestUtils.DEMO_MODELS
2126
rand_param_values = DynamicPPL.TestUtils.rand_prior_true(m)
2227
vns = DynamicPPL.TestUtils.varnames(m)

test/runtests.jl

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ using ForwardDiff
1212
using LogDensityProblems
1313
using MacroTools
1414
using MCMCChains
15-
using Mooncake: Mooncake
1615
using StableRNGs
1716
using ReverseDiff
1817
using Zygote
@@ -34,10 +33,18 @@ using OrderedCollections: OrderedSet
3433

3534
using DynamicPPL: getargs_dottilde, getargs_tilde
3635

36+
# These flags are set in CI
3737
const GROUP = get(ENV, "GROUP", "All")
3838
const AQUA = get(ENV, "AQUA", "true") == "true"
39-
Random.seed!(100)
4039

40+
# Detect if prerelease version, if so, we skip some tests
41+
const IS_PRERELEASE = !isempty(VERSION.prerelease)
42+
if !IS_PRERELEASE
43+
Pkg.add("Mooncake")
44+
using Mooncake: Mooncake
45+
end
46+
47+
Random.seed!(100)
4148
include("test_util.jl")
4249

4350
@testset verbose = true "DynamicPPL.jl" begin
@@ -81,26 +88,27 @@ include("test_util.jl")
8188
end
8289
@testset "ad" begin
8390
include("ext/DynamicPPLForwardDiffExt.jl")
84-
include("ext/DynamicPPLMooncakeExt.jl")
91+
if !IS_PRERELEASE
92+
include("ext/DynamicPPLMooncakeExt.jl")
93+
end
8594
include("ad.jl")
8695
end
8796
@testset "prob and logprob macro" begin
8897
@test_throws ErrorException prob"..."
8998
@test_throws ErrorException logprob"..."
9099
end
91-
@testset "doctests" begin
92-
DocMeta.setdocmeta!(
93-
DynamicPPL,
94-
:DocTestSetup,
95-
:(using DynamicPPL, Distributions);
96-
recursive=true,
97-
)
98-
doctestfilters = [
99-
# Ignore the source of a warning in the doctest output, since this is dependent on host.
100-
# This is a line that starts with "└ @ " and ends with the line number.
101-
r"└ @ .+:[0-9]+",
102-
]
103-
doctest(DynamicPPL; manual=false, doctestfilters=doctestfilters)
104-
end
100+
end
101+
102+
if GROUP == "All" || GROUP == "Doctests"
103+
DocMeta.setdocmeta!(
104+
DynamicPPL, :DocTestSetup, :(using DynamicPPL, Distributions); recursive=true
105+
)
106+
doctestfilters = [
107+
# Ignore the source of a warning in the doctest output, since this is dependent on host.
108+
# This is a line that starts with "└ @ " and ends with the line number.
109+
r"└ @ .+:[0-9]+",
110+
]
111+
112+
doctest(DynamicPPL; manual=false, doctestfilters=doctestfilters)
105113
end
106114
end

0 commit comments

Comments
 (0)