-
Notifications
You must be signed in to change notification settings - Fork 8
Split ase integration into a separate metatomic-ase package
#177
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| name: ASE integration tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| # Check all PR | ||
|
|
||
| concurrency: | ||
| group: ase-tests-${{ github.ref }} | ||
| cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | ||
|
|
||
| jobs: | ||
| tests: | ||
| runs-on: ubuntu-24.04 | ||
| name: ASE | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: setup Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.13" | ||
|
|
||
| - name: Setup sccache | ||
| uses: mozilla-actions/sccache-action@v0.0.9 | ||
| with: | ||
| version: "v0.10.0" | ||
|
|
||
| - name: Setup sccache environnement variables | ||
| run: | | ||
| echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV | ||
| echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV | ||
| echo "CMAKE_C_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV | ||
| echo "CMAKE_CXX_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV | ||
|
|
||
| - name: install tests dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install tox coverage | ||
|
|
||
| - name: run tests | ||
| run: tox -e ase-tests | ||
| env: | ||
| PIP_EXTRA_INDEX_URL: https://download.pytorch.org/whl/cpu | ||
|
|
||
| - name: combine Python coverage files | ||
| shell: bash | ||
| run: | | ||
| coverage combine .tox/*/.coverage | ||
| coverage xml | ||
|
|
||
| - name: upload to codecov.io | ||
| uses: codecov/codecov-action@v5 | ||
| with: | ||
| fail_ci_if_error: true | ||
| files: coverage.xml | ||
| token: ${{ secrets.CODECOV_TOKEN }} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| Guillaume Fraux | ||
| Philip Loche | ||
| Filippo Bigi | ||
| Qianjun Xu |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,12 @@ | ||
| Atomic Simulation Environment (ASE) integration | ||
| =============================================== | ||
|
|
||
| .. py:currentmodule:: metatomic.torch | ||
|
|
||
| The code in ``metatomic.torch.ase_calculator`` defines a class that | ||
| allows using a :py:class:`AtomisticModel` which predicts the energy and forces of a | ||
| system as an ASE `calculator`_; enabling the use of machine learning interatomic | ||
| potentials to drive calculations compatible with ASE calculators. | ||
|
|
||
| Additionally, it allows using arbitrary models with prediction targets which are | ||
| not just the energy, through the | ||
| :py:meth:`ase_calculator.MetatomicCalculator.run_model` function. | ||
|
|
||
| .. _calculator: https://ase-lib.org/ase/calculators/calculators.html | ||
|
|
||
| .. autoclass:: metatomic.torch.ase_calculator.MetatomicCalculator | ||
| :show-inheritance: | ||
| :members: | ||
|
|
||
| .. autoclass:: metatomic.torch.ase_calculator.SymmetrizedCalculator | ||
| :show-inheritance: | ||
| :members: | ||
| The integration of metatomic with the Atomic Simulation Environment (ASE) was | ||
| moved into it's own package, ``metatomic-ase``, which is available on PyPI. The | ||
| documentation for this package can be found in the :ref:`corresponding section | ||
| of the documentation <ase-integration-api>`. | ||
|
Comment on lines
+4
to
+7
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this? The historical context I mean.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just there to keep existing links to the corresponding doc page alive for a bit. |
||
|
|
||
| Both calculators classes are re-exported from the | ||
| ``metatomic.torch.ase_calculator`` module for baclwards compatibility, but users | ||
| are encouraged to import them from the ``metatomic_ase`` package instead. The | ||
| old import paths will be removed in a future release. | ||
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Guillaume Fraux | ||
| Qianjun Xu | ||
| Filippo Bigi | ||
| Paolo Pegolo |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Changelog | ||
|
|
||
| All notable changes to metatomic-ase are documented here, following the | ||
| [keep a changelog](https://keepachangelog.com/en/1.1.0/) format. This project | ||
| follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| <!-- Possible sections for each package: | ||
| ### Added | ||
|
|
||
| ### Fixed | ||
|
|
||
| ### Changed | ||
|
|
||
| ### Removed | ||
| --> | ||
|
|
||
| ## [Unreleased](https://github.com/metatensor/metatomic/) | ||
|
|
||
| - `metatomic-ase` is now a standalone package, containing the ASE integration | ||
| for metatomic models. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../LICENSE |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| include AUTHORS | ||
| include git_version_info |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # `metatomic-ase` | ||
|
|
||
| [ASE](https://ase-lib.org/) integration for metatomic models. | ||
|
|
||
| This package allows you to use metatomic models as ASE | ||
| [`Calculator`](https://ase-lib.org/ase/calculators/calculators.html), integrating with any workflow based on ASE. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| pip install metatomic-ase | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ```python | ||
| import ase.io | ||
| from metatomic_ase import MetatomicCalculator | ||
|
|
||
| # load atoms | ||
| atoms = ase.io.read("...") | ||
|
|
||
| # create a calculator from a saved .pt model | ||
| atoms.calc = MetatomicCalculator("model.pt", device="cuda") | ||
|
|
||
| # from here, all the normal ASE functionality is available | ||
| print(atoms.get_forces()) | ||
| print(atoms.get_potential_energies()) | ||
| ``` | ||
|
|
||
| For full documentation, see the [ASE engine | ||
| page](https://docs.metatensor.org/metatomic/latest/engines/ase.html) in | ||
| metatomic documentation. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| [project] | ||
| name = "metatomic-ase" | ||
| dynamic = ["version", "authors", "dependencies"] | ||
| requires-python = ">=3.10" | ||
|
|
||
| readme = "README.md" | ||
| license = "BSD-3-Clause" | ||
| description = "ASE interface to use metatomic atomistic machine learning models" | ||
|
|
||
| keywords = ["machine learning", "molecular modeling", "ase"] | ||
| classifiers = [ | ||
| "Development Status :: 4 - Beta", | ||
| "Intended Audience :: Science/Research", | ||
| "Operating System :: POSIX", | ||
| "Operating System :: MacOS :: MacOS X", | ||
| "Operating System :: Microsoft :: Windows", | ||
| "Programming Language :: Python", | ||
| "Programming Language :: Python :: 3", | ||
| "Topic :: Scientific/Engineering", | ||
| "Topic :: Scientific/Engineering :: Bio-Informatics", | ||
| "Topic :: Scientific/Engineering :: Chemistry", | ||
| "Topic :: Scientific/Engineering :: Physics", | ||
| "Topic :: Software Development :: Libraries", | ||
| "Topic :: Software Development :: Libraries :: Python Modules", | ||
| ] | ||
|
|
||
| [project.urls] | ||
| homepage = "https://docs.metatensor.org/metatomic/latest/engines/ase.html" | ||
| documentation = "https://docs.metatensor.org/metatomic/latest/engines/ase.html" | ||
| repository = "https://github.com/metatensor/metatomic/blob/main/python/metatomic_ase" | ||
| changelog = "https://github.com/metatensor/metatomic/blob/main/python/metatomic_ase/CHANGELOG.md" | ||
|
|
||
| ### ======================================================================== ### | ||
| [build-system] | ||
| requires = [ | ||
| "setuptools >=77", | ||
| "packaging >=23", | ||
| ] | ||
| build-backend = "setuptools.build_meta" | ||
|
|
||
| ### ======================================================================== ### | ||
| [tool.pytest.ini_options] | ||
| python_files = ["*.py"] | ||
| testpaths = ["tests"] | ||
| filterwarnings = [ | ||
| "error", | ||
| "ignore:`torch.jit.script` is deprecated. Please switch to `torch.compile` or `torch.export`:DeprecationWarning", | ||
| "ignore:`torch.jit.script_method` is deprecated. Please switch to `torch.compile` or `torch.export`:DeprecationWarning", | ||
| "ignore:`torch.jit.save` is deprecated. Please switch to `torch.export`:DeprecationWarning", | ||
| "ignore:`torch.jit.load` is deprecated. Please switch to `torch.export`:DeprecationWarning", | ||
| "ignore:.*vesin.metatomic was only tested with metatomic.torch >=0.1.3,<0.2.*:UserWarning", | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
For later but I'd generalize this into base and derived and saying we only currently have one derived thing but more might come
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.
Not sure what you mean by base & derived?
SymmetrizedCalculatorbeing the derived one?Here the plan is not to add more derived calculators, but to move this code to a model wrapper, i.e. #119