-
Notifications
You must be signed in to change notification settings - Fork 28
【Hackathon 10th Spring No.18】SchNet模型复现 #248
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
Open
decade-afk
wants to merge
3
commits into
PaddlePaddle:develop
Choose a base branch
from
decade-afk:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,187 @@ | ||
| # SchNet | ||
|
|
||
| [SchNet: A continuous-filter convolutional neural network for modeling quantum interactions](https://arxiv.org/abs/1706.08566) | ||
|
|
||
| ## Abstract | ||
|
|
||
| SchNet is an end-to-end continuous-filter convolutional neural network for atomistic systems. It models quantum interactions directly from atomic numbers and coordinates, using distance-based filters with smooth cutoffs and atom-wise readout. In PaddleMaterials, this implementation targets paper-style small-molecule regression benchmarks and keeps training/inference interfaces consistent with the `interatomic_potentials` suite. | ||
|
|
||
| ## Datasets | ||
|
|
||
| This SchNet case currently covers: | ||
|
|
||
| - QM9 (`U0`) with paper-aligned split setup | ||
| - MD17 (ethanol example, energy + force supervision) | ||
| - ISO17 (reference to test_other generalization) | ||
|
|
||
| Dataset sources: | ||
|
|
||
| - **QM9 (small molecules)**: | ||
| - Original source: https://figshare.com/ndownloader/files/3195389 | ||
| - PaddleMaterials packaged mirror (used by SchNet config): | ||
| `https://paddle-org.bj.bcebos.com/paddlematerials/datasets/qm9/qm9.tar.gz` | ||
| - PaddleMaterials raw mirror (fallback / non-packaged path): | ||
| `https://paddle-org.bj.bcebos.com/paddlematerials/datasets/qm9/dsgdb9nsd.xyz.tar.bz2` | ||
| - **MD17 / rMD17 (small molecules, energy + force)**: | ||
| - Original source: https://www.quantum-machine.org/datasets/ | ||
| - PaddleMaterials package mirror: | ||
| `https://paddle-org.bj.bcebos.com/paddlematerials/datasets/MD17/md17.tar.gz` | ||
| - Recommended format in this repo: `*.npz` with keys `R/Z/E/F` | ||
| - **ISO17 (isomer generalization benchmark)**: | ||
| - Original source: https://www.quantum-machine.org/datasets/ | ||
| - PaddleMaterials package mirror: | ||
| `https://paddle-org.bj.bcebos.com/paddlematerials/datasets/ISO17/iso17.tar.gz` | ||
| - Recommended format in this repo: `iso17.npz` with keys `R/Z/E` and optional `isomer_ids` | ||
|
|
||
| ## Models | ||
|
|
||
| The Paddle implementation follows the SchNet interaction design: | ||
|
|
||
| - Gaussian RBF expansion for inter-atomic distances | ||
| - Cosine cutoff for locality | ||
| - Continuous-filter interaction blocks with residual updates | ||
| - Atom-wise readout for molecular properties | ||
|
|
||
| Config files: | ||
|
|
||
| - `schnet_qm9_lumo.yaml`: paper-aligned QM9 `U0` case (filename kept for compatibility) | ||
| - `schnet_md17_ethanol.yaml`: MD17 ethanol energy-force joint training | ||
| - `schnet_iso17.yaml`: ISO17 reference->test_other setting | ||
|
|
||
| Training hyperparameters in these SchNet configs are aligned to | ||
| SchNet-master/paper style (instead of current schnetpack defaults): | ||
|
|
||
| - Optimizer: `Adam` | ||
| - LR schedule: exponential decay (`lr=1e-3`, decay steps `100000`, gamma `0.96`) | ||
| - Global-step stop: `max_iter=5000000` | ||
| - Step-based validation/save: `eval_interval_steps=5000`, `save_interval_steps=50000` | ||
| - QM9 train batch: `32`, val/test batch: `100` | ||
| - QM9 split file: `split_qm9_110k_1k_seed42.npz` (`num_train=110000`, `num_val=1000`) | ||
|
|
||
| ## Results | ||
|
|
||
| <table> | ||
| <head> | ||
| <tr> | ||
| <th nowrap="nowrap">Model Name</th> | ||
| <th nowrap="nowrap">Dataset</th> | ||
| <th nowrap="nowrap">Task</th> | ||
| <th nowrap="nowrap">Metric</th> | ||
| <th nowrap="nowrap">GPUs</th> | ||
| <th nowrap="nowrap">Training time</th> | ||
| <th nowrap="nowrap">Config</th> | ||
| <th nowrap="nowrap">Checkpoint | Log</th> | ||
| </tr> | ||
| </head> | ||
| <body> | ||
| <tr> | ||
| <td nowrap="nowrap">schnet_qm9_u0</td> | ||
| <td nowrap="nowrap">QM9</td> | ||
| <td nowrap="nowrap">U0 regression</td> | ||
| <td nowrap="nowrap">MAE: to_be_filled</td> | ||
| <td nowrap="nowrap">~</td> | ||
| <td nowrap="nowrap">~</td> | ||
| <td nowrap="nowrap"><a href="schnet_qm9_lumo.yaml">schnet_qm9_lumo.yaml</a></td> | ||
| <td nowrap="nowrap"><a href="to_be_filled">checkpoint | log</a></td> | ||
| </tr> | ||
| <tr> | ||
| <td nowrap="nowrap">schnet_md17_ethanol</td> | ||
| <td nowrap="nowrap">MD17</td> | ||
| <td nowrap="nowrap">Energy + Force</td> | ||
| <td nowrap="nowrap">MAE: to_be_filled</td> | ||
| <td nowrap="nowrap">~</td> | ||
| <td nowrap="nowrap">~</td> | ||
| <td nowrap="nowrap"><a href="schnet_md17_ethanol.yaml">schnet_md17_ethanol.yaml</a></td> | ||
| <td nowrap="nowrap"><a href="to_be_filled">checkpoint | log</a></td> | ||
| </tr> | ||
| <tr> | ||
| <td nowrap="nowrap">schnet_iso17</td> | ||
| <td nowrap="nowrap">ISO17</td> | ||
| <td nowrap="nowrap">Energy regression</td> | ||
| <td nowrap="nowrap">MAE: to_be_filled</td> | ||
| <td nowrap="nowrap">~</td> | ||
| <td nowrap="nowrap">~</td> | ||
| <td nowrap="nowrap"><a href="schnet_iso17.yaml">schnet_iso17.yaml</a></td> | ||
| <td nowrap="nowrap"><a href="to_be_filled">checkpoint | log</a></td> | ||
| </tr> | ||
| </body> | ||
| </table> | ||
|
|
||
| ## Alignment Checklist | ||
|
|
||
| Use the following acceptance criteria during migration: | ||
|
|
||
| - Single-card forward alignment: logits diff around `1e-4` (generative models `1e-6`) | ||
| - Backward alignment: after at least 2 epochs, train loss trend is consistent | ||
| - Supervised task metric error: within `1%` | ||
|
|
||
| Quick local checks: | ||
|
|
||
| ```bash | ||
| python test/run_schnet_torch_alignment.py | ||
| python test/run_schnet_data_metric_alignment.py | ||
| ``` | ||
|
|
||
| Dataset preparation from original/torch sources: | ||
|
|
||
| ```bash | ||
| python test/prepare_schnet_paper_datasets.py --data_root ./data --tasks all | ||
| ``` | ||
|
|
||
| ## Resource Links (Baidu) | ||
|
|
||
| Per PaddleMaterials delivery requirement, fill cloud links here after PR/WeChat handoff: | ||
|
|
||
| - Dataset package links: | ||
| - QM9: `https://paddle-org.bj.bcebos.com/paddlematerials/datasets/qm9/qm9.tar.gz` | ||
| - MD17: `https://paddle-org.bj.bcebos.com/paddlematerials/datasets/MD17/md17.tar.gz` | ||
| - ISO17: `https://paddle-org.bj.bcebos.com/paddlematerials/datasets/ISO17/iso17.tar.gz` | ||
| - Pretrained model link (Baidu): `to_be_filled` | ||
| - Training/inference raw log link (Baidu): `to_be_filled` | ||
|
|
||
| ### Training | ||
|
|
||
| ```bash | ||
| # multi-gpu training (QM9) | ||
| python -m paddle.distributed.launch --gpus="0,1,2,3" interatomic_potentials/train.py -c interatomic_potentials/configs/schnet/schnet_qm9_lumo.yaml | ||
|
|
||
| # single-gpu training (QM9) | ||
| python interatomic_potentials/train.py -c interatomic_potentials/configs/schnet/schnet_qm9_lumo.yaml | ||
|
|
||
| # MD17 (ethanol) | ||
| python interatomic_potentials/train.py -c interatomic_potentials/configs/schnet/schnet_md17_ethanol.yaml | ||
|
|
||
| # ISO17 | ||
| python interatomic_potentials/train.py -c interatomic_potentials/configs/schnet/schnet_iso17.yaml | ||
| ``` | ||
|
|
||
| ### Validation | ||
|
|
||
| ```bash | ||
| python interatomic_potentials/train.py -c interatomic_potentials/configs/schnet/schnet_qm9_lumo.yaml Global.do_eval=True Global.do_train=False Global.do_test=False Trainer.pretrained_model_path='your checkpoint path(*.pdparams)' | ||
| ``` | ||
|
|
||
| ### Testing | ||
|
|
||
| ```bash | ||
| python interatomic_potentials/train.py -c interatomic_potentials/configs/schnet/schnet_qm9_lumo.yaml Global.do_test=True Global.do_train=False Global.do_eval=False Trainer.pretrained_model_path='your checkpoint path(*.pdparams)' | ||
| ``` | ||
|
|
||
| ### Prediction | ||
|
|
||
| ```bash | ||
| # Mode 1: load from local config/checkpoint | ||
| python interatomic_potentials/predict.py --config_path='interatomic_potentials/configs/schnet/schnet_qm9_lumo.yaml' --checkpoint_path='your checkpoint path(*.pdparams)' --cif_file_path='./interatomic_potentials/example_data/cifs/' | ||
| ``` | ||
|
|
||
| ## Citation | ||
|
|
||
| ``` | ||
| @inproceedings{schutt2017schnet, | ||
| title={SchNet: A continuous-filter convolutional neural network for modeling quantum interactions}, | ||
| author={Sch{\"u}tt, Kristof T and Kindermans, Pieter-Jan and Sauceda, Felix A and Chmiela, Stefan and Tkatchenko, Alexandre and M{\"u}ller, Klaus-Robert}, | ||
| booktitle={Advances in Neural Information Processing Systems}, | ||
| volume={30}, | ||
| year={2017} | ||
| } | ||
| ``` |
141 changes: 141 additions & 0 deletions
141
interatomic_potentials/configs/schnet/schnet_iso17.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| Global: | ||
| do_train: True | ||
| do_eval: True | ||
| do_test: True | ||
|
|
||
| label_names: ["energy"] | ||
| graph_converter: | ||
| __class_name__: FindPointsInSpheres | ||
| __init_params__: | ||
| # Paper-priority setting. | ||
| cutoff: 5.0 | ||
| pbc: [0, 0, 0] | ||
| num_cpus: 4 | ||
|
|
||
|
|
||
| Trainer: | ||
| # Paper + SchNet-master aligned optimizer style. | ||
| max_epochs: 100000 | ||
| # SchNet-master style stop/eval/save by global step. | ||
| max_iter: 5000000 | ||
| eval_interval_steps: 5000 | ||
| save_interval_steps: 50000 | ||
| seed: 42 | ||
| output_dir: ./output/schnet_iso17_paper | ||
| save_freq: 100 | ||
| log_freq: 20 | ||
| start_eval_epoch: 1 | ||
| eval_freq: 1 | ||
| pretrained_model_path: null | ||
| pretrained_weight_name: null | ||
| resume_from_checkpoint: null | ||
| use_amp: False | ||
| amp_level: "O1" | ||
| eval_with_no_grad: True | ||
| gradient_accumulation_steps: 1 | ||
| best_metric_indicator: "eval_metric" | ||
| name_for_best_metric: "energy" | ||
| greater_is_better: False | ||
| compute_metric_during_train: True | ||
| metric_strategy_during_eval: "epoch" | ||
| use_visualdl: False | ||
| use_wandb: False | ||
| use_tensorboard: False | ||
|
|
||
|
|
||
| Model: | ||
| __class_name__: SchNet | ||
| __init_params__: | ||
| # Paper-priority setting. | ||
| n_atom_basis: 128 | ||
| n_interactions: 6 | ||
| n_filters: 128 | ||
| cutoff: 5.0 | ||
| n_rbf: 20 | ||
| max_z: 100 | ||
| property_name: "energy" | ||
| readout: "sum" | ||
| data_mean: 0.0 | ||
| data_std: 1.0 | ||
| loss_type: "mse_loss" | ||
|
|
||
|
|
||
| Optimizer: | ||
| __class_name__: Adam | ||
| __init_params__: | ||
| lr: | ||
| __class_name__: ExponentialDecay | ||
| __init_params__: | ||
| learning_rate: 1e-3 | ||
| gamma: 0.96 | ||
| decay_steps: 100000 | ||
| by_epoch: False | ||
|
|
||
|
|
||
| Metric: | ||
| energy: | ||
| __class_name__: paddle.nn.L1Loss | ||
| __init_params__: {} | ||
|
|
||
|
|
||
| Dataset: | ||
| # Dataset package mirror (uploaded): | ||
| # https://paddle-org.bj.bcebos.com/paddlematerials/datasets/ISO17/iso17.tar.gz | ||
| train: | ||
| dataset: | ||
| __class_name__: ISO17Dataset | ||
| __init_params__: | ||
| path: "./data/iso17" | ||
| url: "https://paddle-org.bj.bcebos.com/paddlematerials/datasets/ISO17/iso17.tar.gz" | ||
| subset: "train" | ||
| split_file: "split_iso17_ref90_testother_seed42.npz" | ||
| property_names: ${Global.label_names} | ||
| build_graph_cfg: ${Global.graph_converter} | ||
| seed: 42 | ||
| sampler: | ||
| __class_name__: BatchSampler | ||
| __init_params__: | ||
| shuffle: True | ||
| drop_last: True | ||
| batch_size: 32 | ||
|
|
||
| val: | ||
| dataset: | ||
| __class_name__: ISO17Dataset | ||
| __init_params__: | ||
| path: "./data/iso17" | ||
| url: "https://paddle-org.bj.bcebos.com/paddlematerials/datasets/ISO17/iso17.tar.gz" | ||
| subset: "val" | ||
| split_file: "split_iso17_ref90_testother_seed42.npz" | ||
| property_names: ${Global.label_names} | ||
| build_graph_cfg: ${Global.graph_converter} | ||
| seed: 42 | ||
| sampler: | ||
| __class_name__: BatchSampler | ||
| __init_params__: | ||
| shuffle: False | ||
| drop_last: False | ||
| batch_size: 100 | ||
|
|
||
| test: | ||
| dataset: | ||
| __class_name__: ISO17Dataset | ||
| __init_params__: | ||
| path: "./data/iso17" | ||
| url: "https://paddle-org.bj.bcebos.com/paddlematerials/datasets/ISO17/iso17.tar.gz" | ||
| subset: "test" | ||
| split_file: "split_iso17_ref90_testother_seed42.npz" | ||
| property_names: ${Global.label_names} | ||
| build_graph_cfg: ${Global.graph_converter} | ||
| seed: 42 | ||
| sampler: | ||
| __class_name__: BatchSampler | ||
| __init_params__: | ||
| shuffle: False | ||
| drop_last: False | ||
| batch_size: 100 | ||
|
|
||
|
|
||
| Predict: | ||
| graph_converter: ${Global.graph_converter} | ||
| eval_with_no_grad: True |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
辛苦补充完整results表格