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

Convert explicit looping to bit twiddling for nuts u-turn calculations #1818

Merged
merged 4 commits into from
Jun 23, 2024

Conversation

andrewdipper
Copy link
Contributor

Removes explicit looping for calculating the uturn checks to perform and replaces it with bitwise calculations.

I didn't see too much performance difference with a cpu backend but it gives ~20% boost with gpu on some models I'm working with. This clearly will depend on the model and # of steps though. For jnp.bitwise_count((~n & (n + 1)) - 1) (~n & (n + 1)) isolates the bit that changes from 0 to 1 when adding 1 - this is the first zero before the last sequence of ones. - 1 clears the above bit and sets all the original last non-zero bits

As a side note it looks like the raveling / unraveling bog things down a bit too - but the option for block inverse mass matrices make that harder to resolve

@andrewdipper
Copy link
Contributor Author

Unless I'm mistaken I don't think any of the failures are related to the change - they also pass locally. But I haven't seen similar failures on other pr runs

@fehiepsi
Copy link
Member

@andrewdipper The issues are fixed upstream. Could you sync with the master?

Copy link
Member

@fehiepsi fehiepsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice derivations. Thanks @andrewdipper!

@andrewdipper
Copy link
Contributor Author

Ah, sweet. Thanks!

@fehiepsi fehiepsi merged commit 0924135 into pyro-ppl:master Jun 23, 2024
4 checks passed
@andrewdipper andrewdipper deleted the twiddling branch June 24, 2024 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants