Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOF-7194: preliminary deepmd support on the web platform #110

Merged
merged 21 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7f42efa
SOF-7194: preliminary deepmd support on the web platform
pranabdas Jan 6, 2024
e47cd8c
SOF-7194: add tests
pranabdas Jan 6, 2024
f017cc2
SOF-7194: include deepmd in the applications data
pranabdas Jan 6, 2024
9c09052
SOF-7194: set default executable for deepmd
pranabdas Jan 6, 2024
fea0e32
SOF-7194: include deepmd in allApplications export
pranabdas Jan 6, 2024
e0277c7
SOF-7194: fix typo in template name
pranabdas Jan 6, 2024
6925289
SOF-7194: add lammps executable and templates
pranabdas Jan 8, 2024
a177333
SOF-7194: fix lammps input template array
pranabdas Jan 9, 2024
40b9406
SOF-7194: include lammps in executable tree
pranabdas Jan 9, 2024
0f01c3d
SOF-7194: fix lammps input files array
pranabdas Jan 9, 2024
30bfe3a
SOF-7194: fix qe input file prefix
pranabdas Jan 9, 2024
5642817
chore(SOF-7194): rename structure.lmp -> system.lmp
pranabdas Jan 9, 2024
d51fc8a
SOF-7194: merge main and resolve conflicts
pranabdas Jan 18, 2024
762b497
SOF-7194: add way to convert qe structure to lmp structure
pranabdas Jan 18, 2024
4fbd85a
SOF-7194: fix lmp executable name
pranabdas Jan 18, 2024
a427306
SOF-7194: fix default flavor for deepmd/python executable
pranabdas Jan 18, 2024
e0c8969
SOF-7194: set orthogonalization method and ortho_eps in cp template
pranabdas Jan 20, 2024
4d0debf
SOF-7194: set a default flavor for cp.x executable
pranabdas Jan 20, 2024
1234dde
Update cp.j2.in
timurbazhirov Jan 23, 2024
c76be31
chore (SOF-7194): some renamings
pranabdas Jan 23, 2024
5373764
SOF-7194: fix template file name
pranabdas Jan 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions applications/application_data.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
deepmd: !include 'applications/deepmd.yml'
espresso: !include 'applications/espresso.yml'
exabyteml: !include 'applications/exabyteml.yml'
jupyterLab: !include 'applications/jupyterLab.yml'
Expand Down
7 changes: 7 additions & 0 deletions applications/deepmd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: deepmd
shortName: deepmd
summary: DeePMD
defaultVersion: '2.0.2'
versions:
- version: '2.0.2'
isDefault: true
67 changes: 67 additions & 0 deletions assets/deepmd/dp_train_se_e2_r.j2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"model": {
"type_map": [
"O",
"H"
],
"descriptor": {
"type": "se_e2_r",
"sel": [
23,
46
],
"rcut_smth": 0.50,
"rcut": 5.00,
"neuron": [
5,
5,
5
],
"resnet_dt": false,
"seed": 1
},
"fitting_net": {
"neuron": [
60,
60,
60
],
"resnet_dt": true,
"seed": 1
}
},
"learning_rate": {
"type": "exp",
"decay_steps": 1000,
"start_lr": 0.005,
"stop_lr": 3.51e-6
},
"loss": {
"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
},
"training": {
"training_data": {
"systems": [
"./training/"
],
"batch_size": "auto"
},
"validation_data": {
"systems": [
"./validation/"
],
"batch_size": "auto"
},
"numb_steps": 301,
"seed": 1,
"disp_file": "lcurve.out",
"disp_freq": 10,
"numb_test": 1,
"save_freq": 100
}
}
23 changes: 23 additions & 0 deletions assets/deepmd/espresso_cp_to_deepmd.j2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import dpdata
import numpy as np

# https://docs.deepmodeling.com/projects/dpdata/en/master/formats/QECPTrajFormat.html
data = dpdata.LabeledSystem("cp", fmt="qe/cp/traj")
print("Dataset contains total {0} frames".format(len(data)))

# randomly choose 20% index for validation_data
size = len(data)
size_validation = round(size * 0.2)

index_validation = np.random.choice(size, size=size_validation, replace=False)
index_training = list(set(range(size)) - set(index_validation))

data_training = data.sub_system(index_training)
data_validation = data.sub_system(index_validation)

print("Using {0} frames as training set".format(len(data_training)))
print("Using {0} frames as validation set".format(len(data_validation)))

# save training and validation sets
data_training.to_deepmd_npy("./training")
data_validation.to_deepmd_npy("./validation")
10 changes: 10 additions & 0 deletions assets/deepmd/espresso_to_lammps_structure.j2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import dpdata

# load cp data files
# https://docs.deepmodeling.com/projects/dpdata/en/master/formats/QECPTrajFormat.html
system = dpdata.LabeledSystem("cp", fmt="qe/cp/traj")

# convert dpdata to lammps format
# below procedure will convert input QE structure to lammps format, user may
# want to generate supercell or other complex structure for lammps calculation
system.to_lmp("system.lmp")
25 changes: 25 additions & 0 deletions assets/deepmd/in.lammps
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# LAMMPS input, deepmd-kit version. Built from bulk water calculation.

units metal
boundary p p p
atom_style atomic

neighbor 2.0 bin
neigh_modify every 10 delay 0 check no

read_data system.lmp
mass 1 16
mass 2 2

pair_style deepmd ./graph.pb
pair_coeff * *

velocity all create 330.0 23456789

fix 1 all nvt temp 330.0 330.0 0.5
timestep 0.0005
thermo_style custom step pe ke etotal temp press vol
thermo 100
dump 1 all custom 100 system.dump id type x y z

run 100
3 changes: 3 additions & 0 deletions assets/espresso/cp.j2.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
electron_dynamics = 'verlet'
electron_velocities = 'zero'
emass = {{ dynamics.electronMass }}
!! consider the below parameters if orthogonalization fails
! orthogonalization = 'ortho'
! ortho_eps = 1d-11
/
&IONS
ion_dynamics = 'verlet'
Expand Down
13 changes: 13 additions & 0 deletions executables/deepmd/dp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
isDefault: false
monitors:
- standard_output
results: []
flavors:
dp_train_se_e2_r:
input:
- name: dp_train_se_e2_r.json
results: []
monitors:
- standard_output
applicationName: deepmd
executableName: dp # dp train dp_train_se_e2_r.json && dp freeze -o graph.pb
13 changes: 13 additions & 0 deletions executables/deepmd/lmp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
isDefault: false
monitors:
- standard_output
results: []
flavors:
lammps_md:
input:
- name: in.lammps
results: []
monitors:
- standard_output
applicationName: deepmd
executableName: lmp # mpirun -np $NP lmp -in in.lammps
24 changes: 24 additions & 0 deletions executables/deepmd/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
isDefault: true
monitors:
- standard_output
results: []
flavors:
espresso_cp_to_deepmd:
isDefault: true
input:
- name: espresso_cp_to_deepmd.py
results: []
monitors:
- standard_output
applicationName: deepmd
executableName: python

espresso_to_lammps_structure:
isDefault: false
input:
- name: espresso_to_lammps_structure.py
results: []
monitors:
- standard_output
applicationName: deepmd
executableName: python
1 change: 1 addition & 0 deletions executables/espresso/cp.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ monitors:
results: []
flavors:
cp:
isDefault: true
input:
- name: cp.in
results: []
Expand Down
4 changes: 4 additions & 0 deletions executables/tree.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
deepmd:
dp: !include 'executables/deepmd/dp.yml'
lmp: !include 'executables/deepmd/lmp.yml'
python: !include 'executables/deepmd/python.yml'
espresso:
average.x: !include 'executables/espresso/average.x.yml'
bands.x: !include 'executables/espresso/bands.x.yml'
Expand Down
2 changes: 1 addition & 1 deletion src/js/data/application_data.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/js/data/templates.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/js/data/tree.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const allApplications = [
"espresso",
"jupyterLab",
"exabyteml",
"deepmd",
"nwchem",
"python",
"shell",
Expand Down
5 changes: 5 additions & 0 deletions templates/deepmd/dp_create_lmp_structure.py.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- content: !readFile 'assets/deepmd/espresso_to_lammps_structure.j2.py'
name: espresso_to_lammps_structure.py
contextProviders: []
applicationName: deepmd
executableName: python
5 changes: 5 additions & 0 deletions templates/deepmd/dp_lmp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- content: !readFile 'assets/deepmd/in.lammps'
name: in.lammps
contextProviders: []
applicationName: deepmd
executableName: lmp
5 changes: 5 additions & 0 deletions templates/deepmd/dp_prepare.py.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- content: !readFile 'assets/deepmd/espresso_cp_to_deepmd.j2.py'
name: espresso_cp_to_deepmd.py
contextProviders: []
applicationName: deepmd
executableName: python
5 changes: 5 additions & 0 deletions templates/deepmd/dp_train.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- content: !readFile 'assets/deepmd/dp_train_se_e2_r.j2.json'
name: dp_train_se_e2_r.json
contextProviders: []
applicationName: deepmd
executableName: dp
6 changes: 6 additions & 0 deletions templates/templates.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
!flatten
# deepmd
- !include 'templates/deepmd/dp_create_lmp_structure.py.yml'
- !include 'templates/deepmd/dp_lmp.yml'
- !include 'templates/deepmd/dp_prepare.py.yml'
- !include 'templates/deepmd/dp_train.yml'
# espresso
- !include 'templates/espresso/average.x.yml'
- !include 'templates/espresso/bands.x.yml'
- !include 'templates/espresso/cp.x.yml'
Expand Down
12 changes: 12 additions & 0 deletions tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ describe("assets for all executables", () => {
templates = getAllAppTemplates();
});

it("exists at least 1 asset for each tree entry for deepmd tree", () => {
const tree = APP_TREE.deepmd;

Object.keys(tree).forEach((treeItemName) => {
const treeItemTemplates = templates.filter(
(template) => template.executableName === treeItemName,
);

assert(treeItemTemplates.length > 0);
});
});

it("exists at least 1 asset for each tree entry for espresso tree", () => {
const tree = APP_TREE.espresso;

Expand Down
Loading