Skip to main content

View on GitHub

Open this notebook in GitHub to run it yourself
This notebook is based on Ref. [1]. Given an efficient block-encoding for a Hamiltonian, this algorithm preforms an efficient Quantum Phase Estimation. The core quantum function of this model uses almost all Qmod built-in operations: control, power, within_apply, and invert. The algorithm assumes we have the block-encoding of a matrix HH U(s,m)H=(H/s),U_{(s,m)-H} =\begin{pmatrix} H/s & * \\ * & * \end{pmatrix}, with mm being the size of the block variable and ss some scaling factor. Given this quantum function, we can define the following unitary (usually called the Szegedy quantum walk operator [2]): WΠ0mU(s,m)H,W\equiv \Pi_{|0\rangle_m} U_{(s,m)-H}, where Π0m\Pi_{|0\rangle_m} is a reflection operator about the block state
  1. The spectrum of the walk operator has a nice relation to the spectrum of the block-encoded Hamiltonian [3]:
{eigenvalues:}e{±iarccos(λ/s)},{witheigenvectors:}φ{±}{λ}{1}{{2}}(v{λ}0m±i{λ}),(1) \text\{eigenvalues: \} e^\{\pm i \arccos(\lambda/s)\}, \text\{ with eigenvectors: \} |\varphi^\{\pm\}_\{\lambda\}\rangle \equiv \frac\{1\}\{\sqrt\{2\}\}\left(|v_\{\lambda\}\rangle |0\rangle_m \pm i|\perp_\{\lambda\}\rangle\right), \quad (1) where vλ|v_\lambda\rangle is an eigenstate of the Hamiltonian HH with an eigenvalue λ\lambda. Namely, the eigenphases of HH are related by some nonlinear function (arccos\arccos) to the eigenvalues of HH. The algorithm works under the assumption that the block-encoding unitary itself is also Hermitian, that is, U(s,m)HU_{(s,m)-H} is Unitary and Hermitian.

Preliminaries

We start with defining some utility functions that are not implemented as part of Classiq, and might be included in the future. These functions are used for the specific block-encoding used in this notebook.

Defining a Specific Usecase: A Molecule and Its Block-Encoding Hamiltonian Function

Output:
Finally, we calculate the ground state energy as a reference solution to the quantum solver
Output:
Output:

Defining a Walk Operator

We use the reflect_around_zero function from Classiq’s open library to define a walk operator function with the declaration below. This function implements I200I-2|0\rangle\langle 0|, so we must insert a minus phase (This can be done by adding a minus sign using the phase function).
We define a classical function that takes the eigenphases of the Walk operator, and returns the (scaled) eigenvalues of HH, according to equation (1) above.
We also define a utility function for ploting the results:

Setting Initial State and QPE Size

A Naive QPE

Before going to the optimized implementation, designing a specific QPE that operates on a walk operator, we start with a naive QPE implementation.
Output:
Output:
output

Optimized QPE Design for the Walk Operator

We construct the model design according to Ref. [1], shown in the figure below, with RLR_{\mathcal{L}} being the reflection around zero operation, and χm\chi_m is taken as the usual Hadamard transform for the phase initialization: Screenshot 2025-12-12 at 16.20.32.png
We now construct the model, synthesize it, and retrieve the ground state of the molecule
Output:
Output:
output
Output:
If ΔλW=1/2QPESIZE\Delta \lambda_W = 1/2^{\rm QPE-SIZE}, then Δλ=Δ(cos(2πλW))s=2πssin(2πλW)ΔλW=2πssin(2π2QPESIZE)2QPESIZE\Delta \lambda = \Delta(\cos(2\pi\lambda_W))s = 2\pi s \sin(2\pi\lambda_W) \Delta\lambda_W = 2\pi s \sin(2\pi 2^{-\rm QPE-SIZE}) 2^{-\rm QPE-SIZE}
Output:

References

[1] R. Babbush et. al., Encoding Electronic Spectra in Quantum Circuits with Linear T Complexity. https://arxiv.org/abs/1805.03662 (2018) [2] Szegedy, M. , Quantum speed-up of Markov chain based algorithms. In 5th Annual IEEE Symposium on Foundations of Computer Science (2004) [3] Lin, L., Lecture notes on quantum algorithms for scientific computation. arXiv:2201.08309 quant-ph (2022)