You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: source/user/gpu.rst
+49-5
Original file line number
Diff line number
Diff line change
@@ -39,10 +39,20 @@ The binary package of GPU4PySCF is released based on the CUDA version.
39
39
40
40
Usage of GPU4PySCF
41
41
==================
42
-
GPU4PySCF APIs are designed to be compatible with PySCF. When supported, high-level functions and objects are named the same as PySCF. But, GPU4PySCF classes do not directly inherit from PySCF class.
43
-
PySCF objects and GPU4PySCF objects can be converted into each other by :func:`to_gpu` and :func:`to_cpu`. In the conversion, the numpy arrays will be converted into cupy array. And the functions will be omitted if they are not supported with GPU acceleration.
42
+
The GPU4PySCF APIs are designed to maintain compatibility with PySCF. The
43
+
classes and methods in GPU4PySCF are named identically to those in PySCF,
44
+
ensuring a familiar interface for users. However, GPU4PySCF classes do not
45
+
directly inherit from PySCF classes.
44
46
45
-
One can use the two modes to accelerate the calculations: directly use GPU4PySCF object::
47
+
PySCF objects and GPU4PySCF objects can be converted to each other using the `to_gpu` and `to_cpu` methods.
48
+
The conversion process can automatically, recursively translate all attributes between GPU and CPU instances.
49
+
For example, numpy arrays on the CPU are converted into CuPy arrays on the GPU, and vice versa.
50
+
If certain attributes are exclusive to either the CPU or GPU, these attributes will be appropriately handled.
51
+
They are omitted or specifically converted, depending on the target platform.
52
+
53
+
There are two approaches to execute the computation on GPU.
54
+
55
+
1. Directly import GPU4PySCF classes and methods::
46
56
47
57
import pyscf
48
58
from gpu4pyscf.dft import rks
@@ -65,7 +75,7 @@ One can use the two modes to accelerate the calculations: directly use GPU4PySCF
65
75
h = mf.Hessian()
66
76
h_dft = h.kernel() # compute analytical Hessian
67
77
68
-
Alternatively, one can convert PySCF object to the corresponding GPU4PySCF object with :func:`to_gpu` since PySCF 2.5.0 ::
78
+
2. Convert PySCF object to the corresponding GPU4PySCF object with :func:`to_gpu`::
69
79
70
80
import pyscf
71
81
from pyscf.dft import rks
@@ -82,10 +92,44 @@ Alternatively, one can convert PySCF object to the corresponding GPU4PySCF objec
82
92
83
93
84
94
When the GPU task is done, the GPU4PySCF object can be converted into the corresponding PySCF object via :func:`mf.to_cpu()`.
85
-
Then, more sophisticated methods in PySCF can apply. One can also convert the individual CuPy array to numpy array with `Cupy APIs`_.
95
+
96
+
In GPU4PySCF, wavefunctions, density matrices, and other array data are stored in CuPy arrays.
97
+
To transfer these data to NumPy arrays on the CPU, the `.get()` method of the CuPy array can be invoked.
98
+
For more detailed information on handling CuPy array conversions, please refer to the `CuPy APIs` documentation.
0 commit comments