Quantum Krylov Algorithm
Estimate ground-state energies by building a small Krylov subspace from time-evolved reference states and diagonalizing the projected Hamiltonian classically. It trades a much shallower quantum circuit for a single small classical generalized eigensolve.
The problem it solves
One of the central tasks in quantum chemistry and materials science is finding the
ground-state energy of a Hamiltonian H — its smallest eigenvalue. The
variational quantum eigensolver (VQE) approaches this by parameterizing a deep ansatz circuit and
repeatedly optimizing it to push the energy down; but deep circuits are easily swallowed by
decoherence on noisy hardware, and the optimization often stalls on barren plateaus. The quantum
Krylov method takes a different road: it does no variational optimization at all, and instead leans
on the classical power of linear algebra, using only shallow circuits to collect a little
information.
The intuition — spanning a good subspace with time evolution
Start from a reference state |ψ⟩ that is easy to prepare and has non-zero overlap with
the true ground state. Apply the time-evolution operator e−iHt for several different
durations to obtain a family of states
{ |ψ⟩, e−iHt|ψ⟩, e−2iHt|ψ⟩, … }
These states span a Krylov subspace. The trick is this: the time-evolution
operator shares its eigenstates with H, but stamps each eigencomponent with a different
phase rotation set by its eigenenergy. By forming linear combinations of this family, we can
constructively amplify the low-energy components and destructively suppress the high-energy ones. If the
reference state has sufficient nonzero overlap with the ground state, and the evolution times and
subspace dimension are chosen well, this Krylov subspace can effectively approximate the ground-state
direction — even though every individual generating state may still be far from it. All that remains is
to find the lowest-energy combination inside the subspace.
How it works — a generalized eigenproblem on the subspace
Minimizing the energy within the subspace reduces to solving a generalized eigenproblem
H c = E S c
Here there are two small matrices, with dimension equal to the subspace size (far smaller than the
full Hilbert space): the Hamiltonian matrix Hij = ⟨ψi|H|ψj⟩
and the overlap matrix Sij = ⟨ψi|ψj⟩. The matrix
S appears because the Krylov basis states are not orthogonal — they overlap one
another, so this is not an ordinary eigenproblem but a generalized one carrying the metric
S. The quantum computer is responsible for one thing only: estimating the entries of
these two matrices, ⟨ψi|ψj⟩ and ⟨ψi|H|ψj⟩, with the
Hadamard test. For a quantum-chemistry Hamiltonian, H is usually decomposed into a sum of
Pauli strings H = Σℓ hℓ Pℓ. What is actually measured are
the terms ⟨ψi|Pℓ|ψj⟩, then weighted by
hℓ and summed to give Hij. Solving
H c = E S c is then entirely a classical job, and its smallest
eigenvalue E is the ground-state energy estimate.
An honest look at ill-conditioning and noise
- The overlap matrix S is often badly ill-conditioned. The Krylov basis states
are highly similar to one another, which drives
Stoward singular with a large condition number. This means small errors in the entries ofHandSget amplified into large errors in the energy estimate — the thorniest difficulty of the method in practice. - Noisy matrix elements break the structure of the problem. The entries from the
Hadamard test carry sampling noise and hardware error; when
Sis ill-conditioned, that noise can rob the generalized eigenproblem of physical meaning (even yielding an "energy" below the true ground state). A common remedy is thresholding: discarding the directions ofSwith eigenvalues that are too small, to stabilize the solve. - Growing the subspace is a double-edged sword. Adding more time-evolved states
can in principle improve accuracy, but it also worsens the ill-conditioning of
S. The usable subspace dimension is often modest in practice. - It still needs reliable time evolution. The whole method presupposes a faithful hardware implementation of e−iHt; errors from its Trotter–Suzuki decomposition seep directly into the matrix elements and thus into the final energy.
The algorithm, step by step
- Choose a reference state
|ψ⟩that is easy to prepare and overlaps the ground state. - Generate the Krylov basis {|ψ⟩, e−iHt|ψ⟩, …} from a set of evolution times.
- Estimate the matrix elements Sij and Hij with the Hadamard test.
- Classically solve the generalized eigenproblem H c = E S c (thresholding
Sif needed to stabilize it). - Take the smallest eigenvalue
Eas the ground-state energy estimate.
Seeing it in code
Read the snippet below against the theory above: the double loop fills the overlap matrix
S and Hamiltonian matrix H element by element, where
qalgora_overlap estimates ⟨ψi|ψj⟩ with the Hadamard test and
qalgora_matrix_element estimates ⟨ψi|H|ψj⟩ with H
inserted; finally scipy.linalg.eigh(H, S, …) solves exactly the generalized eigenproblem
H c = E S c, and energies[0] is the ground-state energy estimate.
import qalgora
import numpy as np
# overlap S_ij = <psi_i|psi_j> and H_ij = <psi_i|H|psi_j>
# estimated on hardware with the Hadamard test
dim = 4
S = np.zeros((dim, dim), dtype=complex)
H = np.zeros((dim, dim), dtype=complex)
for i in range(dim):
for j in range(dim):
S[i, j] = qalgora_overlap(i, j) # Hadamard test
H[i, j] = qalgora_matrix_element(i, j) # Hadamard test with H
from scipy.linalg import eigh
energies = eigh(H, S, eigvals_only=True) # generalized eigenproblem
print("ground-state estimate:", energies[0])
量子 Krylov 算法
通过对若干时间演化的参考态构建一个小型 Krylov 子空间,再在经典端对投影后的哈密顿量做对角化,从而估算基态能量。它用浅得多的量子线路换取一次小规模的经典广义本征求解。
它解决的问题
量子化学与材料科学中最核心的任务之一,是求某个哈密顿量 H 的基态能量——即其最小本征值。变分量子本征求解器(VQE)的做法是参数化一个深层拟设线路,再反复优化以压低能量;但深层线路在含噪硬件上极易被退相干吞噬,且优化常陷入贫瘠高原。量子 Krylov 走的是另一条路:完全不做变分优化,而是借线性代数的经典威力,仅用浅线路收集少量信息。
直觉 用时间演化张成一个好子空间
取一个容易制备、且与真实基态有非零交叠的参考态 |ψ⟩。对它施加不同时长的时间演化算子 e−iHt,得到一族态
{ |ψ⟩, e−iHt|ψ⟩, e−2iHt|ψ⟩, … }
这些态张成一个Krylov 子空间。其中的奥妙在于:时间演化算子与 H 共享同一组本征态,但会按本征能量给每个本征分量赋上不同的相位旋转。于是把这族态线性组合起来,便能相长地放大低能分量、相消地压低高能分量。如果参考态与基态有足够非零交叠,并且演化时间与子空间维数选择得当,这个 Krylov 子空间可以有效逼近基态方向——哪怕每一个生成态本身离基态都还很远。我们要做的,就是在这个子空间内找到能量最低的那个组合。
原理 投影到子空间的广义本征问题
在子空间内最小化能量,归结为求解一个广义本征问题
H c = E S c
这里有两个小矩阵,维数等于子空间大小(远小于完整希尔伯特空间):哈密顿量矩阵 Hij = ⟨ψi|H|ψj⟩,与交叠矩阵 Sij = ⟨ψi|ψj⟩。S 之所以出现,是因为这些 Krylov 基态并不正交——它们彼此交叠,所以这不是普通本征问题,而是带度规 S 的广义本征问题。量子计算机只负责一件事:用 Hadamard 测试估出这两个矩阵的各个元素 ⟨ψi|ψj⟩ 与 ⟨ψi|H|ψj⟩。对量子化学哈密顿量,H 通常分解为 Pauli 字符串之和 H = Σℓ hℓ Pℓ。实际测量的是各项 ⟨ψi|Pℓ|ψj⟩,再按系数 hℓ 加权求和得到 Hij。求解 H c = E S c 则完全是经典端的工作,其最小本征值 E 即基态能量估计。
诚实地看待病态与噪声
- 交叠矩阵 S 往往严重病态。Krylov 基态彼此高度相似,使 S 接近奇异、条件数很大。这意味着 H 与 S 元素中的微小误差,会被放大成能量估计中的巨大误差——这是该方法实践中最棘手的难点。
- 含噪的矩阵元会破坏问题结构。Hadamard 测试得到的元素带有采样噪声与硬件误差;当 S 病态时,这些噪声可能让广义本征问题失去物理意义(甚至给出低于真实基态的"能量")。常用对策是阈值化:丢弃 S 中过小的本征值方向,以稳定求解。
- 子空间增大是一把双刃剑。加入更多时间演化态原则上能提高精度,却也加剧 S 的病态。实际可用的子空间维数往往不大。
- 它仍需可靠的时间演化。整个方法的前提是能在硬件上忠实实现 e−iHt;其 Trotter–Suzuki 分解的误差会直接渗入矩阵元,进而影响最终能量。
算法逐步拆解
- 选一个易制备、且与基态有交叠的参考态
|ψ⟩。 - 用一组演化时长生成 Krylov 基 {|ψ⟩, e−iHt|ψ⟩, …}。
- 用 Hadamard 测试估出矩阵元 Sij 与 Hij。
- 经典求解广义本征问题 H c = E S c(必要时对 S 做阈值化以稳定)。
- 取最小本征值 E 作为基态能量估计。
对照代码理解
请对照上文原理来读下面这段:双重循环逐元素填充交叠矩阵 S 与哈密顿量矩阵 H,其中 qalgora_overlap 用 Hadamard 测试估 ⟨ψi|ψj⟩,qalgora_matrix_element 估带 H 的 ⟨ψi|H|ψj⟩;最后 scipy.linalg.eigh(H, S, …) 求解的正是广义本征问题 H c = E S c,energies[0] 即基态能量估计。
import qalgora
import numpy as np
# overlap S_ij = <psi_i|psi_j> and H_ij = <psi_i|H|psi_j>
# estimated on hardware with the Hadamard test
dim = 4
S = np.zeros((dim, dim), dtype=complex)
H = np.zeros((dim, dim), dtype=complex)
for i in range(dim):
for j in range(dim):
S[i, j] = qalgora_overlap(i, j) # Hadamard test
H[i, j] = qalgora_matrix_element(i, j) # Hadamard test with H
from scipy.linalg import eigh
energies = eigh(H, S, eigvals_only=True) # generalized eigenproblem
print("ground-state estimate:", energies[0])