xnn.common.models.registry.prepare_model#
- xnn.common.models.registry.prepare_model(cfg)[source]#
Build a model and the config that rebuilds it.
The same as
build_model(), also returning the resolvedModelConfig: with a"pretrained"source the architecture keys are taken from the checkpoint and recorded in place of the source, so the returned config rebuilds the model from its weights alone (what the trainer writes into its checkpoints).extra["pretrained"]names any sourcefrom_pretrained()accepts (registry name, local checkpoint or model directory, URL, Zenodo DOI);extra["head"]picks the head of a multi-head source;extra["dtype"]casts the weights.cfg.cutoffmust equal the checkpoint’s (the data pipeline follows it), and the only other keys allowed beside the source areheads,lora,atomic_energies(new reference energies, applied after the weights are loaded) and, when the checkpoint has none,dispersion/long_range. A reference-energy marker (atomic_energies: estimated/average) needs data and is resolved by theTrainer; here it is an error.- Parameters:
cfg (ModelConfig) – The model configuration.
- Returns:
The model and the resolved config.
- Return type:
- Raises:
KeyError – If the model name is not registered.
ValueError – For an inconsistent
pretrainedconfig, or a reference-energy marker.