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

Generalize forcefields for generic ASE calculator support #940

Merged
merged 112 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
f05bce8
add ase base calculator classes from forcefield library
esoteric-ephemera Aug 2, 2024
5e538e3
add tests for ase calculators, refactor forcefields slightly
esoteric-ephemera Aug 2, 2024
d861b94
precommit
esoteric-ephemera Aug 2, 2024
786ce93
precommit
esoteric-ephemera Aug 2, 2024
4cd538f
add tests
esoteric-ephemera Aug 2, 2024
e25f61e
precommit
esoteric-ephemera Aug 2, 2024
e2eb2c1
fix forcefield post_init
esoteric-ephemera Aug 2, 2024
756c3fe
precmt
esoteric-ephemera Aug 2, 2024
e32636c
forcefield_objects -> objects rename
esoteric-ephemera Aug 2, 2024
5acc792
pin torchdata version to fix issues with matgl
esoteric-ephemera Aug 5, 2024
924e910
restore forcefield specific schema objects for backwards compatibilit…
esoteric-ephemera Aug 5, 2024
e83deaf
precommit
esoteric-ephemera Aug 5, 2024
b0f7c7c
mypy precommit for ancient python
esoteric-ephemera Aug 5, 2024
77a5833
add static makers
esoteric-ephemera Aug 7, 2024
e6f83a9
precommit
esoteric-ephemera Aug 7, 2024
e951a05
add tblite dependence to ase in toml
esoteric-ephemera Aug 7, 2024
1c1142d
fix merge conflicts
esoteric-ephemera Aug 7, 2024
b1952c9
migrate forcefield MD base class to ase
esoteric-ephemera Aug 7, 2024
4b1915b
add barebones tests for ase md jobs
esoteric-ephemera Aug 7, 2024
b0c9a77
ensure tests clean after completion
esoteric-ephemera Aug 7, 2024
9b13e45
precommit
esoteric-ephemera Aug 7, 2024
c57d9ff
Merge branch 'main' into ase
esoteric-ephemera Aug 7, 2024
89eb1c7
try to figure out why tblite is not working in ci, but is locally
esoteric-ephemera Aug 8, 2024
8d9a7ee
generalize to allow molecules in ase calcs
esoteric-ephemera Aug 9, 2024
d5b3a87
precommit
esoteric-ephemera Aug 9, 2024
ea6f1ea
fix molecule schemas / tests
esoteric-ephemera Aug 10, 2024
625d971
precommit
esoteric-ephemera Aug 10, 2024
9b341d2
Merge branch 'main' into ase
esoteric-ephemera Aug 12, 2024
38449da
make tblite dependence optional
esoteric-ephemera Aug 12, 2024
610ac72
precommit
esoteric-ephemera Aug 12, 2024
6adae2f
try to quarantine forcefield tests
esoteric-ephemera Aug 14, 2024
a90170f
ensure tblite installed for tests
esoteric-ephemera Aug 14, 2024
834ce73
pyrrhic quest to separate torch and non-torch tests, pt. 2 / ???
esoteric-ephemera Aug 14, 2024
af0f978
pyrrhic quest to separate torch and non-torch tests, pt. 3 / ???
esoteric-ephemera Aug 14, 2024
be6829e
remove cov file
esoteric-ephemera Aug 14, 2024
82d7dca
remove torch dependence from non-forcefield tests?
esoteric-ephemera Aug 14, 2024
526b5ad
move misplaced forcefield phonon test to forcefield tests
esoteric-ephemera Aug 14, 2024
d07ca25
move forcefield strict version pins to separate toml block
esoteric-ephemera Aug 14, 2024
b243b73
name refactor / enumification / lazy load md dynamics modules
esoteric-ephemera Aug 19, 2024
3efff87
precommit
esoteric-ephemera Aug 19, 2024
c5f7fe8
Merge branch 'main' into ase
esoteric-ephemera Aug 19, 2024
4a12353
make Ase{Structure,Molecule}TaskDoc construction a single function
esoteric-ephemera Aug 19, 2024
7cf617a
Merge branch 'main' into ase
esoteric-ephemera Aug 20, 2024
73c4269
precommit
esoteric-ephemera Aug 20, 2024
82ab00e
change ASE and forcefield result from dict to BaseModel
esoteric-ephemera Aug 20, 2024
e4f1803
pcmt
esoteric-ephemera Aug 20, 2024
86fe898
ensure ASE and forcefield result docs are subscriptable
esoteric-ephemera Aug 20, 2024
b652a3c
allow dict-style item assignment in AseResult
esoteric-ephemera Aug 20, 2024
e7edeea
Add "ionic_steps" to DATA_OBJECTS
orionarcher Aug 20, 2024
df4eca8
Add 'elapsed_time' and 'tags' to ASE schemas
orionarcher Aug 20, 2024
348678e
Adding timing to ASE runs.
orionarcher Aug 20, 2024
0d181e1
Pass elapsed time through doc
orionarcher Aug 21, 2024
c6d6ffc
Small lint
orionarcher Aug 21, 2024
eb51282
Pass tags through to task document. Add test.
orionarcher Aug 21, 2024
321a975
Merge pull request #4 from orionarcher/ase_fixes
esoteric-ephemera Aug 21, 2024
0d5c46a
Add dict to ionic_steps typing
orionarcher Aug 22, 2024
93dd9cc
define basic ase job schema; remove task_doc_kwargs from ase in favor…
esoteric-ephemera Aug 22, 2024
9585dc9
Change | to Union in type hints
orionarcher Aug 22, 2024
8d85829
pcmt
esoteric-ephemera Aug 22, 2024
bcd23f4
Merge branch 'ase' into ase_fixes_2
esoteric-ephemera Aug 22, 2024
73caa68
Merge pull request #5 from orionarcher/ase_fixes_2
esoteric-ephemera Aug 23, 2024
dcaeb85
revise ionic_step storage / only for md
esoteric-ephemera Aug 23, 2024
ff44149
Merge branch 'main' into ase
esoteric-ephemera Aug 27, 2024
902823d
Return NotImplemented -> Raise NotImplementedError
orionarcher Aug 28, 2024
e0bf592
Partially prevent ase_calculator from failing silently.
orionarcher Aug 28, 2024
0aa8a08
Rollback ability to accept raw forcefield stubs
orionarcher Sep 3, 2024
7b25b10
Merge branch 'main' into ase
esoteric-ephemera Sep 3, 2024
8f305e9
skip default forcefield mlff in phonon setup test
esoteric-ephemera Sep 3, 2024
808de7d
Merge pull request #6 from orionarcher/ase_fixes_3
esoteric-ephemera Sep 3, 2024
ec3a3c5
Merge branch 'main' into ase
esoteric-ephemera Sep 9, 2024
4508b9f
add option to pass forcefield name as str without MLFF. prefix or as …
esoteric-ephemera Sep 9, 2024
0b4987e
precommit
esoteric-ephemera Sep 9, 2024
da01791
correct typing of atoms in AseRelaxer
esoteric-ephemera Sep 9, 2024
063c1c9
add tblite to optional ase-ext and strict requirements; remove CI fai…
esoteric-ephemera Sep 9, 2024
ffacf71
add tblite to optional ase-ext and strict requirements; remove CI fai…
esoteric-ephemera Sep 9, 2024
763bcc6
Merge branch 'main' into ase
esoteric-ephemera Sep 9, 2024
aada903
ensure forcefield tests don't use deprecated makers, test for futurew…
esoteric-ephemera Sep 10, 2024
be168e4
precommit
esoteric-ephemera Sep 10, 2024
027defd
remove dependence on deprecated ff makers; make default calc kwargs a…
esoteric-ephemera Sep 10, 2024
7aa7675
precommit
esoteric-ephemera Sep 10, 2024
ed544be
remove frechet cell filter safety checks (this is included by the min…
esoteric-ephemera Sep 11, 2024
c1db9e6
made MD ensembles and enum
esoteric-ephemera Sep 11, 2024
bb0d2e8
pcmt
esoteric-ephemera Sep 11, 2024
9b077b1
move ase tests to separate test run, use pytest-split on rest of test…
esoteric-ephemera Sep 12, 2024
1e21c6b
forgot pytest-split dep in pyproject
esoteric-ephemera Sep 12, 2024
362db23
add test durations for split
esoteric-ephemera Sep 12, 2024
a638f42
reorg test wf
esoteric-ephemera Sep 12, 2024
f110574
reorg test wf
esoteric-ephemera Sep 12, 2024
4ba239b
update test split, run notebook test as separate test, update test time
esoteric-ephemera Sep 12, 2024
4c581bc
file cleanup
esoteric-ephemera Sep 12, 2024
3e68d3d
move jupyter notebook test into ase
esoteric-ephemera Sep 12, 2024
00aaf8d
move jupyter notebook test into ase
esoteric-ephemera Sep 12, 2024
4c3c13c
tweak some clean_dir to tmp_dir to prevent unncessary test file creation
esoteric-ephemera Sep 13, 2024
00ea296
reduce to 4 splits
esoteric-ephemera Sep 13, 2024
4b0d680
go back to 3 splits
esoteric-ephemera Sep 13, 2024
cde15a0
Merge branch 'main' into ase
esoteric-ephemera Sep 16, 2024
daf460f
try to get better ci timing estimate per @janosh's suggestion
esoteric-ephemera Sep 16, 2024
a40accb
try to get better ci timing estimate per @janosh's suggestion
esoteric-ephemera Sep 16, 2024
e576828
Merge branch 'main' into ase
esoteric-ephemera Sep 16, 2024
1c41666
fix test split cmd
esoteric-ephemera Sep 16, 2024
7e5abd6
revert pytest split change for separate pr
esoteric-ephemera Sep 16, 2024
1b64286
revert pytest split change for separate pr
esoteric-ephemera Sep 16, 2024
5fe8c1f
tweak wf
esoteric-ephemera Sep 16, 2024
3ea5f3e
change gruneisen test for time use - just make phonon maker cheaper
esoteric-ephemera Sep 17, 2024
44bc54c
add ase to phonon supported codes, enforce string literal in BasePhon…
esoteric-ephemera Sep 20, 2024
0b74403
Merge branch 'main' into ase
esoteric-ephemera Sep 23, 2024
b72c91c
Merge branch 'main' into ase
esoteric-ephemera Sep 24, 2024
4d1eeae
try to fix ci test wf
esoteric-ephemera Sep 24, 2024
9ca6d18
try to fix ci test wf
esoteric-ephemera Sep 24, 2024
481a9c9
ci test wf
esoteric-ephemera Sep 24, 2024
f29d17b
fix typo deformationed->deformed
janosh Sep 25, 2024
f120cfc
fix potential pydantic validation error if Ase(MD|Relax)Maker.calcula…
janosh Sep 25, 2024
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
47 changes: 45 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:

runs-on: ubuntu-latest
strategy:
fail-fast: true
Copy link
Member

Choose a reason for hiding this comment

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

IIUC fail-fast: true will reduce the amount of signal you get from a CI run. e.g. if a job running on 3.9-3.12 fails on 3.9 first, you won't know if it also would have failed on 3.10, 3.11, etc. is this intended?

Copy link
Contributor Author

@esoteric-ephemera esoteric-ephemera Sep 9, 2024

Choose a reason for hiding this comment

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

I mostly added this for my ease of figuring out why tests were failing initially - reverted

Copy link
Member

Choose a reason for hiding this comment

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

matrix:
python-version: ["3.9", "3.10", "3.11"]

Expand Down Expand Up @@ -62,8 +63,8 @@ jobs:
mkdir -p ~/.abinit/pseudos
cp -r tests/test_data/abinit/pseudos/ONCVPSP-PBE-SR-PDv0.4 ~/.abinit/pseudos
pip install .[strict,tests,abinit]
pip install torch-runstats
pip install --no-deps nequip==0.5.6
pip install tblite==0.3.0
Copy link
Member

Choose a reason for hiding this comment

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

should tblite be added to pyproject

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'll put this in an ase-ext requirements. The base ASE stuff does not require tblite in any way


- name: Install pymatgen from master if triggered by pymatgen repo dispatch
if: github.event_name == 'repository_dispatch' && github.event.action == 'pymatgen-ci-trigger'
Expand All @@ -75,7 +76,49 @@ jobs:
- name: Test
env:
MP_API_KEY: ${{ secrets.MP_API_KEY }}
run: pytest --cov=atomate2 --cov-report=xml
run: pytest --ignore=tests/forcefields --cov=atomate2 --cov-report=xml

- uses: codecov/codecov-action@v1
if: matrix.python-version == '3.10' && github.repository == 'materialsproject/atomate2'
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml

test-forcefields:
Copy link
Member

Choose a reason for hiding this comment

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

i'd recommend merging all tests back into a single job (which we can then split with pytest-split)

Copy link
Contributor Author

@esoteric-ephemera esoteric-ephemera Sep 11, 2024

Choose a reason for hiding this comment

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

It seems like anything torch-dependent and tblite can't be installed in the same environment without the tblite tests failing in CI. If I use pytest-split, I'd still need to separately run the forcefield tests to have separate environments, no?

Outside of CI, having torch installed but not loaded seems OK with tblite. I can also just split off the tblite / ase-ext tests and then use pytest-split on the rest

Let me know what you think is best

Copy link
Member

Choose a reason for hiding this comment

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

It seems like anything torch-dependent and tblite can't be installed in the same environment without the tblite tests failing in CI.

oh, i forgot about that. in that case, could you verbatim copy your above comment into the test.yml to leave a paper trail on why the tests are split into 2 jobs? i do think it would be better to run the tblite in its own job and move the force fields into the main job. will put some pressure on me to actually implement the pytest-split to warrant the effort. 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK! Split off the ase and jupyter notebook tests into separate test instances. Also set up the pytest-split logic (3 splits per version seems OK), might need some help in getting that optimized

Copy link
Member

Choose a reason for hiding this comment

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

pymatgen uses 10 splits. i think atomate2 could use more than 3, maybe 5 is the sweet spot? how did you generate the durations file? ideally, all splits should take about the same amount of time. currently, 1 is ~35 min, 2 is 15-20 min and 3 is 5 - 10 min so i think there's something off. for comparison, pymatgen uses

pytest --store-durations --durations-path tests/files/.pytest-split-durations

to update the file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied all the pytest split logic from pymatgen 😂 same command for the split durations test, the CI tests just take a very different amount of time in CI vs. my machine. Guessing there's MPS hardware acceleration turned on by default in the forcefields

I'll play around with this a bit - maybe setting the default device to be CPU would help for getting a better CI timing estimate

Copy link
Member

@janosh janosh Sep 13, 2024

Choose a reason for hiding this comment

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

the other option would be to temp change the CI run to

pytest --store-durations --durations-path=DURATIONS_PATH
cat DURATIONS_PATH

and then copy paste the actual test durations in CI from the log into your local durations file

services:
local_mongodb:
image: mongo:4.0
ports:
- 27017:27017

runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[strict,strict-forcefields,tests]
pip install torch-runstats
pip install --no-deps nequip==0.5.6

- name: Install pymatgen from master if triggered by pymatgen repo dispatch
if: github.event_name == 'repository_dispatch' && github.event.action == 'pymatgen-ci-trigger'
run: pip install --upgrade 'git+https://github.com/materialsproject/pymatgen@${{ github.event.client_payload.pymatgen_ref }}'

- name: Test
env:
MP_API_KEY: ${{ secrets.MP_API_KEY }}
run: pytest --cov=atomate2 --cov-report=xml tests/forcefields
Copy link
Member

Choose a reason for hiding this comment

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

should we merge the force field tests into the main test run? ideally, we'll use pytest-split later to split workload into multiple runners equally to speed up CI

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The way it's partitioned now is because tblite is incompatible with torch. The safest approach, to me, seemed like completely quarantining the torch-dependent modules (just forcefields) from everything else. Open to suggestions


- uses: codecov/codecov-action@v1
if: matrix.python-version == '3.10' && github.repository == 'materialsproject/atomate2'
Expand Down
19 changes: 13 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@ forcefields = [
"calorine<=2.2.1",
"chgnet>=0.2.2",
"mace-torch>=0.3.3",
"torchdata<=0.7.1", # TODO: remove when issue fixed
"matgl>=1.1.3",
"quippy-ase>=0.9.14",
"sevenn>=0.9.3",
]
ase = [
"ase>=3.23.0",
]
docs = [
"FireWorks==2.0.3",
"autodoc_pydantic==2.1.0",
Expand All @@ -81,18 +85,14 @@ tests = [
strict = [
"PyYAML==6.0.2",
"ase==3.23.0",
"calorine==2.2.1",
"cclib==1.8.1",
"chgnet==0.3.8",
"click==8.1.7",
"custodian==2024.6.24",
"dscribe==2.1.1",
"emmet-core==0.82.2",
"ijson==3.3.0",
"jobflow==0.1.18",
"lobsterpy==0.4.5",
"mace-torch>=0.3.3",
"matgl==1.1.3",
"monty==2024.7.30",
"mp-api==0.41.2",
"numpy",
Expand All @@ -102,11 +102,18 @@ strict = [
"pymatgen-analysis-defects==2024.7.19",
"pymatgen==2024.6.10",
"python-ulid==2.7.0",
"quippy-ase==0.9.14",
"seekpath==2.1.0",
"typing-extensions==4.12.2",
]
strict-forcefields = [
"calorine==2.2.1",
"chgnet==0.3.8",
"mace-torch>=0.3.3",
"torchdata==0.7.1", # TODO: remove when issue fixed
"matgl==1.1.3",
"quippy-ase==0.9.14",
"sevenn==0.9.3",
"torch==2.2.1",
"typing-extensions==4.12.2",
]

[project.scripts]
Expand Down
1 change: 1 addition & 0 deletions src/atomate2/ase/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Module for Atomic Simulation Environment workflows."""
Loading
Loading