Skip to content

Commit

Permalink
fix some conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoRenaud committed Nov 24, 2023
2 parents 91958c1 + a1b4e11 commit 6505080
Show file tree
Hide file tree
Showing 126 changed files with 4,988 additions and 1,351 deletions.
21 changes: 14 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,33 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [3.7, 3.8]
version: [3.8]

steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.4.0
uses: styfle/cancel-workflow-action@0.12.0
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup conda
uses: s-weigand/setup-conda@v1
with:
update-conda: true
python-version: ${{ matrix.version }}
conda-channels: anaconda
- run: conda --version
- run: which python
- run: conda install rdkit mpi4py h5py==3.1.0 pytorch torchvision cpuonly -c pytorch -c conda-forge
- name: Install essential
run: |
sudo apt update
sudo apt install build-essential
- name: Install conda packages
run: |
conda install -c anaconda cmake
conda install rdkit mpi4py h5py pytorch==2.0.0 torchvision==0.15.0 cpuonly -c pytorch -c conda-forge
conda install -c conda-forge libstdcxx-ng
conda install -c anaconda gxx_linux-64
- name: Install the package
run: pip install .[test,hpc]
run: python -m pip install .[test,hpc]
env:
CONDA_PREFIX: /usr/share/miniconda

Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/draft-pdf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
on: [push]

jobs:
paper:
runs-on: ubuntu-latest
name: Paper Draft
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build draft PDF
uses: openjournals/openjournals-draft-action@master
with:
journal: joss
# This should be the path to the paper within your repo.
paper-path: paper/paper.md
- name: Upload
uses: actions/upload-artifact@v1
with:
name: paper
# This is the output path where Pandoc will write the compiled
# PDF. Note, this should be the same directory as the input
# paper.md
path: paper/paper.pdf
35 changes: 35 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"
# You can also specify other tool versions:
# nodejs: "20"
# rust: "1.70"
# golang: "1.20"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py
# You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs
# builder: "dirhtml"
# Fail on all warnings to avoid broken references
# fail_on_warning: true

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: docs/requirements.txt
20 changes: 20 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@
Change Log
##########

0.3.1 [Released]
*****************

Change
-------

* Support cc-pvdz orbitals (#151)
* Freeze Pytorch version (#151)
* Fix read the doc (#150)

0.3.0 [Released]
********************

* Support ADF2023 (#142)
* JOSS paper (#141)
* Fix bug in converting distance unit (#148)
* Hamiltonian Monte Carlo (#117)
* Jastrow kernels (#112)
* Backflow transformation (#115)

0.1.1 [Unreleased]
******************

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyy] [name of copyright owner]
Copyright 2022 Nicolas Renaud

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ Pytorch Implementation of Real Space Quantum Monte Carlo Simulations of Molecula
[![PyPI version](https://badge.fury.io/py/qmctorch.svg)](https://badge.fury.io/py/qmctorch)
[![Build Status](https://github.com/NLESC-JCER/QMCTorch/workflows/build/badge.svg)](https://github.com/NLESC-JCER/QMCTorch/actions)
[![Coverage Status](https://coveralls.io/repos/github/NLESC-JCER/QMCTorch/badge.svg?branch=master)](https://coveralls.io/github/NLESC-JCER/QMCTorch?branch=master)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/5d99212add2a4f0591adc6248fec258d)](https://www.codacy.com/manual/NicoRenaud/QMCTorch?utm_source=github.com&utm_medium=referral&utm_content=NLESC-JCER/QMCTorch&utm_campaign=Badge_Grade)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/1c52407422a7428083968833341b5945)](https://app.codacy.com/gh/NLESC-JCER/QMCTorch/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3780094.svg)](https://doi.org/10.5281/zenodo.3780094)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.05472/status.svg)](https://doi.org/10.21105/joss.05472)

## Installation

Expand All @@ -15,8 +16,4 @@ Clone the repository and install the code from source or use the Python package
`pip install qmctorch`

## Documentation
https://qmctorch.readthedocs.io/en/latest/intro.html


## Disclaimer
QMCTorch is currently under developmement and most likely won't behave as expected
https://qmctorch.readthedocs.io
2 changes: 1 addition & 1 deletion bin/qmctorch
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import os
import argparse


dist_solvers = ['SolverSlaterJastrowHorovod']
dist_solvers = ['SolverMPI']


def check_file(fname):
Expand Down
8 changes: 5 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
'sphinx.ext.mathjax',
'sphinx.ext.ifconfig',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode'
'sphinx.ext.viewcode',
'nbsphinx'
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -139,7 +140,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = 'en'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand All @@ -165,7 +166,7 @@
# html_theme = 'classic'

html_theme = 'sphinx_rtd_theme'
html_logo = "qmctorch_white.png"
html_logo = "./pics/qmctorch_white.png"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down Expand Up @@ -261,3 +262,4 @@

autoclass_content = 'init'
autodoc_member_order = 'bysource'
nbsphinx_allow_errors = True
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions docs/example/colab/google_collab.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"cells":[{"attachments":{},"cell_type":"markdown","metadata":{"colab_type":"text","id":"PA9WOB4zJfCu"},"source":["# Installation on Google Collab\n","To install `QMCTorch` copy the code from one of the 3 text cells below in a code cell and run that cell. "]},{"cell_type":"markdown","metadata":{"colab_type":"text","id":"6KLOhN_dGQ11"},"source":["## Install QMCTorch from Pypi Package manager\n","\n","```\n","! pip install qmctorch\n","```\n","\n"]},{"cell_type":"markdown","metadata":{"colab_type":"text","id":"Eb9wI3eOGfz1"},"source":["## Install QMCTorch from GitHub\n","```\n","from google.colab import drive\n","drive.mount('/content/gdrive')\n","% cd gdrive/My Drive/\n","! git clone https://github.com/NLESC-JCER/QMCTorch\n","% cd QMCTorch\n","! pip install -e .\n","% cd ../\n","```"]},{"cell_type":"markdown","metadata":{"colab_type":"text","id":"_VNw5sAeHC7M"},"source":["## Pull latest code from Github\n","```\n","from google.colab import drive\n","drive.mount('/content/gdrive')\n","% cd gdrive/My Drive/QMCTorch\n","! git pull origin master\n","! pip install -e .\n","% cd ../\n","```"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":671},"colab_type":"code","executionInfo":{"elapsed":9770,"status":"ok","timestamp":1588617088336,"user":{"displayName":"Nicolas Renaud","photoUrl":"","userId":"07120063468244602126"},"user_tz":-120},"id":"khGd1-ewHZWF","outputId":"674fbe9e-7817-4e11-cc91-cd508bda8107","vscode":{"languageId":"python"}},"outputs":[],"source":["# from google.colab import drive\n","# drive.mount('/content/gdrive')\n","# % cd gdrive/My Drive/QMCTorch\n","# ! git pull origin master\n","# ! pip install -e .\n","# % cd .."]},{"cell_type":"markdown","metadata":{"colab_type":"text","id":"MGNu_L-OJ-7u"},"source":["# Using QMCTorch"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":52},"colab_type":"code","executionInfo":{"elapsed":11632,"status":"ok","timestamp":1588617090211,"user":{"displayName":"Nicolas Renaud","photoUrl":"","userId":"07120063468244602126"},"user_tz":-120},"id":"p7qEQTV2HB4h","outputId":"52c2bbce-3775-442c-95de-d18bd432c2e3","vscode":{"languageId":"python"}},"outputs":[],"source":["import torch\n","from torch import optim\n","from qmctorch.scf import Molecule\n","from qmctorch.wavefunction import SlaterJastrow\n","from qmctorch.solver import Solver\n","from qmctorch.sampler import Metropolis\n","from qmctorch.utils import set_torch_double_precision\n","from qmctorch.utils import plot_energy, plot_data"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{},"colab_type":"code","id":"x-s06JyaHUdN","vscode":{"languageId":"python"}},"outputs":[],"source":["use_gpu = torch.cuda.is_available()\n","set_torch_double_precision()"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":52},"colab_type":"code","executionInfo":{"elapsed":11608,"status":"ok","timestamp":1588617090213,"user":{"displayName":"Nicolas Renaud","photoUrl":"","userId":"07120063468244602126"},"user_tz":-120},"id":"7HO4cNaAID-F","outputId":"a1f652aa-9bcb-4e9b-c038-833b29da2eae","vscode":{"languageId":"python"}},"outputs":[],"source":["mol = Molecule(atom='H 0 0 0.69; H 0 0 -0.69', unit='bohr', \\\n"," calculator='pyscf', basis='sto-3g')"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{},"colab_type":"code","id":"hFZg-XanIOeY","vscode":{"languageId":"python"}},"outputs":[],"source":["wf = SlaterJastrow(mol, configs='cas(2,2)', cuda=use_gpu)"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{},"colab_type":"code","id":"Mqlk1N3tIVXN","vscode":{"languageId":"python"}},"outputs":[],"source":["sampler = Metropolis(nwalkers=2000, nstep=2000, step_size=0.2, \\\n"," ntherm=-1, ndecor=100, nelec=wf.nelec, \\\n"," init=mol.domain('atomic'), \\\n"," move={'type':'all-elec', 'proba':'normal'},\n"," cuda=use_gpu)"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{},"colab_type":"code","id":"5-I7abLxI5qG","vscode":{"languageId":"python"}},"outputs":[],"source":["lr_dict = [{'params': wf.jastrow.parameters(), 'lr': 3E-3},\n"," {'params': wf.ao.parameters(), 'lr': 1E-6},\n"," {'params': wf.mo.parameters(), 'lr': 1E-3},\n"," {'params': wf.fc.parameters(), 'lr': 2E-3}]\n","opt = optim.Adam(lr_dict, lr=1E-3)"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{},"colab_type":"code","id":"xgXSp8JwJIr9","vscode":{"languageId":"python"}},"outputs":[],"source":["scheduler = optim.lr_scheduler.StepLR(opt, step_size=100, gamma=0.90)"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{},"colab_type":"code","id":"g6TE--nNJL1H","vscode":{"languageId":"python"}},"outputs":[],"source":["solver = Solver(wf=wf, sampler=sampler,\n"," optimizer=opt, scheduler=scheduler)"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":87},"colab_type":"code","executionInfo":{"elapsed":26805,"status":"ok","timestamp":1588617105475,"user":{"displayName":"Nicolas Renaud","photoUrl":"","userId":"07120063468244602126"},"user_tz":-120},"id":"Y5MPLiv2JTCy","outputId":"ef067f86-11b3-48e0-9dac-dc8ff5784905","vscode":{"languageId":"python"}},"outputs":[],"source":["# obs = solver.single_point()"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{},"colab_type":"code","id":"yfx4g1Luz9Z-","vscode":{"languageId":"python"}},"outputs":[],"source":["# solver.configure(freeze=['ao', 'mo'], loss='energy', grad='manual')\n","# solver.track_observable(['local_energy'])\n","\n","# solver.configure_resampling(mode='update',\n","# resample_every=1,\n","# nstep_update=50)\n","# solver.ortho_mo = False"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":1000},"colab_type":"code","executionInfo":{"elapsed":52595,"status":"ok","timestamp":1588617131289,"user":{"displayName":"Nicolas Renaud","photoUrl":"","userId":"07120063468244602126"},"user_tz":-120},"id":"VtrVSk620A1A","outputId":"32ad9904-40e5-4efa-bcee-27145e04cfd4","vscode":{"languageId":"python"}},"outputs":[],"source":["# obs = solver.run(50)"]}],"metadata":{"accelerator":"GPU","colab":{"authorship_tag":"ABX9TyMr6DKmNBGlyg+0pzpuupgz","name":"qmctorch.ipynb","provenance":[]},"kernelspec":{"display_name":"Python 3","name":"python3"}},"nbformat":4,"nbformat_minor":0}
4 changes: 0 additions & 4 deletions docs/example/example_gpu.rst

This file was deleted.

4 changes: 0 additions & 4 deletions docs/example/example_horovod.rst

This file was deleted.

4 changes: 0 additions & 4 deletions docs/example/example_opt.rst

This file was deleted.

4 changes: 0 additions & 4 deletions docs/example/example_sp.rst

This file was deleted.

6 changes: 3 additions & 3 deletions example/gpu/h2.py → docs/example/gpu/h2.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from torch import optim

from qmctorch.scf import Molecule
from qmctorch.wavefunction.slater_jastrow import SlaterJastrow
from qmctorch.wavefunction.jastrows.elec_elec import JastrowFactor, PadeJastrowKernel
from qmctorch.solver import SolverSlaterJastrow
from qmctorch.wavefunction import SlaterJastrow
from qmctorch.solver import Solver
from qmctorch.sampler import Metropolis
from qmctorch.utils import set_torch_double_precision
from qmctorch.utils import (plot_energy, plot_data)
Expand Down Expand Up @@ -51,7 +51,7 @@
scheduler = optim.lr_scheduler.StepLR(opt, step_size=100, gamma=0.90)

# QMC solver
solver = SolverSlaterJastrow(wf=wf, sampler=sampler,
solver = Solver(wf=wf, sampler=sampler,
optimizer=opt, scheduler=None)

# perform a single point calculation
Expand Down
12 changes: 7 additions & 5 deletions example/horovod/h2.py → docs/example/horovod/h2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from qmctorch.scf import Molecule
from qmctorch.wavefunction import SlaterJastrow
from qmctorch.solver import SolverSlaterJastrowHorovod
from qmctorch.solver import SolverMPI
from qmctorch.sampler import Metropolis
from qmctorch.utils import set_torch_double_precision
from qmctorch.utils import (plot_energy, plot_data)
Expand All @@ -15,7 +15,8 @@
# bond dissociation energy 4.478 eV -> 0.16 hartree

hvd.init()
if torch.cuda.is_available():
use_cuda = torch.cuda.is_available()
if use_cuda:
torch.cuda.set_device(hvd.rank())

set_torch_double_precision()
Expand All @@ -29,14 +30,15 @@
# define the wave function
wf = SlaterJastrow(mol, kinetic='jacobi',
configs='cas(2,2)',
cuda=False)
cuda=use_cuda)

# sampler
sampler = Metropolis(nwalkers=200,
nstep=200, step_size=0.2,
ntherm=-1, ndecor=100,
nelec=wf.nelec, init=mol.domain('atomic'),
move={'type': 'all-elec', 'proba': 'normal'})
move={'type': 'all-elec', 'proba': 'normal'},
cuda=use_cuda)


# optimizer
Expand All @@ -50,7 +52,7 @@
scheduler = optim.lr_scheduler.StepLR(opt, step_size=100, gamma=0.90)

# QMC solver
solver = SolverSlaterJastrowHorovod(wf=wf, sampler=sampler,
solver = SolverMPI(wf=wf, sampler=sampler,
optimizer=opt, scheduler=scheduler,
rank=hvd.rank())

Expand Down
File renamed without changes.
15 changes: 7 additions & 8 deletions example/optimization/h2.py → docs/example/optimization/h2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from qmctorch.scf import Molecule

from qmctorch.solver import SolverSlaterJastrow
from qmctorch.solver import Solver
from qmctorch.sampler import Metropolis, Hamiltonian
from qmctorch.utils import set_torch_double_precision
from qmctorch.utils.plot_data import (plot_energy, plot_data)
Expand Down Expand Up @@ -44,25 +44,24 @@
step_size=0.05, init=mol.domain('atomic'))

# optimizer
lr_dict = [{'params': wf.jastrow.parameters(), 'lr': 3E-3},
lr_dict = [{'params': wf.jastrow.parameters(), 'lr': 1E-2},
{'params': wf.ao.parameters(), 'lr': 1E-6},
{'params': wf.mo.parameters(), 'lr': 1E-3},
{'params': wf.mo.parameters(), 'lr': 2E-3},
{'params': wf.fc.parameters(), 'lr': 2E-3}]
opt = optim.Adam(lr_dict, lr=1E-3)

# scheduler
scheduler = optim.lr_scheduler.StepLR(opt, step_size=100, gamma=0.90)
scheduler = optim.lr_scheduler.StepLR(opt, step_size=10, gamma=0.90)

# QMC solver
solver = SolverSlaterJastrow(wf=wf, sampler=sampler,
optimizer=opt, scheduler=None)
solver = Solver(wf=wf, sampler=sampler, optimizer=opt, scheduler=None)

# perform a single point calculation
# obs = solver.single_point()

# configure the solver
solver.configure(track=['local_energy'], freeze=['ao', 'mo'],
loss='energy', grad='auto',
solver.configure(track=['local_energy', 'parameters'], freeze=['ao'],
loss='energy', grad='manual',
ortho_mo=False, clip_loss=False,
resampling={'mode': 'update',
'resample_every': 1,
Expand Down
23 changes: 23 additions & 0 deletions docs/example/scf/scf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from qmctorch.scf import Molecule

# Select the SCF calculator
calc = ['pyscf', # pyscf
'adf', # adf 2019
'adf2019' # adf 2020+
][1]

# select an appropriate basis
basis = {
'pyscf' : 'sto-6g',
'adf' : 'VB1',
'adf2019': 'dz'
}[calc]

# do the scf calculation
mol = Molecule(atom='H 0 0 -0.69; H 0 0 0.69',
calculator=calc,
basis=basis,
unit='bohr')



Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from qmctorch.wavefunction.slater_jastrow import SlaterJastrow
from qmctorch.wavefunction.jastrows.elec_elec import JastrowFactor, PadeJastrowKernel
from qmctorch.sampler import Metropolis
from qmctorch.solver import SolverSlaterJastrow
from qmctorch.solver import Solver
from qmctorch.utils import set_torch_double_precision
set_torch_double_precision()

Expand Down Expand Up @@ -34,7 +34,7 @@
# print(' Variance : %f' % s.detach().item())

# solver
solver = SolverSlaterJastrow(wf=wf, sampler=sampler)
solver = Solver(wf=wf, sampler=sampler)

# single point
obs = solver.single_point()
Expand Down
Loading

0 comments on commit 6505080

Please sign in to comment.