Skip to content

66% speed-up by removing bound checks #4376

Closed
@twiecki

Description

@twiecki

I added a single line of code and got a 66% speed-up. Most of our distributions have various bound checks. pm.Normal.logp for example checks that sigma > 0 for every logp eval.

These checks are useful when building a new model, for example, if I put a pm.Normal on my sigma and it proposes negative values I want the logp to become -inf.

However, once I have built the model and know that all my parameters can only take on valid ranges I don't need these checks anymore.

So just by making bound() return logp directly (i.e turning it into a noop) I got a nice 66% speed-up on the stochastic vol model.

My question is how do we best allow the user to configure this.

One idea is with pm.Model(disable_bounds_check=True).

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