-
Notifications
You must be signed in to change notification settings - Fork 57
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
Major updates of the arithmetic PCV code #564
Conversation
This implementation compute is better than I am not sure if it is better in the case of calculating |
I think our main concern here is stability and performance. Since we use double precision, accuracy should be ok once we avoid under/overflow. |
Thanks @jhenin ! The sum of shifted-softmax is used in this PR. As for performance I think the two ways are basically the same. |
Using LogSumExp instead of calculating the equations directly to get rid of NaN
The new code has following improvements with respect to the old code: 1. Correctly calculate s and z with logsumexp and shifted softmax to avoid overflow and underflow; 2. Correctly calculate the derivatives of s and z with respect to vector sub CVs (also use logsumexp and shifted softmax); 3. Implement debug gradients for s and z with respect to sub CVs that have no explicit gradients; 4. Add new tests for derivatives;
Save the intermediate results from the calculation of s and z, and then use them to accelerate the calculation of derivatives, and also remove separate logsumexp and softmax functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great changes.
It would be better if the tests were included in the top folder rather than being specific to the NAMD sub-folder. However, this would require some more effort to handle the additional files.
The new code has following improvements with respect to the old code:
avoid overflow and underflow;
sub CVs (also use logsumexp and shifted softmax);
have no explicit gradients;
The new
aspath
andazpath
also implement the PCV calculation using Parrinello's formula in atomic Cartesian space.