xnn.common.models.hub.loader.from_pretrained#
- xnn.common.models.hub.loader.from_pretrained(source, *, wrap=True, **kwargs)[source]#
Load a pre-trained model in one call.
MACE foundation models, xnn-trained models, Zenodo uploads and local checkpoints all load the same way:
from xnn.common.models import from_pretrained model = from_pretrained("mace-off23-small") # registry name model = from_pretrained("mace-mh-0", head="omat_pbe") # one head model = from_pretrained("doi:10.5281/zenodo.18957344", filename="mace_csfapbbri_al_5_1_stagetwo.model") model = from_pretrained("runs/exp/best.pt") # trainer checkpoint model = from_pretrained("mace-off23-small", cache_dir="/scratch/models")
The first call downloads (and verifies) the file into
cache_dirand, for a foreign format such asmace-torch, converts it once; later calls load the cached portable directory without network access and without the upstream package.- Parameters:
source (str or pathlib.Path) – Registry name, local directory or checkpoint, URL, or Zenodo DOI; see
fetch_model().wrap (bool, optional) – Return the
ForceStressOutputwrapper (forces, and stress withcompute_stress=True).Falsereturns the bare potential inside it. Defaults toTrue.**kwargs –
cache_dir,filename,head,format,force_download,local_files_only,quiet,device,dtype,dispersion,compute_forces,compute_stress,eeq_reuse,use_fast,model_options; seeload_pretrained().
- Returns:
The model in eval mode.
- Return type: