Skip to content

Commit

Permalink
add pt command line end-to-end test
Browse files Browse the repository at this point in the history
  • Loading branch information
cherryWangY committed Nov 5, 2024
1 parent b9acf04 commit 14ac57b
Show file tree
Hide file tree
Showing 9 changed files with 676 additions and 0 deletions.
8 changes: 8 additions & 0 deletions source/tests/pt/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import pathlib
from typing import (
Optional,
Union,
Expand All @@ -7,6 +8,7 @@
import numpy as np
import torch

from deepmd.common import j_loader as dp_j_loader
from deepmd.main import (
main,
)
Expand All @@ -15,6 +17,12 @@
GLOBAL_PT_FLOAT_PRECISION,
)

tests_path = pathlib.Path(__file__).parent.absolute()


def j_loader(filename):
return dp_j_loader(tests_path / filename)


def run_dp(cmd: str) -> int:
"""Run DP directly from the entry point instead of the subprocess.
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions source/tests/pt/model_compression/data/type.raw
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
0
1
1
0
1
1
2 changes: 2 additions & 0 deletions source/tests/pt/model_compression/data/type_map.raw
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
O
H
85 changes: 85 additions & 0 deletions source/tests/pt/model_compression/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"_comment1": " model parameters",
"model": {
"type_map": [
"O",
"H"
],
"descriptor": {
"type": "se_e2_a",
"sel": [
46,
92
],
"rcut_smth": 0.50,
"rcut": 6.00,
"_comment": "N2=2N1, N2=N1, and otherwise can be tested",
"neuron": [
4,
8,
17,
17
],
"resnet_dt": false,
"axis_neuron": 16,
"seed": 1,
"_comment2": " that's all"
},
"fitting_net": {
"neuron": [
20,
20,
20
],
"resnet_dt": true,
"seed": 1,
"_comment3": " that's all"
},
"_comment4": " that's all"
},

"learning_rate": {
"type": "exp",
"decay_steps": 5000,
"start_lr": 0.001,
"stop_lr": 3.51e-8,
"_comment5": "that's all"
},

"loss": {
"type": "ener",
"start_pref_e": 0.02,
"limit_pref_e": 1,
"start_pref_f": 1000,
"limit_pref_f": 1,
"start_pref_v": 0,
"limit_pref_v": 0,
"_comment6": " that's all"
},

"training": {
"training_data": {
"systems": [
"model_compression/data"
],
"batch_size": "auto",
"_comment7": "that's all"
},
"validation_data": {
"systems": [
"model_compression/data"
],
"batch_size": 1,
"numb_btch": 3,
"_comment8": "that's all"
},
"numb_steps": 1,
"seed": 10,
"disp_file": "lcurve.out",
"disp_freq": 1,
"save_freq": 1,
"_comment9": "that's all"
},

"_comment10": "that's all"
}
Loading

0 comments on commit 14ac57b

Please sign in to comment.