Skip to content

feat: add TorchSim integration for batch MD and relaxation#155

Open
yanghan234 wants to merge 11 commits intomainfrom
feat/torchsim-integration
Open

feat: add TorchSim integration for batch MD and relaxation#155
yanghan234 wants to merge 11 commits intomainfrom
feat/torchsim-integration

Conversation

@yanghan234
Copy link
Copy Markdown
Collaborator

@yanghan234 yanghan234 commented Apr 29, 2026

Summary

Port TorchSim support from the internal repo, providing GPU-accelerated batch molecular dynamics and structure relaxation via torch-sim.

Note: This PR depends on #154 and should only be merged after #154 is merged. Once that is done, this branch will be rebased onto main.

Breaking Change: Python >=3.12 Required

torch-sim-atomistic requires Python 3.12+, so requires-python has been bumped from >=3.10 to >=3.12. All CI pipelines, docs, README, MODEL_CARD, environment.yaml, and cibuildwheel config have been updated accordingly.

Changes

New package: mattersim.torchsim

  • TorchSimWrapper: adapts MatterSim Potential as a TorchSim ModelInterface
  • TorchSimBatchMD: batch MD with NVT/NPT integrators, temperature schedules
  • TorchSimBatchRelaxer: batch structure optimization with FIRE/etc.
  • Settings classes (IntegratorSettings, OptimizerSettings) with validation
  • Trajectory loading/saving via TorchSim H5MD format
  • Graph construction bridge (build_graph_from_simstate)
  • Model loading with AOTI compilation support

New in mattersim.forcefield

  • load_mattersim(): convenience function wrapping Potential.from_checkpoint() with version normalization and gradient checkpointing support

Dependencies

  • Added torch-sim-atomistic>=0.5.0 as required dependency
  • Bumped requires-python from >=3.10 to >=3.12

CI/CD

  • Test matrix: dropped Python 3.10, added 3.13
  • Release pipeline: wheel builds only for 3.12/3.13
  • GitHub Pages: bumped to Python 3.12

Tests

27 new tests covering settings validation, wrapper forward pass, batch relaxation (file + in-memory), batch MD with multiple integrators, trajectory continuation, per-system temperature schedules, and trajectory loader. GPU tests marked @slow and @requires_gpu.

@yanghan234 yanghan234 changed the base branch from feat/extract-internal-optimizations to main April 29, 2026 09:22
yanghan234 and others added 11 commits April 30, 2026 13:09
Add a convenience function that wraps Potential.from_checkpoint() with
gradient checkpointing support and automatic version normalization from
checkpoint paths. Exported from mattersim.forcefield.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Port TorchSim support from the internal repo, providing GPU-accelerated
batch molecular dynamics and structure relaxation via torch-sim.

New package: mattersim.torchsim
- TorchSimWrapper: adapts MatterSim Potential as a TorchSim ModelInterface
- TorchSimBatchMD: batch MD with NVT/NPT integrators, temperature schedules
- TorchSimBatchRelaxer: batch structure optimization with FIRE/etc.
- Settings classes (IntegratorSettings, OptimizerSettings) with validation
- Trajectory loading/saving via TorchSim H5MD format
- Graph construction bridge (build_graph_from_simstate)
- Model loading with AOTI compilation support

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
27 tests covering settings validation, TorchSimWrapper forward pass,
batch relaxation (file + in-memory), batch MD with multiple integrators,
trajectory continuation, per-system temperature schedules, and
trajectory loader convenience constructors.

GPU-heavy tests are marked @slow and @requires_gpu so they are skipped
on CPU-only machines.

Also adds mattersim_potential_best_device fixture to conftest.py.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
load_mattersim now always sets Potential.version so the pre-computed
autobatcher memory scaler table is used instead of falling back to
slow runtime memory estimation.

- Default checkpoint (load_path=None) gets 'mattersim-v1.0.0-1M'
- Explicit paths are normalized to canonical version strings

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Since requires-python is now >=3.12 (for torch-sim-atomistic), the
python_version < 3.10 dependency conditionals for emmet-core and numpy
are unreachable. Simplify to unconditional versions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Drop Python 3.10 from CI matrix since requires-python is now >=3.12.
Add Python 3.13 to the test matrix. Update macOS job to 3.12.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Only build wheels for Python 3.12 and 3.13 since torch-sim-atomistic
requires Python >=3.12.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Update badge, prerequisite, and conda create example to reflect
the new minimum Python 3.12 requirement.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…, cibuildwheel

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@yanghan234 yanghan234 force-pushed the feat/torchsim-integration branch from 23c4659 to 3abacda Compare April 30, 2026 13:09
@yanghan234 yanghan234 marked this pull request as ready for review April 30, 2026 13:12
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.

1 participant