Skip to content
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

Energy seems not correct when using pretrained model on only-OC20 dataset and some models don't work #929

Open
Ramblekiss opened this issue Nov 28, 2024 · 2 comments

Comments

@Ramblekiss
Copy link

Ramblekiss commented Nov 28, 2024

What would you like to report?

Hi,OCP teams:

I found some thing during using the pre-trained models.

Two different sample in tutorial page (https://fair-chem.github.io/core/quickstart.html
image
and https://fair-chem.github.io/tutorials/OCP-introduction.html)
image
image

using the same slab model, but differs a lot of energy. It seems that it's because the latter model is based on trainning of only OC20?

When I tested the EquiformerV2-153M-S2EF-OC20-All+MD model in my own slab file, the result did not seem to make any physical sense at all. This seems to be due to some numerical setting? I hope to know how to fix them.

Additionally, the GemNet model didn't work properly when it was introduced into OCPCalculator.
Could you please tell me how can I fix this?

@rayg1234
Copy link
Collaborator

rayg1234 commented Dec 6, 2024

Hello, thanks for reaching out!

the models trained on OC20 are outputting adsorption energies (see https://fair-chem.github.io/tutorials/OCP-introduction.html#simple-simulations-using-the-ocp-ase-calculator) , and models trained on OC22 are on total energies, this would explain the large differences you are seeing.

Additionally, the GemNet model didn't work properly when it was introduced into OCPCalculator.
Could you please tell me how can I fix this?

can you elaborate on this?

@Ramblekiss
Copy link
Author

Ramblekiss commented Dec 10, 2024

Thanks for your reply!

The problem I mentioned with the model not working correctly occurred when I used the GemNet model to try to calculate the energy of a slab loaded from a file (POSCAR or cif), and the command line output error message was here:

WARNING:root:Detected old config, converting to new format. Consider updating to avoid potential incompatibilities.
WARNING:root:Unrecognized arguments: ['symmetric_edge_symmetrization']
WARNING:root:Using weight_decay from optim instead of optim.optimizer_params.Please update your config to use optim.optimizer_params.weight_decay.optim.weight_decay will soon be deprecated.
Traceback (most recent call last):
File "path/jupyter_file/scripts/new_model_test.py", line 107, in
opt.run(steps=300,fmax = 0.05)
File "path/anaconda3/envs/fair-chem/lib/python3.11/site-packages/ase/optimize/optimize.py", line 269, in run
return Dynamics.run(self)
^^^^^^^^^^^^^^^^^^
File "path/anaconda3/envs/fair-chem/lib/python3.11/site-packages/ase/optimize/optimize.py", line 156, in run
for converged in Dynamics.irun(self):
File "path/anaconda3/envs/fair-chem/lib/python3.11/site-packages/ase/optimize/optimize.py", line 122, in irun
self.atoms.get_forces()
File "path/anaconda3/envs/fair-chem/lib/python3.11/site-packages/ase/atoms.py", line 788, in get_forces
forces = self._calc.get_forces(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "path/anaconda3/envs/fair-chem/lib/python3.11/site-packages/ase/calculators/abc.py", line 23, in get_forces
return self.get_property('forces', atoms)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "path/anaconda3/envs/fair-chem/lib/python3.11/site-packages/ase/calculators/calculator.py", line 737, in get_property
self.calculate(atoms, [name], system_changes)
File "path/anaconda3/envs/fair-chem/lib/python3.11/site-packages/fairchem/core/common/relaxation/ase_utils.py", line 243, in calculate
predictions = self.trainer.predict(batch, per_image=False, disable_tqdm=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "path/anaconda3/envs/fair-chem/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "path/anaconda3/envs/fair-chem/lib/python3.11/site-packages/fairchem/core/trainers/ocp_trainer.py", line 434, in predict
out = self._forward(batch)
^^^^^^^^^^^^^^^^^^^^
File "path/anaconda3/envs/fair-chem/lib/python3.11/site-packages/fairchem/core/trainers/ocp_trainer.py", line 235, in _forward
out = self.model(batch.to(self.device))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "path/anaconda3/envs/fair-chem/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "path/anaconda3/envs/fair-chem/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "path/anaconda3/envs/fair-chem/lib/python3.11/site-packages/fairchem/core/common/utils.py", line 156, in cls_method
return f(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "path/anaconda3/envs/fair-chem/lib/python3.11/site-packages/fairchem/core/models/gemnet_oc/gemnet_oc.py", line 1229, in forward
) = self.get_bases(
^^^^^^^^^^^^^^^
File "path/anaconda3/envs/fair-chem/lib/python3.11/site-packages/fairchem/core/models/gemnet_oc/gemnet_oc.py", line 1102, in get_bases
basis_rad_sph_qint_raw, basis_sph_qint_raw = self.sbf_basis_qint(
^^^^^^^^^^^^^^^^^^^^
File "path/anaconda3/envs/fair-chem/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "path/anaconda3/envs/fair-chem/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "path/anaconda3/envs/fair-chem/lib/python3.11/site-packages/fairchem/core/models/gemnet_oc/layers/spherical_basis.py", line 132, in forward
sph_basis = self.spherical_basis(cosφ_cab, θ_cabd)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "path/anaconda3/envs/fair-chem/lib/python3.11/site-packages/fairchem/core/models/gemnet_oc/layers/spherical_basis.py", line 116, in
).reshape(cosφ.shape[0], -1)
^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: cannot reshape tensor of 0 elements into shape [0, -1] because the unspecified dimension size -1 can be any value and is ambiguous

What's more confusing is that the code given in the tutorial works, and the only change I made was to load the slab from a file instead of a direct fcc111 method (even though the file was also saved directly after being created by the fcc111 method), and the above error occurred.
In addition, I have some doubts about the influence of the different training goals you mentioned:

  1. For any model trained on OC20, is calculating the difference between adsorbed and unadsorbed energies the only way to make the results physically meaningful?

  2. For some OC20-OC22 hybrid training models, due to the difference in bulk material types of OC20 and OC22 datasets, is there any physical meaning for the predicted absolute energy of the alloy material corresponding to OC20?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants