Skip to content

JET + Mooncake fixes for 1.12 #921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/JuliaPre.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
6 changes: 4 additions & 2 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -29,6 +28,9 @@ StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[weakdeps]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it mean for something to be a weak dependency of tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, no idea now, I remember needing to add it to satisfy something. It could have been because of the compat entry i.e. if we remove the Mooncake compat entry from test/Project.toml it might be fine. Let me try that

Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"

[compat]
ADTypes = "1"
AbstractMCMC = "5"
Expand All @@ -44,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"
Expand Down
17 changes: 11 additions & 6 deletions test/ad.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down
44 changes: 28 additions & 16 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ using ForwardDiff
using LogDensityProblems
using MacroTools
using MCMCChains
using Mooncake: Mooncake
using StableRNGs
using ReverseDiff
using Zygote
Expand All @@ -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
Expand Down Expand Up @@ -81,26 +88,31 @@ 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)
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
Loading