Skip to content

Disable Mooncake on prerelease; bump min Julia to 1.10.2; regroup CI tests #2569

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 8 commits into from
May 30, 2025
Merged
Show file tree
Hide file tree
Changes from all 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: 3 additions & 7 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,12 @@ jobs:
# not included in the others.
- name: "mcmc/gibbs"
args: "mcmc/gibbs.jl"
- name: "mcmc/hmc"
args: "mcmc/hmc.jl"
- name: "mcmc/abstractmcmc"
args: "mcmc/abstractmcmc.jl"
- name: "mcmc/Inference"
args: "mcmc/Inference.jl"
- name: "mcmc/ess"
args: "mcmc/ess.jl"
- name: "ad"
args: "ad.jl"
- name: "everything else"
args: "--skip mcmc/gibbs.jl mcmc/hmc.jl mcmc/abstractmcmc.jl mcmc/Inference.jl mcmc/ess.jl"
args: "--skip mcmc/gibbs.jl mcmc/Inference.jl ad.jl"
runner:
# Default
- version: '1'
Expand Down
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Release 0.38.4

The minimum Julia version was increased to 1.10.2 (from 1.10.0).
On versions before 1.10.2, `sample()` took an excessively long time to run (probably due to compilation).

# Release 0.38.3

`getparams(::Model, ::AbstractVarInfo)` now returns an empty `Float64[]` if the VarInfo contains no parameters.
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 = "Turing"
uuid = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"
version = "0.38.3"
version = "0.38.4"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down Expand Up @@ -83,7 +83,7 @@ Statistics = "1.6"
StatsAPI = "1.6"
StatsBase = "0.32, 0.33, 0.34"
StatsFuns = "0.8, 0.9, 1"
julia = "1.10"
julia = "1.10.2"

[extras]
DynamicHMC = "bbc10e6e-7c05-544b-b16e-64fede858acb"
Expand Down
2 changes: 0 additions & 2 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LogDensityProblems = "6fdf6af0-433a-55f7-b3ed-c6c6e0b8df7c"
LogDensityProblemsAD = "996a588d-648d-4e1f-a8f0-a84b347e47b1"
MCMCChains = "c7f686f2-ff18-58e9-bc7b-31028e88f75d"
Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"
NamedArrays = "86f7a689-2022-50b4-a561-43c23ac3c673"
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba"
Expand Down Expand Up @@ -61,7 +60,6 @@ LinearAlgebra = "1"
LogDensityProblems = "2"
LogDensityProblemsAD = "1.4"
MCMCChains = "5, 6, 7"
Mooncake = "0.4.95"
NamedArrays = "0.9.4, 0.10"
Optim = "1"
Optimization = "3, 4"
Expand Down
27 changes: 19 additions & 8 deletions test/ad.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,23 @@ using Random: Random
using StableRNGs: StableRNG
using Test
using ..Models: gdemo_default
import ForwardDiff, ReverseDiff, Mooncake
import ForwardDiff, ReverseDiff

# Detect if prerelease version, if so, we skip some tests
const IS_PRERELEASE = !isempty(VERSION.prerelease)
const INCLUDE_MOONCAKE = !IS_PRERELEASE

if INCLUDE_MOONCAKE
import Pkg
Pkg.add("Mooncake")
using Mooncake: Mooncake
end

"""Element types that are always valid for a VarInfo regardless of ADType."""
const always_valid_eltypes = (AbstractFloat, AbstractIrrational, Integer, Rational)

"""A dictionary mapping ADTypes to the element types they use."""
const eltypes_by_adtype = Dict(
eltypes_by_adtype = Dict(
Turing.AutoForwardDiff => (ForwardDiff.Dual,),
Turing.AutoReverseDiff => (
ReverseDiff.TrackedArray,
Expand All @@ -25,8 +35,10 @@ const eltypes_by_adtype = Dict(
ReverseDiff.TrackedVecOrMat,
ReverseDiff.TrackedVector,
),
Turing.AutoMooncake => (Mooncake.CoDual,),
)
if INCLUDE_MOONCAKE
eltypes_by_adtype[Turing.AutoMooncake] = (Mooncake.CoDual,)
end

"""
AbstractWrongADBackendError
Expand Down Expand Up @@ -177,11 +189,10 @@ end
"""
All the ADTypes on which we want to run the tests.
"""
ADTYPES = [
Turing.AutoForwardDiff(),
Turing.AutoReverseDiff(; compile=false),
Turing.AutoMooncake(; config=nothing),
]
ADTYPES = [Turing.AutoForwardDiff(), Turing.AutoReverseDiff(; compile=false)]
if INCLUDE_MOONCAKE
push!(ADTYPES, Turing.AutoMooncake(; config=nothing))
end

# Check that ADTypeCheckContext itself works as expected.
@testset "ADTypeCheckContext" begin
Expand Down
1 change: 0 additions & 1 deletion test/mcmc/Inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import MCMCChains
import Random
import ReverseDiff
using StableRNGs: StableRNG
import Mooncake
using Test: @test, @test_throws, @testset
using Turing

Expand Down
1 change: 0 additions & 1 deletion test/mcmc/abstractmcmc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ using LogDensityProblems: LogDensityProblems
using Random: Random
using ReverseDiff: ReverseDiff
using StableRNGs: StableRNG
import Mooncake
using Test: @test, @test_throws, @testset
using Turing
using Turing.Inference: AdvancedHMC
Expand Down
1 change: 0 additions & 1 deletion test/mcmc/gibbs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ using DynamicPPL: DynamicPPL
using ForwardDiff: ForwardDiff
using Random: Random
using ReverseDiff: ReverseDiff
import Mooncake
using StableRNGs: StableRNG
using Test: @inferred, @test, @test_broken, @test_throws, @testset
using Turing
Expand Down
1 change: 0 additions & 1 deletion test/mcmc/hmc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ using LinearAlgebra: I, dot, vec
import Random
using StableRNGs: StableRNG
using StatsFuns: logistic
import Mooncake
using Test: @test, @test_logs, @testset, @test_throws
using Turing

Expand Down
1 change: 0 additions & 1 deletion test/mcmc/sghmc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import ForwardDiff
using LinearAlgebra: dot
import ReverseDiff
using StableRNGs: StableRNG
import Mooncake
using Test: @test, @testset
using Turing

Expand Down
2 changes: 0 additions & 2 deletions test/optimisation/Optimisation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ using ..Models: gdemo, gdemo_default
using Distributions
using Distributions.FillArrays: Zeros
using DynamicPPL: DynamicPPL
using ForwardDiff: ForwardDiff
using LinearAlgebra: Diagonal, I
using Mooncake: Mooncake
using Random: Random
using Optimization
using Optimization: Optimization
Expand Down