Skip to main content

View on GitHub

Open this notebook in GitHub to run it yourself
This demonstration is based on the [1] paper. The notebook was written in collaboration with Prof. Di Fang, the first author of the paper. Time marching is a method for solving differential equations in time by integrating the solution vector through time in small discrete steps, where each timestep depends on previous timesteps. This paper applies an evolution matrix sequentially on the state and makes it evolve through time, as done in time-dependent Hamiltonian simulations.

Defining the Problem

  • Input: a system of linear homogenous linear equations (ODEs):
ddt∣ψ(t)⟩=A(t)∣ψ(t)⟩,∣ψ(0)⟩=∣ψ0⟩\frac{d}{dt} |\psi(t)\rangle = A(t) |\psi(t)\rangle, \quad |\psi(0)\rangle = |\psi_0\rangle Note that AA can vary in time. We assume that the matrix AA is with bounded variation. The input model of A(t)A(t) is a series of time-dependent block-encodings, described next.
  • Output: a state that is proportional to the solution at time TT, ∣ψ(T)⟩|\psi(T)\rangle.

Describing the Algorithm

The algorithm divides the timeline into long timesteps and short timesteps. In each long timestep, some approximation of evolution of the short timesteps is done, such as the Truncated Dyson series [2] or Magnus series [3]. These are applied as block-encodings on the state, where the following matrix is block-encoded in each long timestep: Ξl=Te∫tl−1tlA(t) dt\mathcal{\Xi_l} = \mathcal{T} e^{\int_{t_{l-1}}^{t_l} A(t) \, dt} image.png The problem is that when this block-encoding has some prefactor ss (for example, because some LCU is block-encoding the integration), the prefactor of the entire simulation is amplified by ss on each iteration. This means that the probability to sample the wanted block decreases exponentially with the number of long timesteps. This is the main pain-point that the algorithm in the paper resolves. In the case of Hamiltonian simulation, it is possible to wrap each timestep with oblivious amplitude amplification [4] (see oblivious amplitude amplification) and get rid of the prefactor. However, it is only possible in the case of a unitary block-encoding. The authors address this issue by using uniform singular amplitude amplification [5] instead, within the QSVT framework.

Implementing the Algorithm Using Classiq

image.png We choose an easy artificial example to demonstrate the algorithm. For simplicity, we choose AA, which is easy to block-encode. The following matrix can be easily block-encoded using linear Pauli rotations: Aij(t)=cos⁡(i+t)δijA_{ij}(t) = \cos(i+t)\delta_{ij} The matrix is Hermitian and diagonal, and it helps us in several aspects:
  1. The first-order Magnus expansion will be exact.
  2. The QSVT and QET (quantum eigenvalue transform) will coincide, and we use it to exponentiate the block-encoding.
We simulate a 4x4 matrix using four timesteps, from t=0t=0 to t=2t=2:

Classical Simulation

This is how the evolution looks classically:
output

Time-Dependent Block-Encoding

The time-dependent block-encoding of A(t)A(t): (Inq⊗⟨0m∣⊗In)UA(t)(Inq⊗∣0m⟩⊗In)=∑i=02nq−1∣i⟩⟨i∣A((b−a)i2nq+a)α\left( I_{n_q} \otimes \langle 0_m | \otimes I_n \right) U_{A(t)} \left( I_{n_q} \otimes | 0_m \rangle \otimes I_n \right) = \sum_{i=0}^{2^{n_q}-1} | i \rangle \langle i | \frac{A\left((b-a)\frac{i}{{2^{n_q}}}+a\right)}{\alpha} For a given timeslice, we get this: Aij(t,a,b)=cos⁡((b−a)t2nq+a+i)δijA_{ij}(t, a, b) = \cos((b-a)\frac{t}{2^{n_q}} + a + i)\delta_{ij} We accomplish this easily with a sequence of two Pauli rotations:

Short Time Evolution

We use a first-order Magnus expansion, which is exact in this case: Ξ‾=eb−aM∑k=0M−1A(a+kb−aM)\overline{\Xi} = e^{\frac{b-a}{M}} \sum_{k=0}^{M-1} A\left(a + k \frac{b-a}{M}\right) It is built in two steps.

  1. Riemannian Summation of Short Timesteps
By wrapping the time variable with the Hadamard transform, we get an exact block-encoding of the Reimann sum of the input block-encoding. image.png

  1. Block-Encoding of the Summation Exponential
We want to find polynomials for cosh⁡(ax)\cosh(ax) and sinh⁡(ax)\sinh(ax), to combine them into eaxe^{ax}. For pedagogical reasons, we work naively and create a polynomial approximation for each of the odd and even polynomials of Pcosh≈cosh⁡(ax)eaP_{cosh} \approx \frac{\cosh(ax)}{e^a} and Psinh≈sinh⁡(ax)eaP_{sinh} \approx \frac{\sinh(ax)}{e^a}. Combining them with LCU gives these results: P(x)≈eax2ea,P(x) \approx \frac{e^{ax}}{2e^a}, which is a polynomial bounded by 12\frac{1}{2}. We could choose Pcosh≈cosh⁡(ax)cosh⁡(a)P_{cosh} \approx \frac{\cosh(ax)}{\cosh(a)} and Psinh≈sinh⁡(ax)sinh⁡aP_{sinh} \approx \frac{\sinh(ax)}{\sinh{a}}. Then, LCU with coefficients [cosh⁡(a)cosh⁡(a)+sinh⁡(a),sinh⁡(a)cosh⁡(a)+sinh⁡(a)][\frac{\cosh(a)}{\cosh(a)+\sinh(a)}, \frac{\sinh(a)}{\cosh(a)+\sinh(a)}] gives us this: P(x)≈eaxea,P(x) \approx \frac{e^{ax}}{e^a}, which is the best we can get, and doesn’t require amplification. We go with the first approach for demonstrating the singular value amplification. Getting rid of this redundant factor 2 can save us a multiplicative factor of O(2T)O(2^T) in the success probability.
Output:
output We transform the polynomials to QSVT phases using the qsvt_phases function, and plug them into the qsvt_lcu function, which is optimized for implementing a linear combination of two QSVT sequences:

Amplification of a Single Long Timestep

At the climax of the algorithm, we wrap the Magnus evolution in an amplification step. The prefactor of the exponential block-encoding is 2, so we want to approximate the function f(x)=2xf(x)=2x in the interval [0,12][0, \frac{1}{2}]. We use Classiq’s qsp_approximate to obtain the polynomial approximation. Our built-in routine is inspired by the paper’s approach: it solves a minimax problem to determine the Chebyshev coefficients on a subinterval of [−1,1][-1, 1], while ensuring the resulting polynomial remains bounded on the entire interval.

Singular Value Amplification (γx\gamma x)

output Then we apply the phases on the Magnus block-encoding:

Long Time Evolution

Lastly, we sequentially apply the block-encodings of each timeslice. To have a quantum variable that is ∣0⟩|0\rangle when all the block encodings are applied to the state, we use a counter. A further amplitude amplification step is possible using the counter; however, we do not do it here. image.png
Output:
Output:

Comparing to the Naive Case: Without Uniform Amplification

Here we do not use the amplification step. We see that the measured amplitudes are much smaller than in the amplified case.
Output:
Output:
Output:

Post-Processing

Output:
And indeed we can see the the naive amplitudes are order of magnitude smaller than the amplified case (this is exactly what we expect for 4 timesteps).

Comparing Classical and Quantum Results

In this final step, we verify that the classical and quantum solutions are equivalent:

References

[1]: Fang, Di, Lin, Lin, and Tong, Yu. Time-marching based quantum solvers for time-dependent linear differential equations. Quantum 7, 955 (2023). [2]: [M. Kieferová, A. Scherer, and D. W. Berry. Simulating the dynamics of timedependent Hamiltonians with a truncated Dyson series. Phys. Rev. A, 99(4), Apr 2019](https://arxiv.org/abs/1805.00582). [3]: Magnus Expansion (Wikipedia). [4]: Berry, Dominic W., et al. Exponential improvement in precision for simulating sparse Hamiltonians. Proceedings of the forty-sixth annual ACM symposium on Theory of Computing. 2014. [5]: [A. Gilyén, Y. Su, G. H. Low, and N. Wiebe. Quantum singular value transformation and beyond: exponential improvements for quantum matrix arithmetics. In Proc. 51st Annu. ACM SIGACT Symp. Theory Comput., pages 193{204, 2019.](https://dl.acm.org/doi/10.1145/3313276.3316366)