Skip to content

Metatomic interface seems not torch scriptable #91

@PicoCentauri

Description

@PicoCentauri

When trying to export a simple test function

from metatomic.torch import AtomisticModel, System
import vesin.metatomic

@torch.jit.script
def foo(systems: list[System], model: AtomisticModel) -> None:
    vesin.metatomic.compute_requested_neighbors(
        systems=systems, system_length_unit="nm", model=model
        )

I get an error for an unsupported annotation

AssertionError: Unsupported annotation typing.Union[metatomic.torch.model.AtomisticModel, metatomic.torch.model.ModelInterface] could not be resolved because None could not be resolved. At
  File "/Users/philiploche/projects/water-benchmark/.venv/lib/python3.13/site-packages/vesin/metatomic/_model.py", line 17
    systems: Union[List[System], System],
    system_length_unit: str,
    model: Union[AtomisticModel, ModelInterface],
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
    model_length_unit: Optional[str] = None,
    check_consistency: bool = False,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions