Skip to content

Conversation

@AdeeshKolluru
Copy link
Contributor

@AdeeshKolluru AdeeshKolluru commented Apr 14, 2025

Summary

Adds test to compare ASE vs TorchSim for FIRE optimization.

Currently the trajectories don't match.

Checklist

Work-in-progress pull requests are encouraged, but please enable the draft status on your PR.

Before a pull request can be merged, the following items must be checked:

  • Doc strings have been added in the Google docstring format.
    Run ruff on your code.
  • Tests have been added for any new functionality or bug fixes.
  • All linting and tests pass.

Note that the CI system will run all the above checks. But it will be much more
efficient if you already fix most errors prior to submitting the PR. It is highly
recommended that you use the pre-commit hook provided in the repository. Simply run
pre-commit install and a check will be run prior to allowing commits.

@cla-bot cla-bot bot added the cla-signed Contributor license agreement signed label Apr 14, 2025
Copy link
Collaborator

@orionarcher orionarcher left a comment

Choose a reason for hiding this comment

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

Great check to have but I'd suggest making it a script in examples/scripts/7_Others. Otherwise it will require a not very generalizable change to the testing action to get it passing.

You can add the dependencies at the top to get the tests passing, like this:

# /// script
# dependencies = [
#     "mace-torch>=0.3.11",
# ]
# ///

@abhijeetgangan
Copy link
Collaborator

Agree with @orionarcher that it should be a script for now. Currently the tests have a lot of repeated code and could be made cleaner along with integration tests with ASE.

@orionarcher orionarcher force-pushed the main branch 2 times, most recently from 02be493 to 80a4802 Compare April 14, 2025 19:15
@CompRhys CompRhys force-pushed the optimizer_ase_test branch from c2e2942 to e17db82 Compare May 2, 2025 09:12
CompRhys and others added 3 commits May 2, 2025 10:33
…in orig FIRE paper) and improve coverage in `test_optimizers.py` (#174)

* feat(fire-optimizer-changes) Update fire_step in optimizers.py based feature/neb-workflow

* reset optimizers.py to main version prior to adding updated changes

* (feat:fire-optimizer-changes) - Added ase_fire_step and renamed fire_step to vv_fire_step. Allowed for selection of md_flavor

* (feat:fire-optimizer-changes) - lint check on optimizers.py with ruff

* (feat:fire-optimizer-changes) - added test cases and example script in examples/scripts/7_Others/7.6_Compare_ASE_to_VV_FIRE.py

* (feat:fire-optimizer-changes) - updated FireState, UnitCellFireState, and FrechetCellFireState to have md_flavor to select vv or ase. ASE currently coverges in 1/3 as long. test cases for all three FIRE schemes added to test_optimizers.py with both md_flavors

* ruff auto format

* minor refactor of 7.6_Compare_ASE_to_VV_FIRE.py

* refactor optimizers.py: define MdFlavor type alias for SSoT on MD flavors

* new optimizer tests: FIRE and UnitCellFIRE initialization with dictionary states, md_flavor validation, non-positive volume warnings

brings optimizers.py test coverage up to 96%

* cleanup test_optimizers.py: parameterize tests for FIRE and UnitCellFIRE initialization and batch consistency checks

maintains same 96% coverage

* refactor optimizers.py: consolidate vv_fire_step logic into a single _vv_fire_step function modified by functools.partial for different unit cell optimizations (unit/frechet/bare fire=no cell relax)

- more concise and maintainable code

* same as prev commit but for _ase_fire_step

instead of _vv_fire_step

* (feat:fire-optimizer-changes) - added references to ASE implementation of FIRE and a link to the original FIRE paper.

* (feat:fire-optimizer-changes) switched md_flavor type from str to MdFlavor and set default to ase_fire_step

* pytest.mark.xfail frechet_cell_fire with ase_fire flavor, reason: shows asymmetry in batched mode, batch 0 stalls

* rename maxstep to max_step for consistent snake_case

fix RuntimeError: a leaf Variable that requires grad is being used in an in-place operation:

7. Position / cell update
state.positions += dr_atom

* unskip frechet_cell_fire in test_optimizer_batch_consistency, can no longer repro error locally

* code cleanup

* bumpy set-up action to v6, more descriptive CI test names

* pin to fairchem_core-1.10.0 in CI

* explain differences between vv_fire and ase_fire and link references in fire|unit_cell_fire|frechet_cell_fire doc strings

---------

Co-authored-by: Janosh Riebesell <[email protected]>
… ASE vs torch-sim test for Frechet Cell FIRE optimizer into test_optimizers.py

- move `ase_mace_mpa` and `torchsim_mace_mpa` fixtures into `conftest.py` for wider reuse
@janosh janosh added tests Test all the things geo-opt Geometry optimization and removed fix Bug fix labels May 14, 2025
@janosh janosh force-pushed the optimizer_ase_test branch from ad950b0 to 03bdb80 Compare May 14, 2025 18:57
@janosh janosh changed the title Test to compare ASE vs TorchSim for FIRE optimization Directly compare ASE vs TorchSim Frechet cell FIRE relaxation May 14, 2025
@janosh janosh merged commit 8211e08 into main May 14, 2025
95 checks passed
@janosh janosh deleted the optimizer_ase_test branch May 14, 2025 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed Contributor license agreement signed geo-opt Geometry optimization tests Test all the things

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants