@@ -26,5 +26,36 @@ function AbstractMCMC.step(
26
26
),
27
27
)
28
28
_, vi = DynamicPPL. evaluate!! (sampling_model, vi)
29
- return Transition (model, vi, nothing ; reevaluate= false ), nothing
29
+ vi = DynamicPPL. typed_varinfo (vi)
30
+ return Transition (model, vi, nothing ; reevaluate= false ), vi
31
+ end
32
+
33
+ function AbstractMCMC. step (
34
+ rng:: Random.AbstractRNG ,
35
+ model:: DynamicPPL.Model ,
36
+ sampler:: DynamicPPL.Sampler{<:Prior} ,
37
+ vi:: AbstractVarInfo ;
38
+ kwargs... ,
39
+ )
40
+ # TODO (DPPL0.38/penelopeysm): replace this entire thing with init!!
41
+ #
42
+ # `vi` is a VarInfo from the previous step so already has all the
43
+ # right accumulators and stuff. The only thing we need to change is to make
44
+ # sure that the old values are overwritten when we resample.
45
+ #
46
+ # Note also that the values in the Transition (and hence the chain) are not
47
+ # obtained from the VarInfo's metadata itself, but are instead obtained
48
+ # from the ValuesAsInModelAccumulator, which is cleared in the evaluate!!
49
+ # call. Thus, the actual values in the VarInfo's metadata don't matter:
50
+ # we only set the del flag here to make sure that new values are sampled
51
+ # (and thus new values enter VAIMAcc), rather than the old ones being
52
+ # reused during the evaluation. Yes, SampleFromPrior really sucks.
53
+ for vn in keys (vi)
54
+ DynamicPPL. set_flag! (vi, vn, " del" )
55
+ end
56
+ sampling_model = DynamicPPL. contextualize (
57
+ model, DynamicPPL. SamplingContext (rng, DynamicPPL. SampleFromPrior (), model. context)
58
+ )
59
+ _, vi = DynamicPPL. evaluate!! (sampling_model, vi)
60
+ return Transition (model, vi, nothing ; reevaluate= false ), vi
30
61
end
0 commit comments