fix(dynamics): use inv_ex with contiguous in NPT.pre_update#43
Merged
dallasfoster merged 4 commits intoNVIDIA:mainfrom Apr 6, 2026
Merged
fix(dynamics): use inv_ex with contiguous in NPT.pre_update#43dallasfoster merged 4 commits intoNVIDIA:mainfrom
dallasfoster merged 4 commits intoNVIDIA:mainfrom
Conversation
NPT.pre_update() was the only cell inversion call in the dynamics codebase using torch.linalg.inv() instead of inv_ex()[0].contiguous(). inv() returns a non-contiguous tensor (column-major strides) which can cause incorrect results in downstream Warp kernels that expect row-major layout. All other call sites (NPH, NPT.post_update, FIREVariableCell, NeighborListHook) already use inv_ex + contiguous.
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
Contributor
Greptile SummaryThis PR fixes a one-line inconsistency in Important Files Changed
Reviews (3): Last reviewed commit: "Merge branch 'main' into fix/npt-inv-con..." | Re-trigger Greptile |
dallasfoster
approved these changes
Apr 2, 2026
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.
ALCHEMI Toolkit Pull Request
Description
NPT.pre_update()was the only cell inversion call in the dynamics codebase usingtorch.linalg.inv()instead ofinv_ex()[0].contiguous().inv()returns a non-contiguous tensor (column-major strides(9, 1, 3)) which can cause incorrect results in downstream Warp kernels that expect row-major layout.Type of Change
Changes Made
npt.py:292fromtorch.linalg.inv(batch.cell)totorch.linalg.inv_ex(batch.cell)[0].contiguous(), matching every other cell inversion call site (NPH, NPT.post_update, FIREVariableCell, NeighborListHook).Testing
make pytest)make lint)test_npt_nph.py(20/20 pass) andtest_ops.py(80/80 pass) on CUDAChecklist