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
{{ message }}
Repository navigation
Keep prior optional and remove unnecessary copies of theas from ImproperPrior. #1635
The refactored .build_posterior method now effectively requires a prior.
If none is provided, _resolve_prior will raise an error (unless overridden).
However, a prior is only truly required in specific cases — e.g., sequential methods (nle, nre).
It might be preferable to raise an error only when a prior is actually needed, rather than unconditionally.
That said, implementing this conditional behavior might be more work than simply overriding the method in cases where the prior isn’t used.
At present, most methods that don’t need a prior bypass this requirement by using an ImproperEmpirical prior:
This workaround is somewhat inefficient — it stores another copy of theta inside the prior and an extra weight tensor, even though neither is truly needed.
Solution
The ImproperEmpirical prior avoids the error but is never meaningfully used. The only cases I’m aware of are:
Sequential methods: calls to prior.log_prob, which always return zeros.
Support checks: redundant here, since it already has “real” support.
mcmc_transform: used for z-scoring, but this only needs mean and standard deviation.
In most cases, we could replace ImproperEmpirical with a much simpler placeholder class.
Alternatively, we could skip any auxiliary logic that requires the prior when it’s None (e.g., skip rejection sampling if there’s no bounded support).
Both halves of this are done. PR #1803 made the prior check conditional, so a
missing prior no longer raises. PRs #1700 and #1822 removed the copies from ImproperEmpirical. Closing as done.
Activity
Refactored use of prior in NeuralInference methods, introduced NoPrio…
janfb commentedon Aug 11, 2026
Both halves of this are done. PR #1803 made the prior check conditional, so a
missing prior no longer raises. PRs #1700 and #1822 removed the copies from
ImproperEmpirical. Closing as done.Simformer (#1621)