Hamiltonian Variational Ansatz

The Hamiltonian Variational Ansatz (HVA) attempts to prepare an interacting state with a minimal number of variational parameters by following the example of adiabatic state evolution [63]. The system’s annealing is described by a sequence of unitary rotations in short time steps \(t/dt\) which brings the system from an initial state \(\psi_i\) to the ground state of \(H\):

(114)\[\begin{split}H(t)=H_0+\frac{t}{dt}H_1 \\ U=e^{-i\int_0^t H(t')dt'},\end{split}\]

where \(U\) is the evolution operator of the system. Trotterisation allows us to further decompose these rotations into sequences involving individual Hamiltonian terms.

(115)\[U_{trot}=e^{-it_0 H_0}e^{-it_0 H_1}e^{-it_1 H_0}...\]

These rotation angles can take arbitrary values in the HVA, rather than remain fixed by trotterisation. We can repeat these rotation sequences, introducing new variational parameters with each “layer” to increase the accuracy of the ansatz. This ansatz construction limits the number of symbolic parameters and has been shown to help preserve the system’s quantum numbers in the process [63].

(116)\[U_{HV}=e^{-i\phi_0 H_0}e^{-i\phi_1 H_1}e^{-i \phi_2 H_0}...\]

The specific decomposition of the interacting Hamiltonian into terms in the above rotation sequence depends on the problem and the type of the term. To reflect this, InQuanto includes several HVA variants: one suitable for chemistry problems as well as one for the Hubbard model.

In the example below, the HVA is used to find the ground state of an \(H_2\) molecule with VQE using HamiltonianVariationalAnsatzChemistry. To define the HVA, we need a reference state, which will play the role of \(\psi_i\). The HVA ansatz will split the Hamiltonian into individual terms and arrange them in \(s\) layers of rotation sequences. Then, an expectation valued can be defined and a VQE algorithm built just as with other variational ansatzes in InQuanto.

from inquanto.express import load_h5
from inquanto.protocols import SparseStatevectorProtocol
from inquanto.algorithms import AlgorithmVQE
from inquanto.ansatzes import HamiltonianVariationalAnsatzChemistry
from inquanto.computables.atomic import ExpectationValue
from inquanto.mappings import QubitMappingJordanWigner
from inquanto.minimizers import MinimizerScipy
from inquanto.spaces import FermionSpace
from pytket.extensions.qiskit import AerStateBackend


# Load in the system from the express module.
h2_sto3g = load_h5("h2_sto3g.h5", as_tuple=True)
ham = h2_sto3g.hamiltonian_operator
# In order to construct an ansatz we need to create a space and a state object.
space = FermionSpace(4)
state = space.generate_occupation_state_from_list([1, 1, 0, 0])

# Initiate the HV ansatz for chemistry with one layer
ansatz = HamiltonianVariationalAnsatzChemistry(
    reference=state,
    hamiltonian_operator=ham,
    qubit_mapping=QubitMappingJordanWigner(),
    step_number=1
)

# Create the computable for the quantity of interest, then build and run the algorithm.
ev = ExpectationValue(ansatz, QubitMappingJordanWigner().operator_map(ham))
# Initialize the algorithm, supplying a set of initial parameters for the HV ansatz
# here our optimization process only uses the total energy, not the gradients
vqe = AlgorithmVQE(
    objective_expression=ev,
    minimizer=MinimizerScipy(),
    initial_parameters=ansatz.state_symbols.construct_random(mu=0.0, sigma=0.2),
)
vqe.build(
    protocol_objective=SparseStatevectorProtocol(AerStateBackend()),
)
vqe.run()

print("Minimum Energy: {}".format(vqe.final_value))
# TIMER BLOCK-0 BEGINS AT 2026-06-18 13:46:14.438861
# TIMER BLOCK-0 ENDS - DURATION (s):  1.8317932 [0:00:01.831793]
Minimum Energy: -1.1368465754717607

The HVA variant HamiltonianVariationalAnsatzHubbard is dedicated for the Hubbard model problems. More details on the Hubabrd model can be found on the model Hamiltonians page. There is also a detailed tutorial on how to use HamiltonianVariationalAnsatzHubbard to solve a Hubbard model.