Skip to content

Commit 20cbb85

Browse files
committed
Merge remote-tracking branch 'origin/release-0.35' into mhauru/dot-tilde-to-loops
2 parents 15dc8a2 + 4b9665a commit 20cbb85

17 files changed

+37
-231
lines changed

.github/workflows/CI.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ on:
77
- backport-*
88
- release-0.35
99
pull_request:
10-
branches:
11-
- master
12-
- backport-*
13-
- release-0.35
1410
merge_group:
1511
types: [checks_requested]
1612

HISTORY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ This release removes the feature of `VarInfo` where it kept track of which varia
8383
- `eltype(::VarInfo)` no longer accepts a sampler as an argument
8484
- `keys(::VarInfo)` no longer accepts a sampler as an argument
8585
- `VarInfo(::VarInfo, ::Sampler, ::AbstractVector)` no longer accepts the sampler argument.
86+
- `push!!` and `push!` no longer accept samplers or `Selector`s as arguments
87+
- `getgid`, `setgid!`, `updategid!`, `getspace`, and `inspace` no longer exist
8688

8789
### Reverse prefixing order
8890

Project.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
1515
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
1616
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
1717
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
18-
# TODO(penelopeysm,mhauru) KernelAbstractions is only a dependency so that we can pin its version, see
19-
# https://github.com/TuringLang/DynamicPPL.jl/pull/781#event-16017866767
2018
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
2119
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
2220
LogDensityProblems = "6fdf6af0-433a-55f7-b3ed-c6c6e0b8df7c"
@@ -55,9 +53,7 @@ Compat = "4"
5553
ConstructionBase = "1.5.4"
5654
Distributions = "0.25"
5755
DocStringExtensions = "0.9"
58-
# TODO(penelopeysm,mhauru) See https://github.com/TuringLang/DynamicPPL.jl/pull/781#event-16017866767
59-
# for why KernelAbstractions is pinned like this.
60-
KernelAbstractions = "< 0.9.32"
56+
KernelAbstractions = "0.9.33"
6157
EnzymeCore = "0.6 - 0.8"
6258
ForwardDiff = "0.10"
6359
JET = "0.9"

docs/src/api.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,6 @@ unset_flag!
289289
is_flagged
290290
```
291291

292-
For Gibbs sampling the following functions were added.
293-
294-
```@docs
295-
setgid!
296-
updategid!
297-
```
298-
299292
The following functions were used for sequential Monte Carlo methods.
300293

301294
```@docs

ext/DynamicPPLChainRulesCoreExt.jl

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,7 @@ end
1010

1111
# See https://github.com/TuringLang/Turing.jl/issues/1199
1212
ChainRulesCore.@non_differentiable BangBang.push!!(
13-
vi::DynamicPPL.VarInfo,
14-
vn::DynamicPPL.VarName,
15-
r,
16-
dist::Distributions.Distribution,
17-
gidset::Set{DynamicPPL.Selector},
18-
)
19-
20-
ChainRulesCore.@non_differentiable DynamicPPL.updategid!(
21-
vi::DynamicPPL.AbstractVarInfo, vn::DynamicPPL.VarName, spl::DynamicPPL.Sampler
13+
vi::DynamicPPL.VarInfo, vn::DynamicPPL.VarName, r, dist::Distributions.Distribution
2214
)
2315

2416
# No need + causes issues for some AD backends, e.g. Zygote.

src/DynamicPPL.jl

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ export AbstractVarInfo,
6363
is_flagged,
6464
set_flag!,
6565
unset_flag!,
66-
setgid!,
67-
updategid!,
6866
setorder!,
6967
istrans,
7068
link,
@@ -74,7 +72,6 @@ export AbstractVarInfo,
7472
values_as,
7573
# VarName (reexport from AbstractPPL)
7674
VarName,
77-
inspace,
7875
subsumes,
7976
@varname,
8077
# Compiler
@@ -148,9 +145,6 @@ macro prob_str(str)
148145
))
149146
end
150147

151-
# Used here and overloaded in Turing
152-
function getspace end
153-
154148
"""
155149
AbstractVarInfo
156150
@@ -162,14 +156,8 @@ See also: [`VarInfo`](@ref), [`SimpleVarInfo`](@ref).
162156
"""
163157
abstract type AbstractVarInfo <: AbstractModelTrace end
164158

165-
const LEGACY_WARNING = """
166-
!!! warning
167-
This method is considered legacy, and is likely to be deprecated in the future.
168-
"""
169-
170159
# Necessary forward declarations
171160
include("utils.jl")
172-
include("selector.jl")
173161
include("chains.jl")
174162
include("model.jl")
175163
include("sampler.jl")

src/abstract_varinfo.jl

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -169,51 +169,6 @@ See also: [`getindex(vi::AbstractVarInfo, vn::VarName, dist::Distribution)`](@re
169169
"""
170170
function getindex_internal end
171171

172-
"""
173-
push!!(vi::AbstractVarInfo, vn::VarName, r, dist::Distribution)
174-
175-
Push a new random variable `vn` with a sampled value `r` from a distribution `dist` to
176-
the `VarInfo` `vi`, mutating if it makes sense.
177-
"""
178-
function BangBang.push!!(vi::AbstractVarInfo, vn::VarName, r, dist::Distribution)
179-
return BangBang.push!!(vi, vn, r, dist, Set{Selector}([]))
180-
end
181-
182-
"""
183-
push!!(vi::AbstractVarInfo, vn::VarName, r, dist::Distribution, spl::AbstractSampler)
184-
185-
Push a new random variable `vn` with a sampled value `r` sampled with a sampler `spl`
186-
from a distribution `dist` to `VarInfo` `vi`, if it makes sense.
187-
188-
The sampler is passed here to invalidate its cache where defined.
189-
190-
$(LEGACY_WARNING)
191-
"""
192-
function BangBang.push!!(
193-
vi::AbstractVarInfo, vn::VarName, r, dist::Distribution, spl::Sampler
194-
)
195-
return BangBang.push!!(vi, vn, r, dist, spl.selector)
196-
end
197-
function BangBang.push!!(
198-
vi::AbstractVarInfo, vn::VarName, r, dist::Distribution, spl::AbstractSampler
199-
)
200-
return BangBang.push!!(vi, vn, r, dist)
201-
end
202-
203-
"""
204-
push!!(vi::AbstractVarInfo, vn::VarName, r, dist::Distribution, gid::Selector)
205-
206-
Push a new random variable `vn` with a sampled value `r` sampled with a sampler of
207-
selector `gid` from a distribution `dist` to `VarInfo` `vi`.
208-
209-
$(LEGACY_WARNING)
210-
"""
211-
function BangBang.push!!(
212-
vi::AbstractVarInfo, vn::VarName, r, dist::Distribution, gid::Selector
213-
)
214-
return BangBang.push!!(vi, vn, r, dist, Set([gid]))
215-
end
216-
217172
@doc """
218173
empty!!(vi::AbstractVarInfo)
219174
@@ -768,7 +723,6 @@ end
768723
# Legacy code that is currently overloaded for the sake of simplicity.
769724
# TODO: Remove when possible.
770725
increment_num_produce!(::AbstractVarInfo) = nothing
771-
setgid!(vi::AbstractVarInfo, gid::Selector, vn::VarName) = nothing
772726

773727
"""
774728
from_internal_transform(varinfo::AbstractVarInfo, vn::VarName[, dist])

src/context_implementations.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,11 @@ function assume(
239239
r = init(rng, dist, sampler)
240240
if istrans(vi)
241241
f = to_linked_internal_transform(vi, vn, dist)
242-
push!!(vi, vn, f(r), dist, sampler)
242+
push!!(vi, vn, f(r), dist)
243243
# By default `push!!` sets the transformed flag to `false`.
244244
settrans!!(vi, true, vn)
245245
else
246-
push!!(vi, vn, r, dist, sampler)
246+
push!!(vi, vn, r, dist)
247247
end
248248
end
249249

src/sampler.jl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ Sampling algorithm that samples unobserved random variables from their prior dis
1818
"""
1919
struct SampleFromPrior <: AbstractSampler end
2020

21-
getspace(::Union{SampleFromPrior,SampleFromUniform}) = ()
22-
2321
# Initializations.
2422
init(rng, dist, ::SampleFromPrior) = rand(rng, dist)
2523
function init(rng, dist, ::SampleFromUniform)
@@ -31,6 +29,8 @@ function init(rng, dist, ::SampleFromUniform, n::Int)
3129
return istransformable(dist) ? inittrans(rng, dist, n) : rand(rng, dist, n)
3230
end
3331

32+
# TODO(mhauru) Could we get rid of Sampler now that it's just a wrapper around `alg`?
33+
# (Selector has been removed).
3434
"""
3535
Sampler{T}
3636
@@ -47,12 +47,7 @@ By default, values are sampled from the prior.
4747
"""
4848
struct Sampler{T} <: AbstractSampler
4949
alg::T
50-
selector::Selector # Can we remove it?
51-
# TODO: add space such that we can integrate existing external samplers in DynamicPPL
5250
end
53-
Sampler(alg) = Sampler(alg, Selector())
54-
Sampler(alg, model::Model) = Sampler(alg, model, Selector())
55-
Sampler(alg, model::Model, s::Selector) = Sampler(alg, s)
5651

5752
# AbstractMCMC interface for SampleFromUniform and SampleFromPrior
5853
function AbstractMCMC.step(

src/selector.jl

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)