Convert explicit looping to bit twiddling for nuts u-turn calculations#1818
Merged
fehiepsi merged 4 commits intopyro-ppl:masterfrom Jun 23, 2024
Merged
Convert explicit looping to bit twiddling for nuts u-turn calculations#1818fehiepsi merged 4 commits intopyro-ppl:masterfrom
fehiepsi merged 4 commits intopyro-ppl:masterfrom
Conversation
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 |
Member
|
@andrewdipper The issues are fixed upstream. Could you sync with the master? |
fehiepsi
approved these changes
Jun 22, 2024
Member
fehiepsi
left a comment
There was a problem hiding this comment.
Nice derivations. Thanks @andrewdipper!
Contributor
Author
|
Ah, sweet. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.- 1clears the above bit and sets all the original last non-zero bitsAs 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