Use this file to discover all available pages before exploring further.
View on GitHub
Open this notebook in GitHub to run it yourself
Simulating physical and chemical systems was among the original motivations for quantum computing, as first envisioned by Richard Feynman in 1982, and remains one of its most impactful applications. Time-independent Hamiltonian simulation refers to the task of approximately implementing the unitary evolution operator e−iHt for a Hermitian matrix H. When access to the Hamiltonian is provided via block-encoding, this can be realized by applying an appropriate polynomial transformation within a desired precision ϵ.Generalized Quantum Signal Processing (GQSP) [1] achieves this by applying a Laurent polynomial P(W) to the walk operator W of the block-encoded Hamiltonian. The polynomial coefficients are derived from the Jacobi–Anger expansion (Eq. (1): eitcos(x)=∑kikJk(t)eikx). GQSP requires only one auxiliary qubit and eliminates the need for amplitude amplification.
Input: A Hermitian operator H given through a block-encoding unitary UH with scaling factor α≥∥H∥, evolution time t, and target error ϵ.
Output: A unitary U approximating e−iHt, with ∥U−e−iHt∥<ϵ.
Complexity:O(αt+log(e+log(ϵ−1)/αt)logϵ−1) calls to the block-encoding, using one auxiliary qubit and a classical preprocessing step to compute the GQSP rotation angles.Keywords: Hamiltonian Simulation, Block Encoding, Generalized Quantum Signal Processing, GQSP, Walk Operator, Oracle/Query complexity.
A block-encoded Hamiltonian refers to its embedding within a larger unitary matrix.Definition: A (s,m,ϵ)-encoding of a 2n×2n matrix A refers to completing it into a 2n+m×2n+m unitary matrix U(s,m,ϵ)−A:U(s,m,ϵ)−A=(A/s∗∗∗),with functional error (U(s,m,ϵ)−A)0:2n−1,0:2n−1−A/s≤ϵ.Here s is a scaling factor that ensures the overall operator is unitary, m is the number of auxiliary (block) qubits, and ϵ is the encoding error.This notebook assumes basic knowledge of Linear Combination of Unitaries (LCU); see the LCU tutorial for background.The GQSP approach implements polynomials on unitary operators.For Hamiltonian evolution, given an exact (s,m,0)-encoding of the Hamiltonian (denoting UH≡U(s,m,0)−H), we define the Szegedy quantum walk operator [2] W≡Π∣0⟩mUH, where Π∣0⟩m reflects about the ∣0⟩ state of the block variable. The walk operator W is unitary, with eigenvalues z=e±iarccos(λ/s), where λ are the Hamiltonian eigenvalues. By the Jacobi–Anger expansion (Eq. (1)), the polynomial approximating e−istcos(x) as a Laurent series in z=eix gives P(z)≈e−iλt on the eigenvalue z=eiarccos(λ/s) (since cos(x)=λ/s) — the desired time-evolution phase.Applying P(W) via GQSP therefore gives approximately e−iHt in the block.GQSP computes a set of single-qubit rotation angles {ϕk} such that the resulting circuit block-encodes the desired polynomial:GQSP(W)≈U(1,m+1,ϵ)−e−iHt=(e−iHt∗∗∗).(In practice, our prefactor is slightly different, β−1 with β=0.9999 which ensures numerical stability of the classical angle computation).Compared the the QSVT approach for Hamiltonian simulation, the GQSP method uses only one extra block qubit, and requires no amplitude amplification. However, it includes controlled operations on the block-encoding unitary.
This notebook demonstrates Hamiltonian simulation using the GQSP method.For the other approaches, see the companion notebooks on QSVT and Qubitization.For a side-by-side comparison of all three methods, see the table at the end of this notebook.
We set some specific hyperparameters for our problem. We use a simple Hamiltonian given as a sum of Pauli strings, and the lcu_pauli function to block-encode it via the Linear Combination of Unitaries (LCU) technique:H=i∑αiUi,U(αˉ,m,0)−H=(H/αˉ∗∗∗),αˉ=i∑∣αi∣.To treat different problems with the same algorithm, simply change theses hyperparameters.
import timeimport matplotlib.pyplot as pltimport numpy as npimport scipyfrom classiq import *
Working with block-encoding typically requires post-selection of the block variable being at state ∣0⟩.The success of this process can be amplified via Oblivious Amplitude Amplification. In this notebook, instead, we use a statevector simulator and project the result. We import two utility functions from hamiltonian_simulation_utils:
get_projected_state_vector: extracts the post-selected statevector from the execution results.
compare_quantum_classical_states: aligns the global phase and computes the overlap with the classically computed reference.
The polynomial approximation of the time evolution relies on the Jacobi–Anger expansion.For GQSP, we use the complex exponential form eitcos(x)=∑kikJk(t)eikx, implemented via poly_jacobi_anger_exp_cos. We then compute the GQSP rotation angles from this polynomial using gqsp_phases.
Note: The current implementation assumes that the block-encoding unitary UH is also Hermitian. For the non-Hermitian generalization, see the Technical Notes.
Given the block-encoding U(s,m,0)−H, we define the Szegedy quantum walk operator [2]:W≡Π∣0⟩mU(s,m,0)−H,where Π∣0⟩m is a reflection about the ∣0⟩ state of the block variable. As mentioned above, it has the key property that its spectrum is directly tied to the Hamiltonian’s eigenvalues:eigenvalues: e±iarccos(λ/s),eigenvectors: ∣φλ±⟩≡21(∣vλ⟩∣0⟩m±i∣⊥λ⟩),where ∣vλ⟩ is an eigenstate of H with eigenvalue λ.
As a sanity check before the main algorithm, we verify the Hamiltonian block-encoding: we apply UH on the initial state and check that the post-selected result matches (H/αˉ)∣ψ⟩ as expected.
We define a Quantum Struct for the GQSP block-encoding.The GQSP method adds one block qubit (block_gqsp) to the Hamiltonian block variable (block_ham).The data variable follows that of the Hamiltonian encoding.Applying GQSP requires a negative power of the walk operator, since the approximating polynomial P(z) is a Laurent polynomial that includes negative powers of z (corresponding to W−1).This is handled by the negative_power parameter.
The code in the rest of this section builds a model that applies the gqsp_hamiltonian_evolution function on the randomly prepared vector, synthesizes it, executes the resulting quantum program, and verifies the results.
Generalizing to Non-Hermitian Block-Encoding Unitaries
The current implementation assumes that the block-encoding unitary UH is also Hermitian.This assumption underlies the walk operator’s spectral properties.For a non-Hermitian block-encoding unitary, an analogous walk operator can be defined as W~≡UHTΠ∣0⟩mUHΠ∣0⟩m, which satisfies equivalent spectral properties.See Section 7.4 in Ref. [3] for details.