Commit 3384efb
test(infer,lmp): drop stale DPA2 .pth fixtures, repoint tests to deeppot_dpa2 (#5446)
## Summary
- Drop the stale pre-committed `deeppot_dpa.pth` and
`deeppot_dpa_sel.pth` fixtures and the redundant C++ test
`test_deeppot_dpa_pt.cc`. Both `.pth` files predate the `g1_out_mlp` /
`g1_out_conv` repformer features, so they could be loaded only via the
baked-in TorchScript IR (`torch.jit.load`) — they could not be
round-tripped through `get_model() + load_state_dict()` and therefore
could not be converted to `.pt2`. This was the blocker recorded in
`memory/project_stale_dpa2_pth.md` and the master plan's "LAMMPS .pt2
DPA tests" planned item.
- Repoint the three LAMMPS PyTorch-backend tests at the current-arch
`deeppot_dpa2.pth` and load reference values from
`deeppot_dpa2.expected` via `read_expected_ref` (already used by
`test_lammps_dpa3_pt2.py`). This replaces ~150 hard-coded reference
floats per file with a 5-line `try / except` block, and the .expected
file is regenerated at CI time by `source/tests/infer/gen_dpa2.py`.
- Rename `test_lammps_dpa_pt.py` → `test_lammps_dpa2_pt.py` and
`test_lammps_dpa_pt_nopbc.py` → `test_lammps_dpa2_pt_nopbc.py` so the
descriptor is visible from the filename (matching
`test_lammps_dpa2_pt2.py` / `test_lammps_dpa3_*` convention). Delete
`test_lammps_dpa_sel_pt.py` outright — once both fixtures collapse onto
`deeppot_dpa2.pth` it becomes a pure duplicate of the PBC variant. The
small-`sel`-specific semantics of the old `deeppot_dpa_sel.pth` are not
preserved; if that coverage is wanted back, the right path is a separate
`deeppot_dpa2_sel.pth` fixture written by an extended `gen_dpa2.py`.
- Deletion of `test_deeppot_dpa_pt.cc`: once migrated to
`deeppot_dpa2.pth` + `expected_ref.h`, this file is byte-for-byte
equivalent to the existing `test_deeppot_dpa2_pt.cc` (same backend, same
fixture, same geometry, same five test cases). Keeping both would be
pure duplication.
Net diff: 9 files changed, +61 insertions, −1369 deletions.
The JAX path (`source/lmp/tests/test_lammps_dpa_jax.py`,
`source/api_cc/tests/test_deeppot_dpa_jax.cc`, and the
`deeppot_dpa.yaml` → `deeppot_dpa.savedmodel` conversion in
`convert-models.sh`) is intentionally left untouched. The
`deeppot_dpa.yaml` has the current architecture (the .pth files diverged
from it at some point), so the JAX tests continue to work; renaming them
for consistency would be a separate cleanup.
## Test plan
- [x] `pytest --collect-only` on the two renamed Python tests collects
33 tests (PBC 17 + NoPBC 16). No `ModuleNotFoundError`,
`read_expected_ref` resolves the `.expected` file at import time.
- [x] Live `DeepPot(deeppot_dpa2.pth).eval(...)` output matches every
value in `deeppot_dpa2.expected` for both PBC and NoPBC sections
(atol=1e-12, rtol=0).
- [x] C++ ctest filter `*Dpa2Pt*:*Dpa2PtNoPbc*` from `build_pt2_test/`:
**28 / 28 PASSED** in 69.4 s. Covers all `.pth` cases that the deleted
`test_deeppot_dpa_pt.cc` would have run (`TestInferDeepPotDpa2Pt`,
`TestInferDeepPotDpa2PtNoPbc`, double + float), plus the existing `.pt2`
AOTI suites.
- [ ] Full LAMMPS pair_deepmd run (not exercised locally — depends on
built LAMMPS-with-deepmd integration; CI will cover).
- [ ] Confirm CI `convert-models.sh` still produces
`deeppot_dpa.savedmodel` cleanly for the JAX tests (the yaml is
unchanged, but worth watching the first CI run).
Closes the "Stale DPA2 .pth files" limitation and the "LAMMPS .pt2 DPA
tests" planned item in the pt_expt master plan.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Tests**
* DPA2 LAMMPS tests now load expected references from external files
(with graceful fallback when reference files are unavailable).
* Added tests to validate per-atom energy/virial outputs when periodic
boundaries are disabled.
* Removed several deprecated DeepPot test modules to streamline and
reduce redundant test coverage.
<!-- review_stack_entry_start -->
[](https://app.coderabbit.ai/change-stack/deepmodeling/deepmd-kit/pull/5446?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)
<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Han Wang <wang_han@iapcm.ac.cn>1 parent e7108b6 commit 3384efb
7 files changed
Lines changed: 121 additions & 1350 deletions
File tree
- source
- api_cc/tests
- lmp/tests
- tests/infer
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
212 | 248 | | |
213 | 249 | | |
214 | 250 | | |
| |||
242 | 278 | | |
243 | 279 | | |
244 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 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 | + | |
0 commit comments