Skip to content

Update PET-MAD example to PET-MAD v1.1.0rc4 #129

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 4 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions examples/periodic-hamiltonian/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ dependencies:
- ase==3.22.1
- seekpath
- requests
- metatensor
- metatensor-core
- metatensor-learn
- metatensor-operations
- metatensor-torch
- --extra-index-url https://download.pytorch.org/whl/cpu
- rascaline-torch @ git+https://github.com/luthaf/rascaline@3450bc4d609aee87ab73648b059536baa97d15ac#subdirectory=python/rascaline-torch
- --extra-index-url https://download.pytorch.org/whl/cpu
- lightning
- xitorch
- keras_core
Expand Down
2 changes: 0 additions & 2 deletions examples/pet-mad/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ channels:
dependencies:
- python=3.12
- lammps-metatensor=*=cpu*nompi*
- libtorch=*=cpu*mkl*
- pet-mad
- python-metatensor-torch=0.7.6
- pip
- pip:
- ase
Expand Down
20 changes: 7 additions & 13 deletions examples/pet-mad/pet-mad.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@

calculator = PETMADCalculator(version="latest", device="cpu")

# %%
#
# The model can also be exported in a format that can be used with
# external MD engines. This is done by saving the model to a file,
# which includes the model architecture and weights.

calculator.model.save("pet-mad-latest.pt")

# %%
#
Expand Down Expand Up @@ -380,19 +387,6 @@
# without having to introduce vacancies or wait for the
# very long time scale needed for diffusion.

# %%
#
# Before starting the simulations with MD engines, it is important
# to export the model to a format that can be used by the engine.
# This is done by saving the model to a file, which includes the
# model weights and the compiled extensions. We use the ``collect_extensions``
# argument to save the compiled extensions to disk. These extensions ensure that
# the model remains self-contained and can be executed without requiring the
# original Python or C++ source code. In particular, this is necessary for
# the LAMMPS interface to work because it has no access to the Python code.

calculator.model.save("pet-mad-latest.pt", collect_extensions="extensions")


# %%
#
Expand Down