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

Feat: Add DeepMD MLFF support #999

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

MoseyQAQ
Copy link

Summary

I have integrated atomate2 with the DeepMD MLFF, enabling efficient high-throughput calculations using this powerful tool.

Checklist

  • Tests have been added for any new functionality or bug fixes.

@JaGeo
Copy link
Member

JaGeo commented Sep 29, 2024

@MoseyQAQ Thanks for your contribution.

As you might have seen, we want to deprecate the concrete implementations of the force fields in the future and just provide a general interface. I am not sure if it makes sense to add this new implementation just now and directly deprecate it in a few months.

@utf @janosh Opinions?

@MoseyQAQ
Copy link
Author

@JaGeo Hi, thanks for your comment! I opted for concrete implementations because the atomate2 workflow for calculating phonons tutorial uses concrete implementations. I aim to maintain consistency with the established practices in these resources to ensure a seamless user experience.

@JaGeo
Copy link
Member

JaGeo commented Sep 30, 2024

@utf Opinions?

@MoseyQAQ Yes, sure, it does. However, we decided to change this in the future. You can even see this from the code that you implemented.

@utf
Copy link
Member

utf commented Sep 30, 2024

Thanks for this @MoseyQAQ. I agree with @JaGeo, there doesn't seem much point adding something already with a deprecation notice. I would remove the concrete implementations but leave the rest of your code. DeepMD is great to have in atomate2.

In the future, we should think about convenience functions to create entire flows with a specific forcefield. E.g., something like:

from atomate2.forcefields.flows import ElasticMaker

maker = ElasticMaker.from_forcefield("DeepMD")

@MoseyQAQ
Copy link
Author

@utf Thank you!

@MoseyQAQ
Copy link
Author

MoseyQAQ commented Oct 3, 2024

@utf @JaGeo , Hi! I’m currently working on removing the old implementations as suggested and addressing the issue preventing the code from passing the unit tests (which might be related to the dependency version). I’ll update as I make progress.

@@ -143,8 +142,10 @@ def test_ml_ff_md_maker(
for step in task_doc.objects["trajectory"].frame_properties
)

with pytest.warns(FutureWarning):
name_to_maker[ff_name]()
# Skip the following test for DeepMD, since it doesn't have concrete implementations
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to implement this? Or do you see any hurdles?

Copy link
Author

Choose a reason for hiding this comment

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

This part of the code checks whether the concrete Maker classes raise a FutureWarning, indicating they will be deprecated. As per our earlier discussions, I’ve removed the concrete implementations for DeepMD, so this class no longer exists. Therefore, I’ve addressed this by skipping the test for DeepMD.

@MoseyQAQ
Copy link
Author

MoseyQAQ commented Oct 5, 2024

@utf @JaGeo Hi! This PR is ready for review and could be merged.

Copy link
Member

@janosh janosh left a comment

Choose a reason for hiding this comment

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

thanks @MoseyQAQ! two minor comments, otherwise this looks great! 👍

Copy link
Member

Choose a reason for hiding this comment

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

5MB is big for a test file. can we swap this out for a smaller checkpoint? or maybe auto-download the checkpoint on the fly like some of the other models?

Copy link
Author

Choose a reason for hiding this comment

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

I have removed the original file and set it to download from GitHub when the test starts automatically.

# run the flow or job and ensure that it finished running successfully
responses = run_locally(job, ensure_success=True)

# validation the outputs of the job
Copy link
Member

Choose a reason for hiding this comment

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

typo

Copy link
Author

Choose a reason for hiding this comment

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

fixed

@janosh janosh added forcefields Forcefield related md Molecular dynamics labels Oct 5, 2024
# Download DeepMD pretrained model from GitHub
file_url = "https://raw.github.com/sliutheorygroup/UniPero/main/model/graph.pb"
local_path = test_dir / "forcefields" / "deepmd" / "graph.pb"
response = requests.get(file_url, timeout=10)
Copy link
Member

Choose a reason for hiding this comment

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

atomate2 doesn't currently depend on requests so not sure it's installed. if it is, only as transitive dep. maybe better to use std lib urllib.request.urlretrieve

@MoseyQAQ
Copy link
Author

MoseyQAQ commented Oct 5, 2024

@janosh Hi, I found that the test can't pass because MACE is unable to download the foundation model from tinyurl.com. In the latest release of MACE, the original tinyurl.com link has been replaced with GitHub. The previous tinyurl.com URL returns a 403 error, which prevents the model from being downloaded properly.

@janosh
Copy link
Member

janosh commented Oct 5, 2024

thanks for letting me know. could you replace tinyurl.com with one of the checkpoints from here? maybe 2023-12-10-mace-128-L0_epoch-199.model

Copy link

codecov bot commented Oct 5, 2024

Codecov Report

Attention: Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.

Project coverage is 4.36%. Comparing base (ec1b598) to head (b012a93).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/atomate2/forcefields/utils.py 0.00% 5 Missing ⚠️
src/atomate2/forcefields/__init__.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #999       +/-   ##
==========================================
- Coverage   76.09%   4.36%   -71.74%     
==========================================
  Files         174     175        +1     
  Lines       12690   12742       +52     
  Branches     1892    1899        +7     
==========================================
- Hits         9657     556     -9101     
- Misses       2494   12152     +9658     
+ Partials      539      34      -505     
Files with missing lines Coverage Δ
src/atomate2/forcefields/jobs.py 0.00% <ø> (-96.38%) ⬇️
src/atomate2/forcefields/schemas.py 0.00% <ø> (-97.23%) ⬇️
src/atomate2/forcefields/__init__.py 0.00% <0.00%> (-100.00%) ⬇️
src/atomate2/forcefields/utils.py 0.00% <0.00%> (-90.00%) ⬇️

... and 153 files with indirect coverage changes

@esoteric-ephemera
Copy link
Contributor

@utf : I added that kind of convenience function for the forcefield EOS flows but didn't for more complex ones - happy to do that in a separate PR

@utf
Copy link
Member

utf commented Oct 15, 2024

Thanks @esoteric-ephemera and @MoseyQAQ. Is this ready for final review?

@MoseyQAQ
Copy link
Author

@utf Yes. @esoteric-ephemera Thank you!

Copy link
Member

@janosh janosh left a comment

Choose a reason for hiding this comment

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

this looks great. thanks @MoseyQAQ! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
forcefields Forcefield related md Molecular dynamics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants