Skip to content

Commit

Permalink
merged locally
Browse files Browse the repository at this point in the history
  • Loading branch information
wxj6000 committed Nov 9, 2023
2 parents 09010c1 + 5568555 commit 5e9dff8
Show file tree
Hide file tree
Showing 33 changed files with 1,675 additions and 225 deletions.
13 changes: 13 additions & 0 deletions .codebase/pipelines/smoke_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Python
trigger: change
jobs:
benchmarks:
image: hub.byted.org/codebase/ci_python_39
steps:
- name: test
commands:
- pip install pytest
- uses: actions/
inputs:
file: coverage.xml

5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"C_Cpp.errorSquiggles": "disabled",
"cmake.sourceDirectory": "/mlx_devbox/users/xiaojie.wu/playground/gpu4pyscf/build/lib.linux-x86_64-cpython-39/gpu4pyscf/lib"
"cmake.sourceDirectory": "/mlx_devbox/users/xiaojie.wu/playground/gpu4pyscf/build/lib.linux-x86_64-cpython-39/gpu4pyscf/lib",
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8"
}
}
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,24 @@ Speedup with GPU4PySCF v0.6.0 over Q-Chem 6.1 (Desity fitting, SCF, def2-tzvpp,

Find more benchmarks in gpu4pyscf/benchmarks

Benchmarks
--------
Speedup with GPU4PySCF v0.6.0 over Q-Chem 6.1 (Desity fitting, SCF, def2-tzvpp, def2-universal-jkfit, (99,590))

| mol | natm | LDA | PBE | B3LYP | M06 | wB97m-v |
|:------------------|-------:|-------:|-------:|--------:|-------:|----------:|
| 020_Vitamin_C | 20 | 2.86 | 6.09 | 13.11 | 11.58 | 17.46 |
| 031_Inosine | 31 | 13.14 | 15.87 | 16.57 | 25.89 | 26.14 |
| 033_Bisphenol_A | 33 | 12.31 | 16.88 | 16.54 | 28.45 | 28.82 |
| 037_Mg_Porphin | 37 | 13.85 | 19.03 | 20.53 | 28.31 | 30.27 |
| 042_Penicillin_V | 42 | 10.34 | 13.35 | 15.34 | 22.01 | 24.2 |
| 045_Ochratoxin_A | 45 | 13.34 | 15.3 | 19.66 | 27.08 | 25.41 |
| 052_Cetirizine | 52 | 17.79 | 17.44 | 19 | 24.41 | 25.87 |
| 057_Tamoxifen | 57 | 14.7 | 16.57 | 18.4 | 24.86 | 25.47 |
| 066_Raffinose | 66 | 13.77 | 14.2 | 20.47 | 22.94 | 25.35 |
| 084_Sphingomyelin | 84 | 14.24 | 12.82 | 15.96 | 22.11 | 24.46 |
| 095_Azadirachtin | 95 | 5.58 | 7.72 | 24.18 | 26.84 | 25.21 |
| 113_Taxol | 113 | 5.44 | 6.81 | 24.58 | 29.14 | nan |

Find more benchmarks in gpu4pyscf/benchmarks

201 changes: 0 additions & 201 deletions benchmarks/scf/generate_tables.ipynb

This file was deleted.

8 changes: 7 additions & 1 deletion gpu4pyscf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
from . import lib, grad, hessian, solvent, scf, dft
__version__ = '0.6.5'
__version__ = '0.6.1'

import pyscf
from gpu4pyscf.lib.utils import patch_cpu_kernel

# patch tag_array for compatibility
pyscf.lib.tag_array = patch_cpu_kernel(pyscf.lib.tag_array)(lib.cupy_helper.tag_array)
4 changes: 4 additions & 0 deletions gpu4pyscf/df/grad/rks.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ def get_veff(ks_grad, mol=None, dm=None):
vxc = tag_array(vxc, aux=e1_aux)
return vxc

<<<<<<< HEAD
class Gradients(rks_grad.Gradients):
=======
class Gradients(rks_grad.Gradients, pyscf.df.grad.rks.Gradients):
>>>>>>> dev
from gpu4pyscf.lib.utils import to_cpu, to_gpu, device

get_jk = get_jk
Expand Down
4 changes: 4 additions & 0 deletions gpu4pyscf/dft/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<<<<<<< HEAD
from . import rks
=======
from . import rks
from .rks import RKS
from .uks import UKS
from .gks import GKS
from .roks import ROKS
>>>>>>> dev
9 changes: 8 additions & 1 deletion gpu4pyscf/dft/gen_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,18 @@ def arg_group_grids(mol, coords, box_size=GROUP_BOX_SIZE):
atom_coords.max(axis=0) + GROUP_BOUNDARY_PENALTY]
# how many boxes inside the boundary
boxes = ((boundary[1] - boundary[0]) * (1./box_size)).round().astype(int)
tot_boxes = numpy.prod(boxes + 2)
boxes = cupy.asarray(boxes)
boundary = [cupy.asarray(boundary[0]), cupy.asarray(boundary[1])]
tot_boxes = cupy.prod(boxes + 2)
logger.debug(mol, 'tot_boxes %d, boxes in each direction %s', tot_boxes, boxes)
# box_size is the length of each edge of the box
<<<<<<< HEAD
box_size = (boundary[1] - boundary[0]) / boxes
frac_coords = (coords - boundary[0]) * (1./box_size)
=======
box_size = cupy.asarray((boundary[1] - boundary[0]) / boxes)
frac_coords = (coords - cupy.asarray(boundary[0])) * (1./box_size)
>>>>>>> dev
box_ids = cupy.floor(frac_coords).astype(int)
box_ids[box_ids<-1] = -1
box_ids[box_ids[:,0] > boxes[0], 0] = boxes[0]
Expand Down
7 changes: 5 additions & 2 deletions gpu4pyscf/grad/rks.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,12 @@ def get_du(ia, ib): # JCP 98, 5612 (1993); (B10)
yield coords, w0, w1

class Gradients(rhf_grad.Gradients, pyscf.grad.rks.Gradients):
<<<<<<< HEAD
device = 'gpu'
get_veff = patch_cpu_kernel(pyscf.grad.rks.Gradients.get_veff)(_get_veff)
=======
from gpu4pyscf.lib.utils import to_cpu, to_gpu, device

get_veff = _get_veff
>>>>>>> dev

def get_dispersion(self):
if self.base.disp[:2].upper() == 'D3':
Expand Down
10 changes: 10 additions & 0 deletions gpu4pyscf/grad/tests/test_rhf_grad.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,20 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import pyscf
<<<<<<< HEAD
import cupy
import numpy as np
import unittest
from pyscf import lib, scf
import gpu4pyscf

lib.num_threads(8)
=======
import numpy as np
import unittest
import gpu4pyscf
from pyscf import scf
>>>>>>> dev

atom = '''
O 0.0000000000 -0.0000000000 0.1174000000
Expand Down
9 changes: 9 additions & 0 deletions gpu4pyscf/grad/tests/test_rks_grad.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,19 @@
import pyscf
import cupy
import unittest
<<<<<<< HEAD:gpu4pyscf/grad/tests/test_rks_grad.py
from pyscf import lib
from pyscf.dft import rks
import gpu4pyscf
from gpu4pyscf.dft import numint

lib.num_threads(8)
=======
from pyscf.dft import rks
import gpu4pyscf
from gpu4pyscf.dft import numint
>>>>>>> dev:gpu4pyscf/grad/tests/test_grad.py

atom = '''
O 0.0000000000 -0.0000000000 0.1174000000
H -0.7570000000 -0.0000000000 -0.4696000000
Expand Down
4 changes: 4 additions & 0 deletions gpu4pyscf/scf/hf.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,11 @@ def nuc_grad_method(self):
def density_fit(self, auxbasis=None, with_df=None, only_dfj=False):
import gpu4pyscf.df.df_jk
return gpu4pyscf.df.df_jk.density_fit(self, auxbasis, with_df, only_dfj)
<<<<<<< HEAD

=======

>>>>>>> dev
class _VHFOpt(_vhf.VHFOpt):
from gpu4pyscf.lib.utils import to_cpu, to_gpu, device

Expand Down
Loading

0 comments on commit 5e9dff8

Please sign in to comment.