AWS Quantum Technologies Blog

Towards practical molecular electronic structure simulations on NISQ devices with Amazon Braket and Kvantify’s FAST-VQE algorithm

This post was contributed by Patrick Ettenhuber, Marco Majland, Stig Elkjær Rasmussen, and Casper Kirkegaard from Kvantify and Katharine Hyatt and Perminder Singh from AWS

One of the most exciting aspects of quantum computing is the prospect of performing chemistry calculations that surpass the capabilities of classical computers. Even though significant progress has been made in both hardware and algorithm design, practical application of quantum computers in chemistry has still been limited to simulations of the simplest possible molecules. For example, current state-of-the-art algorithms achieve accuracies that are far from what can be achieved experimentally, known as chemical precision.

In this post we demonstrate how Kvantify’s fermionic adaptive sampling theory for variational quantum eigensolvers (FAST-VQE) resolves fundamental scaling issues in constructing effective quantum circuits for electronic structure calculations.

FAST-VQE is particularly well-suited to today’s noisy intermediate scale (NISQ)-era quantum devices due to its reliable performance in the presence of noise. Amazon Braket provides customers access to a variety of quantum computers from trapped-ion, superconducting, and neutral-atom systems. By combining the FAST-VQE algorithm with Amazon Braket, we show how our approach allows for high-accuracy routine simulation of small molecules on real quantum computers.

Quantum algorithm background

The variational quantum eigensolver (VQE) is a quantum computing algorithm used to find approximate solutions to the eigenvalue problem, particularly in quantum chemistry and materials science. It is designed to calculate the ground state energy of a quantum system, which is valuable for understanding molecular structures and properties. Using the variational method, the ground state energy is estimated using a parameterized trial wave function analysis generated on quantum hardware [1].

Recent developments have demonstrated that by constructing wave functions in a stepwise manner, the circuit depth for a highly accurate encoding can be minimized. The reduction in circuit depth is important in making practical use of noisy intermediate-scale quantum (NISQ) devices for chemical systems, and our work builds upon this result.  This adaptive approach was developed by Grimsley et al. [2] in their pioneering work on the adaptive derivative-assembled pseudo-Trotter ansatz variational quantum eigensolver (ADAPT-VQE).

An adaptive VQE algorithm performs the following steps:

  1. An initial Hartree Fock (HF) wave function is expressed as a quantum circuit, which we consider the wave function ansatz.
  2. Using a selection rule, an operator from the operator pool is added to the ansatz.
  3. The updated ansatz is trained to optimize the energy of the system.
  4. Steps 2 and 3 are repeated until a convergence criterion is met.
  5. The final energy is determined from the final optimized circuit.

Figure 1 shows an overview of the adaptive VQE algorithm.

Figure 1 – Overview of an adaptive VQE algorithm. An initial wave function ansatz is created from an HF calculation and is then updated iteratively by adding operators using some selection rule. In each iterative step, the energy is optimized, which results in an ansatz that approximates the energy of the underlying system.

Figure 1 – Overview of an adaptive VQE algorithm. An initial wave function ansatz is created from an HF calculation and is then updated iteratively by adding operators using some selection rule. In each iterative step, the energy is optimized, which results in an ansatz that approximates the energy of the underlying system.

However, this algorithm suffers from a fundamental scaling problem. For a pool containing double excitation operators [3], the number of measurements per iterative step of the ADAPT-VQE algorithm scales at least as N6, where N describes the size of the molecule, severely reducing its practical applicability. Kvantify’s newly developed alternative FAST-VQE [4] overcomes these measurement issues, by utilizing intermediate measurements to guide the construction of the wave function ansatz. This leads to constant scaling in terms of time and cost. An often-overlooked point is that a higher cost is typically associated with switching the circuit, than with recording more samples of the same circuit. FAST-VQE resolves this issue by sampling the ansatz once each time the ansatz is adapted. This provides constant cost for each iteration and reliable performance due to strong resilience towards shot noise. The selection of operators in FAST-VQE is performed by evaluating a heuristic importance metric from a sample of the population of Slater determinants in the current wave function. Even though this metric is a heuristic, it has been observed that it works well, even for complicated electronic structures. And its performance and theoretical foundation are on-par with the commonly used approximate gradient metric.

While our algorithm resolves the main optimization related bottlenecks of adaptive VQE-based algorithms, it is important to note that we have not optimized computation of the energy itself. In this isolated part of the problem, scaling issues still remain, so to keep costs down we are offloading this calculation to a simulator while solving the main part of the problem on real quantum computers.

In summary, FAST-VQE resolves fundamental scaling issues in obtaining the data required for operator selection in the iterative ansatz-building process of VQE algorithms. It presents itself as an adept and practical algorithm for NISQ devices, delivering dependable performance and cost-effectiveness for electronic structure calculations. Table 1 compares the computational complexity of running FAST-VQE to other adaptive VQE algorithms. It is important to realize that FAST-VQE operates in a different manner from ADAPT-VQE as it offloads the task of operator selection to the classical computation using data obtained from the quantum device. The estimates solely encompass the complexity of operator selection in each step, namely step 2 of the adaptive algorithm, without factoring in the energy optimization in step 3. The energy optimization still scales at least as N2 and is therefore the new bottleneck in adaptive VQE algorithms. Currently, we solve this part of the problem on an embedded simulator available on Amazon Braket, where the simulator is co-located in the same classical processor containing the algorithm dramatically delivering improved performance. Table 1 –. In the ADAPT cases, the number of operator evaluations is equal to the number of single and double excitation evolution operators, which scales as N4, whereas FAST allows evaluating all operators at once. For ADAPT, we need to measure each Pauli term for each operator, with the improved version providing better scaling due to operator grouping. Again, FAST allows measuring all operators in one task.

Table 1: the computational complexity of running FAST-VQE to other adaptive VQE algorithms

Table 1: the computational complexity of running FAST-VQE to other adaptive VQE algorithms

Practical quantum computing infrastructure

Quantum hardware is developing at a very rapid pace, with the current focus on advances in noise reduction and qubit scaling. It is still unclear which technology will come out as the winner and the architecture of existing platforms is also very far from being standardized. This means keeping up with the latest changes across a range of rapidly evolving hardware providers can be both time-consuming and relationally challenging. This is part of the reason we use Amazon Braket as our quantum computing provider. The ability to run quantum programs on all types of quantum computing hardware on-demand makes it very easy for our developers to focus on general algorithm development rather than device-specific details. Amazon Braket Hybrid Jobs is one of our particular favorites and our preferred way to run hybrid quantum algorithms such as VQE.

Amazon Braket Hybrid Jobs offers us several advantages. First of all, it simplifies the set-up and management of our compute environment. Amazon Braket takes care of spinning up classical compute resources, running the workload in container environments, and returning the results to Amazon Simple Storage Service (Amazon S3). Second, Amazon Braket Hybrid Jobs provides real-time insights and customizable algorithm metrics. We can track the progress of our jobs through on-the-fly insights and receive near real-time metrics delivered to Amazon CloudWatch and the Amazon Braket console. Amazon Braket Hybrid Jobs offers improved performance compared to running hybrid algorithms from our local environment. Hybrid jobs receive priority access to the selected target QPU, resulting in shorter and more predictable runtimes. Amazon Braket also now supports parametric compilation, the ability to compile a circuit one and reuse the cached compiled output for subsequent iterations, yielding up to 10X faster performance on superconducting QPUs from Rigetti.

An overview of Amazon Braket hybrid Jobs can be seen in Figure 2:

Figure 2 – Overview of Amazon Braket Hybrid Jobs. Running our hybrid algorithms this way allows for tracking job progress on-the-fly using Amazon CloudWatch and data collection in Amazon S3.Amazon Braket takes care of spinning up the right amount of classical/quantum resources at the right time, so you only pay for what you use.

Figure 2 – Overview of Amazon Braket Hybrid Jobs. Running our hybrid algorithms this way allows for tracking job progress on-the-fly using Amazon CloudWatch and data collection in Amazon S3.Amazon Braket takes care of spinning up the right amount of classical/quantum resources at the right time, so you only pay for what you use.

Benchmarking FAST-VQE on Amazon Braket

Kvantify’s implementation of FAST-VQE is made in Python and starts from a Hartree-Fock calculation. The energy calculation is separated from the rest of the implementation so it can be offloaded to a simulator rather than run on the quantum device. Benchmarks are performed from inside Docker containers running as hybrid jobs, using the bring your own container (BYOC) feature. Benchmark calculations were run in three different modes: noiseless state vector simulation, noisy density matrix simulation, and a NISQ device. We simulate two different molecules, H4 and LiH, in an STO-3G basis set without selecting an active space. As actual quantum devices, we use Rigetti’s 79-qubit Aspen-M-3 and IonQ’s 11-qubit Harmony (the latter only for the H4 case). In the case of H4, 25 iterations were sufficient to reach machine (single-) precision, while LiH requires 50 iterations to achieve sub-chemical precision. An empirically determined value of 1000 shots was used in all calculations, including the simulations. In both cases, 10 repetitions were needed to obtain reasonable statistics. This implies that the H4 calculation costs approximately 25 iterations times 10 repetitions which equals a total of 250 quantum tasks, while the number of quantum tasks for LiH was 500 since 50 iterations were used. Amazon Braket Hybrid Jobs are priced based on the number of quantum tasks and shots submitted to the respective quantum processor and the cost of the classical co-processor. Refer to the Braket pricing page for up-to-date information on pricing for different QPUs available on Amazon Braket.

The results of our benchmarks are shown in Figure 3. It shows the energy error as compared to a full configuration interaction (FCI) calculation in the same space, as a function of the number of CNOTs in the ansatz. Red lines show results for ADAPT-VQE on a noiseless state vector evolution, serving as a benchmark. Note how this curve only dips slightly below the dashed chemical precision line within the range of the left-hand H4 figure, and how it never reaches chemical precision in the right-hand side LiH result. In both cases, FAST-VQE achieves chemical precision within 150 CNOTs and continues to improve by orders of magnitude thereafter. It is also worth noting how the noisy FAST-VQE results outperform the noiseless simulation. This is quite surprising since noise has been shown to have a negative effect on the accuracy of ADAPT-VQE [5]. However, throughout our experiments, we have found FAST-VQE to be very robust with respect to noise. We are still investigating this behavior and how it can be utilized going forward.

Figure 3 -- Comparison of energy errors for VQE variants on H4 and LiH, using a STO-3G basis set on simulators and quantum devices. The operator selection part of FAST-VQE is run as a finite shot state vector evolution simulation, a density matrix simulation, Rigetti’s Aspen-M-3 and IonQ’s Harmony (the latter only for H4). The density matrix simulation includes realistic noise. For comparison, a finite shot state vector simulation is also shown for ADAPT-VQE. For all calculations the energy optimization was done as a state vector simulation without noise. All plots include 95% confidence intervals. Note how ADAPT-VQE does not converge to chemical accuracy within the range of figure, while all cases of the FAST-VQE converge at around 150 CNOT. In the case of H4, this is equivalent to 15 adaptive iterations. For LiH, all cases of FAST-VQE converge within 100 CNOTs equivalent to less than 15 adaptive iterations.

Figure 3 — Comparison of energy errors for VQE variants on H4 and LiH, using a STO-3G basis set on simulators and quantum devices. The operator selection part of FAST-VQE is run as a finite shot state vector evolution simulation, a density matrix simulation, Rigetti’s Aspen-M-3 and IonQ’s Harmony (the latter only for H4). The density matrix simulation includes realistic noise. For comparison, a finite shot state vector simulation is also shown for ADAPT-VQE. For all calculations the energy optimization was done as a state vector simulation without noise. All plots include 95% confidence intervals. Note how ADAPT-VQE does not converge to chemical accuracy within the range of figure, while all cases of the FAST-VQE converge at around 150 CNOT. In the case of H4, this is equivalent to 15 adaptive iterations. For LiH, all cases of FAST-VQE converge within 100 CNOTs equivalent to less than 15 adaptive iterations.

Conclusion

By combining the quantum-classical hybrid algorithm FAST-VQE with Amazon Braket Hybrid Jobs, we have demonstrated the feasibility of conducting practical and accurate electronic structure computations on current NISQ devices. FAST-VQE fixes the problem of operator selection in adaptive VQE algorithms, which is believed to be the main bottleneck of adaptive VQE. However, other bottlenecks exist, primarily regarding energy optimization which is still an outstanding problem. In future work, we will evaluate FAST-VQE for larger systems to further benchmark its performance.

Our results enhance chemical precision efficiently while requiring fewer resources. Additionally, our theoretical findings demonstrate how the algorithm can scale to molecular sizes that were previously considered difficult to attain [6]. FAST-VQE takes an important step towards practical applications of noisy quantum computers in chemistry and drug-discovery. To learn more about how to leverage Amazon Braket to run quantum-classical algorithms suited to your use case, refer to our documentation. Finally, you can now turn your Python functions into Hybrid Jobs directly from your Jupyter notebook with only one line of code using our new remote decorators feature.

For more information on our quantum-ready solutions, please do not hesitate to reach out at contact@kvantify.dk. Researchers interested in exploring running quantum algorithms on Amazon Braket should refer to our AWS Cloud Credits for Research program.

The content and opinions in this blog are those of the third-party author and AWS is not responsible for the content or accuracy of this blog.

References

[1] “A variational eigenvalue solver on a photonic quantum processor”, https://www.nature.com/articles/ncomms5213 (2014)

[2] “An adaptive variational algorithm for exact molecular simulations on a quantum computer”, https://www.nature.com/articles/s41467-019-10988-2 (2019)

[3] “How to really measure operator gradients in ADAPT-VQE“, https://arxiv.org/abs/2306.03227 (2023)

[4] “Fermionic Adaptive Sampling Theory for Variational Quantum Eigensolvers”, https://arxiv.org/abs/2303.07417 (2023)

[5] “Quantum Embedding Method for the Simulation of Strongly Correlated Systems on Quantum Computers”, https://pubs.acs.org/doi/10.1021/acs.jpclett.3c00330 (2023)

[6] “Connecting Ansatz Expressibility to Gradient Magnitudes and Barren Plateaus”, https://journals.aps.org/prxquantum/abstract/10.1103/PRXQuantum.3.010313 (2022)