Skip to content

Commit

Permalink
Bump Julia lower bound to v1.10 (LTS) (#225)
Browse files Browse the repository at this point in the history
* Bump minimum supported Julia version to LTS

* Run CI on LTS

* Bump Optimization lower bound to 3.21

* Bump Optimization dependencies for compatibility

* Remove workaround for old Optimization versions

* Add missing compat bound for OptimizationNLopt

* Drop support for old OptimizationOptimJL version

* Bump OptimizationOptimJL compat

* Match package bounds

* Match package bounds in docs compat

* Bump StatsPlots compat

* Change stdlib compats to 1

* Bump integration test julia bounds

* Fix deprecation warning

* Remove Unpack as dependency

* Bump StatsBase compat

To bring in bugfix in `histrange`

* Remove unnecessary version checks

* Increment patch number
  • Loading branch information
sethaxen authored Jan 3, 2025
1 parent de9073e commit 52fef88
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 105 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.6'
- 'lts'
- '1'
- 'pre'
os:
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
include:
- version: '1'
downgrade: false
- version: '1.7'
- version: 'lts'
downgrade: true
steps:
- uses: actions/checkout@v4
Expand Down
27 changes: 13 additions & 14 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Pathfinder"
uuid = "b1d3bc72-d0e7-4279-b92f-7fa5d6d2d454"
authors = ["Seth Axen <[email protected]> and contributors"]
version = "0.9.8"
version = "0.9.9"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand All @@ -23,7 +23,6 @@ SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
Transducers = "28d57a85-8fef-5791-bfe6-a80928e7c999"
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"

[weakdeps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand All @@ -37,34 +36,34 @@ PathfinderDynamicHMCExt = "DynamicHMC"
PathfinderTuringExt = ["Accessors", "DynamicPPL", "MCMCChains", "Turing"]

[compat]
ADTypes = "0.2, 1"
ADTypes = "0.2.5, 1"
Accessors = "0.1.12"
Distributions = "0.25.87"
DynamicHMC = "3.4.0"
DynamicPPL = "0.25.2, 0.27, 0.28, 0.29, 0.30, 0.31, 0.32"
Folds = "0.2.9"
ForwardDiff = "0.10.19"
ForwardDiff = "0.10.26"
IrrationalConstants = "0.1.1, 0.2"
LinearAlgebra = "1.6"
LinearAlgebra = "1"
LogDensityProblems = "2.1.0"
LogDensityProblemsAD = "1.7.0"
MCMCChains = "6.0.2"
Optim = "1.7.2"
Optimization = "3.16.0, 4"
OptimizationOptimJL = "0.1.7, 0.2, 0.3, 0.4"
Optimization = "3.21, 4"
OptimizationNLopt = "0.2, 0.3"
OptimizationOptimJL = "0.2.1, 0.3, 0.4"
PDMats = "0.11.26"
PSIS = "0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9"
ProgressLogging = "0.1.4"
Random = "1.6"
Random = "1"
Requires = "1.1"
ReverseDiff = "1.4.5"
SciMLBase = "1.95.0, 2"
Statistics = "1.6"
StatsBase = "0.33.7, 0.34"
ReverseDiff = "1.15"
SciMLBase = "2.30"
Statistics = "1"
StatsBase = "0.33.17, 0.34"
Transducers = "0.4.81"
Turing = "0.31.4, 0.32, 0.33, 0.34, 0.35"
UnPack = "1"
julia = "1.6"
julia = "1.10"

[extras]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand Down
8 changes: 4 additions & 4 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ TransformedLogDensities = "f9bc47f6-f3f8-4f3b-ab21-f8bc73906f26"
Turing = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"

[compat]
ADTypes = "0.2, 1"
ADTypes = "0.2.5, 1"
AdvancedHMC = "0.6"
Documenter = "1"
DocumenterCitations = "1.2"
DocumenterInterLinks = "1"
DynamicHMC = "3.4.0"
ForwardDiff = "0.10.19"
ForwardDiff = "0.10.26"
LogDensityProblems = "2.1.0"
LogDensityProblemsAD = "1.7"
Pathfinder = "0.9"
ReverseDiff = "1.4.5"
ReverseDiff = "1.15"
StatsFuns = "1"
StatsPlots = "0.14.21, 0.15"
StatsPlots = "0.15.2"
TransformVariables = "0.6.2, 0.7, 0.8"
TransformedLogDensities = "1.0.2"
Turing = "0.31.4, 0.32, 0.33, 0.34, 0.35"
1 change: 0 additions & 1 deletion src/Pathfinder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ using SciMLBase: SciMLBase
using Statistics: Statistics
using StatsBase: StatsBase
using Transducers: Transducers
using UnPack: @unpack

export PathfinderResult, MultiPathfinderResult
export pathfinder, multipathfinder
Expand Down
66 changes: 20 additions & 46 deletions src/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,54 +98,28 @@ struct OptimizationCallback{X,FX,∇FX,ID,CB}
fail_on_nonfinite::Bool
end

@static if isdefined(Optimization, :OptimizationState)
# Optimization v3.21.0 and later
function (cb::OptimizationCallback)(state::Optimization.OptimizationState, args...)
@unpack (
xs, fxs, ∇fxs, progress_name, progress_id, maxiters, callback, fail_on_nonfinite
) = cb
ret = callback !== nothing && callback(state, args...)
iteration = state.iter
Base.@logmsg ProgressLogging.ProgressLevel progress_name progress =
iteration / maxiters _id = progress_id

x = copy(state.u)
fx = -state.objective
∇fx = state.grad === nothing ? nothing : -state.grad

# some backends mutate x, so we must copy it
push!(xs, x)
push!(fxs, fx)
push!(∇fxs, ∇fx)

if fail_on_nonfinite && !ret
ret = (isnan(fx) || fx == Inf || (∇fx !== nothing && any(!isfinite, ∇fx)))::Bool
end

return ret
function (cb::OptimizationCallback)(state::Optimization.OptimizationState, args...)
(; xs, fxs, ∇fxs, progress_name, progress_id, maxiters, callback, fail_on_nonfinite) =
cb
ret = callback !== nothing && callback(state, args...)
iteration = state.iter
Base.@logmsg ProgressLogging.ProgressLevel progress_name progress = iteration / maxiters _id =
progress_id

x = copy(state.u)
fx = -state.objective
∇fx = state.grad === nothing ? nothing : -state.grad

# some backends mutate x, so we must copy it
push!(xs, x)
push!(fxs, fx)
push!(∇fxs, ∇fx)

if fail_on_nonfinite && !ret
ret = (isnan(fx) || fx == Inf || (∇fx !== nothing && any(!isfinite, ∇fx)))::Bool
end
else
# Optimization v3.20.X and earlier
function (cb::OptimizationCallback)(x, nfx, args...)
@unpack (
xs, fxs, ∇fxs, progress_name, progress_id, maxiters, callback, fail_on_nonfinite
) = cb
ret = callback !== nothing && callback(x, nfx, args...)
iteration = length(cb.xs)
Base.@logmsg ProgressLogging.ProgressLevel progress_name progress =
iteration / maxiters _id = progress_id

# some backends mutate x, so we must copy it
push!(xs, copy(x))
push!(fxs, -nfx)
push!(∇fxs, nothing)

if fail_on_nonfinite && !ret
ret = (isnan(nfx) || nfx == -Inf)::Bool
end

return ret
end
return ret
end

struct OptimizationTrace{P,L}
Expand Down
2 changes: 1 addition & 1 deletion src/singlepath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function pathfinder(
kwargs...,
)
end
@unpack (
(;
itry,
success,
optim_prob,
Expand Down
2 changes: 1 addition & 1 deletion src/woodbury.jl
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ function Base.AbstractMatrix{T}(W::WoodburyPDMat) where {T}
F = pdfactorize(W)
Fnew = WoodburyPDFactorization(
convert(AbstractMatrix{T}, F.U),
convert(AbstractMatrix{T}, F.Q),
convert(LinearAlgebra.AbstractQ{T}, F.Q),
convert(AbstractMatrix{T}, F.V),
)
return WoodburyPDMat(
Expand Down
6 changes: 1 addition & 5 deletions test/elbo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ using Transducers
logp(x) = logpdf(target_dist, x[1])
σs = [1e-3, 0.05, σ_target, 1.0, 1.1, 1.2, 5.0, 10.0]
dists = Normal.(0, σs)
if VERSION v"1.7.0"
executors = [SequentialEx(), ThreadedEx()]
else
executors = [SequentialEx()]
end
executors = [SequentialEx(), ThreadedEx()]
@testset "$executor" for executor in executors
rng = Random.seed!(Random.default_rng(), 42)
lopt, estimates = @inferred Pathfinder.maximize_elbo(
Expand Down
4 changes: 2 additions & 2 deletions test/integration/AdvancedHMC/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ TransformedLogDensities = "f9bc47f6-f3f8-4f3b-ab21-f8bc73906f26"
[compat]
AdvancedHMC = "0.6"
Distributions = "0.25.87"
ForwardDiff = "0.10.19"
ForwardDiff = "0.10.26"
LogDensityProblems = "2.1.0"
LogDensityProblemsAD = "1.7"
MCMCDiagnosticTools = "0.3"
Expand All @@ -28,4 +28,4 @@ Statistics = "1"
StatsFuns = "1"
TransformVariables = "0.6.2, 0.7, 0.8"
TransformedLogDensities = "1.0.2"
julia = "1.6"
julia = "1.10"
2 changes: 1 addition & 1 deletion test/integration/DynamicHMC/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ Statistics = "1"
StatsFuns = "1"
TransformVariables = "0.6.2, 0.7, 0.8"
TransformedLogDensities = "1.0.2"
julia = "1.6"
julia = "1.10"
2 changes: 1 addition & 1 deletion test/integration/Turing/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Turing = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"
LogDensityProblems = "2.1.0"
Pathfinder = "0.9"
Turing = "0.31.4, 0.32, 0.33, 0.34, 0.35"
julia = "1.6"
julia = "1.10"
6 changes: 1 addition & 5 deletions test/multipath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ using Transducers
d = MvNormal(μ, Σ)
logp(x) = logpdf(d, x)
= build_logdensityproblem(logp, dim, 2)
rngs = if VERSION v"1.7"
[MersenneTwister(), Random.default_rng()]
else
[MersenneTwister()]
end
rngs = [MersenneTwister(), Random.default_rng()]
seed = 76
@testset for rng in rngs
executor = rng isa MersenneTwister ? SequentialEx() : ThreadedEx()
Expand Down
19 changes: 7 additions & 12 deletions test/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,13 @@ end
(isdefined(Optimization, :OptimizationState) && !isfinite(gval))
)
)
if isdefined(Optimization, :OptimizationState)
# Optimization v3.21.0 and later
callback = (state, args...) -> cbfail
state = Optimization.OptimizationState(;
iter=0, u=x, objective=-fval, grad=-∇f(x)
)
cb_args = (state, -fval)
else
# Optimization v3.20.X and earlier
callback = (x, fx, args...) -> cbfail
cb_args = (x, -fval)
end

callback = (state, args...) -> cbfail
state = Optimization.OptimizationState(;
iter=0, u=x, objective=-fval, grad=-∇f(x)
)
cb_args = (state, -fval)

cb = Pathfinder.OptimizationCallback(
xs,
fxs,
Expand Down
12 changes: 2 additions & 10 deletions test/singlepath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ using Transducers
# here pathfinder finds the exact solution after 1 iteration
logp(x) = -sum(abs2, x) / 2
ndraws = 100
rngs = if VERSION v"1.7"
[MersenneTwister(), Random.default_rng()]
else
[MersenneTwister()]
end
rngs = [MersenneTwister(), Random.default_rng()]
seed = 42
@testset for dim in [1, 5, 10, 100], rng in rngs
executor = rng isa MersenneTwister ? SequentialEx() : ThreadedEx()
Expand Down Expand Up @@ -83,11 +79,7 @@ using Transducers
dim = 5
= build_logdensityproblem(logp, dim, 2)
ndraws_elbo = 100
rngs = if VERSION v"1.7"
[MersenneTwister(), Random.default_rng()]
else
[MersenneTwister()]
end
rngs = [MersenneTwister(), Random.default_rng()]
x = randn(dim)
seed = 38
optimizer = Optim.LBFGS(; m=6)
Expand Down

2 comments on commit 52fef88

@sethaxen
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/122360

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.9.9 -m "<description of version>" 52fef889ec6b579e35d251c0fc5b74628214b98f
git push origin v0.9.9

Please sign in to comment.