Commit 58e346a
pd(feat): support python inference with
Summary:
1. support python inference with `DP(model=paddle_inference.json)` for
ase, and add an unitest.
2. update ase document with different backend
3. fix typos in `DeepPotPD.cc`
---
This pull request introduces significant enhancements and refactoring to
the Paddle backend implementation of `DeepEval` in
`deepmd/pd/infer/deep_eval.py`, along with minor improvements to model
freezing in `deepmd/pd/entrypoints/main.py`. The most important changes
are the addition of support for static models loaded from `.json` files,
expanded model type handling, and improved output shape and evaluation
logic for various model branches and output variable categories.
### Static model and inference support
* Added support for loading and evaluating static models from `.json`
files, including Paddle inference engine integration and input/output
handle management for efficient prediction.
(`deepmd/pd/infer/deep_eval.py`)
[[1]](diffhunk://#diff-8c2ffd525a36d0190726f1aca380b9a4e05e67cd8ba6fa5e3842f810c69e6c68L117-R181)
[[2]](diffhunk://#diff-8c2ffd525a36d0190726f1aca380b9a4e05e67cd8ba6fa5e3842f810c69e6c68R470)
[[3]](diffhunk://#diff-8c2ffd525a36d0190726f1aca380b9a4e05e67cd8ba6fa5e3842f810c69e6c68R481-R508)
[[4]](diffhunk://#diff-8c2ffd525a36d0190726f1aca380b9a4e05e67cd8ba6fa5e3842f810c69e6c68R532-R547)
[[5]](diffhunk://#diff-8c2ffd525a36d0190726f1aca380b9a4e05e67cd8ba6fa5e3842f810c69e6c68L420-R566)
### Expanded model type and branch handling
* Enhanced model type detection to support additional output types such
as DOS, dipole, polar, global polar, WFC, and property models, with
corresponding evaluator selection. Also added methods for model branch
information retrieval and default parameter checks.
(`deepmd/pd/infer/deep_eval.py`)
[[1]](diffhunk://#diff-8c2ffd525a36d0190726f1aca380b9a4e05e67cd8ba6fa5e3842f810c69e6c68L152-R259)
[[2]](diffhunk://#diff-8c2ffd525a36d0190726f1aca380b9a4e05e67cd8ba6fa5e3842f810c69e6c68L187-R306)
### Output variable and evaluation improvements
* Improved output shape determination for new output variable categories
(e.g., `DERV_R_DERV_R`), and refactored evaluation logic to handle both
static and dynamic models, including proper output conversion.
(`deepmd/pd/infer/deep_eval.py`)
[[1]](diffhunk://#diff-8c2ffd525a36d0190726f1aca380b9a4e05e67cd8ba6fa5e3842f810c69e6c68R412)
[[2]](diffhunk://#diff-8c2ffd525a36d0190726f1aca380b9a4e05e67cd8ba6fa5e3842f810c69e6c68R681-R683)
[[3]](diffhunk://#diff-8c2ffd525a36d0190726f1aca380b9a4e05e67cd8ba6fa5e3842f810c69e6c68L420-R566)
* Implemented the previously unimplemented `_eval_model_spin` method to
support spin-dependent model evaluation and output extraction.
(`deepmd/pd/infer/deep_eval.py`)
### Type embedding evaluation
* Added a new method `eval_typeebd` to extract and concatenate type
embedding network outputs from the loaded model.
(`deepmd/pd/infer/deep_eval.py`)
### Model freezing improvements
* Updated the `freeze` function to support freezing additional model
methods and atomic virial computation, and changed input specifications
for better compatibility. (`deepmd/pd/entrypoints/main.py`)
[[1]](diffhunk://#diff-e3f56cd14511cf86a0db88d6d9ee5b08cf45374edfdef0625a0f519d94c58507R345)
[[2]](diffhunk://#diff-e3f56cd14511cf86a0db88d6d9ee5b08cf45374edfdef0625a0f519d94c58507L377-R378)
[[3]](diffhunk://#diff-e3f56cd14511cf86a0db88d6d9ee5b08cf45374edfdef0625a0f519d94c58507L393-R400)
[[4]](diffhunk://#diff-e3f56cd14511cf86a0db88d6d9ee5b08cf45374edfdef0625a0f519d94c58507R413-R432)
Let me know if you'd like a walkthrough of any specific new
functionality or code sections!
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- New Features
- Dual evaluation modes: dynamic (.json) and static (.pd) with optional
no-JIT; new evaluation branches for additional model types and spin
support.
- Freeze can include atomic virial; frozen exports expose additional
buffer-backed getters (type map, cutoffs, parameter dims, ntypes).
- Improvements
- Wider static-graph support via persistent buffers across
descriptors/models; more consistent inference input handling and
batching.
- Documentation
- ASE guide extended with backend-specific examples.
- Tests
- New end-to-end training, inference, and frozen-model validation tests.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: HydrogenSulfate <490868991@qq.com>
Co-authored-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>DP class (#4987)1 parent 58f60c4 commit 58e346a
24 files changed
Lines changed: 1036 additions & 154 deletions
File tree
- deepmd/pd
- entrypoints
- infer
- model
- atomic_model
- descriptor
- model
- task
- utils
- doc/third-party
- source
- api_cc/src
- tests/pd/model
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
| |||
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
101 | | - | |
102 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
103 | 107 | | |
104 | 108 | | |
105 | 109 | | |
106 | 110 | | |
107 | 111 | | |
108 | 112 | | |
109 | | - | |
| 113 | + | |
| 114 | + | |
110 | 115 | | |
111 | | - | |
| 116 | + | |
| 117 | + | |
112 | 118 | | |
113 | 119 | | |
114 | 120 | | |
| |||
342 | 348 | | |
343 | 349 | | |
344 | 350 | | |
| 351 | + | |
345 | 352 | | |
346 | 353 | | |
347 | 354 | | |
| |||
374 | 381 | | |
375 | 382 | | |
376 | 383 | | |
377 | | - | |
| 384 | + | |
378 | 385 | | |
379 | 386 | | |
380 | 387 | | |
| |||
396 | 403 | | |
397 | 404 | | |
398 | 405 | | |
399 | | - | |
| 406 | + | |
400 | 407 | | |
401 | 408 | | |
402 | 409 | | |
| |||
409 | 416 | | |
410 | 417 | | |
411 | 418 | | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
412 | 439 | | |
413 | 440 | | |
414 | 441 | | |
| |||
0 commit comments