Skip to content

Commit 9e5467a

Browse files
mhaurupenelopeysmtorfjelde
authored
Replace old Gibbs sampler with the experimental one. (#2328)
* Replace old Gibbs sampler with the experimental one. * Remove dead references to experimental * Remove mention of experimental from JuliaFormatter conf * Add tests for deprecated constructor * Fix deprecated Gibbs constructors. Add HISTORY entry. * Bump version to 0.35.0 * Add Gibbs constructor test for repeat samplers * Fix typo in test/mcmc/ess.jl * Use provided rng to initialise VarInfo in Gibbs * Fix a typo in GibbsContext * Fix the Gibbs sampler * Fix the Gibbs sampler more * Remove mentions of old Gibbs sampler from MH docs Co-authored-by: Penelope Yong <[email protected]> * Bump DPPL to 0.28.6 * Redesign GibbsContext, work in progress * Fixing new Gibbs, adding a broken test * Document and clean up GibbsContext * Code style and docs improvements to Gibbs * Change how AdvancedHMC Gibbs state treats momenta * Remove unnecessary invlinking * Change how AdvancedHMC Gibbs state treats momenta, again * Use setparams!! rather than reset_state!! * Don't overload setparams\!\! with VarInfo * A fix for ESS in Gibbs * Remove recompute_logprob!! * Fix setparams_varinfo!! for MH * Stop hard coding the leafcontext for MH setparams_varinfo!! * Fix setparams_varinfo!! for ESS * Fix the context used by setparams_varinfo!! ESS * Add GibbsContext type stability tests * Apply suggestions from code review Co-authored-by: Tor Erlend Fjelde <[email protected]> * Add clarifying comment * Add setparams_varinfo!! type bounds * Fix an import * Style improvement * Improve GibbsContext type stability test * Add comment to constructor tests * Fix a Gibbs test * Document the methods of `varinfo` better * Check whether a sampler is a valid Gibbs component * Move varinfo methods where they belong * Fix calling of child context in GibbsContext * Fix Selectors and type stability of Gibbs * Fix broken short circuit in MH * Stop unnecessary use of Val in GibbsContext * Enforce GibbsContext being next to a leaf * Fix setparams_varinfo!! for ESS * Fix a small Gibbs bug * Fix Gibbs sampler test * Add back tests that were accidentally commented out * Relax a test tolerance * Add a Gibbs test for dynamic model with ESS * Use ESS in Gibbs DEMO_MODELS tests * Add Gibbs component call order test * Fix Gibbs linking bug, add tests * Make Gibbs constructor more flexible * Introduce RepeatSampler * Switch gold standard sample Gibbs test back to HMC I tried using ESS instead, because I thought it would test behavior a bit more broadly, given similarities between HMC and NUTS. It worked locally, but the KS test fails in one or two cases on CI. * Clean up RepeatSamplerTests preamble * Fix RepeatSampler in Gibbs bug * Rename a function in Gibbs * Test HMCDA in Gibbs tests * Simplify is_target_varname * Add suggestions from code review Co-authored-by: Tor Erlend Fjelde <[email protected]> * Add a couple of issue references * Restructure Gibbs inference tests and reduce iteration counts * Reduce another iter count in Gibbs tests * Add an info print to Gibbs tests * Use StableRNG, relax test tolerance * Fix a kwarg --------- Co-authored-by: Penelope Yong <[email protected]> Co-authored-by: Tor Erlend Fjelde <[email protected]>
1 parent 2707d12 commit 9e5467a

30 files changed

+1457
-1116
lines changed

.JuliaFormatter.toml

-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
style="blue"
22
format_markdown = true
33
import_to_using = false
4-
# TODO
5-
# We ignore these files because when formatting was first put in place they were being worked on.
6-
# These ignores should be removed once the relevant PRs are merged/closed.
7-
ignore = [
8-
# https://github.com/TuringLang/Turing.jl/pull/2328/files
9-
"src/experimental/gibbs.jl",
10-
"test/experimental/gibbs.jl",
11-
]

.github/workflows/Tests.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,10 @@ jobs:
3434
args: "mcmc/abstractmcmc.jl"
3535
- name: "mcmc/Inference"
3636
args: "mcmc/Inference.jl"
37-
- name: "experimental/gibbs"
38-
args: "experimental/gibbs.jl"
3937
- name: "mcmc/ess"
4038
args: "mcmc/ess.jl"
4139
- name: "everything else"
42-
args: "--skip essential/ad.jl mcmc/gibbs.jl mcmc/hmc.jl mcmc/abstractmcmc.jl mcmc/Inference.jl experimental/gibbs.jl mcmc/ess.jl"
40+
args: "--skip essential/ad.jl mcmc/gibbs.jl mcmc/hmc.jl mcmc/abstractmcmc.jl mcmc/Inference.jl mcmc/ess.jl"
4341
runner:
4442
# Default
4543
- version: '1'

HISTORY.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# Release 0.36.0
2+
3+
## Breaking changes
4+
5+
0.36.0 introduces a new Gibbs sampler. It's been included in several previous releases as `Turing.Experimental.Gibbs`, but now takes over the old Gibbs sampler, which gets removed completely.
6+
7+
The new Gibbs sampler supports the same user-facing interface as the old one. However, given
8+
that the internals of it having been completely rewritten in a very different manner, there
9+
may be accidental breakage that we haven't anticipated. Please report any you find.
10+
11+
`GibbsConditional` has also been removed. It was never very user-facing, but it was exported, so technically this is breaking.
12+
13+
The old Gibbs constructor relied on being called with several subsamplers, and each of the constructors of the subsamplers would take as arguments the symbols for the variables that they are to sample, e.g. `Gibbs(HMC(:x), MH(:y))`. This constructor has been deprecated, and will be removed in the future. The new constructor works by assigning samplers to either symbols or `VarNames`, e.g. `Gibbs(; x=HMC(), y=MH())` or `Gibbs(@varname(x) => HMC(), @varname(y) => MH())`. This allows more granular specification of which sampler to use for which variable.
14+
15+
Likewise, the old constructor for calling one subsampler more often than another, `Gibbs((HMC(0.01, 4, :x), 2), (MH(:y), 1))` has been deprecated. The new way to do this is to use `RepeatSampler`, also introduced at this version: `Gibbs(@varname(x) => RepeatSampler(HMC(0.01, 4), 2), @varname(y) => MH())`.
16+
117
# Release 0.35.0
218

319
## Breaking changes

Project.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Turing"
22
uuid = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"
3-
version = "0.35.5"
3+
version = "0.36.0"
44

55
[deps]
66
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
@@ -49,7 +49,7 @@ TuringOptimExt = "Optim"
4949

5050
[compat]
5151
ADTypes = "1.9"
52-
AbstractMCMC = "5.2"
52+
AbstractMCMC = "5.5"
5353
Accessors = "0.1"
5454
AdvancedHMC = "0.3.0, 0.4.0, 0.5.2, 0.6"
5555
AdvancedMH = "0.8"

src/Turing.jl

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ using .Variational
5555
include("optimisation/Optimisation.jl")
5656
using .Optimisation
5757

58-
include("experimental/Experimental.jl")
5958
include("deprecated.jl") # to be removed in the next minor version release
6059

6160
###########
@@ -88,7 +87,6 @@ export @model, # modelling
8887
Emcee,
8988
ESS,
9089
Gibbs,
91-
GibbsConditional,
9290
HMC, # Hamiltonian-like sampling
9391
SGLD,
9492
SGHMC,
@@ -99,6 +97,7 @@ export @model, # modelling
9997
SMC,
10098
CSMC,
10199
PG,
100+
RepeatSampler,
102101
vi, # variational inference
103102
ADVI,
104103
sample, # inference

src/experimental/Experimental.jl

-16
This file was deleted.

0 commit comments

Comments
 (0)