Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

66% speed-up by removing bound checks #4376

Closed
twiecki opened this issue Dec 23, 2020 · 0 comments · Fixed by #4377
Closed

66% speed-up by removing bound checks #4376

twiecki opened this issue Dec 23, 2020 · 0 comments · Fixed by #4377

Comments

@twiecki
Copy link
Member

twiecki commented Dec 23, 2020

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant