Commit 314d03a
feat(pt_expt): add dipole, polar, dos, property and dp-zbl models with cross-backend consistency tests (#5260)
## Summary
- Add 5 new pt_expt model types: DipoleModel, PolarModel, DOSModel,
PropertyModel, and DPZBLModel, completing pt_expt's model coverage to
parity with pt
- Refactor dpmodel base architecture so that pt_expt models inherit
directly from dpmodel via `make_model()`, removing the intermediate
pt_expt atomic model layer
- Consolidate scattered model-level methods (`get_out_bias`,
`set_out_bias`, `get_observed_type_list`, `compute_or_load_stat`) into
shared dpmodel base classes
- Move `compute_fitting_input_stat` for `set-by-statistic` mode from
model-level `change_out_bias` to training-level `model_change_out_bias`
(pt and pd backends), keeping the `change_out_bias` logic focused on
bias only (copied from #5266)
- Fix array-api-compat violations in `general_fitting.change_type_map`
(bare `np.zeros`/`np.ones`/`np.concatenate` → `xp` equivalents with
device)
- Fix dpmodel `change_type_map` not forwarding
`model_with_new_type_stat` through the call chain
- Add comprehensive cross-backend consistency tests for all model types
(dp vs pt vs pt_expt), covering: model output, serialization round-trip,
`change_out_bias`, `change_type_map`, `compute_or_load_stat`, model API
methods.
## Changes
### New pt_expt models
- `deepmd/pt_expt/model/dipole_model.py`
- `deepmd/pt_expt/model/polar_model.py`
- `deepmd/pt_expt/model/dos_model.py`
- `deepmd/pt_expt/model/property_model.py`
- `deepmd/pt_expt/model/dp_zbl_model.py`
### Architecture refactoring
- Remove `deepmd/pt_expt/atomic_model/` layer — models now wrap dpmodel
atomic models directly
- Clean up `BaseModel`: remove concrete methods/data, add plugin
registry
- Refactor `make_model` so backends (dp, pt_expt) inherit shared model
logic from dpmodel
- Consolidate `get_out_bias`/`set_out_bias` into `base_atomic_model.py`
- Add `get_observed_type_list` to abstract API and implement in dpmodel,
pt, pd
- Move fitting input stat update to `model_change_out_bias` in pt/pd
training code (#5266)
### Bug fixes
- `general_fitting.change_type_map`: use array-api-compat ops instead of
bare numpy (breaks pt_expt)
- `make_model.change_type_map`: properly forward
`model_with_new_type_stat` to atomic model
- `stat.py`: fix in-place mutation issue
### Tests
- New cross-backend consistency tests: `test_dipole.py`,
`test_polar.py`, `test_dos.py`, `test_property.py` and
`test_zbl_ener.py` (~1400 lines each)
- Expanded `test_ener.py` with pt_expt and full model API coverage
- New pt_expt unit tests: `test_dipole_model.py`, `test_polar_model.py`,
`test_dos_model.py`, `test_property_model.py`, `test_dp_zbl_model.py`
- Added `test_get_model_def_script`, `test_get_min_nbor_dist`,
`test_set_case_embd` across all 6 model test files
- Moved atomic model output stat tests from pt_expt to dpmodel
- Added `model_change_out_bias` tests in pt/pd training tests (#5266)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* File-backed compute/load for descriptor and fitting statistics; new
compute-or-load stat APIs, get/set output-bias, and observed-type
discovery.
* Exportable/traceable lower-level inference paths for dipole, dos,
polar, property, zbl, and energy models.
* **Refactor**
* Model factory and generated models support extensible base-class
composition and unified fitting backend wiring.
* **Tests**
* Large expansion of cross-backend (DP/PT/PT-EXPT) parity, statistics,
bias, and exportability tests.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Han Wang <wang_han@iapcm.ac.cn>1 parent f0a966b commit 314d03a
64 files changed
Lines changed: 10586 additions & 1800 deletions
File tree
- deepmd
- dpmodel
- atomic_model
- descriptor
- fitting
- model
- jax/model
- pd/model/model
- pt_expt
- atomic_model
- model
- pt/model
- atomic_model
- model
- source/tests
- common/dpmodel
- consistent/model
- pt_expt
- atomic_model
- model
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| 56 | + | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
| 64 | + | |
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
| |||
77 | 80 | | |
78 | 81 | | |
79 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
80 | 91 | | |
81 | 92 | | |
82 | 93 | | |
| |||
287 | 298 | | |
288 | 299 | | |
289 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
290 | 352 | | |
291 | 353 | | |
292 | 354 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
2 | 5 | | |
3 | 6 | | |
4 | 7 | | |
| |||
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
18 | 24 | | |
19 | 25 | | |
20 | 26 | | |
| |||
62 | 68 | | |
63 | 69 | | |
64 | 70 | | |
65 | | - | |
66 | 71 | | |
67 | | - | |
68 | | - | |
69 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
73 | 78 | | |
74 | 79 | | |
75 | | - | |
| 80 | + | |
76 | 81 | | |
77 | 82 | | |
78 | 83 | | |
| |||
87 | 92 | | |
88 | 93 | | |
89 | 94 | | |
90 | | - | |
| 95 | + | |
91 | 96 | | |
92 | 97 | | |
93 | 98 | | |
| |||
180 | 185 | | |
181 | 186 | | |
182 | 187 | | |
183 | | - | |
| 188 | + | |
184 | 189 | | |
185 | 190 | | |
186 | 191 | | |
| |||
191 | 196 | | |
192 | 197 | | |
193 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
194 | 230 | | |
195 | 231 | | |
196 | 232 | | |
| |||
207 | 243 | | |
208 | 244 | | |
209 | 245 | | |
210 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
211 | 271 | | |
212 | 272 | | |
213 | 273 | | |
| |||
218 | 278 | | |
219 | 279 | | |
220 | 280 | | |
221 | | - | |
| 281 | + | |
222 | 282 | | |
223 | 283 | | |
224 | 284 | | |
| |||
244 | 304 | | |
245 | 305 | | |
246 | 306 | | |
247 | | - | |
| 307 | + | |
248 | 308 | | |
249 | 309 | | |
250 | 310 | | |
251 | | - | |
| 311 | + | |
252 | 312 | | |
253 | 313 | | |
254 | 314 | | |
255 | | - | |
| 315 | + | |
256 | 316 | | |
257 | 317 | | |
258 | 318 | | |
259 | | - | |
| 319 | + | |
260 | 320 | | |
261 | 321 | | |
262 | 322 | | |
| |||
265 | 325 | | |
266 | 326 | | |
267 | 327 | | |
268 | | - | |
| 328 | + | |
269 | 329 | | |
270 | 330 | | |
271 | 331 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
2 | 5 | | |
3 | 6 | | |
4 | 7 | | |
| |||
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
20 | 26 | | |
21 | 27 | | |
22 | 28 | | |
| |||
338 | 344 | | |
339 | 345 | | |
340 | 346 | | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
341 | 379 | | |
342 | 380 | | |
343 | 381 | | |
| |||
523 | 561 | | |
524 | 562 | | |
525 | 563 | | |
526 | | - | |
| 564 | + | |
0 commit comments