2026 Volume 39 Issue 2
Article Contents

Yehao Zeng, Zhenlin Zhang, Zhaolong Luo, Jun Gao, Sheng Chen, Wentiao Wu, Yexuan Lin, Yihong Zhang, Xinming Qin, Weiyi Wang, Zhiwen Zhuo, Shizhe Jiao, Wei Hu. KSSOLV-GPU 2.0: A Lightweight MATLAB Toolbox for GPU-Accelerated Plane-Wave Hybrid Functional and Spin-Polarized Density Functional Theory Calculations†[J]. Chinese Journal of Chemical Physics, 2026, 39(2): 182-196. doi: 10.1063/1674-0068/cjcp2511175
Citation: Yehao Zeng, Zhenlin Zhang, Zhaolong Luo, Jun Gao, Sheng Chen, Wentiao Wu, Yexuan Lin, Yihong Zhang, Xinming Qin, Weiyi Wang, Zhiwen Zhuo, Shizhe Jiao, Wei Hu. KSSOLV-GPU 2.0: A Lightweight MATLAB Toolbox for GPU-Accelerated Plane-Wave Hybrid Functional and Spin-Polarized Density Functional Theory Calculations†[J]. Chinese Journal of Chemical Physics, 2026, 39(2): 182-196. doi: 10.1063/1674-0068/cjcp2511175

KSSOLV-GPU 2.0: A Lightweight MATLAB Toolbox for GPU-Accelerated Plane-Wave Hybrid Functional and Spin-Polarized Density Functional Theory Calculations†

通讯作者: 陈斌, bchen63@163.com
  • 1. 

    沈阳化工大学材料科学与工程学院 沈阳 110142

  1. 本站搜索
  2. 百度学术搜索
  3. 万方数据库搜索
  4. CNKI搜索

Figures(7)  /  Tables(1)

Article Metrics

Article views(245) PDF downloads(3) Cited by(0)

Access History

KSSOLV-GPU 2.0: A Lightweight MATLAB Toolbox for GPU-Accelerated Plane-Wave Hybrid Functional and Spin-Polarized Density Functional Theory Calculations†

Abstract: KSSOLV (Kohn−Sham solver) is a MATLAB (Matrix Laboratory) toolbox designed for solving the Kohn-Sham density functional theory (DFT) equations by using the plane-wave basis set. Leveraging the powerful capabilities of MATLAB’s parallel computing toolbox and an advanced, optimized calculation workflow, KSSOLV uniquely enables efficient graphics processing unit (GPU) acceleration, making DFT calculations accessible on standard personal computing hardware. Here, KSSOLV-GPU 2.0, as the latest release, demonstrates substantial computational gains. In benchmarks, particularly involving calculations such as hybrid functionals and spin-polarized systems for complex band structure analysis, KSSOLV-GPU 2.0 achieves a speedup of more than an order of magnitude compared to conventional central processing unit based implementations. This significant acceleration marks a pivotal advancement in performing complex materials simulations, making KS-DFT increasingly accessible on personal computing platforms.

    • The growing demand for precision in computational materials science, particularly in electronic structure calculations, has driven the development of advanced numerical methods and software. Kohn-Sham density functional theory (KS-DFT) [1, 2] is one of the most widely used approaches for modeling the electronic structure of molecules and materials, offering a balance between accuracy and computational efficiency. However, as systems increase in size and complexity, the computational cost of KS-DFT calculations becomes increasingly prohibitive. This has created a pressing need for efficient methods to accelerate these calculations without sacrificing accuracy.

      KSSOLV (Kohn−Sham solver) [3−5], a lightweight MATLAB toolbox for solving KS-DFT problems, implements an extensive suite of optimized electronic structure methods, such as restricted, unrestricted, noncollinear (spin-orbit coupling) [6], and k-point sampling [7] hybrid functionals, the random phase approximation [8], second-order Møller-Plesset perturbation theory [9], density functional perturbation theory [10], time-dependent density functional theory [11−13], the GW [14] approximation and full configuration interaction [15] calculations. The capabilities of KSSOLV have been widely utilized in frontier materials simulations, particularly for investigating excited-state electronic structures in heterostructures [16−19] and reaction mechanisms in photocatalysis [20−22].

      As computational technology evolves, the shift towards graphics processing units (GPUs) [23, 24] for high-performance computing has become essential in addressing the limitations of traditional central processing units (CPUs) [25, 26]. GPUs offer massive parallelism, making them particularly well-suited for computationally demanding tasks such as those found in KS-DFT calculations, including matrix operations, Fourier transforms, and iterative eigensolvers.

      In this work, we present KSSOLV-GPU 2.0, an updated version of KSSOLV that significantly enhances GPU acceleration for KS-DFT calculations. By offloading computational tasks to the GPU, KSSOLV-GPU 2.0 significantly reduces the time required for large-scale simulations, making it possible to efficiently study material properties in systems that were previously too large to handle within a reasonable timeframe. Beyond general performance improvements, the new version specifically addresses the simulation of complex electronic states. One of the most notable features of KSSOLV-GPU 2.0 is its ability to accelerate spin-polarized and hybrid functional calculations [6], which traditionally represented significant computational challenges in KSSOLV-GPU 1.0 [4]. Spin-polarized band structure calculations [6], particularly those incorporating k-point sampling hybrid functionals [7], can be computationally expensive due to the need for non-local exchange interactions and the increased complexity of k-point grids. KSSOLV GPU 2.0 offers substantial acceleration for these calculations, enabling more efficient exploration of materials with complex electronic structures, such as those exhibiting magnetic effects or spin polarization.

      KSSOLV GPU 2.0 provides a powerful, flexible tool for researchers, allowing them to easily adjust the code to suit their specific needs. Since KSSOLV is built on MATLAB, users can modify the code, customize algorithms, and optimize calculations according to their own research objectives. This versatility makes KSSOLV GPU 2.0 an ideal tool for a wide range of KS-DFT applications.

      The development of KSSOLV-GPU 2.0 aligns with a broader paradigm shift in the community, where the push for faster and more scalable electronic structure software has led many established KS-DFT packages to incorporate GPU acceleration. To contextualize our MATLAB-based approach within this high-performance computing landscape, we surveyed a range of widely used first-principles DFT packages developed over the past decade [27−32]. While these programs differ in their use of basis sets, implementation languages, and license types, most converge on a common goal: reducing computational time by leveraging GPUs for the most computationally demanding components.

      Based on our investigation, GPU acceleration in these codes can be categorized into these main types of functionality:

      (i) Matrix operations and eigensolvers: most GPU-accelerated DFT packages now offload linear algebra operations, such as Hamiltonian construction and diagonalization, to GPUs using libraries like cuBLAS, cuSolver, ELPA, or MAGMA [29, 32−34].

      (ii) Real and reciprocal space transforms: plane-wave and grid-based codes use fast Fourier transforms (FFTs) or real-space grid operations, which are naturally parallel and thus highly GPU-friendly. These include density/potential mixing, gradient evaluations, and kinetic energy applications [31, 32, 35, 36].

      Table I summarizes how GPU acceleration is applied across representative software packages. As Table I shows, many plane-wave and real-space codes focus on accelerating FFTs and matrix operations(matrix ops). Additionally, libraries like MAGMA, ELPA, and cuSolver play a central role in enabling eigensolver acceleration across different software [29, 34]. Hybrid functionals and spin-polarized systems, which often require non-local exchange and denser grids, also benefit substantially from GPU support [28, 34, 37].

      These developments demonstrate a clear trend across the field: GPU acceleration is no longer a niche add-on, but a key design principle in modern electronic structure packages. Against this backdrop, KSSOLV GPU 2.0 contributes to the field by offering a flexible, user-accessible platform for GPU-accelerated KS-DFT simulations, particularly for systems involving spin and hybrid functionals, using the high-level MATLAB environment.

    II.   METHODOLOGY
    • In this section, we present the computational methods employed for studying the k-point spin-orbit hybridization band structure of the material. The theory and techniques discussed below are specifically designed to facilitate accurate calculations of the spin-polarized electronic structure, with a particular focus on the treatment of k-point sampling, exchange−correlation functionals, and spin configurations, all crucial for determining the spin-orbit hybridization in the material’s band structure.

    • Kohn−Sham density functional theory (KS-DFT) is one of the most widely applied approaches in first-principles electronic structure calculations for molecules, solids, and low-dimensional materials. The fundamental goal of KS-DFT is to obtain the ground-state electron density $ \rho({\bf{r}}) $, from which a wide range of physical properties can be derived [2].

      The central equation of KS-DFT is a nonlinear eigenvalue problem known as the Kohn-Sham equation:

      where $ \psi_i $ are the Kohn−Sham orbitals (or eigenfunctions), $ \epsilon_i $ are the corresponding orbital energies (or eigenvalues), $ i=1,\dots,N_e $, and $ N_e $ is the number of electrons in the system.

      The electron density is constructed directly from the occupied Kohn-Sham orbitals:

      The Kohn−Sham Hamiltonian $ \hat{H}_{\text{KS}} $ is a functional of the electron density $ \rho $, and can be decomposed into several physical contributions:

      where $ \hat{T} $ is the single-particle kinetic energy operator, $ \hat{V}_{\text{ion}} $ describes the attractive potential between electrons and nuclei, $ \hat{V}_{\text{Hartree}} $ accounts for the classical Coulomb repulsion between electrons, and $ \hat{V}_{\text{xc}} $ denotes the exchange−correlation potential, which incorporates quantum many-body interactions beyond the classical terms.

      The total ground-state energy functional of the system can be written as:

      where $ T_s $ denotes the kinetic energy of non-interacting electrons, $ E_{\text{ext}} $ describes the electron-nuclei interaction energy, $ E_{\text{Hartree}} $ is the classical Coulomb energy, and $ E_{\text{xc}} $ is the exchange-correlation energy functional. Here $ E_{\text{nuc}} $ is the nuclei–nuclei interaction energy, which does not depend on $ \rho $. Solving the Kohn−Sham equations self-consistently provides both the ground-state electron density and the corresponding total energy.

    • In the KS-DFT, the exact form of $ E_{\text{xc}} $ is unknown. Many approximations have been proposed, leading to a variety of exchange−correlation functionals. These functionals can be divided into two major classes: local/semi-local functionals and orbital-dependent functionals. Local and semi-local functionals, such as the local density approximation (LDA) and generalized gradient approximation (GGA), depend only on the electron density $ \rho $ and its gradient $ \nabla\rho $. While efficient, these approximations systematically underestimate the band gap in semiconductors and insulators [49].

      To improve accuracy, hybrid functionals were introduced, which combine a fraction of the exact non-local Hartree−Fock (HF) exchange with the exchange−correlation energy from DFT functionals. The general form of a hybrid functional is:

      where $ \alpha $ is a mixing parameter, typically determined empirically or through fitting to experimental data. This approach retains the efficiency of DFT while incorporating the non-local character of the exact exchange [50]. Three hybrid functionals are widely used in solid-state calculations:

      PBE0 [51]: combines 25% exact exchange from Hartree-Fock and 75% exchange from PBE, with PBE correlation:

      HSE [52]: a screened hybrid functional that splits the Coulomb potential into short-range (SR) and long-range (LR) parts:

      where $ \alpha $ is the mixing parameter, and $ \omega $ is an adjustable parameter controlling the short-rangeness of the interaction. In particular, HSE06 functional corresponds to $ \alpha=0.25 $ and ω=0.2.

      B3LYP [53]: initially developed for molecular systems, which is written as:

      B3LYP is a semi-empirical functional that is fitted based on a large amount of experimental data with $ a=0.2, b=0.72 $ and $ c=0.81 $.

      Hybrid functionals significantly improve the accuracy of band gap predictions and electronic structure in semiconductors and insulators. However, this accuracy comes at a substantial computational cost, particularly in periodic systems. The repeated application of the full-rank Fock operator dominates the computational effort in plane-wave hybrid calculations [6].

      The exact exchange energy takes the form:

      where $ N_{\mathrm{occ}} $ denotes the number of occupied Kohn–Sham orbitals.

      In standard DFT (LDA or GGA), the exchange-correlation potential is local, allowing band structure calculations to be performed efficiently using only the irreducible Brillouin zone (IBZ). In contrast, the non-local HF exchange operator couples all k-points, making symmetry reduction to the IBZ invalid for hybrid functionals.

      The non-local HF exchange potential can be written as:

      This long-range coupling breaks the simple independence of each $ \mathrm{k} $-point and disables symmetry reduction to the IBZ. As a result, the computational cost for hybrid functional band structure calculations scales linearly with the number of $ \mathrm{k} $-points in the full BZ rather than the reduced IBZ, making such calculations expensive for systems with low symmetry or large unit cells [54, 55].

    • To accurately describe the electronic band structure of materials, selecting physically meaningful k-point paths in reciprocal space is essential. Traditional manual selection may introduce subjective ambiguities, such as missing important high-symmetry points or including redundant segments. To address this issue, standardized algorithms have been developed to automatically generate k-point paths based on crystal symmetry. These methods exploit space-group symmetries and Wyckoff positions in reciprocal space to ensure systematic and complete coverage of all critical regions in the Brillouin zone [56, 57].

      This standardized strategy offers several advantages, including unified path generation across different crystal systems, reduced ambiguity in the definition of high-symmetry points, and improved consistency with materials databases such as the Materials Project, enabling reliable cross-platform comparison of electronic band structures.

      The generation of standardized k-point paths is based on orbit decomposition theory applied to reciprocal space groups. For a crystal with space group $ G $, the corresponding symmetry operations act on the reciprocal space and partition the Brillouin zone into symmetry-equivalent regions, each associated with a Wyckoff position. In practice, k-point coordinates are first expressed in the primitive reciprocal lattice basis and subsequently transformed to a standardized conventional reciprocal basis following crystallographic conventions:

      where $ {\bf{k}}_{\mathrm{prim}} $ denotes k-point coordinates in the primitive reciprocal basis, $ {\bf{k}}_{\mathrm{conv}} $ denotes the corresponding coordinates in the conventional reciprocal basis, and $ Q $ is a lattice-dependent transformation matrix determined by the crystal lattice type. This transformation ensures that the resulting k-point paths follow a unique and consistent convention across different crystal structures, facilitating reproducible and comparable band structure calculations [57].

      For non-hybrid functionals such as LDA or PBE, symmetry folding can be applied, enabling Brillouin zone integration to be performed in the irreducible zone using weighted summation:

      where $ f({\bf{k}}) $ denotes a generic $ {\bf{k}} $-dependent quantity appearing in Brillouin zone integrations, such as the band energy, and $ w({\bf{k}}) $ accounts for the symmetry multiplicity of each k-point.

      In the presence of nonlocal HF exchange, the KS equations are no longer invariant under point-group symmetry operations in reciprocal space. This loss of symmetry increases computational cost by approximately $ |G| $ times. Therefore, for hybrid functionals, k-point sampling strategies must carefully balance accuracy and computational resources, and symmetry-based path optimizations cannot be directly applied.

    • In electronic structure calculations, the treatment of spin degrees of freedom significantly influences the computed band structures. Depending on the underlying spin configuration of a system and the manner in which spin is incorporated in the Hamiltonian, Kohn–Sham density functional theory offers three common levels of description: non-spin-polarized, collinear spin-polarized, and non-collinear spin formulations. These different treatments lead to distinct band characteristics, including possible band splitting or magnetic ordering effects.

      (1) Non-spin-polarized calculations

      In the non-spin-polarized approach, the electronic density does not distinguish between spin-up and spin-down channels, and each Kohn–Sham orbital is doubly occupied. The Kohn–Sham equation takes the scalar form:

      where $ \psi_i({\bf{r}}) $ is a single-component orbital. Since each orbital is occupied by two electrons with opposite spins, the number of occupied spatial orbitals is $ N_e/2 $. The electron density is given by

      where the coefficient 2 reflects the double occupancy of each spatial orbital. This formulation reflects spin degeneracy in the absence of magnetic or spin-dependent interactions.

      (2) Collinear spin-polarized calculations

      For simplicity of presentation, we consider a restricted spin-polarized setting in this work, where the numbers of electrons in the spin-up (α) and spin-down (β) channels are fixed and equal, i.e., $ N_\alpha = N_\beta $. This corresponds to a special case of the general collinear spin formalism.

      When spin polarization is explicitly included, the electronic density separates into spin-up electron density $ \rho_\alpha $ and spin-down electron density $ \rho_\beta $:

      The collinear KS equations for each spin channel are decoupled and take the form [6]

      where $ \sigma \in \{\alpha,\beta\} $.

      Collinear spin calculations enable the study of magnetic materials, in which $ \rho^\alpha \neq \rho^\beta $, leading to spin-dependent band splitting.

      (3) Non-collinear spin calculations

      For systems with spin textures or general magnetic configurations, the KS orbitals are represented as two-component spinors:

      where $ i=1,\dots,N_e $.

      The corresponding KS equation takes the matrix form [6]

      where the total electron density $ \rho({\bf{r}}) $ and spin magnetization vector $ {\bf{m}}({\bf{r}}) $ are constructed from the spinor components via

      Non-collinear calculations are essential for systems with spin-orbit interactions, chiral magnetic structures, or frustrated magnetism.

      In the present work, the magnetic configuration is kept fixed during the calculation, and the spin magnetization density is not updated self-consistently.

      In KSSOLV-GPU 2.0, these spin configurations are controlled through the parameter $ {\mathrm{nspin}}$, which can take values of 1, 2, or 4:

      ● $ {\mathrm{nspin = 1}}$: non-spin-polarized calculations.

      ● $ {\mathrm{nspin = 2}}$: collinear spin-polarized calculations.

      ● $ {\mathrm{nspin = 4}}$: non-collinear spin calculations using two-component spinors.

      This allows users to select the appropriate spin treatment based on the magnetic properties and symmetry of the system under study.

    • In this section, we describe the computational realization of the proposed methods and the corresponding optimization strategies. Building upon the theoretical formulations introduced earlier, we detail how the plane-wave DFT workflow is organized and implemented in practice, with particular emphasis on algorithmic modularity, efficient data structures, and hardware-aware acceleration. Key aspects include the treatment of spin degrees of freedom in both self-consistent and post-processing stages, the integration of Hamiltonian transformation techniques for accurate band interpolation, and the acceleration of hybrid functional calculations through low-rank approximations and density fitting. These implementation choices are designed to improve numerical robustness and computational efficiency, enabling large-scale simulations on modern CPU and GPU architectures.

    • To improve the interpolation accuracy of the band structure from sparse $ \mathrm{k} $-point grids, the Hamiltonian transformation (HT) [58] method introduces a pre-optimized spectral transformation to enhance the locality of the Hamiltonian in real space [59].

      In standard DFT-based band structure interpolation, one typically uses Fourier interpolation:

      where $ N_k $ is the number of uniform k-points, $ H_{{\bf{k}}} $ is the Hamiltonian at self-consistent field (SCF) k-point $ {\bf{k}} $, $ {\bf{q}} $ is a nonuniform k-point on the path, and $ {\bf{R}} $ is the Bravais lattice vector. However, the success of this interpolation depends critically on the locality of $ H $ in real space.

      HT aims to construct a more localized Hamiltonian by applying a smooth and invertible transformation function $ f $ to the eigenvalue spectrum of $ H_{{\bf{k}}} $. After diagonalization, the transformed Hamiltonian can be expressed in real space as

      where $ \varepsilon_{i{\bf{k}}} $ and $ \psi_{i{\bf{k}}}({\bf{r}}) $ are the eigenvalues and eigenfunctions of $ H_{{\bf{k}}} $ respectively, and $ N_b $ denotes the number of bands included in the Hamiltonian transformation and subsequent interpolation.

      The interpolation procedure is carried out on the matrix elements of $ f(H_{{\bf{k}}}) $. After interpolation, the original band energies are recovered by applying the inverse transformation:

      where $ i = 1, \dots, N_b $.

      In a given numerical basis, the transformed Hamiltonian matrix elements can be written as

      where $ C_{\mu i}({\bf{k}}) $ are the expansion coefficients of the eigenstates in the numerical basis.

      The function $ f_{a,n}(x) $ is designed to smoothly shift and compress the high-energy part of the spectrum. It is constructed using the error function ($ \text{erf} $) to ensure high-order smoothness ($ C^n $ continuity) at the boundaries, defined piecewise as:

      where $ \varepsilon $ is the spectral cutoff, $ a $ controls the transition width, and $ n $ determines the degree of smoothness.

      HT constructs the Hamiltonian in a numerical, $ {\bf{k}} $-independent basis $ \{Q_\mu({\bf{r}})\} $ via

      where $ Q_\mu({\bf{r}}) $ denotes the $ \mu $-th numerical basis function, $ N_\mu $ is the dimension of the numerical basis, and $ C_{\mu i}({\bf{k}}) $ represents the projection of the $ i $-th Bloch eigenstate onto this basis.

      This representation enables efficient matrix interpolation and spectral transformation [59−61]. Overall, HT avoids the need for runtime optimization (unlike maximally localized Wannier functions) and provides one to two orders of magnitude higher interpolation accuracy for entangled or topological bands.

    • The adaptively compressed exchange (ACE) [6] operator significantly accelerates the computation of exchange-correlation interactions in spin-polarized systems. In recent work, the ACE framework has been extended to unrestricted and non-collinear spin DFT, offering a solution to the high computational cost of hybrid functional calculations in magnetic systems.

      The key idea behind the ACE method is to replace the full-rank Fock exchange operator with a low-rank representation. In real space, the ACE exchange operator can be written in the form

      The projection vectors $ \xi_k({\bf{r}}) $ are obtained through a Cholesky decomposition of the projection matrix constructed from the exchange-applied orbitals. This low-rank representation preserves the exact action of the Fock exchange operator on the occupied subspace while significantly reducing the computational cost.

      To further accelerate the construction of the ACE [43, 62] operator, which traditionally involves solving $ O(N_e^2) $ Poisson equations, the interpolative separable density fitting (ISDF) [63] method is employed.

      ISDF decomposes the products of orbital pairs into a linear combination of a small set of auxiliary basis functions $ \zeta_\mu({\bf{r}}) $:

      where $ N_\mu $ is the rank of the decomposition, typically satisfying $N_\mu \ll {N_e}^2$, and $ C_{\mu,ij} $ are the expansion coefficients that encode the dependence of the orbital-pair product $ (i,j) $ on the auxiliary basis function $ \zeta_\mu({\bf{r}}) $, and can be interpreted as a compressed representation of the pair-density matrix in the ISDF basis.

      By exploiting this separable representation, the number of computationally expensive Poisson solves is reduced from $O({N_e}^2)$ to $ O(N_\mu) $. As a consequence, the overall computational complexity of hybrid functional calculations is reduced from $O({N_e}^4)$ to $O({N_e}^3)$, making large-scale spin-polarized simulations computationally feasible without compromising accuracy.

    • Modern numerical simulations and data-intensive scientific computations benefit greatly from hardware acceleration using GPUs. MATLAB provides a streamlined interface for accessing GPU hardware directly, enabling significant computational speedup in compatible numerical routines [64]. MATLAB users can offload data to the GPU by creating arrays using the $ {\mathrm{gpuArray}}$ class. These arrays reside directly on GPU memory, allowing built-in functions to detect and automatically execute on the GPU [4].

      In a typical workflow, a standard numerical array can be converted into a GPU array using:

      Once data are transferred, supported functions will utilize GPU cores instead of the CPU, accelerating matrix operations, element-wise computations, FFTs, and other parallelizable tasks. Upon completion, results can be retrieved back to host memory:

      MATLAB also provides the $ {\mathrm{gpuDevice}}$ function to query available GPU devices and their properties, enabling users to select the desired device in multi-GPU environments.

      The acceleration provided by GPUs originates from their massively parallel architecture, where thousands of lightweight cores operate simultaneously on independent data elements. This is particularly effective for data-parallel problems, which can be divided into independent sub-tasks that are processed concurrently. The acceleration factor can be roughly estimated as:

      where $ T_\text{CPU} $ and $ T_\text{GPU} $ denote the wall clock time calculated using CPU and GPU, respectively.

      In contrast, performance studies show that when data transfer between CPU and GPU is frequent or involves small payloads, the communication overhead can dominate execution time [65, 66]. For extremely small tasks, micro-level latency in kernel launch and transfer may exceed computation time [67].

      MATLAB’s GPU computing is particularly suitable for matrix operations, signal processing, numerical linear algebra, and deep learning training, where data-parallelism can be fully exploited. The supported function set includes common mathematical and statistical operations, such as:

      ● Matrix multiplication (${\mathrm{mtimes}} $)

      ● Element-wise arithmetic and logical operations

      ● Fourier transforms (${\mathrm{fft}} $)

      ● Linear solvers and decompositions (e.g., ${\mathrm{mldivide}} $, ${\mathrm{chol}} $)

      For general usage, MATLAB automatically handles kernel launch and memory management for supported functions when a ${\mathrm{gpuArray}} $ input is detected. This abstraction allows users to focus on algorithmic development without requiring low-level CUDA programming. However, for performance tuning, users can directly inspect device status using ${\mathrm{gpuDevice}} $, which returns core counts, memory bandwidth, and other relevant hardware metrics.

      In KSSOLV, users can control whether to enable GPU acceleration by setting $ {\mathrm{option.enableGPU}}$ when running SCF or other calculations. If GPU acceleration is enabled, the related computational functions automatically switch to their GPU-optimized versions. For advanced users with more specific performance requirements, KSSOLV also makes it easy to write or modify custom functions to take advantage of GPU computing.

    • To achieve optimal performance in heterogeneous computing systems, it is essential to balance the task distribution between the CPU and GPU based on the specific computational scenario. The following key factors should be considered:

      (1) Data transfer efficiency bottleneck

      There is inherent latency in data exchanges between the CPU and GPU, and frequent small-scale data transfers can significantly reduce the benefits of acceleration [65−67]. A typical scenario is the iterative exchange of intermediate results in algorithms, where the communication time can exceed the actual computation time. Optimization strategies should minimize the number of data transfers between devices and avoid unnecessary data movement.

      (2) Characteristics of small-scale computational tasks

      In practice, for matrix operations with dimensions smaller than 50 × 50, the CPU often outperforms the GPU. This can be attributed to two factors:

      ● The GPU’s parallel architecture requires sufficient computational density to offset the overhead of thread scheduling.

      ● The serial dependencies in small matrix iterations are difficult to parallelize effectively. In such cases, using the CPU directly avoids the additional overhead caused by switching between devices [66, 67].

      (3) Memory constraints in large-scale computations

      The efficiency of GPU acceleration is highly sensitive to the ratio between the matrix size and the available video RAM (VRAM). While the GPU can theoretically store data up to 80%–90% of its capacity, the operational memory threshold for peak performance is significantly lower due to the demand for intermediate workspaces and result buffers. For fundamental operations such as matrix multiplication, the performance begins to degrade when the input occupies approximately 50% of the VRAM, as the system must simultaneously accommodate the result matrix and temporary copies.

      However, for memory-intensive algorithms like the FFT, this “performance cliff” often occurs at an even lower utilization rate. The algorithms frequently require additional workspace for twiddle factors and multi-stage intermediate buffers, which can exceed the size of the input data itself. This leads to several bottlenecks:

      ● Frequent data swapping between GPU memory and host memory.

      ● Computational cores idling while waiting for data to be ready.

      ● Non-linear decline in overall computation throughput.

      It is important to consider these characteristics when using or designing GPU acceleration features in KSSOLV.

      In modern MATLAB applications, especially when leveraging GPU acceleration, optimizing computation is critical for achieving high performance. Below, we discuss in detail the underlying principles and mechanisms behind three key optimization techniques: vectorization, memory management (trading space for time), and offloading computations via compiled C++ code or CUDA kernels.

    • Vectorization replaces explicit loops with operations on entire arrays or matrices. MATLAB is optimized for such operations, relying on highly tuned libraries (e.g., BLAS and LAPACK) that execute low-level operations efficiently. When you use vectorized operations, MATLAB bypasses the overhead of interpreted loops (such as repeated type-checking and memory reallocation) by executing precompiled code. This not only minimizes overhead but also benefits from hardware-level optimizations such as SIMD (Single Instruction, Multiple Data) instructions and efficient cache utilization.

    • This strategy involves preallocating arrays and caching intermediate results to avoid redundant computations, thereby reducing execution time at the expense of using more memory. Dynamic memory allocation during runtime, especially inside loops, can slow down performance significantly. By preallocating memory, you prevent MATLAB from repeatedly resizing arrays, which minimizes memory fragmentation and allocation overhead. Similarly, storing intermediate results avoids recomputation, leading to a lower overall computational complexity.

    • For computationally intensive tasks such as FFT, IFFT, and matrix multiplications, MATLAB allows these operations to be offloaded to compiled C++ code using MEX files or to GPU-based CUDA kernels.

      ● Compiled C++ (MEX files): Instead of using MATLAB’s built-in functions, users can write performance-critical code in C++ and compile it into MEX files. These files run as native machine code, bypassing MATLAB's interpreter. This reduces runtime overhead and enables low-level CPU optimizations, such as cache-aware memory access and multi-threaded execution. For example, in KSSOLV, the most time-consuming FFT and IFFT operations are not performed using MATLAB’s $ {\mathrm{fft}}$ function. Instead, they are handled through MEX interfaces that call NVIDIA’s highly optimized $ {\mathrm{cuFFT}}$ library. This approach avoids the interpreter bottleneck and leverages hardware-specific tuning in $ {\mathrm{cuFFT}}$, resulting in performance gains of 10%–20% over MATLAB’s native GPU FFT implementation.

      ● CUDA kernels: GPUs are optimized for massive parallelism, with thousands of cores designed to execute similar instructions simultaneously. By writing custom CUDA kernels or calling GPU-accelerated libraries, developers can achieve large speedups, especially for operations that are inherently parallel. This is particularly useful for large-scale simulations, such as solving the Kohn−Sham equations in electronic structure calculations, where linear algebra operations and FFTs dominate the computational cost.

    • The acceleration from these methods is due to several factors:

      ● Reduction of interpreter overhead: vectorized code and precompiled routines reduce the frequency of interpreting code line-by-line.

      ● Hardware utilization: compiled C++ routines and CUDA kernels are capable of exploiting advanced processor features (such as SIMD and multi-threading) and the massively parallel architecture of GPUs.

      ● Memory efficiency: preallocating arrays and caching results eliminate the recurring cost of memory allocation and reduce computational redundancy.

      These optimizations yield significant performance gains: vectorization minimizes the overhead of sequential loops, effectively reducing computational constants, while GPU parallelism can cut execution times by orders of magnitude for large-scale calculations.

    III.   RESULTS AND DISCUSSION
    • In this section, we present the numerical results and discuss the performance of the proposed approach. The calculations utilized an NVIDIA A100 GPU (40 GB, HBM2, Driver Version: 535.154.05, CUDA Version: 12.2), and an Intel(R) Xeon(R) Gold 6342 CPU @ 2.80 GHz (48 Physical Cores, 96 Logical Threads). The impact of the proposed optimizations on SCF convergence, band structure calculation, and overall runtime is evaluated in detail. These results demonstrate the effectiveness of the implemented methods for large-scale plane-wave DFT calculations and highlight their practical advantages in realistic simulation scenarios.

    • The workflow of the SCF process is shown in FIG. 1. Before embarking on performance optimization, it is essential to identify the computational bottlenecks within the SCF calculation process. By analyzing the computational hotspots, we can apply targeted optimizations to maximize performance gains. To this end, we analyzed the time consumption of key computational steps within the SCF cycle for a representative graphene supercell system, executed in a CPU-only environment without GPU acceleration.

      To facilitate interpretation of the time breakdown, we briefly clarify the meaning of the abbreviated components shown in FIG. 2.

      Charge density update ($ \rho $ update) refers to the construction and mixing of the electronic charge density. In each SCF iteration, the charge density is reconstructed from the current Kohn–Sham wavefunctions and occupation numbers, followed by a mixing procedure to stabilize convergence. This step involves real–reciprocal space transformations and evaluation of density differences, but does not include the expensive Hamiltonian diagonalization.

      Potential update (V update) denotes the update of the effective Kohn–Sham potential based on the new charge density. This includes the computation of the Hartree potential, exchange–correlation potential, and their assembly into the total effective potential. Although essential for self-consistency, this step mainly consists of local operations and FFT-based Poisson solvers, and therefore contributes a smaller fraction of the total runtime compared to diagonalization-related tasks.

      Orthogonalization (Ortho) corresponds to the orthonormalization of Kohn–Sham wavefunctions during iterative diagonalization. In practice, this step enforces the orthogonality constraints among wavefunctions through matrix–matrix operations, which are dense linear algebra operations and thus highly amenable to GPU acceleration.

      Others aggregate the remaining SCF-related operations whose individual time contributions are relatively small. These include, for example, occupation number evaluation and Fermi level determination, convergence checks, total energy bookkeeping, and auxiliary data rearrangements. Since each of these components accounts for only a minor portion of the runtime, they are grouped together for clarity.

      Overall, FIG. 2 highlights that the dominant computational cost arises from numerically intensive linear algebra and Fourier transform operations, while charge density and potential updates, although physically critical, represent a comparatively modest share of the total execution time. This decomposition provides a clear rationale for prioritizing GPU acceleration of FFTs, orthogonalization, and matrix–matrix operations in KSSOLV-GPU 2.0.

    • To evaluate the impact of GPU acceleration, we first compared SCF calculation performance using both CPU and GPU. The test was conducted on several systems to obtain a comprehensive view of performance scaling.

      FIG. 3 shows the total SCF time for CPU and GPU calculations. In all cases, the GPU provided a significant speedup compared to the CPU.

      To further understand the time reduction, we decomposed the SCF cycle into several key computational components, including FFT/IFFT, matrix multiplications (${\mathrm{mtimes}} $), charge density update and potential updates. The component-wise time comparison is shown in FIG. 4.

      From FIG. 4, we observe that for the graphene supercell system, GPU acceleration achieved a speedup of approximately 24.3× for FFT/IFFT and 30.5× for matrix multiplications. In contrast, operations like potential updates, which involve more irregular memory access, showed a speedup of only about 5×. This clearly demonstrates that the effectiveness of GPU acceleration strongly depends on the degree of parallelism and memory access regularity of each task.

    • To assess the scalability, we evaluated three different systems with increasing size: a silicon primitive cell (small system and large system), a graphene supercell (medium system), and a transition metal oxide surface (large system). For each system, we recorded the total SCF time on both CPU and GPU, as shown in FIG. 5.

      The results demonstrate that for the same material type, both CPU and GPU show increasing computation time as the system size grows. However, the growth rate for GPU is significantly slower, indicating better scaling efficiency. This trend becomes particularly evident in the large system case.

      This improved scaling can be explained by the nature of computational complexity in large-scale simulations. For SCF calculations, the computational cost typically scales as $ {\cal{O}}(N^3) $, where $ N $ is the number of basis functions. In contrast, the data transfer and initialization overhead scales as $ {\cal{O}}(N^2) $. As the system size increases, the relative weight of GPU setup and memory transfer becomes smaller, allowing the GPU’s parallel architecture to be more fully utilized. Thus, the benefit of GPU acceleration increases for larger problems.

      The speedup ratio, defined as the CPU time divided by GPU time, is also shown in FIG. 5. It clearly shows that the speedup grows significantly with system size. For the largest system (Si$ _{128} $), the GPU achieved more than 100× speedup over CPU.

    • For advanced electronic structure calculations, such as spin-polarized band structures using hybrid functionals, the computational cost increases dramatically due to the non-local exchange term and dense k-point sampling. In this context, we evaluated the performance of GPU acceleration under hybrid functional settings and applied algorithmic improvements to further optimize the non-self-consistent field (NSCF) step.

      FIG. 6 compares the total computation time for band structure calculations (NSCF) with CPU and GPU using the HSE06 functional on a magnetic system, respectively. GPU acceleration resulted in a substantial time reduction, especially under fine k-point grids and spin-polarized settings, where the Fock exchange term becomes dominant.

      In the NSCF calculation, the major computational bottleneck comes from the evaluation of the Fock exchange operator. To further reduce this cost, we applied ACE and HT techniques.

      FIG. 7 shows the combined impact of these techniques on the NSCF calculation. The reported total time includes both the preceding SCF calculation and the subsequent NSCF calculation. In all cases, the SCF stage is performed using ACE acceleration by default. The figure is designed to show the relative performance gains introduced by different optimization techniques, specifically in the NSCF stage.

      Each method individually reduces the overall computation time, while the most significant improvement is achieved when ACE, HT, and GPU acceleration are applied together in the NSCF calculation. This improvement arises from the complementary nature of the techniques: ACE reduces the cost of the exchange application, HT lowers the effective Hamiltonian complexity, and GPU acceleration efficiently exploits the resulting dense linear algebra and FFT workloads. In total, this combined approach reduces the NSCF time by more than an order of magnitude compared to the baseline NSCF calculation.

      This integration of GPU acceleration and advanced numerical strategies enables practical hybrid-functional band structure calculations for large-scale, spin-polarized systems—computations that would otherwise be prohibitively expensive on traditional CPU-only platforms.

    IV.   CONCLUSION AND OUTLOOK
    • In this work, we have presented KSSOLV-GPU 2.0, an enhanced MATLAB-based toolbox for performing efficient Kohn−Sham DFT calculations. Our work addresses the significant computational cost associated with complex electronic structure simulations, particularly for spin-polarized systems and those requiring hybrid functionals. By leveraging GPU acceleration through MATLAB’s parallel computing toolbox and implementing advanced computational optimizations, KSSOLV-GPU 2.0 serves as a powerful and flexible tool for materials research.

      Our test results demonstrate that KSSOLV-GPU 2.0 achieves a significant speedup of more than an order of magnitude for demanding band structure calculations compared to conventional CPU-based methods. This performance gain stems from a dual approach: first, the direct offloading of computationally intensive tasks, such as FFTs and matrix multiplications, to the massively parallel architecture of the GPU; second, and more importantly, we have integrated physics-aware algorithmic optimizations. The use of the ACE operator and HT interpolation reduces the intrinsic complexity of hybrid functional calculations, leading to performance gains beyond simple hardware acceleration. We have also shown that the advantage of GPU acceleration scales favorably with increasing system size, making it especially beneficial for large-scale simulations.

      The efficiency of KSSOLV-GPU 2.0 makes advanced and accurate materials simulations more accessible to the broader scientific community. It enables researchers to investigate complex material properties, such as magnetic effects and electronic band gaps, with hybrid functionals on standard workstations, a task that was often prohibitively expensive. The flexible nature of the MATLAB environment further empowers users to easily inspect, modify, and extend the code to suit their specific research needs, fostering innovation and rapid prototyping of new methods.

      Looking ahead, we plan to extend the capabilities of KSSOLV-GPU 2.0 in several directions. Future work will focus on developing support for multi-GPU parallelism to tackle even larger and more complex systems. We also aim to expand the library of implemented functionals and incorporate more post-DFT and post-HF methods for the calculation of excited-state properties. By continuing to combine physical insights with advanced computing techniques, KSSOLV will remain a valuable and evolving tool for computational materials discovery.

    Figure (7)  Table (1) Reference (67)

Catalog

    /

    DownLoad:  Full-Size Img  PowerPoint
    Return
    Return