Actually fixing reverse AD#33
Merged
Merged
Conversation
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.
Fixing #31. The VeryChord thing was a red herring, turns out the problem was with the
infpadding in the hyrex outputs (which is why we were only seeingNaNsin a couple of densities that touch e.g.xe).Here's what was happening:
t1inevolution_one_kends up pushing these arrays very close tolastval, getting closer and closer for largerk.lensing=Trueadds a few additional largerk. This increases the risk offast_interpneeding to interpolate at an index beyondlastval.lastvalboundary,fast_interpgives aninf. This doesn't show up on forward passes since this isn't the branch of thejnp.wherethat actually gets evaluated, but because we're taking a gradient JAX freaks out unless both branches ofwhereare finite.So the fix was pretty simple, once we have the outputs from HyRex I just patch
lastnumon to all of theinfvalues of the array so this doesn't trigger. No change to speed or accuracy, gives finite gradients.Also got rid of the previous VeryChord tolerance fix, it doesn't actually get us anything.