Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dc5de0d
fixed two bugs for otf ocp and otf mdl cases
vxfung Sep 5, 2023
417e920
save log to file
vxfung Sep 6, 2023
f8c2595
Update config.yml
vxfung Sep 11, 2023
d9c8f86
Generate node representations on the fly
itsgt Sep 12, 2023
20885e1
Don't try to call at the beginning of the function
itsgt Sep 12, 2023
5e22613
Fix typo
itsgt Sep 12, 2023
0d70b77
Use built-in torch one hot generation
itsgt Sep 12, 2023
b324f1a
fixed timestamp bug, added option for num_workers, added option for o…
vxfung Sep 13, 2023
b923f63
Merge branch 'main' into fast_node_reps
itsgt Sep 13, 2023
5263e61
Shouldn't need to send to the same device
itsgt Sep 14, 2023
3b6aa20
Merge pull request #44 from Fung-Lab/fast_node_reps
vxfung Sep 14, 2023
3ff7112
added old node rep function back, renamed functions
vxfung Sep 14, 2023
ac0031e
added options for model saving
vxfung Sep 14, 2023
9b3dddf
option to load dataset on gpu
vxfung Sep 14, 2023
ca689f3
minor fixes
vxfung Sep 14, 2023
ca3afb2
minor changes for unit tests
vxfung Sep 14, 2023
54f79ae
additional bugfixes
vxfung Sep 14, 2023
d4f3c5b
added option to compute edge indices, attributes, and node attributes…
vxfung Sep 14, 2023
82342c6
fixed bug with otf GaussianSmearing having inconsistent values; fixed…
vxfung Sep 18, 2023
362e33d
removed extra code
vxfung Sep 18, 2023
346cbf3
Import node representation
itsgt Sep 19, 2023
29d9774
Import node_rep_one_hot for schnet
itsgt Sep 19, 2023
fcda46a
Merge pull request #48 from Fung-Lab/fix-torchmd-import
vxfung Sep 19, 2023
5a52ee2
Upload necessary files
qzheng75 Sep 20, 2023
b377baf
Add prediction module in trainer
qzheng75 Sep 20, 2023
bc7f794
Merge pull request #49 from Fung-Lab/Calculator_test
vxfung Sep 21, 2023
453a2a6
Update __init__.py
vxfung Sep 21, 2023
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
49 changes: 34 additions & 15 deletions configs/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ task:
load_training_state: False
# Path to the checkpoint.pt file
checkpoint_path:
# E.g. ["train", "val", "test"]
# Whether to write predictions to csv file. E.g. ["train", "val", "test"]
write_output: [train, val, test]
# Frequency of writing to file; 0 denotes writing only at the end, 1 denotes writing every time
output_frequency: 0
# Frequency of saving model .pt file; 0 denotes saving only at the end, 1 denotes saving every time, -1 denotes never saving; this controls both checkpoint and best_checkpoint
model_save_frequency: 0
# Specify if labels are provided for the predict task
# labels: True
# Use amp mixed precision
use_amp: True

model:
Expand All @@ -34,9 +39,13 @@ model:
batch_track_stats: True
act: relu
dropout_rate: 0.0
# Compute edge features on the fly
otf_edge: False
# compute gradients w.r.t to positions and cell, requires otf_edge=True
# Compute edge indices on the fly in the model forward
otf_edge_index: False
# Compute edge attributes on the fly in the model forward
otf_edge_attr: False
# Compute node attributes on the fly in the model forward
otf_node_attr: False
# compute gradients w.r.t to positions and cell, requires otf_edge_attr=True
gradient: False

optim:
Expand All @@ -47,8 +56,8 @@ optim:
loss:
loss_type: TorchLossWrapper
loss_args: {loss_fn: l1_loss}
clip_grad_norm: 10

# gradient clipping value
clip_grad_norm: 10
batch_size: 100
optimizer:
optimizer_type: AdamW
Expand All @@ -63,6 +72,7 @@ optim:

dataset:
name: test_data
# Whether the data has already been processed and a data.pt file is present from a previous run
processed: False
# Path to data files - this can either be in the form of a string denoting a single path or a dictionary of {train: train_path, val: val_path, test: test_path, predict: predict_path}
src: data/test_data/data_graph_scalar.json
Expand All @@ -71,7 +81,7 @@ dataset:
target_path:
# Path to save processed data.pt file
pt_path: data/
# Either "node" or "graph"
# Either "node" or "graph" level
prediction_level: graph

transforms:
Expand All @@ -81,12 +91,11 @@ dataset:
# For example, an index: 0 (default) will use the first entry in the target vector
# if all values are to be predicted simultaneously, then specify index: -1
index: -1
otf: True # Optional parameter, default is False
otf_transform: True # Optional parameter, default is True
# Format of data files (limit to those supported by ASE: https://wiki.fysik.dtu.dk/ase/ase/io/io.html)
data_format: json
# E.g. additional_attributes: [forces, stress]
# specify if additional attributes to be loaded into the dataset from the .json file; e.g. additional_attributes: [forces, stress]
additional_attributes:
#additional_attributes:
# Print out processing info
verbose: True
# Index of target column in targets.csv
Expand All @@ -99,16 +108,26 @@ dataset:
# determine if edge attributes are computed during processing, if false, then they need to be computed on the fly
preprocess_edge_features: True
# determine if node attributes are computed during processing, if false, then they need to be computed on the fly
preprocess_nodes: True
preprocess_node_features: True
# distance cutoff to determine if two atoms are connected by an edge
cutoff_radius : 8.0
# maximum number of neighbors to consider (usually an arbitrarily high number to consider all neighbors)
n_neighbors : 250
# number of pbc offsets to consider when determining neighbors (usually not changed)
num_offsets: 2
edge_steps : 50
# dimension of node attributes
node_dim : 100
# dimension of edge attributes
edge_dim : 50
# whether or not to add self-loops
self_loop: True
# Method of obtaining atom dictionary: available: (onehot)
node_representation: onehot
all_neighbors: True
# Ratios for train/val/test split out of a total of less than 1
# Number of workers for dataloader, see https://pytorch.org/docs/stable/data.html
num_workers: 0
# Where the dataset is loaded; either "cpu" or "cuda"
dataset_device: cpu
# Ratios for train/val/test split out of a total of less than 1 (0.8 corresponds to 80% of the data)
train_ratio: 0.8
val_ratio: 0.05
test_ratio: 0.15
test_ratio: 0.15
130 changes: 130 additions & 0 deletions configs/config_calculator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
trainer: matdeeplearn.trainers.PropertyTrainer

task:
run_mode: train
identifier: my_train_job
parallel: False
# If seed is not set, then it will be random every time
seed: 12345678
# Defaults to run directory if not specified
save_dir:
# continue from a previous job
continue_job: False
# spefcify if the training state is loaded: epochs, learning rate, etc
load_training_state: False
# Path to the checkpoint.pt file. The model used in the calculator will load parameters from this file.
checkpoint_path: results/2023-09-20-16-22-38-738-my_train_job/checkpoint/best_checkpoint.pt
# E.g. ["train", "val", "test"]
write_output: [train, val, test]
# Specify if labels are provided for the predict task
# labels: True
use_amp: True

model:
name: CGCNN
# model attributes
dim1: 100
dim2: 150
pre_fc_count: 1
gc_count: 4
post_fc_count: 3
pool: global_add_pool
pool_order: early
batch_norm: False
batch_track_stats: True
act: silu
dropout_rate: 0.0
# Compute edge indices on the fly in the model forward
otf_edge_index: True
# Compute edge attributes on the fly in the model forward
otf_edge_attr: True
# Compute node attributes on the fly in the model forward
otf_node_attr: True
# compute gradients w.r.t to positions and cell, requires otf_edge_attr=True
gradient: True

optim:
max_epochs: 40
max_checkpoint_epochs: 0
lr: 0.002
# Either custom or from torch.nn.functional library. If from torch, loss_type is TorchLossWrapper
loss:
loss_type: TorchLossWrapper
loss_args: {loss_fn: l1_loss}
# gradient clipping value
clip_grad_norm: 10
batch_size: 100
optimizer:
optimizer_type: AdamW
optimizer_args: {}
scheduler:
scheduler_type: ReduceLROnPlateau
scheduler_args: {mode: min, factor: 0.8, patience: 10, min_lr: 0.00001, threshold: 0.0002}
#Training print out frequency (print per n number of epochs)
verbosity: 5
# tdqm progress bar per batch in the epoch
batch_tqdm: False

dataset:
name: test_data
# Whether the data has already been processed and a data.pt file is present from a previous run
processed: False
# Path to data files - this can either be in the form of a string denoting a single path or a dictionary of {train: train_path, val: val_path, test: test_path, predict: predict_path}
src: data/force_data/data.json
# Path to target file within data_path - this can either be in the form of a string denoting a single path or a dictionary of {train: train_path, val: val_path, test: test_path} or left blank when the dataset is a single json file
# Example: target_path: "data/raw_graph_scalar/targets.csv"
target_path:
# Path to save processed data.pt file
pt_path: data/force_data/
# Either "node" or "graph" level
prediction_level: graph

transforms:
- name: GetY
args:
# index specifies the index of a target vector to predict, which is useful when there are multiple property labels for a single dataset
# For example, an index: 0 (default) will use the first entry in the target vector
# if all values are to be predicted simultaneously, then specify index: -1
index: -1
otf_transform: True # Optional parameter, default is True
# Format of data files (limit to those supported by ASE: https://wiki.fysik.dtu.dk/ase/ase/io/io.html)
data_format: json
# specify if additional attributes to be loaded into the dataset from the .json file; e.g. additional_attributes: [forces, stress]
additional_attributes:
# Print out processing info
verbose: True
# Index of target column in targets.csv
# graph specific settings
preprocess_params:
# one of mdl (minimum image convention), ocp (all neighbors included)
edge_calc_method: ocp
# determine if edges are computed, if false, then they need to be computed on the fly
preprocess_edges: False
# determine if edge attributes are computed during processing, if false, then they need to be computed on the fly
preprocess_edge_features: False
# determine if node attributes are computed during processing, if false, then they need to be computed on the fly
preprocess_node_features: False
# distance cutoff to determine if two atoms are connected by an edge
cutoff_radius : 8.0
# maximum number of neighbors to consider (usually an arbitrarily high number to consider all neighbors)
n_neighbors : 250
# number of pbc offsets to consider when determining neighbors (usually not changed)
num_offsets: 2
# dimension of node attributes
node_dim : 100
# dimension of edge attributes
edge_dim : 50
# whether or not to add self-loops
self_loop: True
# Method of obtaining atom dictionary: available: (onehot)
node_representation: onehot
all_neighbors: True

# Number of workers for dataloader, see https://pytorch.org/docs/stable/data.html
num_workers: 0
# Where the dataset is loaded; either "cpu" or "cuda"
dataset_device: cpu
# Ratios for train/val/test split out of a total of less than 1 (0.8 corresponds to 80% of the data)
train_ratio: 0.9
val_ratio: 0.05
test_ratio: 0.05
40 changes: 27 additions & 13 deletions configs/config_forces.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ task:
checkpoint_path:
# E.g. [train, val, test]
write_output: [val, test]
# Frequency of writing to file; 0 denotes writing only at the end, 1 denotes writing every time
output_frequency: 1
# Frequency of saving model .pt file; 0 denotes saving only at the end, 1 denotes saving every time, -1 denotes never saving; this controls both checkpoint and best_checkpoint
model_save_frequency: 1
# Specify if labels are provided for the predict task
# labels: True
use_amp: False
Expand All @@ -34,15 +38,19 @@ model:
batch_track_stats: True
act: silu
dropout_rate: 0.0
# Compute edge features on the fly
otf_edge: True
# compute gradients w.r.t to positions and cell, requires otf_edge=True
# Compute edge indices on the fly in the model forward
otf_edge_index: True
# Compute edge attributes on the fly in the model forward
otf_edge_attr: True
# Compute node attributes on the fly in the model forward
otf_node_attr: False
# compute gradients w.r.t to positions and cell, requires otf_edge_attr=True
gradient: True

optim:
max_epochs: 40
max_epochs: 400
max_checkpoint_epochs: 0
lr: 0.002
lr: 0.001
# Either custom or from torch.nn.functional library. If from torch, loss_type is TorchLossWrapper
loss:
#loss_type: "TorchLossWrapper"
Expand All @@ -69,12 +77,12 @@ dataset:
name: test_data
processed: False
# Path to data files - this can either be in the form of a string denoting a single path or a dictionary of {train: train_path, val: val_path, test: test_path, predict: predict_path}
src: /global/cfs/projectdirs/m3641/Shared/Materials_datasets/MP_data_forces/raw/data.json
src: data/force_data/data.json
# Path to target file within data_path - this can either be in the form of a string denoting a single path or a dictionary of {train: train_path, val: val_path, test: test_path} or left blank when the dataset is a single json file
# Example: target_path: "data/test_data/raw_graph_scalar/targets.csv"
target_path:
# Path to save processed data.pt file
pt_path: data/
pt_path: data/force_data/
# Either "node" or "graph"
prediction_level: graph

Expand Down Expand Up @@ -103,18 +111,24 @@ dataset:
# determine if edge attributes are computed during processing, if false, then they need to be computed on the fly
preprocess_edge_features: False
# determine if node attributes are computed during processing, if false, then they need to be computed on the fly
preprocess_nodes: True
preprocess_node_features: True
cutoff_radius : 8.0
n_neighbors : 250
num_offsets: 2
edge_steps : 50
# dimension of node attributes
node_dim : 100
# dimension of edge attributes
edge_dim : 50
self_loop: True
# Method of obtaining atom dictionary: available: (onehot)
node_representation: onehot
all_neighbors: True

# Number of workers for dataloader, see https://pytorch.org/docs/stable/data.html
num_workers: 0
# Where the dataset is loaded; either "cpu" or "cuda"
dataset_device: cpu
# Ratios for train/val/test split out of a total of less than 1
train_ratio: 0.8
train_ratio: 0.9
val_ratio: 0.05
test_ratio: 0.015


test_ratio: 0.05
Loading