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

Using fairchem pre-trained models on custom datasets. #947

Open
nevinngyt opened this issue Dec 18, 2024 · 2 comments
Open

Using fairchem pre-trained models on custom datasets. #947

nevinngyt opened this issue Dec 18, 2024 · 2 comments
Assignees

Comments

@nevinngyt
Copy link

nevinngyt commented Dec 18, 2024

What would you like to report?

Hello, I'm trying to use the fairchem pre-trained models and evaluate their performances on my custom datasets (xyz files). The headers in my xyz file look like:
Lattice="5.494219689819475 0.0 0.0 2.7471098449097373 4.758133825356323 0.0 0.0 0.0 27.21502897900848" Properties=species:S:1:pos:R:3:forces:R:3 energy=-136.82442956 pbc="T T T"

I converted my xyz files into atoms objects and geometric graph objects with ASE for use of fairchem pre-trained models. However, I ran into some errors and would need help navigating the documentation to solve the issues. Here's the code I used and the errors I encountered:

from fairchem.core.models.model_registry import model_name_to_local_file

checkpoint_path = model_name_to_local_file('EquiformerV2-31M-S2EF-OC20-All+MD', local_cache='/tmp/fairchem_checkpoints/')

Error:
WARNING:root:No seed has been set in modelcheckpoint or OCPCalculator! Results may not be reproducible on re-run

Attempt to calculate eenrgies and forces with atoms object:
calc.calculate(atoms, properties=['energy', 'forces'], system_changes=False)

Result
None

Could anyone advise on what I did wrong here and how I could best use fairchems models for my own xyz dataset? Would greatly appreciate it!! Thanks!

@lbluque
Copy link
Collaborator

lbluque commented Dec 20, 2024

Hello @nevinngyt 👋

If you are trying to run predictions using the ASE calculator interface the recommended way to do so is something like this:

from ase.io import read
from fairchem.core import OCPCalculator

atoms = read("path_to_your_structure.xyz")

# set cpu=False to use GPU, set the seed if you want exactly reproducible results and avoid the Warning.
calc = OCPCalculator(model_name="EquiformerV2-31M-S2EF-OC20-All+MD", cpu=True, seed=0) 

atoms.calc = calc

# calculate 
energy = atoms.get_potential_energy()
forces = atoms.get_forces()

@lbluque lbluque self-assigned this Dec 20, 2024
@nevinngyt
Copy link
Author

@lbluque Ahh thank you so much!! What about if I hope to play around with freezing some layers of the models and the parameters and re-training the models on my custom datasets?

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