Automatic differentiation (AD) is a well-established tool that allows us to compute exact derivatives of implemented functions with respect to all their parameters. It does so without requiring any extra coding or knowledge of the analytical derivatives. Derivatives of quantum chemistry algorithms are generally very hard to obtain and often cumbersome to implement. AD shows great potential to solve this problem and to facilitate the implementation of gradients in the context of electronic structure methods. In this dissertation, we have applied AD in a broader context and demonstrate that AD tools can compute arbitrary gradients of quantum chemistry methods with respect to any input parameter and any intermediate function. To this end, we have developed the open-source code DiffiQult, a fully differentiable Hartree-Fock (HF) software package. DiffiQult is a python package that uses AD tools using the external libraries JAX and Algopy. As a proof of concept, DiffiQult is an example of an end-to-end differentiable software package of a quantum chemistry algorithm based solely on AD tools. This application has helped us understand the challenges of AD in quantum chemistry. We outline the details, benefits, and caveats of AD for the HF algorithm in this work. We have chosen HF as a starting point since it contains all the functions included in correlated electronic structure methods. In this way, it opens the door for the development of AD for more accurate algorithms. As an application, we describe DiffiQult within the framework of the fully variational HF method, where we use a gradient-based optimization method to compute system-specific basis functions. As a result, the wavefunction can capture more molecular features, and we obtain a set of basis functions for correlated methods in quantum and classical algorithms. This proves that these functions improve variationally energy while keeping a compact representation in correlated methods by interfacing with the quantum chemistry library PySCF, and with Tequila, a platform for rapid development of quantum algorithms. First, we present optimization results of minimal basis sets with respect to all parameters of the molecules H2O, CH4, NH3, HF. Later we include optimization of the potential energy surface of two isomerization mechanisms of diazene and hydrogens chains. Here, we use a minimal optimized basis set to compute FCI when possible with PySCF and VQE energies of hydrogen chains with Tequila. We obtain similar results compared to a bigger basis set with considerably fewer configurations. Also, we show how this approach improves the estimation of the thermodynamic limit in the hydrogen chain at the HF level. Finally, we apply this approach to the optimization of all atomic orbitals of benzene and compute electronic correlations restricting the active space to the 6 π orbitals of benzene using the UpCCGSD ansatz implemented in Tequila.
Automatic differentiation (AD) is a well-established tool that allows us to compute exact derivatives of implemented functions with respect to all their parameters. It does so without requiring any extra coding or knowledge of the analytical derivatives. Derivatives of quantum chemistry algorithms are generally very hard to obtain and often cumbersome to implement. AD shows great potential to solve this problem and to facilitate the implementation of gradients in the context of electronic structure methods. In this dissertation, we have applied AD in a broader context and demonstrate that AD tools can compute arbitrary gradients of quantum chemistry methods with respect to any input parameter and any intermediate function. To this end, we have developed the open-source code DiffiQult, a fully differentiable Hartree-Fock (HF) software package. DiffiQult is a python package that uses AD tools using the external libraries JAX and Algopy. As a proof of concept, DiffiQult is an example of an end-to-end differentiable software package of a quantum chemistry algorithm based solely on AD tools. This application has helped us understand the challenges of AD in quantum chemistry. We outline the details, benefits, and caveats of AD for the HF algorithm in this work. We have chosen HF as a starting point since it contains all the functions included in correlated electronic structure methods. In this way, it opens the door for the development of AD for more accurate algorithms. As an application, we describe DiffiQult within the framework of the fully variational HF method, where we use a gradient-based optimization method to compute system-specific basis functions. As a result, the wavefunction can capture more molecular features, and we obtain a set of basis functions for correlated methods in quantum and classical algorithms. This proves that these functions improve variationally energy while keeping a compact representation in correlated methods by interfacing with the quantum chemistry library PySCF, and with Tequila, a platform for rapid development of quantum algorithms. First, we present optimization results of minimal basis sets with respect to all parameters of the molecules H2O, CH4, NH3, HF. Later we include optimization of the potential energy surface of two isomerization mechanisms of diazene and hydrogens chains. Here, we use a minimal optimized basis set to compute FCI when possible with PySCF and VQE energies of hydrogen chains with Tequila. We obtain similar results compared to a bigger basis set with considerably fewer configurations. Also, we show how this approach improves the estimation of the thermodynamic limit in the hydrogen chain at the HF level. Finally, we apply this approach to the optimization of all atomic orbitals of benzene and compute electronic correlations restricting the active space to the 6 π orbitals of benzene using the UpCCGSD ansatz implemented in Tequila.
Abstract Automatic differentiation (AD) is a powerful tool that allows calculating derivatives of implemented algorithms with respect to all of their parameters up to machine precision, without the need to explicitly add any additional functions. Thus, AD has great potential in quantum chemistry, where gradients are omnipresent but also difficult to obtain, and researchers typically spend a considerable amount of time finding suitable analytical forms when implementing derivatives. Here, we demonstrate that AD can be used to compute gradients with respect to any parameter throughout a complete quantum chemistry method. We present DiffiQult, a Hartree–Fock implementation, entirely differentiated with the use of AD tools. DiffiQult is a software package written in plain Python with minimal deviation from standard code which illustrates the capability of AD to save human effort and time in implementations of exact gradients in quantum chemistry. We leverage the obtained gradients to optimize the parameters of one-particle basis sets in the context of the floating Gaussian framework.
Accurate and efficient gradients of molecular energy with respect to nuclear degrees of freedom are essential for geometry optimization and molecular dynamics, including simulations that go beyond the Born-Oppenheimer regime. A common approach involves deriving analytical formulas for new electronic structure methods, which is often conceptually difficult and requires tedious coding. Here, we implement analytical, semi-numerical, and automatic differentiation (AD)-based gradient pathways for semiempirical Hamiltonian models in the PYSEQM software package, leveraging both graphics processing unit (GPU) and central processing unit (CPU) architectures. We further extend these capabilities to excited states calculated using the configuration interaction singles and time-dependent Hartree-Fock ansätze. We benchmark wall time, peak memory usage, and accuracy across three molecular families of varying chemical complexity, including systems of up to a thousand atoms. For ground-state simulations, analytical and AD gradients achieve near-identical GPU runtimes, while semi-numerical gradients are slower on GPU but remain competitive on CPU. For excited states, both analytical and custom AD approaches using implicit differentiation show similar performance and low memory requirements, whereas gradients with full AD are memory-limited. AD gradients match analytical ones in accuracy across all tested systems, aided by a quaternion-based diatomic frame rotation for two-center quantities that ensures smooth energy surfaces. Overall, automatic differentiation emerges as a practical alternative to analytical gradients in semiempirical quantum chemistry, offering high accuracy while allowing seamless integration in AI-driven workflows and popular packages, such as PyTorch and JAX. Our results provide actionable guidance for selecting optimal gradient strategies in large-scale ground- and excited-state molecular dynamics simulations.
This work describes the theoretical foundation for all quantum chemistry functionality in PennyLane, a quantum computing software library specializing in quantum differentiable programming. We provide an overview of fundamental concepts in quantum chemistry, including the basic principles of the Hartree-Fock method. A flagship feature in PennyLane is the differentiable Hartree-Fock solver, allowing users to compute exact gradients of molecular Hamiltonians with respect to nuclear coordinates and basis set parameters. PennyLane provides specialized operations for quantum chemistry, including excitation gates as Givens rotations and templates for quantum chemistry circuits. Moreover, built-in simulators exploit sparse matrix techniques for representing molecular Hamiltonians that lead to fast simulation for quantum chemistry applications. In combination with PennyLane's existing methods for constructing, optimizing, and executing circuits, these methods allow users to implement a wide range of quantum algorithms for quantum chemistry. We discuss how PennyLane can be used to implement variational algorithms for calculating ground-state energies, excited-state energies, and energy derivatives, all of which can be differentiated with respect to both circuit and Hamiltonian parameters. We provide an example workflow describing how to jointly optimize circuit parameters, nuclear coordinates, and basis set parameters for quantum chemistry algorithms. We discuss a functionality for reducing the number of qubits by using symmetries and explain how PennyLane can be used to estimate quantum resources needed to implement several quantum algorithms. By combining insights from quantum computing, computational chemistry, and machine learning, PennyLane is the first library for differentiable quantum computational chemistry.
Automatic differentiation is a tool for numerically calculating derivatives of a given function up to machine precision. This tool is useful for quantum chemistry methods, which require the calculation of gradients either for the minimization of the energy with respect to wave function parameters or for the calculation of molecular responses to external perturbations. Herein, we apply automatic differentiation to the coupled cluster with doubles method, in which the wave function parameters are obtained by minimizing the energy Lagrangian. The benefit of this approach is that the l amplitudes can be obtained without implementation of the usual L-equations, thereby reducing the coding effort by approximately a factor of two. We also show that the excitation energies at the coupled cluster level can be ontained with only a few lines of the code using automatic differentiation. We further apply automatic differentiation to the multicomponent coupled cluster with doubles method, which treats more than one type of particle, such as electrons and protons, quantum mechanically. This approach will be especially useful for prototyping, debugging, and testing multicomponent quantum chemistry methods because reference and benchmark data are limited in this emerging field.
We introduce an extension to the PySCF package, which makes it automatically differentiable. The implementation strategy is discussed, and example applications are presented to demonstrate the automatic differentiation framework for quantum chemistry methodology development. These include orbital optimization, properties, excited-state energies, and derivative couplings, at the mean-field level and beyond, in both molecules and solids. We also discuss some current limitations and directions for future work.
Quantum Monte Carlo (QMC) methods are powerful, stochastic techniques for computing the properties of interacting electrons and nuclei with an accuracy comparable to the standard post-Hartree--Fock methods of quantum chemistry. Whilst the favourable scaling of QMC methods enables a quantum, many-body treatment of much larger systems, the lack of accurate and efficient total energy derivatives, required to compute atomic forces, has hindered their widespread adoption. The work contained within this thesis provides an efficient procedure for calculating exact derivatives of QMC results. This procedure uses the programming technique of algorithmic differentiation (AD), which allows access to the derivatives of a computed function by applying chain rule differentiation to the underlying source code. However, this thesis shows that a straightforward differentiation of a stochastic function fails to capture the important contribution to the derivative from probabilistic decisions. A general approach for calculating the derivatives of a stochastic function is presented, where a similar adaptation of AD applied to the diffusion Monte Carlo (DMC) algorithm yields exact DMC atomic forces. The approach is validated by performing the largest ever DMC force calculations, which demonstrate the feasibility of treating systems containing thousands of electrons. The efficiency of AD also enables molecular dynamics simulations driven entirely by DMC, adding new functionality to the QMC toolkit. Another focus of this thesis is using the phenomenon of stochastic coherence to correlate DMC simulations, allowing finite difference derivatives to be obtained with a small error. Whilst this method is far easier to implement than AD, preliminary results show an instability when treating larger systems. A different approach is obtained from extrapolating this method to a finite difference step size of zero, producing algebraic expressions for a direct differentiation of the DMC algorithm.