Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
303 commits
Select commit Hold shift + click to select a range
770bde6
Use covalent radii
frostedoyster Sep 4, 2024
293c7a6
Revert some changes to the encoder
frostedoyster Sep 5, 2024
94df82e
Remove random factor
frostedoyster Oct 7, 2024
9eff61f
Merge branch 'main' into nanopet
frostedoyster Oct 14, 2024
2fd9b8d
Speed up a tiny bit
frostedoyster Oct 14, 2024
6c8f1da
Merge branch 'main' into nanopet
Oct 15, 2024
713cfbb
Fair comparison to PET
frostedoyster Oct 15, 2024
33e2c70
Calculate displacements independently + format
frostedoyster Oct 16, 2024
4b8d8c1
Fix pyproject.toml
frostedoyster Oct 16, 2024
3377b2d
Dependencies
frostedoyster Oct 17, 2024
63bcfac
Merge branch 'mae-logging' into nanopet
frostedoyster Oct 17, 2024
f79a36d
Automatic continuation
frostedoyster Oct 17, 2024
3c136bf
Call processing function before new `outputs/` directory is created
frostedoyster Oct 18, 2024
c33bcf2
Make it distributed-proof
frostedoyster Oct 18, 2024
4b2a877
Merge branch 'auto-continue' into nanopet
frostedoyster Oct 18, 2024
129c9b9
Only save checkpoints from the main process
frostedoyster Oct 18, 2024
d88cfcf
Merge branch 'main' into nanopet
frostedoyster Oct 18, 2024
a675bfe
Get rid of nanopet-neighbors
frostedoyster Oct 18, 2024
72a6502
Speed up
frostedoyster Oct 18, 2024
fc33c70
Proper cutoff parameters
frostedoyster Oct 20, 2024
a951638
MLP for geometric embedding
frostedoyster Oct 20, 2024
92d2c80
Merge branch 'nanopet' of https://github.com/lab-cosmo/metatrain into…
frostedoyster Oct 20, 2024
45c2fc7
Fix bug
frostedoyster Oct 20, 2024
b8cd9ba
Add sample `TensorMap` to `TargetInfo`
frostedoyster Oct 26, 2024
60b6b0d
Change `TensorMap`s inside `TargetInfo` to `float64` to avoid seriali…
frostedoyster Oct 28, 2024
4c614f7
Better documentation
frostedoyster Oct 28, 2024
172af0b
Upgrade to `metatensor-torch` 0.6.0
frostedoyster Oct 29, 2024
0f3bfd7
Upgrade `metatensor-learn`
frostedoyster Oct 30, 2024
0e8e2f7
Update strict NL
frostedoyster Oct 30, 2024
d632dc2
Fix PBCs
frostedoyster Oct 30, 2024
b65536a
Draft
frostedoyster Nov 1, 2024
cf62ee7
Upgrade rascaline-torch
frostedoyster Nov 1, 2024
0ebcc9a
Fix `slice` argument name
frostedoyster Nov 2, 2024
f7355dd
Merge branch 'upgrade-metatensor' into targetinfo-tensormap
frostedoyster Nov 2, 2024
906d01a
Merge branch 'targetinfo-tensormap' into generic-readers
frostedoyster Nov 2, 2024
d850528
Merge branch 'adapt-models' into nanopet
frostedoyster Nov 4, 2024
5d6ccdb
FIx a few issues
frostedoyster Nov 4, 2024
f881951
Add dataset information overview to the dev docs
frostedoyster Nov 5, 2024
de9a28e
Fix docs
frostedoyster Nov 5, 2024
4f89649
Merge branch 'main' into targetinfo-tensormap
frostedoyster Nov 5, 2024
a9773f4
Merge branch 'targetinfo-tensormap' into generic-readers
frostedoyster Nov 5, 2024
5cc0806
Fix export issue
frostedoyster Nov 6, 2024
775be90
Small fixes
frostedoyster Nov 7, 2024
940bd3c
Better LR decreases
frostedoyster Nov 7, 2024
00f289e
Merge branch 'main' into generic-readers
frostedoyster Nov 10, 2024
758b9c5
Fix stuff
frostedoyster Nov 10, 2024
6d99827
Fix more stuff
frostedoyster Nov 10, 2024
012f141
Fix even more stuff
frostedoyster Nov 10, 2024
4146954
Revert changes to options file
frostedoyster Nov 10, 2024
e93ac4a
Fix tests
frostedoyster Nov 10, 2024
e86192d
Add warning when learning of `forces`, `stress`, `virial` not as grad…
frostedoyster Nov 10, 2024
a1c2146
Update developer docs
frostedoyster Nov 11, 2024
b8647f2
Add user docs for generic targets
frostedoyster Nov 11, 2024
00434c6
Overall and ASE reader tests
frostedoyster Nov 11, 2024
b743030
Move tests
frostedoyster Nov 11, 2024
b815435
Metatensor reader tests
frostedoyster Nov 11, 2024
21d6098
One more test
frostedoyster Nov 11, 2024
f3843d9
Eliminate useless checks that are already performed by the `DictConfi…
frostedoyster Nov 11, 2024
fd4a858
Test error with ASE and multiple spherical irreps
frostedoyster Nov 11, 2024
fb4a24d
One more test
frostedoyster Nov 11, 2024
239428d
Fix bug
frostedoyster Nov 11, 2024
15093de
Test more errors
frostedoyster Nov 11, 2024
2a52859
Allow SOAP-BPNN to fit Cartesian vectors
frostedoyster Nov 11, 2024
13da2b8
Fix composition test
frostedoyster Nov 12, 2024
078fbd6
Add checks and SOAP-BPNN vector test
frostedoyster Nov 12, 2024
77f275b
Bug fix in schema
frostedoyster Nov 12, 2024
af5c126
Merge branch 'generic-readers' into adapt-models
frostedoyster Nov 12, 2024
0370921
Add vector output training test
frostedoyster Nov 12, 2024
76b941f
Fix regression tests
frostedoyster Nov 12, 2024
13e7769
Check that ZBL gets correct targets
frostedoyster Nov 12, 2024
da544ff
Docs
frostedoyster Nov 12, 2024
0e6c46f
Fix bug
frostedoyster Nov 12, 2024
3ff9370
Fix bug
frostedoyster Nov 12, 2024
737c895
Extract function to add outputs for SOAP-BPNN
frostedoyster Nov 12, 2024
998b7ed
Fix some small issues
frostedoyster Nov 12, 2024
5da6e75
Merge branch 'main' into nanopet
frostedoyster Nov 12, 2024
4e1c38a
Merge branch 'adapt-models' into nanopet
frostedoyster Nov 12, 2024
04159f2
Fix leftover merge issues
frostedoyster Nov 12, 2024
dd23a63
Add tests
frostedoyster Nov 13, 2024
853ccf0
Fix `tests/resources` folder
frostedoyster Nov 13, 2024
a777fcb
Merge branch 'main' into generic-readers
frostedoyster Nov 13, 2024
27e6104
Merge branch 'generic-readers' into adapt-models
frostedoyster Nov 13, 2024
3be99cc
Remove commented torch hack
frostedoyster Nov 13, 2024
89bddcc
Merge branch 'adapt-models' into nanopet
frostedoyster Nov 13, 2024
160124f
Undo spurious changes
frostedoyster Nov 13, 2024
79e8b30
Codeowners, tox, GH workflows
frostedoyster Nov 13, 2024
8712d27
Add correct values for regression tests
frostedoyster Nov 13, 2024
afb9059
Add documentation
frostedoyster Nov 13, 2024
e665c7a
Regression test
frostedoyster Nov 13, 2024
aeff14f
Clean up
frostedoyster Nov 13, 2024
4aa2a1c
Fix restart issue
frostedoyster Nov 13, 2024
5cc35c0
Fix test
frostedoyster Nov 13, 2024
d0be159
Fix accidental deletion of test
frostedoyster Nov 13, 2024
a325942
Apply suggestions from code review
frostedoyster Nov 18, 2024
a69dfa7
Fix assert
frostedoyster Nov 18, 2024
025048d
Infer `quantity` in `get_energy_target_info`
frostedoyster Nov 18, 2024
03c6df3
Allow arbitrary properties with `metatensor` reader
frostedoyster Nov 18, 2024
b6f5cd5
Fix tests
frostedoyster Nov 18, 2024
7b4ae53
Merge branch 'main' into generic-readers
frostedoyster Nov 18, 2024
a5416be
Fix tests
frostedoyster Nov 18, 2024
a5a102c
Update docs/src/advanced-concepts/preparing-generic-targets.rst
frostedoyster Nov 19, 2024
155aac5
Suggestions from review
frostedoyster Nov 19, 2024
6fcc7f4
Remove private functions from docs
frostedoyster Nov 19, 2024
46223b5
Merge branch 'adapt-models' into phace
frostedoyster Nov 19, 2024
5328def
Update model according to new infrastructure
frostedoyster Nov 19, 2024
175264b
Fix buggggg
frostedoyster Nov 19, 2024
405c2cf
Change metatensor target format to a single `TensorMap`
frostedoyster Nov 19, 2024
0c207fc
Merge branch 'generic-readers' into adapt-models
frostedoyster Nov 20, 2024
e158719
Correctly inherit properties from targets in SOAP-BPNN
frostedoyster Nov 20, 2024
7d3bc7d
Merge branch 'adapt-models' into nanopet
frostedoyster Nov 20, 2024
2a590b0
Correctly inherit properties from targets in SOAP-BPNN
frostedoyster Nov 20, 2024
ab1446a
Fix LLPR test
frostedoyster Nov 20, 2024
a15ae29
Fix regressiont tests
frostedoyster Nov 20, 2024
364bd9b
Fix regression tests
frostedoyster Nov 20, 2024
dff9612
Merge branch 'adapt-models' into nanopet
frostedoyster Nov 20, 2024
7c73db6
Add head types to SOAP-BPNN and nanoPET
frostedoyster Nov 20, 2024
d28583e
Update for features and LLPR module
frostedoyster Nov 20, 2024
8296733
Update old tests
frostedoyster Nov 20, 2024
3a66aa9
Docs and new tests
frostedoyster Nov 20, 2024
f598aab
Merge branch 'main' into adapt-models
frostedoyster Nov 21, 2024
23a99fc
Fix docs
frostedoyster Nov 21, 2024
d35fd1b
Make composition restart-proof (continue, fine-tune, transfer learning)
frostedoyster Nov 21, 2024
7754e6d
Add scale to logger
frostedoyster Nov 21, 2024
59e3363
Turn old warning into error
frostedoyster Nov 21, 2024
e6993e4
Merge branch 'adapt-models' into nanopet
frostedoyster Nov 22, 2024
d4c59b6
Scaler class
frostedoyster Nov 22, 2024
7d2c940
Add to documentation
frostedoyster Nov 22, 2024
d46ca0f
num_properties -> num_subtargets
frostedoyster Nov 22, 2024
b137a4a
Merge branch 'nanopet' into heads-and-utils
frostedoyster Nov 22, 2024
5dbc9ed
Merge branch 'heads-and-utils' into scaler
frostedoyster Nov 22, 2024
40ef3ad
Tests
frostedoyster Nov 22, 2024
ae90f6f
Merge branch 'scaler' into phace
frostedoyster Nov 23, 2024
5c5f3f4
Scaler
frostedoyster Nov 23, 2024
9fb5a93
Actually use `log_mae`
frostedoyster Dec 15, 2024
a6f0dad
Fix final checkpoint bug
frostedoyster Dec 17, 2024
22014dd
Merge branch 'main' into phace
frostedoyster Dec 17, 2024
8fcb14e
Fix 0 epoch issue
frostedoyster Dec 17, 2024
7cf75d2
Merge branch 'checkpoint-bug' into phace
frostedoyster Dec 17, 2024
4a2f5ec
Add dependencies
frostedoyster Dec 17, 2024
6223234
Update trainer
frostedoyster Dec 17, 2024
8d19694
Merge branch 'main' into phace
frostedoyster Dec 17, 2024
596ff08
Add equivariant fitting
frostedoyster Dec 17, 2024
04a58a0
Fix regressiont test
frostedoyster Dec 17, 2024
497c538
Merge branch 'main' into phace
frostedoyster Dec 17, 2024
be3e37f
Fix table
frostedoyster Dec 18, 2024
204c37f
Fix torchscripted training
frostedoyster Dec 19, 2024
a8aea20
Also fix for distributed
frostedoyster Dec 19, 2024
df5414d
Merge branch 'main' into phace
frostedoyster Dec 26, 2024
98963f9
Automatic overall scaling
frostedoyster Jan 18, 2025
f44b15c
Update regression tests
frostedoyster Jan 18, 2025
08cce72
Merge branch 'main' into phace
frostedoyster Jan 18, 2025
3dbb2af
Small update
frostedoyster Jan 18, 2025
2d56150
Add validation of options
frostedoyster Jan 18, 2025
0294053
Clean up
frostedoyster Jan 18, 2025
f3ecf4f
Undo spurious changes
frostedoyster Jan 18, 2025
8e9a96d
Tests
frostedoyster Jan 18, 2025
cde75c9
Remove minus sign
frostedoyster Jan 18, 2025
f90b32d
Restore SOAP-BPNN tests
frostedoyster Jan 18, 2025
d3bf923
Fix model scaling
frostedoyster Jan 19, 2025
a8b5987
Remove automatic scaling (it doesn't work)
frostedoyster Jan 24, 2025
c0665f3
Fix model
frostedoyster Jan 24, 2025
025c756
Final changes
frostedoyster Jan 27, 2025
30b67c3
Allow different metrics than the loss for best model selection
frostedoyster Jan 27, 2025
2e89ac3
Merge branch 'main' into phace
frostedoyster Jan 27, 2025
206493d
Merge branch 'main' into phace
frostedoyster Jan 29, 2025
ed8e64d
Linter
frostedoyster Jan 29, 2025
3bd5a12
Reduce size of MLP head
frostedoyster Jan 29, 2025
9b6d871
Merge branch 'main' into phace
frostedoyster Jan 29, 2025
134e670
Fix regression tests
frostedoyster Jan 29, 2025
2f50d70
Update default hypers
frostedoyster Jan 29, 2025
ac719b4
Change defaults again
frostedoyster Jan 29, 2025
3962929
Merge branch 'main' into phace
frostedoyster Jan 29, 2025
37ed487
Fix tests
frostedoyster Jan 29, 2025
3bd43ad
Customize head size
frostedoyster Jan 29, 2025
da82cc8
Change dtype selection in loading
frostedoyster Jan 30, 2025
ebb35b2
Suggestions from review
frostedoyster Feb 2, 2025
cdad8b4
First implementation
frostedoyster Feb 12, 2025
ffd4638
Fix more stuff
frostedoyster Feb 12, 2025
d1ca76e
Finalize Hartmut TP
frostedoyster Mar 13, 2025
1595899
O(3) Hartmut TPs
frostedoyster Mar 14, 2025
cada851
Remove odd message passing channels
frostedoyster Mar 16, 2025
e92fb54
Add mixing layers after CG
frostedoyster Mar 16, 2025
32961f4
Sparse MM
frostedoyster Mar 17, 2025
d6a5681
Test stuff
frostedoyster Mar 17, 2025
632daff
Test 2
frostedoyster Mar 17, 2025
d69a4aa
More expressive
frostedoyster Mar 17, 2025
dee4694
Merge branch 'main' into phace-hartmut
frostedoyster Jul 6, 2025
f04946c
Update to main
frostedoyster Jul 6, 2025
a99b56e
Merge branch 'main' into phace-hartmut
frostedoyster Aug 17, 2025
f252cb3
Adapt after merge
frostedoyster Aug 17, 2025
bce45de
Fix export issues
frostedoyster Aug 19, 2025
4fbe9ff
Go back to torchscripted training
frostedoyster Aug 19, 2025
c37649e
Use cosine annealing training schedule
frostedoyster Aug 19, 2025
40fbbdd
Train on rank-1 Cartesian tensors
frostedoyster Aug 20, 2025
1546f1d
Fix bug
frostedoyster Aug 20, 2025
caa6d02
Merge branch 'main' into phace-hartmut
frostedoyster Oct 18, 2025
0fa4094
Update to latest main
frostedoyster Oct 18, 2025
0a9e743
Fix small issue
frostedoyster Oct 18, 2025
499d089
Fix one more issue
frostedoyster Oct 18, 2025
962acfc
Remove double TPs
frostedoyster Oct 18, 2025
269c402
Fix stuff
frostedoyster Oct 19, 2025
a89d865
Merge branch 'main' into phace-hartmut
frostedoyster Nov 18, 2025
9cc65a0
Update with new-style hypers
frostedoyster Nov 18, 2025
3a2c722
?
frostedoyster Nov 18, 2025
a38ddec
Merge branch 'main' into phace-hartmut
frostedoyster Nov 26, 2025
202f14c
Purify torch code
frostedoyster Nov 27, 2025
43db1f3
Try to use torch.compile
frostedoyster Nov 28, 2025
6f3f928
Almost working
frostedoyster Nov 28, 2025
613fb5b
Max autotune
frostedoyster Nov 28, 2025
c29a65c
Working version
frostedoyster Nov 29, 2025
93baa32
Handling of generic targets
frostedoyster Nov 29, 2025
dd564e3
Add `torch.compile` option
frostedoyster Nov 29, 2025
077dfaa
Moved tests to shared test suite
pfebrer Nov 29, 2025
07e29d4
Add option to run the whole architecture in the Hartmut representation
frostedoyster Nov 30, 2025
a52b409
Merge branch 'main' into phace-hartmut
frostedoyster Nov 30, 2025
e16f3a4
Fix tests
frostedoyster Nov 30, 2025
8b8d1df
Lint
frostedoyster Nov 30, 2025
ba361cd
Fix tests
frostedoyster Nov 30, 2025
58be984
Fix tests
frostedoyster Nov 30, 2025
994e13b
Fix more bugs
frostedoyster Nov 30, 2025
6aa345a
Conversion for Cartesian vectors
frostedoyster Nov 30, 2025
5b75207
Fix torchscripting
frostedoyster Dec 1, 2025
894ebf1
Merge branch 'main' into phace-hartmut
frostedoyster Dec 1, 2025
de4608f
Improve PhACE architecture (#968)
Copilot Dec 3, 2025
fef73ca
Better defaults
frostedoyster Dec 3, 2025
fefd0a6
Fix bug
frostedoyster Dec 3, 2025
c8c6eaa
Merge branch 'main' into phace-hartmut
frostedoyster Dec 4, 2025
fb922cf
Lint
frostedoyster Dec 4, 2025
96b7937
Remove files
frostedoyster Dec 4, 2025
28268df
Fix PET tests
frostedoyster Dec 4, 2025
ff71154
Update hyper recommendations
frostedoyster Dec 4, 2025
02c4922
Refactor transformations to TP basis and back
frostedoyster Dec 5, 2025
573f156
Refactor and add comments
frostedoyster Dec 5, 2025
5607d2d
Update capabilities
frostedoyster Dec 5, 2025
98b3289
Merge branch 'main' into phace-hartmut
frostedoyster Dec 5, 2025
898bbd7
Fix some tests
frostedoyster Dec 5, 2025
4117ce3
Fix some tests
frostedoyster Dec 5, 2025
384210a
Fix tests
frostedoyster Dec 5, 2025
ad6945b
Fix radial basis description
frostedoyster Dec 6, 2025
398a797
Merge branch 'main' into phace-hartmut
frostedoyster Dec 6, 2025
bd259b0
Remove print
frostedoyster Dec 6, 2025
b4eedf0
Fix gradient request bug
frostedoyster Dec 7, 2025
4938935
Lint
frostedoyster Dec 8, 2025
bfaeea2
Provide a good error message if target L is too large
frostedoyster Dec 8, 2025
34b1203
Merge branch 'main' into phace-hartmut
jwa7 Dec 14, 2025
c21e387
Use atomic baseline
jwa7 Dec 14, 2025
c75b088
Merge branch 'main' into phace-hartmut
frostedoyster Dec 14, 2025
0ded1cc
Fix tests
frostedoyster Dec 14, 2025
d7f1d70
Make sure all parameters are used
frostedoyster Dec 14, 2025
4ca5b62
Merge branch 'main' into phace-hartmut
frostedoyster Jan 26, 2026
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
3 changes: 2 additions & 1 deletion .github/workflows/architecture-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ jobs:
- mace
- nanopet
- pet
- soap-bpnn
- phace
- soap-bpnn

runs-on: ubuntu-22.04

Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
**/pet @abmazitov
**/gap @DavideTisi
**/nanopet @frostedoyster
**/phace @frostedoyster
**/llpr @frostedoyster @SanggyuChong
**/flashmd @johannes-spies @frostedoyster
**/classifier @frostedoyster
Expand Down
7 changes: 6 additions & 1 deletion examples/1-advanced/03-fitting-generic-targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- Energy, forces, stress/virial
- Yes
- Yes
- No
- Only rank-1 (vectors)
* - GAP
- Energy, forces
- No
Expand All @@ -46,6 +46,11 @@
- Yes
- Yes
- Only with ``rank=1`` (vectors)
* - PhACE
- Energy, forces, stress/virial
- Yes
- Yes
- Only rank-1 (vectors)

Preparing generic targets for reading by metatrain
--------------------------------------------------
Expand Down
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ gap = [
"skmatter",
"scipy",
]
phace = [
"physical_basis",
"wigners",
"opt-einsum",
]
llpr = []
classifier = []
mace = [
Expand Down Expand Up @@ -171,8 +176,10 @@ filterwarnings = [
"ignore:No libgomp shared library found in 'sphericart_torch.libs'.",
# Multi-threaded tests clash with multi-process data-loading
"ignore:This process \\(pid=\\d+\\) is multi-threaded, use of fork\\(\\) may lead to deadlocks in the child.:DeprecationWarning",
# Initialization of tensors of zero size
"ignore:Initializing zero-element tensors is a no-op:UserWarning",
# MACE warning with newer versions of pytorch (because they use e3nn==0.4.4)
"ignore:Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed:UserWarning"
"ignore:Environment variable TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD detected, since the`weights_only` argument was not explicitly passed:UserWarning",
]
addopts = ["-p", "mtt_plugin"]
pythonpath = "src/metatrain/utils/testing"
Expand Down
2 changes: 1 addition & 1 deletion src/metatrain/deprecated/nanopet/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def train(

# Move the model to the device and dtype:
model.to(device=device, dtype=dtype)
# The additive models of the SOAP-BPNN are always in float64 (to avoid
# The additive models of NanoPET are always in float64 (to avoid
# numerical errors in the composition weights, which can be very large).
for additive_model in model.additive_models:
additive_model.to(dtype=torch.float64)
Expand Down
14 changes: 14 additions & 0 deletions src/metatrain/experimental/phace/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from .model import PhACE
from .trainer import Trainer


__model__ = PhACE
__trainer__ = Trainer

__authors__ = [
("Filippo Bigi <filippo.bigi@epfl.ch>", "@frostedoyster"),
]

__maintainers__ = [
("Filippo Bigi <filippo.bigi@epfl.ch>", "@frostedoyster"),
]
Empty file.
280 changes: 280 additions & 0 deletions src/metatrain/experimental/phace/documentation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
"""
PhACE
=====

PhACE is a physics-inspired equivariant neural network architecture. Compared to, for
example, MACE and GRACE, it uses a geometrically motivated basis and a fast and
elegant tensor product implementation. The tensor product used in PhACE leverages a
equivariant representation that differs from the typical spherical one. You can read
more about it here: https://pubs.acs.org/doi/10.1021/acs.jpclett.4c02376.

{{SECTION_INSTALLATION}}

{{SECTION_DEFAULT_HYPERS}}

Tuning hyperparameters
----------------------

The default hyperparameters above will work well in most cases, but they
may not be optimal for your specific use case. There is good number of
parameters to tune, both for the
:ref:`model <architecture-{{architecture}}_model_hypers>` and the
:ref:`trainer <architecture-{{architecture}}_trainer_hypers>`. Here, we provide a
**list of the parameters that are in general the most important** (in decreasing order
of importance) for the PhACE architecture:

.. container:: mtt-hypers-remove-classname

.. autoattribute:: {{model_hypers_path}}.radial_basis
:no-index:

.. autoattribute:: {{model_hypers_path}}.num_element_channels
:no-index:

.. autoattribute:: {{trainer_hypers_path}}.num_epochs
:no-index:

.. autoattribute:: {{trainer_hypers_path}}.batch_size
:no-index:

.. autoattribute:: {{model_hypers_path}}.num_message_passing_layers
:no-index:

.. autoattribute:: {{trainer_hypers_path}}.learning_rate
:no-index:

.. autoattribute:: {{model_hypers_path}}.cutoff
:no-index:

.. autoattribute:: {{model_hypers_path}}.force_rectangular
:no-index:

.. autoattribute:: {{model_hypers_path}}.spherical_linear_layers
:no-index:
"""

from typing import Literal, Optional

from typing_extensions import TypedDict

from metatrain.utils.additive import FixedCompositionWeights
from metatrain.utils.hypers import init_with_defaults
from metatrain.utils.loss import LossSpecification
from metatrain.utils.scaler import FixedScalerWeights


class RadialBasisHypers(TypedDict):
"""Hyperparameter concerning the radial basis functions used in the model."""

max_eigenvalue: float = 25.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this needs tuning with respect to the max L of the target, some useful heuristics on how to set this would be useful. For instance, with all other parameters as default, I found I had to set it to max_eigenvalue: 200.0 to reach L=8.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC the laplacian eigenvalues paper uses nmax as the only parameter, and then finds lmax as a consequence. That is far more user-friendly then asking a mysterious eigenvalue. IDK if this applies also with the physical weighting, but it should

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on this one @frostedoyster ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a good idea because there are many exact truncations that you can't get (or are ambiguous) if you move to n_max or l_max. I would rather add more documentation to the eigenvalue

"""Maximum eigenvalue for the radial basis."""

scale: float = 0.7
"""Scaling factor for the radial basis."""

optimizable_lengthscales: bool = False
"""Whether the length scales in the radial basis are optimizable."""


###########################
# MODEL HYPERPARAMETERS #
###########################


class ModelHypers(TypedDict):
"""Hyperparameters for the experimental.phace model."""

max_correlation_order_per_layer: int = 3
"""Maximum correlation order per layer."""

num_message_passing_layers: int = 2
"""Number of message passing layers.

Increasing this value might increase the accuracy of the model (especially on
larger datasets), at the expense of computational efficiency.
"""

cutoff: float = 5.0
"""Cutoff radius for neighbor search.

This should be set to a value after which most of the interactions
between atoms is expected to be negligible. A lower cutoff will lead
to faster models.
"""

cutoff_width: float = 1.0
"""Width of the cutoff smoothing function."""

num_element_channels: int = 128
"""Number of channels per element.

This determines the size of the embedding used to encode the atomic species, and it
increases or decreases the size of the internal features used in the model.
"""

force_rectangular: bool = False
"""Makes the number of channels per irrep the same.

This might improve accuracy with a limited increase in computational cost.
"""

spherical_linear_layers: bool = False
"""Whether to perform linear layers in the spherical representation."""

radial_basis: RadialBasisHypers = init_with_defaults(RadialBasisHypers)
"""Hyperparameters for the radial basis functions.

Raising``max_eigenvalue`` from its default will increase the number of spherical
irreducible representations (irreps) used in the model, which can improve accuracy
at the cost of computational efficiency. Increasing this value will also increase
the number of radial basis functions (and therefore internal features) used for each
irrep.
"""

nu_scaling: float = 0.1
"""Scaling for the nu term."""

mp_scaling: float = 0.1
"""Scaling for message passing."""

overall_scaling: float = 1.0
"""Overall scaling factor."""

disable_nu_0: bool = True
"""Whether to disable nu=0."""

use_sphericart: bool = False
"""Whether to use spherical Cartesian coordinates."""

head_num_layers: int = 1
"""Number of layers in the head."""

heads: dict[str, Literal["linear", "mlp"]] = {}
"""Heads to use in the model, with options being "linear" or "mlp"."""

zbl: bool = False
"""Whether to use the ZBL potential in the model."""


##############################
# TRAINER HYPERPARAMETERS #
##############################


class TrainerHypers(TypedDict):
"""Hyperparameters for training the experimental.phace model."""

compile: bool = True
"""Whether to use `torch.compile` during training.

This can lead to significant speedups, but it will cause a compilation step at the
beginning of training which might take up to 5-10 minutes, mainly depending on
``max_eigenvalue``.
"""

distributed: bool = False
"""Whether to use distributed training."""

distributed_port: int = 39591
"""Port for DDP communication."""

batch_size: int = 8
"""Batch size for training.

Decrease this value if you run into out-of-memory errors during training. You can
try to increase it if your structures are very small (less than 20 atoms) and you
have a good GPU.
"""

num_epochs: int = 1000
"""Number of epochs to train the model.

A larger number of epochs might lead to better accuracy. In general, if you see
that the validation metrics are not much worse than the training ones at the end of
training, it might be a good idea to increase this value.
"""

learning_rate: float = 0.01
"""Learning rate for the optimizer.

You can try to increase this value (e.g., to 0.02 or 0.03) if training is very
slow or decrease it (e.g., to 0.005 or less) if you see that training explodes in
the first few epochs.
"""

warmup_fraction: float = 0.01
"""Fraction of training steps for learning rate warmup."""

gradient_clipping: Optional[float] = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed - shall we set a default here?

Suggested change
gradient_clipping: Optional[float] = None
gradient_clipping: Optional[float] = 1.0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think so. I'm running some more experiments to understand what a good default could be

"""Gradient clipping value. If None, no clipping is applied."""

log_interval: int = 1
"""Interval to log metrics during training."""

checkpoint_interval: int = 25
"""Interval to save model checkpoints."""

scale_targets: bool = True
"""Whether to scale targets during training."""

atomic_baseline: FixedCompositionWeights = {}
"""The baselines for each target.

By default, ``metatrain`` will fit a linear model (:class:`CompositionModel
<metatrain.utils.additive.composition.CompositionModel>`) to compute the
least squares baseline for each atomic species for each target.

However, this hyperparameter allows you to provide your own baselines.
The value of the hyperparameter should be a dictionary where the keys are the
target names, and the values are either (1) a single baseline to be used for
all atomic types, or (2) a dictionary mapping atomic types to their baselines.
For example:

- ``atomic_baseline: {"energy": {1: -0.5, 6: -10.0}}`` will fix the energy
baseline for hydrogen (Z=1) to -0.5 and for carbon (Z=6) to -10.0, while
fitting the baselines for the energy of all other atomic types, as well
as fitting the baselines for all other targets.
- ``atomic_baseline: {"energy": -5.0}`` will fix the energy baseline for
all atomic types to -5.0.
- ``atomic_baseline: {"mtt:dos": 0.0}`` sets the baseline for the "mtt:dos"
target to 0.0, effectively disabling the atomic baseline for that target.

This atomic baseline is substracted from the targets during training, which
avoids the main model needing to learn atomic contributions, and likely makes
training easier. When the model is used in evaluation mode, the atomic baseline
is added on top of the model predictions automatically.

.. note::
This atomic baseline is a per-atom contribution. Therefore, if the property
you are predicting is a sum over all atoms (e.g., total energy), the
contribution of the atomic baseline to the total property will be the
atomic baseline multiplied by the number of atoms of that type in the
structure.

.. note::
If a MACE model is loaded through the ``mace_model`` hyperparameter, the
atomic baselines in the MACE model are used by default for the target
indicated in ``mace_head_target``. If you want to override them, you need
to set explicitly the baselines for that target in this hyperparameter.
"""

fixed_scaling_weights: FixedScalerWeights = {}
"""Fixed scaling weights for the model."""

num_workers: Optional[int] = None
"""Number of workers for data loading."""

per_structure_targets: list[str] = []
"""List of targets to calculate per-structure losses."""

log_separate_blocks: bool = False
"""Whether to log per-block error during training."""

log_mae: bool = False
"""Whether to log MAE alongside RMSE during training."""

best_model_metric: Literal["rmse_prod", "mae_prod", "loss"] = "rmse_prod"
"""Metric used to select the best model checkpoint."""

loss: str | dict[str, LossSpecification] = "mse"
"""Loss function used for training."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we copy the trainer hypers that are common to PET from the PET trainer, so that they have more extensive documentation?

This would also rename fixed_composition_weights to atomic_baseline, so the trainer and the checkpoint will require changes.

Loading
Loading