Skip to content

fix: Enforce contiguous storage when compiling for AOTI - #176

Merged
Daniel Zügner (danielzuegner) merged 1 commit into
microsoft:mainfrom
PascalSalzbrenner:aoti-contiguous-cell-tensor
Oct 21, 2026
Merged

Daniel Zügner (danielzuegner) merged 1 commit into
microsoft:mainfrom
PascalSalzbrenner:aoti-contiguous-cell-tensor

Conversation

@PascalSalzbrenner

Copy link
Copy Markdown
Contributor

Issue

I noticed that geometry optimisations & MD under certain thermo- and baro-stats rapidly became unphysical when using TorchSim to drive AOTI-compiled MatterSim.

Root cause

During geometry optimisation & with the npt_crescale_triclinic integrator, TorchSim passes row_vector_cell in a form that is non-contiguous in memory. AOTI assumes the layout is identical to the contiguous examples it was compiled with, which results in incorrect stresses and thus unphysical trajectories.

Fix

One-line fix in src/mattersim/forcefield/aoti_compile.py: call .contiguous() on all input parameters before passing them to the compiled model. This reoders storage to match what the AOTI kernels assume. I also added a regression test to check for this bug.

@danielzuegner
Daniel Zügner (danielzuegner) merged commit 5c84771 into microsoft:main Oct 21, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants