Commit 58ce1aa
feat(pt): add model branch alias (#4883)
Introduces model branch alias and info fields to model configuration,
adds utility functions for handling model branch dictionaries, and
updates related modules to use alias-based lookup and provide detailed
branch information. Enhances multi-task model usability and improves
logging of available model branches.
example:
```
dp --pt show 0415_compat_new.pt model-branch
[2025-08-14 10:05:54,246] DEEPMD WARNING To get the best performance, it is recommended to adjust the number of threads by setting the environment variables OMP_NUM_THREADS, DP_INTRA_OP_PARALLELISM_THREADS, and DP_INTER_OP_PARALLELISM_THREADS. See https://deepmd.rtfd.io/parallelism/ for more information.
[2025-08-14 10:05:59,122] DEEPMD INFO This is a multitask model
[2025-08-14 10:05:59,122] DEEPMD INFO Available model branches are ['Dai2023Alloy', 'Zhang2023Cathode', 'Gong2023Cluster', 'Yang2023ab', 'UniPero', 'Huang2021Deep-PBE', 'Liu2024Machine', 'Zhang2021Phase', 'Jinag2021Accurate', 'Chen2023Modeling', 'Wen2021Specialising', 'Wang2022Classical', 'Wang2022Tungsten', 'Wu2021Deep', 'Huang2021Deep-PBEsol', 'Transition1x', 'Wang2021Generalizable', 'Wu2021Accurate', 'MPTraj', 'Li2025APEX', 'Shi2024SSE', 'Tuo2023Hybrid', 'Unke2019PhysNet', 'Shi2024Electrolyte', 'ODAC23', 'Alex2D', 'OMAT24', 'SPICE2', 'OC20M', 'OC22', 'Li2025General', 'RANDOM'], where 'RANDOM' means using a randomly initialized fitting net.
[2025-08-14 10:05:59,125] DEEPMD INFO Detailed information:
+-----------------------+------------------------------+--------------------------------+--------------------------------+
| Model Branch | Alias | description | observed_type |
+-----------------------+------------------------------+--------------------------------+--------------------------------+
| Dai2023Alloy | Alloys, Domains_Alloy | The dataset contains | ['La', 'Fe', 'Ho', 'Cu', 'Sn', |
| | | structure-energy-force-virial | 'Cd', 'Y', 'Be', 'V', 'Sm', |
| | | data for 53 typical metallic | 'In', 'Pr', 'Mo', 'Mn', 'Gd', |
| | | elements in alloy systems, | 'Ru', 'Nd', 'Li', 'Tm', 'K', |
| | | including ~9000 intermetallic | 'Pt', 'Ir', 'Na', 'Hf', 'Dy', |
| | | compounds and FCC, BCC, HCP | 'Ca', 'Nb', 'Au', 'Sr', 'Si', |
| | | structures. It consists of two | 'Ge', 'Co', 'W', 'Cr', 'Zn', |
| | | parts: DFT-generated relaxed | 'Ag', 'Ti', 'Ni', 'Zr', 'Pd', |
| | | and deformed structures, and | 'Os', 'Ta', 'Rh', 'Sc', 'Tb', |
| | | randomly distorted structures | 'Al', 'Ga', 'Re', 'Lu', 'Er', |
| | | produced covering pure metals, | 'Mg', 'Ce', 'Pb'] |
| | | solid solutions, and | |
| | | intermetallics with vacancies. | |
+-----------------------+------------------------------+--------------------------------+--------------------------------+
| OMAT24 | Default, Materials, Omat24 | OMat24 is a large-scale open | ['La', 'Fe', 'Cu', 'Cd', 'Be', |
| | | dataset containing over 110 | 'Ar', 'V', 'Sm', 'In', 'Pm', |
| | | million DFT calculations | 'Pr', 'Mn', 'Ru', 'He', 'Nd', |
| | | spanning diverse structures | 'Th', 'Pa', 'K', 'Pt', 'Yb', |
| | | and compositions. It is | 'Dy', 'Sr', 'Co', 'Np', 'Cr', |
| | | designed to support AI-driven | 'Tl', 'Br', 'Se', 'Ni', 'Zr', |
| | | materials discovery by | 'Pu', 'O', 'Xe', 'Tb', 'Ga', |
| | | providing broad and deep | 'Lu', 'H', 'Ne', 'Er', 'Ce', |
| | | coverage of chemical space. | 'I', 'Kr', 'Ho', 'Cs', 'Sn', |
| | | | 'Rb', 'Y', 'N', 'F', 'Mo', |
| | | | 'Gd', 'B', 'Li', 'Tm', 'Sb', |
| | | | 'Ir', 'Hf', 'Na', 'Ca', 'Nb', |
| | | | 'Au', 'As', 'Si', 'Ge', 'W', |
| | | | 'Zn', 'Hg', 'Ag', 'Bi', 'Ti', |
| | | | 'Os', 'Cl', 'Pd', 'P', 'U', |
| | | | 'Tc', 'Ta', 'Ba', 'Rh', 'Sc', |
| | | | 'C', 'S', 'Te', 'Al', 'Re', |
| | | | 'Eu', 'Mg', 'Pb', 'Ac'] |
+-----------------------+------------------------------+--------------------------------+--------------------------------+
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Alias-based multi-task branch selection for evaluation and
fine-tuning; new API to query model alias/branch info; show now prints a
detailed model-branch table.
* **Documentation**
* Model config gains optional fields to declare branch aliases and
per-branch info (PyTorch-only).
* **Examples**
* Added a two-task PyTorch example demonstrating aliases, shared
components, and per-branch info.
* **Tests**
* Tests include the new example and now filter out table-like show
output.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: Duo <50307526+iProzd@users.noreply.github.com>
Co-authored-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Co-authored-by: Han Wang <92130845+wanghan-iapcm@users.noreply.github.com>1 parent c796862 commit 58ce1aa
File tree
8 files changed
+573
-9
lines changed- deepmd
- entrypoints
- pt
- infer
- utils
- utils
- examples/water_multi_task/pytorch_example
- source/tests
- common
- pt
8 files changed
+573
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
| |||
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
| 40 | + | |
36 | 41 | | |
37 | 42 | | |
38 | 43 | | |
39 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
40 | 49 | | |
41 | 50 | | |
42 | 51 | | |
| |||
79 | 88 | | |
80 | 89 | | |
81 | 90 | | |
82 | | - | |
83 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
84 | 107 | | |
85 | 108 | | |
86 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
70 | 74 | | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
| 78 | + | |
| 79 | + | |
74 | 80 | | |
75 | 81 | | |
76 | 82 | | |
| |||
116 | 122 | | |
117 | 123 | | |
118 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
119 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
120 | 134 | | |
121 | 135 | | |
122 | 136 | | |
123 | | - | |
| 137 | + | |
| 138 | + | |
124 | 139 | | |
125 | | - | |
126 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
127 | 152 | | |
| 153 | + | |
| 154 | + | |
128 | 155 | | |
129 | 156 | | |
130 | 157 | | |
| |||
253 | 280 | | |
254 | 281 | | |
255 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
256 | 294 | | |
257 | 295 | | |
258 | 296 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
| |||
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
47 | | - | |
48 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
49 | 53 | | |
| 54 | + | |
50 | 55 | | |
| 56 | + | |
51 | 57 | | |
52 | 58 | | |
53 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2306 | 2306 | | |
2307 | 2307 | | |
2308 | 2308 | | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
2309 | 2319 | | |
2310 | 2320 | | |
2311 | 2321 | | |
| |||
2321 | 2331 | | |
2322 | 2332 | | |
2323 | 2333 | | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
2324 | 2348 | | |
2325 | 2349 | | |
2326 | 2350 | | |
| |||
0 commit comments