deepmodeling / deepmodeling/deepmd-kit

Generic LinearAtomicModel: combine all output-def-matched variables of submodels, not just energy

Open
#5,901 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
2k
Forks
649
Avg merge
6d 18h
Merged PRs (30d)
15

Description

Follow-up from the ZBL-bridging composition work on the DPA4 graph branch (PR #5884): `bridging_method: ZBL` now builds `LinearEnergyModel(LinearEnergyAtomicModel([learned, InterPotentialAtomicModel], weights="sum"))`, and `LinearEnergyAtomicModel` gained a NeighborGraph-route forward (weighted sum of the children's graph forwards on one shared graph, so the summed energy differentiates through a single shared edge backward).

The composition is currently **energy-only**. The generic design worth building:

**A generic `LinearAtomicModel` that linearly combines ALL matched output variables, not just energy:**

- At construction, check the output signatures (`FittingOutputDef`) of all submodels for consistency: variables with the same name must agree on shape/reducibility/differentiability flags.
- The combined `fitting_output_def` is the union (or intersection — to be decided) of the children's defs; the forward (dense and graph) linearly combines every matched output variable with the configured weights, not only `energy`.
- This would make compositions of dipole/polar/property models (and mixed analytical terms for those quantities) first-class, instead of requiring a new `LinearAtomicModel` per output type.

Related current limitations to lift along the way:
- The graph route of `LinearEnergyAtomicModel` supports constant weights only (`"sum"`/`"mean"`/float list); the distance-switched ZBL-interpolation weights remain dense-only.
- Children must share the parent `type_map` on the graph route (no atype remapping).
- Wire types: the energy composition serializes as `"linear_ener"` (with `"linear"` kept as a legacy atomic-registry alias); a generic linear model needs a coherent wire-type story for other output types (e.g. `"linear_dipole"`, ...).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.