Skip to content

Commit 50298b4

Browse files
committed
Split the ASE integration into it's own separate package
1 parent 37c9b53 commit 50298b4

33 files changed

Lines changed: 3188 additions & 2639 deletions

.github/workflows/ase-tests.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: ASE integration tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
# Check all PR
8+
9+
concurrency:
10+
group: ase-tests-${{ github.ref }}
11+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
12+
13+
jobs:
14+
tests:
15+
runs-on: ubuntu-24.04
16+
name: ASE
17+
steps:
18+
- uses: actions/checkout@v6
19+
with:
20+
fetch-depth: 0
21+
22+
- name: setup Python
23+
uses: actions/setup-python@v6
24+
with:
25+
python-version: "3.13"
26+
27+
- name: Setup sccache
28+
uses: mozilla-actions/sccache-action@v0.0.9
29+
with:
30+
version: "v0.10.0"
31+
32+
- name: Setup sccache environnement variables
33+
run: |
34+
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
35+
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
36+
echo "CMAKE_C_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV
37+
echo "CMAKE_CXX_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV
38+
39+
- name: install tests dependencies
40+
run: |
41+
python -m pip install --upgrade pip
42+
python -m pip install tox coverage
43+
44+
- name: run tests
45+
run: tox -e ase-tests
46+
env:
47+
PIP_EXTRA_INDEX_URL: https://download.pytorch.org/whl/cpu
48+
49+
- name: combine Python coverage files
50+
shell: bash
51+
run: |
52+
coverage combine .tox/*/.coverage
53+
coverage xml
54+
55+
- name: upload to codecov.io
56+
uses: codecov/codecov-action@v5
57+
with:
58+
fail_ci_if_error: true
59+
files: coverage.xml
60+
token: ${{ secrets.CODECOV_TOKEN }}

AUTHORS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
Guillaume Fraux
2+
Philip Loche
23
Filippo Bigi
4+
Qianjun Xu

docs/src/engines/ase.rst

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ASE
1414
Supported model outputs
1515
^^^^^^^^^^^^^^^^^^^^^^^
1616

17-
.. py:currentmodule:: metatomic.torch.ase_calculator
17+
.. py:currentmodule:: metatomic_ase
1818
1919
- the :ref:`energy <energy-output>`, non-conservative :ref:`forces
2020
<non-conservative-forces-output>` and :ref:`stress <non-conservative-stress-output>`
@@ -26,16 +26,37 @@ Supported model outputs
2626
- for non-equivariant architectures like
2727
`PET <https://docs.metatensor.org/metatrain/latest/architectures/pet.html>`_,
2828
rotationally-averaged energies, forces, and stresses can be computed using
29-
:py:class:`metatomic.torch.ase_calculator.SymmetrizedCalculator`.
29+
:py:class:`metatomic_ase.SymmetrizedCalculator`.
3030

3131
How to install the code
3232
^^^^^^^^^^^^^^^^^^^^^^^
3333

34-
The code is available in the ``metatomic-torch`` package, in the
35-
:py:class:`metatomic.torch.ase_calculator.MetatomicCalculator` class.
34+
The code is available in the ``metatomic-ase`` package, which can be installed
35+
using ``pip install metatomic-ase``.
3636

3737
How to use the code
3838
^^^^^^^^^^^^^^^^^^^
3939

40-
See the :ref:`corresponding tutorial <atomistic-tutorial-md>`, and API
41-
documentation of the :py:class:`MetatomicCalculator` class.
40+
We offer two ASE calculators: :py:class:`metatomic_ase.MetatomicCalculator` is
41+
the default one, and support all the features described above, while
42+
:py:class:`metatomic_ase.SymmetrizedCalculator` is a wrapper around the former
43+
that allows to compute rotationally-averaged energies, forces, and stresses for
44+
non-equivariant architectures. Both calculators are designed to be used as
45+
drop-in replacements for any ASE calculator, and can be used in any ASE
46+
workflow. You can also check the :ref:`corresponding tutorial
47+
<atomistic-tutorial-md>`.
48+
49+
.. _ase-integration-api:
50+
51+
API documentation
52+
-----------------
53+
54+
.. _calculator: https://ase-lib.org/ase/calculators/calculators.html
55+
56+
.. autoclass:: metatomic_ase.MetatomicCalculator
57+
:show-inheritance:
58+
:members:
59+
60+
.. autoclass:: metatomic_ase.SymmetrizedCalculator
61+
:show-inheritance:
62+
:members:

docs/src/torch/reference/ase.rst

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
Atomic Simulation Environment (ASE) integration
22
===============================================
33

4-
.. py:currentmodule:: metatomic.torch
5-
6-
The code in ``metatomic.torch.ase_calculator`` defines a class that
7-
allows using a :py:class:`AtomisticModel` which predicts the energy and forces of a
8-
system as an ASE `calculator`_; enabling the use of machine learning interatomic
9-
potentials to drive calculations compatible with ASE calculators.
10-
11-
Additionally, it allows using arbitrary models with prediction targets which are
12-
not just the energy, through the
13-
:py:meth:`ase_calculator.MetatomicCalculator.run_model` function.
14-
15-
.. _calculator: https://ase-lib.org/ase/calculators/calculators.html
16-
17-
.. autoclass:: metatomic.torch.ase_calculator.MetatomicCalculator
18-
:show-inheritance:
19-
:members:
20-
21-
.. autoclass:: metatomic.torch.ase_calculator.SymmetrizedCalculator
22-
:show-inheritance:
23-
:members:
4+
The integration of metatomic with the Atomic Simulation Environment (ASE) was
5+
moved into it's own package, ``metatomic-ase``, which is available on PyPI. The
6+
documentation for this package can be found in the :ref:`corresponding section
7+
of the documentation <ase-integration-api>`.
8+
9+
Both calculators classes are re-exported from the
10+
``metatomic.torch.ase_calculator`` module for baclwards compatibility, but users
11+
are encouraged to import them from the ``metatomic_ase`` package instead. The
12+
old import paths will be removed in a future release.

metatomic-torch/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ a changelog](https://keepachangelog.com/en/1.1.0/) format. This project follows
2828
- 3-argument `unit_conversion_factor(quantity, from_unit, to_unit)` is
2929
deprecated; the `quantity` parameter is ignored
3030

31+
- `metatomic.torch.ase_calculator` has been split into a separate
32+
`metatomic-ase` package. The code is temporarily re-exported from the old
33+
path, but all users are encouraged to update to explicitly requiring
34+
`metatomic-ase` as a dependency and changing `from
35+
metatomic.torch.ase_calculator import MetatomicCalculator` to `from
36+
metatomic_ase import MetatomicCalculator`
37+
3138
## [Version 0.1.11](https://github.com/metatensor/metatomic/releases/tag/metatomic-torch-v0.1.11) - 2026-02-27
3239

3340
### Added

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ ignore = ["B018", "B904"]
7878

7979
[tool.ruff.lint.isort]
8080
lines-after-imports = 2
81-
known-first-party = ["metatomic", "metatomic_torchsim", "metatomic_lj_test"]
81+
known-first-party = [
82+
"metatomic",
83+
"metatomic_ase",
84+
"metatomic_torchsim",
85+
"metatomic_lj_test",
86+
]
8287
known-third-party = ["torch"]
8388

8489
[tool.ruff.format]

python/examples/2-running-ase-md.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
)
4343

4444
# Integration with ASE for metatomic models
45-
from metatomic.torch.ase_calculator import MetatomicCalculator
45+
from metatomic_ase import MetatomicCalculator
4646

4747

4848
# %%

python/examples/3-atomistic-model-with-nl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
NeighborListOptions,
6060
System,
6161
)
62-
from metatomic.torch.ase_calculator import MetatomicCalculator
62+
from metatomic_ase import MetatomicCalculator
6363

6464

6565
# %%

python/examples/4-profiling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
ModelOutput,
3030
System,
3131
)
32-
from metatomic.torch.ase_calculator import MetatomicCalculator
32+
from metatomic_ase import MetatomicCalculator
3333

3434

3535
# %%

python/metatomic_ase/AUTHORS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Guillaume Fraux
2+
Qianjun Xu
3+
Filippo Bigi
4+
Paolo Pegolo

0 commit comments

Comments
 (0)