You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs+tests(bias): pin set/change-by-statistic semantics for bridged models (#5966)
Close#5927 — resolved **as designed**, with documentation and semantic
pin tests instead of a behavior change.
## The definitions (verified against the code)
The model energy decomposes as `E = E_model + E_bias`, where `E_model`
is everything the model computes (learned network, analytical ZBL term,
or a `linear_ener` combination) and `E_bias` is the per-type output
bias.
- **`set-by-statistic`** assigns `E_bias` directly: user values, or the
per-type least-squares statistic of the **raw labels**. It never calls a
model forward (`compute_output_stats` with `model_forward=None`, stored
with `add=False`) — it is independent of `E_model` **by definition**,
ignoring a trained network and the analytical ZBL term alike.
- **`change-by-statistic`** fits the residual of the labels against the
**complete model prediction** (the bridged predictor since #5910) and
adds the delta to the existing bias.
Under these definitions the "double count" described in the issue is not
a bridging bug: `set` uniformly ignores all of `E_model` for every model
kind. A bridged model after `set` carries no compensation for the mean
ZBL contribution — exactly as a trained plain model after `set` carries
no compensation for its network output. The two modes "disagree" because
they are defined to answer different questions; a self-consistent
calibration is `change`'s job.
Verified conformance of the `linear_ener` composition path in both
backends: children compute no output statistics
(`compute_or_load_out_stat=False`); the composition level performs one
`set` fit on the raw labels. Also verified: the ZBL term contributes
exactly zero for isolated atoms, so its own statistics are trivially
`bias = 0`.
## Changes
- `doc/model/change-bias.md`: precise definitions of the two modes, and
the guidance that calibrating a bridged (or any nonzero-`E_model`) model
self-consistently requires `change-by-statistic`.
- `doc/model/dpa4.md`: note in the ZBL section.
- Semantic pin tests (pt `SeZMModel` + dpmodel `LinearEnergyAtomicModel`
composition): `set-by-statistic` equals the raw-label least-squares fit
exactly — guarding against a future "fix" that would subtract the
analytical term and silently create a third, model-dependent mode.
## Known limitations
- No behavior change anywhere; the pin tests cover
`model.change_out_bias` (the `dp change-bias --mode set` and finetune
routes) and the dpmodel composition out-stat; the pt training-init chain
was verified in-session and funnels into the same pinned branch.
- The spin variants share the machinery but have no dedicated pin.
- Fact worth knowing when reading the docs: `InnerPotential` adds the
full ZBL over the whole cutoff (not only below `bridging_r_outer`), so
the label-side ZBL at equilibrium geometries is small but not strictly
zero; the docs state the offset plainly.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Documentation**
* Clarified how `set` and `change` statistic modes handle model energy,
analytical contributions, labels, residuals, and existing bias.
* Documented the interaction between output-bias calibration and ZBL
bridging, including guidance for self-consistent calibration.
* **Tests**
* Added regression coverage confirming that `set-by-statistic`
calibration uses raw energy labels independently of learned and ZBL
model contributions.
* Verified calibration correctly replaces seeded bias and remains
consistent when repeated.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Han Wang <wang_han@iapcm.ac.cn>
0 commit comments