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 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
16 changes: 16 additions & 0 deletions tests/forcefields/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

from typing import TYPE_CHECKING

import pytest
import requests
import torch

if TYPE_CHECKING:
from pathlib import Path
from typing import Any


Expand All @@ -13,3 +16,16 @@ def pytest_runtest_setup(item: Any) -> None:
torch.set_default_dtype(torch.float32)
# For consistent performance across hardware, explicitly set device to CPU
torch.set_default_device("cpu")


@pytest.fixture(scope="session", autouse=True)
def download_deepmd_pretrained_model(test_dir: Path) -> None:
# 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

if response.status_code == 200:
with open(local_path, "wb") as file:
file.write(response.content)
else:
raise requests.RequestException(f"Failed to download: {file_url}")
4 changes: 2 additions & 2 deletions tests/forcefields/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def test_deepmd_static_maker(sr_ti_o3_structure: Structure, test_dir: Path):
# 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
# validate the outputs of the job
output1 = responses[job.uuid][1].output
assert isinstance(output1, ForceFieldTaskDocument)
assert output1.output.energy == approx(-3723.09868, rel=1e-4)
Expand Down Expand Up @@ -584,7 +584,7 @@ def test_deepmd_relax_maker(
# 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
# validate the outputs of the job
output1 = responses[job.uuid][1].output
assert isinstance(output1, ForceFieldTaskDocument)
if relax_cell:
Expand Down
Binary file removed tests/test_data/forcefields/deepmd/graph.pb
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.

Binary file not shown.
Loading