Skip to content

Upstream metatomic TorchSim model#167

Draft
CompRhys wants to merge 1 commit intometatensor:mainfrom
CompRhys:main
Draft

Upstream metatomic TorchSim model#167
CompRhys wants to merge 1 commit intometatensor:mainfrom
CompRhys:main

Conversation

@CompRhys
Copy link

Move the torchsim model upstream.

import pytest
import torch
from metatomic.torch import ase_calculator
from metatrain.utils.io import load_model
Copy link
Author

Choose a reason for hiding this comment

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

this is the only bit that I am sus on how to correctly load a model here.

Copy link
Author

Choose a reason for hiding this comment

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

        # Load the model
        if isinstance(model, (str, bytes, pathlib.PurePath)):
            if not os.path.exists(model):
                raise InputError(f"given model path '{model}' does not exist")

            # only store the model in self.parameters if is it the path to a file
            self.parameters["model"] = str(model)

            model = load_atomistic_model(
                model, extensions_directory=extensions_directory
            )

        elif isinstance(model, torch.jit.RecursiveScriptModule):
            if model.original_name != "AtomisticModel":
                raise InputError(
                    "torch model must be 'AtomisticModel', "
                    f"got '{model.original_name}' instead"
                )
        elif isinstance(model, AtomisticModel):
            # nothing to do
            pass
        else:
            raise TypeError(f"unknown type for model: {type(model)}")

This is how models are loaded on the ase side

@Luthaf
Copy link
Member

Luthaf commented Feb 26, 2026

Thanks @CompRhys! We had a chat about this 1h ago, and plan to create a separate metatomic-torchsim (and metatomic-ase, …) python package that would live in this repository but have a separate version number and release schedule. This might take us a couple of weeks to do, how urgent is getting this code out of torchsim for you?

@HaoZeke in the mean time can you help bringing this PR in a state where it supports all the same features as the other engine integrations?

@HaoZeke
Copy link
Member

HaoZeke commented Feb 26, 2026

Thanks @CompRhys! We had a chat about this 1h ago, and plan to create a separate metatomic-torchsim (and metatomic-ase, …) python package that would live in this repository but have a separate version number and release schedule. This might take us a couple of weeks to do, how urgent is getting this code out of torchsim for you?

In the same vein, @CompRhys, would you be OK with me making changes to this PR? I'd like to setup the python package first.

@HaoZeke in the mean time can you help bringing this PR in a state where it supports all the same features as the other engine integrations?

Yup, in the package 😁

@CompRhys
Copy link
Author

Not urgent. We just cut a 0.5.2 release and so will be a while till we cut 0.5.3. Hopefully this could land in that release. The big switch also relies on there being new releases with the upstreamed interfaces for orb-models and sevenn.

Please feel free to take this over or delete!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants