Commit 80fc539
feat(pt_expt): add DeepSpin support for pt_expt backend (#5370)
## Summary
- Add DeepSpin (spin model) support for the pt_expt (.pt2) backend: C++
API, Python inference, LAMMPS pair style, and model deviation
- Fix `add_mag` bug in dpmodel `SpinModel`: atomic virial used
`add_mag=False` while PT backend used `add_mag=True`, causing
inconsistent per-atom virial between .pth and .pt2
- Add `"type": "spin_ener"` to spin model serialization for correct
deserialization dispatch across all backends
- Replace committed `.pth` model file with canonical `.yaml` (dpmodel
serialization); `.pth` and `.pt2` are now regenerated from `.yaml` via
`convert_backend` at test time
## Test plan
- [x] C++ spin tests: 38 passed (12 TF-only skipped)
- [x] LAMMPS .pt2 spin tests: 7 passed (PBC + NoPBC + model_devi)
- [x] LAMMPS .pth spin tests: 3 passed (single-model; model_devi needs
TF .pb)
- [x] .pth vs .pt2 agreement: all quantities diff ~1e-15
- [ ] CI: full test suite
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Spin-capable models: public queries for model spin presence and
per-type spin usage; PyTorch-exportable spin backend and new export/run
backend for spin models; serialized spin model discriminator added.
* Output pipeline extended to include magnetic derivatives, magnetic
virial counterparts, and per-atom magnetic masks.
* **Tests**
* Added extensive unit and regression tests, new test suites and
generators for spin models, updated golden reference data, and
model-generation scripts.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Han Wang <wang_han@iapcm.ac.cn>1 parent d7ee913 commit 80fc539
File tree
39 files changed
+13647
-841
lines changed- deepmd
- dpmodel
- infer
- model
- infer
- pd/infer
- pt_expt
- infer
- model
- utils
- pt
- infer
- model/model
- utils
- source
- api_cc
- include
- src
- tests
- api_c/tests
- install
- lmp/tests
- tests
- infer
- pt_expt
- infer
39 files changed
+13647
-841
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
169 | 179 | | |
170 | 180 | | |
171 | 181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
130 | 138 | | |
131 | 139 | | |
132 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
| 552 | + | |
552 | 553 | | |
553 | 554 | | |
554 | 555 | | |
555 | 556 | | |
556 | 557 | | |
557 | 558 | | |
| 559 | + | |
| 560 | + | |
558 | 561 | | |
559 | 562 | | |
560 | 563 | | |
| |||
646 | 649 | | |
647 | 650 | | |
648 | 651 | | |
649 | | - | |
| 652 | + | |
650 | 653 | | |
651 | 654 | | |
652 | 655 | | |
| |||
823 | 826 | | |
824 | 827 | | |
825 | 828 | | |
826 | | - | |
| 829 | + | |
827 | 830 | | |
828 | 831 | | |
829 | 832 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
131 | 147 | | |
132 | 148 | | |
133 | 149 | | |
| |||
235 | 251 | | |
236 | 252 | | |
237 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
238 | 269 | | |
239 | 270 | | |
240 | 271 | | |
241 | 272 | | |
242 | 273 | | |
243 | 274 | | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
244 | 279 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
326 | 337 | | |
327 | 338 | | |
328 | 339 | | |
| |||
705 | 716 | | |
706 | 717 | | |
707 | 718 | | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
708 | 731 | | |
709 | 732 | | |
710 | 733 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
300 | 307 | | |
301 | 308 | | |
302 | 309 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
317 | 324 | | |
318 | 325 | | |
319 | 326 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
637 | 637 | | |
638 | 638 | | |
639 | 639 | | |
| 640 | + | |
640 | 641 | | |
641 | 642 | | |
642 | 643 | | |
643 | 644 | | |
644 | 645 | | |
645 | 646 | | |
| 647 | + | |
| 648 | + | |
646 | 649 | | |
647 | 650 | | |
648 | 651 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
76 | 84 | | |
77 | 85 | | |
78 | 86 | | |
| |||
0 commit comments