-
Notifications
You must be signed in to change notification settings - Fork 228
Description
After #2202 we will perform one additional evaluation per MCMC iteration than before.
In most use-cases we and users encounter in practice, this is negligible compared to the inference itself, e.g. when using NUTS, but in some cases it can be a significant increase in computational cost.
Unfortunately this is necessary to support "all" possible models and stealthy bugs causing incorrect results in some cases, e.g. see referenced issues in #2202. But IMO we should also provide the user a way to turn this off, as it is not required for most models encountered in practice.
One simple way of doing this is to let the user tell Turing.jl that "hey, this model is 'static' (in some sense), so perform optimizations where you can". At the moment, this would have to be done by the user manually, e.g. by setting a variable attached to the Model
itself telling us that it has static support, etc., which is not ideal, but I don't really see a way around it in the near future (long-term we can definitely do better, e.g. analyze the IR in the model).
I'm of the opinion that adding something like this now is worth it, because I know I would personally be annoyed if I'm forced to perform redundant operations when my model does not require it, without an easy way to turn it off. But I know there are other opinions floating around regarding this.
Thoughts? @devmotion @yebai @sunxd3