Skip to content

Commit 2a82988

Browse files
wanghan-iapcmHan Wang
andauthored
feat(c++,pt-expt): add DeepPotModelDevi C++ tests for .pt2 backend (#5342)
## Summary - Add C++ `DeepPotModelDevi` unit tests for the pt_expt (.pt2) backend - Generate two SE(A)+fparam/aparam .pt2 models with different seeds (`gen_model_devi.py`) for meaningful deviations - Both models include `default_fparam=[0.25852028]` for attribute detection tests ## Tests added (14 total: 2 test classes × {double, float}) **TestInferDeepPotModeDeviPtExpt** (6 tests per type): - `attrs` — cutoff, numb_types, dim_fparam==1, dim_aparam==1, has_default_fparam - `cpu_build_nlist` / `cpu_build_nlist_atomic` — individual dp0/dp1 vs model_devi consistency - `cpu_lmp_list` / `cpu_lmp_list_atomic` — same with LAMMPS nlist + fold_back - `cpu_lmp_list_std` — manual vs API compute_avg, compute_std_e, compute_std_f, compute_relative_std_f **TestInferDeepPotModeDeviPtExptPrecomputed** (1 test per type): - `cpu_lmp_list_std` — max/min/avg std_f and max/min/mystd std_v against hardcoded reference values ## Known limitations - `default_fparam` **compute** path is not tested: `DeepPotPTExpt::compute` creates a zero-size tensor when fparam is empty, which crashes the .pt2 runner. The C++ API supports `has_default_fparam()` detection but not automatic value substitution. ## Test plan - [x] `gen_model_devi.py` generates two .pt2 models without errors - [x] All 14 TYPED_TEST cases pass for both double and float - [x] Precomputed deviation values match - [x] No regressions in existing 94 PtExpt tests (108 total pass) - [x] No compiler warnings - [x] Pre-commit hooks pass <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Added a comprehensive test suite validating multi-model deviation inference and statistical outputs for the PyTorch-enabled backend. * Added an automated artifact-generation step to produce paired model artifacts used for deviation comparisons. * Updated test setup to run the new generation step and conditionally enable these tests only when PyTorch support is available. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Han Wang <wang_han@iapcm.ac.cn>
1 parent 206ace0 commit 2a82988

File tree

3 files changed

+785
-0
lines changed

3 files changed

+785
-0
lines changed

0 commit comments

Comments
 (0)