betaFeedback

WorksPhysics and Astronomy

Implementation of the multigrid Gaussian-Plane-Wave algorithm with GPU acceleration in PySCF

Abstract

We introduce a GPU-accelerated multigrid Gaussian-Plane-Wave density fitting (FFTDF) approach for efficient Fock builds and nuclear gradient evaluations within Kohn-Sham density functional theory, as implemented in the GPU4PySCF module of PySCF. Our CUDA kernels employ a grid-based parallelization strategy for contracting Gaussian basis function pairs and achieve up to 80% of the FP64 peak performance on NVIDIA GPUs, with no loss of efficiency for high angular momentum (up to f-shell) functions. Benchmark calculations on molecules and solids with up to 1536 atoms and 20480 basis functions show up to 25x speedup on an H100 GPU relative to the CPU implementation on a 28-core shared memory node. For a 256-water cluster, the ground-state energy and nuclear gradients can be computed in ~30 seconds on a single H100 GPU. This implementation serves as an open-source foundation for many applications, such as ab initio molecular dynamics and high-throughput calculations.

Introduction

Graphics processing units (GPUs) have enabled orders-of-magnitude speedups for numerous computational chemistry methods, including molecular dynamics,[1, 2, 3, 4] Kohn-Sham density functional theory (KS-DFT),[5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22] correlation theories such as second-order Møller-Plesset perturbation theory,[23, 24, 25] coupled-cluster theory,[26, 27, 28, 29] and many others.[30, 31, 32, 33] This is because of the distinct design of GPU chips, which compared to central processing units (CPUs), offer significantly higher instruction throughput and memory bandwidth.[34]

Nevertheless, fully exploiting GPU throughput generally requires substantial algorithmic redesign to accommodate the distinct aspects of GPU architectures. GPU kernel performance can deteriorate significantly when implementations do not carefully follow best practices, such as minimizing register spilling and global-memory traffic.[34] For example, in our GPU implementation of two-electron repulsion integrals,[35] we found a strong dependence of the kernel efficiency on the angular momentum of the Gaussian basis functions, because higher angular momenta require deeper recursion relations, leading to intermediates that exceed the available register capacity. Addressing such challenges is the key to achieving efficient GPU implementations of quantum chemistry methods.

In this work, we focus on accelerating pseudopotential KS-DFT on GPUs by employing the multigrid Gaussian-Plane-Wave density fitting (denoted FFTDF in PySCF)[36] approach, originally introduced by Lippert et al.[37, 38] Compared with the original CPU implementation in PySCF (which has already enabled several large-scale DFT applications[39, 40, 41]), our GPU implementation introduces an additional layer of parallelism at the real-space grid level. In particular, the uniform grid in the FFTDF method maps naturally onto the hierarchical thread-block structure of GPUs, allowing for a balanced workload distribution and to minimize global memory traffic so that the kernels remain compute-bound. Our design achieves near-peak FP64 throughput on NVIDIA GPUs and offers state-of-the-art performance for KS-DFT Fock builds with local and semi-local exchange-correlation (XC) functionals. Overall, our implementation supports the local density approximation (LDA), generalized gradient approximation (GGA), and meta-generalized gradient approximation (meta-GGA) functionals. Both Γ-point and kk-point sampling are available, along with band structure analysis for orthorhombic and non-orthorhombic periodic systems.

The remainder of the paper is organized as follows. Section II provides a brief overview of the multigrid FFTDF algorithm. Section III describes our GPU implementation in detail. Section IV reports timing results and kernel-level performance analyses for a range of molecules and solids. Finally, Section V summarizes our conclusions.

Background

In this section, we review the multigrid FFTDF approach for KS-DFT Fock builds. In FFTDF, the underlying single particle basis functions are chosen as crystalline Gaussian type orbitals (GTOs),

ϕμ,k(r)=∑Teik⋅rϕμT(r),(1)\phi_{\mu,\mathbf{k}}(\mathbf{r}) = \sum_{\mathbf{T}} e^{i\mathbf{k}\cdot\mathbf{r}}\phi_{\mu}^{\mathbf{T}}(\mathbf{r}), \tag*{(1)}

where T\mathbf{T} is a lattice translation vector, and k\mathbf{k} is a crystal momentum vector in the first Brillouin zone. ϕμ(r)\phi_{\mu}(\mathbf{r}) represents the Gaussian basis functions located in the reference unit cell and

ϕμT(r)=ϕμ(r−T).(2)\phi_\mu^{\mathrm{T}}(\mathbf{r})=\phi_\mu(\mathbf{r}-\mathbf{T}). \tag*{(2)}

In this paper, we only describe Γ\Gamma-point calculations, i.e., k=0\mathbf{k}=0, for simplicity, although our implementation in the GPU4PySCF module fully supports kk-point sampling.

The real-space electron density can be expressed as

ρ(r)=∑ST∑μνDμνϕμS(r)ϕνT(r),(3)\rho(\mathbf{r})=\sum_{\mathbf{S}\mathbf{T}}\sum_{\mu\nu}D_{\mu\nu}\phi_\mu^{\mathbf{S}}(\mathbf{r})\phi_\nu^{\mathbf{T}}(\mathbf{r}), \tag*{(3)}

where D\mathbf{D} is the one-electron density matrix. The two-electron part of the Fock matrix, including the Coulomb and XC contributions, is then evaluated numerically in real space as

Fμν2e=∑ST∫ΩϕμS(r)vHxc(r)ϕνT(r)dr,(4)F_{\mu\nu}^{2e}=\sum_{\mathbf{S}\mathbf{T}}\int_{\Omega}\phi_\mu^{\mathbf{S}}(\mathbf{r})v_{\mathrm{Hxc}}(\mathbf{r})\phi_\nu^{\mathbf{T}}(\mathbf{r})d\mathbf{r}, \tag*{(4)}

where

vHxc(r)=F−1(v~Hxc(G))=1Ω∑G≠0v~Hxc(G)eiG⋅r(5)v_{\mathrm{Hxc}}(\mathbf{r})=\mathcal{F}^{-1}\left(\widetilde{v}_{\mathrm{Hxc}}(\mathbf{G})\right)=\frac{1}{\Omega}\sum_{\mathbf{G}\ne0}\widetilde{v}_{\mathrm{Hxc}}(\mathbf{G})e^{i\mathbf{G}\cdot\mathbf{r}} \tag*{(5)}

and

v~Hxc(G)=4π∣G∣2ρ~(G)+v~xc(6)\widetilde{v}_{\mathrm{Hxc}}(\mathbf{G})=\frac{4\pi}{\lvert\mathbf{G}\rvert^2}\widetilde{\rho}(\mathbf{G})+\widetilde{v}_{\mathrm{xc}} \tag*{(6)}

are the Hartree exchange-correlation (Hxc) potential and its Fourier representation, with ρ~\widetilde{\rho} the Fourier representation of ρ\rho, v~xc\widetilde{v}_{\mathrm{xc}} the Fourier representation of the XC potential, F−1\mathcal{F}^{-1} the inverse of Fourier transformation F\mathcal{F}, G\mathbf{G} the momentum vectors of the plane waves, and Ω\Omega the unit cell volume. The first term in Eq. (6) is the Hartree potential in Fourier space. Note that the Fourier transforms are performed using the fast Fourier transform (FFT), while the plane waves can be viewed as a density fitting basis, hence the designation FFTDF.

In conventional Gaussian basis sets (including the ones used in this work) the underlying GTO exponents typically span a wide range, yielding both compact and diffuse orbitals. It is therefore beneficial to employ multiple sets of numerical grids with varying resolutions when evaluating Eqs. (3)–(5). This leads to the multigrid method, where the GTO pair products (which are also GTOs) are sorted according to their exponents and subsequently binned into groups. Each group is assigned a distinct uniform grid, with an associated plane wave cutoff GαG_\alpha.1 On each grid, Eq. (3) is evaluated for the corresponding group of GTO pairs to obtain the partial density ρα\rho_\alpha. The total electron density is then accumulated (on the finest grid) by Fourier interpolation as

ρ~(G)=∑αρ~α(G),(7)\widetilde{\rho}(\mathbf{G})=\sum_\alpha\widetilde{\rho}_\alpha(\mathbf{G}), \tag*{(7)}

where

ρ~α(G)={F(ρα(r))if ∣G∣<Gα,0if ∣G∣≥Gα.(8)\widetilde{\rho}_\alpha(\mathbf{G})= \begin{cases} \mathcal{F}(\rho_\alpha(\mathbf{r})) & \text{if } \lvert\mathbf{G}\rvert<G_\alpha,\\ 0 & \text{if } \lvert\mathbf{G}\rvert\ge G_\alpha. \end{cases} \tag*{(8)}

Once ρ~\widetilde{\rho} is obtained, the Hxc potential is computed in Fourier space [Eq. (6)], transformed back to real space [Eq. (5)] for each of the multiple grids, and integrated numerically via Eq. (4) to yield its contribution to the Fock matrix.

For LDA functionals, the XC potential vxcLDA[ρ]v_{\mathrm{xc}}^{\mathrm{LDA}}[\rho] depends only on the electron density ρ\rho, and

vxcLDA(r)=δExcLDAδρ(r),(9)v_{\mathrm{xc}}^{\mathrm{LDA}}(\mathbf{r})=\frac{\delta E_{\mathrm{xc}}^{\mathrm{LDA}}}{\delta\rho(\mathbf{r})}, \tag*{(9)}

where ExcLDAE_{\mathrm{xc}}^{\mathrm{LDA}} is the corresponding XC energy, and δ\delta denotes the functional derivative.

For GGA functionals, the XC potential vxcGGA[ρ,∇ρ]v_{\mathrm{xc}}^{\mathrm{GGA}}[\rho,\nabla\rho] is a functional of both the electron density and its gradient. Due to the cost of computing the density gradient in real space (which requires basis function gradients), it is approximated by a gradient evaluation in Fourier space followed by an inverse Fourier transform,

∇ρ(r)=F−1(iGρ~(G)).(10)\nabla\rho(\mathbf{r})=\mathcal{F}^{-1}\left(i\mathbf{G}\widetilde{\rho}(\mathbf{G})\right). \tag*{(10)}

In addition to the LDA contribution, in the GGA formalism, evaluating the Fock matrix involves an integration over the XC potential of the form

Vμνxc,GGA=∑ST∫Ω(∇ϕμS(r)ϕνT(r))⋅vxcGGA(r)dr,(11)V_{\mu\nu}^{\mathrm{xc,GGA}}=\sum_{\mathbf{S}\mathbf{T}}\int_{\Omega}\left(\nabla\phi_\mu^{\mathbf{S}}(\mathbf{r})\phi_\nu^{\mathbf{T}}(\mathbf{r})\right)\cdot v_{\mathrm{xc}}^{\mathrm{GGA}}(\mathbf{r})d\mathbf{r}, \tag*{(11)}

where

vxcGGA(r)=δExcGGAδ∇ρ(r).(12)v_{\mathrm{xc}}^{\mathrm{GGA}}(\mathbf{r})=\frac{\delta E_{\mathrm{xc}}^{\mathrm{GGA}}}{\delta\nabla\rho(\mathbf{r})}. \tag*{(12)}

In conventional XC matrix evaluation programs based on general (non-uniform) numerical integration grids, evaluating this integral requires computing gradients of each orbital pair ϕμS(r)ϕνT(r)\phi_\mu^{\mathbf{S}}(\mathbf{r})\phi_\nu^{\mathbf{T}}(\mathbf{r}), which is computationally demanding. Applying integration by parts to Eq. (11) gives

Vμνxc,GGA=∑ST∫Ω−ϕμS(r)ϕνT(r)∇⋅vxcGGA(r)dr,(13)V_{\mu\nu}^{\mathrm{xc,GGA}}=\sum_{\mathbf{S}\mathbf{T}}\int_{\Omega}-\phi_\mu^{\mathbf{S}}(\mathbf{r})\phi_\nu^{\mathbf{T}}(\mathbf{r})\nabla\cdot v_{\mathrm{xc}}^{\mathrm{GGA}}(\mathbf{r})d\mathbf{r}, \tag*{(13)}

where gradients of the real-space XC potential can be efficiently approximated using Fourier transforms, in the same manner as those of the electron density,

∇⋅vxcGGA(r)=F−1(iG⋅F(vxcGGA(r))).(14)\nabla\cdot v_{\mathrm{xc}}^{\mathrm{GGA}}(\mathbf{r})=\mathcal{F}^{-1}\left(i\mathbf{G}\cdot\mathcal{F}(v_{\mathrm{xc}}^{\mathrm{GGA}}(\mathbf{r}))\right). \tag*{(14)}

In practice, Eq. (14) is absorbed into the real-space Hxc potential in Eq. (5), making computation of the Fock matrix for GGA functionals as inexpensive as for LDA functionals.

However, such approximations cannot be directly applied to meta-GGA functionals, due to their dependence on the kinetic energy density

τ(r)=12∑ST∑μνDμν∇ϕμS(r)⋅∇ϕνT(r).(15)\tau(\mathbf{r})=\frac{1}{2}\sum_{\mathbf{S}\mathbf{T}}\sum_{\mu\nu}D_{\mu\nu}\nabla\phi_\mu^{\mathbf{S}}(\mathbf{r})\cdot\nabla\phi_\nu^{\mathbf{T}}(\mathbf{r}). \tag*{(15)}

The corresponding Fock matrix contains an additional term that requires explicit evaluation of orbital gradients:

Fμν2e=∑ST∫Ωdr(ϕμS(r)vHxc(r)ϕνT(r)+vxcmGGA(r)∇ϕμS(r)⋅∇ϕνT(r)),(16)F_{\mu\nu}^{2e}=\sum_{\mathrm{S T}}\int_{\Omega}d\mathbf{r}\left(\phi_{\mu}^{\mathrm{S}}(\mathbf{r})v_{\mathrm{Hxc}}(\mathbf{r})\phi_{\nu}^{\mathrm{T}}(\mathbf{r})+v_{\mathrm{xc}}^{\mathrm{mGGA}}(\mathbf{r})\nabla\phi_{\mu}^{\mathrm{S}}(\mathbf{r})\cdot\nabla\phi_{\nu}^{\mathrm{T}}(\mathbf{r})\right), \tag*{(16)}

where

vxcmGGA(r)=δExcmGGAδτ(r).(17)v_{\mathrm{xc}}^{\mathrm{mGGA}}(\mathbf{r})=\frac{\delta E_{\mathrm{xc}}^{\mathrm{mGGA}}}{\delta\tau(\mathbf{r})}. \tag*{(17)}

Eq. (16) replaces Eq. (4) when a meta-GGA functional is required. The XC energy and potential are conveniently computed using the LibXC[43] library.

Finally, the remaining one-electron contributions, including the kinetic energy and the GTH pseudopotential,[44] are precomputed and cached at the beginning of the self-consistent field iterations. The kinetic energy, as well as the short-range local and non-local components of the GTH pseudopotential are evaluated analytically. The long-range part of the GTH pseudopotential is treated as arising from a Gaussian charge distribution, as described in Eq. 10 of Ref. 42, and is incorporated into the Hxc potential in Eq. (6) for the evaluation of the Fock matrix.

Implementation

In this section, we present our GPU implementation of the multigrid FFTDF approach, preceded by a brief review of the CPU implementation to clarify key algorithmic distinctions.

CPU

The Fock build consists of two stages, namely, construction of the electron density Eq. (3) and integration of the Hxc potential Eq. (4), both performed in real space. The central computational task in both cases is the evaluation of GTO pair products on uniform grids. For clarity, we omit the explicit notation of lattice translations in the following discussion. However, in the CPU implementation, we adopt the convention that one of the orbitals in Eqs. (3) and (4) is fixed in the reference unit cell, while the other is summed over its periodic images. Contributions arising outside the reference cell are subsequently folded back into it. In other words, Eqs. (3) and (4) are now computed as

ρ(r)=∑S(∑TDμνϕμS(r)ϕνS+T(r)),(18)\rho(\mathbf{r})=\sum_{\mathrm{S}}\left(\sum_{\mathrm{T}}D_{\mu\nu}\phi_{\mu}^{\mathrm{S}}(\mathbf{r})\phi_{\nu}^{\mathrm{S+T}}(\mathbf{r})\right), \tag*{(18)}

and

Fμν2e=∑S(∑T∫ΩϕμS(r)vHxc(r)ϕνS+T(r)dr).(19)F_{\mu\nu}^{2e}=\sum_{\mathrm{S}}\left(\sum_{\mathrm{T}}\int_{\Omega}\phi_{\mu}^{\mathrm{S}}(\mathbf{r})v_{\mathrm{Hxc}}(\mathbf{r})\phi_{\nu}^{\mathrm{S+T}}(\mathbf{r})d\mathbf{r}\right). \tag*{(19)}

This choice simplifies the screening procedure and reduces the computational cost.

First, to achieve a linear scaling algorithm, proper prescreening of GTO pairs is necessary. For each shell of GTOs, we compute a shell cutoff radius rcutr_{\mathrm{cut}}, such that

rcut2ϕR(rcut)<τ,(20)r_{\mathrm{cut}}^{2}\phi_{\mathrm{R}}(r_{\mathrm{cut}})<\tau, \tag*{(20)}

where ϕR\phi_{\mathrm{R}} is the radial part of a primitive Gaussian function, and τ\tau is a predefined accuracy threshold. Only those GTOs that overlap with each other (i.e., the distance between them is smaller than the sum of their shell cutoff radii) are considered when evaluating Eqs. (3) and (4).

Next, we follow the strategies of VandeVondele et al.42 to compute GTO pair products on uniform grids. It takes O(NpairNgrid)O(N_{\mathrm{pair}}N_{\mathrm{grid}}) floating-point operations (FLOPs), where NpairN_{\mathrm{pair}} and NgridN_{\mathrm{grid}} are the numbers of GTO pairs and grid points, respectively. Note that NpairN_{\mathrm{pair}} grows only linearly with system size due to the prescreening mentioned above, while NgridN_{\mathrm{grid}} remains constant as we further eliminate non-contributing grid points for each GTO pair (see below).

In orthorhombic lattices, primitive Cartesian Gaussian basis functions (and their products) evaluated on uniform grids admit simple separable factorizations into xx-, yy-, and zz-dependent components, each of which can be computed independently. (An analogous factorization applies to non-orthorhombic lattices, documented in the Appendix, Eq. A.30-A.32.) For example, a single primitive Gaussian factorizes as

ga(r)≡ga(x,y,z)=ga(x)ga(y)ga(z),(21)g_a(\mathbf{r})\equiv g_a(x,y,z)=g_a(x)g_a(y)g_a(z), \tag*{(21)}

where

ga(x)=(x−Ax)lxae−αa(x−Ax)2,…(22)g_a(x)=(x-A_x)^{l_x^a}e^{-\alpha_a(x-A_x)^2},\ldots \tag*{(22)}

For the product of a Gaussian pair, Eq. (22) becomes

gablxalxb(x)=(x−Ax)lxa(x−Bx)lxbe−αp(x−Px)2,(23)g_{ab}^{l_x^a l_x^b}(x)=(x-A_x)^{l_x^a}(x-B_x)^{l_x^b}e^{-\alpha_p(x-P_x)^2}, \tag*{(23)}

where αp=αa+αb\alpha_p=\alpha_a+\alpha_b and P=(αaA+αbB)/αp\mathbf{P}=(\alpha_a\mathbf{A}+\alpha_b\mathbf{B})/\alpha_p. In Eq. (23), the grid-point independent prefactor is omitted for clarity. Such factorization offers the benefit that at most O(Ngrid3)O(\sqrt[3]{N_{\mathrm{grid}}}) evaluations of Gaussian functions [Eq. (23)] are needed, compared with O(Ngrid)O(N_{\mathrm{grid}}) evaluations for the non-factorized case. Furthermore, the uniform grid spacing allows one to use the following recursion relation to reduce the number of exponential function (exp) evaluations to only three per dimension:

gab00(xi+1)=gab00(xi)e−(2i+1)αpdx2e−2αpdx(x0−Px),(24)g_{ab}^{00}(x_{i+1})=g_{ab}^{00}(x_i)e^{-(2i+1)\alpha_pdx^2}e^{-2\alpha_pdx(x_0-P_x)}, \tag*{(24)}
gab00(x0)=e−αp(x0−Px)2,(25)g_{ab}^{00}(x_0)=e^{-\alpha_p(x_0-P_x)^2}, \tag*{(25)}

where x0x_0 denotes the grid point nearest to the Gaussian center PxP_x, dxdx is the grid spacing, and xi=x0+i×dxx_i=x_0+i\times dx. In Eq. (24), ii (which can be negative) iterates over the grid points within a sphere centered at P\mathbf{P}, whose radius is determined through Eq. (20) for each Gaussian pair. Because evaluating exp⁡\exp is one to two orders of magnitude more expensive than a multiplication, the procedure above substantially reduces the overall computational cost. In addition, the single-lattice-sum-plus-folding scheme [Eqs. (18) and (19)] requires significantly fewer Gaussian pair (more precisely, exp⁡\exp) evaluations than the double-lattice-sum formalism [Eqs. (3) and (4)], which justifies our adoption of the former approach.

Finally, for orbital pairs within the same shell pair, common factors in the polynomial prefactor of Eq. (23) can be extracted via a binomial expansion,

(x−Ax)lxa(x−Bx)lxb=∑k=0lxb(lxbk)(x−Ax)k+lxa(Ax−Bx)lxb−k,(26)(x-A_x)^{l_x^a}(x-B_x)^{l_x^b} = \sum_{k=0}^{l_x^b} \binom{l_x^b}{k} (x-A_x)^{k+l_x^a}(A_x-B_x)^{l_x^b-k}, \tag*{(26)}

where lxa∈{0,1,…,la}l_x^a \in\{0,1,\ldots,l^a\}, and lxb∈{0,1,…,lb}l_x^b \in\{0,1,\ldots,l^b\} for shells aa and bb with angular momenta lal^a and lbl^b, respectively. Consequently, instead of evaluating Eq. (23) for every (lxa,lxb)(l_x^a,l_x^b) pair, i.e., lalbl^a l^b times per grid point along a given dimension, only (la+lb+1)(l^a+l^b+1) distinct functions need to be computed, namely,

gablxp(x)=(x−Ax)lxpe−αp(x−Px)2,(27)g_{ab}^{l_x^p}(x)=(x-A_x)^{l_x^p}e^{-\alpha_p(x-P_x)^2}, \tag*{(27)}

where lxp∈{0,1,…,la+lb}l_x^p \in\{0,1,\ldots,l^a+l^b\}. The resulting FLOP reduction is more evident in the contraction in Eq. (3), where the contribution from each shell pair can now be written as

∑lxp,lyp,lzp=0la+lbDlxp,lyp,lzpgablxp(x)gablyp(y)gablzp(z),(28)\sum_{l_x^p,l_y^p,l_z^p=0}^{l^a+l^b} D_{l_x^p,l_y^p,l_z^p}g_{ab}^{l_x^p}(x)g_{ab}^{l_y^p}(y)g_{ab}^{l_z^p}(z), \tag*{(28)}

and DD involves contractions between the density matrix DD in Eq. (3) and the expansion coefficients in Eq. (26). The computational cost of evaluating Eq. (28) therefore scales as O((la+lb)Ngrid)O((l^a+l^b)N_{\mathrm{grid}}), which is orders of magnitude lower than the O((lalb)2Ngrid)O((l^a l^b)^2N_{\mathrm{grid}}) scaling of the original expression in Eq. (3) for shells with higher angular momenta.

The same conclusion applies to the integration of the Hxc potential in Eq. (4). In this case, an intermediate 3-dimensional tensor Vlxp,lyp,lzp\mathcal{V}_{l_x^p,l_y^p,l_z^p} (analogous to DD in Eq. (28)), with 0≤lxp,lyp,lzp≤la+lb0\le l_x^p,l_y^p,l_z^p\le l^a+l^b, is first constructed for each shell pair by contracting the real-space potential with the Gaussian products defined in Eq. (27):

Vlxp,lyp,lzp=ΩNgrid∑x,y,zvHxc(x,y,z)gablxp(x)gablyp(y)gablzp(z),(29)\mathcal{V}_{l_x^p,l_y^p,l_z^p} = \frac{\Omega}{N_{\mathrm{grid}}} \sum_{x,y,z} v_{\mathrm{Hxc}}(x,y,z)g_{ab}^{l_x^p}(x)g_{ab}^{l_y^p}(y)g_{ab}^{l_z^p}(z), \tag*{(29)}

The computational cost of this step scales as O((la+lb)Ngrid)O((l^a+l^b)N_{\mathrm{grid}}). The obtained tensor V\mathcal{V} is then contracted with the expansion coefficients in Eq. (26) along each Cartesian component to assemble the final Fock matrix.

Our CPU implementation of the multigrid FFTDF approach employs straightforward OpenMP parallelization

over Gaussian shell pairs, without explicit load-balancing optimization. We also note that Eq. (28) leads to skinny matrix multiplications for basis functions with low angular momentum, a regime in which standard BLAS level-3 routines (used exclusively in our current implementation) might be suboptimal. As such, additional performance gains are likely possible through manually unrolled contraction loops combined with cache-aware blocking and explicit SIMD (single instruction, multiple data) vectorization. Later, we provide a performance comparison of our implementation with the leading implementation of multigrid KS-DFT (which performs such optimizations) in CP2K.[37, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53]

GPU

In the CPU implementation, the intermediate Gaussian products in Eq. (27) are precomputed and cached in memory. In our initial GPU implementation, the same strategy was adopted, with these intermediates evaluated and stored in global memory. However, this approach results in substantial global memory traffic due to repeated reads of the intermediates, as well as excessive write conflicts during reductions over orbital indices or grid points. As a result, the GPU implementation achieved only marginal speedup compared to the CPU version.

In various GPU optimization practices, minimizing global-memory access is often more critical for performance than minimizing the FLOP count. In contrast to CPU implementations, where reducing FLOPs often leads to higher performance, achieving near-peak performance on GPUs requires prioritizing the reduction of global-memory traffic. Based on this understanding, we develop a two-stage algorithm, in which contributions from Gaussian pairs at each grid point are first accumulated in registers or shared memory, followed by a single write of the aggregated result to global memory. With such a strategy, for example, the global memory write associated with the density construction [Eq. (3)] is reduced to its theoretical minimum, NgridN_{\mathrm{grid}}. This also naturally introduces an additional level of parallelism over the grid points. In the following, we provide more details of this GPU implementation of the multigrid FFTDF approach.

First, to exploit grid-level parallelism, the uniform grid is logically partitioned into 64-point (4×4×44\times4\times4) grid blocks, each mapped to a CUDA thread block (which contains 64 threads) across all our custom CUDA kernels. For each grid block, we record the contributing Gaussian pairs, i.e., those with nonzero overlap on the corresponding grid points. The screening procedure is technically involved and is described in the Appendix. The computational cost of this step is approximately 1.5 times that of a single SCF cycle, but it is performed only once for the entire energy and nuclear gradient evaluation.

Next, we employ a two-stage parallelism for constructing the electron density [Eq. (3)]. The procedure is out-

Image not extracted

Figure 1.

Algorithm 1. Workflow of electron density build
1  __global__ ρ(r);
2  in CUDA block B_n:
3      __shared__ ρ_shared(r ∈ B_n);
4      n_batch = size({Λ_p}_{B_n}) // 64 + 1;
5      thread_id = threadIdx.x;
6      for batch_idx in range(n_batch):
7          p = batch_idx * 64 + thread_id;
8          Read D_{μν∈Λ_p};
9          for r in B_n:
10             contracted = Σ_{μν∈Λ_p} D_{μν}Λ_p(r);
11             ρ_shared(r) += reduce(contracted);
12     ρ(r) = ρ_shared(r)
Image not extracted

Figure 2.

Algorithm 2. Workflow of two-electron Fock matrix build
1  __global__ F^{2e};
2  in CUDA block B_n:
3      __shared__ v_Hxc(r ∈ B_n);
4      n_batch = size({Λ_p}_{B_n}) // 64 + 1;
5      thread_id = threadIdx.x;
6      for batch_idx in range(n_batch):
7          p = batch_idx * 64 + thread_id;
8          F^{local}_{μν∈Λ_p} = 0;
9          for r in B_n:
10             F^{local}_{μν∈Λ_p} += v_Hxc(r)Λ_p(r);
11         atomicAdd(F^{2e}_{μν∈Λ_p}, F^{local}_{μν∈Λ_p});

lined in Algorithm 1. Within each CUDA thread block BnB_n (assigned with a grid block), we loop over the corresponding contributing set of primitive Gaussian shell pairs {Λp≡gabalb}Bn\{\Lambda_p \equiv g_{ab}^{a^l b}\}_{B_n} in batches. In each batch, the 64 threads each process one shell pair and computes its contribution to the density in parallel. Specifically, each thread loads into registers the subblock of the density matrix associated with the shell pair and contracts it with the result of Eq. (23), which is evaluated on the grid points (belonging to BnB_n) using the recursion relations Eqs. (24) and (25). When computing the kinetic energy density for meta-GGA functionals, Λp(r)\Lambda_p(r) is replaced by ∇ga(r)⋅∇gb(r)\nabla g_a(r) \cdot\nabla g_b(r). Unlike the CPU implementation, the polynomial prefactor in Eq. (23) is evaluated directly, without applying the binomial expansion in Eq. (26). This is because forming the intermediate tensor DD in Eq. (28) would exceed the available GPU register capacity, causing register spilling and increased memory traffic, thereby significantly degrading the performance. A reduction over the threads within the block BnB_n is then performed using the CUB54 library to accumulate the partial density, which is stored in shared memory (denoted as ρshared\rho_{\mathrm{shared}}). Finally, ρshared\rho_{\mathrm{shared}} is written to the global density output ρ\rho in parallel, with each thread responsible for one grid point. It is clear that the number of global memory writes is strictly at its theoretical minimum, NgridN_{\mathrm{grid}}, and that the global memory latency does not affect the compute-dominant steps. Together, these two factors are key to the high performance of our GPU implementation.

The Fock matrix build Eq. (4) follows a simpler workflow, as outlined in Algorithm 2. The real-space Hxc potential (vHxcv_{\mathrm{Hxc}}) is first loaded into shared memory, enabling low-latency access by all threads within a thread block. The primitive Gaussian shell pairs contributing to the current grid block are then processed in parallel. Each thread handles one shell pair, evaluates its values on the grid points using the recursion relations Eqs. (24) and (25), and contracts the result with vHxcv_{\mathrm{Hxc}} to form the local Fock matrix contribution FlocalF^{\mathrm{local}}. For meta-GGA functionals, we also add contributions from the kinetic energy density,

Fμν∈Λplocal=12vxcmGGA(r)∇ga(r)⋅∇gb(r).F^{\mathrm{local}}_{\mu\nu\in\Lambda_p} = \frac{1}{2}v_{\mathrm{xc}}^{\mathrm{mGGA}}(r)\nabla g_a(r)\cdot\nabla g_b(r).

Finally, FlocalF^{\mathrm{local}} is reduced to the global Fock matrix (in the primitive basis; the transformation from the primitive to the contracted basis is performed outside the kernel via efficient sparse matrix multiplications) using atomicAdd. Two aspects of this design are critical for performance. First, all threads in a block simultaneously read vHxcv_{\mathrm{Hxc}} at the same grid point from shared memory, which effectively minimizes shared-memory access latency compared to unordered access. Second, each thread updates distinct shell-pair elements in the global Fock matrix, thereby minimizing write contention and preventing the severe latency penalties that would otherwise arise from contended atomicAdd operations.

Image not extracted

Figure 3.

Algorithm 3. Workflow of energy gradient
1  __global__ ∇_A E; #A iterates over atoms
2  in CUDA block B_n:
3      __shared__ v_Hxc(r ∈ B_n);
4      n_batch = size({Λ_p}_{B_n}) // 64 + 1;
5      thread_id = threadIdx.x;
6      for batch_idx in range(n_batch):
7          p = batch_idx * 64 + thread_id;
8          Read D_{μν∈Λ_p};
9          [∇_A E^{local}, ∇_B E^{local}] = 0;
10         for r in B_n:
11             ∇_A E^{local} += Σ_{μν∈Λ_p} D_{μν}v_Hxc(r)∇_AΛ_p(r);
12             ∇_B E^{local} += Σ_{μν∈Λ_p} D_{μν}v_Hxc(r)∇_BΛ_p(r);
13         atomicAdd(∇_A E, ∇_A E^{local});
14         atomicAdd(∇_B E, ∇_B E^{local});

Finally, for the computation of nuclear gradients, the contribution from the Hxc potential is evaluated in a way analogous to Algorithm 2, except that gradients of Gaussian pairs with respect to nuclear coordinates are evaluated (denoted as ∇AΛp\nabla_A\Lambda_p), and that the energy gradient is obtained directly by contracting the density matrix, vHxcv_{\mathrm{Hxc}}, and ∇AΛp\nabla_A\Lambda_p, as shown in Algorithm 3 (lines 10–12). For meta-GGA functionals, the contribution from the kinetic energy density is computed as

∇AElocal+∑μν∈ΛpDμνvxcmGGA(r)∇A(∇ga(r)⋅∇gb(r)),\nabla_A E^{\mathrm{local}}+\sum_{\mu\nu\in\Lambda_p}D_{\mu\nu}v_{\mathrm{xc}}^{\mathrm{mGGA}}(\mathbf{r})\nabla_A\left(\nabla g_a(\mathbf{r})\cdot\nabla g_b(\mathbf{r})\right),

which involves second-order derivatives of the basis functions.

Results and Discussions

We have implemented the multigrid FFTDF approach in PySCF and GPU4PySCF for CPUs and NVIDIA GPUs, respectively. All results were obtained using forks of PySCF[55] and GPU4PySCF[56]. In this section, we examine their performance. The benchmark systems include water clusters, crystalline benzene, diamond, and LiF. The geometries of the water clusters were taken from the CP2K benchmark suit,[42] while those of crystalline benzene and LiF were adopted from Ref. 57. Conventional diamond supercells were constructed using the Atomic Simulation Environment (ASE).[58] All calculations were performed within restricted KS-DFT using the PBE[59] functional and the GTH-PADE[44] pseudopotentials. For water and benzene, the GTH-TZV2P[60] basis set was employed, whereas the GTH-DZVP[60] basis set was used for diamond and LiF. A plane wave kinetic energy cutoff of 140 a.u. was used. The GTO screening threshold τ\tau in Eq. (20) was set to 10−610^{-6}, which gives an accuracy comparable to that obtained by setting the keyword EPS DEFAULT to 10−1210^{-12} in CP2K, the program we compare our code with. Benchmark calculations were run on NVIDIA A100 (80 GB) and H100 (80 GB) GPUs, as well as on Intel Cascade Lake 8276 CPUs.

First, we report the wall times for SCF iterations and nuclear gradient calculations in Table I and Figure 1. For SCF iterations, GPU4PySCF running on an NVIDIA A100 GPU achieves a speedup of 4–10× relative to PySCF running on 28 CPU cores. Using an H100 GPU provides an additional 2× speedup over the A100, consistent with the ratio of their peak FP64 throughputs.

In Table II and Figure 2, we further compare the Fock build times of our implementations with those of CP2K, which is widely regarded as one of the most efficient codes for Gaussian-Plane-Wave KS-DFT. For CP2K, the GPU benchmarks were performed using the Docker image version 2025.1, while the CPU benchmarks [run with MPI (Message Passing Interface)] employed the 2025.2 Docker image built for Intel Cascade Lake CPUs with AVX-512 support. On CPUs, PySCF is slower than CP2K by a factor of approximately two. This can be attributed to less efficient parallelization, as reflected by the comparable single-core CPU timings reported in parentheses in Table II. In contrast, GPU4PySCF exhibits a significant performance advantage for water and benzene, giving a roughly 3× speedup over the GPU CP2K implementation on A100 GPUs. This advantage is smaller for diamond and LiF. This may be due to the larger fraction of diffuse Gaussian functions in these systems, which leads to a larger amount of redundant computation of Gaussian pair prefactors across different grid blocks.

For nuclear gradient calculations, the GPU speedup is generally smaller than that observed for SCF iterations because the calculation of one-electron integrals has not been fully optimized for GPUs. For example, in water clusters studied here that have more than 1000 basis functions, the HxcH_{\mathrm{xc}} potential accounts for less than 25% of the total gradient wall time, as shown in Fig. 3b. A similar trend is observed in the energy evaluations, because as the system size increases, the eigensolver and DIIS[61] steps dominate the computational cost (see Fig. 3a). We leave further optimization of these remaining components beyond the Fock build to future work. Nevertheless, even in its current form, our GPU-accelerated KS-DFT implementation is highly efficient for medium-sized systems. For example, the energy and nuclear gradient calculation for a 256-molecule water cluster (with 10,000 basis functions) finishes in only 30 seconds on an H100 GPU.

We next present the roofline analysis for our GPU-accelerated multigrid FFTDF implementation. For the electron density build, as shown in Figure 4a, the kernels for computing ss-shell Gaussian pair contributions [denoted as (s∣s)(s|s)] achieve approximately 50% of the peak FP64 throughput on A100 GPUs, while the (d∣d)(d|d) and (f∣f)(f|f) kernels reach about 70% of peak performance. The higher effective FLOP rate for larger angular momenta arises from the additional arithmetic associated with generating more Cartesian components within a shell of Gaussian orbitals, whose instructions can effectively hide shared-memory latency during the reduction. This improves utilization of the FP64 cores within each streaming multiprocessor (SM). In contrast, a performance degradation is observed when gg-shell orbitals are involved. In this case, the increased number of intermediate variables exceeds the available register capacity, requiring the use of global memory and rendering the kernels memory-bandwidth-bound. The primary bottleneck is the reduction of the partial densities in shared memory at each recursion step (Algorithm 1, line 11). Because this reduction requires thread synchronization, the latency associated with shared-memory access can no longer be hidden by instruction-level parallelism.

Roofline plots for the electron density build, effective potential build, and effective potential gradient kernels

Figure 4. FLOP performance of the custom CUDA kernels analyzed using the roofline model benchmarked on the NVIDIA A100 GPU. The solid blue line represents the official peak FP64 FLOP rate of 9.7 TFLOP/s with no bandwidth constraint (horizontal) and the peak FP64 FLOP rate constrained by the peak memory bandwidth of 1.6 TB/s (diagonal). The theoretical arithmetic intensity of 6.1 FLOP/byte marks the boundary between the memory-bound zone and the compute-bound zone for the A100 GPU. The benchmark calculations were performed for a 32-water cluster at the PBE/GTH-cc-pVQZ level of theory.

The kernels for constructing the Coulomb matrix are more compute-bound, as shown in Figure 4b. This is because the HxcH_{\mathrm{xc}} potential is stored in shared memory and can be broadcast to all threads during each recursion step (Algorithm 2, line 10) without requiring synchronization, resulting in minimal shared memory traffic. Consequently, these kernels can achieve approximately 80% of the peak FP64 throughput on A100 GPUs. A similar performance degradation is again observed when gg-shell orbitals are involved, reflecting the increased register pressure associated with higher angular momentum.

The kernels for computing the nuclear gradient exhibit even higher arithmetic intensity (see Figure 4c), as the density matrix is contracted with the Fock matrix on the fly, although we observe that the low angular momentum kernels, such as the (s∣s)(s|s) and (p∣s)(p|s) kernels, do not fully saturate the compute units.

SystemNbasisN_{\mathrm{basis}}GPU4PySCF H100GPU4PySCF A100PySCF 28-core CPUGPU4PySCF H100GPU4PySCF A100PySCF 28-core CPU
1 SCF iteration on averageNuclear gradient
GTH-TZV2P basis set
32H2_2O12800.060.080.520.310.391.25
64H2_2O25600.130.211.830.470.703.33
128H2_2O51200.430.798.971.151.999.03
256H2_2O102401.863.8052.524.027.6029.37
512H2_2O2048013.4230.58226.2817.0738.11108.30
1 × 1 × 1 benzene1860.320.080.100.530.240.16
2 × 2 × 2 benzene14880.370.150.950.700.581.35
3 × 3 × 3 benzene50220.940.917.921.832.738.54
4 × 4 × 4 benzene119043.446.3856.957.2913.0432.68
GTH-DZVP basis set
2 × 2 × 2 diamond4160.070.090.230.510.541.48
3 × 3 × 3 diamond14040.120.221.000.610.935.56
4 × 4 × 4 diamond33280.310.624.132.193.3915.95
5 × 5 × 5 diamond65000.981.9113.187.3711.4538.19
6 × 6 × 6 diamond112322.795.8146.6218.5628.3684.56
2 × 2 × 2 LiF8640.640.250.651.111.1911.37
3 × 3 × 3 LiF29160.530.634.011.972.3741.76
4 × 4 × 4 LiF69122.042.1424.796.169.14119.94

Table 1. Wall times (in seconds) for single SCF iterations on average and nuclear gradient calculations within restricted KS-DFT for various systems, using the PBE functional and the GTH-PADE pseudopotentials.

Figure 1. Speedups of GPU4PySCF on NVIDIA H100 and A100 GPUs for a single SCF iteration and nuclear gradient calculation, relative to the corresponding PySCF CPU timings reported in Table I.

Conclusion

We have described our implementation of the multigrid Gaussian-Plane-Wave (FFTDF) Kohn-Sham DFT algorithm that enables highly-performant KS-DFT calculations on both CPUs and GPUs. Currently our CPU implementation supports KS-DFT simulations with up to 100,000 basis functions on a single shared memory

node, while the GPU implementation provides an order-of-magnitude speedup over the single-node CPU performance, subject to available device memory. Notably, by implementing two-level parallelism, our GPU kernels achieve approximately 80% of the peak FP64 throughput, leading to state-of-the-art performance without degradation for orbitals up to the ff shell.

The implementation in PySCF establishes a strong open-source foundation for many applications in computational chemistry and computational materials science, including large-scale materials screening and ab initio molecular dynamics. The full potential of our approach can be further realized through PySCF’s support for QM/MM and quantum embedding methods, en-

SystemNbasisN_{\mathrm{basis}}GPU4PySCF H100GPU4PySCF A100CP2K A100PySCF 28-core CPUCP2K 28-core CPU
GTH-TZV2P basis set
32H2_2O12800.040.050.320.320.21
64H2_2O25600.060.100.470.68 (12.95)0.42 (9.12)
128H2_2O51200.120.230.811.57 (24.69)0.85 (20.22)
256H2_2O102400.330.601.563.56 (41.01)1.73 (42.66)
512H2_2O204800.945.483.328.08 (87.00)5.54 (68.24)
1024H2_2O40960–a^{a}––a^{a}––a^{a}–23.5010.36
2048H2_2O81920–a^{a}––a^{a}––a^{a}–68.4916.78
1 × 1 × 1 benzene1860.310.070.180.090.08
2 × 2 × 2 benzene14880.330.110.540.710.54
3 × 3 × 3 benzene50220.640.361.912.741.81
4 × 4 × 4 benzene119041.171.474.727.084.25
GTH-DZVP basis set
2 × 2 × 2 diamond4160.050.080.140.210.19
3 × 3 × 3 diamond14040.090.180.250.800.40
4 × 4 × 4 diamond33280.190.410.522.050.98
5 × 5 × 5 diamond65000.410.860.994.361.88
6 × 6 × 6 diamond112320.771.581.968.253.38
2 × 2 × 2 LiF8640.630.230.340.540.73
3 × 3 × 3 LiF29160.460.490.962.152.59
4 × 4 × 4 LiF69121.471.072.556.876.68

Table 2. Wall times (in seconds) for one Fock build on average using different packages. Single-core CPU times are reported in parentheses for a subset of water clusters.

Figure 2. Speedups of GPU4PySCF on NVIDIA H100 and A100 GPUs, and of CP2K on A100 GPUs and CPUs, for a single Fock build, relative to the corresponding PySCF CPU timings reported in Table II.

abling significantly larger quantum mechanical regions to be treated at the DFT level. Our GPU implementation strategy may also be useful in the development of fast Gaussian-Plane-Wave exact exchange algorithms. We will report on these developments in future work.

Acknowledgements

RL (development of GPU multigrid code) and GKC (project supervision) were supported by the US Department of Energy, Office of Science, through Award No. DE-SC0023318. XZ (development of CPU multigrid code) was supported by the Center for Molecular Magnetic Quantum Materials, an Energy Frontier Research Center funded by the U.S. Department of Energy, Office of Science, Basic Energy Sciences under Award No. DE-SC0019330. Software packaging, integration, and infrastructure development in PySCF was supported by the US National Science Foundation under Award 2513474.

This research used resources of the National Energy Research Scientific Computing Center (NERSC), a U.S. Department of Energy Office of Science User Facility located at Lawrence Berkeley National Laboratory, operated under Contract No. DE-AC02-05CH11231 using NERSC award ERCAP-0024087. Part of the computations were conducted in the Resnick High Performance Computing Center, a facility supported by Resnick Sustainability Institute at the California Institute of Technology. GKC is a Simons Investigator in Physics.

Figure 3. The computational time ratio for subroutines in an SCF cycle (a) and nuclear gradient calculation (b) for water clusters, benchmarked on H100 GPUs. In the legends, “Hxc” denotes Hxc potential, and “Pseudo” denotes pseudopotential.

APPENDIX

GTO screening on GPUs

The screening procedure consists of two steps: identifying the contributing Gaussian pairs, and distributing these pairs to the grid blocks with which they overlap. The corresponding pseudocode is given in Algorithms 4 and 5, respectively. In the former step, primitive

Gaussian pairs are processed in parallel and their spatial boundaries are computed. Pairs that overlap with the reference unit cell have their indices and boundaries recorded for subsequent grid block assignment. In the latter step, we first count the number of contributing pairs for each grid block (n_pairs_per_block) based on the pairs’ boundaries. The indices of the contributing pairs are then populated into a list (indices_on_blocks). Together, they identify the Gaussian pairs contributing to each grid block. To maximize compute throughput, the pair indices are first pooled in shared memory, and then written to global memory only when the buffer is full (Algorithm 5, lines 22–29). To achieve a more fine-grained screening, the screened Gaussian pairs are evaluated on the corresponding grid blocks, and are removed from the list if the absolute values do not exceed the accuracy threshold τ\tau (Algorithm 5, line 30-41).

Workflow of Gaussian pair screening
1Count number of contributing pairs NpairN_{\mathrm{pair}};
2__global__ pair_index[N_pair];
3__global__ boundary[N_pair];
4__global__ recorded_count;
5in CUDA block BxB_x, ByB_y:
6(μ,T1)(\mu,T_1) = threadIdx.x + BxB_x * blockDim.x;
7(ν,T2)(\nu,T_2) = threadIdx.y + ByB_y * blockDim.y;
8__shared__ offset;
9is_valid = 0;
10Compute boundaries qmin⁡q_{\min}, qmax⁡q_{\max} in fractional coordinates);
11if qmin⁡,τ<1q_{\min,\tau}<1 and qmax⁡,τ>0q_{\max,\tau}>0 for all τ∈{x,y,z}\tau\in\{x,y,z\}:
12is_valid = 1;
13Change qmin⁡q_{\min}, qmax⁡q_{\max} to grid point indices, and extend to block boundaries (multiple of 4 in grid point indices)
14prefix_sum = 0;
15aggregated = 0;
16ExclusiveSum(is_valid, prefix_sum, aggregated);
17if master thread:
18offset = atomicAdd(recorded_count, aggregated);
19index = offset + prefix_sum;
20pair_index[index] = (\mu,\nu,T_1,T_2);
21boundary[index] = (q_min,q_max);

Table 4.

Non-orthogonal lattices

We denote the three lattice vectors as {R1,R2,R3}\{\mathbf{R}_1,\mathbf{R}_2,\mathbf{R}_3\}, and the corresponding fractional coordinates of the grid points are noted as {ui,vj,wk}\{u_i,v_j,w_k\}. Given a starting point with fractional coordinate {u0,v0,w0}\{u_0,v_0,w_0\} and absolute coordinate r0=u0R1+v0R2+w0R3\mathbf{r}_0=u_0\mathbf{R}_1+v_0\mathbf{R}_2+w_0\mathbf{R}_3, the fractional coordinate of each point can be expressed simply as ui=i/N1+u0u_i=i/N_1+u_0, vj=j/N2+v0v_j=j/N_2+v_0, wk=k/N3+w0w_k=k/N_3+w_0, where N1N_1, N2N_2, N3N_3 are the number of grid points along each lattice vector. The recursion form for the computation of a

Workflow of mapping Gaussian pair to grid blocks
1__global__ n_pairs_per_block[n_blocks];
2in CUDA block BnB_n:
3count = 0;
4for batch in {Λp}\{\Lambda_p\}:
5if Bn∈(qmin⁡,qmax⁡)B_n \in(q_{\min},q_{\max}):
6count++;
7n_pairs_per_block[B_n] = reduce(count);
8__global__ offsets = {0} + cumsum(n_pairs_per_block);
9__global__ indices_on_blocks[offsets[-1]];
10in CUDA block BnB_n:
11__shared__ pool[pool_size];
12n_pooled = 0;
13offset = offsets[B_n];
14for batch in {Λp}\{\Lambda_p\}:
15p = batch_idx * batch_size + threadIdx.x;
16is_valid = 0;
17if Bn∈(qmin⁡,qmax⁡)B_n \in(q_{\min},q_{\max}):
18is_valid = 1;
19aggregated = 0;
20prefix_sum = 0;
21ExclusiveSum(is_valid, prefix_sum, aggregated);
22if aggregated + n_pooled > pool_size:
23Store pooled pairs to indices_on_blocks;
24offset += aggregated;
25n_pooled = 0;
26pool[n_pooled + prefix_sum] = p;
27n_pooled += aggregated;
28if n_pooled > 0:
29Store pooled pairs to indices_on_blocks;
30in CUDA block BnB_n:
31n_batch = size{\Lambda_p}_B_n // 64 + 1;
32offset = offsets[B_n];
33for batch_idx in range(n_batch):
34p = batch_idx * 64 + thread.id;
35max_value = 0;
36for rr in BnB_n:
37`max_value = max(max_value,4\pi^2 \Lambda_p(r));`
38if max_value < τ:
39indices_on_blocks[offset + p] = -1;
40atomicAdd(n_pairs_per_blocks[B_n], -1);
41Filter negative pair indices in indices_on_blocks;

Table 5.

Gaussian pair becomes

gab00(ui+1,0,0)=gab00(ui,0,0)e−(2i+1)αP∣dR1∣2e−2αP(r0−P)⋅dR1(30)g_{ab}^{00}(u_{i+1},0,0)=g_{ab}^{00}(u_i,0,0)e^{-(2i+1)\alpha_P|\mathbf{dR}_1|^2}e^{-2\alpha_P(\mathbf{r}_0-\mathbf{P})\cdot\mathbf{dR}_1} \tag*{(30)}
gab00(ui,vj+1,0)=gab00(ui,vj,0)e−(2j+1)αP∣dR2∣2e−2αP(r0−P)⋅dR2e−2uiαpdR1⋅dR2(31)g_{ab}^{00}(u_i,v_{j+1},0)=g_{ab}^{00}(u_i,v_j,0)e^{-(2j+1)\alpha_P|\mathbf{dR}_2|^2}e^{-2\alpha_P(\mathbf{r}_0-\mathbf{P})\cdot\mathbf{dR}_2} e^{-2u_i\alpha_p\mathbf{dR}_1\cdot\mathbf{dR}_2} \tag*{(31)}
gab00(ui,vj,wk+1)=gab00(ui,vj,wk)e−(2k+1)αP∣dR3∣2e−2αP(r0−P)⋅dR3×e−2uiαpdR1⋅dR3e−2vjαpdR2⋅dR3(32)\begin{aligned} g_{ab}^{00}(u_i,v_j,w_{k+1})={}&g_{ab}^{00}(u_i,v_j,w_k)e^{-(2k+1)\alpha_P|\mathbf{dR}_3|^2}e^{-2\alpha_P(\mathbf{r}_0-\mathbf{P})\cdot\mathbf{dR}_3}\\ &\mathrel{}\times e^{-2u_i\alpha_p\mathbf{dR}_1\cdot\mathbf{dR}_3}e^{-2v_j\alpha_p\mathbf{dR}_2\cdot\mathbf{dR}_3} \tag*{(32)} \end{aligned}

with initial condition

gab00(0,0,0)=e−αP∣r0−P∣2.(33)g_{ab}^{00}(0,0,0)=e^{-\alpha_P|\mathbf{r}_0-\mathbf{P}|^2}. \tag*{(33)}

References

  1. [1]R. Sakamaki, T. Narumi, and K. Yasuoka, “412 Implementation and Evaluation of Particle Mesh Ewald Method on GPU for Molecular Dynamics Simulation,” The Proceedings of The Computational Mechanics Conference 2009.22, 756–757 (2009).DOI
  2. [2]T.-S. Lee, D. S. Cerutti, D. Mermelstein, C. Lin, S. LeGrand, T. J. Giese, A. Roitberg, D. A. Case, R. C. Walker, and D. M. York, “Gpu-accelerated molecular dynamics and free energy methods in amber18: performance enhancements and new features,” Journal of chemical information and modeling 58, 2043–2050 (2018).DOI
  3. [3]Z. Fan, Y. Wang, P. Ying, K. Song, J. Wang, Y. Wang, Z. Zeng, K. Xu, E. Lindgren, J. M. Rahm, A. J. Gabourie, J. Liu, H. Dong, J. Wu, Y. Chen, Z. Zhong, J. Sun, P. Erhart, Y. Su, and T. Ala-Nissila, “GPUMD: A package for constructing accurate machine-learned potentials and performing highly efficient atomistic simulations,” The Journal of Chemical Physics 157, 114801 (2022).DOI
  4. [4]P. Eastman, R. Galvelis, R. P. Peláez, C. R. Abreu, S. E. Farr, E. Gallicchio, A. Gorenko, M. M. Henry, F. Hu, J. Huang, et al., “Openmm 8: molecular dynamics simulation with machine learning potentials,” The Journal of Physical Chemistry B 128, 109–116 (2023).arxiv.org/abs/2310.03121
  5. [5]K. Yasuda, “Accelerating density functional calculations with graphics processing unit,” Journal of Chemical Theory and Computation 4, 1230–1236 (2008).DOI
  6. [6]I. S. Ufimtsev and T. J. Martínez, “Graphical Processing Units for Quantum Chemistry,” Computing in Science & Engineering 10, 26–34 (2008).DOI
  7. [7]I. S. Ufimtsev and T. J. Martínez, “Quantum Chemistry on Graphical Processing Units. 1. Strategies for Two-Electron Integral Evaluation,” Journal of Chemical Theory and Computation 4, 222–231 (2008).DOI
  8. [8]I. S. Ufimtsev and T. J. Martinez, “Quantum Chemistry on Graphical Processing Units. 2. Direct Self-Consistent-Field Implementation,” Journal of Chemical Theory and Computation 5, 1004–1015 (2009).
  9. [9]I. S. Ufimtsev and T. J. Martinez, “Quantum Chemistry on Graphical Processing Units. 3. Analytical Energy Gradients, Geometry Optimization, and First Principles Molecular Dynamics,” Journal of Chemical Theory and Computation 5, 2619–2628 (2009).DOI
  10. [10]N. Luehr, I. S. Ufimtsev, and T. J. Martínez, “Dynamic Precision for Electron Repulsion Integral Evaluation on Graphical Processing Units (GPUs),” Journal of Chemical Theory and Computation 7, 949–954 (2011).DOI
  11. [11]M. Hacene, A. Anciaux-Sedrakian, X. Rozanska, D. Klahr, T. Guignon, and P. Fleuret-Lessard, “Accelerating VASP electronic structure calculations using graphic processing units,” Journal of Computational Chemistry 33, 2581–2589 (2012).DOI
  12. [12]Y. Miao and K. M. Merz, “Acceleration of Electron Repulsion Integral Evaluation on Graphics Processing Units via Use of Recurrence Relations,” Journal of Chemical Theory and Computation 9, 965–976 (2013).DOI
  13. [13]S. Maintz, B. Eck, and R. Dronskowski, “cuVASP: A GPU-Accelerated Plane-Wave Electronic-Structure Code ,” in High Performance Computing in Science and Engineering ’11, edited by W. E. Nagel, D. B. Kröner, and M. M. Resch (Springer Berlin Heidelberg, Berlin, Heidelberg, 2012) pp. 201–205.DOI
  14. [14]J. Kussmann and C. Ochsenfeld, “Hybrid CPU/GPU Integral Engine for Strong-Scaling Ab Initio Methods,” Journal of Chemical Theory and Computation 13, 3153–3159 (2017).DOI
  15. [15]J. Romero, E. Phillips, R. Ruetsch, M. Fattal, F. Spiga, and P. Giannozzi, “A Performance Study of Quantum ESPRESSO’s PWscf Code on Multi-core and GPU Systems,” in High Performance Computing Systems. Performance Modeling, Benchmarking, and Simulation, Vol. 10724, edited by S. Jarvis, S. Wright, and S. Hammond (Springer International Publishing, Cham, 2018) pp. 67–87.DOI
  16. [16]S. Seritan, C. Bannwarth, B. S. Fales, E. G. Hohenstein, C. M. Isborn, S. I. L. Kokkila-Schumacher, X. Li, F. Liu, N. Luehr, J. W. Snyder, C. Song, A. V. Titov, I. S. Ufimtsev, L.-P. Wang, and T. J. Martínez, “TERACHEM : A graphical processing unit - ACCELERATED electronic structure package for LARGE-SCALE ab initio molecular dynamics,” WIREs Computational Molecular Science 11, e1494 (2021).DOI
  17. [17]G. M. J. Barca, M. Alkan, J. L. Galvez-Vallejo, D. L. Poole, A. P. Rendell, and M. S. Gordon, “Faster Self-Consistent Field (SCF) Calculations on GPU Clusters,” Journal of Chemical Theory and Computation 17, 7486–7503 (2021).DOI
  18. [18]J. Qi, Y. Zhang, and M. Yang, “A hybrid CPU/GPU method for Hartree–Fock self-consistent-field calculation,” The Journal of Chemical Physics 159, 104101 (2023).DOI
  19. [19]Y. Wang, D. Hait, K. G. Johnson, O. J. Fajen, J. H. Zhang, R. D. Guerrero, and T. J. Martínez, “Extending GPU-accelerated Gaussian integrals in the TeraChem software package to f type orbitals: Implementation and applications,” The Journal of Chemical Physics 161, 174118 (2024).
  20. [20]R. Stocks and G. M. Barca, “Efficient algorithms for gpu accelerated evaluation of the dft exchange-correlation functional,” Journal of Chemical Theory and Computation 21, 10263–10280 (2025).DOI
  21. [21]X. Wu, Q. Sun, Z. Pu, T. Zheng, W. Ma, W. Yan, Y. Xia, Z. Wu, M. Huo, X. Li, et al., “Enhancing gpu-acceleration in the python-based simulations of chemistry frameworks,” Wiley Interdisciplinary Reviews: Computational Molecular Science 15, e70008 (2025).DOI
  22. [22]G. Ambrogio, L. Donà, J. K. Desmarais, C. Ribaldone, S. Casassa, F. Spiga, B. Civalleri, and A. Erba, “Accelerated linear algebra for large scale DFT calculations of materials on CPU/GPU architectures with CRYSTAL,” The Journal of Chemical Physics 162, 082501 (2025).
  23. [23]L. Vogt, R. Olivares-Amaya, S. Kermes, Y. Shao, C. Amador-Bedolla, and A. Aspuru-Guzik, “Accelerating resolution-of-the-identity second-order møller–plesset quantum chemistry calculations with graphical processing units,” The Journal of Physical Chemistry A 112, 2049–2057 (2008).DOI
  24. [24]C. Song and T. J. Martínez, “Atomic orbital-based sos-mp2 with tensor hypercontraction. i. gpu-based tensor construction and exploiting sparsity,” The Journal of Chemical Physics 144, 174111 (2016).DOI
  25. [25]R. Stocks, E. Palethorpe, and G. M. J. Barca, “High-Performance Multi-GPU Analytic RI-MP2 Energy Gradients,” Journal of Chemical Theory and Computation 20, 2505–2519 (2024).DOI
  26. [26]A. E. DePrince III and J. R. Hammond, “Coupled cluster theory on graphics processing units i. the coupled cluster doubles method ” Journal of chemical theory and computation 7, 1287–1295 (2011).
  27. [27]J. W. Snyder, B. S. Fales, E. G. Hohenstein, B. G. Levine, and T. J. Martínez, “A direct-compatible formulation of the coupled perturbed complete active space self-consistent field equations on graphical processing units,” The Journal of Chemical Physics 146, 174113 (2017).DOI
  28. [28]D. Datta and M. S. Gordon, “Accelerating coupled-cluster calculations with gpus: An implementation of the density-fitted ccsd(t) approach for heterogeneous computing architectures using openmp directives,” Journal of Chemical Theory and Computation 19, 7640–7657 (2023).DOI
  29. [29]E. G. Hohenstein and T. J. Martínez, “GPU acceleration of rank-reduced coupled-cluster singles and doubles,” The Journal of Chemical Physics 155, 184110 (2021).DOI
  30. [30]J. Yan, L. Li, and C. O’Grady, “Graphics Processing Unit acceleration of the Random Phase Approximation in the projector augmented wave method,” Computer Physics Communications 184, 2728–2733 (2013).DOI
  31. [31]T. Jiang, M. K. Baumgarten, P.-F. o. Loos, A. Mahajan, A. Scemama, S. F. Ung, J. Zhang, F. D. Malone, and J. Lee, “Improved modularity and new features in ipie: Toward even larger afqmc calculations on cpus and gpus at zero and finite temperatures,” The Journal of Chemical Physics 161, 162502 (2024).DOI
  32. [32]Y. Huang, Z. Guo, H. Q. Pham, and D. Lv, “Gpu-accelerated auxiliary-field quantum monte carlo with multi-slater determinant trial states,” (2024), arXiv:2406.08314 [physics.chem-ph].arxiv.org/abs/2406.08314
  33. [33]C. Xiang, W. Jia, W.-H. Fang, and Z. Li, “Distributed multi-gpu ab initio density matrix renormalization group algorithm with applications to the p-cluster of nitrogenase,” Journal of Chemical Theory and Computation 20, 775–786 (2024).
  34. [34]“CUDA programming guide,” https://docs.nvidia.com/cuda/cuda-programming-guide.
  35. [35]R. Li, Q. Sun, X. Zhang, and G. K.-L. Chan, “Introducing gpu acceleration into the python-based simulations of chemistry framework,” The Journal of Physical Chemistry A 129, 1459–1468 (2025).DOI
  36. [36]Q. Sun, X. Zhang, S. Banerjee, P. Bao, M. Barbry, N. S. Blunt, N. A. Bogdanov, G. H. Booth, J. Chen, Z.-H. Cui, et al., “Recent developments in the pyscf program package,” The Journal of chemical physics 153, 024109 (2020).DOI
  37. [37]G. Lippert, J. Hutter, and M. Parrinello, “A hybrid gaussian and plane wave density functional scheme,” Molecular Physics 92, 477–488 (1997).DOI
  38. [38]G. Lippert, J. Hutter, and M. Parrinello, “The gaussian and augmented-plane-wave density functional method for ab initio molecular dynamics simulations,” Theoretical Chemistry Accounts 103, 124–140 (1999).DOI
  39. [39]A. F. White, C. Li, X. Zhang, and G. K.-L. Chan, “Quantum harmonic free energies for biomolecules and nanomaterials,” Nature Computational Science 3, 328–333 (2023).DOI
  40. [40]K. E. Smyser, A. White, and S. Sharma, “Use of multigrids to reduce the cost of performing interpolative separable density fitting,” The Journal of Physical Chemistry A 128, 7451–7461 (2024).arxiv.org/abs/2404.09373
  41. [41]C. Li, O. Sharin, S. Yuan, and G. K.-L. Chan, “Image super-resolution inspired electron density prediction,” Nature Communications 16, 4811 (2025).DOI
  42. [42]J. VandeVondele, M. Krack, F. Mohamed, M. Parrinello, T. Chassaing, and J. Hutter, “Quickstep: Fast and accurate density functional calculations using a mixed gaussian and plane waves approach,” Computer Physics Communications 167, 103–128 (2005).DOI
  43. [43]S. Lehtola, C. Steigemann, M. J. Oliveira, and M. A. Marques, “Recent developments in libcxx—a comprehensive library of functionals for density functional theory,” SoftwareX 7, 1–5 (2018).DOI
  44. [44]C. Hartwigsen, G. Goedecker, and J. Hutter, “Relativistic separable dual-space gaussian pseudopotentials from h to rn,” Physical Review B 58, 3641 (1998).DOI
  45. [45]O. Schütt, P. Messmer, J. Hutter, and J. VandeVondele, “GPU-accelerated sparse matrix-matrix multiplication for linear scaling density functional theory,” in Electronic Structure Calculations on Graphics Processing Units (John Wiley & Sons, Ltd, Chichester, UK, 2016) pp. 173–190.
  46. [46]T. D. Kühne, M. Iannuzzi, M. Del Ben, V. V. Rybkin, P. Seewald, F. Stein, T. Laino, R. Z. Khaliullin, O. Schütt, F. Schiffmann, D. Golze, J. Wilhelm, M. C. Chulkov, M. H. Bani-Hashemian, V. Weber, U. Boštürk, M. Taillefumier, A. S. Jakobovits, A. Lazzaro, H. Pabst, T. Müller, R. Schade, M. Guidon, S. Ander­matt, N. Holmberg, G. K. Schenter, A. Hehn, A. Bussy, F. Belleflamme, G. Tabacchi, A. Glöß, M. Lass, I. Bethune, C. J. Mundy, C. Plessl, M. Watkins, J. VandeVondele, M. Krack, and J. Hutter, “CP2K: An electronic structure and molecular dynamics software package - quickstep: Efficient and accurate electronic structure calculations,” J. Chem. Phys. 152, 194103 (2020).DOI
  47. [47]A. Heincke, G. Henry, M. Hutchinson, and H. Pabst, “LIBXSMM: Accelerating small matrix multiplications by run-time code generation,” in SC16: International Conference for High Performance Computing, Networking, Storage and Analysis (IEEE, 2016).
  48. [48]J. Hutter, M. Iannuzzi, F. Schiffmann, and J. VandeVondele, “Cp2k: Atomistic simulations of condensed matter systems,” Wiley Interdiscip. Rev. Comput. Mol. Sci. 4, 15–25 (2014).DOI
  49. [49]U. Boršt­nik, J. VandeVondele, V. Weber, and J. Hutter, “Sparse matrix multiplication: The distributed block-compressed sparse row library,” Parallel Comput. 40, 47–58 (2014).
  50. [50]A. Marek, V. Blum, R. Johanni, V. Havu, B. Lang, T. Auckenthaler, A. Heinecke, H.-J. Bungartz, and H. Lederer, “The ELPA library: scalable parallel eigenvalue solutions for electronic structure theory and computational science,” J. Phys. Condens. Matter 26, 213201 (2014).DOI
  51. [51]M. Krack, “Pseudopotentials for H to kr optimized for gradient-corrected exchange-correlation functionals,” Theor. Chem. Acc. 114, 145–152 (2005).DOI
  52. [52]M. Frigo and S. G. Johnson, “The design and implementation of FFTW3,” Proc. IEEE Inst. Electr. Electron. Eng. 93, 216–231 (2005).DOI
  53. [53]S. Goedecker, M. Teter, and J. Hutter, “Separable dual-space gaussian pseudopotentials,” Phys. Rev. B Condens. Matter 54, 1703–1710 (1996).pubmed.ncbi.nlm.nih.gov/9986014
  54. [55]https://github.com/fishjojo/pyscf/tree/multigrid2_large_system.
  55. [56]https://github.com/Walter-Feng/gpu4pyscf/tree/multi-grid/publish.
  56. [58]A. H. Larsen, J. J. Mortensen, J. Blomqvist, I. E. Castelli, R. Christensen, M. Dulak, J. Friis, M. N. Groves, B. Hammer, C. Hargus, E. D. Hermes, P. C. Jennings, P. B. Jensen, J. Kermode, J. R. Kitchin, E. L. Kolsbjerg, J. Kubal, K. Kaasbjerg, S. Lysgaard, J. B. Maronsson, T. Maxson, T. Olsen, L. Pastewka, A. Peterson, C. Rostgaard, J. Schiøtz, O. Schütt, M. Strange, K. S. Thygesen, T. Vegge, L. Vilhelmsen, M. Walter, Z. Zeng, and K. W. Jacobsen, “The atomic simulation environment—a python library for working with atoms,” Journal of Physics: Condensed Matter 29, 273002 (2017).DOI
  57. [59]J. P. Perdew, K. Burke, and M. Ernzerhof, “Generalized gradient approximation made simple,” Phys. Rev. Lett. 77, 3865–3868 (1996).pubmed.ncbi.nlm.nih.gov/10062328
  58. [60]J. VandeVondele and J. Hutter, “Gipiee calculations on molecular systems in gas and condensed phases,” The Journal of chemical physics 127, 114105 (2007).pubmed.ncbi.nlm.nih.gov/17887826
  59. [61]P. Pulay, “Convergence acceleration of iterative sequences. the case of scf iteration,” Chemical Physics Letters 73, 393–398 (1980).DOI

Paper details

vlnc:W_fdapmpne
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Physics and Astronomy

Not recorded for this paper

View statement
Looking for related papers…
Contents