executing-plans
executing-plans
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available
inference-model-opsLoad DeePMD-kit models, run Python or CLI inference, extract descriptors and embeddings, compute model deviation, and operate on frozen/checkpoint/pretrained model artifacts.
Independent GitHub snapshot · Automated classification · Original documentation governs
Use this sub-skill when the user already has a DeePMD-kit model artifact or built-in pretrained model selector and needs to evaluate, inspect, compare, convert, compress, or bias-adjust it.
DeepPot, DeepPotential, dp test, dp eval-desc, dp embed, dp model-devi, dp show, dp compress, dp convert-from, dp convert-backend, dp pretrained, and dp change-bias.../training-models/SKILL.md when available.../integrations-development/SKILL.md when available.type.raw/set.* layout fixes, and data conversion to ../data-config/SKILL.md when available..pb; use default backend or dp --tf .....pth; use dp --pt .....pt; usable for some commands such as dp embed, dp show, and dp change-bias; freeze before standard frozen-model inference workflows when needed..pdiparams; use dp --pd ... for supported operations.DPA-3.2-5M; pass directly to DeepPot or download with dp pretrained download.--tf, --pt, --jax, --pd, --pt-expt) when suffixes are ambiguous, generated by another tool, or being converted.dp show MODEL type-map descriptor fitting-net size observed-type before inference when atom type order, branch selection, or descriptor support is uncertain.--head or --model-branch to CLI commands that support it, and pass the corresponding head= keyword to Python evaluator construction when available.Use deepmd.infer.DeepPot for energy models:
from deepmd.infer import DeepPot
import numpy as np
pot = DeepPot("model.pth", auto_batch_size=True)
coord = np.asarray(coords, dtype=float).reshape(nframes, natoms * 3)
cell = np.asarray(cells, dtype=float).reshape(nframes, 9) # or None for non-PBC
atype = np.asarray(type_indices, dtype=np.int32) # (natoms,) unless mixed_type=True
energy, force, virial = pot.eval(coord, cell, atype)
Important shape rules are in references/python-api.md. If the user only needs a safe scaffold for shapes, run:
python sub-skills/inference-model-ops/scripts/deeppot_input_shapes.py --natoms 3 --nframes 2
Use cell=None for non-periodic inference; do not pass zero cells as a substitute unless the model/data workflow explicitly expects PBC with zero vectors.
| Task | API | Main outputs | Notes |
|---|---|---|---|
| Energy/force/virial | DeepPot.eval(...) | energy (nframes, 1), force (nframes, natoms, 3), virial (nframes, 9) | Add atomic=True for atomic energy and atomic virial. |
| Descriptors | DeepPot.eval_descriptor(...) | descriptor (nframes, natoms, ndesc) | dtype="native" by default; accepts fp32, fp64, native. |
| Embeddings | DeepPot.eval_embedding(...) | descriptor, atomic feature, structural feature | PyTorch-focused; dtype="fp32" by default. |
| Model deviation | calc_model_devi(...) | deviation table (nframes, 8+) | Load models once, then reuse model objects. |
| Metadata | get_type_map(), get_rcut(), get_dim_fparam(), get_dim_aparam() | scalars/lists | Inspect before shaping optional parameters. |
| Task | Command | Primary output |
|---|---|---|
| Test labeled data | dp test -m MODEL -s SYSTEM -n NUM | RMSE summary; optional detail files. |
| Save descriptors | dp eval-desc -m MODEL -s SYSTEM -o desc --dtype native | desc/<system>.npy arrays. |
| Save embeddings | dp embed -m MODEL -s SYSTEM -o embedding.hdf5 --dtype fp32 | HDF5 datasets: descriptor, atomic_feature, structural_feature. |
| Compare models | dp model-devi -m M0 M1 M2 M3 -s SYSTEM -o model_devi.out | Deviation text table. |
| Inspect model | dp show MODEL type-map descriptor fitting-net size | Logged model metadata. |
| Download pretrained | dp pretrained download MODEL --cache-dir CACHE | Local model path. |
| Compress frozen model | dp compress -i MODEL -o MODEL_COMPRESSED | Compressed frozen model. |
| Convert old TF model | dp convert-from auto -i old.pb -o new.pb | Compatibility-updated graph. |
| Convert backend | dp convert-backend INPUT OUTPUT | Model in backend inferred from OUTPUT. |
| Change output bias | dp change-bias INPUT -s SYSTEM -o OUTPUT | Bias-adjusted model/checkpoint. |
Full command recipes and pitfalls are in references/cli-model-ops.md.
When comparing an ensemble in Python, instantiate each model once outside loops:
from deepmd.infer import DeepPot, calc_model_devi
models = [DeepPot(path, auto_batch_size=True) for path in model_paths]
deviation = calc_model_devi(
coord,
cell,
atype,
models,
atomic=True,
relative=0.05,
relative_v=0.05,
)
Do not create DeepPot(path) repeatedly inside frame, trajectory, or active-learning loops; TensorFlow and PyTorch runtimes may not release all memory, which can lead to OOM.
Before running inference, verify:
atype indices follow the model type_map, not alphabetical element order unless that is the model order.coord is reshapeable to (nframes, natoms, 3) or flattened (nframes, natoms * 3).cell is None for non-PBC or reshapeable to (nframes, 9) / (nframes, 3, 3) for PBC.fparam and aparam are present only when the model reports nonzero parameter dimensions.dp convert-from before use if the installed version rejects them.references/troubleshooting.md#wrong-backend-or-model-suffixreferences/troubleshooting.md#repeated-model-loading-memory-growthreferences/troubleshooting.md#atom-type-order-mismatchreferences/troubleshooting.md#bad-coordinate-cell-or-atype-shapesreferences/troubleshooting.md#non-periodic-cell-handlingreferences/troubleshooting.md#descriptor-embedding-and-dtype-confusionreferences/troubleshooting.md#unsupported-old-frozen-modelreferences/troubleshooting.md#pretrained-network-or-cache-constraintsauto_batch_size=True for Python inference unless the user has a reason to set an integer initial batch size.--dtype native for descriptor reproducibility; use fp32 for compact embedding files unless the user needs higher precision.--relative and --relative_v only with an explicit level parameter, not as booleans.--atomic in dp test or dp model-devi only when per-atom output is needed, because it increases output size.