Benchmark lab for 1D quantum systems on a grid (Infinite Square Well / Harmonic Oscillator / Double Well), comparing VQE/VQD ansatzes and the impact of shots + noise.
This benchmark compares two VQE/VQD ansatz families:
efficient_su2(hardware-efficient): generic layers of single-qubit rotations + entanglers.hva(Hamiltonian Variational Ansatz): physics-informed layers built from the Hamiltonian’s structure.
Goal:
For simple 1D quantum systems (ISW / HO / Double Well), which ansatz gives the best first
k_statesenergies for the least circuit cost, and how do shots + noise degrade performance?
python -m venv qc-bench-venv
source qc-bench-venv/bin/activate
pip install -e .
qc-bench --help
qc-bench configs/isw.yaml
If qc-bench is not on your PATH, use:
python -m qcbench.runner --help
python -m qcbench.runner configs/isw.yaml
By default, results append to results/runs.parquet. Use --no-append to overwrite:
qc-bench configs/isw.yaml --no-append
Then open notebooks/01_figures.ipynb to plot from the results table.
Each run appends one row to results/runs.parquet with run settings, grid info, circuit cost, energies, and error metrics.
potential: string. Potential name (e.g.,isw,ho,doublewell).ansatz: string. Ansatz family (e.g.,efficient_su2,hva).reps: int. Ansatz repetition count / depth parameter.entanglement: string. Entanglement pattern (passed through to ansatz builder).backend: string."statevector"or"noisy".noise_strength: float or NaN. Noise parameter used for"noisy"runs.shots: int or NaN. Shot count used for"noisy"runs.seed: int. Random seed for reproducibility.k_states: int. Number of eigenstates requested (produces energy columns0..k_states-1).
-
L: float. Domain length. -
N: int. Number of interior grid points (physical Hilbert dimension). -
dx: float. Grid spacing. -
n_qubits: int. Smallest integer such that$2^{n_{\text{qubits}}} \ge N$ . -
hilbert_dim: int. Embedded qubit dimension, defined as$\mathrm{hilbert_dim} = 2^{n_{\text{qubits}}}$ . -
x_min,x_max: float. Min/max coordinates of the grid. -
hbar: float. The reduced Planck constant$\hbar$ used in the kinetic term. -
m: float. Mass$m$ used in the kinetic term.
depth: int. Circuit depth after construction (and transpilation if applicable in your workflow).two_qubit_count: int. Count of two-qubit gates (CX/CZ/SWAP/iSWAP/ECR/RXX/RYY/RZZ).num_parameters: int. Number of trainable circuit parameters.num_pauli_terms: int. Number of Pauli terms in the qubit Hamiltonian operator.
runtime_sec: float. Wall-clock runtime for the VQD call.eval_count: int or NaN. Optimizer evaluation count (if available from metadata).success: bool. Whether the optimizer reports success.
For i = 0..k_states-1 (ground state is i=0):
-
E{i}: VQD estimated energy for statei. (This is what you are benchmarking.) -
E_exact{i}: Energies from exact diagonalization of the padded qubit Hamiltonian, which is a$$2^{n_{\text{qubits}}} \times 2^{n_{\text{qubits}}}$$ matrix. -
E_err{i}: VQD error vs padded reference, defined asabs(E{i} - E_exact{i}).
Also always included (grid diagonalization):
-
E_grid{i}: Energies from exact diagonalization of the physical grid Hamiltonian, which is an$$N \times N$$ matrix. -
E_pad_err{i}: Padding mismatch, defined asabs(E_exact{i} - E_grid{i}).
Analytic (only when a closed-form exists and required params exist; e.g., ISW, HO with omega):
E_analytic{i}: Analytic (continuous-space) textbook energy level.E_analytic_err{i}: Discretization error, defined asabs(E_grid{i} - E_analytic{i}).
For i = 0..k_states-2:
gap_err_{i}: error in the energy gap between statesiandi+1.
padding_leakage_max: max leakage across the lowestk_statespadded eigenvectors.padding_leakage_mean: mean leakage across the lowestk_statespadded eigenvectors.
Leakage here means probability mass outside the original physical
QC-Bench tracks errors across three layers: continuous physics, grid discretization, and quantum execution.
- Definition: Closed-form energy in continuous space (no discretization).
- Why it matters: Physics “ground truth” (when it exists).
-
Example (Harmonic Oscillator):
$$E_n = \hbar\omega\left(n+\frac{1}{2}\right);\Rightarrow;E_0=\frac{1}{2}\hbar\omega.$$ (So you need the parameteromegato define the analytic energies.)
- Definition: Eigenvalue of the physical grid Hamiltonian.
- Why it matters: Best possible answer your grid model can produce (even with a perfect quantum solver).
- Definition: Eigenvalue of the final padded Hamiltonian used for qubits.
- Why it matters: The actual mathematical target that VQD is trying to match.
- Definition:
abs(E_exact{i} - E_grid{i}) - Why it matters: Detects whether padding/penalties are cleanly preserving the low-energy physical spectrum.
- Definition:
abs(E_grid{i} - E_analytic{i})(when analytic energies exist) - Why it matters: Tells you whether your grid resolution (
dx,N, domain size) is sufficient.
E{i}definition: The VQD-estimated energy for statei.E_err{i}definition:abs(E{i} - E_exact{i})- Why it matters: Captures optimization limits + sampling + noise + ansatz expressibility.
Definition:
- Why it matters: Excitation gaps are often more physically relevant than absolute energies.