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
+119Lines changed: 119 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,21 @@
4
4
5
5
**Breaking changes**
6
6
7
+
### Submodel macro
8
+
9
+
The `@submodel` macro is fully removed; please use `to_submodel` instead.
10
+
11
+
### `DynamicPPL.TestUtils.AD.run_ad`
12
+
13
+
The three keyword arguments, `test`, `reference_backend`, and `expected_value_and_grad` have been merged into a single `test` keyword argument.
14
+
Please see the API documentation for more details.
15
+
(The old `test=true` and `test=false` values are still valid, and you only need to adjust the invocation if you were explicitly passing the `reference_backend` or `expected_value_and_grad` arguments.)
16
+
17
+
There is now also an `rng` keyword argument to help seed parameter generation.
18
+
19
+
Finally, instead of specifying `value_atol` and `grad_atol`, you can now specify `atol` and `rtol` which are used for both value and gradient.
20
+
Their semantics are the same as in Julia's `isapprox`; two values are equal if they satisfy either `atol` or `rtol`.
21
+
7
22
### Accumulators
8
23
9
24
This release overhauls how VarInfo objects track variables such as the log joint probability. The new approach is to use what we call accumulators: Objects that the VarInfo carries on it that may change their state at each `tilde_assume!!` and `tilde_observe!!` call based on the value of the variable in question. They replace both variables that were previously hard-coded in the `VarInfo` object (`logp` and `num_produce`) and some contexts. This brings with it a number of breaking changes:
@@ -18,6 +33,110 @@ This release overhauls how VarInfo objects track variables such as the log joint
18
33
-`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`.
19
34
- 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.
20
35
36
+
### Evaluation contexts
37
+
38
+
Historically, evaluating a DynamicPPL model has required three arguments: a model, some kind of VarInfo, and a context.
39
+
It's less known, though, that since DynamicPPL 0.14.0 the _model_ itself actually contains a context as well.
40
+
This version therefore excises the context argument, and instead uses `model.context` as the evaluation context.
41
+
42
+
The upshot of this is that many functions that previously took a context argument now no longer do.
43
+
There were very few such functions where the context argument was actually used (most of them simply took `DefaultContext()` as the default value).
44
+
45
+
`evaluate!!(model, varinfo, ext_context)` is removed, and broadly speaking you should replace calls to that with `new_model = contextualize(model, ext_context); evaluate!!(new_model, varinfo)`.
46
+
If the 'external context' `ext_context` is a parent context, then you should wrap `model.context` appropriately to ensure that its information content is not lost.
47
+
If, on the other hand, `ext_context` is a `DefaultContext`, then you can just drop the argument entirely.
48
+
49
+
**To aid with this process, `contextualize` is now exported from DynamicPPL.**
50
+
51
+
The main situation where one _did_ want to specify an additional evaluation context was when that context was a `SamplingContext`.
52
+
Doing this would allow you to run the model and sample fresh values, instead of just using the values that existed in the VarInfo object.
53
+
Thus, this release also introduces the **unexported** function `evaluate_and_sample!!`.
54
+
Essentially, `evaluate_and_sample!!(rng, model, varinfo, sampler)` is a drop-in replacement for `evaluate!!(model, varinfo, SamplingContext(rng, sampler))`.
55
+
**Do note that this is an internal method**, and its name or semantics are liable to change in the future without warning.
56
+
57
+
There are many methods that no longer take a context argument, and listing them all would be too much.
58
+
However, here are the more user-facing ones:
59
+
60
+
-`LogDensityFunction` no longer has a context field (or type parameter)
61
+
-`DynamicPPL.TestUtils.AD.run_ad` no longer uses a context (and the returned `ADResult` object no longer has a context field)
62
+
-`VarInfo(rng, model, sampler)` and other VarInfo constructors / functions that made VarInfos (e.g. `typed_varinfo`) from a model
63
+
-`(::Model)(args...)`: specifically, this now only takes `rng` and `varinfo` arguments (with both being optional)
64
+
- If you are using the `__context__` special variable inside a model, you will now have to use `__model__.context` instead
65
+
66
+
And a couple of more internal changes:
67
+
68
+
- Just like `evaluate!!`, the other functions `_evaluate!!`, `evaluate_threadsafe!!`, and `evaluate_threadunsafe!!` now no longer accept context arguments
69
+
-`evaluate!!` no longer takes rng and sampler (if you used this, you should use `evaluate_and_sample!!` instead, or construct your own `SamplingContext`)
70
+
- The model evaluation function, `model.f` for some `model::Model`, no longer takes a context as an argument
71
+
- The internal representation and API dealing with submodels (i.e., `ReturnedModelWrapper`, `Sampleable`, `should_auto_prefix`, `is_rhs_model`) has been simplified. If you need to check whether something is a submodel, just use `x isa DynamicPPL.Submodel`. Note that the public API i.e. `to_submodel` remains completely untouched.
72
+
73
+
## 0.36.15
74
+
75
+
Bumped minimum Julia version to 1.10.8 to avoid potential crashes with `Core.Compiler.widenconst` (which Mooncake uses).
0 commit comments