Skip to main content

View on GitHub

Open this notebook in GitHub to run it yourself
SKQD [1] estimates the ground-state energy of a Hamiltonian HH. It is an alternative to Quantum Phase Estimation (QPE), designed for pre-fault-tolerant hardware. QPE, the textbook quantum algorithm for eigenvalue estimation, is for now out of reach: it requires circuits far too deep for current, noisy hardware. This has motivated a search for shallower, near-term alternatives. One promising family is the subspace diagonalization algorithms, in which a quantum module identifies a low-dimensional subspace of the Hilbert space expected to contain most of the ground state’s weight, and a classical module then diagonalizes HH restricted to that subspace. These methods differ in how the quantum module builds the subspace. In Krylov quantum diagonalization (KQD) [2], it is spanned by time-evolving a reference state over a range of time intervals. In sample-based quantum diagonalization (SQD), it is spanned by sampling a reference state in the computational basis (see [3] for example). Sample-based Krylov quantum diagonalization (SKQD) [1], which we implement in this notebook, draws on both: a well-chosen reference state is time-evolved over several time intervals, and each evolved state is then sampled in the computational basis. The sampled bitstrings define the subspace in which we classically diagonalize HH. Like KQD, SKQD comes with a polynomial-time convergence guarantee (under certain assumptions we mention below), but it uses shallower circuits than KQD, and the sampling makes it more robust to noise. In this notebook we implement SKQD, using the single-impurity Anderson model (SIAM) [4] as a worked example.

The idea

Starting from a reference state ∣ψ0⟩|\psi_0\rangle, real-time evolution generates the Krylov states ∣ψk⟩=e−iH k Δt ∣ψ0⟩,k=0,1,…,D−1.|\psi_k\rangle = e^{-iH\,k\,\Delta t}\,|\psi_0\rangle, \qquad k = 0, 1, \dots, D-1 . Their span is a Krylov subspace that, provided ∣ψ0⟩|\psi_0\rangle has sufficient overlap with the true ground state, captures the low-energy physics, so diagonalizing HH restricted to that subspace gives a good ground-energy estimate. The sample-based twist avoids measuring overlaps with Hadamard tests. Instead we sample each ∣ψk⟩|\psi_k\rangle in the computational basis, collect the set S\mathcal{S} of observed bitstrings, and diagonalize HH projected onto span(S)\mathrm{span}(\mathcal{S}). Informally, the main assumptions are (the full convergence analysis is considerably more intricate; see Theorem 1 of [1]):
  1. Ground-state overlap. The reference ∣ψ0⟩|\psi_0\rangle needs appreciable overlap with the true ground state; the smaller the overlap, the more Krylov vectors and shots are needed.
  2. Ground-state sparsity. The ground state must be reasonably sparse in the computational basis, so that sampling actually collects the few configurations that carry its weight.
Complexity. Made quantitative (inverse-polynomial overlap and a polynomially sparse ground state), these assumptions yield a polynomial-time ground-energy estimate [1]. The notebook first builds a generic time-evolution core, then instantiates it on the SIAM example — constructing the Hamiltonian, mapping it to qubits, and preparing a Hartree–Fock reference — and finally samples the Krylov states and diagonalizes HH in the sampled subspace.

Time evolution: building the Krylov states

The quantum heart of SKQD is building the Krylov states ∣ψk⟩=e−iH (k Δt) ∣ψ0⟩|\psi_k\rangle = e^{-iH\,(k\,\Delta t)}\,|\psi_0\rangle. We approximate the evolution e−iHte^{-iHt} by a Suzuki–Trotter product, using Classiq’s built-in suzuki_trotter. The reference state enters through a pluggable state_prep argument so it can be swapped later; the concrete main is assembled further down.

The single-impurity Anderson model

The worked example is the single-impurity Anderson model [4]: one impurity orbital dd coupled to LL bath sites k=1,…,Lk = 1, \dots, L. With spin σ∈{↑,↓}\sigma \in \{\uparrow, \downarrow\}, H=ϵd∑σndσ  +  U nd↑nd↓  +  ∑k=1L∑σϵk nkσ  +  ∑k=1L∑σVk(cdσ†ckσ+ckσ†cdσ),H = \epsilon_d \sum_\sigma n_{d\sigma} \;+\; U\, n_{d\uparrow} n_{d\downarrow} \;+\; \sum_{k=1}^{L}\sum_\sigma \epsilon_k\, n_{k\sigma} \;+\; \sum_{k=1}^{L}\sum_\sigma V_k \left(c_{d\sigma}^\dagger c_{k\sigma} + c_{k\sigma}^\dagger c_{d\sigma}\right), where c†c^\dagger and cc are the fermionic creation and annihilation operators, n=c†cn = c^\dagger c is the number operator, ϵd\epsilon_d the impurity level, UU the on-site Coulomb interaction felt when the impurity is doubly occupied (repulsive for U>0U>0, the regime we use), ϵk\epsilon_k the bath energies, and VkV_k the impurity–bath hybridization (hopping). There are 2(L+1)2(L+1) spin-orbitals, hence a register of N=2(L+1)N = 2(L+1) qubits (one qubit per spin-orbital). We index modes in a spin-blocked layout, mode(o,σ)=σ (L+1)+o,\text{mode}(o, \sigma) = \sigma\,(L+1) + o, with orbital o=0o = 0 the impurity and o=1,…,Lo = 1, \dots, L the bath; spin σ=0\sigma = 0 (up), 11 (down). We build HH as an openfermion FermionOperator. Any other second-quantized Hamiltonian can be swapped in and fed to the time-evolution core above.

Mapping to a qubit Hamiltonian (Jordan–Wigner)

As the test case we take L=5L = 5 bath sites with a symmetric bath (energies symmetric about zero) at the particle–hole symmetric point (ϵd=−U/2\epsilon_d = -U/2), at half filling (three spin-up and three spin-down electrons). This is a 12-qubit model whose (3,3)(3,3) sector is 400-dimensional. The Anderson Hamiltonian conserves the number of electrons of each spin, so it is block-diagonal in the (n↑,n↓)(n_\uparrow, n_\downarrow) sectors. Our reference has definite occupation numbers (the Hartree–Fock state, defined below). Real-time evolution then keeps every Krylov state in that one sector, and every sampled bitstring has exactly n↑n_\uparrow (n↓n_\downarrow) occupied up- (down-) orbitals. SKQD therefore targets the ground state within that sector. For our half-filled (3,3)(3,3) choice at the particle–hole-symmetric point, this sector ground state coincides with the global ground state. We map this fermionic Hamiltonian to qubits with the Jordan–Wigner transformation, which assigns one qubit per spin-orbital (qubit ii is ∣1⟩|1\rangle exactly when spin-orbital ii is occupied). The code below builds HH, applies the mapping, and converts the result to the Qmod operator the time-evolution core expects.
Output:

The initial state (Hartree–Fock reference)

SKQD needs a reference state ∣ψ0⟩|\psi_0\rangle with appreciable overlap with the ground state (assumption 1 in the intro). A standard, cheap choice is the Hartree–Fock (HF) state.
Output:
For this test case the overlap between the HF state and the true ground state is ∣⟨HF ∣ ground⟩∣2≈0.10|\langle \mathrm{HF}\,|\,\mathrm{ground}\rangle|^2 \approx 0.10, which we now confirm by exact diagonalization. We also compute the exact ground-state energy — the benchmark we compare against later — and check how concentrated the ground state’s weight is in the computational basis (assumption 2, the sparsity that lets sampling work). All three are possible only at this small scale, and are not part of SKQD itself.
Output:

Assembling and synthesizing the circuit

We assemble the entry point main, in which we prepare the Hartree–Fock reference and evolve under HH, and synthesize it. The evolution time t is left as a classical parameter, so a single synthesis yields a circuit we reuse at t=k Δtt = k\,\Delta t for each Krylov index kk. How large should DELTA_T be? As a rule of thumb, the step should be small enough to resolve the spectrum: on the order of π/ΔE\pi/\Delta E, where ΔE=Emax⁡−Emin⁡\Delta E = E_{\max}-E_{\min} is the Hamiltonian’s spectral width (with too large a step, distinct eigenvalues may become indistinguishable). How does the Trotter accuracy influence the accuracy of the output? The goal of the time-evolution in SKQD is only to generate configurations. The energy itself comes from diagonalizing the exact Hamiltonian in the sampled subspace, so we don’t need precise dynamics, only enough accuracy to reach the ground-state-relevant configurations. For this reason a few Trotter repetitions suffice.
Output:

Sampling the Krylov states

Now we run the quantum part. For each Krylov index k=0,1,…,D−1k = 0, 1, \dots, D-1 we evaluate the circuit at t=k Δtt = k\,\Delta t and sample it in the computational basis. Each shot returns an electron configuration — a bitstring over the spin-orbitals. The union of all configurations observed across the DD Krylov states is the set S\mathcal{S} that defines the subspace we diagonalize in the final diagonalization step. How many Krylov states DD, and how many shots per state, are enough? There is no simple rule: DD, the shot budget, the reference overlap ∣⟨ψ0∣ground⟩∣2|\langle\psi_0|\mathrm{ground}\rangle|^2, the ground-state sparsity, and the target energy error are all tied together by SKQD’s convergence analysis — see Theorem 1 of [1]. Qualitatively, smaller overlap or a tighter target error demands more Krylov states and more shots. For this small model we simply pick values that converge comfortably. Although our model is small, we want it to behave like the real, at-scale regime, where the sector is far too large to enumerate. We therefore use a modest shot budget, keeping the collected set S\mathcal{S} a genuine subset of the 400-dimensional sector rather than all of it (with many more shots we would simply collect all 400 configurations and recover exact-sector diagonalization). We also apply an explicit particle-number post-selection: we keep only bitstrings in the (n↑,n↓)(n_\uparrow, n_\downarrow) sector. It discards nothing here since the simulator conserves particle number exactly, but on noisy hardware it removes samples that a bit-flip has knocked out of the correct sector.
Output:
Output:

Sample-based diagonalization

Finally we turn the sampled configurations into a ground-energy estimate. The set S\mathcal{S} of collected configurations spans a subspace; we build the Hamiltonian projected onto it, HSH_{\mathcal{S}}, and take its lowest eigenvalue. We compare our estimate against the exact ground-state energy E0E_0 computed earlier (by diagonalizing the full 2N2^N matrix).
Output:

Alternative: keep the top-k most-sampled configurations

The core SKQD algorithm above keeps all unique sampled configurations. A variant that can be used for noise robustness, as well as for reducing the cost of the classical diagonalization, is to keep only the configurations that were sampled most often. With good probability estimates from many shots, the top-ranked configurations are reliably the important ones. Here we keep the top k=30k = 30 and compare to the Hartree–Fock baseline and the exact energy. In this noiseless run, keeping fewer configurations can only raise the estimate (i.e. move it further above the true ground energy), since a larger subspace is always variationally lower. So keeping only the top-ranked configurations trades a little accuracy for a cheaper classical diagonalization; the real payoff comes on noisy hardware, where the rarely-sampled configurations that get discarded are largely noise-induced ones.
Output:

Convergence vs. subspace size

How many configurations do we actually need, and how does a small subspace compare to the cheap classical baseline — the Hartree–Fock energy ⟨HF∣H∣HF⟩\langle \mathrm{HF}|H|\mathrm{HF}\rangle? We rank the collected configurations by how often they were sampled, keep the top mm, and diagonalize in that mm-dimensional subspace. The left panel shows the absolute energy, bracketed between the HF baseline and the exact energy: SKQD starts at the HF level and, with only a handful of configurations, recovers most of the correlation energy HF misses. The right panel shows the error to the exact energy on a log scale, which exposes the continued convergence that the left panel hides once the curve visually merges with the exact line.
output

References

[1] J. Yu, J. Robledo Moreno, J. T. Iosue, L. Bertels, D. Claudino, B. Fuller, P. Groszkowski, T. S. Humble, P. Jurcevic, W. Kirby, T. A. Maier, M. Motta, B. Pokharel, A. Seif, A. Shehata, K. J. Sung, M. C. Tran, V. Tripathi, A. Mezzacapo, and K. Sharma, “Quantum-Centric Algorithm for Sample-Based Krylov Diagonalization”, arXiv:2501.09702 (2025). [2] N. Yoshioka, M. Amico, W. Kirby, P. Jurcevic, A. Dutt, B. Fuller, S. Garion, H. Haas, I. Hamamura, A. Ivrii, R. Majumdar, Z. Minev, M. Motta, B. Pokharel, P. Rivero, K. Sharma, C. J. Wood, A. Javadi-Abhari, and A. Mezzacapo, “Diagonalization of Large Many-Body Hamiltonians on a Quantum Processor”, arXiv:2407.14431 (2024). [3] J. Robledo-Moreno, M. Motta, H. Haas, A. Javadi-Abhari, P. Jurcevic, W. Kirby, S. Martiel, K. Sharma, S. Sharma, T. Shirakawa, I. Sitdikov, R.-Y. Sun, K. J. Sung, M. Takita, M. C. Tran, S. Yunoki, and A. Mezzacapo, “Chemistry Beyond the Scale of Exact Diagonalization on a Quantum-Centric Supercomputer”, Science Advances 11, eadu9991 (2025); arXiv:2405.05068. [4] P. W. Anderson, “Localized Magnetic States in Metals”, Phys. Rev. 124, 41 (1961).