View on GitHub
Open this notebook in GitHub to run it yourself
The idea
Starting from a reference state , real-time evolution generates the Krylov states Their span is a Krylov subspace that, provided has sufficient overlap with the true ground state, captures the low-energy physics, so diagonalizing restricted to that subspace gives a good ground-energy estimate. The sample-based twist avoids measuring overlaps with Hadamard tests. Instead we sample each in the computational basis, collect the set of observed bitstrings, and diagonalize projected onto . Informally, the main assumptions are (the full convergence analysis is considerably more intricate; see Theorem 1 of [1]):- Ground-state overlap. The reference needs appreciable overlap with the true ground state; the smaller the overlap, the more Krylov vectors and shots are needed.
- 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.
Time evolution: building the Krylov states
The quantum heart of SKQD is building the Krylov states . We approximate the evolution by a Suzuki–Trotter product, using Classiq’s built-insuzuki_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 coupled to bath sites . With spin , where and are the fermionic creation and annihilation operators, is the number operator, the impurity level, the on-site Coulomb interaction felt when the impurity is doubly occupied (repulsive for , the regime we use), the bath energies, and the impurity–bath hybridization (hopping). There are spin-orbitals, hence a register of qubits (one qubit per spin-orbital). We index modes in a spin-blocked layout, with orbital the impurity and the bath; spin (up), (down). We build as anopenfermion 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 bath sites with a symmetric bath (energies symmetric about zero) at the particle–hole symmetric point (), at half filling (three spin-up and three spin-down electrons). This is a 12-qubit model whose sector is 400-dimensional. The Anderson Hamiltonian conserves the number of electrons of each spin, so it is block-diagonal in the 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 () occupied up- (down-) orbitals. SKQD therefore targets the ground state within that sector. For our half-filled 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 is exactly when spin-orbital is occupied). The code below builds , 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 with appreciable overlap with the ground state (assumption 1 in the intro). A standard, cheap choice is the Hartree–Fock (HF) state.Output:
Output:
Assembling and synthesizing the circuit
We assemble the entry pointmain, in which we prepare the Hartree–Fock reference and evolve under , and
synthesize it.
The evolution time t is left as a classical parameter, so a single synthesis
yields a circuit we reuse at for each Krylov index .
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 , where 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 we evaluate the circuit at 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 Krylov states is the set that defines the subspace we diagonalize in the final diagonalization step. How many Krylov states , and how many shots per state, are enough? There is no simple rule: , the shot budget, the reference overlap , 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 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 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 of collected configurations spans a subspace; we build the Hamiltonian projected onto it, , and take its lowest eigenvalue. We compare our estimate against the exact ground-state energy computed earlier (by diagonalizing the full 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 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 ? We rank the collected configurations by how often they were sampled, keep the top , and diagonalize in that -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.