"""Wrapper for NequIP-Allegro models in TorchSim.This module re-exports the NequIP framework's torch-sim integration for convenientimporting. The actual implementation is maintained in the NequIP package.References: - NequIP Package: https://github.com/mir-group/nequip"""importtracebackimportwarningsfromtypingimportAny,Selftry:fromnequip.integrations.torchsimimportNequIPTorchSimCalc# Re-export with backward-compatible nameclassNequIPFrameworkModel(NequIPTorchSimCalc):"""NequIP model framework wrapper for torch-sim. NOTE: NequIPFrameworkModel.dtype is always set to torch.float64. The AOTInductor may actually contain a different dtype but the model will cast to the correct dtype internally. """exceptImportErrorasexc:_nequip_import_error=exc# capture before except block ends (exc is deleted)warnings.warn(f"NequIP import failed: {traceback.format_exc()}",stacklevel=2)fromtorch_sim.models.interfaceimportModelInterface
[docs]classNequIPFrameworkModel(ModelInterface):"""NequIP model framework wrapper for torch-sim. NOTE:This class is a placeholder when NequIP is not installed. It raises an ImportError if accessed. """def__init__(self,err:ImportError=_nequip_import_error,*_args:Any,**_kwargs:Any)->None:"""Dummy init for type checking."""raiseerr
[docs]@classmethoddeffrom_compiled_model(cls,_path:Any,*_args:Any,**_kwargs:Any)->Self:"""Dummy classmethod for type checking when NequIP is not installed."""raise_nequip_import_error