Commit 625646c
authored
perf: bound memory in model testing and output statistics (deepmodeling#5944)
## Summary
- evaluate `dp test` in atom-bounded chunks, with lazy on-demand
decoding for LMDB inputs
- preserve run-level MAE/RMSE aggregation and detail output across
chunks while consolidating backend-independent test logic under
`deepmd.infer.model_test`
- build the neighbor representation declared by each atomic model during
output-bias statistics, using `NeighborGraph` for graph-native models
and the existing dense neighbor list for other models
## Why
Large LMDB datasets were fully decoded before frame selection, so even a
small test run could require loading tens of millions of frames.
Separately, graph-native atomic models were routed through a
fixed-capacity dense neighbor list while calibrating output bias;
because those models do not declare a finite neighbor capacity, that
path could allocate tens of gigabytes and fail before fine-tuning began.
This change bounds LMDB decoding and model-evaluation memory while
preserving the existing evaluation and output-statistics contracts.
Ordinary `DeepmdData` inputs still materialize one test system before
chunked evaluation.
## Additional correctness fixes
- preserve legacy TensorFlow spin-model dispatch and spin virial/stress
reporting
- use canonical atomic tensor labels consistently across NPY and LMDB
inputs
- flatten atomic parameters correctly for graph-native output statistics
- keep LMDB frame selection deterministic and honor availability
subgroups during iteration
- keep detail files isolated across systems and emit a single header
across chunks
- require atomic property labels when atomic metrics are requested
## Checks
- `ruff check .`
- `ruff format --check .`
- targeted common model-test and LMDB regression tests
- targeted PyTorch streaming/output-stat regression tests
- `git diff --check`
The TensorFlow atomic dipole/polar integration cases could not be run
locally because this checkout has no built TensorFlow backend; they are
left to CI.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Expanded model evaluation for energy, spin, DOS, property, dipole, and
polarizability models.
* Added chunked testing, frame limits, per-frame details, and
atomic-level metrics.
* **Improvements**
* Large LMDB test datasets now load frames lazily for improved
efficiency.
* Added clearer weighted aggregation of MAE and RMSE results.
* Graph-capable models now use graph-based neighbor representations
during inference.
* **Bug Fixes**
* Improved handling of periodic systems, mixed atom counts, exclusions,
optional outputs, missing labels, and atomic label naming.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 6330a2f commit 625646c
16 files changed
Lines changed: 2196 additions & 1644 deletions
File tree
- deepmd
- dpmodel
- atomic_model
- utils
- entrypoints
- infer/model_test
- utils
- source/tests
- common
- dpmodel
- pt
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
805 | 805 | | |
806 | 806 | | |
807 | 807 | | |
808 | | - | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
809 | 819 | | |
810 | 820 | | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
811 | 824 | | |
812 | 825 | | |
813 | 826 | | |
| |||
841 | 854 | | |
842 | 855 | | |
843 | 856 | | |
844 | | - | |
845 | | - | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
850 | | - | |
851 | | - | |
852 | | - | |
853 | | - | |
854 | | - | |
855 | | - | |
856 | | - | |
857 | | - | |
858 | | - | |
859 | | - | |
860 | | - | |
861 | | - | |
862 | | - | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | | - | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
869 | 915 | | |
870 | 916 | | |
871 | 917 | | |
| |||
0 commit comments