Skip to main content

View on GitHub

Open this notebook in GitHub to run it yourself
The Adaptive Derivative-Assembled Pseudo-Trotter Variational Quantum Eigensolver (ADAPT-VQE) [1] is a variational hybrid algorithm, which constitutes an extension of the Variational Quantum Eigensolver (VQE) framework [2], that constructs problem-specific ansätze in a systematic and adaptive manner. Instead of relying on a fixed, heuristic circuit structure, ADAPT-VQE iteratively grows the state ansatz by selecting operators from a predefined pool based on their energy gradients with respect to the current variational state. At each iteration, the operator that yields the largest energy reduction is appended to the circuit and its parameters are reoptimized. This adaptive procedure significantly reduces the number of variational parameters and circuit depth, making ADAPT-VQE particularly well suited for near-term quantum hardware. Importantly, the algorithm is heuristic, leading to an approximate solution with no proven convergence guarantees. The algorithm treats the following problem:
  • Input: System Hamiltonian HH, reference state ∣Ψref⟩| \Psi_{\text{ref}}\rangle and an operator pool of anti-Hermitian operators O={O1,…,OM}{\cal O} =\{O_1,\dots,O_M\}.
  • Output: Approximation of the ground state and energy of HH.
Complexity: The major overhead generally comes from the evaluation of the elements of the energy gradient by repeated measurements of different observables. We therefore focus on the measurement complexity of the algorithm. The complexity depends on the chosen operator pool and classical optimization scheme. The total cost incorporates the two main components of the algorithm, (i) evaluating the energy gradient, and (ii) re-optimization of the current state-ansatz (corresponds to the standard VQE optimization). As a result, at each iteration step the cost is a sum of two terms, corresponding to the two algorithm components:
Cost≈∑k=1K(M⋅CG(n)+Nopt(k)⋅CE(n))  ,\text{Cost}\approx \sum_{k = 1}^K (M \cdot C_G(n)+ N_{\text{opt}^{(k)}}\cdot C_E(n))~~, where nn is the number of qubits, KK is the total number of iterations, CG(n)C_G(n) is the measurement cost to estimate a single operator gradient, Nopt(k)N_{\text{opt}}^{(k)} is the number of optimizer steps at iteration kk, and CE(n)C_E(n) is the measurement cost to estimate the energy once.

Keywords: Variational quantum algorithm, Chemistry, Optimization

Overview

The following notebook begins with a theoretical explanation of the algorithm. We then consider an explicit example, consisting of a system of four qubits. The ADAPT-VQE algorithm is employed to evaluate the ground state energy and state. Following, we provide a modified version of the algorithm, and the results of both versions of the ADAPT-VQE algorithms are compared to the results obtained by the standard VQE algorithm. The notebook concludes with a short summary and analysis of the algorithm and results.

Algorithm Steps

The algorithm builds and constructs the ansatz iteratively, one operator at a time, including only the most significant operators. This approach builds a minimal, problem-specific ansatz, avoiding unnecessary parameters and allowing systematic improvement of the accuracy. Similarly to VQE, the algorithms essentially reduce the circuit depth at the expense of measurements. Initially, we define an operator pool O={O1,O2,⋯ ,OM}{\cal O}=\{O_1,O_2,\cdots,O_M\}, containing a collection of anti-Hermitian operators that are employed in the ansatz construction. We then follow the following procedure:
  1. Initialize the qubits to the reference state, ∣Ψref⟩| \Psi_{\text{ref}}\rangle, and define the initial iterative state as ∣ψ(0)⟩=∣Ψref⟩| \psi^{(0)}\rangle = | \Psi_{\text{ref}} \rangle.
  2. Prepare a trial quantum state with the current ansatz, denoted by ∣ψ(k)⟩|\psi^{(k)}\rangle, where k=0,1,…k=0,1,\dots corresponds to the iteration step number (initially set to zero).
  3. Measure the commutator of the Hamiltonian with the operators of O\cal{O}.
The expectation value corresponds to the partial derivative of the energy (in the kk iteration step) with respect to the coefficient of OjO_j: ∂E(k+1)∂θj∣θj=0=⟨ψ(k)∣∂θie−θiOjHeOjθj∣ψ(l)⟩∣θj=0+⟨ψ(k)∣e−θjOjH∂θjeOjθj∣ψ(k)⟩∣θj=0\frac{\partial E^{(k+1)}}{\partial \theta_j}\bigg |_{\theta_j=0} = \langle\psi^{(k)}|\partial_{\theta_i}e^{-\theta_i O_j} H e^{O_j \theta_j}|\psi^{(l)}\rangle {\bigg |}_{\theta_j = 0}+ \langle\psi^{(k)}|e^{-\theta_j O_j} H \partial_{\theta_j}e^{O_j \theta_j}|\psi^{(k)}\rangle {\bigg |}_{\theta_j = 0} =⟨ψ(k)∣[H,Oj]∣ψ(k)⟩ .= {{\langle \psi^{(k)}| [H, O_j] |\psi^{(k)}\rangle}}~. Hence, the measured commutation relations, provides the gradiant \nabla_\vec{\theta} E, where θ⃗={θ1,…,θk}T  .\vec{\theta} = \{\theta_1,\dots,\theta_k\}^T~~. 4. If the magnitude of the gradient vector is below a certain threshold, stop. Otherwise, identify the operator with the largest gradient, and add it to the left end of the ansatz, with a new variational parameter. If Ak∈{Oi}A_k\in \{O_i\} is an operator with the largest gradient on the step kk, the update rule is given by ∣ψ(k+1)⟩=eθkAk∣ψ(k)⟩  .|\psi^{(k+1)} \rangle = e^{\theta_k A_k} |\psi^{(k)}\rangle~~. Note, that the added operator still remains in the operator pool, therefore may be added again later on. 5. Conduct a VQE experiment to re-optimize all the ansatz parameters, {θ1,…,θk}\{\theta_1,\dots,\theta_k\}. 6. Go back to step 3 and take k→k+1k\rightarrow k+1. The final optimized ansatz is of the form ∣ψADAPT(θ⃗)⟩=Πn=1KeθkAk∣ψref⟩  ,| \psi^{\text{ADAPT}}(\vec{\theta}) \rangle = \Pi_{n=1}^{K} e^{\theta_k A_k}|\psi_{\text{ref}}\rangle~~, where KK is the total number of iterations. Note that when multiple quantum computers are available or sufficiently many qubits on a single computer, the preparation of the trial state and measurement of the commutation relations with the Hamiltonian can be performed in parallel, substantially reducing the runtime.

Implementation of ADPT-VQE with Classiq

We consider a simple example, consisting of a four-qubit system. The Hamiltonian and operator pool are defined in terms of the SparsePauliOp data structure, allowing for rapid and efficient algebraic computations. For implementation convenience, we consider an operator pool of Hermitian operators (instead of anti-Hermitian as in the theoretical derivation). In this case, the ansatz stat is of the form ∣ψADAPT(θ⃗)⟩=Πk=1Ke−iθkAk∣ψref⟩  ,| \psi^{\text{ADAPT}}(\vec{\theta}) \rangle = \Pi_{k=1}^{K} e^{-i\theta_k A_k}|\psi_{\text{ref}}\rangle~~, leading to the relation ∂E(k+1)∂θj∣θj=0=−i⟨ψ(k)∣[H,Oj]∣ψ(k)⟩  .\frac{\partial E^{(k+1)}}{\partial \theta_j}\bigg |_{\theta_j=0} = -i{{\langle \psi^{(k)}| [H, O_j] |\psi^{(k)}\rangle}}~~. We begin by uploading software packages and utility functions
Next, we define the grad_operator function, which receives an operator, op, and Hamiltonian, hamiltonian, as SparsePauliOps, and returns the observable −i[H,Oj]-i[H,O_j], whose expectation value is the partial derivative ∇θ⃗Ej=−i⟨ψ(k)∣[H,Oj]∣ψ(k)⟩\nabla_{\vec{\theta}} E_j=-i\langle\psi^{(k)}|[H,O_j] |\psi^{(k)}\rangle. The commutator is computed with Classiq’s built-in commutator function. Since ExecutionSession.observe accepts a list of observables and estimates all of them in a single execution job, the operators for every element of the operator pool are built up front, and all the resulting gradients are estimated together in one observe call.

Defining the Example System and Operator Pool

Output:

Main Program

Before defining the ADAPT-VQE main function, we first define the adapt_vqe_ansatz function, which prepares the product state of phases, ∣ψADAPT(θ⃗))⟩=Πn=1Ke−iθkAk∣ψref⟩|\psi^{\text{ADAPT}}(\vec{\theta})) \rangle = \Pi_{n=1}^{K} e^{-i\theta_k A_k}|\psi_{\text{ref}}\rangle, defined by the optimization parameters, thetas, and the associated operators of the operator pool, O\cal O. The function builds the state, phase by phase, utilizing a helper function adapt_layer. The reference state is taken to be ∣ψref⟩=∣0n⟩  ,|\psi_{\text{ref}}\rangle=|0^n \rangle~~, where n=4n=4 is the number of qubits.
In order to obtain accurate evaluations of the observables and obtain deterministic results, we execute the quantum program on a state vector simulator.
Following the algorithm steps, the main ADAPT-VQE performs an iterative calculation, each time adding another phase to the ansatz, thereby increasing the ansatz length, k, (starting from k=1k=1) until the gradient converges and satisfies ∣∇E∣/k<|\nabla E|/k <tol. If the procedure does not converge, we limit the number of iterations by MAX_ITERATIONS. Each iteration begins with a preparation of the ansatz state Πk=1Ke−iθkAk∣ψref⟩\Pi_{k=1}^{K} e^{-i\theta_k A_k}|\psi_{\text{ref}}\rangle for the current KK. The state preparation is performed by the first main quantum function, the quantum circuit is synthesized, and the optimization parameters are optimized by the es execution call and saved as a Python list in params. The params parameters, along with the operators represented by the associated operator indices stored in the ansatz_ops, completely define the ansatz state. Finally, the elements of the gradient, ∇θ⃗E\nabla_{\vec{\theta}}E, are evaluated by the execution call using the grad_energy function. A convergence check is made; if the ansatz state converged or the number of iterations exceeds the limit, the iterative procedure is terminated; otherwise, the iteration cycle continues.
Output:

Results and Discussion

Optimized ansatz summary
Output:

Energy Graph

output

Convergence Graph

output

Circuit Information

The circuit width and depth are:
Output:

Summary ADAPT-VQE Ansatz

For the chosen operator pool and classical optimization algorithm, the optimal ansatz state has 1010 parameters converged to a result Emin=−0.707848681231239E_{\text{min}}= -0.707848681231239 The ansatz operators, indexed by their associated index in the operator pool: [6,6,39,20,45,6,50,6,50,6][6,6,39,20,45,6,50,6,50,6]. The optimization parameters are: θ⃗=[0.5848,0.4323,1.5439,−0.0094,0.8553,0.5134,1.7361,0.6801,0.7741,0.9886]T  ,\vec{\theta} = [0.5848, 0.4323, 1.5439, -0.0094, 0.8553, 0.5134, 1.7361, 0.6801, 0.7741, 0.9886]^T~~, The ansatz state can be constructed with a quantum circuit with a circuit width of 44 and circuit depth of 44.

Modified ADAPT-VQE Ansatz

We provide a modified version of the algorithm, where the algorithm starts with a pre-optimization with respect to a chosen operator. The algorithm showed improved results for the considered Hamiltonian and operator pool.
Output:

Results and Discussion

Ansatz state summary
Output:

Energy Graph

output

Convergence Graph

output

Circuit Information

The circuit width and depth are:
Output:

Summary Modified ADAPT-VQE Ansatz

For the chosen operator pool and classical optimization algorithm, the optimal ansatz state has 77 parameters converged to a result Emin=−1.1804771E_{\text{min}}=-1.1804771 The ansatz operators, indexed by their associated index in the operator pool: [2,4,50,42,45,39,21][2,4,50,42,45,39,21]. The optimization parameters are: θ⃗=[1.5757,1.8084,0.7077,0.5244,−0.1062,−0.1099,1.5939]T  ,\vec{\theta} = [1.5757, 1.8084, 0.7077, 0.5244, -0.1062, -0.1099, 1.5939]^T~~, The ansatz state can be constructed with a quantum circuit with a circuit width of 44 and circuit depth of 1919.

Comparison to the VQE Algorithm

We now validate the results of the ADAPT-VQE by comparing them to the outcome of the standard VQE algorithm with ten optimization parameters (K=10K=10), and picking the operator pool as the first ten even indices (the choice is arbitrary and independent of the Hamiltonian). We fix the ansatz state by considering a product form of phases, ∣ψVQE⟩=Πk=1Ke−iθkOk∣0n⟩  ,|\psi_{\text{VQE}}\rangle = \Pi_{k=1}^{K} e^{-i \theta_k O_k}|0^n\rangle~~, where n=4n=4, for the presented test case. The operators {Ok}\{O_k\} are determined by their operator pool indices in vqe_ansatz_ops_indicies and the associated parameters {θk}\{\theta_k\} are optimized by applying the VQE algorithm.
Output:

Circuit Information

Output:

Summary VQE Ansatz

The VQE ansatz is characterized by: Optimized optimization parameters: θ⃗=[1.536,−0.564,1.271,0.144,1.94,1.511,−0.215,−0.062,−0.391,0.855]T\vec{\theta} = [1.536, -0.564, 1.271, 0.144, 1.94, 1.511, -0.215, -0.062, -0.391, 0.855]^T The ansatz operators are originally set (an arbitrary choice): [0,2,4,6,8,10,12,14,16,18][0,2,4,6,8,10,12,14,16,18]. and minimal energy ⟨ψVQE∣H∣ψVQE⟩\langle\psi^{\text{VQE}}|H |\psi^{\text{VQE}}\rangle: −0.96816-0.96816. The ansatz state can be constructed with a quantum circuit with a circuit width of 44 and circuit depth of 2626.

Analysis and Summary

By comparing the results obtained with ADAPT-VQE, modified ADAPT-VQE and standard VQE, and exact diagonalization, we observe that for an equal number of variational parameters, modified ADAPT-VQE converges to an ansatz that yields a more accurate estimate of the ground-state energy, Eg.s=−1.189380715792109E_{\text{g.s}}= -1.189380715792109. Specifically, modified ADAPT-VQE achieves an energy within approximately  0.7~0.7% of the exact value. In contrast, the original ADAPT-VQE achieves a minimal energy which is 4040% above the true ground state energy. The VQE ansatz - whose operator structure is chosen independently of the Hamiltonian - converges to an optimal energy that remains 18.618.6% above the true ground-state energy. The result highlights the potential of an ADAPT-VQE type ansatz, which is constructed iteratively based on the energy gradient, that is directly determined by the Hamiltonian under consideration. As a consequence, only operators that most effectively lower the energy are included in the ansatz, leading to faster and more accurate convergence. The ADAPT-VQE achieves a better accuracy, with a smaller circuit depth (44 and 1919 compared to 2626 for the VQE). This contrasts with a general, Hamiltonian-independent ansatz, which lacks such targeted optimization and therefore exhibits inferior convergence performance and tends to require larger circuit depths to achieve the same accuracy. Importantly, the large difference between the two variations of ADAPT-VQE proposed showcases that the algorithm doesn’t guarantee better results. A clever choice of the operator pool and the initial state can potentially greatly improve the algorithm’s performance.

References

[1]: Grimsley, H. R., Economou, S. E., Barnes, E., & Mayhall, N. J. (2019). An adaptive variational algorithm for exact molecular simulations on a quantum computer. Nature communications, 10(1), 3007. [2]: Tilly, J., Chen, H., Cao, S., Picozzi, D., Setia, K., Li, Y., … & Tennyson, J. (2022). The variational quantum eigensolver: a review of methods and best practices. Physics Reports, 986, 1-128.