Quantum Circuits for Computational Chemists

Overview

The world of quantum computing has its own language and conventions. This document aims to bridge the gap between computational quantum chemistry and quantum computing.

In computational chemistry we think in terms of wave functions, operators, and excitations. In quantum computing we think in terms of circuits and gates.

The wave function of a molecule is represented as a quantum state \(|\Psi\rangle\) in a high-dimensional Hilbert space. On NISQ devices such a wave function may be encoded by a parameterized circuit, with parameters \(\{\theta_i\}\), which is also called the ansatz. On this page, we will guide you from a general understanding of quantum chemistry to the specifics of implementing quantum circuits for simulating molecular systems.

Full Configuration Interaction

An FCI wave function can be expressed as a linear combination of Slater determinants, each reachable from the Hartree–Fock reference (\(| \mathrm{HF} \rangle\)) by a series of excitations.

\[|\Psi_{\mathrm{FCI}}\rangle \;=\; \sum_{I} c_I \, \hat{E}_I |HF\rangle,\]

Here the the \(c_I\) are coefficients and \(\hat{E}_I\) is a general excitation operator that transforms the Hartree–Fock state into an excited Slater determinant.

For a single excitation from occupied orbital \(i\) to virtual orbital \(a\):

\[\hat{E}_{i}^{a} \;=\; \hat{a}_{a}^\dagger \hat{a}_{i},\]

For a double excitation from occupied orbitals \(i, j\) to virtual orbitals \(a, b\):

\[\hat{E}_{ij}^{ab} \;=\; \hat{a}_{a}^\dagger \hat{a}_{b}^\dagger \hat{a}_{j} \hat{a}_{i},\]

In general, the index \(I\) represents all possible excitations consistent with the target electron number and spin symmetry. Applying \(\hat{E}_I\) to the Hartree–Fock reference \(|\mathrm{HF}\rangle\) yields one of the determinants in the FCI expansion. Thus, \(I\) is a compound index that runs over all possible excitations. This creates all determinants of the given electron number and spin symmetry.

Coupled Cluster

In coupled cluster (CC) theory, the wave function is written in an exponential cluster form over a single reference Hartree–Fock determinant (\(| \mathrm{HF} \rangle\)). More specifically, the CC with singles and doubles (CCSD) ansatz is for example given by:

\[|\Psi_{\mathrm{CCSD}}\rangle \;=\; e^{\hat{T}_1 + \hat{T}_2} \, |\Phi_0\rangle,\]

with the singles and doubles cluster operators

\[\begin{split}\hat{T}_1 &= \sum_{i}^{\mathrm{occ}}\sum_{a}^{\mathrm{virt}} t_i^{a}\, \hat{E}_{i}^{a}, \\ \hat{T}_2 &= \tfrac{1}{4}\sum_{ij}^{\mathrm{occ}}\sum_{ab}^{\mathrm{virt}} t_{ij}^{ab}\, \hat{E}_{ij}^{ab},\end{split}\]

where \(i,j\) label occupied spin orbitals and \(a,b\) label virtual spin orbitals of the reference.

The Disentangled Unitary Coupled Cluster (UCC) Ansatz

On a classical computer, many common electronic structure methods (such as Coupled Cluster and Configuration Interaction) use wave function parametrizations that are not unitary. For example, the exponential form of Coupled Cluster Theory \(e^{\hat{T}}\) does not correspond to a unitary operator because \(\hat{T}\) is not anti-Hermitian.

A quantum computer, however, represents the state of the system as a normalized vector in Hilbert space, and evolves it through operations that must be unitary to preserve this normalization and to be physically realizable.

This means that any ansatz for a quantum computer must be composed of unitary operators. Generally, a unitary operator may be constructed from exponentials of anti-Hermitian operators. For example, Unitary CC (UCC) theory uses the unitary ansatz \(e^{\hat{T} - \hat{T}^\dagger}\) where \(\hat{T} - \hat{T}^\dagger\) is anti-Hermitian.

UCC however, is too expensive to implement directly on current quantum hardware as it requires Trotterization. One way to avoid this is to resort to the so-called disentangled UCC ansatz (dUCC). This ansatz is equivalent to a first-order Trotter approximation of UCC, but has been shown to be able to parameterize the exact wave function, even when only single and double excitations are included. dUCC is thus best regarded a as an ansatz in its own right, rather than an approximation to UCC.

In dUCC, the ansatz is expressed as a product of unitary operators, where each of the unitaries is generated by an anti-Hermitian built from one excitation operator \(\hat{\kappa}_I = \hat{E}_I - \hat{E}_I^\dagger\). Thus the parameterized unitary operator is given by:

\[U_I(\theta_I) = e^{- \theta_I \hat{\kappa}_I},\]

where:

  • the minus is conventional,

  • \(\theta_I\) is a real variational parameter.

Note that in the literature, the unitary is often introduced with a Hermitian generator \(\hat{G}_I = i\hat{\kappa}_I\), but this is not necessary since \(\hat{\kappa}_I\) is anti-Hermitian by construction.

As a result we use a disentangled product of such unitaries to build our ansatz.

\[|\Psi\rangle = U_m(\theta_m) \cdots U_2(\theta_2) U_1(\theta_1) \, |\mathrm{HF}\rangle,\]

or in dUCC form

\[|\Psi\rangle = e^{- \theta_m \hat{\kappa}_m} \cdots e^{- \theta_2 \hat{\kappa}_2} e^{- \theta_1 \hat{\kappa}_1} |\mathrm{HF}\rangle.\]

Where for the anti-Hermitian operator \(\hat{\kappa}_I\) for single and double excitation operators may be written as:

\[\begin{split}\hat{\kappa}_{i}^{a} &= \hat{E}_{i}^{a} - \hat{E}_{a}^{i}, \\ \hat{\kappa}_{ij}^{ab} &= \hat{E}_{ij}^{ab} - \hat{E}_{ab}^{ij},\end{split}\]

with the labels \(i,j\) referring to occupied spin orbitals and \(a,b\) labeling virtual spin orbitals of the reference.

The Hartree-Fock Quantum Circuit

With the general understanding of the wave function ansatz in place, we can now translate these concepts into the language of quantum computing.

Any variational quantum chemistry calculation begins from a reference state. In molecular quantum chemistry, this is often the Hartree–Fock (HF) determinant.

When encoding the HF state into a quantum circuit, we need to choose a mapping from the molecular orbitals to qubits. Several choices exist, but here we will focus on the Jordan–Wigner (JW) mapping. In JW, each spin orbital is mapped to a single qubit with the result that Slater determinants are encoded as occupation number vectors.

Mapping Orbitals to Qubits

To achieve this mapping, we follow these conventions:

  • 1 spin orbital ↔ 1 qubit

  • Occupied orbital ↔ qubit in \(|1\rangle\)

  • Virtual orbital ↔ qubit in \(|0\rangle\)

  • The alpha (spin up) and beta (spin down) orbitals are sorted into separate blocks of qubits.

  • Within each spin block, orbitals are ordered by increasing energy.

The Pauli X Gate

One of the fundamental quantum gates used in quantum circuits is the (single-qubit) Pauli X gate. The Pauli \(X\) gate, also known as the bit-flip or NOT gate, is crucial in preparing quantum states that correspond to specific electronic configurations. The action of the Pauli \(X\) gate on a qubit state is as follows:

\[\begin{split}X \ket{0} &= \ket{1} \quad \text{(flips the virtual state to occupied)},\\ X \ket{1} &= \ket{0} \quad \text{(flips the occupied state to virtual)}.\end{split}\]

Note that Pauli \(X\) (acting on qubit \(p\)) can not directly be related to the fermionic creation and annihilation operators since it does not obey the fermionic anti-commutation relations. More on this later.

Initial Circuit — Preparing the HF State

Now we are in a position to prepare the HF reference state. Generally we assume that all qubits start in the \(|0\rangle\) state. To prepare the HF reference state, we may then use Pauli X gates to flip the qubits corresponding to occupied spin orbitals.

  • \(|0\rangle\) → virtual orbital

  • \(X |0\rangle\) = \(|1\rangle\) → occupied orbital

Example: For H2 with two electrons in three spatial orbitals (six spin orbitals):

q0: ──X────  (occupied α orbital)
q1: ───────  (virtual α orbital)
q2: ───────  (virtual α orbital)
q3: ──X────  (occupied β orbital)
q4: ───────  (virtual β orbital)
q5: ───────  (virtual β orbital)

So here qubits q0 and q3 are flipped to \(|1\rangle\) to represent the two electrons in the lowest-energy spin orbitals. One in a spin up state (q0) and one in a spin down state (q3).

The HF state is thus just a quantum circuit, which is just a set of qubits and a set of gates applied to the qubits. Until now we have not done anything that we could not also have done on a classical computer (i.e. encode occupation number vectors as bit strings). The real power of quantum computing comes from the ability to store superpositions of states, e.g. a FCI state, in the same number of qubits as the HF state and to manipulate these superpositions with quantum gates. One way to generate such superpositions is to apply parameterized unitary operators corresponding to excitations, which we will discuss next.

Beyond the Hartree-Fock Circuit

To go beyond the Hartree-Fock reference state and capture electron correlation, we need to apply additional quantum gates that correspond to excitation operators. In the disentangled UCC framework, these are the unitary operators \(U_I(\theta_I) = e^{- \theta_I \hat{\kappa}_I}\) introduced earlier.

For the implementation of these unitaries on a quantum computer, we need to decompose such abstract operators into a sequence of fundamental quantum gates, such as the single-qubit Pauli X gate introduced above. However, to complete the construction, we need to learn about more quantum gates, such as

  • Pauli \(Y\) and \(Z\) gates

  • Rotation gates (\(R_x\), \(R_y\), \(R_z\))

  • Multi-qubit gates like CNOT and Toffoli

Often such gates are available on current quantum hardware as native gates, otherwise the process of transpilation will express these gates in terms of the hardware native gates. For our purposes here it is sufficient to use these gates as building blocks to construct the excitation unitaries.

The Pauli \(Y\) and \(Z\) Gates and Rotation Gates

In addition to the Pauli \(X\) gate, there are two other fundamental single-qubit Pauli gates: the Pauli Y and Pauli Z gates. The actions of these gates on a qubit state are as follows:

\[\begin{split}Y \ket{0} &= i\ket{1} \qquad &&\text{(flips the virtual state to occupied with a phase)},\\ Y \ket{1} &= -i\ket{0} && \text{(flips the occupied state to virtual with a phase)},\\ Z \ket{0} &= \ket{0} && \text{(leaves the virtual state unchanged)},\\ Z \ket{1} &= -\ket{1} && \text{(adds a phase of -1 to the occupied state)}.\end{split}\]

Single qubit rotation gates Rx, Ry, Rz can then be understood from the Pauli gates:

\[\begin{split}R_x(\theta) &= e^{-i \frac{\theta}{2} X} &= \cos\left(\frac{\theta}{2}\right) I - i \sin\left(\frac{\theta}{2}\right) X, \\ R_y(\theta) &= e^{-i \frac{\theta}{2} Y} &= \cos\left(\frac{\theta}{2}\right) I - i \sin\left(\frac{\theta}{2}\right) Y, \\ R_z(\theta) &= e^{-i \frac{\theta}{2} Z} &= \cos\left(\frac{\theta}{2}\right) I - i \sin\left(\frac{\theta}{2}\right) Z.\end{split}\]

Multi-Qubit Gates

So far, we have described single-qubit gates, which act on individual qubits. However, more complex operations are required to implement excitation operators, specifically, we need multi-qubit gates, which are essential for creating entanglement — correlations between qubits that cannot be described by classical probabilities.

For the implementation of excitation operators we mostly use the

CNOT (Controlled-NOT) gate

  • Acts on two qubits: a control qubit and a target qubit.

  • If the control qubit is \(|1\rangle\), the target qubit is flipped (an \(X\) is applied).

  • If the control qubit is \(|0\rangle\), the target is unchanged.

  • Often denoted by a solid dot on the control qubit line, connected by a vertical line to a \(\oplus\) symbol on the target.

Example circuit:

q0: ──●────
      │
q1: ──X────

Universal Quantum Gates

A set of gates is considered universal if it can approximate any unitary operation to arbitrary precision. We have introduced several gates above, and it turns out that the combination of:

  • Single-qubit rotations (\(R_x\), \(R_y\), \(R_z\))

  • Multi-qubit gate (CNOT)

is sufficient to construct any quantum circuit, including those needed for quantum chemistry applications.

The Excitation Gate

The excitation gate is an implementation of the unitary operator \(U_I(\theta_I) = e^{- \theta_I \hat{\kappa}_I}\) where \(\hat{\kappa}_I\) is an anti-Hermitian operator corresponding to a single or double excitation. This construction is not straight-forward as the commutation relations of the fermionic annihilation and creation operators must be preserved, more on that in Mapping the Hamiltonian to Qubit Operators. But several approximations and decompositions have been developed to reduce the circuit depth while achieving reasonable accuracy. One way of introducing such approximate parameterized excitation gates is called Qubit-Excitation Based (QEB) gates (or operators), where some phase information is dropped. For example, a QEB single excitation gate between orbitals \(i\) and \(a\) may be written as:

q0: ──Rz(−π/2)──Rx(π/2)──●──Rx(Θ)──●──Rx(-π/2)──Rz(π/2)──
                         │         │
q1: ────────────Rx(π/2)──X──Rz(Θ)──X──Rx(-π/2)───────────

Analogous, but more complicated, we may construct double excitation QEB gates using a combination of CNOTs and single-qubit rotations. Often, it is sufficient to take an abstract view and write the the singles excitation operators as:

q0: ────■────
        │
q1: ────■────

where we only record the qubits between which particles are swapped while keeping in mind that the implementation may be more complicated, as shown above. Similarly, doubles excitation operators may be viewed abstractly as

q0: ────■────
        │
q1: ────■────
        |
q2: ────+────
        │
q3: ────■────
        │
q4: ────■────

where we have a double excitation operator that operates on q0, q1, q3 and q4, but not on q2. With these abstractions in place we can now visualize a one possible encoding (or parameterization) of a dUCC state as a quantum circuit by applying a sequence of such excitation gates to the Hartree-Fock reference circuit, where we use two double excitation gates and two single excitation gates in sequence and parallel, respectively:

q0: ──X───■────■─────────
          │    │
q1: ──────■────+────■────
          │    │    │
q2: ──────+────■────■────
          │    │
q3: ──X───■────■─────────
          │    │
q4: ──────■────+────■────
               │    │
q5: ───────────■────■────

Each of these excitation gates would be parameterized by a variational parameter \(\theta_I\), which can be optimized by running the VQE algorithm. In order for this to work, we also need to be able to measure expectation values of operators on the quantum computer, which we will discuss below. Another important operation on such a circuit is to be able to sample the quantum state, e.g. to enable FAST-VQE and other quantum algorithms. This we will discuss next.

Other Important Quantum Gates

Toffoli gates are mostly important in the context of fault-tolerant quantum computing, but we mention it here for completeness as you may encounter it in the literature.

Toffoli (CCNOT) gate

  • A three-qubit gate with two control qubits and one target qubit.

  • The target qubit is flipped only if both controls are \(|1\rangle\).

  • The Toffoli gate is important in reversible computing and quantum error correction.

Example circuit:

q0: ──●────
      │
q1: ──●────
      │
q2: ──X────

Sampling the Quantum State

As mentioned before the Hartree-Fock circuit can be represented as a bitstring: \(b_0 = 001001\) using the ordering of the qubits \(q_5q_4q_3q_2q_1q_0\). This also represents an occupation number vector of second quantization or a single slater determinant.

Now consider the case where several excitation gates are applied to the HF circuit to obtain the wave function \(|\Psi\rangle\) as before:

\[|\Psi\rangle = U_m(\theta_m) \cdots U_2(\theta_2) U_1(\theta_1) \, |\mathrm{HF}\rangle,\]

After expanding each of these unitaries appropriately, the resulting quantum state can be expressed as a superposition of multiple bitstrings:

\[|\Psi\rangle = c_0 |b_0\rangle + c_1 |b_1\rangle + c_2 |b_2\rangle + \cdots\]

where each bitstring corresponds to a slater determinant and the coefficients \(c_i\) are real numbers determined by the parameters of the excitation gates. Since we have used unitaries for the expansion, we also know that the coefficients must satisfy the normalization condition. We may now sample from \(|\Psi\rangle\) by executing the quantum circuit above and measure all qubits each time. Each execution (shot) will yield one bitstring \(b_i\) according to Born’s rule:

\[P(b_i) = |c_i|^2\]

Classically, the expansion of the unitaries can be prohibitively expensive, but on a quantum computer, the circuit can be executed directly to obtain samples from the distribution of bitstrings. This way, one can get an idea about the magnitudes of the amplitudes \(c_i\) without explicitly constructing them - and use that information in various quantum algorithms such as FAST-VQE.

Expectation Values

Calculating the energy of a quantum state \(|\Psi\rangle\) requires measuring the expectation value of the Hamiltonian. On a quantum computer, this is done by expressing the Hamiltonian in terms of Pauli strings, which is the subjet of this section.

Mapping the Hamiltonian to Qubit Operators

Consider the standard second-quantized Hamiltonian:

\[\hat{H} = \sum_{pq} h_{pq} \,\hat{a}^\dagger_p \hat{a}_q + \frac12 \sum_{pqrs} g_{pqrs} \hat{a}^\dagger_p \hat{a}^\dagger_r \hat{a}_s \hat{a}_q.\]

This operator must be mapped to qubit operators, e.g. using the previously introduced JW mapping. To understand how this works, we first need to understand the operator algebras of qubits and fermions in more detail. Qubits obey Pauli algebra (with the previously introduced Pauli matrices):

\[\{X, Y, Z, I\}, \quad X^2 = Y^2 = Z^2 = I\]

Fermionic creation and annihilation operators instead obey anticommutation relations:

\[\{\hat{a}_p, \hat{a}_q^\dagger\} = \delta_{pq}, \quad \{\hat{a}_p, \hat{a}_q\} = 0\]

Since qubits and fermions have different operator algebras, we cannot directly run the Hamiltonian on a quantum processor. We must map the fermionic operators to qubit operators while preserving the correct commutation/anticommutation structure.

The JW mapping represents creation and annihilation operators as:

\[\begin{split}\hat{a}^\dagger_p = \frac12 (X_p - i Y_p) \prod_{j=0}^{p-1} Z_j, \\ \hat{a}_p = \frac12 (X_p + i Y_p) \prod_{j=0}^{p-1} Z_j,\end{split}\]

where:

  • \(X_p, Y_p, Z_p\) are Pauli matrices acting on qubit \(p\),

  • the Z-string \(\prod_{j=0}^{p-1} Z_j\) enforces the fermionic sign from particle exchanges.

Result of the mapping

Once each \(\hat{a}^\dagger\) and \(\hat{a}\) is expressed in terms of Pauli matrices, the Hamiltonian becomes:

\[\hat{H} = \sum_{\alpha} c_\alpha \, P_\alpha\]

where:

  • \(P_\alpha\) is a tensor product of Pauli operators (Pauli string),

  • \(c_\alpha\) is a real coefficient derived from \(h_{pq}\) and \(g_{pqrs}\).

This Pauli string representation is the form used in variational quantum algorithms such as VQE or ADAPT-VQE. In order to determine the expectation of individual Pauli strings on we need to measure the respective qubits in the appropriate basis. Consider the Pauli string \(P_\alpha = \bigotimes_0^{n-1} P_i\), where \(P_i\) acts on qubit \(i\). We need to measure each qubit in the basis corresponding to \(P_i\). This can be written in terms of a diagonalization operator \(U_i\) such that:

\[P_i = U_i^\dagger Z_i U_i,\]

where we have used that each Pauli operator can be diagonalized to \(Z\) by an appropriate unitary transformation.

On the quantum computer can directly apply \(U_i\) to a quantum state \(|\Psi\rangle\) and measure its expectation value in the computational basis (the Z-basis). In the example circuit from before, this may look like:

q0: ──X───■────■───────U0──
          │    │
q1: ──────■────+────■──U1──
          │    │    │
q2: ──────+────■────■──U2──
          │    │
q3: ──X───■────■───────U3──
          │    │
q4: ──────■────+────■──U4──
               │    │
q5: ───────────■────■──U5──

Such measurements must be repeated many times for a single Pauli string to obtain an accurate estimate of its expectation value. Furthermore, since the Hamiltonian is a sum of many Pauli strings, we must measure the expectation value of each Pauli string separately and combine them classically to obtain the total energy:

\[E = \langle \Psi | \hat{H} | \Psi \rangle = \sum_{\alpha} c_\alpha \, \langle \Psi | P_\alpha | \Psi \rangle.\]

To make this process efficient, there are many details of transforming to a specific measurement basis, grouping measurements, and post-processing, which are implemented and automatically handled in Qrunch.

Adaptive VQE Circuits

Until now, we have only considered a fixed ansatz, which means that the structure of the quantum circuit is predetermined. However, in adaptive VQE algorithms such as ADAPT-VQE and FAST-VQE, the circuit is constructed iteratively by selecting and adding excitation operators from a predefined pool based on some criteria followed by parameter optimization using VQE.

Adaptive VQE algorithms are explained in detail in What Is an Adaptive-VQE and FAST-VQE and how to efficiently select the excitation operators is described in gate selection (Gate Selection).

Cheat Sheet

A quick translation between the language of computational chemistry and quantum computing.

  • Circuit depth correspond to the number of terms in the disentangled UCC product

  • Gate parameters (theta_k) are the variational coefficients in the ansatz

  • Hartree-Fock Circuit is the Quantum Circuit that correspond to the Hartree-Fock reference determinant

  • Gate pool is the candidates of excitation operators

  • Mapping is the mapping from Fermionic operator (e.g. Hamiltonian) to a set of Pauli strings

  • Ansatz construction is picking unitaries (gates) from excitation pool

  • State preparation is applying gates to HF state

  • Sampling is the act of getting the state of the circuit as a linear combination of bitstrings

  • Measurement is the act of evaluating \(\langle P_\alpha \rangle\) for each Pauli string

  • Shot is one complete execution of the quantum circuit followed by measurement of all qubits.

  • Shots (plural) = Repeated executions used to estimate probabilities of bitstrings and expectation values.

See Also