Skip to content

Commit a32172e

Browse files
penelopeysmmhauru
andauthored
v0.38 (#1018)
* Bump minor version * bump benchmarks compat * add a skeletal changelog * `InitContext`, part 3 - Introduce `InitContext` (#981) * Implement InitContext * Fix loading order of modules; move `prefix(::Model)` to model.jl * Add tests for InitContext behaviour * inline `rand(::Distributions.Uniform)` Note that, apart from being simpler code, Distributions.Uniform also doesn't allow the lower and upper bounds to be exactly equal (but we might like to keep that option open in DynamicPPL, e.g. if the user wants to initialise all values to the same value in linked space). * Document * Add a test to check that `init!!` doesn't change linking * Fix `push!` for VarNamedVector This should have been changed in #940, but slipped through as the file wasn't listed as one of the changed files. * Add some line breaks Co-authored-by: Markus Hauru <markus@mhauru.org> * Add the option of no fallback for ParamsInit * Improve docstrings * typo * `p.default` -> `p.fallback` * Rename `{Prior,Uniform,Params}Init` -> `InitFrom{Prior,Uniform,Params}` --------- Co-authored-by: Markus Hauru <markus@mhauru.org> * use `varname_leaves` from AbstractPPL instead (#1030) * use `varname_leaves` from AbstractPPL instead * add changelog entry * fix import * tidy occurrences of varname_leaves as well (#1031) * `InitContext`, part 4 - Use `init!!` to replace `evaluate_and_sample!!`, `predict`, `returned`, and `initialize_values` (#984) * Replace `evaluate_and_sample!!` -> `init!!` * Use `ParamsInit` for `predict`; remove `setval_and_resample!` and friends * Use `init!!` for initialisation * Paper over the `Sampling->Init` context stack (pending removal of SamplingContext) * Remove SamplingContext from JETExt to avoid triggering `Sampling->Init` pathway * Remove `predict` on vector of VarInfo * Fix some tests * Remove duplicated test * Simplify context testing * Rename FooInit -> InitFromFoo * Fix JETExt * Fix JETExt properly * Fix tests * Improve comments * Remove duplicated tests * Docstring improvements Co-authored-by: Markus Hauru <markus@mhauru.org> * Concretise `chain_sample_to_varname_dict` using chain value type * Clarify testset name * Re-add comment that shouldn't have vanished * Fix stale Requires dep * Fix default_varinfo/initialisation for odd models * Add comment to src/sampler.jl Co-authored-by: Markus Hauru <markus@mhauru.org> --------- Co-authored-by: Markus Hauru <markus@mhauru.org> * `InitContext`, part 5 - Remove `SamplingContext`, `SampleFrom{Prior,Uniform}`, `{tilde_,}assume` (#985) * Remove `SamplingContext` for good * Remove `tilde_assume` as well * Split up tilde_observe!! for Distribution / Submodel * Tidy up tilde-pipeline methods and docstrings * Fix tests * fix ambiguity * Add changelog * Update HISTORY.md Co-authored-by: Markus Hauru <markus@mhauru.org> --------- Co-authored-by: Markus Hauru <markus@mhauru.org> * fix missing import * Shuffle context code around and remove dead code (#1050) * Delete the `"del"` flag (#1058) * Delete del * Fix a typo * Add HISTORY entry about del * Fixes for Turing 0.41 (#1057) * setleafcontext(model, ctx) and various other fixes * fix a bug * Add warning for `initial_parameters=...` * Remove `resume_from` and `default_chain_type` (#1061) * Remove resume_from * Format * Fix test * remove initial_params warning * Allow more flexible `initial_params` (#1064) * Enable NamedTuple/Dict initialisation * Add more tests * fix include_all kwarg for predict, improve perf (#1068) * Fix `include_all` for predict * Fix include_all for predict, some perf improvements * Replace `Metadata.flags` with `Metadata.trans` (#1060) * Replace Medata.flags with Metadata.trans * Fix a bug * Fix a typo * Fix two bugs * Rename trans to is_transformed * Rename islinked to is_transformed, remove duplication * Change pointwise_logdensities default key type to VarName (#1071) * Change pointwise_logdensities default key type to VarName * Fix a doctest * Fix DynamicPPL / MCMCChains methods (#1076) * Reimplement pointwise_logdensities (almost completely) * Move logjoint, logprior, ... as well * Fix imports, etc * Remove tests that are failing (yes I learnt this from Claude) * Changelog * logpdf * fix docstrings * allow dict output * changelog * fix some comments * fix tests * Fix more imports * Remove stray n Co-authored-by: Markus Hauru <markus@mhauru.org> * Expand `logprior`, `loglikelihood`, and `logjoint` docstrings --------- Co-authored-by: Markus Hauru <markus@mhauru.org> * Remove `Sampler` and its interface (#1037) * Remove `Sampler` and `initialstep` * Actually just remove the entire file * forgot one function * Move sampling test utils to Turing as well * Update changelog to correctly reflect changes * [skip ci] Make changelog headings more consistent --------- Co-authored-by: Markus Hauru <markus@mhauru.org>
1 parent c1d9b61 commit a32172e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2274
-3379
lines changed

HISTORY.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,106 @@
11
# DynamicPPL Changelog
22

3+
## 0.38.0
4+
5+
### Breaking changes
6+
7+
#### Introduction of `InitContext`
8+
9+
DynamicPPL 0.38 introduces a new evaluation context, `InitContext`.
10+
It is used to generate fresh values for random variables in a model.
11+
12+
Evaluation contexts are stored inside a `DynamicPPL.Model` object, and control what happens with tilde-statements when a model is run.
13+
The two major leaf (basic) contexts are `DefaultContext` and, now, `InitContext`.
14+
`DefaultContext` is the default context, and it simply uses the values that are already stored in the `VarInfo` object passed to the model evaluation function.
15+
On the other hand, `InitContext` ignores values in the VarInfo object and inserts new values obtained from a specified source.
16+
(It follows also that the VarInfo being used may be empty, which means that `InitContext` is now also the way to obtain a fresh VarInfo for a model.)
17+
18+
DynamicPPL 0.38 provides three flavours of _initialisation strategies_, which are specified as the second argument to `InitContext`:
19+
20+
- `InitContext(rng, InitFromPrior())`: New values are sampled from the prior distribution (on the right-hand side of the tilde).
21+
- `InitContext(rng, InitFromUniform(a, b))`: New values are sampled uniformly from the interval `[a, b]`, and then invlinked to the support of the distribution on the right-hand side of the tilde.
22+
- `InitContext(rng, InitFromParams(p, fallback))`: New values are obtained by indexing into the `p` object, which can be a `NamedTuple` or `Dict{<:VarName}`. If a variable is not found in `p`, then the `fallback` strategy is used, which is simply another of these strategies. In particular, `InitFromParams` enables the case where different variables are to be initialised from different sources.
23+
24+
(It is possible to define your own initialisation strategy; users who wish to do so are referred to the DynamicPPL API documentation and source code.)
25+
26+
**The main impact on the upcoming Turing.jl release** is that, instead of providing initial values for sampling, the user will be expected to provide an initialisation strategy instead.
27+
This is a more flexible approach, and not only solves a number of pre-existing issues with initialisation of Turing models, but also improves the clarity of user code.
28+
In particular:
29+
30+
- When providing a set of fixed parameters (i.e. `InitFromParams(p)`), `p` must now either be a NamedTuple or a Dict. Previously Vectors were allowed, which is error-prone because the ordering of variables in a VarInfo is not obvious.
31+
- The parameters in `p` must now always be provided in unlinked space (i.e., in the space of the distribution on the right-hand side of the tilde). Previously, whether a parameter was expected to be in linked or unlinked space depended on whether the VarInfo was linked or not, which was confusing.
32+
33+
#### Removal of `SamplingContext`
34+
35+
For developers working on DynamicPPL, `InitContext` now completely replaces what used to be `SamplingContext`, `SampleFromPrior`, and `SampleFromUniform`.
36+
Evaluating a model with `SamplingContext(SampleFromPrior())` (e.g. with `DynamicPPL.evaluate_and_sample!!(model, VarInfo(), SampleFromPrior())` has a direct one-to-one replacement in `DynamicPPL.init!!(model, VarInfo(), InitFromPrior())`.
37+
Please see the docstring of `init!!` for more details.
38+
Likewise `SampleFromUniform()` can be replaced with `InitFromUniform()`.
39+
`InitFromParams()` provides new functionality which was previously implemented in the roundabout way of manipulating the VarInfo (e.g. using `unflatten`, or even more hackily by directly modifying values in the VarInfo), and then evaluating using `DefaultContext`.
40+
41+
The main change that this is likely to create is for those who are implementing samplers or inference algorithms.
42+
The exact way in which this happens will be detailed in the Turing.jl changelog when a new release is made.
43+
Broadly speaking, though, `SamplingContext(MySampler())` will be removed so if your sampler needs custom behaviour with the tilde-pipeline you will likely have to define your own context.
44+
45+
#### Removal of `DynamicPPL.Sampler`
46+
47+
`DynamicPPL.Sampler` and **all associated interface functions** have also been removed entirely.
48+
If you were using these, the corresponding replacements are:
49+
50+
- `DynamicPPL.Sampler(S)`: just don't wrap `S`; but make sure `S` subtypes `AbstractMCMC.AbstractSampler`
51+
- `DynamicPPL.initialstep`: directly implement `AbstractMCMC.step` and `AbstractMCMC.step_warmup` as per the AbstractMCMC interface
52+
- `DynamicPPL.loadstate`: `Turing.loadstate` (will be introduced in the next version)
53+
- `DynamicPPL.default_chain_type`: removed, just use the `chain_type` keyword argument directly
54+
- `DynamicPPL.initialsampler`: `Turing.Inference.init_strategy` (will be introduced in the next version; note that this function must return an `AbstractInitStrategy`, see above for explanation)
55+
- `DynamicPPL.default_varinfo`: `Turing.Inference.default_varinfo` (will be introduced in the next version)
56+
- `DynamicPPL.TestUtils.test_sampler` and related methods: removed, please implement your own testing utilities as needed
57+
58+
#### Simplification of the tilde-pipeline
59+
60+
There are now only two functions in the tilde-pipeline that need to be overloaded to change the behaviour of tilde-statements, namely, `tilde_assume!!` and `tilde_observe!!`.
61+
Other functions such as `tilde_assume` and `assume` (and their `observe` counterparts) have been removed.
62+
63+
Note that this was effectively already the case in DynamicPPL 0.37 (where they were just wrappers around each other).
64+
The separation of these functions was primarily implemented to avoid performing extra work where unneeded (e.g. to not calculate the log-likelihood when `PriorContext` was being used). This functionality has since been replaced with accumulators (see the 0.37 changelog for more details).
65+
66+
#### Removal of the `"del"` flag
67+
68+
Previously `VarInfo` (or more correctly, the `Metadata` object within a `VarInfo`), had a flag called `"del"` for all variables. If it was set to `true` the variable was to be overwritten with a new value at the next evaluation. The new `InitContext` and related changes above make this flag unnecessary, and it has been removed.
69+
70+
The only flag other than `"del"` that `Metadata` ever used was `"trans"`. Thus the generic functions `set_flag!`, `unset_flag!` and `is_flagged!` have also been removed in favour of more specific ones. We've also used this opportunity to name the `"trans"` flag and the corresponding `istrans` function to be more explicit. The new, exported interface consists of the `is_transformed` and `set_transformed!!` functions.
71+
72+
#### Removal of `resume_from`
73+
74+
The `resume_from=chn` keyword argument to `sample` has been removed; please use the `initial_state` argument instead.
75+
`loadstate` will be exported from Turing in the next release of Turing.
76+
77+
#### Change of output type for `pointwise_logdensities`
78+
79+
The functions `pointwise_prior_logdensities`, `pointwise_logdensities`, and `pointwise_loglikelihoods` when called on `MCMCChains.Chains` objects, now return new `MCMCChains.Chains` objects by default, instead of dictionaries of matrices.
80+
81+
If you want the old behaviour, you can pass `OrderedDict` as the third argument, i.e., `pointwise_logdensities(model, chain, OrderedDict)`.
82+
83+
### Other changes
84+
85+
#### `predict(model, chain; include_all)`
86+
87+
The `include_all` keyword argument for `predict` now works even when no RNG is specified (previously it would only work when an RNG was explicitly passed).
88+
89+
#### `DynamicPPL.setleafcontext(model, context)`
90+
91+
This convenience method has been added to quickly modify the leaf context of a model.
92+
93+
#### Reimplementation of functions using `InitContext`
94+
95+
A number of functions have been reimplemented and unified with the help of `InitContext`.
96+
In particular, this release brings substantial performance improvements for `returned` and `predict`.
97+
Their APIs are the same.
98+
99+
#### Upstreaming of VarName functionality
100+
101+
The implementation of the `varname_leaves` and `varname_and_value_leaves` functions have been moved to AbstractPPL.jl.
102+
Their behaviour is otherwise identical, and they are still accessible from the DynamicPPL module (though still not exported).
103+
3104
## 0.37.5
4105

5106
A minor optimisation for Enzyme AD on DynamicPPL models.

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "DynamicPPL"
22
uuid = "366bfd00-2699-11ea-058f-f148b4cae6d8"
3-
version = "0.37.5"
3+
version = "0.38.0"
44

55
[deps]
66
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
@@ -48,7 +48,7 @@ DynamicPPLMooncakeExt = ["Mooncake"]
4848
[compat]
4949
ADTypes = "1"
5050
AbstractMCMC = "5"
51-
AbstractPPL = "0.13"
51+
AbstractPPL = "0.13.1"
5252
Accessors = "0.1"
5353
BangBang = "0.4.1"
5454
Bijectors = "0.13.18, 0.14, 0.15"

benchmarks/Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ DynamicPPL = {path = "../"}
2323
ADTypes = "1.14.0"
2424
BenchmarkTools = "1.6.0"
2525
Distributions = "0.25.117"
26-
DynamicPPL = "0.37"
26+
DynamicPPL = "0.38"
2727
Enzyme = "0.13"
2828
ForwardDiff = "0.10.38, 1"
2929
LogDensityProblems = "2.1.2"
3030
Mooncake = "0.4"
3131
PrettyTables = "3"
3232
ReverseDiff = "1.15.3"
33-
StableRNGs = "1"
33+
StableRNGs = "1"

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Accessors = "0.1"
1919
Distributions = "0.25"
2020
Documenter = "1"
2121
DocumenterMermaid = "0.1, 0.2"
22-
DynamicPPL = "0.37"
22+
DynamicPPL = "0.38"
2323
FillArrays = "0.13, 1"
2424
ForwardDiff = "0.10, 1"
2525
JET = "0.9, 0.10"

docs/src/api.md

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Part of the API of DynamicPPL is defined in the more lightweight interface packa
88

99
A core component of DynamicPPL is the [`@model`](@ref) macro.
1010
It can be used to define probabilistic models in an intuitive way by specifying random variables and their distributions with `~` statements.
11-
These statements are rewritten by `@model` as calls of [internal functions](@ref model_internal) for sampling the variables and computing their log densities.
11+
These statements are rewritten by `@model` as calls of internal functions for sampling the variables and computing their log densities.
1212

1313
```@docs
1414
@model
@@ -243,14 +243,7 @@ DynamicPPL.TestUtils.AD.ADIncorrectException
243243

244244
## Demo models
245245

246-
DynamicPPL provides several demo models and helpers for testing samplers in the `DynamicPPL.TestUtils` submodule.
247-
248-
```@docs
249-
DynamicPPL.TestUtils.test_sampler
250-
DynamicPPL.TestUtils.test_sampler_on_demo_models
251-
DynamicPPL.TestUtils.test_sampler_continuous
252-
DynamicPPL.TestUtils.marginal_mean_of_samples
253-
```
246+
DynamicPPL provides several demo models in the `DynamicPPL.TestUtils` submodule.
254247

255248
```@docs
256249
DynamicPPL.TestUtils.DEMO_MODELS
@@ -345,9 +338,8 @@ The [Transformations section below](#Transformations) describes the methods used
345338
In the specific case of `VarInfo`, it keeps track of whether samples have been transformed by setting flags on them, using the following functions.
346339

347340
```@docs
348-
set_flag!
349-
unset_flag!
350-
is_flagged
341+
is_transformed
342+
set_transformed!!
351343
```
352344

353345
```@docs
@@ -360,6 +352,13 @@ Base.empty!
360352
SimpleVarInfo
361353
```
362354

355+
### Tilde-pipeline
356+
357+
```@docs
358+
tilde_assume!!
359+
tilde_observe!!
360+
```
361+
363362
### Accumulators
364363

365364
The subtypes of [`AbstractVarInfo`](@ref) store the cumulative log prior and log likelihood, and sometimes other variables that change during executing, in what are called accumulators.
@@ -432,8 +431,6 @@ DynamicPPL.StaticTransformation
432431
```
433432

434433
```@docs
435-
DynamicPPL.istrans
436-
DynamicPPL.settrans!!
437434
DynamicPPL.transformation
438435
DynamicPPL.link
439436
DynamicPPL.invlink
@@ -451,8 +448,6 @@ DynamicPPL.maybe_invlink_before_eval!!
451448
Base.merge(::AbstractVarInfo)
452449
DynamicPPL.subset
453450
DynamicPPL.unflatten
454-
DynamicPPL.varname_leaves
455-
DynamicPPL.varname_and_value_leaves
456451
```
457452

458453
### Evaluation Contexts
@@ -465,61 +460,48 @@ AbstractPPL.evaluate!!
465460

466461
This method mutates the `varinfo` used for execution.
467462
By default, it does not perform any actual sampling: it only evaluates the model using the values of the variables that are already in the `varinfo`.
468-
To perform sampling, you can either wrap `model.context` in a `SamplingContext`, or use this convenience method:
469-
470-
```@docs
471-
DynamicPPL.evaluate_and_sample!!
472-
```
463+
If you wish to sample new values, see the section on [VarInfo initialisation](#VarInfo-initialisation) just below this.
473464

474465
The behaviour of a model execution can be changed with evaluation contexts, which are a field of the model.
475466
Contexts are subtypes of `AbstractPPL.AbstractContext`.
476467

477468
```@docs
478-
SamplingContext
479469
DefaultContext
480470
PrefixContext
481471
ConditionContext
472+
InitContext
482473
```
483474

484-
### Samplers
475+
### VarInfo initialisation
485476

486-
In DynamicPPL two samplers are defined that are used to initialize unobserved random variables:
487-
[`SampleFromPrior`](@ref) which samples from the prior distribution, and [`SampleFromUniform`](@ref) which samples from a uniform distribution.
477+
The function `init!!` is used to initialise, or overwrite, values in a VarInfo.
478+
It is really a thin wrapper around using `evaluate!!` with an `InitContext`.
488479

489480
```@docs
490-
SampleFromPrior
491-
SampleFromUniform
481+
DynamicPPL.init!!
492482
```
493483

494-
Additionally, a generic sampler for inference is implemented.
484+
To accomplish this, an initialisation _strategy_ is required, which defines how new values are to be obtained.
485+
There are three concrete strategies provided in DynamicPPL:
495486

496487
```@docs
497-
Sampler
488+
InitFromPrior
489+
InitFromUniform
490+
InitFromParams
498491
```
499492

500-
The default implementation of [`Sampler`](@ref) uses the following unexported functions.
493+
If you wish to write your own, you have to subtype [`DynamicPPL.AbstractInitStrategy`](@ref) and implement the `init` method.
501494

502495
```@docs
503-
DynamicPPL.initialstep
504-
DynamicPPL.loadstate
505-
DynamicPPL.initialsampler
496+
DynamicPPL.AbstractInitStrategy
497+
DynamicPPL.init
506498
```
507499

508-
Finally, to specify which varinfo type a [`Sampler`](@ref) should use for a given [`Model`](@ref), this is specified by [`DynamicPPL.default_varinfo`](@ref) and can thus be overloaded for each `model`-`sampler` combination. This can be useful in cases where one has explicit knowledge that one type of varinfo will be more performant for the given `model` and `sampler`.
509-
510-
```@docs
511-
DynamicPPL.default_varinfo
512-
```
500+
### Choosing a suitable VarInfo
513501

514502
There is also the _experimental_ [`DynamicPPL.Experimental.determine_suitable_varinfo`](@ref), which uses static checking via [JET.jl](https://github.com/aviatesk/JET.jl) to determine whether one should use [`DynamicPPL.typed_varinfo`](@ref) or [`DynamicPPL.untyped_varinfo`](@ref), depending on which supports the model:
515503

516504
```@docs
517505
DynamicPPL.Experimental.determine_suitable_varinfo
518506
DynamicPPL.Experimental.is_suitable_varinfo
519507
```
520-
521-
### [Model-Internal Functions](@id model_internal)
522-
523-
```@docs
524-
tilde_assume
525-
```

ext/DynamicPPLEnzymeCoreExt.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ else
88
using ..EnzymeCore
99
end
1010

11-
@inline EnzymeCore.EnzymeRules.inactive_type(::Type{<:DynamicPPL.SamplingContext}) = true
12-
13-
# Mark istrans as having 0 derivative. The `nothing` return value is not significant, Enzyme
11+
# Mark is_transformed as having 0 derivative. The `nothing` return value is not significant, Enzyme
1412
# only checks whether such a method exists, and never runs it.
15-
@inline EnzymeCore.EnzymeRules.inactive(::typeof(DynamicPPL.istrans), args...) = nothing
13+
@inline EnzymeCore.EnzymeRules.inactive(::typeof(DynamicPPL.is_transformed), args...) =
14+
nothing
1615

1716
end

ext/DynamicPPLJETExt.jl

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ using JET: JET
66
function DynamicPPL.Experimental.is_suitable_varinfo(
77
model::DynamicPPL.Model, varinfo::DynamicPPL.AbstractVarInfo; only_ddpl::Bool=true
88
)
9-
# Let's make sure that both evaluation and sampling doesn't result in type errors.
109
f, argtypes = DynamicPPL.DebugUtils.gen_evaluator_call_with_types(model, varinfo)
1110
# If specified, we only check errors originating somewhere in the DynamicPPL.jl.
1211
# This way we don't just fall back to untyped if the user's code is the issue.
@@ -21,32 +20,36 @@ end
2120
function DynamicPPL.Experimental._determine_varinfo_jet(
2221
model::DynamicPPL.Model; only_ddpl::Bool=true
2322
)
24-
# Use SamplingContext to test type stability.
25-
sampling_model = DynamicPPL.contextualize(
26-
model, DynamicPPL.SamplingContext(model.context)
27-
)
28-
29-
# First we try with the typed varinfo.
30-
varinfo = DynamicPPL.typed_varinfo(sampling_model)
23+
# Generate a typed varinfo to test model type stability with
24+
varinfo = DynamicPPL.typed_varinfo(model)
3125

32-
# Let's make sure that both evaluation and sampling doesn't result in type errors.
33-
issuccess, result = DynamicPPL.Experimental.is_suitable_varinfo(
34-
sampling_model, varinfo; only_ddpl
26+
# Check type stability of evaluation (i.e. DefaultContext)
27+
model = DynamicPPL.setleafcontext(model, DynamicPPL.DefaultContext())
28+
eval_issuccess, eval_result = DynamicPPL.Experimental.is_suitable_varinfo(
29+
model, varinfo; only_ddpl
3530
)
31+
if !eval_issuccess
32+
@debug "Evaluation with typed varinfo failed with the following issues:"
33+
@debug eval_result
34+
end
3635

37-
if !issuccess
38-
# Useful information for debugging.
39-
@debug "Evaluaton with typed varinfo failed with the following issues:"
40-
@debug result
36+
# Check type stability of initialisation (i.e. InitContext)
37+
model = DynamicPPL.setleafcontext(model, DynamicPPL.InitContext())
38+
init_issuccess, init_result = DynamicPPL.Experimental.is_suitable_varinfo(
39+
model, varinfo; only_ddpl
40+
)
41+
if !init_issuccess
42+
@debug "Initialisation with typed varinfo failed with the following issues:"
43+
@debug init_result
4144
end
4245

43-
# If we didn't fail anywhere, we return the type stable one.
44-
return if issuccess
46+
# If neither of them failed, we can return the typed varinfo as it's type stable.
47+
return if (eval_issuccess && init_issuccess)
4548
varinfo
4649
else
4750
# Warn the user that we can't use the type stable one.
4851
@warn "Model seems incompatible with typed varinfo. Falling back to untyped varinfo."
49-
DynamicPPL.untyped_varinfo(sampling_model)
52+
DynamicPPL.untyped_varinfo(model)
5053
end
5154
end
5255

0 commit comments

Comments
 (0)