WorksPhysics and Astronomy
QChemistry: A quantum computation platform for quantum chemistry
Abstract
Quantum computer provides new opportunities for quantum chemistry. In this article, we present a versatile, extensible, and efficient software package, named QChemistry, for developing quantum algorithms and quantum inspired classical algorithms in the field of quantum chemistry. In QChemistry, wave function and Hamiltonian can be conveniently mapped into the qubit space, then quantum circuits can be generated according to a specific quantum algorithm already implemented in the package or newly developed by the users. The generated circuits can be dispatched to either a physical quantum computer, if available, or to the internal virtual quantum computer realized by simulating quantum circuit on classical supercomputers. As demonstrated by our benchmark simulations with up to 72 qubit, QChemistry achieves excellent performance in simulating medium scale quantum circuits. Application of QChemistry to simulate molecules and periodic systems are given with performance analysis.
Introduction
As the application of accurate classical methods are severely limited by the fast growing computational cost, quantum computation provides a promising pathway to solve the quantum chemistry problems. [1, 2, 3] By encoding wave functions into the Hilbert space of qubits, the Schrodinger equation for molecular systems can be solved on a quantum computer. In recent years, various quantum algorithms, such as quantum phase estimation (QPE) and variational quantum eigensolver (VQE), [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25] are developed for quantum chemistry. There are some important issues should be studied for these algorithms. For example, the basis set used to construct the electronic Hamiltonian and the fermion-to-qubit encoding technique may lead to significant gate complexity and measurement overhead in QPE. [26] The optimization of typical wave function ansatzes using VQE can suffer from the ”barren plateaus” [27, 28] or local minimum traps. [29] A quantum computation platform which can provided extensive functionalities and step-by-step cross verification is therefore desirable for designing novel quantum algorithms for chemistry applications.
Noisy intermediate quantum (NISQ) devices have been used to demonstrate the possility of studying the ground and excited states of molecular systems using currently available algorithms. [14, 15, 16, 17, 18, 19, 20, 30, 31, 32] However, such experimental demonstrations are limited to tiny molecules with an artificially small basis set. This is because NISQ experiments are limited by the available quantum resources and the error associated with each quantum gate. Therefore, low gate fidelity, short coherence time, and insufficient qubit resource prohibit a systematic study of quantum chemistry oreinted quantum algorithms on NISQ devices. The largest quantum computation experiment for chemistry up to date uses 16 qubits with 160 two-qubit gates, [32] while a simple VQE circuit of the commonly used unitary coupled-cluster (UCC) [33, 34, 35] ansatz for a small molecule has CNOT gates (Table 1), which is far beyond the capability of NISQ devices. Therefore, it is important to have the capability to simulate quantum circuit on a classical computer at this stage. Even beyond the NISQ era, such a capability can help us to develop quantum inspired classical algorithms.
| Molecule | Qubits | Parameters | CNOT gates | ||
| UCCSD | UCCGSD | UCCSD | UCCGSD | ||
| H | 4 | 2 | 5 | 64 | 144 |
| LiH | 8 | 14 | 72 | 1632 | 10720 |
| HO | 14 | 90 | 630 | 26272 | |
| NH | 16 | 135 | 1064 | 46480 | |
| CH | 18 | 230 | 1692 | 95200 | |
| CH | 28 | 1224 | 9737 | ||
| CH | 42 | 5994 | 48930 |
Table 1. Computational resources required to perform VQE simulations for a number of molecules using the unitary coupled-cluster ansatz truncated up to double excitations (UCCSD) and the minimum basis set STO-3G. UCCGSD means that generalized excitation operators (not distinguishing occupied and virtual orbitals) are used.
Several quantum computation packages have been reported, for example, C++ based ProjectQ[36] and Qiskit[37], GPU-enabled Qulacs[38], and the differentiable simulator Yao[39] implemented in Julia. Most of these codes are developed as stand-along quantum circuit simulators or compilers, which have no interfaces for quantum chemistry applications. Some of the packages such as Qiskit or PennyLane[40] provide modules linked to external ab-initio chemistry codes. However, the functionalities are limited, for example, with support for periodic boundary condition which plays an important role in modeling materials. At the same time, the performance of simulating quantum circuit is not very satisfactory in these packages. Most of these packages only implement the brute-force simulating method which leads to an exponential computational cost. Tensor-based methods have been implemented in packages such as Qiskit and PennyLane, however, without an efficient distributed parallelization algorithm. As a reference, the largest simulated quantum circuit up to date contains 28 qubits, which is used to study the ground state of ethene molecule using VQE.[41]
Based on the above considerations, we develop a versatile and extensible quantum computation platform for quantum chemistry, named Chemistry (pronounced as ”Q square chemsitry”) to highlight the two quantum dimensions (the systems to be studied and the tools used to study them). Chemistry adopt a modular design and a mixed-language programming model to achieve versatility together with high performance, where Python is used as its application program interface (API) while C++ and Julia [42] are used for computational intensive tasks such as quantum circuit simulators. provides interfaces to quantum chemistry packages such as PySCF[43] to generate required parameters for the qubit Hamiltonian. The quantum algorithms for solving the eigenstates of the electronic Hamiltonian are programmable at a high level of abstraction by adopting internal templates and/or defining custom circuit generation procedures. Some popular VQE and post-VQE algorithms have already been implemented for ground and excited states of molecular and periodic systems. provides native modules to run the circuit generated by a specific quantum algorithm, either via various high performance classical circuit simulation algorithms for simulating the circuit on a classical computer, or via extensible interfaces reserved for the upcoming actual quantum processors. An efficient matrix product state (MPS)[44, 45] based circuit simulation engine is implemented to perform quantum simulations for systems with 50100 qubits.
The remaining part ot this article is organizing as the following. After introducing the framework of in § 2, we present functionalities for handling ab-initio chemistry quantities in § 3. In § 4 we explain the implementation of the circuit simulation on a classical computer or running on the upcoming quantum hardwares. § 5 gives a general introduction to the natively implemented VQE-based algorithms. Finally, in § 6, we provide some examples to demonstrate the power of in chemistry applications, and provide the road map for further extensions including the support for more quantum algorithms, classical circuit simulation backends, and circuit optimization algorithms.
The framework of Q2Chemistry
As shown in Figure 1a, contains three modules. (1) q2chem.qchem: the quantum chemistry module which defines quantum chemistry problems in the qubit space typi cally with the help of external classical quantum chemistry packages; (2) q2chem.qcirc: the quantum circuit module which provides quantum circuit related functionalities, including circuit construction, visualization, optimization, and execution on a virtual or real quantum computer; (3) q2chem.qalgo: the quantum algorithm module which includes native quantum algorithms and also provides tools to implement new algorithms to solve chemistry problems.

Figure 1. (a) The framework of Chemistry. (b) A typical workflow of solving a chemical problem using a quantum algorithm.
High-level modules in Chemistry are implemented using the scripting language Python and provide base implementations for classes in submodules. Benefiting from the modular design and Python’s extensibility, extending existing submodules are easily achieved by constructing derived classes and implementing only a small number of virtual functions, which requires no modifications to higher level modules. Core functions in the backends are implemented using programming languages including C++ and Julia. These functions are integrated into the Python interfaces using just-in-time (JIT) technology, which compiles the code at run time to provide machine-specific optimizations and deliver outstanding performance. Most of the low-level data structures accessible from Python are stored using NumPy’s[46] ndarray. Therefore, auxiliary operations, such as exact diagonalization for the qubit Hamiltonian, can be realized by using NumPy-compatible packages such as SciPy[47] or PyTorch.[48]
Using such a modular framework, a general workflow to solve a quantum chemistry problem on a quantum computer is briefly illustrated in Figure 1b. (1) Collect classical data such as electron integrals and mean-field orbital coefficients to generate Hamiltonian and an initial quantum state. (2) Choose or develop a suitable quantum algorithm and generate corresponding quantum circuits, which may depend on the Hamiltonian such as in the QPE algorithm or be system independent such as in some VQE algorithms. (3) Perform lower level circuit optimizations, including eliminating redundant quantum gates to reduce circuit depth or reconstructing the circuit to fit a specific quantum processor. (4) Execute the quantum circuits and perform some measurements to extract necessary information, using either a virtual or real quantum computer.
Currently, Chemistry can be routinely used for performing VQE simulations on a classical computer, which is powered by Hamiltonian generation for molecular and periodic systems, hardware-efficient and UCC-based ansatzes for parametric circuit construction, and a scalable noise-free tensor network backend for classical simulations of large quantum circuits.
The quantum chemistry module
The q2chem.qchem module mainly handles system Hamiltonian and wave function mapping. The second-quantized Hamiltonian is constructed from classically calculated quantities such as molecular orbital coefficients. The wave function mapping determines how the orbitals of simulated wave function are mapped onto qubits therefore influences measurement strategy.
Hamiltonian
For a Hamiltonian which is expressed as the linear combination of Pauli strings
where is product of Pauli operators , the expectation value can be obtained through quantum measurement techniques such as the Hadamard test as
Given the Hartree-Fock orbitals, the second-quantized electronic Hamiltonian can be written as
with
and are one- and two-electron integrals. In order to convert the second-quantized Hamiltonian Equation (3) into the qubit form as given in Equation (1), a fermion-to-qubit mapping such as the Jordan-Wigner or Bravyi-Kitaev mapping is required. [49, 50, 51]
In , an interface with the PySCF package is provided to calculate one- and two-electron integrals. for molecular and periodic systems. [52, 53] Orbital optimization is also supported by linking to the pyscf.lo module or using a custom cost function. A unitary matrix is then obtained to transform the integrals as:
This step is carried out efficiently by calling the optimized tensor contraction package opt_einsum[54]. For fermion-to-qubit mapping, Chemistry implements an efficient Jordan-Wigner transformation written in pure Julia. Other methods such as Bravyi-Kitaev are currently provided through the interface of OpenFermion.[55] The qubit Hamiltonian can then be used to construct quantum gates for measurement in quantum algorithms such as VQE or QPE.
Wave function
To represent a many-electron quantum state on a quantum computer, the most commonly used strategy is to map its molecular orbitals onto qubits of which can span the Fock space. Such a straightforward orbital-to-qubit approach can be written as
where represents both the occupation of orbitals and the quantum state or of the corresponding qubit. Equation (6) actually describes the quantum state corresponding to the eigenstates of a qubit Hamiltonian which is obtained from the Jordan-Wigner transformation. If other fermion-to-qubit mapping algorithms such as Bravyi-Kitaev are used for the Hamiltonian, such a correspondence does not necessarily exist. With a quantum state mapped to qubits, Chemistry provides Hadamard test to evaluate the expectation value of the quantum state with respect to an operator.
In the simple orbital-to-qubit mapping, the number of qubits required to simulate the wave function has a linear dependence on the number of basis functions, which prohibit the use of a large basis set on NISQ devices. provides another strategy which maps a classical tensor network (TN) state onto quantum circuits.[56, 57] In this way, the qubits determines the classical bond dimension of the tensor network. For chemical systems which contain weak electron correlations or have a special symmetry, such a TN-based strategy provides a possible solution to effectively reduce the number of qubits at the expense of performing more measurements. Generally, different wave function mapping strategy leads to distinctive structures of the quantum circuits, therefore may bring special restrictions to subsequent quantum algorithms and measurement protocols. The q2chem.qchem module passes the mapping strategy to quantum algorithms in q2chem.qalgo to generate an abstract circuit class for initialization. The abstract circuits are then extended according to the adopted quantum algorithm and instantiated to a common readable quantum circuit that can be used in the q2chem.qcirc.
The quantum circuit module
The q2chem.qcirc module provides quantum circuit execution functionalities. It mainly contains two parts: a interface reserved for quantum computer manufacturers and a classical simulator which simulates state evolution determined by quantum circuits on a classical computer.
Interfaces to quantum devices
Functionalities in q2chem.qcirc are inherited from the _Base class. High-level Python APIs enable efficient extensions of , which can be used to interface with different quantum devices operation systems. Currently, there are multiple competing technical routes of quantum computer, e.g., the photonic qubits have long coherence time while su-
class _BaseQPU(object):
def __init__(self, options, ...):
self.quantum_state = ...
...
def evolve_circuit(self, ...):
...
class _BaseHardware(_BaseQPU):
def evolve_circuit(self, ...):
circuit_asm = self._compile_circuit(...)
measurement_result = self._quantum_hardware_evolution(...)
...
def _compile_circuit(self, ...):
# Implement for specific hardware.
def _quantum_hardware_evolution(self, ...):
# Implement for specific hardware.
class _BaseSimulator(_BaseQPU):
def evolve_circuit(self, ...):
...
for op in quantum_circuit:
if isinstance(op, QuantumGate):
self._quantum_gate_evolution(...)
elif isinstance(op, MeasurementOp):
self._measure_qubit(...)
...
def _quantum_gate_evolution(self, ...):
# Implement in custom simulators.
def _measure_qubit(self, ...):
# Implement in custom simulators.
Code Example 1: Interface to quantum devices in the qcircuit module.
perconducting platforms have good scalability. In order to efficiently and accurately study quantum chemical problems, various quantum hardwares may be required depending on the characteristics of the quantum algorithm. Therefore, we provide a flexible interface for connecting to different quantum hardware platforms as illustrated in Code Example 1. In a general _BaseHardware, the circuit generated by Chemistry is firstly represented by quantum assembly language such as OpenQASM via _compile_circuit(). This step generally should include circuit optimization and reconstruction to fit the architecture of specific hardwares. Then the sequence of gates are converted into signals or pulses and sent to the quantum devices through _quantum_hardware_evolution() using a compiler provided by the vendor of the hardware system. Finally, results such as measurement statistics or bit strings are collected and post-processed in to obtain required quantities.
Classical quantum circuit simulator
implements several simulators to run quantum circuits on a classical computer. The quantum state of multiple qubits can be expanded using a certain basis set
where is the number of qubits, and is the basis state. The coefficients is an -dimensional tensor which contains amplitudes. Equation 7 is similar to the correlated wave function in quantum chemistry represented by a configuration interaction (CI) expansion.
Currently, there are two strategies to simulate the evolution of quantum state on a classical computer. One is brute-force simulation which uses a state vector (SV) or a density matrix (DM) to represent the quantum state. The other is tensor network methods which approximate the quantum state by a set of low-rank tensors. The brute-force methods are supported by most of the existing packages (Table 2). Chemistry also supports the state vector and density matrix methods. These brute-force methods implemented in the q2chem.qcirc module uses compressed sparse row (CSR) format for sparse matrix storage and OpenMP for multi-threaded calculation. An OpenACC-enabled C++ code is also implemented and can be selected at compile time to utilize GPU, which can provide 2 10 times speed-up over the multi-threaded CPU version.
Table 2. Backends for circuit simulations in present open-source quantum computation softwares. External indicates that one or more third-party packages are required to enable the functionality. SA stands for single-amplitude simulation.
A typical drawback of the brute-force simulation is that the memory usage and computational complexity both scales as , where is a constant between 2 to 4 and is the number of qubits. This exponential scaling prevents quantum simulations for larger molecules with more than 30 qubits. Recently, matrix product states (MPS) and projected entangled pair states (PEPS) are used to simulate large scale random quantum circuits. [63, 64, 65, 66] Since the tensor contraction pattern is mostly fixed and does not have the NP-hard path optimization problems, [67, 68] the one-dimensional MPS is preferable as a high performance tensor network backend for a general quantum circuit simulator.
The MPS ansatz factorizes the rank- coefficients into lower rank tensors which can be written as
where is a rank-3 tensor with called the physical index and the auxiliary index. The maximum size of the auxiliary indices are defined as the bond dimension of the MPS, which is denoted as . Algorithms based on MPS generally have a complexity of . If the bond dimension is allowed to grow exponentially, the MPS can exactly represent any quantum state using Equation (8).
The q2chem.qcirc module implements the MPS simulation algorithm on the top of the machine learning framework PyTorch[48] based on the algorithm proposed by Guifré et al. 69``. A demonstrative procedure for simulating quantum circuit using MPS algorithm is presented in Figure 2. Different from the common classical MPS-based methods such as density matrix renormalization group (DMRG), [45] a set of auxiliary matrices are inserted between the rank-3 tensors and stored to maintain a normalized quantum state after the truncated SVD.
Figure 2. (a) Applying a single qubit gate on the MPS quantum state is simulated by simply a local contraction. (b) Applying a two-qubit gate on neighbouring qubits generally has 2 steps: 1) Reshape the two-qubit gate into a 4-dimensional tensor and contract with the qubits to form a two-qubit tensor; 2) perform a singular value decomposition to restore the two-qubit tensor back to the MPS formulation. Post-processing is usually required to maintain normalization or canonicalization of MPS tensors; (c) Auxiliary matrices which contains truncated and normalized singular values are used to achieve normalization of the quantum state.
Classical quantum simulator backends can also be extended within the framework of Chemistry in a similar style as the interfaces for hardwares. It requires only a minimum effort of implementing functions quantum_gate_evolution() and measure_qubit() for a derived class of BaseSimulator and, if necessary, a custom data structure to store the quantum state. No modifications to upper level modules such as expectation value evaluation or higher level quantum algorithms is required. In § 6.2, we show the application of Chemistry interfaced with an external MPS simulator QuantumSpins [64, 70] which efficiently simulated a 40-qubit molecule with a high accuracy.
Reverse-mode differentiation
In many quantum algorithms, a parametric quantum circuit is constructed and optimization of the circuit parameters is carried out iteratively. On a quantum computer, the gradients of energy or another target function with respect to circuit parameters can be calculated through the parameter-shift rule or finite difference steps, which will introduce an additional complexity factor of , where is the number of parameters. Nevertheless, using a classical quantum circuit simulator the gradients can be evaluated efficiently with an approximately complexity, which is extremely helpful just as the backward propagation algorithm used in classical machine learning if a large number of parameters are involved. This classical algorithm as illustrated in Algorithm 1 is termed as reverse-mode differentiation.[71, 72]
| Algorithm 1: Reverse-mode algorithm to calculate . |
| Data: , , |
| Result: : gradients of energy w.r.t. parameters |
| number of parameters, empty array of length ; |
| for ; ; do |
| ; |
| end |
| , ; |
| for ; ; do |
| ; |
| ; |
| ; |
| end |
Table 1 (PDF p. 14).
Chemistry implements reverse-mode differentiation for the brute-force backends. It should be noted that the reverse-mode differentiation algorithm is invalid on real quantum devices even if the original equation is used:
since the derivative gates are generally non-unitary. At the same time, using reverse-mode differentiation with the MPS simulator requires careful modifications to the algorithm and specially designed techniques due to the SVD truncation during the simulation. A naive implementation of Algorithm 1 probably leads to suboptimal performance and numerical errors.
Quantum algorithms
In the current release, Chemistry provides a couple of VQE-based algorithms. The module q2chem.qalgo adopted several variational wave function ansatzes which can be used individually or collectively to solve for the eigenstates of the given chemical system. New quantum algorithms can also be implemented by users conveniently.
Variational quantum circuit ansatz
Introducing a parametric wave function , the lowest eigenvalue can be obtained variationally:
Such a protocol is implemented in the q2chem.qalgo module to obtain the eigenstates of a given Hamiltonian. Properly constructing a parametric quantum circuit, the wave function ansatz is encoded into the quantum state of qubits. Combining the measurements for expectation value evaluation on a quantum computer and a numerical optimization algorithm on a classical computer, the variational procedure can then be performed in a hybrid quantum-classical way.
Generally, there are two broad types of variational quantum circuit ansatzes. [9] They are physically motivated ansatz (PMA) which is inspired by classical wave function methods that systematically approaches the exact electronic wave function and hardware heuristic ansatz (HHA) which considers specific hardware structure and employs entangling blocks. Both types are currently integrated into the q2chem.qalgo module.
Unitary coupled-cluster is one of the most commonly PMA for quantum computing.
Generally, the UCC wave function is defined as
In Chemistry, the spin-adapt CCD0 cluster operators [73, 74, 75] are used to construct the UCCSD and UCCGSD wave functions. A fermion-to-qubit mapping is performed and first-order Trotter-Suzuki decomposition [76, 77] is implemented to convert (10) into the product of Pauli strings:
where the -th fermion excitation operator is transformed into the qubit form . Each exponential term is mapped to quantum circuit following Algorithm 2. An example of the mapped circuit is present in Figure 3a.
Figure 3. (a) The quantum circuit corresponding to the operator and (b) the two-layer Kandala-Mezzacapo circuit which entangles all neighbouring qubits using the controlled- gate. Blue squares represent non-parametric gates while green represent parametric quantum gates such as and the three-parameter (controlled-) gate.
The Kandala-Mezzacapo circuit [30] is implemented as an HHA ansatz. If the type of entanglement gates, the ordering of entanglement qubits and the number of layers are set, Chemistry automatically generates the parametric hardware efficient circuit for simulation. Figure 3(b) shows an example of a two-layer Kandala-Mezzacapo circuit with all neighbouring qubits entangled by the three-parameter controlled- gate.
Algorithm 2: Map to circuit. is the Hadamard-Y gate defined as
Data: $\hat{P}$, $\theta$
Result: C: the quantum circuit
$N_q \leftarrow$ number of qubits, C$\leftarrow$empty circuit;
for $i=0$; $i\leq N_q-1$; $i+=1$ do
$p_i=P[i]$;
if $p_i==\hat{\sigma}_x$ then
C += $H_i$
else if $p_i==\hat{\sigma}_y$ then
C += $HY_i$
end
end
for $i=N_q-2$; $i\geq 0$; $i-=1$ do
C += $\mathit{CNOT}_{(i+1,i)}$
end
C += $RZ(-2\theta)_{N_q-1}$
for $i=0$; $i\leq N_q-2$; $i+=1$ do
C += $\mathit{CNOT}_{i+1,i}$
end
for $i=0$; $i\leq N_q-1$; $i+=1$ do
$p_i=P[i]$;
if $p_i==\hat{\sigma}_x$ then
C += $H_i$
else if $p_i==\hat{\sigma}_y$ then
C += $HY_i$
end
end
Several techniques are implemented in Chemistry to reduce the computational overhead, including qubit tapering for Hamiltonian, [78] qubit excitation based (QEB) operator, [79] Pauli entangler, [80, 81, 82] symmetry-based operator selection[41] and the ADAPT-VQE algorithm.[83] Chemistry supports combination of above methods, for example, using Pauli entanglers which entangle at most 4 qubits together with ADAPT-VQE leads to an iterative-qubit-coupled-cluster (iQCC)[81] like algorithm.
In addition to ground state methods, q2chem.qalgo module offers a couple of post-VQE algorithms for calculating excited states, including the variational quantum deflation (VQD),[24] quantum subspace expansion (QSE)[25] and equation-of-motion (EOM)[53, 84, 85, 86, 87] theory. VQD consecutively constructs an effective Hamiltonian, the lowest eigenvalue of which corresponds to the 1st, 2nd, 3rd, . . . excited state energy:
where is the original second-quantized electronic Hamiltonian. QSE and EOM use a set of fermion excitation operators or a state-transfer operator to construct and solve a generalized eigenvalue problem by additional quantum measurements on the top of the ground state circuit. These methods are implemented in Chemistry for calculating electron excitations, ionization potentials and electron affinity energies for both molecules and periodic systems.
Parallel evaluation of an expectation value
As shown in Equation (2), the Hamiltonian is expressed as the summation of a polynomial number of mutually uncorrelated Pauli strings. Expectation values of each Pauli string can thus be calculated independently. Figure 4 gives an example of circuits used for evaluating expectation value for a given Hamiltonian containing a number of Pauli strings under some fermion-to-qubit transformation. For each of the circuits, the ansatz parts are the same while the measurement parts are constructed according to the specific form of Pauli string. During the calculation of expectation value, automatically distributes these circuits to different quantum devices or simulator processes. On each device, a subset of circuits are executed then measured. The measurement outcomes are then post-processed to calculate expectation values locally. Finally, the results are reduced across all the devices to obtain the total energy.

Figure 4. Evaluating the expectation of a linear combination of Pauli strings using multiple quantum devices or simulator processes. In this example, the measurement parts are the Hadamard test circuits.
It should be noted that on real quantum devices, since the quantum states are non-replicable, all the circuits should be executed. However, on a classical simulator, the memory data of quantum states can be reused. Therefore, using a quantum circuit simulator, the ansatz part only needs to be executed once, and the simulated quantum state can then be copied to each process for later measurements. This strategy is used in the simulations of § 6.
Applications
We present several simulations to show the power of , including a scalability test for the MPS-based quantum circuit simulator and the numerical simulation results for ground- and excited-state calculations.
Scalability benchmark
The parallel measurement for expectation value introduced in § 5.2 is extended to a two-level parallelism for the MPS simulator:
The first level parallelization over Hamiltonian. Subsets of Pauli strings from the Hamiltonian in Equation (1) is distributed to each process. The expectation values of Pauli strings are calculated independently and a reduce-sum is performed across all processes to obtain the final energy.
A second low-level parallelization using multi-thread parallelism on CPU or GPU, to accelerate the calculations of linear algebra routines such as matrix multiplication and singular value decomposition.
The two-level strategy enables good parallel scalability if the adapted dynamical distribution algorithm is used to achieve load balance. To reduce memory usage, in the first level the quantum circuit is stored and evolved only on the 0-th process. Although for small molecules such as (4 qubits), the circuit evolution may contribute over 80% to the total execution time, the number of Pauli strings in the Hamiltonian will quickly go beyond due to the scaling, and the time cost of circuit simulation will become negligible if larger systems with more that 12 qubits are involved. The scaling benchmark of the Chemistry simulating a molecule (STO-3G basis set) using the MPS backend is given in Figure 5. Chemistry achieves good parallel performance up to 768 CPU cores for this 72-qubit system.

Figure 5. Simulating molecule using the MPS backend. STO-3G basis set and the symmetry-reduced UCCSD ansatz is used. The qubit Hamiltonian contains 305041 Pauli strings. 51 out of 3131 variational parameters (with random initial values) are selected, leading to a quantum circuit with 119884 gates. The upper bound for bond dimension is set to be 64. The time cost for one VQE iteration (including evolution of the quantum circuit and calculation of energy) is tested. The distributed parallelization is implemented using OpenMPI and Python’s mpi4py package.
Numerical results
Figure 6 shows the potential energy curve of the molecule. The calculation is carried out by extending the simulators in q2chem.qcirc module to an external MPS circuit simulator written in Julia. [64, 70] Benefiting from the high-level modular structure introduced in § 2, this external simulator and the parallelization techniques introduced in § 5.2 can be easily implemented within the framework of Chemistry by adding a few lines of code. The ground-state energies are variationally optimized using ccj-pVDZ basis set[88] and the symmetry-reduced UCCSD[41] circuit (leading to 40 qubits and 53 variational parameters). The BOBYQA optimizer is used to perform gradient-free optimizations. For each geometry, 2000 optimization steps are performed within 24 hours using 560 CPU cores.

Figure 6. The VQE optimized potential energy curve of H calculated by the MPS backend using ccj-pVDZ basis set. The FCI energies are obtained using the PySCF code, and the VQE results are calculated by interfacing with the external Julia-implemented MPS simulator.
Figure 7 calculates quasi-particle band structures for silicon. For such periodic systems, the Hamiltonian and UCC-based wave function ansatz need to include the constraint of crystal momentum conservation,[52] which is automatically handled by the q2chem.qchem module. The simulation uses GTH-SVZ basis set with GTH-PADE pseudopotential. A UCCGSD operator pool with complementary operators[53] is employed together with the ADAPT algorithm for ground state ADAPT-C wave function. With a k-point grid, 16 qubits are simulated using the state vector backend. The EOM-ADAPT-C method[53] is used for band structure calculation, which achieves a mean absolute difference of 0.047 eV from EOM-CCSD and the deviation is as small as eV at point (Figure 7).

Figure 7. Energy difference between EOM-ADAPT-C and classical EOM-CCSD band structures for Si. Inset gives the EOM-ADAPT-C band structure calculated using Chemistry.
Conclusion
In this study, we demonstrate that the Chemistry package is suitable for simulating and developing quantum algorithms for quantum chemistry applications. Chemistry provides versatile functionalities for simulating ground- and excited-state properties. The simulator backend, including the parallelized MPS algorithm, achieves high performance for large-scale simulations up to 72 qubits using a moderate amount of computational resources. Directions for future development include more classical simulation methods including high-dimensional tensor network based methods, more integrated quantum algorithms, and high-performance quantum circuit optimization algorithms. With the flexibility to link to different quantum devices, Chemistry can be used as a useful platform in pursuing practical quantum advantage.
Acknowledgement
This work was partially supported by the NSFC (21825302), by the Fundamental Research Funds for the Central Universities (WK2060000018), by National Supercomputing Center in Jinan, and by the USTC Supercomputing Center.
References
References
- [1]Preskill, J. Quantum Computing in the NISQ era and beyond. Quantum 2018, 2, 79.DOI
- [2]McArdle, S.; Endo, S.; Aspuru-Guzik, A.; Benjamin, S. C.; Yuan, X. Quantum computational chemistry. Rev. Mod. Phys. 2020, 92, 015003.DOI
- [3]Yung, M.-H.; Casanova, J.; Mezzacapo, A.; McClean, J.; Lamata, L. et al. From transistor to trapped-ion computers for quantum chemistry. Scientific Reports 2014, 4, 3589.DOI
- [4]Tilly, J.; Chen, H.; Cao, S.; Picozzi, D.; Setia, K. et al. The Variational Quantum Eigen-solver: a review of methods and best practices. arxiv:quant-ph 2021, arxiv:2111.05176.DOI
- [5]Cerezo, M.; Arrasmith, A.; Babbush, R.; Benjamin, S. C.; Endo, S. et al. Variational quantum algorithms. Nature Reviews Physics 2021, 3, 625–644.DOI
- [6]Magann, A. B.; Arenz, C.; Grace, M. D.; Ho, T.-S.; Kosut, R. L. et al. From Pulses to Circuits and Back Again: A Quantum Optimal Control Perspective on Variational Quantum Algorithms. PRX Quantum 2021, 2, 010101.
- [7]Fedorov, D. A.; Peng, B.; Govind, N.; Alexeev, Y. VQE method: a short survey and recent developments. Materials Theory 2022, 6, 2.arxiv.org/abs/2103.08505
- [8]Bravyi, S. B.; Kitaev, A. Y. Fermionic Quantum Computation. Ann. Phys. 2002, 298, 210–226.DOI
- [9]Cao, Y.; Romero, J.; Olson, J. P.; Degroote, M.; Johnson, P. D. et al. Quantum Chemistry in the Age of Quantum Computing. Chem. Rev. 2019, 119, 10856–10915.DOI
- [10]Preskill, J. Quantum Computing in the NISQ era and beyond. Quantum 2018, 2, 79.DOI
- [11]Georgescu, I. M.; Ashhab, S.; Nori, F. Quantum simulation. Rev. Mod. Phys. 2014, 86, 153–185.DOI
- [12]Aspuru-Guzik, A.; Dutoi, A. D.; Love, P. J.; Head-Gordon, M. Simulated Quantum Computation of Molecular Energies. Science 2005, 309, 1704–1707.
- [13]Wang, H.; Kais, S.; Aspuru-Guzik, A.; Hoffmann, M. R. Quantum algorithm for obtaining the energy spectrum of molecular systems. Phys. Chem. Chem. Phys. 2008, 10, 5388–5393.
- [14]Peruzzo, A.; McClean, J.; Shadbolt, P.; Yung, M.-H.; Zhou, X.-Q. et al. A variational eigenvalue solver on a photonic quantum processor. Nat. Commun. 2014, 5, 4213.DOI
- [15]Hempel, C.; Maier, C.; Romero, J.; McClean, J.; Monz, T. et al. Quantum Chemistry Calculations on a Trapped-Ion Quantum Simulator. Phys. Rev. X 2018, 8, 031022.DOI
- [16]Nam, Y.; Chen, J.-S.; Pisenti, N. C.; Wright, K.; Delaney, C. et al. Ground-state energy estimation of the water molecule on a trapped-ion quantum computer. NPJ Quantum Inf. 2020, 6, 33.arxiv.org/abs/1902.10171
- [17]Shen, Y.; Zhang, X.; Zhang, S.; Zhang, J.-N.; Yung, M.-H. et al. Quantum implementation of the unitary coupled cluster for simulating molecular electronic structure. Phys. Rev. A: At., Mol., Opt. Phys. 2017, 95, 020501.DOI
- [18]O’ Malley, P. J. J.; Babbush, R.; Kivlichan, I. D.; Romero, J.; McClean, J. R. et al. Scalable Quantum Simulation of Molecular Energies. Phys. Rev. X 2016, 6, 031007.
- [19]Kandala, A.; Mezzacapo, A.; Temme, K.; Takita, M.; Brink, M. et al. Hardware-efficient variational quantum eigensolver for small molecules and quantum magnets. Nature 2017, 549, 242–246.DOI
- [20]Colless, J. I.; Ramasesh, V. V.; Dahlen, D.; Blok, M. S.; Kimchi-Schwartz, M. E. et al. Computation of Molecular Spectra on a Quantum Processor with an Error-Resilient Algorithm. Phys. Rev. X 2018, 8, 011021.DOI
- [21]McClean, J. R.; Romero, J.; Babbush, R.; Aspuru-Guzik, A. The theory of variational hybrid quantum-classical algorithms. New J. Phys. 2016, 18, 023023.DOI
- [22]Lanyon, B. P.; Whitfield, J. D.; Gillett, G. G.; Goggin, M. E.; Almeida, M. P. et al. Towards quantum chemistry on a quantum computer. Nat. Chem. 2010, 2, 106–111.DOI
- [23]Romero, J.; Babbush, R.; McClean, J. R.; Hempel, C.; Love, P. J. et al. Strategies for quantum computing molecular energies using the unitary coupled cluster ansatz. Quantum Sci. Technol. 2018, 4, 014008.arxiv.org/abs/1701.02691
- [24]Higgott, O.; Wang, D.; Brierley, S. Variational Quantum Computation of Excited States. Quantum 2019, 3, 156.DOI
- [25]McClean, J. R.; Kimchi-Schwartz, M. E.; Carter, J.; de Jong, W. A. Hybrid quantum-classical hierarchy for mitigation of decoherence and determination of excited states. Phys. Rev. A 2017, 95, 042308.DOI
- [26]Liu, J.; Fan, Y.; Li, Z.; Yang, J. Quantum algorithms for electronic structures: basis sets and boundary conditions. Chem. Soc. Rev. 2022, 51, 3263–3279.DOI
- [27]McClean, J. R.; Boixo, S.; Smelyansky, V. N.; Babbush, R.; Neven, H. Barren plateaus in quantum neural network training landscapes. Nature Communications 2018, 9, 4812.DOI
- [28]Napp, J. Quantifying the barren plateau phenomenon for a model of unstructured variational ansätze. arXiv:quant-ph 2022, arXiv:2203.06174.arxiv.org/abs/2203.06174
- [29]Anschuetz, E. R.; Kiani, B. T. Beyond Barren Plateaus: Quantum Variational Algorithms Are Swamped With Traps. arxiv:quant-ph 2022, arxiv:2205.05786.
- [30]Kandala, A.; Mezzacapo, A.; Temme, K.; Takita, M.; Brink, M. et al. Hardware-efficient variational quantum eigensolver for small molecules and quantum magnets. Nature 2017, 549, 242–246.DOI
- [31]Arute, F.; Arya, K.; Babbush, R.; Bacon, D.; Bardin, J. C. et al. Hartree-Fock on a superconducting qubit quantum computer. Science 2020, 369, 1084–1089.DOI
- [32]Huggins, W. J.; O’Gorman, B. A.; Rubin, N. C.; Reichman, D. R.; Babbush, R. et al. Unbiasing fermionic quantum Monte Carlo with a quantum computer. Nature 2022, 603, 416–420.
- [33]Kutzelnigg, W. Quantum chemistry in Fock space. I. The universal wave and energy operators. J. Chem. Phys. 1982, 77, 3081–3097.DOI
- [34]Bartlett, R. J.; Kucharski, S. A.; Noga, J. Alternative coupled-cluster ansätze II. The unitary coupled-cluster method. Chem. Phys. Lett. 1989, 155, 133–140.DOI
- [35]Taube, A. G.; Bartlett, R. J. New perspectives on unitary coupled-cluster theory. Int. J. Quantum Chem. 2006, 106, 3393–3401.DOI
- [36]Steiger, D. S.; Häner, T.; Troyer, M. ProjectQ: an open source software framework for quantum computing. Quantum 2018, 2, 49.DOI
- [37]ANIS, M. S.; Abby-Mitchell;; Abraham, H.; AduOffei;; Agarwal, R. et al. Qiskit: An Open-source Framework for Quantum Computing. 2021.
- [38]Suzuki, Y.; Kawase, Y.; Masumura, Y.; Hiraga, Y.; Nakadai, M. et al. Qulacs: a fast and versatile quantum circuit simulator for research purpose. Quantum 2021, 5, 559.DOI
- [39]Luo, X.-Z.; Liu, J.-G.; Zhang, P.; Wang, L. Yao.jl: Extensible, Efficient Framework for Quantum Algorithm Design. Quantum 2020, 4, 341.DOI
- [40]Bergholm, V.; Izaac, J.; Schuld, M.; Gogolin, C.; Alam, M. S. et al. PennyLane: Automatic differentiation of hybrid quantum-classical computations. arxiv:quant-ph 2018, arxiv:1811.04968.arxiv.org/abs/1811.04968
- [41]Cao, C.; Hu, J.; Zhang, W.; Xu, X.; Chen, D. et al. Progress toward larger molecular simulation on a quantum computer: Simulating a system with up to 28 qubits accelerated by point-group symmetry. Phys. Rev. A 2022, 105, 062452.DOI
- [42]Bezanson, J.; Edelman, A.; Karpinski, S.; Shah, V. B. Julia: A Fresh Approach to Numerical Computing. SIAM Review 2017, 59, 65–98.arxiv.org/abs/1411.1607
- [43]Sun, Q.; Berkelbach, T. C.; Blunt, N. S.; Booth, G. H.; Guo, S. et al. PySCF: the Python-based simulations of chemistry framework. Wiley Interdisciplinary Reviews: Computational Molecular Science 2018, 8, e1340.arxiv.org/abs/1701.08223
- [44]Orús, R. A practical introduction to tensor networks: Matrix product states and projected entangled pair states. Annals of Physics 2014, 349, 117–158.DOI
- [45]Schollwöck, U. The density-matrix renormalization group in the age of matrix product states. Annals of Physics 2011, 326, 96–192, January 2011 Special Issue.DOI
- [46]Harris, C. R.; Millman, K. J.; van der Walt, S. J.; Gommers, R.; Virtanen, P. et al. Array programming with NumPy. Nature 2020, 585, 357–362.
- [47]Virtanen, P.; Gommers, R.; Oliphant, T. E.; Haberland, M.; Reddy, T. et al. SciPy 1.0: Fundamental Algorithms for Scientific Computing in Python. Nature Methods 2020, 17, 261–272.
- [48]Paszke, A.; Gross, S.; Massa, F.; Lerer, A.; Bradbury, J. et al. In Advances in Neural Information Processing Systems 32; Wallach, H., Larochelle, H., Beygelzimer, A., d’Alché-Buc, F., Fox, E. et al. , Eds.; Curran Associates, Inc., 2019; pp 8024–8035.
- [49]Jordan, P.; Wigner, E. Über das Paulische Äquivalenzverbot. Zeitschrift für Physik 1928, 47, 631–651.
- [50]Seeley, J. T.; Richard, M. J.; Love, P. J. The Bravyi-Kitaev transformation for quantum computation of electronic structure. J. Chem. Phys. 2012, 137, 224109.DOI
- [51]Tranter, A.; Love, P. J.; Mintert, F.; Coveney, P. V. A Comparison of the Bravyi–Kitaev and Jordan–Wigner Transformations for the Quantum Simulation of Quantum Chemistry. J. Chem. Theory Comput. 2018, 14, 5617–5630.DOI
- [52]Liu, J.; Wan, L.; Li, Z.; Yang, J. Simulating Periodic Systems on a Quantum Computer Using Molecular Orbitals. J. Chem. Theory Comput. 2020, 16, 6904–6914.DOI
- [53]Fan, Y.; Liu, J.; Li, Z.; Yang, J. Equation-of-Motion Theory to Calculate Accurate Band Structures with a Quantum Computer. The Journal of Physical Chemistry Letters 2021, 12, 8833–8840, PMID: 34492184.DOI
- [54]a. Smith, D. G.; Gray, J. opt_einsum - A Python package for optimizing contraction order for einsum-like expressions. Journal of Open Source Software 2018, 3, 753.DOI
- [55]McClean, J. R.; Sung, K. J.; Kivlichan, I. D.; Cao, Y.; Dai, C. et al. OpenFermion: The Electronic Structure Package for Quantum Computers. arXiv:quant-ph 2017, arXiv:1710.07629.arxiv.org/abs/1710.07629
- [56]Liu, J.-G.; Zhang, Y.-H.; Wan, Y.; Wang, L. Variational quantum eigensolver with fewer qubits. Phys. Rev. Research 2019, 1, 023025.DOI
- [57]Haghshenas, R.; Gray, J.; Potter, A. C.; Chan, G. K.-L. Variational Power of Quantum Circuit Tensor Networks. Phys. Rev. X 2022, 12, 011047.DOI
- [58]Nguyen, D.; Mikushin, D.; Man-Hong, Y. HiQ-ProjectQ: Towards user-friendly and high-performance quantum computing on GPUs. 2021 Design, Automation & Test in Europe Conference & Exhibition (DATE). 2021; pp 1056–1061.DOI
- [59]MindQuantum Developer, MindQuantum, version 0.6.0. 2021; https://gitee.com/mindspore/mindquantum.
- [60]Cirq Developers, Cirq. 2022; https://doi.org/10.5281/zenodo.6599601, See full list of authors on Github: https://github.com/quantumlib/Cirq/graphs/contributors.
- [61]Paddle Quantum. 2020; https://github.com/PaddlePaddle/Quantum.
- [62]Jones, T.; Brown, A.; Bush, I.; Benjamin, S. C. QuEST and High Performance Simulation of Quantum Computers. Scientific Reports 2019, 9, 10736.DOI
- [63]Guo, C.; Liu, Y.; Xiong, M.; Xue, S.; Fu, X. et al. General-Purpose Quantum Circuit Simulator with Projected Entangled-Pair States and the Quantum Supremacy Frontier. Phys. Rev. Lett. 2019, 123, 190501.DOI
- [64]Guo, C.; Zhao, Y.; Huang, H.-L. Verifying Random Quantum Circuits with Arbitrary Geometry Using Tensor Network States Algorithm. Phys. Rev. Lett. 2021, 126, 070502.DOI
- [65]Liu, X.; Guo, C.; Liu, Y.; Yang, Y.; Song, J. et al. Redefining the quantum supremacy baseline with a new generation sunway supercomputer. arXiv:quant-ph 2021, arXiv:2111.01066.arxiv.org/abs/2111.01066
- [66]McCaskey, A.; Dumitrescu, E.; Chen, M.; Lyakh, D.; Humble, T. Validating quantum-classical programming models with tensor network simulations. PLOS ONE 2018, 13, 1–19.DOI
- [67]Chi-Chung, L.; Sadayappan, P.; Wenger, R. On Optimizing a Class of Multi-Dimensional Loops with Reduction for Parallel Execution. Parallel Processing Letters 1997, 07, 157–168.
- [68]Pfeifer, R. N. C.; Haegeman, J.; Verstraete, F. Faster identification of optimal contraction sequences for tensor networks. Phys. Rev. E 2014, 90, 033315.pubmed.ncbi.nlm.nih.gov/25314572
- [70]Chu, G. QuantumSpins. https://github.com/guochu/QuantumSpins, 2020.
- [71]Jones, T.; Gacon, J. Efficient calculation of gradients in classical simulations of variational quantum algorithms. arXiv:quant-ph 2020, arXiv:2009.02823.arxiv.org/abs/2009.02823
- [72]Chu, G. VQC.jl. https://github.com/guochu/VQC.jl, 2020.
- [73]Scuseria, G. E.; Janssen, C. L.; Schaefer, H. F. An efficient reformulation of the closed-shell coupled cluster single and double excitation (CCSD) equations. The Journal of Chemical Physics 1988, 89, 7382–7387.DOI
- [74]Bulik, I. W.; Henderson, T. M.; Scuseria, G. E. Can Single-Reference Coupled Cluster Theory Describe Static Correlation? Journal of Chemical Theory and Computation 2015, 11, 3171–3179, PMID: 26575754.DOI
- [75]Sokolov, I. O.; Barkoutsos, P. K.; Ollitrault, P. J.; Greenberg, D.; Rice, J. et al. Quantum orbital-optimized unitary coupled cluster methods in the strongly correlated regime: Can quantum algorithms outperform their classical equivalents? The Journal of Chemical Physics 2020, 152, 124107.DOI
- [76]Grimsley, H. R.; Claudino, D.; Economou, S. E.; Barnes, E.; Mayhall, N. J. Is the Trotterized UCCSD Ansatz Chemically Well-Defined? J. Chem. Theory Comput. 2020, 16, 1–6.DOI
- [77]Babbush, R.; McClean, J.; Wecker, D.; Aspuru-Guzik, A.; Wiebe, N. Chemical basis of Trotter-Suzuki errors in quantum chemistry simulation. Phys. Rev. A 2015, 91, 022311.DOI
- [78]Bravyi, S.; Gambetta, J. M.; Mezzacapo, A.; Temme, K. Tapering off qubits to simulate fermionic Hamiltonians. arxiv:quant-ph 2017, arxiv:1701.08213.arxiv.org/abs/1701.08213
- [79]Yordanov, Y. S.; Armaos, V.; Barnes, C. H. W.; Arvidsson-Shukur, D. R. M. Qubit-excitation-based adaptive variational quantum eigensolver. Communications Physics 2021, 4, 228.
- [80]Ryabinkin, I. G.; Yen, T.-C.; Genin, S. N.; Izmaylov, A. F. Qubit Coupled Cluster Method: A Systematic Approach to Quantum Chemistry on a Quantum Computer. Journal of Chemical Theory and Computation 2018, 14, 6317–6326, PMID: 30427679.arxiv.org/abs/1809.03827
- [81]Ryabinkin, I. G.; Lang, R. A.; Genin, S. N.; Izmaylov, A. F. Iterative Qubit Coupled Cluster Approach with Efficient Screening of Generators. Journal of Chemical Theory and Computation 2020, 16, 1055–1063, PMID: 31935085.DOI
- [82]Ryabinkin, I. G.; Izmaylov, A. F.; Genin, S. N. A posteriori corrections to the iterative qubit coupled cluster method to minimize the use of quantum resources in large-scale calculations. Quantum Science and Technology 2021, 6, 024012.arxiv.org/abs/2009.13622
- [83]Grimsley, H. R.; Economou, S. E.; Barnes, E.; Mayhall, N. J. An adaptive variational algorithm for exact molecular simulations on a quantum computer. Nat. Commun. 2019, 10, 3007.DOI
- [84]ROWE, D. J. Equations-of-Motion Method and the Extended Shell Model. Rev. Mod. Phys. 1968, 40, 153–166.DOI
- [85]Stanton, J. F.; Bartlett, R. J. The equation of motion coupled-cluster method. A systematic biorthogonal approach to molecular excitation energies, transition probabilities, and excited state properties. J. Chem. Phys. 1993, 98, 7029–7039.DOI
- [86]Krylov, A. I. Equation-of-Motion Coupled-Cluster Methods for Open-Shell and Electronically Excited Species: The Hitchhiker’s Guide to Fock Space. Annu. Rev. Phys. Chem. 2008, 59, 433–462.DOI
- [87]Ollitrault, P. J.; Kandala, A.; Chen, C.-F.; Barkoutsos, P. K.; Mezzacapo, A. et al. Quantum equation of motion for computing molecular excitation energies on a noisy quantum processor. Phys. Rev. Res. 2020, 2, 043140.
- [88]Benedikt, U.; Auer, A. A.; Jensen, F. Optimization of augmentation functions for correlated calculations of spin-spin coupling constants and related properties. The Journal of Chemical Physics 2008, 129, 064111.DOI

