You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: HISTORY.md
+29-1Lines changed: 29 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,6 +72,35 @@ The other case where one might use `PriorContext` was to use `@addlogprob!` to a
72
72
Previously, this was accomplished by manually checking `__context__ isa DynamicPPL.PriorContext`.
73
73
Now, you can write `@addlogprob (; logprior=x, loglikelihood=y)` to add `x` to the log-prior and `y` to the log-likelihood.
74
74
75
+
### Removal of `order` and `num_produce`
76
+
77
+
The `VarInfo` type used to carry with it:
78
+
79
+
-`num_produce`, an integer which recorded the number of observe tilde-statements that had been evaluated so far; and
80
+
-`order`, an integer per `VarName` which recorded the value of `num_produce` at the time that the variable was seen.
81
+
82
+
These fields were used in particle samplers in Turing.jl.
83
+
In DynamicPPL 0.37, these fields and the associated functions have been removed:
84
+
85
+
-`get_num_produce`
86
+
-`set_num_produce!!`
87
+
-`reset_num_produce!!`
88
+
-`increment_num_produce!!`
89
+
-`set_retained_vns_del!`
90
+
-`setorder!!`
91
+
92
+
Because this is one of the more arcane features of DynamicPPL, some extra explanation is warranted.
93
+
94
+
`num_produce` and `order`, along with the `del` flag in `VarInfo`, were used to control whether new values for variables were sampled during model execution.
95
+
For example, the particle Gibbs method has a _reference particle_, for which variables are never resampled.
96
+
However, if the reference particle is _forked_ (i.e., if the reference particle is selected by a resampling step multiple times and thereby copied), then the variables that have not yet been evaluated must be sampled anew to ensure that the new particle is independent of the reference particle.
97
+
98
+
Previousy, this was accomplished by setting the `del` flag in the `VarInfo` object for all variables with `order` greater or equal to than `num_produce`.
99
+
Note that setting the `del` flag does not itself trigger a new value to be sampled; rather, it indicates that a new value should be sampled _if the variable is encountered again_.
100
+
[This Turing.jl PR](https://github.com/TuringLang/Turing.jl/pull/2629) changes the implementation to set the `del` flag for _all_ variables in the `VarInfo`.
101
+
Since the `del` flag only makes a difference when encountering a variable, this approach is entirely equivalent as long as the same variable is not seen multiple times in the model.
102
+
The interested reader is referred to that PR for more details.
103
+
75
104
**Internals**
76
105
77
106
### Accumulators
@@ -83,7 +112,6 @@ This release overhauls how VarInfo objects track variables such as the log joint
83
112
-`tilde_observe` and `observe` have been removed. `tilde_observe!!` still exists, and any contexts should modify its behaviour. We may further rework the call stack under `tilde_observe!!` in the near future.
84
113
-`tilde_assume` no longer returns the log density of the current assumption as its second return value. We may further rework the `tilde_assume!!` call stack as well.
85
114
- For literal observation statements like `0.0 ~ Normal(blahblah)` we used to call `tilde_observe!!` without the `vn` argument. This method no longer exists. Rather we call `tilde_observe!!` with `vn` set to `nothing`.
86
-
-`set/reset/increment_num_produce!` have become `set/reset/increment_num_produce!!` (note the second exclamation mark). They are no longer guaranteed to modify the `VarInfo` in place, and one should always use the return value.
87
115
-`@addlogprob!` now _always_ adds to the log likelihood. Previously it added to the log probability that the execution context specified, e.g. the log prior when using `PriorContext`.
88
116
-`getlogp` now returns a `NamedTuple` with keys `logprior` and `loglikelihood`. If you want the log joint probability, which is what `getlogp` used to return, use `getlogjoint`.
89
117
- Correspondingly `setlogp!!` and `acclogp!!` should now be called with a `NamedTuple` with keys `logprior` and `loglikelihood`. The `acclogp!!` method with a single scalar value has been deprecated and falls back on `accloglikelihood!!`, and the single scalar version of `setlogp!!` has been removed. Corresponding setter/accumulator functions exist for the log prior as well.
0 commit comments