Skip to content
Open
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.0

- Removed Turing's local `PROGRESS` and `setprogress!`; use `AbstractMCMC.PROGRESS` and `AbstractMCMC.setprogress!` instead.

# 0.46.0

## Breaking changes
Expand Down
6 changes: 0 additions & 6 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,6 @@ See the [AD guide](https://turinglang.org/docs/tutorials/docs-10-using-turing-au
| `AutoMooncake` | [`ADTypes.AutoMooncake`](@extref) | Mooncake.jl backend |
| `AutoReverseDiff` | [`ADTypes.AutoReverseDiff`](@extref) | ReverseDiff.jl backend |

### Debugging

```@docs
setprogress!
```

### Distributions

These distributions are defined in Turing.jl, but not in Distributions.jl.
Expand Down
17 changes: 0 additions & 17 deletions src/Turing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,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,8 +126,6 @@ export
AutoReverseDiff,
AutoMooncake,
AutoEnzyme,
# Debugging - Turing
setprogress!,
# Distributions
Flat,
FlatPos,
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
2 changes: 1 addition & 1 deletion src/mcmc/particle_mcmc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function AbstractMCMC.sample(
check_model=true,
chain_type=DEFAULT_CHAIN_TYPE,
initial_params=Turing.Inference.init_strategy(sampler),
progress=PROGRESS[],
progress=AbstractMCMC.PROGRESS[],
discard_initial=0,
thinning=1,
verbose=false,
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
9 changes: 5 additions & 4 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 @@ -94,7 +95,7 @@ function q_initialize_scale(
energy = mean(
map(1:num_samples) do _
z = rand(rng, q)
LogDensityProblems.logdensity(ldf, z)
return LogDensityProblems.logdensity(ldf, z)
end,
)

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
2 changes: 1 addition & 1 deletion test/mcmc/chains.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using Random: Random, Xoshiro
using Test
using Turing

Turing.setprogress!(false)
AbstractMCMC.setprogress!(false)

# This sampler does nothing (it just stays at the existing state)
struct StaticSampler <: AbstractMCMC.AbstractSampler end
Expand Down
3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using Pkg
using Random: seed!
using Test
using TimerOutputs: TimerOutputs, @timeit
using AbstractMCMC: AbstractMCMC
import Turing

# Fix the global Random.seed for reproducibility.
Expand All @@ -13,7 +14,7 @@ include("test_utils/models.jl")
include("test_utils/numerical_tests.jl")
include("test_utils/sampler.jl")

Turing.setprogress!(false)
AbstractMCMC.setprogress!(false)
included_paths, excluded_paths = parse_args(ARGS)

# Filter which tests to run and collect timing and allocations information to show in a
Expand Down
10 changes: 6 additions & 4 deletions test/variational/vi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module AdvancedVITests
using ..Models: gdemo_default
using ..NumericalTests: check_gdemo

using AbstractMCMC: AbstractMCMC
import AbstractMCMC
using AdvancedVI
using Bijectors: Bijectors
using Distributions: Dirichlet, Normal
Expand Down 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