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

ASE Calculator interface #215

Merged
merged 27 commits into from
May 15, 2024
Merged

Conversation

laserkelvin
Copy link
Collaborator

@laserkelvin laserkelvin commented May 15, 2024

This PR adds a Calculator implementation that specializes to matsciml's pipeline/abstractions.

Currently it is only implemented for energy and force prediction, but given that ase also supports other properties like stress, multipole moments, etc. there is some flexibility in using ScalarRegressionTask for things like that.

  • Add matsciml.interfaces.ase.MatSciMLCalculator class that adapts Atoms representations to structures expected by matsciml models
  • Add two minimum working examples for using the new interface: one loading from an inexistent pretrained checkpoint, and another showing training on LiPS and using ase after a quick training run on the devset
  • Adds a Github action to run pytests in the interfaces submodule
  • Removes obsolete OCP relaxation and ase routines

@laserkelvin laserkelvin added enhancement New feature or request inference Issues related to model inference and testing labels May 15, 2024
Copy link
Collaborator

@melo-gonzo melo-gonzo left a comment

Choose a reason for hiding this comment

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

Looks good so far. Left a few comments.

One more general comment is that it took me a while to figure out that using a checkpoint which was created from a task like this:

model = EGNN(encoder_kwargs=...)
task = ForceRegressionTask(
    model,
    output_kwargs=...
)

will not load properly, however a checkpoint created from a task like this:

task = ForceRegressionTask(
    encoder_class=EGNN,
    encoder_kwargs=...,
    output_kwargs=...
)

will load. This is due to how the 'hyper parameters' are stored in the model checkpoint.

It could be worth depreciating the first method of task creation in matsciml, or making note of this somewhere.

def from_pretrained_force_regression(
cls, ckpt_path: str | Path, *args, **kwargs
) -> MatSciMLCalculator:
if isinstance(ckpt_path, str):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you consolidate this between the class methods?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You mean the path conversion?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This bit should be consolidated to one function:

        if isinstance(ckpt_path, str):
            ckpt_path = Path(ckpt_path)
        if not ckpt_path.exists():
            raise FileNotFoundError(f"Checkpoint file not found; passed {ckpt_path}")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in 439b7b4

matsciml/interfaces/ase/base.py Show resolved Hide resolved
matsciml/interfaces/ase/base.py Show resolved Hide resolved
matsciml/models/base.py Show resolved Hide resolved
@laserkelvin laserkelvin merged commit f494d60 into IntelLabs:main May 15, 2024
3 of 4 checks passed
@laserkelvin laserkelvin deleted the ase-calculator branch May 15, 2024 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request inference Issues related to model inference and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants