xnn.common.models.hub.checkpoint#
Reading, writing and building models from checkpoints.
Three kinds of file hold a model’s weights, and load_checkpoint() reads
all of them into the same Checkpoint:
a portable model directory (
card.json,config.yaml,model.pt), written bysave_pretrained(). The config is plain YAML and the weights load withtorch.load(weights_only=True), so the directory carries no pickled Python objects and no absolute paths: copy it anywhere and it loads there;an xnn trainer checkpoint (
best.pt:{"model": state_dict, "cfg": Config}, written bysave()), or a bare state dict;a file in a foreign format registered in
formats(e.g. amace-torchfoundation model), converted on the fly.
build_potential() turns a checkpoint into a ready model. It is the one
loading recipe behind from_pretrained(), the MDI
engine, xnn export and the benchmark runner.
Functions
|
Rebuild a model from its config and weights. |
|
Serialize a |
|
The innermost potential under the force, dispersion, LES and multi-head wrappers. |
|
Config values of the model section that name existing files. |
|
Floating-point dtype of a module's parameters or of a state dict. |
|
Whether a model already includes a D3 / D4 wrapper (at any nesting). |
|
Read any supported checkpoint into a |
|
Read a config written by |
|
Write a model as a portable directory. |
|
State dict in the trainer's |
|
Write a config as YAML, atomically (see |
Classes
|
A model's weights and the config that rebuilds it. |