Skip to content

Allow user to disable unnecessary model evaluations after #2202 #2215

@torfjelde

Description

@torfjelde

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions