Commit e48b6e2
Han Wang
fix: refresh the ZBL lookup on change_type_map; allow native spin + bridging
Two review items.
**3649295675 -- ZBL element lookup went stale on change_type_map.**
``InterPotentialAtomicModel`` inherited the generic
``BaseAtomicModel.change_type_map``, which rewrites the public map and the
stat/exclusion state only, so ``InterPotential`` kept its ORIGINAL nuclear
charges while ``atype`` values already meant the new elements -- silently
wrong energies after a reorder, ``IndexError`` after adding a type, and a
restart-time jump because serialization records the new map. The lookup
belongs to ``InterPotential``, so it owns the update: a new
``change_type_map`` rebuilds symbols, count and table together from the
symbols (not by permuting indices), keeping the array's namespace/dtype/
device so a pt_expt buffer -- possibly on CUDA -- is updated in place. The
atomic model delegates rather than reimplementing.
**3649276109 -- native spin + analytical bridging was rejected.**
The combination needs no new machinery: ``get_standard_model`` already OWNS
assembling the atomic model, bridging composition included, so the guard is
gone and ``get_native_spin_model`` now delegates to it and re-classes
whatever atomic model comes back -- a single learned model or a
``LinearEnergyAtomicModel`` over ``[learned, InterPotential]``. The learned
child consumes ``spin``; the analytical child accepts and ignores it. Two
supporting changes: a shared ``learned_descriptor()`` so the descriptor
capability gate reads the learned child either way, and ``NSM.serialize``
now records the backbone's own wire type (``backbone_type``) -- it was
hard-coded to "standard", which fails on a composed backbone whose dict has
a different shape and @Version. Archives without the field still read as
"standard".
Also fixes the C++ pair-exclusion regression added in ecfb7a8: its
``cpu_lmp_nlist`` case compared an nghost=0 explicit-nlist run (no periodic
images) against the PBC reference; it now uses the gas-phase one, the same
convention test_deepspin_dpa4_graph_ptexpt.cc follows.
Tests: change_type_map reorder / add / drop / serialize-roundtrip in both
dpmodel and pt_expt (the pt_expt twin asserts the rebuilt lookup is still a
torch buffer on the model device); native spin + ZBL construction, eager
energy/force/force_mag with mask_mag, the analytical term checked against an
independent in-test pair loop at 1e-10, serialization, and graph
freeze + DeepPot parity at 1e-10. The stale
``test_native_spin_with_bridging_fails_fast`` is replaced by those.1 parent fd6fa77 commit e48b6e2
7 files changed
Lines changed: 549 additions & 41 deletions
File tree
- deepmd
- dpmodel
- atomic_model
- model
- pt_expt/model
- source
- api_cc/tests
- tests
- common/dpmodel
- pt_expt/model
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
100 | 125 | | |
101 | 126 | | |
102 | 127 | | |
103 | 128 | | |
104 | 129 | | |
105 | 130 | | |
106 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
107 | 158 | | |
108 | 159 | | |
109 | 160 | | |
| |||
259 | 310 | | |
260 | 311 | | |
261 | 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 | + | |
262 | 338 | | |
263 | 339 | | |
264 | 340 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 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 | + | |
| 271 | + | |
| 272 | + | |
243 | 273 | | |
244 | 274 | | |
245 | 275 | | |
| |||
250 | 280 | | |
251 | 281 | | |
252 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
253 | 292 | | |
254 | 293 | | |
255 | 294 | | |
256 | 295 | | |
257 | 296 | | |
258 | 297 | | |
259 | 298 | | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | 299 | | |
267 | 300 | | |
268 | 301 | | |
| |||
271 | 304 | | |
272 | 305 | | |
273 | 306 | | |
| 307 | + | |
274 | 308 | | |
275 | | - | |
276 | 309 | | |
277 | | - | |
| 310 | + | |
278 | 311 | | |
279 | 312 | | |
280 | 313 | | |
| |||
289 | 322 | | |
290 | 323 | | |
291 | 324 | | |
292 | | - | |
| 325 | + | |
| 326 | + | |
293 | 327 | | |
294 | 328 | | |
295 | 329 | | |
296 | 330 | | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
| 331 | + | |
305 | 332 | | |
306 | 333 | | |
307 | 334 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
230 | 236 | | |
231 | 237 | | |
232 | 238 | | |
| |||
236 | 242 | | |
237 | 243 | | |
238 | 244 | | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
244 | 257 | | |
245 | 258 | | |
246 | 259 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | 274 | | |
281 | 275 | | |
282 | 276 | | |
| |||
306 | 300 | | |
307 | 301 | | |
308 | 302 | | |
309 | | - | |
310 | | - | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
| |||
Lines changed: 20 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
75 | 83 | | |
76 | 84 | | |
77 | 85 | | |
| 86 | + | |
78 | 87 | | |
79 | 88 | | |
80 | 89 | | |
| |||
98 | 107 | | |
99 | 108 | | |
100 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
101 | 113 | | |
102 | 114 | | |
103 | 115 | | |
104 | 116 | | |
105 | 117 | | |
106 | 118 | | |
| 119 | + | |
107 | 120 | | |
108 | 121 | | |
| 122 | + | |
109 | 123 | | |
110 | 124 | | |
111 | 125 | | |
| |||
155 | 169 | | |
156 | 170 | | |
157 | 171 | | |
158 | | - | |
159 | | - | |
160 | | - | |
| 172 | + | |
| 173 | + | |
161 | 174 | | |
162 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
163 | 179 | | |
164 | 180 | | |
165 | 181 | | |
| |||
0 commit comments