# GeoDiff: a Geometric Diffusion Model for Molecular Conformation Generation [](https://github.com/MinkaiXu/GeoDiff/blob/main/LICENSE) [[OpenReview](https://openreview.net/forum?id=PzcvxEMzvQC)] [[arXiv](https://arxiv.org/abs/2203.02923)] [[Code](https://github.com/MinkaiXu/GeoDiff)] The official implementation of GeoDiff: A Geometric Diffusion Model for Molecular Conformation Generation (ICLR 2022 **Oral Presentation [54/3391]**).  ## Environments ### Install via Conda (Recommended) ```bash # Clone the environment conda env create -f env.yml # Activate the environment conda activate geodiff # Install PyG conda install pytorch-geometric=1.7.2=py37_torch_1.8.0_cu102 -c rusty1s -c conda-forge ``` ## Dataset ### Offical Dataset The offical raw GEOM dataset is avaiable [[here]](https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/JNGTDF). ### Preprocessed dataset We provide the preprocessed datasets (GEOM) in this [[google drive folder]](https://drive.google.com/drive/folders/1b0kNBtck9VNrLRZxg6mckyVUpJA5rBHh?usp=sharing). After downleading the dataset, it should be put into the folder path as specified in the `dataset` variable of config files `./configs/*.yml`. ### Prepare your own GEOM dataset from scratch (optional) You can also download origianl GEOM full dataset and prepare your own data split. A guide is available at previous work ConfGF's [[github page]](https://github.com/DeepGraphLearning/ConfGF#prepare-your-own-geom-dataset-from-scratch-optional). ## Training All hyper-parameters and training details are provided in config files (`./configs/*.yml`), and free feel to tune these parameters. You can train the model with the following commands: ```bash # Default settings python train.py ./config/qm9_default.yml python train.py ./config/drugs_default.yml # An ablation setting with fewer timesteps, as described in Appendix D.2. python train.py ./config/drugs_1k_default.yml ``` The model checkpoints, configuration yaml file as well as training log will be saved into a directory specified by `--logdir` in `train.py`. ## Generation We provide the checkpoints of two trained models, i.e., `qm9_default` and `drugs_default` in the [[google drive folder]](https://drive.google.com/drive/folders/1b0kNBtck9VNrLRZxg6mckyVUpJA5rBHh?usp=sharing). Note that, please put the checkpoints `*.pt` into paths like `${log}/${model}/checkpoints/`, and also put corresponding configuration file `*.yml` into the upper level directory `${log}/${model}/`. Attention: if you want to use pretrained models, please use the code at the [`pretrain`](https://github.com/MinkaiXu/GeoDiff/tree/pretrain) branch, which is the vanilla codebase for reproducing the results with our pretrained models. We recently notice some issue of the codebase and update it, making the `main` branch not compatible well with the previous checkpoints. You can generate conformations for entire or part of test sets by: ```bash python test.py ${log}/${model}/checkpoints/${iter}.pt \ --start_idx 800 --end_idx 1000 ``` Here `start_idx` and `end_idx` indicate the range of the test set that we want to use. All hyper-parameters related to sampling can be set in `test.py` files. Specifically, for testing qm9 model, you could add the additional arg `--w_global 0.3`, which empirically shows slightly better results. Conformations of some drug-like molecules generated by GeoDiff are provided below.