Skip to content
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
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.47.1

`setprogress!` is now a re-export of `AbstractMCMC.setprogress!`, so `Turing.setprogress!(false)` keeps working and there is a single progress logging switch instead of two. The internal `Turing.PROGRESS` flag is gone, its state lives in `AbstractMCMC.PROGRESS`.

# 0.47.0

## Breaking changes
Expand Down
2 changes: 1 addition & 1 deletion 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.47.0"
version = "0.47.1"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
4 changes: 1 addition & 3 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ See the [AD guide](https://turinglang.org/docs/tutorials/docs-10-using-turing-au

### Debugging

```@docs
setprogress!
```
`setprogress!` is re-exported from AbstractMCMC. See [`AbstractMCMC.setprogress!`](@extref).

### Distributions

Expand Down
18 changes: 2 additions & 16 deletions src/Turing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ using LogDensityProblems: LogDensityProblems
using StatsAPI: StatsAPI
using StatsBase: StatsBase
using AbstractMCMC
using AbstractMCMC: setprogress!
using FlexiChains

using Printf: Printf
Expand All @@ -24,21 +25,6 @@ using ADTypes: ADTypes, AutoForwardDiff, AutoReverseDiff, AutoMooncake, AutoEnzy

const DEFAULT_ADTYPE = ADTypes.AutoForwardDiff()

const PROGRESS = Ref(true)

# TODO: remove `PROGRESS` and this function in favour of `AbstractMCMC.PROGRESS`
"""
setprogress!(progress::Bool)

Enable progress logging in Turing if `progress` is `true`, and disable it otherwise.
"""
function setprogress!(progress::Bool)
@info "[Turing]: progress logging is $(progress ? "enabled" : "disabled") globally"
PROGRESS[] = progress
AbstractMCMC.setprogress!(progress; silent=true)
return progress
end

# Random probability measures.
include("stdlib/distributions.jl")
include("stdlib/RandomMeasures.jl")
Expand Down Expand Up @@ -141,7 +127,7 @@ export
AutoReverseDiff,
AutoMooncake,
AutoEnzyme,
# Debugging - Turing
# Progress logging - re-exported from AbstractMCMC
setprogress!,
# Distributions
Flat,
Expand Down
2 changes: 1 addition & 1 deletion src/mcmc/Inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ using DynamicPPL:
using Distributions, Libtask, Bijectors
using FlexiChains: FlexiChains, VNChain
using LinearAlgebra
using ..Turing: PROGRESS, Turing
using ..Turing: Turing
using StatsFuns: logsumexp
using Random: AbstractRNG
using AbstractMCMC: AbstractModel, AbstractSampler
Expand Down
2 changes: 1 addition & 1 deletion src/mcmc/hmc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function AbstractMCMC.sample(
chain_type=DEFAULT_CHAIN_TYPE,
initial_params=Turing.Inference.init_strategy(sampler),
initial_state=nothing,
progress=PROGRESS[],
progress=AbstractMCMC.PROGRESS[],
nadapts=sampler.n_adapts,
discard_adapt=true,
discard_initial=-1,
Expand Down
4 changes: 2 additions & 2 deletions src/mcmc/repeat_sampler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function AbstractMCMC.sample(
check_model=true,
initial_params=Turing.Inference.init_strategy(sampler),
chain_type=DEFAULT_CHAIN_TYPE,
progress=PROGRESS[],
progress=AbstractMCMC.PROGRESS[],
verbose=true,
kwargs...,
)
Expand Down Expand Up @@ -146,7 +146,7 @@ function AbstractMCMC.sample(
check_model=true,
initial_params=fill(Turing.Inference.init_strategy(sampler), n_chains),
chain_type=DEFAULT_CHAIN_TYPE,
progress=PROGRESS[],
progress=AbstractMCMC.PROGRESS[],
kwargs...,
)
check_model && Turing._check_model(model, sampler)
Expand Down
7 changes: 4 additions & 3 deletions src/variational/Variational.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ using DynamicPPL: DynamicPPL, LogDensityFunction
using LinearAlgebra
using LogDensityProblems: LogDensityProblems
using Random
using ..Turing: DEFAULT_ADTYPE, PROGRESS
using ..Turing: DEFAULT_ADTYPE
import AbstractMCMC

export vi,
q_locationscale,
Expand Down Expand Up @@ -347,7 +348,7 @@ Base.rand(res::VIResult, sz::Integer...) = Base.rand(Random.default_rng(), res,
),
unconstrained::Bool=requires_unconstrained_space(algorithm),
fix_transforms::Bool=false,
show_progress::Bool = Turing.PROGRESS[],
show_progress::Bool = AbstractMCMC.PROGRESS[],
kwargs...
)

Expand Down Expand Up @@ -391,7 +392,7 @@ function vi(
),
unconstrained::Bool=requires_unconstrained_space(algorithm),
fix_transforms::Bool=false,
show_progress::Bool=PROGRESS[],
show_progress::Bool=AbstractMCMC.PROGRESS[],
kwargs...,
)
transform_strategy = unconstrained ? DynamicPPL.LinkAll() : DynamicPPL.UnlinkAll()
Expand Down
8 changes: 5 additions & 3 deletions test/variational/vi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ using Turing.Variational

@testset "default interface" begin
for q0 in [q_meanfield_gaussian, q_fullrank_gaussian]
result = vi(gdemo_default, q0, 100; show_progress=Turing.PROGRESS[], adtype)
result = vi(
gdemo_default, q0, 100; show_progress=AbstractMCMC.PROGRESS[], adtype
)
@test result isa Turing.Variational.VIResult
@test rand(result) isa DynamicPPL.VarNamedTuple
@test rand(result, 2) isa Vector{<:DynamicPPL.VarNamedTuple}
Expand All @@ -76,7 +78,7 @@ using Turing.Variational
q_fullrank_gaussian,
T;
algorithm,
show_progress=Turing.PROGRESS[],
show_progress=AbstractMCMC.PROGRESS[],
)
c2 = rand(result, 10)
@test c2 isa Vector{<:DynamicPPL.VarNamedTuple}
Expand Down Expand Up @@ -105,7 +107,7 @@ using Turing.Variational
q_fullrank_gaussian,
T;
algorithm,
show_progress=Turing.PROGRESS[],
show_progress=AbstractMCMC.PROGRESS[],
)

N = 1000
Expand Down
Loading