Introduction

Quantum computers have found great success in electronic structure theory through the variational quantum eigensolver1 and subsequent algorithms known as variational quantum algorithms (VQA)2. Considering the full nuclear dynamics, the problem becomes unmanageable much faster, potentially even for quantum computers3. One way to reconcile this is to partition the system into interacting quantum and classical parts. This is the realm of mixed quantum-classical (MQC) approaches, which are a widely used set of tools for understanding chemical systems4,5. In quantum computing, this area is less researched than the electronic structure problem, but it is actively being explored3,6,7. In this work we propose and explore a noisy intermediate-scale quantum (NISQ) friendly algorithm that can be used to study MQC dynamics.

Using quantum computers alongside classical computers is the backbone of VQAs, but splitting a system into sections treated separately by each machine is not new. An example of this is the density functional theory (DFT) embedding scheme with a quantum computer expansion of the active space8 and has been found to outperform certain types of state-of-the-art approximate techniques such as complete active space self-consistent field (CASSCF)9 in finding ground state energies. Furthermore, ground state dynamics, geometry relaxation, and force measurements for molecular dynamics applications have been explored with success7,10,11. Ollitraut et al.3 explored dynamics in both first and second quantization, but using a time-independent Hamiltonian. This is also the case for various other time propagation techniques12,13,14; we draw inspiration from and use projected variational quantum dynamics (p-VQD)13 in this work.

Our contribution is the presentation of a general algorithmic structure to tackle non-adiabatic molecular dynamics (NAMD) by offloading the quantum mechanical (QM) part to a quantum computer and evolving the classical system by the Ehrenfest method. Observables from the QM subsystem are measured and used to update the classical system, which in turn will update the time-dependent Hamiltonian that is used to evolve the QM state in turn. The electronic subsystem is treated in first quantization on a local diabatic basis. The latter saves the algorithm from needing to measure nonadiabatic couplings, as these are treated directly within the wave function and its evolution. The algorithm is demonstrated in the Shin-Metiu model15, which is often used to test non-adiabatic techniques16,17,18,19. We consider the model by partitioning it into a classical nucleus and a quantum electron. Under this framework, the major contribution is establishing how the measurement of observables in the quantum computer affects the update of the classical and quantum states of the system, as well as introducing a general scheme that is suited for the exploration of other time-dependent phenomena under a mixed quantum-classical paradigm on NISQ machines.

The theoretical advantage of using quantum computers relies on the fact that they have access to an exponentially growing computational space for each additional qubit20. Current machines consist of hundreds of qubits, which would ideally allow them to already outperform current supercomputers. This is not the case due to noise arising from interactions with the environment and imperfect gate implementations. As such, NISQ algorithms21 have to contend with limits on the number of imperfect operations that can be made. But even if this were not the case and full quantum dynamics could be simulated for larger systems than currently possible, we may still want to tackle even bigger problems, so MQC approximations on quantum computers retain their raison d’être.

Finally, it should be noted that existing supercomputers by far outperform existing quantum computers in handling large quantum-chemistry problems, and applications to hitherto unsolvable chemical systems will have to be deferred until there is a provable quantum advantage in this application domain. Approximations like limiting the simulation to a selected active space8 can extend the reach of quantum computers, but analogs of these ideas apply to classical computers as well. For now, quantum algorithms in chemistry mostly study systems that are comfortably computable on current classical hardware, although this state of affairs may change in the future.

Results

Time-dependent Hamiltonian variational quantum propagation

The time-dependent variational quantum propagation (TDVQP) algorithm builds on the circuit compression idea of (p-VQD)13 by allowing the Hamiltonian to be time-dependent. For many large problems of interest in theoretical chemistry, especially in dynamics applications, it is impossible to simulate the system of interest fully quantum mechanically. A common strategy is to subdivide the system into classical and quantum components. The evolution of both subsystems occurs in locked steps, with the classical subsystem defining the Hamiltonian for the quantum evolution, and the quantum subsystem then feeding back into the classical component in the way of some observable, usually the energy gradient (force).

The algorithm begins with a parameterized circuit initialized to some desired state. This is denoted as \(\left\vert {\psi }_{0}\right\rangle\), which will have been generated according to a Hamiltonian based on an initial vector of classical parameters \({\overrightarrow{q}}_{0}\) of the classical coordinates, which we denote \(H({\overrightarrow{q}}_{0}):= {H}_{0}\). This is done by choosing some sufficiently expressive parameterized circuit ansatz \(\hat{C}(\overrightarrow{\theta })\) which takes the quantum register of the quantum computer from its initial state \(\left\vert 0\right\rangle\) to \(\left\vert {\psi }_{0}\right\rangle\). This can be done using a VQA to find a chosen state with respect to H0, which returns the circuit parameters \({\overrightarrow{\theta }}_{0}\). Then \(\left\vert {\psi }_{0}\right\rangle =\hat{C}({\overrightarrow{\theta }}_{0})\left\vert 0\right\rangle\). A chosen set of observables \(\{\hat{{O}^{(s)}}({q}_{0})\}:= \{{\hat{{O}^{(s)}}}_{0}\}\) are measured from \(\left\vert {\psi }_{0}\right\rangle\), which yield a set of expectation values \(\{{O}_{0}^{(s)}\}\). These observables are used to evolve the classical state of the system, generating a new vector of classical parameters \({\overrightarrow{q}}_{1}\). Now, one evolves the state from \(\left\vert {\psi }_{0}\right\rangle\) to \(\left\vert {\psi }_{1}\right\rangle\) by applying the time evolution operator to the state, \(\left\vert {\psi }_{1}\right\rangle =\exp (-i{\hat{H}}_{0}\Delta t)\left\vert {\psi }_{0}\right\rangle\). Thereafter one can generate H1 and measure \(\{{\hat{{O}^{(s)}}}_{1}\}\), which provides the necessary information for the next classical step. In a physical implementation, measuring the observables destroys the wavefunction, so this has to be done after the parameters defining the wavefunction at the current step, \(\left\vert {\psi }_{1}\right\rangle \approx \hat{C}({\theta }_{1})\left\vert 0\right\rangle\), have been found with a single step of the p-VQD algorithm to some desired threshold. This process is repeated until the desired timestep is reached. The entire process is described in Algorithm 1, and a depiction of the quantum circuit can be seen in Fig. 1. The overall number of circuit evaluations is linear with respect to the number of iterations, circuit parameters, timesteps and Pauli terms of the observables. This is treated in greater depth in Supplementary Note 1. The physical implementation of the quantum time evolution can either be the Trotterized form of the operator or some other approximate time evolution. In this work, we simply use \({\hat{H}}_{0}\) to evolve the quantum state with a first-order Trotter expansion. The Hamiltonian used for the time evolution could be of higher order. For example, \(({\hat{H}}_{0}+{\hat{H}}_{1})/2\) can be used with no extra cost in this scheme, but higher-order integrators will require an additional evolution and observable measurement for each timestep beyond H1.

Fig. 1: Sketch of the Time Dependent Variational Quantum Propagation process.
figure 1

Circuit diagram with slices showing the state after each gate. The initial guess for the parameter vector \({\theta }_{i}^{{\prime} }\) is θi and its final value is denoted θi+1. Then observables \(\hat{O}\) can be measured on \(\left\vert {\psi }_{i+1}\right\rangle\) to update the Hamiltonian or the classical state of the system.

TDVQP should be thought of as a meta-algorithm that has replaceable components. The most directly replaceable part is the choice of ansatz \(\hat{C}(\overrightarrow{\theta })\). At the moment, one uses some heuristic choice for most problems in NISQ devices. More advanced choices, such as the family of adaptive ansatze have been shown to work in this scheme22. The time evolution is currently performed via a Trotterized form of the time evolution operator, as in p-VQD13,14. Alternatives exist in the form of more NISQ-friendly time evolutions as is done in several works23,24. The theoretical limiting factor for \(\hat{C}(\overrightarrow{\theta })\) is the no-fast forwarding theorem25,26,27, which states that one cannot achieve a time evolution of time t in a sublinear gate count for a general Hamiltonian. For shorter-time evolutions, limited system sizes, and specific Hamiltonians, including our sparse Hamiltonian, this theorem is likely not to apply strictly24.

In the classical evolution, the choice of integrator and the actual Hamiltonian used in the time evolution will depend on the type of problem and desired accuracy. Integrators like the Velocity Verlet algorithm require no additional resources. TDVQP becomes exact when \(\hat{C}(\overrightarrow{\theta })\) can express the system perfectly for any configuration of classical parameters \(\overrightarrow{q}\), given that the exact parameters \(\overrightarrow{\theta }\) can be found by optimization. Finding more efficient \(\hat{C}(\overrightarrow{\theta })\) ansatze, VQA, and shot-efficient optimizers is at the forefront of dedicated research in this area2, and it is out of scope for this work.

Error propagation in TDVQP

The TDVQP algorithm inherits the inaccuracies of its constituent parts. This includes the chosen circuit compression algorithm, time evolution approximation, and the classical propagator. This section illustrates the sources of error in the wavefunction and observables, and their interdependence in the velocity-Verlet integrator. A more thorough derivation and discussion can be found in Supplementary Note 2.

When running the algorithm, any coherent error on the wavefunction representation in the quantum computer \(\left\vert \tilde{\psi }\right\rangle\) can be represented as a superposition of the desired state \(\left\vert \psi \right\rangle\) and some combination of undesired orthogonal states \(\left\vert \phi \right\rangle\), such that \(\left\vert \tilde{\psi }\right\rangle =\sqrt{1-{I}^{2}}\left\vert \psi \right\rangle +I\left\vert \phi \right\rangle\), where I is the infidelity. When measuring the expectation value of a Hermitian observable \({{{{{{{\mathcal{O}}}}}}}}\) on \(\left\vert \tilde{\psi }\right\rangle\) one thus gets

$$\left\langle \tilde{\psi }\right\vert {{{{{{{\mathcal{O}}}}}}}}\left\vert \tilde{\psi }\right\rangle =\left(1-{I}^{2}\right)\left\langle \psi \right\vert {{{{{{{\mathcal{O}}}}}}}}\left\vert \psi \right\rangle +{I}^{2}\left\langle \phi \right\vert {{{{{{{\mathcal{O}}}}}}}}\left\vert \phi \right\rangle .$$
(1)

How this translates into the actual measured observable is system-dependent. This will lead to an error in the observable, which in the case of the velocity-Verlet integrator with a force error FiϵI2 in 1 dimension will give a new position \({\tilde{R}}_{i}\) of

$${\tilde{R}}_{i}={R}_{i}+\frac{{F}_{i\epsilon }}{M}\Delta {t}^{2}$$
(2)

shifted from the expected true position Ri. This is linear in the error of the force and quadratic with respect to the timestep Δt. The following time evolution Hamiltonian and observable operator will be based on this position with an error, which is again, system dependent. The effect is illustrated by the equations

$$\left\vert \tilde{{\psi }_{1}}\right\rangle =\exp (-i{H}_{el}({R}_{0})\Delta t)\left\vert \tilde{{\psi }_{0}}\right\rangle ,$$
(3)
$$\left\vert \tilde{{\psi }_{i}}\right\rangle =\exp (-i{H}_{el}({\tilde{R}}_{i-1})\Delta t)\left\vert \tilde{{\psi }_{i-1}}\right\rangle .$$
(4)

Even in the one-dimensional model used in this work, this effect is not analytically computable, but it is small if the timesteps are sufficiently small. This then enters the velocity \((\dot{R})\) update as

$${\tilde{\dot{R}}}_{i+1}={\dot{R}}_{(i+1)}+\frac{{F}_{i\epsilon }+{F}_{(i+1)\epsilon }}{2M}\Delta t,$$
(5)

which is linear in the error and timestep. Assuming for simplicity a constant error over all times of Fϵ, that is to say, that the force deviates from the correct one by a constant offset, this has the overall effect on the position at iteration i of

$${\tilde{R}}_{i}={R}_{i}+{\dot{R}}_{i-1}\Delta t+\frac{({i}^{2}+i){F}_{\epsilon }}{2M}\Delta {t}^{2}.$$
(6)

This expression is quadratic in i and quadratic in timestep. The effect on the fidelity of the TDVQP wavefunction compared to an exact propagation is nontrivial, but numerical examples are provided in Supplementary Note 2.

The other source of error inherent to the p-VQD algorithm is that the optimizer does not converge to a perfect representation of the time-evolved wavefunction, but rather to an approximation that meets some fidelity threshold T < 1. If at least this threshold is met at each p-VQD step, assuming all observable measurements are unaffected, then the decrease in the fidelity is modeled by

$$\,{{\mbox{Fidelity(i)}}}\,={T}^{i}.$$
(7)

When the algorithm is run under limited quantum resources and thus subject to finite sampling noise, both the observable and p-VQD step fidelity measurements will have some Gaussian distribution, which will feed into the errors above on a simulation-by-simulation basis. The effect of this has been analyzed numerically in the case of our modified Shin-Metiu Model.

The Shin Metiu model

The Shin-Metiu model is a numerically exactly solvable minimal model which captures essential nonadiabatic effects15. It is often used as a benchmark system for new techniques and physical effects, for example in polaritonic dynamics, and to study the effect of electromagnetic fields from first principles16,17,18,28. Its parameters can be chosen to exhibit adiabatic to strongly non-adiabatic dynamics.

In its simplest and original conception, the model shown in Fig. 2a consists of two stationary ions separated by a distance of L, specifically located at \(\frac{L}{2}\) and \(\frac{-L}{2}\). These enclose a mobile ion p of mass M at distance R from the origin and an electron e at distance r. The modified Coulomb potential is parameterized by the constants Rl, Rr  and Rf, as shown in Eq. (8). This avoids singularities and renders the system numerically stable to simulate.

Fig. 2: The Shin-Metiu Model.
figure 2

a Fixed ions at \(\frac{-L}{2},\,\frac{L}{2}\) as stationary boundaries, the mobile ion p with mass M at distance R from the origin and the electron e at distance r from the origin. Rl, Rr and Rf are constants for the regularized Coulomb potential in Eq. (8). b Potential Energy Surfaces for the coefficients Rf = 5.0 a.u.,  Rl = 4.0 a.u. and Rr = 3.2 a.u. showing the avoided crossing around position R = − 1.9 a.u. with L = 19 a.u..

The Hamiltonian of the system reads

$$H=-\frac{1}{2M}\frac{\partial }{\partial {R}^{2}}+{H}_{e}(r,R),$$

with the electronic part being

$${H}_{e} =-\frac{1}{2m}\frac{{\partial }^{2}}{\partial {r}^{2}}+\frac{1}{\left\vert \frac{L}{2}-R\right\vert }+\frac{1}{\left\vert \frac{L}{2}+R\right\vert }-\\ -\frac{{{{{{{{\rm{erf}}}}}}}}(\left\vert \frac{L}{2}-r\right\vert /{R}_{r})}{\left\vert \frac{L}{2}-r\right\vert }-\frac{{{{{{{{\rm{erf}}}}}}}}(\left\vert \frac{L}{2}+r\right\vert /{R}_{l})}{\left\vert \frac{L}{2}+r\right\vert }-\frac{{{{{{{{\rm{erf}}}}}}}}(\left\vert R-r\right\vert /{R}_{f})}{\left\vert R-r\right\vert }.$$
(8)

The Hamiltonian above is defined using atomic units, m = e =  = 1, and we also take Z = 1, M = 1836. The constants Rl, Rr and Rf are given in Fig. 2 and are designed to create a sharp avoided crossing between the ground and first excited adiabatic electronic states at R = − 1.9 a.u.. These parameters were chosen to be similar to those used in several studies of the model16,19. The shape of the Born-Oppenheimer potential energy surfaces (BOPES) can be seen in Fig. 2b

Ehrenfest propagation

In the Ehrenfest propagation of the Shin-Metiu model the electron subsystem is treated as a quantum particle described by Hamiltonian (8), where He is parameterized by the nuclear position (R), while the nuclear subsystem is described classically by the position (R) and velocity (\(\dot{R}\)).

For initial coordinates \({R}_{0}\,{{{{{{{\rm{and}}}}}}}}\,{\dot{R}}_{0}\), we first prepare the electronic Hamiltonian He(R0), which is used to compute the initial state of the electron \(\left\vert {\psi }_{0}\right\rangle\). Thanks to the simplicity of the model, one can use exact diagonalization to compute the eigenvectors and choose any arbitrary superposition of eigenvectors as the initial state.

The nucleus is evolved using the velocity-Verlet method29 with the acceleration being computed from the Coulombic repulsion from the fixed ions and the force from the electronic state. The electronic state is propagated by unitary time evolution with the Hamiltonian at the nuclear position. We use a timestep Δt, and subscripts i denote the specific step. We set our initial conditions at timestep 0, and for the ith step, we compute

$${F}_{e}(R,\left\vert {\psi }_{i}\right\rangle )=-\left\langle {\psi }_{i}\right\vert \frac{\partial {H}_{e}(R)}{\partial R}\left\vert {\psi }_{i}\right\rangle ,$$
(9)
$${R}_{i}={R}_{i-1}+{\dot{R}}_{i-1}\Delta t+\frac{{F}_{e}({R}_{i-1},\left\vert {\psi }_{i-1}\right\rangle )}{M}\Delta {t}^{2},$$
(10)
$$\left\vert {\psi }_{i}\right\rangle ={e}^{-i{H}_{e}({R}_{i-1})\Delta t}\left\vert {\psi }_{i-1}\right\rangle ,$$
(11)
$${\dot{R}}_{i}={\dot{R}}_{i-1}+\frac{{F}_{e}({R}_{i-1},\left\vert {\psi }_{i-1}\right\rangle )+{F}_{e}({R}_{i},\left\vert {\psi }_{i}\right\rangle )}{2M}\Delta t.$$
(12)

Numerical results

We consider two situations in the following: first, we consider a single set of initial conditions meant to illustrate the accuracy of the algorithm in reproducing the numerically exact evolution of the quantum-classical system. Although a single trajectory is not likely to be the intended use case of TDVQP in most applications, it is nonetheless most instructive to determine its behavior. Second, we consider the molecular dynamics-like (MD) use case, where initial conditions are sampled from a distribution and where we use a single TDVQP evolution per trajectory. The initial classical conditions are picked as random pairs of position and velocity from a thermally averaged distribution centered around the same initial value as the (single) simulations. The specific initial conditions are shown in the “Numerical Simulations” subsection of the Method section. Their average dynamics are taken as an approximation to the true system evolution. For NISQ devices, one can consider different approaches to MD such as those mentioned by Kuroiwa et al.30.

The quality of the simulations of closed Hamiltonian systems can be gauged in their energy conservation. We use a symplectic integrator in the classical system (velocity-Verlet), and in the exact diagonalization case, we see energy conservation for up to 50,000 timesteps. However, as can be seen in Fig. 3a, the TDVQP algorithm does not conserve energy. This is because the populations are not preserved in the diagonal basis in the p-VQD step, as the optimization of the quantum state is limited to a finite number of iterations and the circuit ansatz is not complete. The effect of this population leak can be seen clearly in Fig. 3b, where one observes how the population in higher states increases much faster than in the exact case. The population plot is shown at the infinite shot limit for clarity, but the finite shot cases can be found in Supplementary Note 3.

Fig. 3: Energy and Population Plots for Time Dependent Variational Quantum Propagation.
figure 3

a Plot of the relative total energy for single initialization (blue) and for Molecular Dynamics (MD) initialization (orange) compared to the ideal simulation (black). The highlighted areas show the standard deviation of the distribution of 100 separate runs of 1000 timesteps of 0.5 a.u. at the infinite shot limit. The energy continually increases in the Time Dependent Variational Quantum Propagation (TDVQP) as higher energy levels are increasingly populated through leakage. b Plot of the evolution of the state population for the ideal simulation (solid) and 100 instances of TDVQP evolution (dashed) over 1000 timesteps of 0.5 a.u. at the infinite shot limit. The states (colored) are the same as those seen in Fig. 2b. The main graph is in logarithmic scale showing faint lines for higher energy levels in TDVQP, with the inset showing a linear scale of the two most populated levels.

As a consequence of the higher energy levels becoming increasingly populated, there is an error in the measured observables. Figure 4 shows the mean of the electron force measurements from TDVQP compared to the ideal measurements at different per-circuit shot counts. It is clear that the mean value slowly deviates from the ideal evolution, even in the infinite shot limit, and that one requires 105 shots per circuit to reach qualitatively relevant results at longer times. Efficiently estimating energy gradients is a demanding task, and this work does not implement some of the NISQ-friendly techniques that have been developed31,32, but this is expected to be a problem even in the fault-tolerant regime33.

Fig. 4: Electron force observable for the single initialization.
figure 4

The ideal simulation (black) and 100 instances of Time-Dependent Variational Quantum Propagation (TDVQP) evolutions (colored) over 1000 timesteps of 0.5 a.u. at varying shot counts per circuit. We observe qualitative agreement of TDVQP with the ideal case at 105 shots and the infinite shot limit, with a shift downwards due to leakage to higher energy levels, which in this case biases the force in this direction.

Another consequence of the progressive and unphysical population of higher energy levels is that the fidelity decreases gradually, as can be seen in Fig. 5a. This general degradation of quality could be mitigated with dedicated strategies, such as measuring the energy and allowing the cost function to penalize when the system is not conserving energy. However, this would require measuring the expectation value of the system Hamiltonian, which would increase the cost of this algorithm.

Fig. 5: Fidelity of the Time Dependent Variational Quantum Propagation algorithm.
figure 5

a Time-Dependent Variational Quantum Propagation (TDVQP) compared to the exact diagonalization evolution of the single initialized state (solid) at different shot counts (colored). The best-fit approximation of Eq. (7) (dashed) for each line is shown. b Plot of the infinite shot limit and 105 shots comparing the MD mode of TDVQP evolution (dashed) to the single mode (solid). The Molecular Dynamics (MD) simulation is of slightly higher fidelity compared to single trajectory simulations at high but finite shot counts. Lower shot counts cause the fidelity to decrease too quickly. c Fidelity over shots at specified times of the exact diagonalization evolution of the VQE initialized state and the TDVQP evolution. a, b and c 1000 timesteps of 0.5 a.u. for 100 different MD and single simulations.

We see in Fig. 5a that the fidelity decays in all cases over time and that for long-term time evolutions, one requires more than 105 shots per step. At lower shot counts the fidelity falls quickly, following Eq. (7) until an equal superposition is approached. In this final state of the quantum register there is a residual overlap with the true physical state, which sets a higher floor than zero for the decay of the fidelity. The potential effects of other noise sources are described in more detail in Supplementary Note 2.

Figure 5b zooms into the two more reasonable fidelity lines, those of the infinite and 105 shot simulations. Here we can see that using the multiple trajectories in an MD sense somewhat improves the simulation fidelity compared to the single trajectory case, and more quantum-tailored algorithms like30 may improve this further. In the infinite shot case, the difference is minimal - but due to the larger variance of the MD simulations compared to the ideal trajectory, the performance tends to be minimally worse.

The relationship between shots and fidelity is also illustrated in Fig. 5c, where one can more clearly see that the MD simulation slightly improves the results at longer time evolutions when using finite shots. However, this improvement is not very large. It also highlights the large improvement in fidelity when using higher shot counts. The p-VQD implementation (see Ref. 13) on which we base our time evolution evolves the system for 40 iterations (20 a.u. here), where we see very high compression fidelities beyond 104 shots per circuit evaluation.

Finally, Fig. 6 illustrates that in the simulation the maximum number of iterations of the quantum state optimizer (100) is quickly reached before the 200th timestep at the infinite shot limit. The overall mean final infidelity is 10−5, although the fitted threshold of Eq. (7) for the overall algorithm is slightly lower at 3  105. The infidelity is defined as \(I=1-{{{{{{{\mathcal{F}}}}}}}}\), where \({{{{{{{\mathcal{F}}}}}}}}\) is the fidelity. This implies there is an additional error, likely due to the drift of the exact simulation from the TDVQP case. This is consistent with a 10−6 to 10−7 shift in the force as described in the numerical simulations in Supplementary Note 2, which is also roughly the difference in the force observable seen in Fig. 4.

Fig. 6: Compression infidelity and number of iterations per step.
figure 6

Compression infidelity for the single Time Dependent Variational Quantum Propagation (TDVQP) setup at the infinite shot limit, showing the mean number of iterations in red with scale to the left. The mean initial infidelity (dashed, blue) and final infidelity (solid, blue) with the scale on the right, where infidelity (I) is I = 1 − Fidelity. The number of iterations taken by the optimizer quickly reaches the limit of 100, while the final and initial infidelities gradually fall with the number of timesteps into the simulation.

Overall the results show some interesting behavior. The number of timesteps modeled in this work compared to previous studies is very large13. This results in a qualitative agreement in the region of interest where there is a significant population transfer, but high qualitative accuracy is missing. Furthermore in this simple model, the energy levels are well separated and we begin in the ground state. This results in a strong unidirectional contribution from population leakage to higher energy levels. In a more complex molecule, one would begin, for example, from a thermal ensemble of not only velocities but also states. In turn, the leakage would then result in deviations towards both higher and lower energy levels and might be less detrimental to the ensemble average than here.

Discussion

Time-dependent evolution is an exceptionally interesting problem that can be well explored through quantum computers. Many techniques can be used for full quantum systems13,14,23,24,34,35 which are suitable to both near term and fault-tolerant machines.

Algorithms that are suitable for MQC dynamics do require efficient and accurate full quantum dynamics, but the interplay between the classical and quantum systems brings a new spate of challenges. To exchange information, one must measure observables from the quantum system, which is expensive and destroys the state, requiring at minimum an efficient way to measure energy gradients, which is an area of active research31,32,36. This is a disadvantage, but it also means that one is limited to short-time evolutions between measurements. This makes it possible that a single Trotter step is accurate enough37,38, which is beneficial to near-term devices.

Even though larger timesteps may be possible, the longer the time evolution, the longer the quantum-state optimizer takes to find the time-evolved ansatz parameters. This is because the previous timestep parameters are no longer as close to the evolved ones. At the same time, most classical MQC methods do not update the parameters that govern the classical system’s evolution at the small time intervals we use4. It would be advantageous to use the largest possible classical timestep for a given integrator. To do this, one could do multiple compression steps with short-time Trotterizations using a constant Hamiltonian and only measuring the desired observables after the quantum system has evolved for the standard timestep of the classical problem, performing updates after this point. This will leverage the underlying compression algorithm to its fullest and reduce the overall number of measurements required.

The algorithm we present takes advantage of the above facts and is highly modular. Although the results are shown using an algorithm like p-VQD13 with Trotterization of the operator, there is no reason that other efficient time evolution algorithms couldn’t be used. This is especially true if the time evolution operator could be efficiently represented by techniques other than the Trotterization of the Hamiltonian. The update step used here measures the Pauli string decomposition of the \(\frac{dH}{dR}\) matrix to compute forces, but other techniques exist in the fault-tolerant regime33,36, as well as in the NISQ regime31,32. The main constraint with TDVQP is the fact that throughout the time evolution, there are inevitable inaccuracies in optimization, due to the compression step not preserving the populations in the diagonal basis as would have been expected as shown in Fig. 3b. This has the direct consequence that energy is not conserved, even though in the ideal simulation this is the case as shown in Fig. 3a. Due to this accumulated error, fidelity falls continuously, and the effect is compounded when quantum resources are finite.

These problems might be tackled by either increasing the threshold of the compression step or by measuring the energy and penalizing the optimizer when energy is not conserved. Another option that may be possible is designing an ansatz with problem-specific constraints39. Such an ansatz considers properties such as particle preservation within their structure (not relevant in our first quantization treatment here), which may remove the need for expensive additional iteration steps or measurements. Furthermore, it may be possible to replace the p-VQD propagation with other compression methods14.

We have also found that the inaccuracy of the propagation mostly originates from the compression step and due to finite sampling effects rather than from the discretization of the classical timesteps. Although we did not consider noise effects, we refer the reader to14, where the performance of p-VQD under noise was explored for full quantum dynamics.

Overall we have introduced the TDVQP algorithm for MQC dynamics with the quantum subsystem computed on a quantum computer and have explored it on the Shin-Metiu model as an example of Ehrenfest dynamics in first quantization. The approach reproduces the expected observables and state evolution quantitatively at short times and qualitatively afterwards. The algorithm is modular and refinements to it may be tackled in future research. Inaccuracies of the quantum computer can also be mitigated when computing ensemble averages of the classical properties. This work shows that MQC simulations may be practically feasible on noisy quantum computers if it is proven that variational quantum algorithms can have an advantage in chemical problems.

Method

Numerical simulations

To gauge the performance of the scheme we implement the Shin-Metiu model as described in the Results section. The BOPES presents an avoided crossing at around R = − 1.9 a.u. We initialize the system with the nucleus at an initial position of R = − 2 a.u. and an initial velocity of v0 = 1.14  10−3 a.u., the average nuclear velocity from the Boltzmann distribution at 300K. The electronic system is initialized through the VQE with a random set of parameters and is allowed 300 iterations to approximate the ground state. The system is then evolved through the TDVQP algorithm with a timestep of Δt = 0.5 a.u. Each quantum time evolution step attempts to reach a fidelity threshold of 1 − 10−5 using up to 100 iterations of stochastic gradient descent40 to find the optimal circuit parameters to approximate the previous time evolved state. Gradients were computed through the parameter shift rule41. All simulations are done on 16 grid points that can be represented by 4 qubits.

We examine two different situations. First, we keep the initial conditions constant but sample different VQE ground state approximations, which we call the single case. In the second case, we examine the MD-type approach in depth, where we sample a normal distribution of initial conditions for the initial velocity of the nucleus and allow one TDVQP evolution per sample. The velocity distribution is sampled from the Boltzmann distribution, only keeping positive velocities so that the nuclei approach the avoided crossing. The results shown are 100 samples that are evolved for 1000 timesteps which bring the classical trajectory beyond the avoided crossing point.

Additional examples are provided for longer-time evolutions as well as for non-ground state evolution in Supplementary Note 4. Excited states and superpositions are prepared by using the uncomputation step of the TDVQP, but instead of starting the state with a known circuit from the VQE, the simulator is simply initialized to a desired arbitrary state, and the optimizer attempts to uncompute it with the ansatz and then those parameters are used as the initial step in place of the VQE. Various techniques to prepare excited states exist42,43, but are not the focus of this work.

We use two different metrics to establish the accuracy of the TDVQP algorithm: the ideal evolution begins at the desired state to numerical precision and is evolved by exact diagonalization. But, precise state preparation is another area of intense study44. To better gauge the performance of the TDVQP in isolation, we also perform an exact evolution, which uses the VQE-optimized initial state for evolution via exact diagonalization. This allows us to remove any bias from a poorly optimized ground state.

The VQE uses an ansatz of the form shown in Fig. 7, which was heuristically chosen as it can achieve ground state infidelities of up to 10−5 on this system with 4 layers. We use the same ansatz as in the p-VQD paper13, but various ansatze can be used, and for first quantization problems, in particular, there are some examples of how several different heuristic ansatze perform in45. The number of repetitions of the Trotterization layer is another choosable parameter, but as the decomposition of the Trotterized operator into native gates is deep, we limit ourselves to one. Although for full quantum dynamics, this would be very inaccurate for larger timesteps, the interaction with a classical system necessitates that we use short time steps, so that the Hamiltonian of the system is kept up to date with the classical state of the system. This means that a single Trotter step is all that is needed, and the number of layers of the ansatz can compensate as shown in Supplementary Note 5.

Fig. 7: Form of the ansatz used for three qubits.
figure 7

If multiple layers are used then the above circuit is repeated. If more qubits are used then the vertical motif is continued. In both cases, more parameters can be added as needed and \(\overrightarrow{\theta }\) refers to the list of all parameters. The ansatz features x rotations and the parameterized ZZ rotation.

The simulations were run on the Qiskit state vector simulator (version 0.28)46 using the parameter-shift rule41,47 to determine the analytic gradients required for gradient-descent based optimization. Numpy48 was used for the exact numerical simulations, to prepare the Hamiltonian and to compute the velocity Verlet steps.

Grid-based mapping to qubits

We treat the Shin-Metiu system on the quantum computer in first quantization. We use a finite difference method on an equidistant grid. This renders the kinetic energy matrix tri-diagonal and the potential energy matrix diagonal. If the grid is fine enough, this is an appropriate approximation, but in general discrete variable representations (DVR) are a better choice. In quantum computing, DVRs have been used to explore first quantization simulations34 using the Colbert and Miller DVR49. Issues exist with using DVRs on quantum computers as the corresponding kinetic energy matrix is generally full, which is costly to measure and implement on the quantum computer, and alternatives have been proposed45.

Quantum computing in first quantization has the advantage that ng grid points can be represented by \(N={\log }_{2}({n}_{g})\) qubits. We choose ng = 2N to maximize the use of the N available qubits. In the simplest finite differences method each position is given by xg = gL/ng with 0 ≤ g ≤ ng − 1. The grid point g is encoded by the quantum state \(\left\vert g\right\rangle\) and mapped as

$$\left\vert g\right\rangle =\left\vert {j}_{0}\right\rangle \otimes \cdots \otimes \left\vert {j}_{k}\right\rangle \otimes \cdots \otimes \left\vert {j}_{N}\right\rangle ,$$
(13)

where jk is the kth bit value of the binary representation of g. The potential operator \(\hat{V}\) is diagonal in this representation, simply sampling the potential at each grid point. The kinetic energy Hamiltonian is not diagonal in the position representation, and although one could use the split operator method50 to make it diagonal in momentum space would require a quantum Fourier transform implementation, which, as far as we know, cannot be effectively implemented on existing quantum devices.

We sidestep all of the issues by using the finite differences method, in which the one-dimensional potential and the Laplacian form of the kinetic energy can be written as

$${V}_{j,{j}^{{\prime} }}=V({x}_{j}){\delta }_{j,{j}^{{\prime} }}$$
(14)
$${T}_{j,{j}^{{\prime} }}=\frac{-{\partial }^{2}}{\partial {r}^{2}}\frac{1}{2{m}_{el}}f,\,f\left\{\begin{array}{ll}-2,\quad &\,{{\mbox{if}}}\,\,j={j}^{{\prime} };\hfill\\ 1,\quad &\,{{\mbox{if}}}\,\,j={j}^{{\prime} }\pm 1.\end{array}\right.$$
(15)

The tridiagonal matrix that results has the same value on the off-diagonal terms, which allows them to be decomposed into fewer Pauli strings than a full matrix via an elegant recursive form that is described in Supplementary Note 6 following from51. This is beneficial because the number of non-zero entries is related to the number of terms in the Pauli decomposition, which should be kept minimal to reduce the length of the Trotterized time evolution operator and observable measurements. The finite difference method does require high grid densities to be accurate (although this depends on how oscillatory the system in question is), but this requirement will likely be met by the doubling of grid points per additional qubit.

Although not implemented in this paper, some algorithms can make the time evolution of Hamiltonians with this form more efficient on near-term devices52. Depending on the particular Hamiltonian one chooses to study in this way, different efficient algorithms exist to lessen the cost of the time evolution such as variational fast forwarding and qubitization23,24. It is also possible to efficiently solve for the eigenstates of tridiagonal matrices on quantum computers53.

Circuit compression

A key building block of the presented algorithm and a fundamental aspect of quantum circuit optimization is the concept of circuit compression54. Any operation on a quantum computer must be a unitary operation \(\hat{U}\), but the quantum computer only has a finite set of few-qubit gates. An arbitrary \(\hat{U}\) must be expressed, or compiled, into a set of native gates20. This can always be done, but it is an NP-hard problem. If one implements an approximation of \(\hat{U}\) within some threshold, one may find \(\tilde{U}\) with a shorter circuit length than even an optimal decomposition of \(\hat{U}\). This latter definition is generally known as circuit compression, although the term is sometimes used to refer to more optimal perfect decompositions55.

With an error-corrected quantum computer, one could use arbitrary circuit depths, but NISQ hardware benefits from using short circuits to minimize errors. But designing hardware-efficient ansatze for VQAs is an unsolved problem56. This means that for most purposes we use a heuristic ansatz \(\hat{C}\) parameterized by some vector \(\overrightarrow{\theta }\), which brings the initial computational state \(\left\vert 0\right\rangle\) to a desired state \(\left\vert \psi \right\rangle\) via \(\hat{C}(\theta )\left\vert 0\right\rangle =\left\vert \psi \right\rangle\). The defining property of unitary matrices, namely

$$U{U}^{{{{\dagger}}} }={U}^{{{{\dagger}}} }U=I,$$
(16)

ensures that C(θ) reverses the action of C(θ). If we add a unitary \(\hat{U}\), then it may be possible to find some parameters \({\theta }^{{\prime} }\) such that \(\hat{U}\hat{C}(\theta )\left\vert 0\right\rangle \approx \hat{C}({\theta }^{{\prime} })\left\vert 0\right\rangle\), thus compressing the action of the unitary back into the same quantum circuit, at least approximately. This approach has been used in other works12,13,14.

Another approach consists of approximating an initial state with such an ansatz and then performing a short-time evolution via Trotterization of the time-evolved operator as is often done28,29,39. The adjoint of the ansatz is appended to the circuit and its parameters varied such that the machine state is ‘uncomputed’ to its initial state. If one assumes that the chosen circuit ansatz is expressive enough to capture the entire state’s time evolution, then such an approach is guaranteed to work. One then needs this new set of parameters and the original ansatz to express the new timestep without the time evolution operator, hence compressing the circuit. This idea has been implemented almost concurrently by Lin et al.12, and by Barison et al.’s projected variational quantum dynamics (p-VQD) algorithm13. Subsequent works14, have built on the circuit compression idea.