-
Notifications
You must be signed in to change notification settings - Fork 26
Add GAP model #223
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
Add GAP model #223
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
7334795
Fix typo
frostedoyster e7b293f
Prototype
frostedoyster 32747ed
Merge branch 'main' into extensions
frostedoyster 0555c97
Add GAP implementation
frostedoyster 9dab079
Merge branch 'extensions' into sparse-gap
frostedoyster 958a773
Adapt to new read_targets
frostedoyster dd9b523
Fix this test
frostedoyster 2875787
Merge branch 'extensions' into sparse-gap
frostedoyster 5f6f7fe
Log destination of checkpoint, exported model and extensions at the e…
frostedoyster 5a2fc75
Merge branch 'extensions' into sparse-gap
frostedoyster e065412
Merge branch 'main' into extensions
frostedoyster d38b2e5
Merge branch 'extensions' into sparse-gap
frostedoyster 028b6c5
Fix ASE
frostedoyster c9c1357
Add tests that extensions are saved
frostedoyster 1260d46
Also log message when exporting model
frostedoyster 2db6a09
Merge branch 'extensions' into sparse-gap
frostedoyster 4bf7928
Merge branch 'main' into sparse-gap
frostedoyster edac40c
Add Davide to codeowners
frostedoyster c6ce54e
added suggestions
DavideTisi 822e02f
linter + comments
DavideTisi 2c73d01
Update docs/src/architectures/gap.rst
DavideTisi 2ca5ae8
fix doc
DavideTisi 6bed07a
linter
DavideTisi 2cdd563
atomic_types
DavideTisi 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,32 @@ | ||
| name: GAP tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| # Check all PR | ||
|
|
||
| jobs: | ||
| tests: | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - os: ubuntu-22.04 | ||
| python-version: "3.11" | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v3 | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - run: pip install tox | ||
|
|
||
| - name: run SparseGAP tests | ||
| run: tox -e gap-tests | ||
| env: | ||
| # Use the CPU only version of torch when building/running the code | ||
| PIP_EXTRA_INDEX_URL: https://download.pytorch.org/whl/cpu | ||
|
|
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 |
|---|---|---|
|
|
@@ -5,3 +5,4 @@ | |
| **/soap_bpnn @frostedoyster | ||
| **/alchemical_model @abmazitov | ||
| **/pet @spozdn @abmazitov | ||
| **/gap @DavideTisi | ||
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,120 @@ | ||
| .. _architecture-sparse-gap: | ||
|
|
||
| GAP | ||
| === | ||
|
|
||
| This is an implementation of the sparse `Gaussian Approximation Potential | ||
| <GAP_>`_ (GAP) using `Smooth Overlap of Atomic Positions <SOAP_>`_ (SOAP) | ||
| implemented in `rascaline <RASCALINE_>`_. | ||
|
|
||
|
|
||
| .. _SOAP: https://doi.org/10.1103/PhysRevB.87.184115 | ||
| .. _GAP: https://doi.org/10.1002/qua.24927 | ||
| .. _RASCALINE: https://github.com/Luthaf/rascaline | ||
|
|
||
| The GAP model in metatensor-models can only train on CPU, but evaluation | ||
| is also supported on GPU. | ||
|
|
||
|
|
||
| Installation | ||
| ------------ | ||
|
|
||
| To install the package, you can run the following command in the root directory | ||
| of the repository: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| pip install .[gap] | ||
|
|
||
| This will install the package with the GAP dependencies. | ||
|
|
||
|
|
||
| Architecture Hyperparameters | ||
| ---------------------------- | ||
|
|
||
| :param name: ``experimental.gap`` | ||
|
|
||
| model | ||
| ##### | ||
| soap | ||
| ^^^^ | ||
| :param cutoff: Spherical cutoff (Å) to use for atomic environments. Default 5.0 | ||
| :param max_radial: Number of radial basis function to use. Default 8 | ||
| :param max_angular: Number of angular basis function to use also denoted by the maximum | ||
| degree of spherical harmonics. Default 6 | ||
| :param atomic_gaussian_width: Width of the atom-centered gaussian creating the atomic | ||
| density. Default 0.3 | ||
| :param center_atom_weight: Weight of the central atom contribution to the features. If | ||
| 1.0 the center atom contribution is weighted the same as any other contribution. If | ||
| 0.0 the central atom does not contribute to the features at all. Default 1.0 | ||
| :param cutoff_function: cutoff function used to smooth the behavior around the cutoff | ||
| radius. The supported cutoff function are | ||
|
|
||
| - ``Step``: Step function, 1 if ``r < cutoff`` and 0 if ``r >= cutoff``. This cutoff | ||
| function takes no additional parameters and can set as in ``.yaml`` file: | ||
|
|
||
| .. code-block:: yaml | ||
|
|
||
| cutoff_function: | ||
| Step: | ||
|
|
||
| - ``ShiftedCosine`` (Default value): Shifted cosine switching function | ||
| ``f(r) = 1/2 * (1 + cos(π (r- cutoff + width) / width ))``. | ||
| This cutoff function takes the ``width``` as | ||
| additional parameter and can set as in ``options.yaml`` file as: | ||
|
|
||
| .. code-block:: yaml | ||
|
|
||
| cutoff_function: | ||
| ShiftedCosine: | ||
| width: 1.0 | ||
|
|
||
| :param radial_scaling: Radial scaling can be used to reduce the importance of neighbor | ||
| atoms further away from the center, usually improving the performance of the model. | ||
| The supported radial scaling functions are | ||
|
|
||
| - ``None``: No radial scaling. | ||
|
|
||
| .. code-block:: yaml | ||
|
|
||
| radial_scaling: | ||
| None: | ||
|
|
||
| - ``Willatt2018`` (Default value): Use a long-range algebraic decay and | ||
| smooth behavior at :math:`r | ||
| \rightarrow 0`: as introduced by :footcite:t:`willatt_feature_2018` as ``f(r) = | ||
| rate / (rate + (r / scale) ^ exponent)`` This radial scaling function can be set | ||
| in the ``options.yaml`` file as. | ||
|
|
||
| .. code-block:: yaml | ||
|
|
||
| radial_scaling: | ||
| Willatt2018: | ||
| rate: 1.0 | ||
| scale: 2.0 | ||
| exponent: 7.0 | ||
|
|
||
| .. note:: | ||
|
|
||
| Currently, we only support a Gaussian type orbitals (GTO) as radial basis functions | ||
| and radial integrals. | ||
|
|
||
| krr | ||
| ^^^^ | ||
| :param degree: degree of the polynomial kernel. Default 2 | ||
| :param num_sparse_points: number of pseudo points to select | ||
| (by farthest point sampling). Default 500 | ||
|
|
||
| training: | ||
| ^^^^^^^^^ | ||
| :param regularizer: value of the energy regularizer. Default 0.001 | ||
| :param regularizer_forces: value of the forces regularizer. Default null | ||
|
|
||
|
|
||
| Default Hyperparameters | ||
| ----------------------- | ||
| The default hyperparameters for the GAP model are: | ||
|
|
||
| .. literalinclude:: ../../../src/metatensor/models/experimental/gap/default-hypers.yaml | ||
| :language: yaml | ||
|
|
||
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,14 @@ | ||
| from .model import GAP | ||
| from .trainer import Trainer | ||
|
|
||
| __model__ = GAP | ||
| __trainer__ = Trainer | ||
|
|
||
| __authors__ = [ | ||
| ("Alexander Goscinski <alex.goscinski@posteo.de>", "@agosckinski"), | ||
| ("Davide Tisi <davide.tisi@epfl.ch>", "@DavideTisi"), | ||
| ] | ||
|
|
||
| __maintainers__ = [ | ||
| ("Davide Tisi <davide.tisi@epfl.ch>", "@DavideTisi"), | ||
|
PicoCentauri marked this conversation as resolved.
|
||
| ] | ||
28 changes: 28 additions & 0 deletions
28
src/metatensor/models/experimental/gap/default-hypers.yaml
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,28 @@ | ||
| # default hyperparameters for the SparseGAP model | ||
| name: gap | ||
|
|
||
| model: | ||
| soap: | ||
| cutoff: 5.0 | ||
| max_radial: 8 | ||
| max_angular: 6 | ||
| atomic_gaussian_width: 0.3 | ||
| radial_basis: | ||
| Gto: {} | ||
| center_atom_weight: 1.0 | ||
| cutoff_function: | ||
| ShiftedCosine: | ||
| width: 1.0 | ||
| radial_scaling: | ||
| Willatt2018: | ||
| rate: 1.0 | ||
| scale: 2.0 | ||
| exponent: 7.0 | ||
|
|
||
| krr: | ||
| degree: 2 | ||
| num_sparse_points: 500 | ||
|
|
||
| training: | ||
| regularizer: 0.001 | ||
| regularizer_forces: null |
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.
Uh oh!
There was an error while loading. Please reload this page.