# Leveraging commuting groups for an efficient variational Hamiltonian ansatz

Abhinav Anand<EMAIL_ADDRESS>Duke Quantum Center, Duke University,
Durham, NC 27701, USA.  Department of Electrical and Computer Engineering,
Duke University, Durham, NC 27708, USA.  Kenneth R. Brown<EMAIL_ADDRESS>Duke Quantum Center, Duke University, Durham, NC 27701, USA.  Department of
Electrical and Computer Engineering, Duke University, Durham, NC 27708, USA.
Department of Physics, Duke University, Durham, NC 27708, USA.  Department of
Chemistry, Duke University, Durham, NC 27708, USA.

(August 28, 2024)

###### Abstract

Efficiently calculating the low-lying eigenvalues of Hamiltonians, written as
sums of Pauli operators, is a fundamental challenge in quantum computing.
While various methods have been proposed to reduce the complexity of quantum
circuits for this task, there remains room for further improvement. In this
article, we introduce a new circuit design using commuting groups within the
Hamiltonian to further reduce the circuit complexity of Hamiltonian-based
quantum circuits. Our approach involves partitioning the Pauli operators into
mutually commuting clusters and finding Clifford unitaries that diagonalize
each cluster. We then design an ansatz that uses these Clifford unitaries for
efficient switching between the clusters, complemented by a layer of
parameterized single qubit rotations for each individual cluster. By
conducting numerical simulations, we demonstrate the effectiveness of our
method in accurately determining the ground state energy of different quantum
chemistry Hamiltonians. Our results highlight the applicability and potential
of our approach for designing problem-inspired ansatz for various quantum
computing applications.

##  I Introduction

The last decade has seen quantum computing emerge as a transformative
technology, with the potential to revolutionize various scientific fields [1,
2, 3, 4]. A critical use of quantum computers involves simulating Hamiltonian
time evolution [5] for predicting properties of different quantum systems [6].
However, the existing quantum computing platforms are in their early phases of
development and encounter various sources of error, thus restricting the
practical applicability of these systems [7]. This requires us to find novel
algorithms that are designed to mitigate the effects of noise. One such method
is to design hybrid quantum-classical algorithms [8, 9, 10] where one utilizes
both the classical and quantum computer in a manner that exploits there
respective strengths.

A central object of such algorithms are parameterized quantum circuits (PQCs)
[11, 12, 13], which are used to prepare trial wavefunctions on the quantum
computer. Recent advancements have significantly enhanced our understanding of
the design principles [14, 15], trainability [16, 17, 18, 19] and convergence
properties [20] of different PQCs. A popular approach for design of PQCs are
Hamiltonian based circuits [21] which are known to have better training
properties [22] as they preserve the symmetry of the problem. However, these
circuits often possess limitations, such as depth and subspace restrictions,
which can impact their effectiveness [23, 24]. A potential solution to
overcome these limitations was proposed in Ref. [23], where the authors add
driving terms to the Hamiltonian to break the problem symmetry and observe
better convergence.

Another promising approach involves the utilization of Clifford or near-
Clifford circuits for performing useful computation. These circuits can be
simulated classically efficiently [25, 26] but are not universal, thus have a
limited applications. Nevertheless, they have been used to reduce the number
of measurements in quantum algorithms [27, 28, 29, 30, 31, 32, 33], find
compressed representation of quantum states [34], add correlation to product
wavefunctions [35] and for initial state preparation [36], among others.

In this study, we use techniques for partitioning of a Hamiltonian into
commuting groups and present a novel circuit design that integrates circuits
from problem-specific knowledge with general single qubit rotation gates. We
employ efficient clustering techniques to construct sets of mutually commuting
operators and Clifford unitaries, which simultaneously diagonalize these
operator sets. Subsequently, we utilize these Clifford circuits to create
"single-code" and "combined-codes" ansätze, where the Clifford circuits define
a symmetric subspace of the Hamiltonian and the general rotations navigate
these subspaces. We then apply these circuits to approximate ground state
energies of various molecules. Finally we provide empirical evidence of better
convergence of these circuit when compared to the traditional problem-based
ansatz.

The remaining sections of this paper are organized as follows: Section II
outlines the preliminary information and the method used in this study.
Section III presents the results from numerical simulations, and finally,
Section IV provides concluding remarks.

##  II Methodology

###  II.1 Clustering Hamiltonian into commuting groups

A quantum Hamiltonian, $\hat{H}$, can be written as

$\hat{H}=\sum_{k=1}^{M}c_{k}\hat{P}_{k},$ (1)

where $c_{k}$ is a complex number and $\hat{P}_{k}$ is a Pauli-string on
$n$-qubits. A Pauli-string is defined as a tensor product of the Pauli
matrices ($\hat{\sigma}_{x},\hat{\sigma}_{y},\hat{\sigma}_{z}$) and the
identity operator $\hat{I}$ as

$\hat{P}_{k}=\bigotimes_{j=1}^{n}\hat{\sigma},$ (2)

with
$\hat{\sigma}\in\\{\hat{I},\hat{\sigma}_{x},\hat{\sigma}_{y},\hat{\sigma}_{z}\\}$.
The Hamiltonian can be further separated into $m$-sets of mutually commuting
groups as

$\hat{H}=\sum_{k=1}^{m}\sum_{l=1}^{m_{i}}c_{kl}\hat{P}_{kl};$ (3)
$[\hat{P}_{ki},\hat{P}_{kj}]=0\text{ }\forall\text{
}(\hat{P}_{ki},\hat{P}_{kj})\in\\{\hat{P}_{k1},...,\hat{P}_{km_{i}}\\}$ (4)

where $\hat{P}_{kl}$ is the $l$-th Pauli-string in the $k$-th commuting set
and $c_{kl}$ is the complex coefficient. It is also well known that given a
set of commuting terms, there exists a unitary, $\mathcal{U}$, that
simultaneously diagonalizes each of the operators in the set as

$\mathcal{U}\hat{P}_{kl}\mathcal{U}^{\dagger}=\bigotimes_{j=1}^{n}\hat{\sigma},\text{
}\forall\text{ }\hat{P}_{kl}\in\\{\hat{P}_{k1},...,\hat{P}_{km_{i}}\\},$ (5)

where $\hat{\sigma}\in\\{\hat{I},\hat{\sigma}_{z}\\}$. In the past few years,
several proposals [27, 28, 29, 30, 31, 32, 33] have been put forward to find
the set of commuting groups, however, we follow the techniques presented in
Refs. [30]. The gate complexity of the unitary, $\mathcal{U}$, depends on the
choice of the type of commutativity, qubit wise commutativity vs. general
commutativity. In this work we use the general commutativity approach, as it
leads to lower number of commuting set but have deeper unitaries.

###  II.2 Variational Hamiltonian ansatz (VHA)

Given a Hamiltonian, $\hat{H}$, as in Eq. 3 we can define an ansatz as

$U(\bm{\theta})=\prod_{k=1}^{m}\mathcal{U}_{k}(\prod_{l=1}^{m_{k}}e^{-i\theta_{kl}\hat{P}_{kl}})\mathcal{U}^{\dagger}_{k},$
(6)

where $\\{\theta_{kl}\\}$ are variational parameters. The variational
Hamiltonian ansatz is a product of unitaries that correspond to short time
evolution under different parts of the Hamiltonian and can be repeated
multiple times to get better approximation of the full time evolution unitary,
$e^{-i\bm{\theta}\hat{H}}$. A schematic representation of the VHA ansatz is
shown in Fig. 1. This ansatz has been used for approximating eigenvalues of
different condensed matter systems as well as for strongly correlated systems
in quantum chemistry. However, they have been known to have some issues such
as, limited expressibility, larger circuit depths, among others. In what
follows, we present our proposed method that modifies the VHA ansatz to
mitigate some of the issues.

(a) A schematic of the traditional variational Hamiltonian ansatz (VHA). A
blue box represents a gate of the form $e^{-i\theta\hat{P}_{i}}$, where
$\hat{P}_{i}$ can be any Pauli-string.

(b) A schematic of the variational Hamiltonian ansatz of the form in Eq. 6. A
blue box represents a gate of the form $e^{-i\theta\hat{P}_{i}}$, where
$\hat{P}_{i}$’s are diagonal Pauli-strings.

Figure 1: A schematic of the different forms of the variational Hamiltonian
ansatz. The green box represents gate of the form
$e^{-i\theta\hat{\sigma}_{z}}$, the pink box represents gates for basis change
and the orange box represents Clifford circuits ($\mathcal{U}_{i}$ and
$\mathcal{U}_{i}^{\dagger}$) for simultaneous diagonalization.

###  II.3 Modified Variational Hamiltonian Ansatz

Given a decomposition of the Hamiltonian as in Eq. 3, a set of mutually
commuting terms $\\{\hat{P}_{k1},...,\hat{P}_{km_{i}}\\}$ forms an abelian
group. We can then construct a stabilizer group corresponding to every group
by replacing some of the $\hat{P}_{ki}$ with -$\hat{P}_{ki}$. The full
procedure for constructing these stabilizer groups is as follows:

  1. 1.

Collect all the terms $\hat{P}_{k}$ in the Hamiltonian,
$\hat{H}=\sum_{k=1}^{M}c_{k}\hat{P}_{k}$, which have only $\hat{\sigma}_{z}$
and $\hat{I}$ in one set.

  2. 2.

Use the technique in Refs. [30] to find the remaining sets and unitaries for
simultaneous diagonalizaton. At this point we have $m$-sets
$\\{\mathcal{G}_{i}\\}$ and $m$-unitaries $\\{\mathcal{U}_{i}\\}$ that
diagonalize the operators within the set.

  3. 3.

The stabilizer group $\mathcal{S}_{i}$ corresponding to the set with only
$\hat{\sigma}_{z}$ and $\hat{I}$, can be constructed by replacing
$\hat{P}_{ki}$ with -$\hat{P}_{ki}$, if there are odd number of
$\hat{\sigma}_{z}$ acting on the first $n/2$-qubits. A state,
$\ket{\Psi_{s_{i}}}$, that is stabilized by this group is the Hartree-Fock
state, $\ket{\text{HF}}$ .

  4. 4.

For the rest of the groups, we use their corresponding diagonal representation
(which can be constructed using similarity transform with the unitaries
obtained above) to replace $\hat{P}_{ki}$ with -$\hat{P}_{ki}$ following the
same procedure as for the case in step 3. A stabilizer state for these groups
is the state $\ket{\Psi_{s_{i}}}=\mathcal{U}_{i}^{\dagger}\ket{\text{HF}}$.

The stabilizer groups $\\{\mathcal{S}_{i}\\}$ that we construct above can be
considered as error-detecting codes, where the elements of the group are the
stabilizers and the states $\\{\ket{\Psi_{s_{i}}}\\}$ define the codespace. We
can use these stabilizer states $\\{\ket{\Psi_{s_{i}}}\\}$ and the unitaries
$\mathcal{U}_{i}$ to construct modified VHA ansatz. We describe the
construction in detail in the following sections.

####  II.3.1 Single-code ansatz

We modify the unitary $\mathcal{U}_{i}^{\dagger}$ generating the stabilizer
states for each group, with a layer of general single qubit rotation to create
a near-Clifford state. The resulting ansätze is of the form

$U_{s{{}_{i}}}(\bm{\theta}_{i})=\mathcal{U}_{i}^{\dagger}(\bigotimes_{j=1}^{n}\textbf{Rx}_{j}(\theta_{x_{j}})\textbf{Ry}_{j}(\theta_{y_{j}})\textbf{Rz}_{j}(\theta_{z_{j}})),$
(7)

where $\mathcal{U}_{i}$ is the unitary that diagonalizes all the operators in
the group $\mathcal{G}_{i}$, Rx, Ry and Rz are single qubit rotation gates,
and $\theta_{x_{j}}$, $\theta_{y_{j}}$ and $\theta_{z_{j}}$ are variational
parameters. We refer to these ansätze as single-code ansatz (Fig. 2) as they
originate from a single abelian group.

Figure 2:  A schematic of a single layer of the single-code ansätze. The
orange box represent Clifford circuits ($\mathcal{U}_{i}^{\dagger}$) and the
green boxes represents a general single qubit roatation gate of the kind
$e^{-i\theta_{x}\hat{\alpha}_{x}}e^{-i\theta_{y}\hat{\sigma}_{y}}e^{-i\theta_{z}\hat{\sigma}_{z}}$.

We can use this ansatz to find the ground state of the Hamiltonian
corresponding to the Hamiltonian $\hat{H}^{{}^{\prime}}=\sum g_{i},\forall
g_{i}\in\mathcal{G}_{i}$, by minimizing the following objective function

$E(\bm{\theta})=\bra{\text{HF}}U_{s{{}_{i}}}^{\dagger}(\bm{\theta})\hat{H}^{{}^{\prime}}U_{s{{}_{i}}}(\bm{\theta})\ket{\text{HF}}.$
(8)

This optimization corresponds to finding the ground state of a block of the
Hamiltonian, and we hypothesize that the state
$U_{s{{}_{i}}}(\bm{\theta}^{*})\ket{\text{HF}}$, which is a classically
simulatable state, can be a better state than the Hartree-Fock state for the
full Hamiltonian. We provide empirical evidence to support this hypothesis by
carrying out numerical simulations and report the result in sec. III.

####  II.3.2 Combined-codes ansatz

We can then combine all the single-code ansätze to form an ansatz using the
unitaries $\mathcal{U}_{i}\mathcal{U}_{j}^{\dagger}$ to change the basis from
group $\mathcal{G}_{i}$ to $\mathcal{G}_{j}$. This ansatz referred to as
combined-codes ansatz (Fig. 3) can be then written as

$\displaystyle
U(\bm{\theta})=\prod_{i}^{m}\mathcal{U}_{i}^{\dagger}\bigotimes_{j=1}^{n}\textbf{Rx}_{j}(\theta_{x_{i,j}})\textbf{Ry}_{j}(\theta_{y_{i,j}})\textbf{Rz}_{j}(\theta_{z_{i,j}})\mathcal{U}_{i},$
(9)

where $\theta_{x_{i,j}}$, $\theta_{y_{i,j}}$ and $\theta_{z_{i,j}}$ are
variational parameters.

Figure 3:  A schematic of a single layer of the combined-codes ansatz. The
orange box represent Clifford circuits ($\mathcal{U}_{i}$ and
$\mathcal{U}_{i}^{\dagger}$) and the green boxes represents a general single
qubit roatation gate of the kind
$e^{-i\theta_{x}\hat{\alpha}_{x}}e^{-i\theta_{y}\hat{\sigma}_{y}}e^{-i\theta_{z}\hat{\sigma}_{z}}$.

The ordering of the different single-code ansatz is important for the full
ansatz to have better convergence properties. One can use adaptive strategies
[37, 38, 39, 40] to sequentially combine these single-code ansätze to
construct the full ansatz. However, that may add extra overhead in terms of
circuit evaluations. So, we choose a strategy where we order them based on the
1-norm of the group.

The construction of the ansatz allows for a shorter circuit [41] with better
convergence properties, as we introduce more degrees of freedom by introducing
the general single qubit unitaries within the space spanned by each commuting
group. The total number of parameters in the circuit scales linearly both in
the number of the qubits, $n$, and number of commuting groups, $m$.

We believe that the ansatz presented above can be used to approximate low
energy eigenstates and eigenenergies within the VQE framework. We demonstrate
the usefulness of the proposed ansatz by running different numerical
experiments for different molecular systems and report our findings in sec.
III. One can further increase the accuracy of the approximation by repeating
the above ansatz multiple times.

As an illustration of our proposed framework, we provide the detailed
construction of the different ansätze for the hydrogen molecule in the
appendix Appendix.

##  III Numerical Experiments

In the following we will illustrate some application of the proposed ansatz.
We have implemented the whole framework using the Tequila [42] an open source
package, which uses Qulacs [43] as the backend for the execution of all the
numerical simulations and the BFGS implementation of SciPy [44] for gradient
based optimization. We use the Jordan-Wigner transformation [45] to map the
fermionic Hamiltonians of different molecules to Hamiltonians of the form in
Eq. 1. The Hamiltonians used in the numerical simulations can be found here
[46]. The initial values for all the circuit parameters in the different
numerical simulations was fixed to 0.001.

###  III.1 Simulations with single layer

Here we present results from experiments using the single-code ansatze and a
layer of the combined-codes ansatz for approximating ground state energies of
different molecules using the VQE framework.

####  III.1.1 Small Molecules: H2 and LiH

We first use our ansatz to approximate the ground state of the hydrogen
molecule, H2, in the minimal basis, where we have two electrons in four spin-
orbitals and the lithium hydride molecule, LiH, in an active space of the
minimal basis, where we have two electrons in six spin-orbitals. The results
from the simulation are presented in Fig. 4.

a) H2 molecule | b) LiH molecule
---|---
Energy
|
Error in energy
|
Figure 4:  VQE results from optimization of ground state energies for H2 and
LiH molecule using different geometries with a single layer of the proposed
ansatz.

It can be seen from the Fig. 4, that for both the molecules H2 and LiH, the
combined-codes ansatz converges to the corresponding exact solution (FCI) in
the given basis set for all geometries considered here. This implies that
using a single layer of proposed ansatz is expressive enough to find good
ground energy approximations for very small molecules.

Next we analyze the results from experiments using the single-code ansätze.
The energy corresponding to the best single-code ansatz (the ansatz with the
lowest energy) is plotted in Fig. 4. In both cases we observe that the energy
corresponding this ansatz is strictly better than the Hartree-Fock (HF)
energy. It converges to HF for geometries closer to equilibrium, but
outperforms HF for stretched geometries.

The success of our method for approximating ground state energies of small
molecules encouraged us to test our methods for larger problems.

####  III.1.2 Larger Molecules: H2O and N2

In this section, we present the results from simulations carried out for
slightly larger molecules. We simulate the active space of water molecule,
H2O, which has 6 electrons in 10 spin-orbitals and an active space nitrogen
molecule, N2, which has 6 electrons in 12 spin-orbitals. The result from all
the simulations are shown in Fig. 5.

a) H2O molecule | b) N2 molecule
---|---
Energy
|
Error in energy
|
Figure 5:  VQE results from optimization of ground state energies for H2O and
N2 molecule using different geometries with a single layer of the proposed
ansatz.

We observe that the results for these molecules using the best single-code
ansatz is qualitatively similar to what we observed for the case of small
molecules. It again converges to the HF solution for geometries near
equilibrium while outperforms HF for stretched geometries. This implies that
we can use the single-code ansätze for initial state preparation in regimes
where the molecules have higher correlation.

Additionally, we observe that a single layer of the combined-code ansatz
doesn’t perform as well as for the case of the small molecules. In both cases,
H2O and N2, the optimal energy for configurations close to the equilibrium
geometry agree to chemical accuracy (1e-3) with the exact ground state energy.
However, the optimal energy for stretched configurations does not converge to
the exact ground state energy. We suspect that the reason behind this behavior
is the limited expressivity of single layer of the proposed ansatz. This is
observed in the case of the traditional VHA ansatz as well, where one needs to
repeat the circuit to get better approximations. Thus, we now analyze the
convergence of the proposed ansatz as a function of the number of layers used
and report the results in the following section.

###  III.2 Simulation with two layers

In this section, we use the active space of the beryllium hydride molecule,
BeH2, where we have 4 electrons in 8 spin-orbitals. We run two different
simulations with single and two layers of the combined-codes ansatz and show
the results in Fig. 6.

a) single layer | b) two layers
---|---
Energy
|
Error in energy
|
Figure 6:  VQE results from optimization of ground state energies for BeH2
molecule using different geometries with single and two layers of the proposed
ansatz.

It can be seen from Fig. 6, that the energy convergence is qualitatively
similar to that observed for the case of H2O and N2 molecules, with good
convergence near equilibrium and larger errors for stretched geometries.
However, the curves corresponding to the simulation with two layers of the
ansatz converges to the true ground state energy for all geometries considered
here. This implies that by repeating the ansatz a few times, we can get a
better approximation of the eigenstates and their correpsonding energies.

All the numerical experiments presented until now suggest that the ansatz
proposed in this work is able to approximately find eigenvalues of molecules
of varying complexity. However, we haven’t provided any evidence to suggest
using our method over the VHA ansatz. We provide some numerical evidence
regarding that in the following section.

###  III.3 Comparison with VHA

In this section, we use the active space of the nitrogen molecule, N2, used
above in sec. III.1.2, to compare the performance of the two different anaätze
for three different configurations, squeezed, equilibrium and stretched.

a) 0.79 | b) 1.09 | c) 1.29
---|---|---
|  |
Figure 7:  Optimization trajectories from simulations of the N2 molecule with
three different geometries using the traditional VHA ansatz and the proposed
ansatz. The red and blue lines corresponds to Hartree-Fock and the exact
ground state energies, correspndingly.

We show the results from the different simulations in Fig. 7. It can be seen
from the plots that the modified ansatz converges to a slightly better optimal
energy value in comparison to the VHA ansatz, where the gap increases as we
move away from equilibrium geometries towards stretched geometries. This
indicates that the modified ansatz has better convergence properties for
approximating eigenvalues of different molecules.

We also report the circuit complexity of the two ansätze for all the molecules
considered in this work. The data is presented in Table 1. We note that the
modified ansatz has comparable 2-qubit gate count for the smaller molecules
and significantly lower gate count for the larger molecule considered in this
work, while the number of parameters are significantly higher for the modified
ansatz as compared to the traditional ansatz. This suggests that we can reduce
the circuit complexity of the VHA ansatz using our method for approximating
eigenvalues of different molecules.

Molecule | Number of 2-qubit gates | Number of Parameters
---|---|---
| VHA | M-VHA | VHA | M-VHA
H2 | 36 | 48 | 14 | 12
LiH | 262 | 272 | 61 | 108
BeH2 | 1328 | 1272 | 184 | 192
H2O | 2042 | 1408 | 251 | 474
N2 | 1860 | 1740 | 246 | 362
Table 1: A table containing the gate complexity of a single layer of the VHA
ansatz and the proposed modified ansatz (M-VHA). The values listed here are
the average of all the circuits used for simulation corresponding to the
different molecules.

##  IV Conclusion

In this work, we propose a new approach for designing quantum circuits to
approximate the low-lying eigenvalues of molecular Hamiltonians. We utilize
efficient clustering techniques to identify groups of mutually commuting terms
in the Hamiltonian, alongside Clifford unitaries that can simultaneously
diagonalize the operators within each set. Subsequently, we introduce two
distinct types of ansätze, namely the "single-code" and "combined-codes"
ansatz, utilizing the stabilizer states associated with each set of commuting
groups.

The proposed single-code ansatz which is classically simulatable, was shown to
have better energy when compared to the widely used Hartree-Fock states for
all the molecules considered in this work. These finding suggests its
potential for initial state preparation for molecular geometries where HF
states are not a good choice. Our work contributes to the growing research
direction [36, 35, 34] of exploring practical applications of classically
simulatable quantum models.

Furthermore, we provide empirical evidence confirming the utility of the
combined-codes ansatz in approximating ground state energies for various
molecules. Finally, we conduct a comparative analysis of the performance and
gate complexity between the combined-codes ansatz and the traditional VHA
ansatz. Our research marks an initial step towards the development of quantum
circuits that incorporate a combination of problem-dependent and random single
qubit unitaries, enabling symmetry-breaking and potentially leading to
improved convergence for various problems of interest. We anticipate that the
presented ansatz will unlock new possibilities for exploring the applicability
of the proposed ansätze in other areas of physics and machine learning, while
also providing a solid foundation for further investigations into such types
of ansätze.

## Acknowledgements

This work was supported by the National Science Foundation (NSF) Quantum Leap
Challenge Institute of Robust Quantum Simulation (QLCI grant OMA-2120757).
A.A. also acknowledges support by the National Science Foundation (Grant No.
DMS-1925919), as part of the work was done when he was visiting the Institute
for Pure and Applied Mathematics (IPAM).

## References

  * Bharti  _et al._ [2022] K. Bharti, A. Cervera-Lierta, T. H. Kyaw, T. Haug, S. Alperin-Lea, A. Anand, M. Degroote, H. Heimonen, J. S. Kottmann, T. Menke, _et al._ , Reviews of Modern Physics 94, 015004 (2022).
  * Cerezo  _et al._ [2021a] M. Cerezo, A. Arrasmith, R. Babbush, S. C. Benjamin, S. Endo, K. Fujii, J. R. McClean, K. Mitarai, X. Yuan, L. Cincio, _et al._ , Nature Reviews Physics , 1 (2021a).
  * Anand  _et al._ [2022a] A. Anand, P. Schleich, S. Alperin-Lea, P. W. K. Jensen, S. Sim, M. Díaz-Tinoco, J. S. Kottmann, M. Degroote, A. F. Izmaylov, and A. Aspuru-Guzik, Chemical Society Reviews 10.1039/D1CS00932J (2022a), arXiv:2109.15176 .
  * McArdle  _et al._ [2020] S. McArdle, S. Endo, A. Aspuru-Guzik, S. C. Benjamin, and X. Yuan, Reviews of Modern Physics 92, 015003 (2020).
  * Feynman [1982] R. P. Feynman, Int. J. Theor. Phys 21 (1982).
  * Aspuru-Guzik  _et al._ [2005] A. Aspuru-Guzik, A. D. Dutoi, P. J. Love, and M. Head-Gordon, Science 309, 1704 (2005).
  * Preskill [2018] J. Preskill, Quantum 2, 79 (2018).
  * Peruzzo  _et al._ [2014] A. Peruzzo, J. McClean, P. Shadbolt, M.-H. Yung, X.-Q. Zhou, P. J. Love, A. Aspuru-Guzik, and J. L. O’brien, Nature communications 5, 4213 (2014).
  * Farhi  _et al._ [2014] E. Farhi, J. Goldstone, and S. Gutmann, arXiv preprint arXiv:1411.4028 (2014).
  * McClean  _et al._ [2016] J. R. McClean, J. Romero, R. Babbush, and A. Aspuru-Guzik, New Journal of Physics 18, 023023 (2016).
  * Sim  _et al._ [2019] S. Sim, P. D. Johnson, and A. Aspuru-Guzik, Advanced Quantum Technologies 2, 1900070 (2019).
  * Benedetti  _et al._ [2019] M. Benedetti, E. Lloyd, S. Sack, and M. Fiorentini, Quantum Science and Technology 4, 043001 (2019).
  * Cong  _et al._ [2019] I. Cong, S. Choi, and M. D. Lukin, Nature Physics 15, 1273 (2019).
  * Zhang  _et al._ [2022] S.-X. Zhang, C.-Y. Hsieh, S. Zhang, and H. Yao, Quantum Science and Technology 7, 045023 (2022).
  * Du  _et al._ [2022] Y. Du, T. Huang, S. You, M.-H. Hsieh, and D. Tao, npj Quantum Information 8, 62 (2022).
  * McClean  _et al._ [2018] J. R. McClean, S. Boixo, V. N. Smelyanskiy, R. Babbush, and H. Neven, Nature communications 9, 1 (2018).
  * Cerezo  _et al._ [2021b] M. Cerezo, A. Sone, T. Volkoff, L. Cincio, and P. J. Coles, Nature communications 12, 1 (2021b).
  * Marrero  _et al._ [2021] C. O. Marrero, M. Kieferová, and N. Wiebe, PRX Quantum 2, 040316 (2021).
  * Wang  _et al._ [2021] S. Wang, E. Fontana, M. Cerezo, K. Sharma, A. Sone, L. Cincio, and P. J. Coles, Nature communications 12, 1 (2021).
  * Haug and Kim [2021] T. Haug and M. Kim, arXiv preprint arXiv:2104.14543 (2021).
  * Wecker  _et al._ [2015] D. Wecker, M. B. Hastings, and M. Troyer, Physical Review A 92, 042303 (2015).
  * Wiersema  _et al._ [2020] R. Wiersema, C. Zhou, Y. de Sereville, J. F. Carrasquilla, Y. B. Kim, and H. Yuen, PRX Quantum 1, 020319 (2020).
  * Choquette  _et al._ [2021] A. Choquette, A. Di Paolo, P. K. Barkoutsos, D. Sénéchal, I. Tavernelli, and A. Blais, Physical Review Research 3, 023092 (2021).
  * Anand  _et al._ [2022b] A. Anand, S. Alperin-Lea, A. Choquette, and A. Aspuru-Guzik, arXiv preprint arXiv:2209.14405 (2022b).
  * Aaronson and Gottesman [2004] S. Aaronson and D. Gottesman, Physical Review A 70, 052328 (2004).
  * Bravyi and Gosset [2016] S. Bravyi and D. Gosset, Physical review letters 116, 250501 (2016).
  * Verteletskyi  _et al._ [2020] V. Verteletskyi, T.-C. Yen, and A. F. Izmaylov, The Journal of chemical physics 152 (2020).
  * Izmaylov  _et al._ [2019] A. F. Izmaylov, T.-C. Yen, R. A. Lang, and V. Verteletskyi, Journal of chemical theory and computation 16, 190 (2019).
  * Jena  _et al._ [2019] A. Jena, S. Genin, and M. Mosca, arXiv preprint arXiv:1907.07859 (2019).
  * Crawford  _et al._ [2021] O. Crawford, B. van Straaten, D. Wang, T. Parks, E. Campbell, and S. Brierley, Quantum 5, 385 (2021).
  * Huggins  _et al._ [2021] W. J. Huggins, J. R. McClean, N. C. Rubin, Z. Jiang, N. Wiebe, K. B. Whaley, and R. Babbush, npj Quantum Information 7, 23 (2021).
  * Gokhale  _et al._ [2020] P. Gokhale, O. Angiuli, Y. Ding, K. Gui, T. Tomesh, M. Suchara, M. Martonosi, and F. T. Chong, IEEE Transactions on Quantum Engineering 1, 1 (2020).
  * Zhao  _et al._ [2020] A. Zhao, A. Tranter, W. M. Kirby, S. F. Ung, A. Miyake, and P. J. Love, Physical Review A 101, 062322 (2020).
  * Anand  _et al._ [2022c] A. Anand, J. S. Kottmann, and A. Aspuru-Guzik, arXiv preprint arXiv:2207.02961 (2022c).
  * Schleich  _et al._ [2023] P. Schleich, J. Boen, L. Cincio, A. Anand, J. S. Kottmann, S. Tretiak, P. A. Dub, and A. Aspuru-Guzik, arXiv preprint arXiv:2303.01221 (2023).
  * Ravi  _et al._ [2022] G. S. Ravi, P. Gokhale, Y. Ding, W. Kirby, K. Smith, J. M. Baker, P. J. Love, H. Hoffmann, K. R. Brown, and F. T. Chong, in  _Proceedings of the 28th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 1_ (2022) pp. 15–29.
  * Tang  _et al._ [2021] H. L. Tang, V. Shkolnikov, G. S. Barron, H. R. Grimsley, N. J. Mayhall, E. Barnes, and S. E. Economou, PRX Quantum 2, 020310 (2021).
  * Grimsley  _et al._ [2018] H. R. Grimsley, S. E. Economou, E. Barnes, and N. J. Mayhall, arXiv preprint arXiv:1812.11173 (2018).
  * Ryabinkin  _et al._ [2018] I. G. Ryabinkin, T.-C. Yen, S. N. Genin, and A. F. Izmaylov, Journal of chemical theory and computation 14, 6317 (2018).
  * Ryabinkin  _et al._ [2020] I. G. Ryabinkin, R. A. Lang, S. N. Genin, and A. F. Izmaylov, Journal of chemical theory and computation 16, 1055 (2020).
  * Van Den Berg and Temme [2020] E. Van Den Berg and K. Temme, Quantum 4, 322 (2020).
  * Kottmann  _et al._ [2021] J. S. Kottmann, S. Alperin-Lea, T. Tamayo-Mendoza, A. Cervera-Lierta, C. Lavigne, T.-C. Yen, V. Verteletskyi, P. Schleich, A. Anand, M. Degroote, _et al._ , Quantum Science and Technology 6, 024009 (2021).
  * Suzuki  _et al._ [2020] Y. Suzuki, Y. Kawase, Y. Masumura, Y. Hiraga, M. Nakadai, J. Chen, K. M. Nakanishi, K. Mitarai, R. Imai, S. Tamiya, T. Yamamoto, T. Yan, T. Kawakubo, Y. O. Nakagawa, Y. Ibe, Y. Zhang, H. Yamashita, H. Yoshimura, A. Hayashi, and K. Fujii, Qulacs: a fast and versatile quantum circuit simulator for research purpose (2020), arXiv:2011.13524 [quant-ph] .
  * Virtanen  _et al._ [2020] P. Virtanen, R. Gommers, T. E. Oliphant, M. Haberland, T. Reddy, D. Cournapeau, E. Burovski, P. Peterson, W. Weckesser, J. Bright, _et al._ , Nature methods 17, 261 (2020).
  * Jordan and Wigner [1928] P. Jordan and E. P. Wigner, Z. Phys. 47, 14 (1928).
  * [46] https://github.com/AbhinavUofT/Modified_VHA.

## Appendix

In this section we present the detailed construction of the ansatz propsed in
this work using the example of hydrogen molecule in the minimal basis. The
Hamiltonian of H2 in the minimal basis has 15 terms, and is:

$\displaystyle\hat{H}$
$\displaystyle=-0.0984\hat{I}+0.1713\hat{Z}(0)+0.1713\hat{Z}(1)$
$\displaystyle-0.2230\hat{Z}(2)-0.2230\hat{Z}(3)+0.1686\hat{Z}(0)\hat{Z}(1)$
$\displaystyle+0.1206\hat{Z}(0)\hat{Z}(2)+0.1659\hat{Z}(0)\hat{Z}(3)$
$\displaystyle+0.1659\hat{Z}(1)\hat{Z}(2)+0.1206\hat{Z}(1)\hat{Z}(3)$
$\displaystyle+0.1744\hat{Z}(2)\hat{Z}(3)+0.0453\hat{Y}(0)\hat{X}(1)\hat{X}(2)\hat{Y}(3)$
$\displaystyle-0.0453Y(0)Y(1)\hat{X}(2)\hat{X}(3)$
$\displaystyle-0.0453\hat{X}(0)\hat{X}(1)\hat{Y}(2)\hat{Y}(3)$
$\displaystyle+0.0453\hat{X}0)\hat{Y}(1)\hat{Y}2)\hat{X}(3)$

We can divide the Hamiltonian in two sets of commuting terms:

$\displaystyle\mathcal{G}_{1}$
$\displaystyle=\\{-0.0984\hat{I},0.1713\hat{Z}(0),0.1713\hat{Z}(1),$
$\displaystyle-0.2230\hat{Z}(2),-0.2230\hat{Z}(3),0.1686\hat{Z}(0)\hat{Z}(1),$
$\displaystyle 0.1206\hat{Z}(0)\hat{Z}(2),0.1659\hat{Z}(0)\hat{Z}(3),$
$\displaystyle 0.1659\hat{Z}(1)\hat{Z}(2),$ $\displaystyle
0.1206\hat{Z}(1)\hat{Z}(3),0.1744\hat{Z}(2)\hat{Z}(3)\\},\text{ and}$

$\displaystyle\mathcal{G}_{2}$
$\displaystyle=\\{0.0453\hat{Y}(0)\hat{X}(1)\hat{X}(2)\hat{Y}(3),$
$\displaystyle-0.0453Y(0)Y(1)\hat{X}(2)\hat{X}(3),$
$\displaystyle-0.0453\hat{X}(0)\hat{X}(1)\hat{Y}(2)\hat{Y}(3),$ $\displaystyle
0.0453\hat{X}0)\hat{Y}(1)\hat{Y}2)\hat{X}(3))\\}.$

We can then find the Clifford unitaries that diagonalizes these groups. The
set $\mathcal{G}_{1}$ is already diagonal and the unitary,
$\mathcal{U}_{diag}$, that diagonalizes the set $\mathcal{G}_{2}$ is shown in
Fig. 8.

Figure 8:  A Clifford unitary that diagonalizes the set $\mathcal{G}_{2}$. The
gates are represented in a compact notation, where, a gate labeled Z(0)Z(3) ==
$e^{-i(\pi/2)\hat{Z}(0)\hat{Z}(3)}$

The corresponding stabilizer groups can be written as

$\displaystyle\mathcal{S}_{1}$
$\displaystyle=\\{\hat{I},-\hat{Z}(0),-\hat{Z}(1),\hat{Z}(2),\hat{Z}(3),\hat{Z}(0)\hat{Z}(1),$
$\displaystyle-\hat{Z}(0)\hat{Z}(2),-\hat{Z}(0)\hat{Z}(3),-\hat{Z}(1)\hat{Z}(2),$
$\displaystyle-\hat{Z}(1)\hat{Z}(3),\hat{Z}(2)\hat{Z}(3)\\},\text{ and}$

$\displaystyle\mathcal{S}_{2}$
$\displaystyle=\\{\hat{Y}(0)\hat{X}(1)\hat{X}(2)\hat{Y}(3),-Y(0)Y(1)\hat{X}(2)\hat{X}(3),$
$\displaystyle-\hat{X}(0)\hat{X}(1)\hat{Y}(2)\hat{Y}(3),\hat{X}0)\hat{Y}(1)\hat{Y}2)\hat{X}(3))\\}.$

The corresponding stabilizer states for the two groups are:

$\displaystyle\ket{\Psi_{s_{1}}}$ $\displaystyle=\ket{1100}$
$\displaystyle\ket{\Psi_{s_{2}}}$
$\displaystyle=\mathcal{U}_{diag}^{\dagger}\ket{1100}$
$\displaystyle=\frac{1}{\sqrt{2}}(\ket{1100}+\ket{0011})$

We can now use these to construct the single code ansätze for the two groups,

$\displaystyle\ket{\Psi_{1}(\bm{\theta}_{1})}$
$\displaystyle=U_{s{{}_{1}}}(\bm{\theta}_{1})\ket{1100}$
$\displaystyle=\bigotimes_{j=1}^{4}\textbf{Rx}_{j}(\theta_{x_{1,j}})\textbf{Ry}_{j}(\theta_{y_{1,j}})\textbf{Rz}_{j}(\theta_{z_{1,j}})\ket{1100},\text{
and}$

$\displaystyle\ket{\Psi_{2}(\bm{\theta}_{2})}$
$\displaystyle=U_{s{{}_{2}}}(\bm{\theta}_{2})(\ket{1100})$
$\displaystyle=\mathcal{U}_{diag}^{\dagger}\bigotimes_{j=1}^{4}\textbf{Rx}_{j}(\theta_{x_{2,j}})\textbf{Ry}_{j}(\theta_{y_{2,j}})\textbf{Rz}_{j}(\theta_{z_{2,j}})\ket{1100}.$

The combined codes ansatz can be then constructed as:

$\displaystyle\ket{\Psi(\bm{\theta})}$
$\displaystyle=\mathcal{U}_{diag}^{\dagger}\bigotimes_{j=1}^{4}\textbf{Rx}_{j}(\theta_{x_{2,j}})\textbf{Ry}_{j}(\theta_{y_{2,j}})\textbf{Rz}_{j}(\theta_{z_{2,j}})$
$\displaystyle\mathcal{U}_{diag}\bigotimes_{j=1}^{4}\textbf{Rx}_{j}(\theta_{x_{1,j}})\textbf{Ry}_{j}(\theta_{y_{1,j}})\textbf{Rz}_{j}(\theta_{z_{1,j}})\ket{1100}$