Conversation
|
Thanks @CompRhys! We had a chat about this 1h ago, and plan to create a separate metatomic-torchsim (and metatomic-ase, …) python package that would live in this repository but have a separate version number and release schedule. This might take us a couple of weeks to do, how urgent is getting this code out of torchsim for you? @HaoZeke in the mean time can you help bringing this PR in a state where it supports all the same features as the other engine integrations? |
In the same vein, @CompRhys, would you be OK with me making changes to this PR? I'd like to setup the python package first.
Yup, in the package 😁 |
|
Not urgent. We just cut a 0.5.2 release and so will be a while till we cut 0.5.3. Hopefully this could land in that release. The big switch also relies on there being new releases with the upstreamed interfaces for Please feel free to take this over or delete! |
Introduces the metatomic-torchsim package at python/metatomic_torchsim/, providing a ModelInterface adapter that bridges metatomic's list-of-System convention to TorchSim's batched SimState. Supports all model loading paths (.pt, .ckpt, pet-mad, AtomisticModel, ScriptModule), autograd forces, strain-trick stress, and vesin/nvalchemi neighbor lists. Adds root extras_require["torchsim"] pointing to the subpackage.
Covers initialization, forward pass (energy/forces/stress), batching, batch consistency, forces sum to zero, StateDict input, wrong dtype error, model loading paths (.pt file, bad path, wrong type, non- AtomisticModel ScriptModule), single-atom system, energy-only mode, check_consistency flag, finite-difference force validation, and stress tensor symmetry.
Adds build-metatomic-torchsim (wheel build), torchsim-tests (pytest with LJ test model), and torchsim-docs (Sphinx with shibuya theme).
Sphinx docs with shibuya theme, MyST markdown, and autoapi. Follows Diataxis structure: getting started tutorial, how-to guides for model loading and batched simulations, architecture explanation, and auto-generated API reference. Includes changelog via MyST include directive.
Points to the standalone metatomic-torchsim package with install instructions and a minimal usage snippet.
Co-authored-by: Rhys Goodall <rhys.goodall@outlook.com>
Make metatrain and torch_sim imports optional in torchsim module so docs-tests can collect doctests without crashing on missing deps. Guard test imports and skip when dependencies are unavailable. Fix ruff formatting (quotes, blank lines, line wrapping).
Add test_torchsim.py with 20 tests exercising the inline MetatomicModel wrapper using the LJ test model (no metatrain needed). Coverage is collected separately and combined with torch-tests by the CI coverage combine step. Also accept AtomisticModel and ScriptModule instances directly in MetatomicModel.__init__, matching the standalone package and ASE calculator APIs.
Two issues: (1) torch-sim-atomistic requires Python >= 3.11 but the torchsim-torch-tests env was in the default envlist, failing on Python 3.10 matrix entries. (2) Batch tests used systems with different atom counts (32 vs 4) which the LJ test model cannot handle. Remove torchsim-torch-tests from the default tox envlist and run it as a separate CI step gated on Python >= 3.11. Fix batch tests to use same-sized supercells (different lattice parameters) instead of mixing supercell with unit cell.
|
We decided to drop support for StateDict, I am confused about why there are two implementations so removed it from both both lmk if there are any issues |
Remove the inline torchsim wrapper from metatomic-torch entirely. Engine wrappers belong in standalone packages (metatomic-torchsim), not inside the core package. Deletes the module, tests, tox env, and CI step. Also cleans up the residual dict-to-SimState fallback in the standalone package forward() method and fixes batch tests to use same-sized supercells (the LJ test model cannot batch different-sized systems).
Sorry about that, the inline one should have been removed, since we now split into the standalone |
|
Thanks! look's great please let me know if there's anything I can help with. |
Torch 2.10 changed torch.jit.save to always pass _extra_files to m.save(), even when empty. AtomisticModel.save() did not accept this kwarg, causing TypeError on macOS CI. Accept **kwargs in AtomisticModel.save() for forward compatibility. Use lj_model.save() directly in torchsim test instead of torch.jit.save.
torchsim-tests ran pytest without --cov, so 414 lines of _calculator.py showed as 0% covered in codecov, dropping project below the 75% threshold.
Move the torchsim model upstream.